[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl GLView.java,1.32,1.33
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2006-01-06 15:36:23
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25160/src/net/sourceforge/bprocessor/gl Modified Files: GLView.java Log Message: Selection refactored. Selection is now a special observable collection. Views responds to changed in the selection. Index: GLView.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/GLView.java,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** GLView.java 4 Jan 2006 14:29:51 -0000 1.32 --- GLView.java 6 Jan 2006 15:36:14 -0000 1.33 *************** *** 14,20 **** import net.sourceforge.bprocessor.model.Observer; import net.sourceforge.bprocessor.model.Project; ! import net.sourceforge.bprocessor.kernel.notification.NotificationListener; ! import net.sourceforge.bprocessor.kernel.notification.Notification; ! import net.sourceforge.bprocessor.kernel.notification.Notifier; import net.sourceforge.bprocessor.gui.GUI; --- 14,18 ---- import net.sourceforge.bprocessor.model.Observer; import net.sourceforge.bprocessor.model.Project; ! import net.sourceforge.bprocessor.model.Selection; import net.sourceforge.bprocessor.gui.GUI; *************** *** 33,36 **** --- 31,35 ---- import java.awt.event.MouseListener; import java.awt.event.ActionListener; + import java.util.Collection; import javax.swing.JTextField; *************** *** 46,50 **** * The 3D display */ ! public class GLView implements MouseListener, NotificationListener, Observer { /** The logger */ private static Logger log = Logger.getLogger(GLView.class); --- 45,49 ---- * The 3D display */ ! public class GLView implements MouseListener, Observer { /** The logger */ private static Logger log = Logger.getLogger(GLView.class); *************** *** 67,71 **** public GLView() { log.info("Using JOGL version " + Version.getVersion()); ! Notifier.getInstance().addListener(this); Project.getInstance().addObserver(this); GLCapabilities glCap = new GLCapabilities(); --- 66,70 ---- public GLView() { log.info("Using JOGL version " + Version.getVersion()); ! Selection.primary().addObserver(this); Project.getInstance().addObserver(this); GLCapabilities glCap = new GLCapabilities(); *************** *** 248,252 **** * The length field class */ ! class LengthField extends JTextField implements NotificationListener { /** The logger */ private Logger log = Logger.getLogger(LengthField.class); --- 247,251 ---- * The length field class */ ! class LengthField extends JTextField implements Observer { /** The logger */ private Logger log = Logger.getLogger(LengthField.class); *************** *** 257,262 **** public LengthField() { super(15); ! ! Notifier.getInstance().addListener(this); } --- 256,260 ---- public LengthField() { super(15); ! Selection.primary().addObserver(this); } *************** *** 284,313 **** return 0; } - - /** - * Handle a notification - * @param n The notification - */ - public void handleNotification(Notification n) { - if (n.getType().equals(Notification.EDGE_SELECTED)) { - Edge e = (Project.getInstance().findEdgeById(n.getObject())); - setText(e.getLength()); - } else if (n.getType().equals(Notification.EDGE_DESELECTED)) { - setText(0); - } - } - /** ! * Should the listener handle this notification ! * @param type The notification type ! * @return Returns true on SELECTED events; otherwise false */ ! public boolean isNotificationEnabled(String type) { ! if (type.equals(Notification.EDGE_SELECTED) || ! type.equals(Notification.EDGE_DESELECTED)) { ! return true; ! } ! return false; } } --- 282,304 ---- return 0; } /** ! * @param object The changed object (Selection) */ ! public void update(Object object) { ! Collection selection = Selection.primary(); ! if (selection == object) { ! if (selection.size() == 1) { ! Object entity = selection.iterator().next(); ! if (entity instanceof Edge) { ! Edge edge = (Edge) entity; ! setText(edge.getLength()); ! } else { ! setText(0); ! } ! } else { ! setText(0); ! } ! } } } *************** *** 350,381 **** /** - * Handle a notification - * @param n The notification - */ - public void handleNotification(Notification n) { - repaint(); - } - - /** - * Should the listener handle this notification - * @param type The notification type - * @return True if it should handle it; otherwise false - */ - public boolean isNotificationEnabled(String type) { - if (type.equals(Notification.FUNCTIONAL_SPACE_SELECTED) || - type.equals(Notification.FUNCTIONAL_SPACE_DESELECTED) || - type.equals(Notification.CONSTRUCTION_SPACE_SELECTED) || - type.equals(Notification.CONSTRUCTION_SPACE_DESELECTED)) { - return true; - } - return false; - } - - /** * Update this view * @param entity The changed entity */ public void update(Object entity) { ! repaint(); } } --- 341,353 ---- /** * Update this view * @param entity The changed entity */ public void update(Object entity) { ! if (entity == Selection.primary()) { ! repaint(); ! } else { ! repaint(); ! } } } |