001: /*
002: * The contents of this file are subject to the
003: * Mozilla Public License Version 1.1 (the "License");
004: * you may not use this file except in compliance with the License.
005: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006: *
007: * Software distributed under the License is distributed on an "AS IS"
008: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
009: * See the License for the specific language governing rights and
010: * limitations under the License.
011: *
012: * The Initial Developer of the Original Code is Simulacra Media Ltd.
013: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014: *
015: * All Rights Reserved.
016: *
017: * Contributor(s):
018: */
019: package org.openharmonise.workfloweditor.flowchart;
020:
021: import java.awt.event.*;
022: import java.util.*;
023:
024: import javax.swing.event.*;
025:
026: import org.openharmonise.workfloweditor.flowchart.shapes.*;
027:
028: /**
029: * Handles mouse guestures to select the connection lines.
030: *
031: * @author Matthew Large
032: * @version $Revision: 1.1 $
033: *
034: */
035: public class LineSelectionMouseHandler extends MouseInputAdapter {
036:
037: /**
038: * Workflow diagram.
039: */
040: private FlowChart m_chart = null;
041:
042: /**
043: * Starting workflow stage instance shape.
044: */
045: private AbstractWorkflowShape m_startShape = null;
046:
047: /**
048: * Ending workflow stage instance shape.
049: */
050: private AbstractWorkflowShape m_endShape = null;
051:
052: /**
053: * Connection line shape.
054: */
055: private ConnectionLine m_connectionLine = null;
056:
057: /**
058: * Constructs a new line selection handler.
059: *
060: * @param chart Workflow diagram
061: */
062: public LineSelectionMouseHandler(FlowChart chart) {
063: super ();
064: this .m_chart = chart;
065: }
066:
067: /* (non-Javadoc)
068: * @see java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent)
069: */
070: public void mouseDragged(MouseEvent me) {
071:
072: }
073:
074: /* (non-Javadoc)
075: * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
076: */
077: public void mousePressed(MouseEvent me) {
078:
079: }
080:
081: /* (non-Javadoc)
082: * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
083: */
084: public void mouseReleased(MouseEvent me) {
085:
086: }
087:
088: /* (non-Javadoc)
089: * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
090: */
091: public void mouseClicked(MouseEvent me) {
092: boolean bLineSelected = false;
093: Iterator itor = this .m_chart.getShapes().iterator();
094: while (itor.hasNext()) {
095: AbstractWorkflowShape shape = (AbstractWorkflowShape) itor
096: .next();
097: if (shape instanceof ConnectionLine) {
098: ConnectionLine connectionLine = (ConnectionLine) shape;
099: if (connectionLine.selectionPointContains(me.getX(), me
100: .getY())) {
101: this.m_chart.removeShape(connectionLine);
102: }
103: }
104: }
105: }
106:
107: }
|