Thread: [Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool AbstractTool.java, 1.73, 1.74 RectToo
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2006-06-20 13:31:06
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv25296/src/net/sourceforge/bprocessor/gl/tool Modified Files: AbstractTool.java RectTool.java SelectTool.java Log Message: Moved some functionallity from selectool to abstractool Index: SelectTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/SelectTool.java,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** SelectTool.java 19 Jun 2006 13:15:12 -0000 1.59 --- SelectTool.java 20 Jun 2006 13:30:58 -0000 1.60 *************** *** 8,17 **** import net.sourceforge.bprocessor.gl.GLView; - import net.sourceforge.bprocessor.gl.view.Transformation; - import net.sourceforge.bprocessor.gl.view.View; import net.sourceforge.bprocessor.model.Edge; - import net.sourceforge.bprocessor.model.Vertex; - import net.sourceforge.bprocessor.model.Surface; import java.awt.Cursor; --- 8,13 ---- *************** *** 19,23 **** import java.util.HashSet; - import java.util.List; import org.apache.log4j.Logger; --- 15,18 ---- *************** *** 30,46 **** private static Logger log = Logger.getLogger(SelectTool.class); - /** Tempoary vertexes for multiple selection */ - private Vertex first, last, temp1, temp2; - - /** Tempoary edges for multiple selection */ - private Edge e1, e2, e3, e4; - - /** The drag box */ - private HashSet box; - - /** Telling if it were a multiple selection */ - private boolean multipleSelection = false; - - /** * The constructor --- 25,28 ---- *************** *** 77,153 **** /** - * Handle a pressed event as selection tool - * @param e MouseEvent - */ - protected void selectionPressed(MouseEvent e) { - Transformation t = glv.getView().transformation(); - first = t.unProject(new Vertex(e.getX(), View.getHeight() - e.getY(), 0.001)); - e1.setFrom(first); - e4.setTo(first); - if (e.getClickCount() >= 2 && target instanceof Surface) { - Surface surface = (Surface) target; - if (surface.getBackDomain() != null) { - selection.addAll(surface.getBackDomain().getEnvelope()); - } - if (surface.getFrontDomain() != null) { - selection.addAll(surface.getFrontDomain().getEnvelope()); - } - } else { - if (target == null) { - selection.clear(); - multipleSelection = true; - } else if (e.isShiftDown()) { - if (!selection.contains(target)) { - selection.add(target); - } else { - selection.remove(target); - } - } else { - if (!selection.contains(target)) { - selection.clear(); - selection.add(target); - } - } - } - } - - /** - * Handle a dragged event as selection tool - * @param e MouseEvent - */ - protected void selectionDragged(MouseEvent e) { - if (multipleSelection) { - Transformation t = glv.getView().transformation(); - last = t.unProject(new Vertex(e.getX(), View.getHeight() - e.getY(), 0.001)); - temp1 = t.unProject(new Vertex(e.getX(), View.getHeight() - pressPos[1], 0.001)); - temp2 = t.unProject(new Vertex(pressPos[0], View.getHeight() - e.getY(), 0.001)); - e1.setTo(temp1); - e2.setFrom(temp1); - e2.setTo(last); - e3.setFrom(last); - e3.setTo(temp2); - e4.setFrom(temp2); - displayConstructors(box); - } - } - - /** - * Handle a released event as selection tool - * @param e MouseEvent - */ - protected void selectionReleased(MouseEvent e) { - if (multipleSelection) { - selection.clear(); - clearConstructors(box); - List l = glv.getView().getObjectInArea(pressPos[0], pressPos[1], - e.getX(), e.getY()); - glv.getView().makeTarget(null); - selection.addAll(l); - multipleSelection = false; - } - } - - - /** * Invoked when a mouse button has been pressed on a component. * @param e The MouseEvent object --- 59,62 ---- Index: RectTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/RectTool.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** RectTool.java 21 Apr 2006 15:06:38 -0000 1.8 --- RectTool.java 20 Jun 2006 13:30:58 -0000 1.9 *************** *** 24,30 **** */ public class RectTool extends AbstractPencil { - /** The edges in the rectangle */ - private Edge e1, e2, e3, e4; - /** The logger */ private static Logger log = Logger.getLogger(RectTool.class); --- 24,27 ---- Index: AbstractTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/AbstractTool.java,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** AbstractTool.java 20 Jun 2006 12:33:27 -0000 1.73 --- AbstractTool.java 20 Jun 2006 13:30:58 -0000 1.74 *************** *** 19,22 **** --- 19,23 ---- import net.sourceforge.bprocessor.model.Surface; import net.sourceforge.bprocessor.model.Vertex; + import net.sourceforge.bprocessor.gl.view.Transformation; import net.sourceforge.bprocessor.gl.view.View; import net.sourceforge.bprocessor.gl.GLView; *************** *** 33,36 **** --- 34,38 ---- import java.net.URL; import java.util.Iterator; + import java.util.List; import java.util.Set; import java.util.HashSet; *************** *** 88,92 **** /** The cursor for drag */ ! private Cursor dragCursor; --- 90,124 ---- /** The cursor for drag */ ! private Cursor dragCursor; ! ! /** Tempoary vertexes for multiple selection */ ! private Vertex first; ! ! /** Tempoary vertexes for multiple selection */ ! private Vertex last; ! ! /** Tempoary vertexes for multiple selection */ ! private Vertex temp1; ! ! /** Tempoary vertexes for multiple selection */ ! private Vertex temp2; ! ! /** Tempoary edges for multiple selection */ ! protected Edge e1; ! ! /** Tempoary edges for multiple selection */ ! protected Edge e2; ! ! /** Tempoary edges for multiple selection */ ! protected Edge e3; ! ! /** Tempoary edges for multiple selection */ ! protected Edge e4; ! ! /** The drag box */ ! protected HashSet box; ! ! /** Telling if it were a multiple selection */ ! private boolean multipleSelection = false; *************** *** 346,349 **** --- 378,389 ---- } + if (!e.isPopupTrigger()) { + if (e.getButton() == 1) { + if (e.isMetaDown() || e.isControlDown()) { + log.info("select-tool"); + } + } + } + pressPos[0] = e.getX(); pressPos[1] = e.getY(); *************** *** 744,746 **** --- 784,858 ---- } } + + /** + * Handle a pressed event as selection tool + * @param e MouseEvent + */ + protected void selectionPressed(MouseEvent e) { + Transformation t = glv.getView().transformation(); + first = t.unProject(new Vertex(e.getX(), View.getHeight() - e.getY(), 0.001)); + e1.setFrom(first); + e4.setTo(first); + if (e.getClickCount() >= 2 && target instanceof Surface) { + Surface surface = (Surface) target; + if (surface.getBackDomain() != null) { + selection.addAll(surface.getBackDomain().getEnvelope()); + } + if (surface.getFrontDomain() != null) { + selection.addAll(surface.getFrontDomain().getEnvelope()); + } + } else { + if (target == null) { + selection.clear(); + multipleSelection = true; + } else if (e.isShiftDown()) { + if (!selection.contains(target)) { + selection.add(target); + } else { + selection.remove(target); + } + } else { + if (!selection.contains(target)) { + selection.clear(); + selection.add(target); + } + } + } + } + + /** + * Handle a dragged event as selection tool + * @param e MouseEvent + */ + protected void selectionDragged(MouseEvent e) { + if (multipleSelection) { + Transformation t = glv.getView().transformation(); + last = t.unProject(new Vertex(e.getX(), View.getHeight() - e.getY(), 0.001)); + temp1 = t.unProject(new Vertex(e.getX(), View.getHeight() - pressPos[1], 0.001)); + temp2 = t.unProject(new Vertex(pressPos[0], View.getHeight() - e.getY(), 0.001)); + e1.setTo(temp1); + e2.setFrom(temp1); + e2.setTo(last); + e3.setFrom(last); + e3.setTo(temp2); + e4.setFrom(temp2); + displayConstructors(box); + } + } + + /** + * Handle a released event as selection tool + * @param e MouseEvent + */ + protected void selectionReleased(MouseEvent e) { + if (multipleSelection) { + selection.clear(); + clearConstructors(box); + List l = glv.getView().getObjectInArea(pressPos[0], pressPos[1], + e.getX(), e.getY()); + glv.getView().makeTarget(null); + selection.addAll(l); + multipleSelection = false; + } + } } |