[Bprocessor-commit] gui/src/net/sourceforge/bprocessor/gui/attrview MaterialAttribute.java, 1.5, 1.
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2007-12-17 13:55:08
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv24534/src/net/sourceforge/bprocessor/gui/attrview Modified Files: MaterialAttribute.java GenericPanel.java Log Message: removed depency to AWT from model Index: GenericPanel.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview/GenericPanel.java,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** GenericPanel.java 17 Dec 2007 13:09:35 -0000 1.49 --- GenericPanel.java 17 Dec 2007 13:55:09 -0000 1.50 *************** *** 8,12 **** import java.awt.BorderLayout; - import java.awt.Color; import java.awt.Dimension; import java.awt.event.ItemEvent; --- 8,11 ---- *************** *** 215,219 **** } else if (a.getValue() instanceof Description) { handleDescription(a, where); ! } else if (a.getValue() instanceof Color) { handleColor(a, where); } else if (a.getValue() instanceof Boolean) { --- 214,218 ---- } else if (a.getValue() instanceof Description) { handleDescription(a, where); ! } else if (a.getValue() instanceof float[]) { handleColor(a, where); } else if (a.getValue() instanceof Boolean) { Index: MaterialAttribute.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview/MaterialAttribute.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** MaterialAttribute.java 20 Nov 2007 08:36:08 -0000 1.5 --- MaterialAttribute.java 17 Dec 2007 13:55:09 -0000 1.6 *************** *** 49,54 **** this.attribute = attribute; this.listeners = new LinkedList(); ! ! //this.add(Box.createHorizontalStrut(7)); component = Box.createHorizontalBox(); component.add(createValueLabel(attribute)); --- 49,53 ---- this.attribute = attribute; this.listeners = new LinkedList(); ! component = Box.createHorizontalBox(); component.add(createValueLabel(attribute)); *************** *** 56,59 **** --- 55,66 ---- } + private Color rgbToColor(float[] rgb) { + return new Color(rgb[0], rgb[1], rgb[2]); + } + + private float[] colorToRgb(Color color) { + return color.getColorComponents(null); + } + /** * Add a mouselisterner to the active elements in the MaterialAttribute *************** *** 99,102 **** --- 106,110 ---- } + /** * Create a value label *************** *** 106,110 **** private JComponent createValueLabel(Attribute a) { JPanel valueLabel = new JPanel(); ! Color color = (Color) a.getValue(); valueLabel.setOpaque(true); Border blackline = BorderFactory.createLineBorder(Color.black); --- 114,119 ---- private JComponent createValueLabel(Attribute a) { JPanel valueLabel = new JPanel(); ! float[] rgb = (float[]) a.getValue(); ! Color color = rgbToColor(rgb); valueLabel.setOpaque(true); Border blackline = BorderFactory.createLineBorder(Color.black); *************** *** 129,135 **** Color color = JColorChooser.showDialog(GUI.getInstance(), "Color chooser", ! (Color) attribute.getValue()); if (color != null) { ! attribute.setValue(color); } valueChanged(); --- 138,144 ---- Color color = JColorChooser.showDialog(GUI.getInstance(), "Color chooser", ! rgbToColor((float[]) attribute.getValue())); if (color != null) { ! attribute.setValue(colorToRgb(color)); } valueChanged(); |