1
/* This notice must be untouched at all times.
4
The latest version is available at
5
http://www.openjacob.org
7
Copyright (c) 2006 Andreas Herz. All rights reserved.
8
Created 5. 11. 2006 by Andreas Herz (Web: http://www.freegroup.de )
12
This library is free software; you can redistribute it and/or
13
modify it under the terms of the GNU Lesser General Public
14
License (LGPL) as published by the Free Software Foundation; either
15
version 2.1 of the License, or (at your option) any later version.
17
This library is distributed in the hope that it will be useful,
18
but WITHOUT ANY WARRANTY; without even the implied warranty of
19
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20
Lesser General Public License for more details.
22
You should have received a copy of the GNU Lesser General Public
23
License along with this library; if not, write to the Free Software
24
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA,
25
or see http://www.gnu.org/copyleft/lesser.html
31
* @author Andreas Herz
33
* @param {draw2d.Workflow} workflow The host canvas for this resize handle
37
draw2d.LineStartResizeHandle=function(/*:draw2d.Workflow*/ workflow)
39
draw2d.Rectangle.call(this);
40
this.setDimension(10,10);
41
this.setBackgroundColor(new draw2d.Color(0,255,0));
42
this.setWorkflow(workflow);
43
this.setZOrder(10000);
46
draw2d.LineStartResizeHandle.prototype = new draw2d.Rectangle;
48
draw2d.LineStartResizeHandle.prototype.type="LineStartResizeHandle";
51
* Will be called after a drag and drop action.<br>
52
* Sub classes can override this method to implement additional stuff. Don't forget to call
53
* the super implementation via <code>Figure.prototype.onDragend.call(this);</code>
56
draw2d.LineStartResizeHandle.prototype.onDragend = function()
58
var line = this.workflow.currentSelection;
60
// A Connection glue at the corresponding port. Reset the position to the origin port
61
// if we doesn't drop the ResizeHandle on a other port.
63
if(line instanceof draw2d.Connection)
65
var start = line.sourceAnchor.getLocation(line.targetAnchor.getReferencePoint());
66
line.setStartPoint(start.x,start.y);
67
this.getWorkflow().showLineResizeHandles(line);
68
line.setRouter(line.oldRouter);
73
// An non draggable resizeHandle doesn't create a move/resize command.
74
// This happens if the selected figure has set the "nonResizeable" flag.
76
if(this.command==null)
78
var x1 = line.getStartX();
79
var y1 = line.getStartY();
80
var x2 = line.getEndX();
81
var y2 = line.getEndY();
82
this.command.setEndPoints(x1,y1,x2,y2);
83
this.getWorkflow().getCommandStack().execute(this.command);
89
* Will be called if the drag and drop action beginns. You can return [false] if you
90
* want avoid the that the figure can be move.
93
* @param {int} x The x position where the mouse has been clicked in the figure
94
* @param {int} y The y position where the mouse has been clicked in the figure
97
draw2d.LineStartResizeHandle.prototype.onDragstart = function(/*:int*/ x, /*:int*/ y)
99
// This happens if the selected figure has set the "nonResizeable" flag
100
// In this case the ResizeHandle can't be dragged. => no resize
105
var line = this.workflow.currentSelection;
107
if(line instanceof draw2d.Connection)
109
// DragDrop of a connection doesn't create a undo command at this point. This will be done in
111
this.command = new draw2d.CommandReconnect(line);
112
line.oldRouter = line.getRouter();
113
line.setRouter(new draw2d.NullConnectionRouter());
117
var x1 = line.getStartX();
118
var y1 = line.getStartY();
119
var x2 = line.getEndX();
120
var y2 = line.getEndY();
121
this.command = new draw2d.CommandMoveLine(line,x1,y1,x2,y2);
131
draw2d.LineStartResizeHandle.prototype.onDrag = function()
133
var oldX = this.getX()
134
var oldY = this.getY();
135
draw2d.Rectangle.prototype.onDrag.call(this);
136
var diffX = oldX-this.getX();
137
var diffY = oldY-this.getY();
139
var objPos = this.workflow.currentSelection.getStartPoint();
141
var line = this.workflow.currentSelection;
142
line.setStartPoint(objPos.x-diffX, objPos.y-diffY);
143
line.isMoving = true;
147
* Resizehandle has ben drop on a InputPort/OutputPort.
150
draw2d.LineStartResizeHandle.prototype.onDrop = function(/*: draw2d.Port*/ dropTarget)
152
var line = this.workflow.currentSelection;
155
// The ResizeHandle of a Connection has been droped on a Port
156
// This will enforce a ReconnectCommand
157
if(line instanceof draw2d.Connection)
159
this.command.setNewPorts(dropTarget, line.getTarget());
160
this.getWorkflow().getCommandStack().execute(this.command);
168
draw2d.LineStartResizeHandle.prototype.onKeyDown=function(/*:int*/ keyCode , /*:boolean*/ ctrl)
170
// redirect this to the workflow.
172
if(this.workflow!=null)
173
this.workflow.onKeyDown(keyCode, ctrl);
178
draw2d.LineStartResizeHandle.prototype.fireMoveEvent=function()
180
// a resizeHandle doesn't fire this event.
181
//Normale this set the document dirty. This is not neccessary for a ResizeHandle.