[Pixelle-commit] SF.net SVN: pixelle:[200] trunk/pixelle/src/com/mebigfatguy/pixelle
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2008-11-20 06:16:43
|
Revision: 200
http://pixelle.svn.sourceforge.net/pixelle/?rev=200&view=rev
Author: dbrosius
Date: 2008-11-20 06:16:41 +0000 (Thu, 20 Nov 2008)
Log Message:
-----------
initial split out of RGB and GS PixelleComponent
Modified Paths:
--------------
trunk/pixelle/src/com/mebigfatguy/pixelle/AlgorithmArchiver.java
trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleBundle.java
trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleTransformer.java
trunk/pixelle/src/com/mebigfatguy/pixelle/dialogs/PixelleExpressionDialog.java
trunk/pixelle/src/com/mebigfatguy/pixelle/resources/pixelle.properties
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/AlgorithmArchiver.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/AlgorithmArchiver.java 2008-11-20 06:07:08 UTC (rev 199)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/AlgorithmArchiver.java 2008-11-20 06:16:41 UTC (rev 200)
@@ -62,12 +62,12 @@
private static AlgorithmArchiver archiver = new AlgorithmArchiver();
- private Map<String, Map<String, Map<PixelleComponent, String>>> systemAlgorithms;
- private Map<String, Map<String, Map<PixelleComponent, String>>> userAlgorithms;
+ private final Map<String, Map<String, Map<RGBPixelleComponent, String>>> systemAlgorithms;
+ private final Map<String, Map<String, Map<RGBPixelleComponent, String>>> userAlgorithms;
private AlgorithmArchiver() {
- systemAlgorithms = new HashMap<String, Map<String, Map<PixelleComponent, String>>>();
- userAlgorithms = new HashMap<String, Map<String, Map<PixelleComponent, String>>>();
+ systemAlgorithms = new HashMap<String, Map<String, Map<RGBPixelleComponent, String>>>();
+ userAlgorithms = new HashMap<String, Map<String, Map<RGBPixelleComponent, String>>>();
loadSystemAlgorithms();
loadUserAlgorithms();
}
@@ -76,7 +76,7 @@
return archiver;
}
- public JPopupMenu getAlgorithmDisplayPopup(ActionListener l) {
+ public JPopupMenu getAlgorithmDisplayPopup(ImageType type, ActionListener l) {
JPopupMenu m = new JPopupMenu(PixelleBundle.getString(PixelleBundle.PIXEL_ALGORITHM));
populateMenuAlgorithms(m, systemAlgorithms, l);
populateMenuAlgorithms(m, userAlgorithms, l);
@@ -84,8 +84,8 @@
return m;
}
- private void populateMenuAlgorithms(JPopupMenu menu, Map<String, Map<String, Map<PixelleComponent, String>>> algorithms, ActionListener l) {
- for (final Map.Entry<String, Map<String, Map<PixelleComponent, String>>> entry : algorithms.entrySet()) {
+ private void populateMenuAlgorithms(JPopupMenu menu, Map<String, Map<String, Map<RGBPixelleComponent, String>>> algorithms, ActionListener l) {
+ for (final Map.Entry<String, Map<String, Map<RGBPixelleComponent, String>>> entry : algorithms.entrySet()) {
String groupName = entry.getKey();
if (!CURRENT.equals(groupName)) {
JMenu group = new JMenu(groupName);
@@ -100,10 +100,10 @@
}
}
- public Map<PixelleComponent, String> getAlgorithm(String groupName, String algorithmName) {
- Map<String, Map<PixelleComponent, String>> group = systemAlgorithms.get(groupName);
+ public Map<? extends Enum, String> getAlgorithm(ImageType type, String groupName, String algorithmName) {
+ Map<String, Map<RGBPixelleComponent, String>> group = systemAlgorithms.get(groupName);
if (group != null) {
- Map<PixelleComponent, String> algo = group.get(algorithmName);
+ Map<RGBPixelleComponent, String> algo = group.get(algorithmName);
if (algo != null)
return algo;
}
@@ -113,7 +113,7 @@
throw new IllegalArgumentException("Unknown group name " + groupName);
}
- Map<PixelleComponent, String> algo = group.get(algorithmName);
+ Map<RGBPixelleComponent, String> algo = group.get(algorithmName);
if (algo == null) {
throw new IllegalArgumentException("Unknown algorithm name " + algorithmName);
}
@@ -126,26 +126,26 @@
return userAlgorithms.keySet().toArray(new String[userAlgorithms.size()]);
}
- public void addAlgorithm(String groupName, String algorithmName, Map<PixelleComponent, String> algorithm) {
- Map<String, Map<PixelleComponent, String>> group = userAlgorithms.get(groupName);
+ public void addAlgorithm(String groupName, String algorithmName, Map<RGBPixelleComponent, String> algorithm) {
+ Map<String, Map<RGBPixelleComponent, String>> group = userAlgorithms.get(groupName);
if (group == null) {
- group = new HashMap<String, Map<PixelleComponent, String>>();
+ group = new HashMap<String, Map<RGBPixelleComponent, String>>();
userAlgorithms.put(groupName, group);
}
- group.put(algorithmName, new HashMap<PixelleComponent, String>(algorithm));
+ group.put(algorithmName, new HashMap<RGBPixelleComponent, String>(algorithm));
}
- public void setCurrent(Map<PixelleComponent, String> algorithm) {
+ public void setCurrent(Map<RGBPixelleComponent, String> algorithm) {
addAlgorithm(AlgorithmArchiver.CURRENT, AlgorithmArchiver.CURRENT, algorithm);
}
- public Map<PixelleComponent, String> getCurrent() {
- return getAlgorithm(AlgorithmArchiver.CURRENT, AlgorithmArchiver.CURRENT);
+ public Map<? extends Enum, String> getCurrent(ImageType type) {
+ return getAlgorithm(type, AlgorithmArchiver.CURRENT, AlgorithmArchiver.CURRENT);
}
public void removeAlgorithm(String group, String name) {
- Map<String, Map<PixelleComponent, String>> algoGroup = userAlgorithms.get(group);
+ Map<String, Map<RGBPixelleComponent, String>> algoGroup = userAlgorithms.get(group);
if (algoGroup != null) {
algoGroup.remove(name);
}
@@ -197,7 +197,7 @@
}
- private void writeAlgorithms(OutputStream is, Map<String, Map<String, Map<PixelleComponent, String>>> algorithms) throws IOException {
+ private void writeAlgorithms(OutputStream is, Map<String, Map<String, Map<RGBPixelleComponent, String>>> algorithms) throws IOException {
PrintWriter pw = null;
try {
pw = new PrintWriter(new OutputStreamWriter(is));
@@ -205,13 +205,13 @@
pw.println(" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'");
pw.println(" xsi:schemaLocation='/com/mebigfatguy/pixelle/resources/algorithms.xsd'>");
- for (Map.Entry<String, Map<String, Map<PixelleComponent, String>>> group : algorithms.entrySet()) {
+ for (Map.Entry<String, Map<String, Map<RGBPixelleComponent, String>>> group : algorithms.entrySet()) {
pw.println(" <group name='" + group.getKey() + "'>");
- for (Map.Entry<String, Map<PixelleComponent, String>> algorithm : group.getValue().entrySet()) {
+ for (Map.Entry<String, Map<RGBPixelleComponent, String>> algorithm : group.getValue().entrySet()) {
pw.println(" <algorithm name='" + algorithm.getKey() + "'>");
- for (Map.Entry<PixelleComponent, String> component : algorithm.getValue().entrySet()) {
+ for (Map.Entry<RGBPixelleComponent, String> component : algorithm.getValue().entrySet()) {
pw.println(" <component name='" + component.getKey().name().toLowerCase() + "'>");
pw.println(" " + component.getValue());
pw.println(" </component>");
@@ -228,21 +228,21 @@
}
}
- private void parseAlgorithms(InputStream is, final Map<String, Map<String, Map<PixelleComponent, String>>> algorithms) throws IOException, SAXException {
+ private void parseAlgorithms(InputStream is, final Map<String, Map<String, Map<RGBPixelleComponent, String>>> algorithms) throws IOException, SAXException {
XMLReader r = XMLReaderFactory.createXMLReader();
r.setContentHandler(new DefaultHandler() {
- Map<String, Map<PixelleComponent, String>> currentGroup = null;
- Map<PixelleComponent, String> currentAlgorithm = null;
+ Map<String, Map<RGBPixelleComponent, String>> currentGroup = null;
+ Map<RGBPixelleComponent, String> currentAlgorithm = null;
String currentComponentName = null;
StringBuilder algorithmText = null;
@Override
public void startElement(String uri, String localName, String qName, Attributes atts) {
if (GROUP.equals(localName)) {
- currentGroup = new HashMap<String, Map<PixelleComponent, String>>();
+ currentGroup = new HashMap<String, Map<RGBPixelleComponent, String>>();
algorithms.put(atts.getValue(NAME), currentGroup);
} else if (ALGORITHM.equals(localName)) {
- currentAlgorithm = new EnumMap<PixelleComponent, String>(PixelleComponent.class);
+ currentAlgorithm = new EnumMap<RGBPixelleComponent, String>(RGBPixelleComponent.class);
currentGroup.put(atts.getValue(NAME), currentAlgorithm);
} else if (COMPONENT.equals(localName)) {
currentComponentName = atts.getValue(NAME);
@@ -260,7 +260,7 @@
@Override
public void endElement(String uri, String localName, String qName) {
if (COMPONENT.equals(localName)) {
- PixelleComponent pc = PixelleComponent.valueOf(currentComponentName.toUpperCase());
+ RGBPixelleComponent pc = RGBPixelleComponent.valueOf(currentComponentName.toUpperCase());
currentAlgorithm.put(pc, algorithmText.toString().trim());
algorithmText = null;
currentComponentName = null;
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleBundle.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleBundle.java 2008-11-20 06:07:08 UTC (rev 199)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleBundle.java 2008-11-20 06:16:41 UTC (rev 200)
@@ -60,6 +60,7 @@
public static final String RED_FORMULA = "formula.red";
public static final String GREEN_FORMULA = "formula.green";
public static final String BLUE_FORMULA = "formula.blue";
+ public static final String BLACK_FORMULA = "formula.black";
public static final String TRANSPARENCY_FORMULA = "formula.transparency";
public static final String SELECTION_FORMULA = "formula.selection";
public static final String PIXEL_ALGORITHMS = "title.algorithms";
@@ -68,6 +69,7 @@
public static final String RED_LABEL = "label.red";
public static final String GREEN_LABEL = "label.green";
public static final String BLUE_LABEL = "label.blue";
+ public static final String BLACK_LABEL = "label.black";
public static final String TRANSPARENCY_LABEL = "label.transparency";
public static final String SELECTION_LABEL = "label.selection";
public static final String PIXEL_OPTIONS = "title.pixel_options";
@@ -85,6 +87,8 @@
public static final String Y = "label.y";
public static final String COLOR = "label.color";
public static final String INSPECTOR_TOOLTIP = "tooltip.inspector";
+ public static final String RGB = "label.rgb";
+ public static final String GRAYSCALE = "label.grayscale";
private static ResourceBundle rb = ResourceBundle.getBundle("com/mebigfatguy/pixelle/resources/pixelle");
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleTransformer.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleTransformer.java 2008-11-20 06:07:08 UTC (rev 199)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleTransformer.java 2008-11-20 06:16:41 UTC (rev 200)
@@ -40,15 +40,15 @@
*/
public class PixelleTransformer {
- private PixelleImage srcImage;
- private Map<PixelleComponent, String> algorithms = null;
+ private final PixelleImage srcImage;
+ private Map<RGBPixelleComponent, String> algorithms = null;
/**
* constructions a transformer given a source bitmap and algorithms
* @param image the source image
* @param algos the algorithms for the color components
*/
- public PixelleTransformer(PixelleImage image, Map<PixelleComponent, String> algos) {
+ public PixelleTransformer(PixelleImage image, Map<RGBPixelleComponent, String> algos) {
srcImage = image;
algorithms = algos;
}
@@ -58,13 +58,13 @@
*
* @return a set of transformation algorithms
*/
- public static Map<PixelleComponent, String> getSampleTransform() {
- Map<PixelleComponent, String> algorithms = new EnumMap<PixelleComponent, String>(PixelleComponent.class);
- algorithms.put(PixelleComponent.RED, "x");
- algorithms.put(PixelleComponent.GREEN, "y");
- algorithms.put(PixelleComponent.BLUE, "abs((width/2) - x)");
- algorithms.put(PixelleComponent.TRANSPARENCY, "((x < 10) || (x >= (width - 10)) || (y < 10) || (y >= (height - 10))) ? 180 : 255");
- algorithms.put(PixelleComponent.SELECTION, "0");
+ public static Map<RGBPixelleComponent, String> getSampleTransform() {
+ Map<RGBPixelleComponent, String> algorithms = new EnumMap<RGBPixelleComponent, String>(RGBPixelleComponent.class);
+ algorithms.put(RGBPixelleComponent.RED, "x");
+ algorithms.put(RGBPixelleComponent.GREEN, "y");
+ algorithms.put(RGBPixelleComponent.BLUE, "abs((width/2) - x)");
+ algorithms.put(RGBPixelleComponent.TRANSPARENCY, "((x < 10) || (x >= (width - 10)) || (y < 10) || (y >= (height - 10))) ? 180 : 255");
+ algorithms.put(RGBPixelleComponent.SELECTION, "0");
return algorithms;
}
/**
@@ -94,7 +94,7 @@
}
});
- for (Map.Entry<PixelleComponent, String> entry : algorithms.entrySet()) {
+ for (Map.Entry<RGBPixelleComponent, String> entry : algorithms.entrySet()) {
currentComponent = entry.getKey().name();
currentAlgorithm = entry.getValue();
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/dialogs/PixelleExpressionDialog.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/dialogs/PixelleExpressionDialog.java 2008-11-20 06:07:08 UTC (rev 199)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/dialogs/PixelleExpressionDialog.java 2008-11-20 06:16:41 UTC (rev 200)
@@ -39,45 +39,72 @@
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
+import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import com.mebigfatguy.pixelle.AlgorithmArchiver;
+import com.mebigfatguy.pixelle.GrayscalePixelleComponent;
+import com.mebigfatguy.pixelle.ImageType;
import com.mebigfatguy.pixelle.PixelleBundle;
-import com.mebigfatguy.pixelle.PixelleComponent;
import com.mebigfatguy.pixelle.PixelleFrame;
+import com.mebigfatguy.pixelle.RGBPixelleComponent;
import com.mebigfatguy.pixelle.utils.GuiUtils;
public class PixelleExpressionDialog extends JDialog {
private static final long serialVersionUID = -4273352119079307059L;
- private final Map<PixelleComponent, JLabel> lhs = new EnumMap<PixelleComponent, JLabel>(PixelleComponent.class);
+ private final Map<RGBPixelleComponent, JLabel> rgbLHS = new EnumMap<RGBPixelleComponent, JLabel>(RGBPixelleComponent.class);
{
- for (PixelleComponent comp : PixelleComponent.values()) {
- lhs.put(comp, new JLabel(PixelleBundle.getString("formula." + comp.name().toLowerCase()) + " = "));
+ for (RGBPixelleComponent comp : RGBPixelleComponent.values()) {
+ rgbLHS.put(comp, new JLabel(PixelleBundle.getString("formula." + comp.name().toLowerCase()) + " = "));
}
};
- private final Map<PixelleComponent, JTextField> editor = new EnumMap<PixelleComponent, JTextField>(PixelleComponent.class);
+ private final Map<RGBPixelleComponent, JTextField> rgbEditor = new EnumMap<RGBPixelleComponent, JTextField>(RGBPixelleComponent.class);
{
- for (PixelleComponent comp : PixelleComponent.values()) {
- editor.put(comp, new JTextField(PixelleBundle.getString("formula." + comp.name().toLowerCase()), 50));
+ for (RGBPixelleComponent comp : RGBPixelleComponent.values()) {
+ rgbEditor.put(comp, new JTextField(PixelleBundle.getString("formula." + comp.name().toLowerCase()), 50));
}
};
- private final Map<PixelleComponent, JLabel> labels = new EnumMap<PixelleComponent, JLabel>(PixelleComponent.class);
+ private final Map<RGBPixelleComponent, JLabel> rgbLabels = new EnumMap<RGBPixelleComponent, JLabel>(RGBPixelleComponent.class);
{
- for (PixelleComponent comp : PixelleComponent.values()) {
- labels.put(comp, new JLabel(PixelleBundle.getString("label." + comp.name().toLowerCase())));
+ for (RGBPixelleComponent comp : RGBPixelleComponent.values()) {
+ rgbLabels.put(comp, new JLabel(PixelleBundle.getString("label." + comp.name().toLowerCase())));
}
};
+ private final Map<GrayscalePixelleComponent, JLabel> gsLHS = new EnumMap<GrayscalePixelleComponent, JLabel>(GrayscalePixelleComponent.class);
+ {
+ for (GrayscalePixelleComponent comp : GrayscalePixelleComponent.values()) {
+ gsLHS.put(comp, new JLabel(PixelleBundle.getString("formula." + comp.name().toLowerCase()) + " = "));
+ }
+ };
+
+ private final Map<GrayscalePixelleComponent, JTextField> gsEditor = new EnumMap<GrayscalePixelleComponent, JTextField>(GrayscalePixelleComponent.class);
+ {
+ for (GrayscalePixelleComponent comp : GrayscalePixelleComponent.values()) {
+ gsEditor.put(comp, new JTextField(PixelleBundle.getString("formula." + comp.name().toLowerCase()), 50));
+ }
+ };
+
+ private final Map<GrayscalePixelleComponent, JLabel> gsLabels = new EnumMap<GrayscalePixelleComponent, JLabel>(GrayscalePixelleComponent.class);
+ {
+ for (GrayscalePixelleComponent comp : GrayscalePixelleComponent.values()) {
+ gsLabels.put(comp, new JLabel(PixelleBundle.getString("label." + comp.name().toLowerCase())));
+ }
+ };
+
+
PixelleFrame frame;
JButton ok;
JButton cancel;
JButton reset;
- JTextField selectedAlgorithm;
- JPopupMenu savedAlgorithms;
+ JTextField selectedRGBAlgorithm;
+ JPopupMenu savedRGBAlgorithms;
+ JTextField selectedGSAlgorithm;
+ JPopupMenu savedGSAlgorithms;
JButton save;
JButton delete;
@@ -94,10 +121,10 @@
return clickedOK;
}
- public Map<PixelleComponent, String> getAlgorithms() {
- Map<PixelleComponent, String> algorithms = new EnumMap<PixelleComponent, String>(PixelleComponent.class);
- for (PixelleComponent comp : PixelleComponent.values()) {
- algorithms.put(comp, editor.get(comp).getText());
+ public Map<RGBPixelleComponent, String> getAlgorithms() {
+ Map<RGBPixelleComponent, String> algorithms = new EnumMap<RGBPixelleComponent, String>(RGBPixelleComponent.class);
+ for (RGBPixelleComponent comp : RGBPixelleComponent.values()) {
+ algorithms.put(comp, rgbEditor.get(comp).getText());
}
return algorithms;
}
@@ -114,6 +141,38 @@
cp.setLayout(new BorderLayout(4, 4));
+ JTabbedPane tabbedPane = new JTabbedPane();
+ cp.add(tabbedPane, BorderLayout.CENTER);
+
+ tabbedPane.add(PixelleBundle.getString(PixelleBundle.RGB), buildRGBPane());
+ tabbedPane.add(PixelleBundle.getString(PixelleBundle.GRAYSCALE), buildGrayscalePanel());
+
+ {
+ JPanel ctlPanel = new JPanel();
+ ctlPanel.setLayout(new BoxLayout(ctlPanel, BoxLayout.X_AXIS));
+ ctlPanel.add(Box.createHorizontalStrut(10));
+ ctlPanel.add(reset);
+ ctlPanel.add(Box.createHorizontalStrut(10));
+ ctlPanel.add(save);
+ ctlPanel.add(Box.createHorizontalStrut(10));
+ ctlPanel.add(delete);
+ ctlPanel.add(Box.createHorizontalGlue());
+ ctlPanel.add(ok);
+ ctlPanel.add(Box.createHorizontalStrut(10));
+ ctlPanel.add(cancel);
+ ctlPanel.add(Box.createHorizontalStrut(10));
+ ctlPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
+ cp.add(ctlPanel, BorderLayout.SOUTH);
+ }
+
+ pack();
+ }
+
+ private JPanel buildRGBPane() {
+
+ JPanel rgbPanel = new JPanel();
+ rgbPanel.setLayout(new BoxLayout(rgbPanel, BoxLayout.Y_AXIS));
+
{
JPanel optionsPanel = new JPanel();
optionsPanel.setLayout(new BoxLayout(optionsPanel, BoxLayout.X_AXIS));
@@ -121,91 +180,142 @@
JLabel l = new JLabel(PixelleBundle.getString(PixelleBundle.PIXEL_ALGORITHM));
optionsPanel.add(l);
optionsPanel.add(Box.createHorizontalStrut(10));
- selectedAlgorithm = new JTextField(PixelleBundle.getString(PixelleBundle.UNTITLED));
- selectedAlgorithm.setEditable(false);
- optionsPanel.add(selectedAlgorithm);
+ selectedRGBAlgorithm = new JTextField(PixelleBundle.getString(PixelleBundle.UNTITLED));
+ selectedRGBAlgorithm.setEditable(false);
+ optionsPanel.add(selectedRGBAlgorithm);
optionsPanel.add(Box.createHorizontalStrut(10));
- savedAlgorithms = AlgorithmArchiver.getArchiver().getAlgorithmDisplayPopup(new ActionListener() {
+ savedRGBAlgorithms = AlgorithmArchiver.getArchiver().getAlgorithmDisplayPopup(ImageType.RGB, new ActionListener() {
public void actionPerformed(ActionEvent ae) {
JMenuItem item = (JMenuItem)ae.getSource();
String algorithmName = item.getText();
String groupName = (String)item.getClientProperty(AlgorithmArchiver.NAME);
- selectedAlgorithm.setText(algorithmName);
- Map<PixelleComponent, String> algorithms = AlgorithmArchiver.getArchiver().getAlgorithm(groupName, algorithmName);
- for (PixelleComponent comp : PixelleComponent.values()) {
- editor.get(comp).setText(algorithms.get(comp));
+ selectedRGBAlgorithm.setText(algorithmName);
+ Map<RGBPixelleComponent, String> algorithms = (Map<RGBPixelleComponent, String>)AlgorithmArchiver.getArchiver().getAlgorithm(ImageType.RGB, groupName, algorithmName);
+ for (RGBPixelleComponent comp : RGBPixelleComponent.values()) {
+ rgbEditor.get(comp).setText(algorithms.get(comp));
}
}
});
try {
- Map<PixelleComponent, String> algorithms = AlgorithmArchiver.getArchiver().getCurrent();
+ Map<RGBPixelleComponent, String> algorithms = (Map<RGBPixelleComponent, String>)AlgorithmArchiver.getArchiver().getCurrent(ImageType.RGB);
if (algorithms != null) {
- for (PixelleComponent comp : PixelleComponent.values()) {
- editor.get(comp).setText(algorithms.get(comp));
+ for (RGBPixelleComponent comp : RGBPixelleComponent.values()) {
+ rgbEditor.get(comp).setText(algorithms.get(comp));
}
}
} catch (IllegalArgumentException iae) {
}
- savedAlgorithms.setInvoker(selectedAlgorithm);
- optionsPanel.add(savedAlgorithms);
+ savedRGBAlgorithms.setInvoker(selectedRGBAlgorithm);
+ optionsPanel.add(savedRGBAlgorithms);
optionsPanel.add(Box.createHorizontalGlue());
optionsPanel.setBorder(BorderFactory.createEmptyBorder(10, 4, 5, 4));
- cp.add(optionsPanel, BorderLayout.NORTH);
+ rgbPanel.add(optionsPanel);
}
{
JPanel algoPanel = new JPanel();
algoPanel.setLayout(new GridLayout(5, 1));
- GuiUtils.sizeUniformly(GuiUtils.Sizing.Both, lhs.values().toArray(new JComponent[lhs.size()]));
- GuiUtils.sizeUniformly(GuiUtils.Sizing.Both, editor.values().toArray(new JComponent[lhs.size()]));
- GuiUtils.sizeUniformly(GuiUtils.Sizing.Both, labels.values().toArray(new JComponent[lhs.size()]));
+ GuiUtils.sizeUniformly(GuiUtils.Sizing.Both, rgbLHS.values().toArray(new JComponent[rgbLHS.size()]));
+ GuiUtils.sizeUniformly(GuiUtils.Sizing.Both, rgbEditor.values().toArray(new JComponent[rgbLHS.size()]));
+ GuiUtils.sizeUniformly(GuiUtils.Sizing.Both, rgbLabels.values().toArray(new JComponent[rgbLHS.size()]));
- for (PixelleComponent comp : PixelleComponent.values()) {
+ for (RGBPixelleComponent comp : RGBPixelleComponent.values()) {
JPanel p = new JPanel();
p.setLayout(new BorderLayout(10, 10));
- p.add(lhs.get(comp), BorderLayout.WEST);
- p.add(editor.get(comp), BorderLayout.CENTER);
- p.add(labels.get(comp), BorderLayout.EAST);
- labels.get(comp).setLabelFor(editor.get(comp));
+ p.add(rgbLHS.get(comp), BorderLayout.WEST);
+ p.add(rgbEditor.get(comp), BorderLayout.CENTER);
+ p.add(rgbLabels.get(comp), BorderLayout.EAST);
+ rgbLabels.get(comp).setLabelFor(rgbEditor.get(comp));
p.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
algoPanel.add(p);
}
- cp.add(algoPanel, BorderLayout.CENTER);
+ rgbPanel.add(algoPanel);
}
- {
- JPanel ctlPanel = new JPanel();
- ctlPanel.setLayout(new BoxLayout(ctlPanel, BoxLayout.X_AXIS));
- ctlPanel.add(Box.createHorizontalStrut(10));
- ctlPanel.add(reset);
- ctlPanel.add(Box.createHorizontalStrut(10));
- ctlPanel.add(save);
- ctlPanel.add(Box.createHorizontalStrut(10));
- ctlPanel.add(delete);
- ctlPanel.add(Box.createHorizontalGlue());
- ctlPanel.add(ok);
- ctlPanel.add(Box.createHorizontalStrut(10));
- ctlPanel.add(cancel);
- ctlPanel.add(Box.createHorizontalStrut(10));
- ctlPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
- cp.add(ctlPanel, BorderLayout.SOUTH);
+ return rgbPanel;
+ }
+
+ private JPanel buildGrayscalePanel() {
+ JPanel gsPanel = new JPanel();
+ gsPanel.setLayout(new BoxLayout(gsPanel, BoxLayout.Y_AXIS));
+
+ {
+ JPanel optionsPanel = new JPanel();
+ optionsPanel.setLayout(new BoxLayout(optionsPanel, BoxLayout.X_AXIS));
+ optionsPanel.add(Box.createHorizontalGlue());
+ JLabel l = new JLabel(PixelleBundle.getString(PixelleBundle.PIXEL_ALGORITHM));
+ optionsPanel.add(l);
+ optionsPanel.add(Box.createHorizontalStrut(10));
+ selectedGSAlgorithm = new JTextField(PixelleBundle.getString(PixelleBundle.UNTITLED));
+ selectedGSAlgorithm.setEditable(false);
+ optionsPanel.add(selectedGSAlgorithm);
+ optionsPanel.add(Box.createHorizontalStrut(10));
+ savedGSAlgorithms = AlgorithmArchiver.getArchiver().getAlgorithmDisplayPopup(ImageType.Grayscale, new ActionListener() {
+ public void actionPerformed(ActionEvent ae) {
+ JMenuItem item = (JMenuItem)ae.getSource();
+ String algorithmName = item.getText();
+ String groupName = (String)item.getClientProperty(AlgorithmArchiver.NAME);
+ selectedGSAlgorithm.setText(algorithmName);
+ Map<GrayscalePixelleComponent, String> algorithms = (Map<GrayscalePixelleComponent, String>)AlgorithmArchiver.getArchiver().getAlgorithm(ImageType.Grayscale, groupName, algorithmName);
+ for (GrayscalePixelleComponent comp : GrayscalePixelleComponent.values()) {
+ gsEditor.get(comp).setText(algorithms.get(comp));
+ }
+ }
+ });
+ try {
+ Map<GrayscalePixelleComponent, String> algorithms = (Map<GrayscalePixelleComponent, String>)AlgorithmArchiver.getArchiver().getCurrent(ImageType.Grayscale);
+ if (algorithms != null) {
+ for (GrayscalePixelleComponent comp : GrayscalePixelleComponent.values()) {
+ gsEditor.get(comp).setText(algorithms.get(comp));
+ }
+ }
+ } catch (IllegalArgumentException iae) {
+ }
+
+ savedGSAlgorithms.setInvoker(selectedGSAlgorithm);
+ optionsPanel.add(savedGSAlgorithms);
+ optionsPanel.add(Box.createHorizontalGlue());
+ optionsPanel.setBorder(BorderFactory.createEmptyBorder(10, 4, 5, 4));
+ gsPanel.add(optionsPanel);
}
- pack();
+ {
+ JPanel algoPanel = new JPanel();
+ algoPanel.setLayout(new GridLayout(5, 1));
+
+ GuiUtils.sizeUniformly(GuiUtils.Sizing.Both, gsLHS.values().toArray(new JComponent[gsLHS.size()]));
+ GuiUtils.sizeUniformly(GuiUtils.Sizing.Both, gsEditor.values().toArray(new JComponent[gsLHS.size()]));
+ GuiUtils.sizeUniformly(GuiUtils.Sizing.Both, gsLabels.values().toArray(new JComponent[gsLHS.size()]));
+
+ for (GrayscalePixelleComponent comp : GrayscalePixelleComponent.values()) {
+ JPanel p = new JPanel();
+ p.setLayout(new BorderLayout(10, 10));
+ p.add(gsLHS.get(comp), BorderLayout.WEST);
+ p.add(gsEditor.get(comp), BorderLayout.CENTER);
+ p.add(gsLabels.get(comp), BorderLayout.EAST);
+ gsLabels.get(comp).setLabelFor(gsEditor.get(comp));
+ p.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
+ algoPanel.add(p);
+ }
+
+ gsPanel.add(algoPanel);
+ }
+
+ return gsPanel;
}
private void initListeners() {
getRootPane().setDefaultButton(ok);
- selectedAlgorithm.addMouseListener(new MouseAdapter() {
+ selectedRGBAlgorithm.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent me) {
- savedAlgorithms.setSize(selectedAlgorithm.getSize());
- savedAlgorithms.show(selectedAlgorithm, 0, 0);
+ savedRGBAlgorithms.setSize(selectedRGBAlgorithm.getSize());
+ savedRGBAlgorithms.show(selectedRGBAlgorithm, 0, 0);
}
});
@@ -218,7 +328,7 @@
if (dialog.isOK()) {
String group = dialog.getGroup();
String name = dialog.getName();
- Map<PixelleComponent, String> algorithm = getAlgorithms();
+ Map<RGBPixelleComponent, String> algorithm = getAlgorithms();
AlgorithmArchiver archiver = AlgorithmArchiver.getArchiver();
archiver.addAlgorithm(group, name, algorithm);
archiver.save();
@@ -228,7 +338,7 @@
ok.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
- Map<PixelleComponent, String> algorithm = getAlgorithms();
+ Map<RGBPixelleComponent, String> algorithm = getAlgorithms();
AlgorithmArchiver archiver = AlgorithmArchiver.getArchiver();
archiver.setCurrent(algorithm);
archiver.save();
@@ -246,8 +356,8 @@
reset.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
- for (PixelleComponent comp : PixelleComponent.values()) {
- editor.get(comp).setText(PixelleBundle.getString("formula." + comp.name().toLowerCase()));
+ for (RGBPixelleComponent comp : RGBPixelleComponent.values()) {
+ rgbEditor.get(comp).setText(PixelleBundle.getString("formula." + comp.name().toLowerCase()));
}
}
});
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/resources/pixelle.properties
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/resources/pixelle.properties 2008-11-20 06:07:08 UTC (rev 199)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/resources/pixelle.properties 2008-11-20 06:16:41 UTC (rev 200)
@@ -55,6 +55,7 @@
formula.red = p[x,y].r
formula.green = p[x,y].g
formula.blue = p[x,y].b
+formula.black = p[x,y].k
formula.transparency = p[x,y].t
formula.selection = p[x,y].s
@@ -66,6 +67,7 @@
label.red = (Red)
label.green = (Green)
label.blue = (Blue)
+label.black = (Black)
label.transparency = (Transparency)
label.selection = (Selection)
@@ -89,3 +91,5 @@
tooltip.inspector = Click in the frame's window to freeze the inspector value, and click again to unfreeze
+label.rgb = RGB
+label.grayscale = Gray scale
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|