[Bprocessor-commit] gui/src/net/sourceforge/bprocessor/gui/attrview AttributeView.java,1.21,1.22
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2006-01-15 14:04:10
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12868/src/net/sourceforge/bprocessor/gui/attrview Modified Files: AttributeView.java Log Message: Moved default colors to Defaults class in the GUI package Index: AttributeView.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview/AttributeView.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** AttributeView.java 13 Jan 2006 11:03:35 -0000 1.21 --- AttributeView.java 15 Jan 2006 14:03:56 -0000 1.22 *************** *** 7,10 **** --- 7,11 ---- package net.sourceforge.bprocessor.gui.attrview; + import net.sourceforge.bprocessor.gui.Defaults; import net.sourceforge.bprocessor.model.Material; import net.sourceforge.bprocessor.model.Observer; *************** *** 121,124 **** --- 122,133 ---- } + /** + * 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]); + } /** *************** *** 132,135 **** --- 141,192 ---- } + /** + * 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(); + } + } + } + /** *************** *** 165,188 **** add(fcolor); ! ! if (o.getFrontMaterial() == null) { ! JPanel front = new JPanel(); ! front.setOpaque(true); ! Border blackline = BorderFactory.createLineBorder(Color.black); ! front.setBorder(blackline); ! front.setBackground(Color.white); ! con.weightx = 1.0; ! con.fill = GridBagConstraints.HORIZONTAL; ! con.gridwidth = GridBagConstraints.REMAINDER; ! layout.setConstraints(front, con); ! add(front); ! front.addMouseListener(new MyMouseListener(o, true)); //true = front color to be changed ! } else { JPanel front = new JPanel(); front.setOpaque(true); Border blackline = BorderFactory.createLineBorder(Color.black); front.setBorder(blackline); ! Color frontColor = getMaterialColor(o.getFrontMaterial()); ! front.setBackground(frontColor); con.weightx = 1.0; con.fill = GridBagConstraints.HORIZONTAL; --- 222,232 ---- add(fcolor); ! { ! float[] frontColor = getFrontColor(o); JPanel front = new JPanel(); front.setOpaque(true); Border blackline = BorderFactory.createLineBorder(Color.black); front.setBorder(blackline); ! front.setBackground(makeAWTColor(frontColor)); con.weightx = 1.0; con.fill = GridBagConstraints.HORIZONTAL; *************** *** 192,197 **** front.addMouseListener(new MyMouseListener(o, true)); //true = front color to be changed } ! ! JLabel bcolor = new JLabel("Back: "); con.weightx = 0; --- 236,240 ---- front.addMouseListener(new MyMouseListener(o, true)); //true = front color to be changed } ! JLabel bcolor = new JLabel("Back: "); con.weightx = 0; *************** *** 200,223 **** layout.setConstraints(bcolor, con); add(bcolor); ! ! if (o.getBackMaterial() == null) { ! JPanel back = new JPanel(); ! back.setOpaque(true); ! Border blackline = BorderFactory.createLineBorder(Color.black); ! back.setBorder(blackline); ! back.setBackground(Color.white); ! con.weightx = 1.0; ! con.fill = GridBagConstraints.HORIZONTAL; ! con.gridwidth = GridBagConstraints.REMAINDER; ! layout.setConstraints(back, con); ! add(back); ! back.addMouseListener(new MyMouseListener(o, false)); //false = back color to be changed ! } else { JPanel back = new JPanel(); back.setOpaque(true); Border blackline = BorderFactory.createLineBorder(Color.black); back.setBorder(blackline); ! Color backColor = getMaterialColor(o.getBackMaterial()); ! back.setBackground(backColor); con.weightx = 1.0; con.fill = GridBagConstraints.HORIZONTAL; --- 243,254 ---- layout.setConstraints(bcolor, con); add(bcolor); ! ! { ! float[] backColor = getBackColor(o); JPanel back = new JPanel(); back.setOpaque(true); Border blackline = BorderFactory.createLineBorder(Color.black); back.setBorder(blackline); ! back.setBackground(makeAWTColor(backColor)); con.weightx = 1.0; con.fill = GridBagConstraints.HORIZONTAL; *************** *** 226,232 **** add(back); back.addMouseListener(new MyMouseListener(o, false)); //false = back color to be changed - } ! JPanel vfiller = new JPanel(); vfiller.setOpaque(true); --- 257,262 ---- add(back); back.addMouseListener(new MyMouseListener(o, false)); //false = back color to be changed } ! JPanel vfiller = new JPanel(); vfiller.setOpaque(true); |