Thread: [Bprocessor-commit] gui/src/net/sourceforge/bprocessor/gui/attrview ClassificationAttribute.java, N
Status: Pre-Alpha
Brought to you by:
henryml
From: Nikolaj B. <nbr...@us...> - 2006-06-26 11:37:55
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv31918/src/net/sourceforge/bprocessor/gui/attrview Modified Files: GenericPanel.java Added Files: ClassificationAttribute.java Log Message: Spaces now have simple classification, and based on this classification an energy transmission loss can be calculated Index: GenericPanel.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview/GenericPanel.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** GenericPanel.java 24 Apr 2006 08:45:10 -0000 1.17 --- GenericPanel.java 26 Jun 2006 11:37:52 -0000 1.18 *************** *** 175,178 **** --- 175,195 ---- }); where.add(new AttributeRow(ma)); + } else if (a.getValue() instanceof String[]) { + // Handles the classification + ClassificationAttribute ca = new ClassificationAttribute(a); + ca.addClassificationAttributeListener(new AttributeListener() { + public void valueChanged(Attribute a) { + obj.setAttributes(attributes); + if (obj instanceof Entity) { + simpleUpdate = true; + ((Entity)obj).changed(); + } else if (obj instanceof Camera) { + Project.getInstance().changed((Camera)obj); + } else { + log.info("Were not a Entity object " + obj); + } + } + }); + where.add(new AttributeRow(ca)); } else { log.info("[GenericPanel] Something were not implemented"); --- NEW FILE: ClassificationAttribute.java --- //--------------------------------------------------------------------------------- // $Id: ClassificationAttribute.java,v 1.1 2006/06/26 11:37:52 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.Dimension; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.JLabel; import net.sourceforge.bprocessor.model.Attribute; /** * The ClassificationAttributeView */ public class ClassificationAttribute extends GenericAttribute implements FocusListener { /** The listeners */ private List listeners; /** The attribute this gui represents */ private Attribute attribute; /** The component */ private JComponent component; /** The Label */ private JLabel label; /** * Constructor for ClassificationAttribute * @param attribute The attribute */ public ClassificationAttribute(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.createHorizontalStrut(7)); header.add(label); header.add(Box.createHorizontalGlue()); column.add(Box.createRigidArea(new Dimension(70, 3))); column.add(header); column.add(Box.createRigidArea(new Dimension(70, 3))); column.setMaximumSize(new Dimension(60, Short.MAX_VALUE)); this.add(column); component = Box.createHorizontalBox(); component.add(createValueLabel(attribute.getValue())); this.add(component); this.add(Box.createHorizontalGlue()); } /** * Create a label for the * @param key The key * @return A JLabel */ private JLabel createLabel(String key) { JLabel keyLabel = new JLabel(key + " :"); keyLabel.setFont(AttributeView.FONT_BOLD); return keyLabel; } /** * Add a listener that are notified when the value is changed * @param listener The listener */ public void addClassificationAttributeListener(AttributeListener listener) { listeners.add(listener); } /** * Remove a listener * @param listener The listener */ public void removeClassificationAttributeListener(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(Object value) { JComboBox valueLabel; valueLabel = new JComboBox((String[]) value); if (attribute.getClassification() != null) { valueLabel.setSelectedItem(attribute.getClassification()); } valueLabel.addFocusListener(this); return valueLabel; } /** * Return the attribute * @return The attribute */ public Attribute attribute() { return attribute; } /** * Not in use * @param event The FocusEvent */ public void focusGained(FocusEvent event) { // TODO Auto-generated method stub } /** * Stop editing on the combobox * @param event The event */ public void focusLost(FocusEvent event) { attribute.setValue(((JComboBox) event.getSource()).getSelectedItem()); valueChanged(); } /** * Not in use */ public void startEditing() { // TODO Auto-generated method stub } /** * Not in use */ public void stopEditing() { // TODO Auto-generated method stub } /** * Not in use */ public void cancelEditing() { // TODO Auto-generated method stub } } |