[Bprocessor-commit] gui/src/net/sourceforge/bprocessor/gui/attrview AttributePanel.java,1.7,1.8 Mate
Status: Pre-Alpha
Brought to you by:
henryml
From: Nikolaj B. <nbr...@us...> - 2006-04-10 11:54:43
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16506/src/net/sourceforge/bprocessor/gui/attrview Modified Files: AttributePanel.java MaterialAttribute.java GenericPanel.java Log Message: Materials are now handled correct when displayed in attribute view: Index: GenericPanel.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview/GenericPanel.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** GenericPanel.java 16 Mar 2006 10:16:55 -0000 1.15 --- GenericPanel.java 10 Apr 2006 11:54:39 -0000 1.16 *************** *** 29,32 **** --- 29,33 ---- import net.sourceforge.bprocessor.model.Description; import net.sourceforge.bprocessor.model.Entity; + import net.sourceforge.bprocessor.model.Material; import net.sourceforge.bprocessor.model.Parametric; import net.sourceforge.bprocessor.model.Project; *************** *** 158,162 **** }); where.add(new AttributeRow(la)); ! } else if (a.getName().equals("Front Material") || a.getName().equals("Back Material")) { // Handles the materials MaterialAttribute ma = new MaterialAttribute(a); --- 159,163 ---- }); where.add(new AttributeRow(la)); ! } else if (a.getValue() instanceof Material) { // Handles the materials MaterialAttribute ma = new MaterialAttribute(a); Index: MaterialAttribute.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview/MaterialAttribute.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MaterialAttribute.java 8 Mar 2006 14:22:05 -0000 1.2 --- MaterialAttribute.java 10 Apr 2006 11:54:39 -0000 1.3 *************** *** 24,34 **** import javax.swing.border.Border; - import net.sourceforge.bprocessor.gui.Defaults; import net.sourceforge.bprocessor.gui.GUI; import net.sourceforge.bprocessor.model.Attribute; import net.sourceforge.bprocessor.model.Material; - import net.sourceforge.bprocessor.model.Project; - import net.sourceforge.bprocessor.model.Space; - import net.sourceforge.bprocessor.model.Surface; /** --- 24,30 ---- *************** *** 46,55 **** private JComponent component; - /** The current surface */ - private Surface surface; - - /** The current side */ - private boolean side; - /** The editor, when this EditableAttribute is being edited */ private JTextField editor; --- 42,45 ---- *************** *** 124,143 **** private JComponent createValueLabel(Attribute a) { JPanel valueLabel = new JPanel(); ! surface = Project.getInstance().findSurfaceById(Long.parseLong(a.getValue().toString())); ! if (a.getName().equals("Front Material")) { ! side = true; ! float[] frontColor = getFrontColor(surface); ! valueLabel.setOpaque(true); ! Border blackline = BorderFactory.createLineBorder(Color.black); ! valueLabel.setBorder(blackline); ! valueLabel.setBackground(makeAWTColor(frontColor)); ! } else { ! side = false; ! float[] backColor = getBackColor(surface); ! valueLabel.setOpaque(true); ! Border blackline = BorderFactory.createLineBorder(Color.black); ! valueLabel.setBorder(blackline); ! valueLabel.setBackground(makeAWTColor(backColor)); ! } return valueLabel; } --- 114,122 ---- 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; } *************** *** 155,191 **** * Start editing the value by replacing the label with an editor */ ! public void startEditing() { ! Color defaultColor = Color.white; ! Material newMaterial; ! ! if (side) { ! if (surface.getFrontDomain() != null) { ! if (surface.getFrontMaterial() != null) { ! defaultColor = getMaterialColor(surface.getFrontMaterial()); ! } ! Color frontColor = JColorChooser.showDialog(GUI.getInstance(), ! "Surface Color", ! defaultColor); ! if (frontColor != null) { ! newMaterial = new Material("temp", frontColor.getRGBColorComponents(null)); ! surface.setFrontMaterial(newMaterial); ! surface.changed(); ! } ! } ! } else { ! if (surface.getBackDomain() != null) { ! if (surface.getBackMaterial() != null) { ! defaultColor = getMaterialColor(surface.getBackMaterial()); ! } ! Color backColor = JColorChooser.showDialog(GUI.getInstance(), ! "Surface Color", ! defaultColor); ! if (backColor != null) { ! newMaterial = new Material("temp", backColor.getRGBColorComponents(null)); ! surface.setBackMaterial(newMaterial); ! surface.changed(); ! } ! } ! } } --- 134,143 ---- * Start editing the value by replacing the label with an editor */ ! public void startEditing() { ! Color frontColor = JColorChooser.showDialog(GUI.getInstance(), ! "Surface Color", ! makeAWTColor(((Material) attribute.getValue()).getColor())); ! attribute.setValue(new Material("temp", frontColor.getRGBColorComponents(null))); ! valueChanged(); } *************** *** 238,293 **** private Color makeAWTColor(float[] rgb) { return new Color(rgb[0], rgb[1], rgb[2]); ! } ! ! ! /** ! * Return front color for surface ! * @param surface The surface ! * @return The color ! */ ! private float[] getFrontColor(Surface surface) { ! if (surface.getFrontDomain() == null) { ! return Defaults.getNoneColor(); ! } else { ! if (surface.getFrontMaterial() == null) { ! Space space = surface.getFrontDomain(); ! if (space.isConstructionSpace()) { ! return Defaults.getFrontColor(); ! } ! if (space.isFunctionalSpace()) { ! return Defaults.getBackColor(); ! } ! return Defaults.getNoneColor(); ! } else { ! return surface.getFrontMaterial().getColor(); ! } ! } ! } ! ! ! /** ! * Return back color for surface ! * @param surface The surface ! * @return The color ! */ ! private float[] getBackColor(Surface surface) { ! if (surface.getBackDomain() == null) { ! return Defaults.getNoneColor(); ! } else { ! if (surface.getBackMaterial() == null) { ! Space space = surface.getBackDomain(); ! if (space.isConstructionSpace()) { ! return Defaults.getFrontColor(); ! } ! if (space.isFunctionalSpace()) { ! return Defaults.getBackColor(); ! } ! return Defaults.getNoneColor(); ! } else { ! return surface.getBackMaterial().getColor(); ! } ! } ! } ! /** --- 190,194 ---- private Color makeAWTColor(float[] rgb) { return new Color(rgb[0], rgb[1], rgb[2]); ! } /** Index: AttributePanel.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview/AttributePanel.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** AttributePanel.java 1 Mar 2006 11:58:36 -0000 1.7 --- AttributePanel.java 10 Apr 2006 11:54:38 -0000 1.8 *************** *** 19,24 **** import javax.swing.border.Border; - import net.sourceforge.bprocessor.gui.Defaults; import net.sourceforge.bprocessor.model.Camera; import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.Material; --- 19,24 ---- import javax.swing.border.Border; import net.sourceforge.bprocessor.model.Camera; + import net.sourceforge.bprocessor.model.Defaults; import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.Material; *************** *** 33,36 **** --- 33,39 ---- */ class AttributePanel extends JPanel { + /** Default serial-version-uid */ + private static final long serialVersionUID = 1L; + /** The logger */ private static Logger log = Logger.getLogger(AttributePanel.class); |