KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > jawe > actions > RemovePoint


1 /*
2  * Authors:
3  * Stefanovic Nenad chupo@iis.ns.ac.yu
4  * Bojanic Sasa sasaboy@neobee.net
5  * Puskas Vladimir vpuskas@eunet.yu
6  * Pilipovic Goran zboniek@uns.ac.yu
7  *
8  */

9
10 package org.enhydra.jawe.actions;
11
12 import org.jgraph.graph.*;
13
14 import org.enhydra.jawe.*;
15 import org.enhydra.jawe.graph.*;
16 import org.enhydra.jawe.xml.*;
17 import org.enhydra.jawe.xml.panels.*;
18
19 import java.awt.event.ActionEvent JavaDoc;
20 import java.awt.*;
21 import javax.swing.*;
22 import java.util.*;
23
24 /**
25 * Class that realizes <B>RemovePoint</B> action.
26 * "Breaking point" is removed from transition at the popup
27 * position (if there is one near).
28 */

29 public class RemovePoint extends ActionBase {
30
31    public RemovePoint (ProcessEditor pe) {
32       super(pe);
33    }
34
35    public void actionPerformed(ActionEvent JavaDoc e) {
36       JaWEMarqueeHandler pemh = (JaWEMarqueeHandler)editor.getGraph().getMarqueeHandler();
37       Point removeAt=pemh.getPopupPoint();
38       Object JavaDoc transition=editor.getGraph().getSelectionCell();
39       if (transition instanceof Transition) {
40          CellView view=editor.getGraph().getGraphLayoutCache().getMapping(transition,false);
41          TransitionView tv=(TransitionView)view;
42          tv.removePoint(removeAt);
43          // updating xml object
44
Transition tr=(Transition)transition;
45          org.enhydra.jawe.xml.elements.Transition t=
46             (org.enhydra.jawe.xml.elements.Transition)
47                tr.getUserObject();
48          int noOfPoints=tv.getPointCount();
49          Map pnts=new Hashtable();
50          for (int i=1; i<noOfPoints-1; i++) {
51             pnts.put(new Integer JavaDoc(i),new Point((int)tv.getPoint(i).getX(),(int)tv.getPoint(i).getY()));//HM, JGraph3.4.1
52
}
53          t.setBreakPoints(pnts);
54       }
55    }
56 }
57
Popular Tags