KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > workfloweditor > flowchart > LineSelectionMouseHandler


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

19 package org.openharmonise.workfloweditor.flowchart;
20
21 import java.awt.event.*;
22 import java.util.*;
23
24 import javax.swing.event.*;
25
26 import org.openharmonise.workfloweditor.flowchart.shapes.*;
27
28
29 /**
30  * Handles mouse guestures to select the connection lines.
31  *
32  * @author Matthew Large
33  * @version $Revision: 1.1 $
34  *
35  */

36 public class LineSelectionMouseHandler extends MouseInputAdapter {
37
38     /**
39      * Workflow diagram.
40      */

41     private FlowChart m_chart = null;
42
43     /**
44      * Starting workflow stage instance shape.
45      */

46     private AbstractWorkflowShape m_startShape = null;
47     
48     /**
49      * Ending workflow stage instance shape.
50      */

51     private AbstractWorkflowShape m_endShape = null;
52
53     /**
54      * Connection line shape.
55      */

56     private ConnectionLine m_connectionLine = null;
57
58     /**
59      * Constructs a new line selection handler.
60      *
61      * @param chart Workflow diagram
62      */

63     public LineSelectionMouseHandler(FlowChart chart) {
64         super();
65         this.m_chart = chart;
66     }
67
68     /* (non-Javadoc)
69      * @see java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent)
70      */

71     public void mouseDragged(MouseEvent me) {
72
73     }
74
75     /* (non-Javadoc)
76      * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
77      */

78     public void mousePressed(MouseEvent me) {
79
80     }
81
82     /* (non-Javadoc)
83      * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
84      */

85     public void mouseReleased(MouseEvent me) {
86
87     }
88
89     /* (non-Javadoc)
90      * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
91      */

92     public void mouseClicked(MouseEvent me) {
93         boolean bLineSelected = false;
94         Iterator itor = this.m_chart.getShapes().iterator();
95         while (itor.hasNext()) {
96             AbstractWorkflowShape shape = (AbstractWorkflowShape) itor.next();
97             if(shape instanceof ConnectionLine) {
98                 ConnectionLine connectionLine = (ConnectionLine) shape;
99                 if(connectionLine.selectionPointContains(me.getX(), me.getY())) {
100                     this.m_chart.removeShape(connectionLine);
101                 }
102             }
103         }
104     }
105
106 }
107
Popular Tags