Thread: [Bprocessor-commit] gui/src/net/sourceforge/bprocessor/gui/attrview MyMouseListener.java,NONE,1.1 At
Status: Pre-Alpha
Brought to you by:
henryml
From: Nikolaj B. <nbr...@us...> - 2006-01-10 13:39:57
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13366/src/net/sourceforge/bprocessor/gui/attrview Modified Files: AttributeView.java Added Files: MyMouseListener.java Log Message: Updated Surface attribute view, so it can now handle colors of the two sides of the surface Index: AttributeView.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview/AttributeView.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** AttributeView.java 6 Jan 2006 15:36:19 -0000 1.15 --- AttributeView.java 10 Jan 2006 13:39:49 -0000 1.16 *************** *** 21,24 **** --- 21,25 ---- import java.awt.GridBagConstraints; + import javax.swing.BorderFactory; import javax.swing.JLabel; import javax.swing.JPanel; *************** *** 26,29 **** --- 27,32 ---- import javax.swing.JTextField; import javax.swing.JComboBox; + import javax.swing.border.Border; + import javax.swing.border.TitledBorder; import org.apache.log4j.Logger; *************** *** 120,124 **** nameEdit.addKeyListener(new MyKeyListener(o)); ! Object[] options = {"Arbejdsv¾relse", "Badev¾relse", "Gang", "K¿kken", "Stue", "V¾relse"}; JComboBox klassifikation = new JComboBox(options); layout.setConstraints(klassifikation, con); --- 123,127 ---- nameEdit.addKeyListener(new MyKeyListener(o)); ! Object[] options = {"Arbejdsværelse", "Badeværelse", "Gang", "Køkken", "Stue", "Værelse"}; JComboBox klassifikation = new JComboBox(options); layout.setConstraints(klassifikation, con); *************** *** 171,184 **** setLayout(layout); ! JLabel name = new JLabel("Name:"); con.anchor = GridBagConstraints.NORTH; ! con.weightx = 1.0; layout.setConstraints(name, con); add(name); JLabel surfaceName = new JLabel(o.getName()); - con.gridwidth = GridBagConstraints.REMAINDER; layout.setConstraints(surfaceName, con); add(surfaceName); revalidate(); } --- 174,272 ---- setLayout(layout); ! JLabel name = new JLabel("Name: "); con.anchor = GridBagConstraints.NORTH; ! con.weightx = 0; layout.setConstraints(name, con); add(name); JLabel surfaceName = new JLabel(o.getName()); layout.setConstraints(surfaceName, con); add(surfaceName); + + JPanel hfiller = new JPanel(); + hfiller.setOpaque(true); + con.weightx = 1.0; + con.gridwidth = GridBagConstraints.REMAINDER; + layout.setConstraints(hfiller, con); + add(hfiller); + + /*JLabel fcolor = new JLabel("Front: "); + con.weightx = 0; + con.gridwidth = 1; + layout.setConstraints(fcolor, con); + add(fcolor); */ + + + if (o.getFrontMaterial() == null) { + JPanel front = new JPanel(); + front.setOpaque(true); + TitledBorder frontBorder; + frontBorder = BorderFactory.createTitledBorder("Front"); + front.setBorder(frontBorder); + 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); + TitledBorder frontBorder; + frontBorder = BorderFactory.createTitledBorder("Front"); + front.setBorder(frontBorder); + Color frontColor = o.getFrontMaterial().getColor(); + front.setBackground(frontColor); + 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 + } + + + JLabel bcolor = new JLabel("Back: "); + con.weightx = 0; + con.fill = GridBagConstraints.NONE; + con.gridwidth = 1; + 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 = o.getBackMaterial().getColor(); + back.setBackground(backColor); + 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 + + } + + JPanel vfiller = new JPanel(); + vfiller.setOpaque(true); + con.weighty = 1.0; + con.fill = GridBagConstraints.BOTH; + layout.setConstraints(vfiller, con); + add(vfiller); revalidate(); } --- NEW FILE: MyMouseListener.java --- //--------------------------------------------------------------------------------- // $Id: MyMouseListener.java,v 1.1 2006/01/10 13:39:49 nbramsen Exp $ // // Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net) // Released under the Lesser GNU Public License v2.1 //--------------------------------------------------------------------------------- package net.sourceforge.bprocessor.gui.attrview; import java.awt.Color; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import javax.swing.JColorChooser; import net.sourceforge.bprocessor.gui.GUI; import net.sourceforge.bprocessor.model.Material; import net.sourceforge.bprocessor.model.Surface; /** * The focus handler */ public class MyMouseListener implements MouseListener { /** The current Surface */ private Surface currentSurface; /** The current Side */ private boolean currentSide; /** * The constructor * @param o the event * @param side shows if its the front or back of the surface. True = front, False = Back. */ public MyMouseListener (Surface o, boolean side) { currentSurface = o; currentSide = side; } /** * Handles mouse event * @param arg0 the event */ public void mouseClicked(MouseEvent arg0) { Color defaultColor = Color.white; Material newMaterial; if (currentSide) { if (currentSurface.getFrontMaterial() != null) { defaultColor = currentSurface.getFrontMaterial().getColor(); } Color frontColor = JColorChooser.showDialog(GUI.getInstance(), "Constructor Line Color", defaultColor); if (frontColor != null) { newMaterial = new Material("temp", frontColor); } else { newMaterial = new Material("temp", defaultColor); } currentSurface.setFrontMaterial(newMaterial); currentSurface.changed(); } else { if (currentSurface.getBackMaterial() != null) { defaultColor = currentSurface.getBackMaterial().getColor(); } Color backColor = JColorChooser.showDialog(GUI.getInstance(), "Constructor Line Color", defaultColor); if (backColor != null) { newMaterial = new Material("temp", backColor); } else { newMaterial = new Material("temp", defaultColor); } currentSurface.setBackMaterial(newMaterial); currentSurface.changed(); } } /** * Handles mouse event * @param arg0 the event */ public void mouseEntered(MouseEvent arg0) { } /** * Handles mouse event * @param arg0 the event */ public void mouseExited(MouseEvent arg0) { } /** * Handles mouse event * @param arg0 the event */ public void mousePressed(MouseEvent arg0) { } /** * Handles mouse event * @param arg0 the event */ public void mouseReleased(MouseEvent arg0) { } } |