Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29503/src/net/sourceforge/bprocessor/gl/tool
Modified Files:
AbstractPencil.java
Log Message:
Parrallel edge mechanism in Pencil
Timer delays constructors until hoovering over the vertex/edge
Index: AbstractPencil.java
===================================================================
RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/AbstractPencil.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** AbstractPencil.java 29 Mar 2006 18:37:24 -0000 1.17
--- AbstractPencil.java 29 Mar 2006 21:52:51 -0000 1.18
***************
*** 8,11 ****
--- 8,13 ----
import java.awt.Cursor;
+ import java.awt.event.ActionEvent;
+ import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
***************
*** 17,20 ****
--- 19,24 ----
import java.util.Set;
+ import javax.swing.Timer;
+
import net.sourceforge.bprocessor.gl.GLView;
import net.sourceforge.bprocessor.gl.model.Intersection;
***************
*** 59,62 ****
--- 63,69 ----
protected String number;
+ /** Timer */
+ protected Timer timer;
+
/**
* Constructor
***************
*** 66,69 ****
--- 73,78 ----
public AbstractPencil(GLView glv, Cursor cursor) {
super(glv, cursor);
+ timer = new Timer(1000, new TargetAction());
+ timer.setRepeats(false);
}
***************
*** 260,263 ****
--- 269,286 ----
if (incident != null) {
constructors.addAll(xyz(incident.vertex()));
+ if (incident.type() == Intersection.EDGE_MIDPOINT) {
+ Edge edge = (Edge) incident.object();
+ Vertex v = edge.getDirection();
+ v.scale(50 / v.length());
+ Edge parrallel = null;
+ if (start != null) {
+ parrallel = new Edge(start.vertex().minus(v), start.vertex().add(v));
+ } else {
+ parrallel = new Edge(incident.vertex().minus(v), incident.vertex().add(v));
+ }
+ parrallel.setConstructor(true);
+ glv.getView().changeColor(parrallel, new float[] {1, 1, 0});
+ constructors.add(parrallel);
+ }
}
constructors(constructors);
***************
*** 295,302 ****
--- 318,377 ----
/**
+ * TargetAction
+ */
+ protected class TargetAction implements ActionListener {
+ /**
+ * ActionPerformed
+ * @param event ActionEvent
+ */
+ public void actionPerformed(ActionEvent event) {
+ hoover();
+ }
+ }
+
+ /**
+ * Hover is called whenever the mouse stands still for
+ * a specific delay.
+ */
+ protected void hoover() {
+ if (current == null) {
+ return;
+ }
+ if (start != null) {
+ if (current.vertex() == start.vertex()) {
+ return;
+ }
+ }
+
+ switch (current.type()) {
+ case Intersection.VERTEX:
+ incident = current;
+ break;
+ case Intersection.EDGE:
+ break;
+ case Intersection.SURFACE:
+ break;
+ case Intersection.EDGE_MIDPOINT:
+ incident = current;
+ break;
+ case Intersection.EDGE_INTERSECTION:
+ incident = current;
+ break;
+ case Intersection.SURFACE_INTERSECTION:
+ incident = current;
+ break;
+ case Intersection.PLANE_INTERSECTION:
+ break;
+ }
+ updateConstructors();
+ glv.repaint();
+ }
+
+ /**
* Make target
* @param intersection Intersection
*/
protected void makeTarget(Intersection intersection) {
+ timer.restart();
if (intersection != null) {
Object target = null;
***************
*** 305,315 ****
case Intersection.VERTEX:
target = current;
- if (start != null) {
- if (intersection.vertex() != start.vertex()) {
- incident = intersection;
- }
- } else {
- incident = intersection;
- }
break;
case Intersection.EDGE:
--- 380,383 ----
***************
*** 321,331 ****
case Intersection.EDGE_MIDPOINT:
target = current;
- if (start != null) {
- if (intersection.vertex() != start.vertex()) {
- incident = intersection;
- }
- } else {
- incident = intersection;
- }
break;
case Intersection.EDGE_INTERSECTION:
--- 389,392 ----
***************
*** 493,496 ****
--- 554,558 ----
number = "";
glv.repaint();
+ timer.stop();
}
}
|