Thread: [Bprocessor-commit] gui/src/net/sourceforge/bprocessor/gui/attrview BooleanAttribute.java, NONE, 1.
Status: Pre-Alpha
Brought to you by:
henryml
From: Nikolaj B. <nbr...@us...> - 2006-07-17 08:32:04
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv23042/src/net/sourceforge/bprocessor/gui/attrview Modified Files: GenericPanel.java Added Files: BooleanAttribute.java Log Message: Constructionspaces can now be transparent Index: GenericPanel.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview/GenericPanel.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** GenericPanel.java 26 Jun 2006 11:37:52 -0000 1.18 --- GenericPanel.java 17 Jul 2006 08:32:00 -0000 1.19 *************** *** 175,178 **** --- 175,195 ---- }); where.add(new AttributeRow(ma)); + } else if (a.getValue() instanceof Boolean) { + // Handles the booleans + BooleanAttribute ba = new BooleanAttribute(a); + ba.addBooleanAttributeListener(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(ba)); } else if (a.getValue() instanceof String[]) { // Handles the classification --- NEW FILE: BooleanAttribute.java --- //--------------------------------------------------------------------------------- // $Id: BooleanAttribute.java,v 1.1 2006/07/17 08:32:00 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.ItemEvent; import java.awt.event.ItemListener; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JLabel; import net.sourceforge.bprocessor.model.Attribute; /** * The BooleanAttributeView */ public class BooleanAttribute extends GenericAttribute implements ItemListener { /** The listeners */ private List listeners; /** The attribute this gui represents */ private Attribute attribute; /** The component */ private JComponent component; /** The Label */ private JLabel label; /** The valueLabel */ private JCheckBox valueLabel; /** * Constructor for BooleanAttribute * @param attribute The attribute */ public BooleanAttribute(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 addBooleanAttributeListener(AttributeListener listener) { listeners.add(listener); } /** * Remove a listener * @param listener The listener */ public void removeBooleanAttributeListener(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) { valueLabel = new JCheckBox(); if (((Boolean) value).booleanValue()) { valueLabel.setSelected(true); } valueLabel.addItemListener(this); return valueLabel; } /** * Return the attribute * @return The attribute */ public Attribute attribute() { return attribute; } /** Listens to the check boxes. * @param e the itemevent*/ public void itemStateChanged(ItemEvent e) { Object source = e.getItemSelectable(); if (source == valueLabel) { if (e.getStateChange() == ItemEvent.DESELECTED) { attribute.setValue(Boolean.FALSE); } else { attribute.setValue(Boolean.TRUE); } 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 } } |