[Bprocessor-commit] gui/src/net/sourceforge/bprocessor/gui/attrview GenericPanel.java, 1.47, 1.48 M
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2007-11-20 08:36:06
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv16448/src/net/sourceforge/bprocessor/gui/attrview Modified Files: GenericPanel.java MaterialAttribute.java Log Message: added a separate attribute handling for Components and expanded on the material attribute Index: GenericPanel.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview/GenericPanel.java,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** GenericPanel.java 9 Nov 2007 09:45:29 -0000 1.47 --- GenericPanel.java 20 Nov 2007 08:36:08 -0000 1.48 *************** *** 8,11 **** --- 8,12 ---- import java.awt.BorderLayout; + import java.awt.Color; import java.awt.Dimension; import java.awt.event.ItemEvent; *************** *** 27,33 **** import net.sourceforge.bprocessor.model.Attribute; import net.sourceforge.bprocessor.model.Camera; import net.sourceforge.bprocessor.model.Description; import net.sourceforge.bprocessor.model.Entity; - import net.sourceforge.bprocessor.model.Material; import net.sourceforge.bprocessor.model.Operation; import net.sourceforge.bprocessor.model.Parametric; --- 28,34 ---- import net.sourceforge.bprocessor.model.Attribute; import net.sourceforge.bprocessor.model.Camera; + import net.sourceforge.bprocessor.model.Component; import net.sourceforge.bprocessor.model.Description; import net.sourceforge.bprocessor.model.Entity; import net.sourceforge.bprocessor.model.Operation; import net.sourceforge.bprocessor.model.Parametric; *************** *** 140,144 **** } ! private void handleMaterial(Attribute attribute, JComponent where) { MaterialAttribute ma = new MaterialAttribute(attribute); ma.addMaterialAttributeListener(new GenericListener()); --- 141,145 ---- } ! private void handleColor(Attribute attribute, JComponent where) { MaterialAttribute ma = new MaterialAttribute(attribute); ma.addMaterialAttributeListener(new GenericListener()); *************** *** 198,201 **** --- 199,208 ---- } + private void handleComponent(Attribute attribute, JComponent where) { + GenericAttribute generic = new PreviewAttribute(attribute); + genAttributes.add(generic); + where.add(new AttributeRow(generic)); + } + private void generateContent(List what, JComponent where) { Iterator iter = what.iterator(); *************** *** 208,215 **** } else if (a.getValue() instanceof Description) { handleDescription(a, where); ! } else if (a.getValue() instanceof Material) { ! handleMaterial(a, where); } else if (a.getValue() instanceof Boolean) { handleBoolean(a, where); } else if (a.getThe2ndValue() instanceof Structure) { handleClassification(a, where); --- 215,224 ---- } else if (a.getValue() instanceof Description) { handleDescription(a, where); ! } else if (a.getValue() instanceof Color) { ! handleColor(a, where); } else if (a.getValue() instanceof Boolean) { handleBoolean(a, where); + } else if (a.getValue() instanceof Component) { + handleComponent(a, where); } else if (a.getThe2ndValue() instanceof Structure) { handleClassification(a, where); Index: MaterialAttribute.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview/MaterialAttribute.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** MaterialAttribute.java 15 May 2006 09:19:53 -0000 1.4 --- MaterialAttribute.java 20 Nov 2007 08:36:08 -0000 1.5 *************** *** 21,31 **** import javax.swing.JComponent; import javax.swing.JPanel; - import javax.swing.JTextField; import javax.swing.border.Border; import net.sourceforge.bprocessor.gui.GUI; import net.sourceforge.bprocessor.model.Attribute; - import net.sourceforge.bprocessor.model.Material; - import net.sourceforge.bprocessor.model.Project; /** --- 21,28 ---- *************** *** 43,52 **** private JComponent component; - /** The editor, when this EditableAttribute is being edited */ - private JTextField editor; - - - - /** * Constructor for MaterialAttribute --- 40,43 ---- *************** *** 115,123 **** private JComponent createValueLabel(Attribute a) { JPanel valueLabel = new JPanel(); ! float[] frontColor = ((Material) a.getValue()).getColor(); valueLabel.setOpaque(true); Border blackline = BorderFactory.createLineBorder(Color.black); valueLabel.setBorder(blackline); ! valueLabel.setBackground(makeAWTColor(frontColor)); return valueLabel; } --- 106,114 ---- private JComponent createValueLabel(Attribute a) { JPanel valueLabel = new JPanel(); ! Color color = (Color) a.getValue(); valueLabel.setOpaque(true); Border blackline = BorderFactory.createLineBorder(Color.black); valueLabel.setBorder(blackline); ! valueLabel.setBackground(color); return valueLabel; } *************** *** 136,145 **** */ public void startEditing() { ! Color frontColor = JColorChooser.showDialog(GUI.getInstance(), ! "Surface Color", ! makeAWTColor(((Material) attribute.getValue()).getColor())); ! Material material = new Material("temp", frontColor.getRGBColorComponents(null)); ! Project.getInstance().add(material); ! attribute.setValue(material); valueChanged(); } --- 127,136 ---- */ public void startEditing() { ! Color color = JColorChooser.showDialog(GUI.getInstance(), ! "Color chooser", ! (Color) attribute.getValue()); ! if (color != null) { ! attribute.setValue(color); ! } valueChanged(); } *************** *** 150,160 **** */ public void stopEditing() { ! if (editor != null && attribute.isEditable()) { ! Object val = attribute.getValue(); ! if (val instanceof String) { ! attribute.setValue(editor.getText()); ! } ! component.remove(editor); ! editor = null; component.add(createValueLabel(attribute)); component.revalidate(); --- 141,145 ---- */ public void stopEditing() { ! if (attribute.isEditable()) { component.add(createValueLabel(attribute)); component.revalidate(); *************** *** 168,197 **** */ public void cancelEditing() { - if (editor != null) { - component.remove(editor); - editor = null; - component.add(createValueLabel(attribute)); - component.revalidate(); - } } - - /** - * Get AWT color for material - * @param material The material - * @return The AWT color - */ - private Color getMaterialColor(Material material) { - float[] rgb = material.getColor(); - return new Color(rgb[0], rgb[1], rgb[2]); - } - - /** - * Make AWT color from the components - * @param rgb Array of floats - * @return AWT Color - */ - private Color makeAWTColor(float[] rgb) { - return new Color(rgb[0], rgb[1], rgb[2]); - } /** --- 153,157 ---- |