[Bprocessor-commit] gui/src/net/sourceforge/bprocessor/gui/attrview AttributePanel.java,NONE,1.1 Gen
Status: Pre-Alpha
Brought to you by:
henryml
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13111/src/net/sourceforge/bprocessor/gui/attrview Modified Files: AttributeView.java Added Files: AttributePanel.java GenericAttribute.java StringAttribute.java GenericPanel.java AttributeListener.java Log Message: Split AttributeView into AttributePanel and GenericPanel and made GenericPanel more usefull --- NEW FILE: StringAttribute.java --- //--------------------------------------------------------------------------------- // $Id: StringAttribute.java,v 1.1 2006/02/03 15:23:00 rimestad 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.Dimension; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JTextField; import net.sourceforge.bprocessor.model.Attribute; /** * The StringAttributeView */ public class StringAttribute extends GenericAttribute implements KeyListener, MouseListener { /** The listeners */ private List listeners; /** The attribute this gui represents */ private Attribute attribute; /** The component */ private JComponent component; /** The Label */ private JLabel label; /** The editor, when this EditableAttribute is being edited */ private JTextField editor; /** * Constructor for StringAttribute * @param attribute The attribute */ public StringAttribute(Attribute attribute) { super(BoxLayout.X_AXIS); this.attribute = attribute; this.listeners = new LinkedList(); label = createLabel(attribute.getName()); Box header = Box.createHorizontalBox(); Box column = Box.createVerticalBox(); header.add(Box.createHorizontalGlue()); header.add(label); column.add(Box.createHorizontalStrut(60)); column.add(header); column.add(Box.createHorizontalStrut(60)); column.setMaximumSize(new Dimension(60, Short.MAX_VALUE)); this.add(column); this.add(Box.createHorizontalStrut(7)); component = Box.createHorizontalBox(); component.add(createValueLabel((String)attribute.getValue())); this.add(component); this.add(Box.createHorizontalGlue()); label.addMouseListener(this); component.addMouseListener(this); } /** * Create a label for the * @param key The key * @return A JLabel */ private JLabel createLabel(String key) { JLabel keyLabel = new JLabel(key + " :"); keyLabel.setFont(AttributePanel.FONT_BOLD); return keyLabel; } /** * Add a mouselisterner to the active elements in the StringAttribute * @param mouseListener the mouselistener */ public void addMouseListener(MouseListener mouseListener) { label.addMouseListener(mouseListener); component.addMouseListener(mouseListener); } /** * Remove a mouselisterner to the active elements in the StringAttribute * @param mouseListener the mouselistener */ public void removeMouseListener(MouseListener mouseListener) { label.removeMouseListener(mouseListener); component.removeMouseListener(mouseListener); } /** * Add a listener that are notified when the value is changed * @param listener The listener */ public void addStringAttributeListener(AttributeListener listener) { listeners.add(listener); } /** * Remove a listener * @param listener The listener */ public void removeStringAttributeListener(AttributeListener listener) { listeners.remove(listener); } /** * Send valueChanged to all listeners */ protected void valueChanged() { Iterator iter = listeners.iterator(); while (iter.hasNext()) { AttributeListener current = (AttributeListener) iter.next(); current.valueChanged(attribute); } } /** * Create a value label * @param value The value * @return The label */ private JComponent createValueLabel(String value) { JLabel valueLabel = new JLabel(value); valueLabel.setFont(AttributePanel.FONT_PLAIN); return valueLabel; } /** * Create a value editor * @param value The value * @return The editor */ private JComponent createValueEditor(String value) { JTextField valueEditor = new JTextField(value); valueEditor.setFont(AttributePanel.FONT_PLAIN); return valueEditor; } /** * Return the attribute * @return The attribute */ public Attribute attribute() { return attribute; } /** * Start editing the value by replacing the label with an editor */ public void startEditing() { if (editor == null) { component.remove(0); editor = (JTextField) createValueEditor((String)attribute.getValue()); editor.addKeyListener(this); component.add(editor); component.revalidate(); } editor.requestFocus(); editor.selectAll(); } /** * Stop editing the value by replacing the editor with an label, * and sending valueChanged to all listeners. */ public void stopEditing() { if (editor != null) { component.remove(editor); attribute.setValue(editor.getText()); editor.removeKeyListener(this); editor = null; component.add(createValueLabel((String)attribute.getValue())); component.revalidate(); valueChanged(); } } /** * Cancels editing the value by replacing the editor with an label, * without sending any events to listeners. */ public void cancelEditing() { if (editor != null) { component.remove(editor); editor.removeKeyListener(this); editor = null; component.add(createValueLabel((String)attribute.getValue())); component.revalidate(); } } /** * Respond to the enter key by stopping editing. * @param event The KeyEvent */ public void keyPressed(KeyEvent event) { if (event.getKeyCode() == KeyEvent.VK_ENTER) { stopEditing(); } else if (event.getKeyCode() == KeyEvent.VK_ESCAPE) { cancelEditing(); } } /** * Not in use * @param event The KeyEvent */ public void keyTyped(KeyEvent event) { } /** * Not in use * @param event The KeyEvent */ public void keyReleased(KeyEvent event) { } /** * Start editing on the view * @param event The event */ public void mouseClicked(MouseEvent event) { startEditing(); } /** * Not in use * @param event The MouseEvent */ public void mousePressed(MouseEvent event) { } /** * Not in use * @param event The MouseEvent */ public void mouseReleased(MouseEvent event) { } /** * Not in use * @param event The MouseEvent */ public void mouseEntered(MouseEvent event) { } /** * Not in use * @param event The MouseEvent */ public void mouseExited(MouseEvent event) { } } --- NEW FILE: AttributeListener.java --- //--------------------------------------------------------------------------------- // $Id: AttributeListener.java,v 1.1 2006/02/03 15:23:00 rimestad 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.util.EventListener; import net.sourceforge.bprocessor.model.Attribute; /** * The StringAttributeListener */ public interface AttributeListener extends EventListener { /** * Called when the value has changed * @param attribute The attribute that have changed */ public void valueChanged(Attribute attribute); } --- NEW FILE: AttributePanel.java --- //--------------------------------------------------------------------------------- // $Id: AttributePanel.java,v 1.1 2006/02/03 15:23:00 rimestad 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.Dimension; import java.awt.Font; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import javax.swing.BorderFactory; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextArea; import javax.swing.JTextField; 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; import net.sourceforge.bprocessor.model.Space; import net.sourceforge.bprocessor.model.Surface; import net.sourceforge.bprocessor.model.Vertex; import org.apache.log4j.Logger; /** * Attributes panel */ class AttributePanel extends JPanel { /** The logger */ private static Logger log = Logger.getLogger(AttributePanel.class); /** Current object */ private Object current; /** The font used in plain */ public static final Font FONT_PLAIN = new Font("Sans-serif", Font.PLAIN, 12); /** The font used in bold */ public static final Font FONT_BOLD = new Font("Sans-serif", Font.BOLD, 12); /** If its a textfield */ public static final int TFIELD = 1; /** If its a textfield */ public static final int TAREA = 2; /** The length field */ public static final int LENGTH = 3; /** The X coordinate */ public static final int XCOOR = 4; /** The Y coordinate */ public static final int YCOOR = 5; /** The Z coordinate */ public static final int ZCOOR = 6; /** * Constructor */ AttributePanel() { current = null; } /** * Get current * @return Current */ public Object getCurrent() { return current; } /** * Display the construction space * @param o The object */ void displaySpace(Space o) { GridBagLayout layout = new GridBagLayout(); GridBagConstraints con = new GridBagConstraints(); setLayout(layout); JLabel name = new JLabel("Name:"); con.anchor = GridBagConstraints.NORTHEAST; con.weightx = 0; layout.setConstraints(name, con); name.setFont(FONT_BOLD); add(name); JTextField nameEdit = new JTextField(o.getName()); con.gridwidth = GridBagConstraints.REMAINDER; con.weightx = 1.0; con.fill = GridBagConstraints.HORIZONTAL; layout.setConstraints(nameEdit, con); nameEdit.setFont(FONT_PLAIN); add(nameEdit); nameEdit.addKeyListener(new MyKeyListener(o, TFIELD)); JTextArea descriptionEditor = new JTextArea(o.getDescription()); descriptionEditor.setLineWrap(true); descriptionEditor.setWrapStyleWord(true); con.weighty = 1.0; con.fill = GridBagConstraints.BOTH; layout.setConstraints(descriptionEditor, con); descriptionEditor.addFocusListener(new MyFocusListener(o)); add(descriptionEditor); } /** * 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]); } /** * 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]); } /** * 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(); } } } /** * Display the edge * @param o The object */ void displayVertex(Vertex o) { GridBagLayout layout = new GridBagLayout(); GridBagConstraints con = new GridBagConstraints(); setLayout(layout); JLabel name = new JLabel("Name: "); con.anchor = GridBagConstraints.NORTH; con.weightx = 0; layout.setConstraints(name, con); name.setFont(FONT_BOLD); add(name); JLabel vertexName = new JLabel(o.getName()); layout.setConstraints(vertexName, con); vertexName.setFont(FONT_PLAIN); add(vertexName); JPanel hfiller = new JPanel(); hfiller.setOpaque(true); con.weightx = 1.0; con.gridwidth = GridBagConstraints.REMAINDER; layout.setConstraints(hfiller, con); add(hfiller); JLabel x = new JLabel("X: "); con.anchor = GridBagConstraints.NORTH; con.gridwidth = 1; con.weightx = 0; layout.setConstraints(x, con); x.setFont(FONT_BOLD); add(x); int xval = (int) (o.getX() * 10000); JTextField xEdit = new JTextField((Double.toString(((double) xval) / 10000))); con.gridwidth = GridBagConstraints.REMAINDER; con.weightx = 1.0; con.fill = GridBagConstraints.HORIZONTAL; layout.setConstraints(xEdit, con); xEdit.setFont(FONT_PLAIN); add(xEdit); xEdit.addKeyListener(new MyKeyListener(o, XCOOR)); JLabel y = new JLabel("Y: "); con.gridwidth = 1; con.weightx = 0; con.fill = GridBagConstraints.NONE; layout.setConstraints(y, con); y.setFont(FONT_BOLD); add(y); int yval = (int) (o.getY() * 10000); JTextField yEdit = new JTextField((Double.toString(((double) yval) / 10000))); con.gridwidth = GridBagConstraints.REMAINDER; con.weightx = 1.0; con.fill = GridBagConstraints.HORIZONTAL; layout.setConstraints(yEdit, con); yEdit.setFont(FONT_PLAIN); add(yEdit); yEdit.addKeyListener(new MyKeyListener(o, YCOOR)); JLabel z = new JLabel("Z: "); con.gridwidth = 1; con.weightx = 0; con.fill = GridBagConstraints.NONE; layout.setConstraints(z, con); z.setFont(FONT_BOLD); add(z); int zval = (int) (o.getZ() * 10000); JTextField zEdit = new JTextField((Double.toString(((double) zval) / 10000))); con.gridwidth = GridBagConstraints.REMAINDER; con.weightx = 1.0; con.fill = GridBagConstraints.HORIZONTAL; layout.setConstraints(zEdit, con); zEdit.setFont(FONT_PLAIN); add(zEdit); zEdit.addKeyListener(new MyKeyListener(o, ZCOOR)); JPanel vfiller = new JPanel(); vfiller.setOpaque(true); con.weighty = 1.0; con.fill = GridBagConstraints.BOTH; layout.setConstraints(vfiller, con); add(vfiller); } /** * Display the edge * @param o The object */ void displayEdge(Edge o) { GridBagLayout layout = new GridBagLayout(); GridBagConstraints con = new GridBagConstraints(); setLayout(layout); JLabel name = new JLabel("Name: "); con.anchor = GridBagConstraints.NORTH; con.weightx = 0; layout.setConstraints(name, con); name.setFont(FONT_BOLD); add(name); JLabel edgeName = new JLabel(o.getName()); layout.setConstraints(edgeName, con); edgeName.setFont(FONT_PLAIN); add(edgeName); JPanel hfiller = new JPanel(); hfiller.setOpaque(true); con.weightx = 1.0; con.gridwidth = GridBagConstraints.REMAINDER; layout.setConstraints(hfiller, con); add(hfiller); JLabel length = new JLabel("Length: "); con.anchor = GridBagConstraints.NORTH; con.weightx = 0; con.gridwidth = 1; layout.setConstraints(length, con); length.setFont(FONT_BOLD); add(length); int l = (int) (o.getLength() * 10000); JTextField lengthEdit = new JTextField((Double.toString(((double) l) / 10000))); con.gridwidth = GridBagConstraints.REMAINDER; con.weightx = 1.0; con.fill = GridBagConstraints.HORIZONTAL; layout.setConstraints(lengthEdit, con); lengthEdit.setFont(FONT_PLAIN); add(lengthEdit); lengthEdit.addKeyListener(new MyKeyListener(o, LENGTH)); JPanel vfiller = new JPanel(); vfiller.setOpaque(true); con.weighty = 1.0; con.fill = GridBagConstraints.BOTH; layout.setConstraints(vfiller, con); add(vfiller); } /** * Display the surface * @param o The object */ void displaySurface(Surface o) { GridBagLayout layout = new GridBagLayout(); GridBagConstraints con = new GridBagConstraints(); setLayout(layout); JLabel name = new JLabel("Name: "); con.anchor = GridBagConstraints.NORTH; con.weightx = 0; layout.setConstraints(name, con); name.setFont(FONT_BOLD); add(name); JLabel surfaceName = new JLabel(o.getName()); layout.setConstraints(surfaceName, con); surfaceName.setFont(FONT_PLAIN); add(surfaceName); JPanel hfiller = new JPanel(); hfiller.setOpaque(true); con.weightx = 1.0; con.gridwidth = GridBagConstraints.REMAINDER; layout.setConstraints(hfiller, con); add(hfiller); JLabel fspace = new JLabel("Space: "); con.weightx = 0; con.gridwidth = 1; layout.setConstraints(fspace, con); fspace.setFont(FONT_BOLD); add(fspace); String fsn; if (o.getFrontDomain() == null) { fsn = "None"; } else { fsn = o.getFrontDomain().getName(); } JLabel frontSpaceName = new JLabel(fsn); layout.setConstraints(frontSpaceName, con); con.weightx = 1; con.fill = GridBagConstraints.HORIZONTAL; con.gridwidth = GridBagConstraints.REMAINDER; layout.setConstraints(frontSpaceName, con); frontSpaceName.setFont(FONT_PLAIN); add(frontSpaceName); { 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; con.gridwidth = GridBagConstraints.REMAINDER; layout.setConstraints(front, con); add(front); front.addMouseListener(new MyMouseListener(o, true)); //true = front color to be changed } JLabel bspace = new JLabel("Space: "); con.weightx = 0; con.gridwidth = 1; layout.setConstraints(bspace, con); bspace.setFont(FONT_BOLD); add(bspace); String bsn; if (o.getBackDomain() == null) { bsn = "None"; } else { bsn = o.getBackDomain().getName(); } JLabel backSpaceName = new JLabel(bsn); layout.setConstraints(backSpaceName, con); con.weightx = 1; con.gridwidth = GridBagConstraints.REMAINDER; layout.setConstraints(backSpaceName, con); backSpaceName.setFont(FONT_PLAIN); add(backSpaceName); { 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; 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); } /** * Display the camera * @param c The camera */ void displayCamera(Camera c) { GridBagLayout layout = new GridBagLayout(); GridBagConstraints con = new GridBagConstraints(); setLayout(layout); JLabel name = new JLabel("Name: "); con.anchor = GridBagConstraints.NORTH; con.weightx = 0; layout.setConstraints(name, con); name.setFont(FONT_BOLD); add(name); JLabel cameraName = new JLabel(c.getName()); layout.setConstraints(cameraName, con); cameraName.setFont(FONT_PLAIN); add(cameraName); // make a empty line JPanel hfiller = new JPanel(); hfiller.setOpaque(true); con.weightx = 1.0; con.gridwidth = GridBagConstraints.REMAINDER; layout.setConstraints(hfiller, con); add(hfiller); // make tab indentation JLabel emptyLine = new JLabel(" "); con.weightx = 1; con.gridwidth = GridBagConstraints.REMAINDER; layout.setConstraints(emptyLine, con); add(emptyLine); con.gridwidth = 2; JPanel type = new JPanel(); type.setMinimumSize(new Dimension(120, 120)); type.setBorder(BorderFactory.createTitledBorder("Type")); type.setLayout(new GridBagLayout()); GridBagConstraints typeCon = new GridBagConstraints(); typeCon.fill = GridBagConstraints.HORIZONTAL; typeCon.gridwidth = 2; // Let top label cover 2 collums typeCon.weightx = 0.5; typeCon.gridx = 0; typeCon.gridy = 0; JLabel cam = new JLabel("Camera:"); cam.setFont(FONT_BOLD); type.add(cam, typeCon); // ADD the camera coordinates double[] camera = c.getCamera(); typeCon.gridwidth = 1; typeCon.gridx = 0; typeCon.gridy = 1; JLabel camxl = new JLabel("x:"); type.add(camxl, typeCon); JTextField camx = new JTextField("" + camera[0]); typeCon.gridx = 1; typeCon.gridy = 1; type.add(camx, typeCon); JLabel camyl = new JLabel("y:"); typeCon.gridx = 0; typeCon.gridy = 2; type.add(camyl, typeCon); JTextField camy = new JTextField("" + camera[1]); typeCon.gridx = 1; typeCon.gridy = 2; type.add(camy, typeCon); JLabel camzl = new JLabel("z:"); typeCon.gridx = 0; typeCon.gridy = 3; type.add(camzl, typeCon); JTextField camz = new JTextField("" + camera[2]); typeCon.gridx = 1; typeCon.gridy = 3; type.add(camz, typeCon); // ADD the eye pointcoordinates typeCon.gridwidth = 2; // Let top label cover 2 collums double[] eye = c.getCenter(); typeCon.gridx = 0; typeCon.gridy = 4; JLabel eyel = new JLabel("Eye-point:"); cam.setFont(FONT_BOLD); type.add(eyel, typeCon); typeCon.gridwidth = 1; JLabel eyexl = new JLabel("x:"); typeCon.gridx = 0; typeCon.gridy = 5; type.add(eyexl, typeCon); JTextField eyex = new JTextField("" + eye[0]); typeCon.gridx = 1; typeCon.gridy = 5; type.add(eyex, typeCon); JLabel eyeyl = new JLabel("y:"); typeCon.gridx = 0; typeCon.gridy = 6; type.add(eyeyl, typeCon); JTextField eyey = new JTextField("" + eye[1]); typeCon.gridx = 1; typeCon.gridy = 6; type.add(eyey, typeCon); JLabel eyezl = new JLabel("z:"); typeCon.gridx = 0; typeCon.gridy = 7; type.add(eyezl, typeCon); JTextField eyez = new JTextField("" + eye[2]); typeCon.gridx = 1; typeCon.gridy = 7; type.add(eyez, typeCon); // ADD the roll coordinates typeCon.gridwidth = 2; // Let top label cover 2 collums double[] roll = c.getRoll(); typeCon.gridx = 0; typeCon.gridy = 8; JLabel rolll = new JLabel("Roll:"); cam.setFont(FONT_BOLD); type.add(rolll, typeCon); typeCon.gridwidth = 1; JLabel rollxl = new JLabel("x:"); typeCon.gridx = 0; typeCon.gridy = 9; type.add(rollxl, typeCon); JTextField rollx = new JTextField("" + roll[0]); typeCon.gridx = 1; typeCon.gridy = 9; type.add(rollx, typeCon); JLabel rollyl = new JLabel("y:"); typeCon.gridx = 0; typeCon.gridy = 10; type.add(rollyl, typeCon); JTextField rolly = new JTextField("" + roll[1]); typeCon.gridx = 1; typeCon.gridy = 10; type.add(rolly, typeCon); JLabel rollzl = new JLabel("z:"); typeCon.gridx = 0; typeCon.gridy = 11; type.add(rollzl, typeCon); JTextField rollz = new JTextField("" + roll[2]); typeCon.gridx = 1; typeCon.gridy = 11; type.add(rollz, typeCon); add(type, con); } /** * Display the object * @param o The object */ void display(Object o) { current = o; removeAll(); if (current instanceof Space) { Space space = (Space) current; displaySpace(space); } else if (current instanceof Surface) { displaySurface((Surface) current); } else if (current instanceof Camera) { displayCamera((Camera) current); } else if (current instanceof Edge) { displayEdge((Edge) current); } else if (current instanceof Vertex) { displayVertex((Vertex) current); } else { if (current != null) { log.info("display " + current); } } revalidate(); } } --- NEW FILE: GenericAttribute.java --- //--------------------------------------------------------------------------------- // $Id: GenericAttribute.java,v 1.1 2006/02/03 15:23:00 rimestad 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 javax.swing.Box; import net.sourceforge.bprocessor.model.Attribute; /** * The AbstractAttribute interface for objects representing *one* attribute */ public abstract class GenericAttribute extends Box { /** * Constructor * @param arg0 The same argument as for Box (BoxLayout) */ public GenericAttribute(int arg0) { super(arg0); } /** * Return the attribute for this gui attribute * @return The name */ public abstract Attribute attribute(); /** * Called when editing is started on this attribute * Should change the component to an editing state */ public abstract void startEditing(); /** * Called when editing is stopped on this attribute * Should send a valueChanged to any listeners in concrete attribute, * and change the component to the default non-editing state */ public abstract void stopEditing(); /** * Called when editing should be cancelled on this attribute. * Should change the state back to before editing was started. * Should not send events the listeners. */ public abstract void cancelEditing(); } --- NEW FILE: GenericPanel.java --- //--------------------------------------------------------------------------------- // $Id: GenericPanel.java,v 1.1 2006/02/03 15:23:00 rimestad 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.event.MouseEvent; import java.awt.event.MouseListener; import java.util.Iterator; import java.util.List; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JPanel; import net.sourceforge.bprocessor.model.Attribute; import net.sourceforge.bprocessor.model.Parametric; /** * A generic panel for classes that implement the parametric interface */ class GenericPanel extends JPanel implements MouseListener { /** The current object shown */ private Parametric obj; /** The list of attributes */ private List attributes; /** The box of content */ private Box content; /** The current edited attribute */ private GenericAttribute current; /** * The constructor * @param param The content */ public GenericPanel(Parametric param) { super(); this.content = Box.createVerticalBox(); obj = param; attributes = param.getAttributes(); generateContent(attributes); add(this.content); addMouseListener(this); } /** * local method for generating the content * @param what The list of attrinutes */ private void generateContent(List what) { Iterator iter = what.iterator(); while (iter.hasNext()) { Attribute a = (Attribute)iter.next(); if (a.getValue() instanceof String) { StringAttribute sa = new StringAttribute(a); sa.addStringAttributeListener(new AttributeListener() { public void valueChanged(Attribute a) { System.out.println("WOW"); obj.setAttributes(attributes); } }); sa.addMouseListener(this); content.add(new AttributeRow(sa)); } } } /** * Start editing the specified AttributeView * @param ga The genericAttribute to edit */ public void startEditing(GenericAttribute ga) { if (current != null) { current.stopEditing(); } current = ga; if (current != null) { ga.startEditing(); } } /** * Stop editing the current AttributeView */ public void stopEditing() { if (current != null) { current.stopEditing(); current = null; } } /** * Stop editing the current attribute * @param event The mouse event */ public void mouseClicked(MouseEvent event) { stopEditing(); } /** * Not in use * @param event The MouseEvent */ public void mousePressed(MouseEvent event) { } /** * Not in use * @param event The MouseEvent */ public void mouseReleased(MouseEvent event) { } /** * Not in use * @param event The MouseEvent */ public void mouseEntered(MouseEvent event) { } /** * Not in use * @param event The MouseEvent */ public void mouseExited(MouseEvent event) { } /** * The AttributeRow */ protected class AttributeRow extends Box implements MouseListener { /** The AttributeView displayed in this AttributeRow */ private GenericAttribute ga; /** * Constructor for AttributeRow * @param ga The generic attribute to put in the */ public AttributeRow(GenericAttribute ga) { super(BoxLayout.X_AXIS); this.ga = ga; this.add(ga); ga.addMouseListener(this); } /** * Start editing on the view * @param event The event */ public void mouseClicked(MouseEvent event) { startEditing(ga); } /** * Not in use * @param event The MouseEvent */ public void mousePressed(MouseEvent event) { } /** * Not in use * @param event The MouseEvent */ public void mouseReleased(MouseEvent event) { } /** * Not in use * @param event The MouseEvent */ public void mouseEntered(MouseEvent event) { } /** * Not in use * @param event The MouseEvent */ public void mouseExited(MouseEvent event) { } } } Index: AttributeView.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview/AttributeView.java,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** AttributeView.java 2 Feb 2006 10:55:19 -0000 1.31 --- AttributeView.java 3 Feb 2006 15:23:00 -0000 1.32 *************** *** 7,38 **** package net.sourceforge.bprocessor.gui.attrview; - import net.sourceforge.bprocessor.gui.Defaults; - import net.sourceforge.bprocessor.model.Attribute; - import net.sourceforge.bprocessor.model.Camera; - import net.sourceforge.bprocessor.model.Material; import net.sourceforge.bprocessor.model.Observer; import net.sourceforge.bprocessor.model.Parametric; import net.sourceforge.bprocessor.model.Project; import net.sourceforge.bprocessor.model.Selection; - import net.sourceforge.bprocessor.model.Space; - import net.sourceforge.bprocessor.model.Surface; - import net.sourceforge.bprocessor.model.Edge; - import net.sourceforge.bprocessor.model.Vertex; - import java.awt.Color; import java.awt.Dimension; - import java.awt.Font; - import java.awt.GridBagLayout; - import java.awt.GridBagConstraints; - import java.util.Iterator; - import java.util.List; - import javax.swing.BorderFactory; - import javax.swing.JLabel; import javax.swing.JPanel; - import javax.swing.JTabbedPane; - import javax.swing.JTextArea; - import javax.swing.JTextField; - import javax.swing.border.Border; import org.apache.log4j.Logger; --- 7,18 ---- *************** *** 41,51 **** * The attribute view */ ! public class AttributeView extends JTabbedPane implements Observer { /** The logger */ private static Logger log = Logger.getLogger(AttributeView.class); - /** The attributes panel */ - private JPanel container; - /** * Constructor --- 21,28 ---- * The attribute view */ ! public class AttributeView extends JPanel implements Observer { /** The logger */ private static Logger log = Logger.getLogger(AttributeView.class); /** * Constructor *************** *** 53,60 **** public AttributeView() { super(); - - container = new JPanel(); - - addTab("Attributes", container); setMinimumSize(new Dimension(120, 240)); setPreferredSize(new Dimension(120, 240)); --- 30,33 ---- *************** *** 71,82 **** if (selection.size() > 0) { Object o = selection.iterator().next(); ! container.removeAll(); if (o instanceof Parametric) { ! log.info("Were Parametric" + o); ! container.add(new GenericPanel((Parametric)o)); } else { ! AttributesPanel ap = new AttributesPanel(); ap.display(o); ! container.add(ap); } } --- 44,54 ---- if (selection.size() > 0) { Object o = selection.iterator().next(); ! this.removeAll(); if (o instanceof Parametric) { ! this.add(new GenericPanel((Parametric)o)); } else { ! AttributePanel ap = new AttributePanel(); ap.display(o); ! this.add(ap); } } *************** *** 86,712 **** ap.display(current); }*/ repaint(); } - - /** - * A generic panel for classes that implement the parametric interface - */ - class GenericPanel extends JPanel { - /** The current object shown */ - private Parametric obj; - - /** - * The constructor - * @param content The content - */ - public GenericPanel(Parametric content) { - super(); - obj = content; - generateContent(content.getAttributes()); - } - - /** - * local method for generating the content - * @param what The list of attrinutes - */ - private void generateContent(List what) { - Iterator iter = what.iterator(); - while (iter.hasNext()) { - Attribute a = (Attribute)iter.next(); - if (a.getValue() instanceof String) { - this.add(new JLabel((String)(a.getValue()))); - } - } - } - } - - /** - * Attributes panel - */ - class AttributesPanel extends JPanel { - /** Current object */ - private Object current; - - /** The font used in plain */ - private Font fontPlain = new Font("Sans-serif", Font.PLAIN, 12); - - /** The font used in bold */ - private Font fontBold = new Font("Sans-serif", Font.BOLD, 12); - - /** If its a textfield */ - public static final int TFIELD = 1; - - /** If its a textfield */ - public static final int TAREA = 2; - - /** The length field */ - public static final int LENGTH = 3; - - /** The X coordinate */ - public static final int XCOOR = 4; - - /** The Y coordinate */ - public static final int YCOOR = 5; - - /** The Z coordinate */ - public static final int ZCOOR = 6; - - /** - * Constructor - */ - AttributesPanel() { - current = null; - } - - /** - * Get current - * @return Current - */ - public Object getCurrent() { - return current; - } - /** - * Display the construction space - * @param o The object - */ - void displaySpace(Space o) { - GridBagLayout layout = new GridBagLayout(); - GridBagConstraints con = new GridBagConstraints(); - setLayout(layout); - - JLabel name = new JLabel("Name:"); - con.anchor = GridBagConstraints.NORTHEAST; - con.weightx = 0; - layout.setConstraints(name, con); - name.setFont(fontBold); - add(name); - - - JTextField nameEdit = new JTextField(o.getName()); - con.gridwidth = GridBagConstraints.REMAINDER; - con.weightx = 1.0; - con.fill = GridBagConstraints.HORIZONTAL; - layout.setConstraints(nameEdit, con); - nameEdit.setFont(fontPlain); - add(nameEdit); - nameEdit.addKeyListener(new MyKeyListener(o, TFIELD)); - - JTextArea descriptionEditor = new JTextArea(o.getDescription()); - descriptionEditor.setLineWrap(true); - descriptionEditor.setWrapStyleWord(true); - con.weighty = 1.0; - con.fill = GridBagConstraints.BOTH; - layout.setConstraints(descriptionEditor, con); - descriptionEditor.addFocusListener(new MyFocusListener(o)); - add(descriptionEditor); - } - - /** - * 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]); - } - - /** - * 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]); - } - - /** - * 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(); - } - } - } - - /** - * Display the edge - * @param o The object - */ - void displayVertex(Vertex o) { - GridBagLayout layout = new GridBagLayout(); - GridBagConstraints con = new GridBagConstraints(); - setLayout(layout); - - JLabel name = new JLabel("Name: "); - con.anchor = GridBagConstraints.NORTH; - con.weightx = 0; - layout.setConstraints(name, con); - name.setFont(fontBold); - add(name); - - JLabel vertexName = new JLabel(o.getName()); - layout.setConstraints(vertexName, con); - vertexName.setFont(fontPlain); - add(vertexName); - - JPanel hfiller = new JPanel(); - hfiller.setOpaque(true); - con.weightx = 1.0; - con.gridwidth = GridBagConstraints.REMAINDER; - layout.setConstraints(hfiller, con); - add(hfiller); - - JLabel x = new JLabel("X: "); - con.anchor = GridBagConstraints.NORTH; - con.gridwidth = 1; - con.weightx = 0; - layout.setConstraints(x, con); - x.setFont(fontBold); - add(x); - - int xval = (int) (o.getX() * 10000); - JTextField xEdit = new JTextField((Double.toString(((double) xval) / 10000))); - con.gridwidth = GridBagConstraints.REMAINDER; - con.weightx = 1.0; - con.fill = GridBagConstraints.HORIZONTAL; - layout.setConstraints(xEdit, con); - xEdit.setFont(fontPlain); - add(xEdit); - xEdit.addKeyListener(new MyKeyListener(o, XCOOR)); - - JLabel y = new JLabel("Y: "); - con.gridwidth = 1; - con.weightx = 0; - con.fill = GridBagConstraints.NONE; - layout.setConstraints(y, con); - y.setFont(fontBold); - add(y); - - int yval = (int) (o.getY() * 10000); - JTextField yEdit = new JTextField((Double.toString(((double) yval) / 10000))); - con.gridwidth = GridBagConstraints.REMAINDER; - con.weightx = 1.0; - con.fill = GridBagConstraints.HORIZONTAL; - layout.setConstraints(yEdit, con); - yEdit.setFont(fontPlain); - add(yEdit); - yEdit.addKeyListener(new MyKeyListener(o, YCOOR)); - - JLabel z = new JLabel("Z: "); - con.gridwidth = 1; - con.weightx = 0; - con.fill = GridBagConstraints.NONE; - layout.setConstraints(z, con); - z.setFont(fontBold); - add(z); - - int zval = (int) (o.getZ() * 10000); - JTextField zEdit = new JTextField((Double.toString(((double) zval) / 10000))); - con.gridwidth = GridBagConstraints.REMAINDER; - con.weightx = 1.0; - con.fill = GridBagConstraints.HORIZONTAL; - layout.setConstraints(zEdit, con); - zEdit.setFont(fontPlain); - add(zEdit); - zEdit.addKeyListener(new MyKeyListener(o, ZCOOR)); - - JPanel vfiller = new JPanel(); - vfiller.setOpaque(true); - con.weighty = 1.0; - con.fill = GridBagConstraints.BOTH; - layout.setConstraints(vfiller, con); - add(vfiller); - - - - } - - /** - * Display the edge - * @param o The object - */ - void displayEdge(Edge o) { - GridBagLayout layout = new GridBagLayout(); - GridBagConstraints con = new GridBagConstraints(); - setLayout(layout); - - JLabel name = new JLabel("Name: "); - con.anchor = GridBagConstraints.NORTH; - con.weightx = 0; - layout.setConstraints(name, con); - name.setFont(fontBold); - add(name); - - JLabel edgeName = new JLabel(o.getName()); - layout.setConstraints(edgeName, con); - edgeName.setFont(fontPlain); - add(edgeName); - - JPanel hfiller = new JPanel(); - hfiller.setOpaque(true); - con.weightx = 1.0; - con.gridwidth = GridBagConstraints.REMAINDER; - layout.setConstraints(hfiller, con); - add(hfiller); - - JLabel length = new JLabel("Length: "); - con.anchor = GridBagConstraints.NORTH; - con.weightx = 0; - con.gridwidth = 1; - layout.setConstraints(length, con); - length.setFont(fontBold); - add(length); - - int l = (int) (o.getLength() * 10000); - JTextField lengthEdit = new JTextField((Double.toString(((double) l) / 10000))); - con.gridwidth = GridBagConstraints.REMAINDER; - con.weightx = 1.0; - con.fill = GridBagConstraints.HORIZONTAL; - layout.setConstraints(lengthEdit, con); - lengthEdit.setFont(fontPlain); - add(lengthEdit); - lengthEdit.addKeyListener(new MyKeyListener(o, LENGTH)); - - - JPanel vfiller = new JPanel(); - vfiller.setOpaque(true); - con.weighty = 1.0; - con.fill = GridBagConstraints.BOTH; - layout.setConstraints(vfiller, con); - add(vfiller); - - - } - - - /** - * Display the surface - * @param o The object - */ - void displaySurface(Surface o) { - GridBagLayout layout = new GridBagLayout(); - GridBagConstraints con = new GridBagConstraints(); - setLayout(layout); - - JLabel name = new JLabel("Name: "); - con.anchor = GridBagConstraints.NORTH; - con.weightx = 0; - layout.setConstraints(name, con); - name.setFont(fontBold); - add(name); - - JLabel surfaceName = new JLabel(o.getName()); - layout.setConstraints(surfaceName, con); - surfaceName.setFont(fontPlain); - add(surfaceName); - - JPanel hfiller = new JPanel(); - hfiller.setOpaque(true); - con.weightx = 1.0; - con.gridwidth = GridBagConstraints.REMAINDER; - layout.setConstraints(hfiller, con); - add(hfiller); - - JLabel fspace = new JLabel("Space: "); - con.weightx = 0; - con.gridwidth = 1; - layout.setConstraints(fspace, con); - fspace.setFont(fontBold); - add(fspace); - - String fsn; - if (o.getFrontDomain() == null) { - fsn = "None"; - } else { - fsn = o.getFrontDomain().getName(); - } - - JLabel frontSpaceName = new JLabel(fsn); - layout.setConstraints(frontSpaceName, con); - con.weightx = 1; - con.fill = GridBagConstraints.HORIZONTAL; - con.gridwidth = GridBagConstraints.REMAINDER; - layout.setConstraints(frontSpaceName, con); - frontSpaceName.setFont(fontPlain); - add(frontSpaceName); - - { - 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; - con.gridwidth = GridBagConstraints.REMAINDER; - layout.setConstraints(front, con); - add(front); - front.addMouseListener(new MyMouseListener(o, true)); //true = front color to be changed - } - - JLabel bspace = new JLabel("Space: "); - con.weightx = 0; - con.gridwidth = 1; - layout.setConstraints(bspace, con); - bspace.setFont(fontBold); - add(bspace); - - String bsn; - if (o.getBackDomain() == null) { - bsn = "None"; - } else { - bsn = o.getBackDomain().getName(); - } - - JLabel backSpaceName = new JLabel(bsn); - layout.setConstraints(backSpaceName, con); - con.weightx = 1; - con.gridwidth = GridBagConstraints.REMAINDER; - layout.setConstraints(backSpaceName, con); - backSpaceName.setFont(fontPlain); - add(backSpaceName); - - { - 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; - 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); - } - - /** - * Display the camera - * @param c The camera - */ - void displayCamera(Camera c) { - GridBagLayout layout = new GridBagLayout(); - GridBagConstraints con = new GridBagConstraints(); - setLayout(layout); - - JLabel name = new JLabel("Name: "); - con.anchor = GridBagConstraints.NORTH; - con.weightx = 0; - layout.setConstraints(name, con); - name.setFont(fontBold); - add(name); - - JLabel cameraName = new JLabel(c.getName()); - layout.setConstraints(cameraName, con); - cameraName.setFont(fontPlain); - add(cameraName); - - // make a empty line - JPanel hfiller = new JPanel(); - hfiller.setOpaque(true); - con.weightx = 1.0; - con.gridwidth = GridBagConstraints.REMAINDER; - layout.setConstraints(hfiller, con); - add(hfiller); - - // make tab indentation - JLabel emptyLine = new JLabel(" "); - con.weightx = 1; - con.gridwidth = GridBagConstraints.REMAINDER; - layout.setConstraints(emptyLine, con); - add(emptyLine); - - con.gridwidth = 2; - JPanel type = new JPanel(); - type.setMinimumSize(new Dimension(120, 120)); - type.setBorder(BorderFactory.createTitledBorder("Type")); - type.setLayout(new GridBagLayout()); - GridBagConstraints typeCon = new GridBagConstraints(); - typeCon.fill = GridBagConstraints.HORIZONTAL; - typeCon.gridwidth = 2; // Let top label cover 2 collums - typeCon.weightx = 0.5; - typeCon.gridx = 0; - typeCon.gridy = 0; - JLabel cam = new JLabel("Camera:"); - cam.setFont(fontBold); - type.add(cam, typeCon); - - // ADD the camera coordinates - double[] camera = c.getCamera(); - typeCon.gridwidth = 1; - typeCon.gridx = 0; - typeCon.gridy = 1; - JLabel camxl = new JLabel("x:"); - type.add(camxl, typeCon); - JTextField camx = new JTextField("" + camera[0]); - typeCon.gridx = 1; - typeCon.gridy = 1; - type.add(camx, typeCon); - JLabel camyl = new JLabel("y:"); - typeCon.gridx = 0; - typeCon.gridy = 2; - type.add(camyl, typeCon); - JTextField camy = new JTextField("" + camera[1]); - typeCon.gridx = 1; - typeCon.gridy = 2; - type.add(camy, typeCon); - JLabel camzl = new JLabel("z:"); - typeCon.gridx = 0; - typeCon.gridy = 3; - type.add(camzl, typeCon); - JTextField camz = new JTextField("" + camera[2]); - typeCon.gridx = 1; - typeCon.gridy = 3; - type.add(camz, typeCon); - - // ADD the eye pointcoordinates - typeCon.gridwidth = 2; // Let top label cover 2 collums - - double[] eye = c.getCenter(); - typeCon.gridx = 0; - typeCon.gridy = 4; - JLabel eyel = new JLabel("Eye-point:"); - cam.setFont(fontBold); - type.add(eyel, typeCon); - typeCon.gridwidth = 1; - JLabel eyexl = new JLabel("x:"); - typeCon.gridx = 0; - typeCon.gridy = 5; - type.add(eyexl, typeCon); - JTextField eyex = new JTextField("" + eye[0]); - typeCon.gridx = 1; - typeCon.gridy = 5; - type.add(eyex, typeCon); - JLabel eyeyl = new JLabel("y:"); - typeCon.gridx = 0; - typeCon.gridy = 6; - type.add(eyeyl, typeCon); - JTextField eyey = new JTextField("" + eye[1]); - typeCon.gridx = 1; - typeCon.gridy = 6; - type.add(eyey, typeCon); - JLabel eyezl = new JLabel("z:"); - typeCon.gridx = 0; - typeCon.gridy = 7; - type.add(eyezl, typeCon); - JTextField eyez = new JTextField("" + eye[2]); - typeCon.gridx = 1; - typeCon.gridy = 7; - type.add(eyez, typeCon); - - - // ADD the roll coordinates - typeCon.gridwidth = 2; // Let top label cover 2 collums - double[] roll = c.getRoll(); - typeCon.gridx = 0; - typeCon.gridy = 8; - JLabel rolll = new JLabel("Roll:"); - cam.setFont(fontBold); - type.add(rolll, typeCon); - typeCon.gridwidth = 1; - JLabel rollxl = new JLabel("x:"); - typeCon.gridx = 0; - typeCon.gridy = 9; - type.add(rollxl, typeCon); - JTextField rollx = new JTextField("" + roll[0]); - typeCon.gridx = 1; - typeCon.gridy = 9; - type.add(rollx, typeCon); - JLabel rollyl = new JLabel("y:"); - typeCon.gridx = 0; - typeCon.gridy = 10; - type.add(rollyl, typeCon); - JTextField rolly = new JTextField("" + roll[1]); - typeCon.gridx = 1; - typeCon.gridy = 10; - type.add(rolly, typeCon); - JLabel rollzl = new JLabel("z:"); - typeCon.gridx = 0; - typeCon.gridy = 11; - type.add(rollzl, typeCon); - JTextField rollz = new JTextField("" + roll[2]); - typeCon.gridx = 1; - typeCon.gridy = 11; - type.add(rollz, typeCon); - - add(type, con); - } - - /** - * Display the object - * @param o The object - */ - void display(Object o) { - current = o; - removeAll(); - if (current instanceof Space) { - Space space = (Space) current; - displaySpace(space); - } else if (current instanceof Surface) { - displaySurface((Surface) current); - } else if (current instanceof Camera) { - displayCamera((Camera) current); - } else if (current instanceof Edge) { - displayEdge((Edge) current); - } else if (current instanceof Vertex) { - displayVertex((Vertex) current); - } else { - if (current != null) { - log.info("display " + current); - } - } - revalidate(); - } - } } - --- 58,63 ---- ap.display(current); }*/ + revalidate(); repaint(); } } |