[Pixelle-commit] SF.net SVN: pixelle: [54] trunk/pixelle/src/com/mebigfatguy/pixelle
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2008-06-22 15:06:17
|
Revision: 54
http://pixelle.svn.sourceforge.net/pixelle/?rev=54&view=rev
Author: dbrosius
Date: 2008-06-22 08:06:22 -0700 (Sun, 22 Jun 2008)
Log Message:
-----------
hook up the out of bounds color
Modified Paths:
--------------
trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleEval.java
trunk/pixelle/src/com/mebigfatguy/pixelle/dialogs/PixelleOptionsDialog.java
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleEval.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleEval.java 2008-06-22 14:45:54 UTC (rev 53)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleEval.java 2008-06-22 15:06:22 UTC (rev 54)
@@ -18,6 +18,7 @@
*/
package com.mebigfatguy.pixelle;
+import java.awt.Color;
import java.awt.image.DataBuffer;
public abstract class PixelleEval {
@@ -44,10 +45,41 @@
public double getValue(int x, int y, char pixelSpec) {
/* in the future, allow customization of out of bounds indices */
- if ((x < 0) || (x >= width))
- return 1.0;
- if ((y < 0) || (y >= height))
- return 1.0;
+ if (((x < 0) || (x >= width)) || ((y < 0) || (y >= height))) {
+ switch (oobOption) {
+ case SpecifiedColor:
+ Color c = oobOption.getColor();
+ switch (pixelSpec) {
+ case 'r':
+ return c.getRed();
+ case 'g':
+ return c.getGreen();
+ case 'b':
+ return c.getBlue();
+ case 't':
+ return 1.0;
+ case 's':
+ default:
+ return 0.0;
+ }
+
+ case BorderColor:
+ if (x < 0)
+ x = 0;
+ else if (x >= width)
+ x = width - 1;
+ if (y < 0)
+ y = 0;
+ else if (y >= height)
+ y = height - 1;
+ break;
+
+ case WrapColor:
+ x %= width;
+ y %= height;
+ break;
+ }
+ }
switch (pixelSpec) {
case 'r':
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/dialogs/PixelleOptionsDialog.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/dialogs/PixelleOptionsDialog.java 2008-06-22 14:45:54 UTC (rev 53)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/dialogs/PixelleOptionsDialog.java 2008-06-22 15:06:22 UTC (rev 54)
@@ -53,17 +53,27 @@
private JButton ok = new JButton(PixelleBundle.getString(PixelleBundle.OK));
private JButton cancel = new JButton(PixelleBundle.getString(PixelleBundle.CANCEL));
private boolean okClicked = false;
+ private Color color;
private OutOfBoundsOption oobOption;
public PixelleOptionsDialog(PixelleFrame owner, OutOfBoundsOption option) {
super(owner, PixelleBundle.getString(PixelleBundle.PIXEL_OPTIONS));
oobOption = option;
+ color = oobOption.getColor();
initComponents();
initListeners();
pack();
}
public boolean isOK() {
+ if (colorBox.isSelected()) {
+ oobOption = OutOfBoundsOption.SpecifiedColor;
+ oobOption.setColor(color);
+ }
+ else if (borderColorBox.isSelected())
+ oobOption = OutOfBoundsOption.BorderColor;
+ else
+ oobOption = OutOfBoundsOption.WrapColor;
return okClicked;
}
@@ -82,7 +92,7 @@
GuiUtils.sizeUniformly(GuiUtils.Sizing.Height, colorBox, colorButton, borderColorBox, wrappedColorBox);
- colorButton.setColor(oobOption.getColor());
+ colorButton.setColor(color);
JPanel colorP = new JPanel();
colorP.setLayout(new BoxLayout(colorP, BoxLayout.X_AXIS));
@@ -158,9 +168,9 @@
colorButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
colorBox.setSelected(true);
- Color chosenColor = JColorChooser.showDialog(PixelleOptionsDialog.this, PixelleBundle.getString(PixelleBundle.PICK_COLOR), oobOption.getColor());
+ Color chosenColor = JColorChooser.showDialog(PixelleOptionsDialog.this, PixelleBundle.getString(PixelleBundle.PICK_COLOR), color);
if (chosenColor != null) {
- oobOption.setColor(chosenColor);
+ color = chosenColor;
colorButton.setColor(chosenColor);
colorButton.repaint();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|