Thread: [Bprocessor-commit] gui/src/net/sourceforge/bprocessor/gui/treeview GenericTreeView.java, 1.109, 1.
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2007-09-21 11:14:47
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/treeview In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv30448/src/net/sourceforge/bprocessor/gui/treeview Modified Files: GenericTreeView.java Log Message: Eye interaction changed Index: GenericTreeView.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/treeview/GenericTreeView.java,v retrieving revision 1.109 retrieving revision 1.110 diff -C2 -d -r1.109 -r1.110 *** GenericTreeView.java 21 Sep 2007 08:23:18 -0000 1.109 --- GenericTreeView.java 21 Sep 2007 11:14:48 -0000 1.110 *************** *** 9,13 **** --- 9,15 ---- import java.awt.Component; import java.awt.Dimension; + import java.awt.Event; import java.awt.Graphics; + import java.awt.Rectangle; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; *************** *** 185,200 **** */ public void paint(Graphics g) { ! super.paint(g); ! Dimension d = getPreferredSize(); ! // will be icon later if (shown == 0) { ! // hidden ! hiddenicon.paintIcon(this, g, d.width - 16, 0); } else if (shown == 1) { ! // shown ! shownicon.paintIcon(this, g, d.width - 16, 0); ! } else { ! // not defined } } --- 187,199 ---- */ public void paint(Graphics g) { ! Dimension size = getSize(); if (shown == 0) { ! hiddenicon.paintIcon(this, g, 0, (size.height - 16) / 2); ! g.translate(18, 0); } else if (shown == 1) { ! shownicon.paintIcon(this, g, 0, (size.height - 16) / 2); ! g.translate(18, 0); } + super.paint(g); } *************** *** 1334,1402 **** /** * Mouse released ! * @param e MouseEvent */ ! public void mouseReleased(MouseEvent e) { ! react(e); } /** * Mouse released ! * @param e MouseEvent */ ! public void mousePressed(MouseEvent e) { ! react(e); } ! ! /** ! * Do the thing ! * @param e the MouseEvent ! */ ! private void react(MouseEvent e) { ! TreePath path = getPathForLocation(e.getX(), e.getY()); if (path != null) { ! if (e.isPopupTrigger()) { ! if (getSelectionCount() < 2) { setSelectionPath(path); - } else { - boolean wereFound = false; - for (TreePath treepath : getSelectionPaths()) { - if (treepath.equals(path)) { - wereFound = true; - } - } - if (!wereFound) { - setSelectionPath(path); - } - } - Object object = path.getLastPathComponent(); - if (object instanceof GenericNode) { - GenericNode node = (GenericNode) object; JPopupMenu menu = node.menu(); if (menu != null) { ! menu.show(GenericTreeView.this, e.getX(), e.getY()); ! } ! } ! } else { ! Object object = path.getLastPathComponent(); ! if (e.getClickCount() > 1) { ! if (object instanceof GenericNode) { ! Object o = ((GenericNode) object).getUserObject(); ! if (o instanceof Geometric) { ! Geometric g = (Geometric) o; ! Camera c = Project.getInstance().getCurrentCamera(); ! if (c.getHiddenGeometrics().contains(g)) { ! c.removeHiddenGeometric(g); ! } else { ! c.addHiddenGeometric(g); ! } ! model.nodeChanged((GenericNode)object); ! } } } else { ! if (object instanceof GenericNode) { ! GenericNode node = (GenericNode) object; ! Object target = node.getUserObject(); ! if (target instanceof Camera) { ! Project.getInstance().setCurrentCamera((Camera) target); } } --- 1333,1373 ---- /** * Mouse released ! * @param event MouseEvent */ ! public void mouseReleased(MouseEvent event) { ! handle(event); } /** * Mouse released ! * @param event MouseEvent */ ! public void mousePressed(MouseEvent event) { ! handle(event); } ! ! private void handle(MouseEvent event) { ! TreePath path = getPathForLocation(event.getX(), event.getY()); if (path != null) { ! Object selected = path.getLastPathComponent(); ! if (selected instanceof GenericNode) { ! GenericNode node = (GenericNode) selected; ! if (event.isPopupTrigger()) { setSelectionPath(path); JPopupMenu menu = node.menu(); if (menu != null) { ! menu.show(GenericTreeView.this, event.getX(), event.getY()); } } else { ! if (event.getID() == Event.MOUSE_DOWN) { ! Object object = node.getUserObject(); ! if (object instanceof Geometric) { ! Geometric geometric = (Geometric) object; ! Rectangle bounds = getPathBounds(path); ! int x = event.getX() - bounds.x; ! if (x <= 16) { ! toggle(geometric); ! model.nodeChanged(node); ! } } } *************** *** 1405,1408 **** --- 1376,1388 ---- } } + + private void toggle(Geometric geometric) { + Camera camera = Project.getInstance().getCurrentCamera(); + if (camera.getHiddenGeometrics().contains(geometric)) { + camera.removeHiddenGeometric(geometric); + } else { + camera.addHiddenGeometric(geometric); + } + } } |