ResizeHandle.js
Summary
No overview generated for 'ResizeHandle.js'
draw2d.ResizeHandle=function( workflow, type)
{
draw2d.Rectangle.call(this,5,5);
this.type = type;
var offset= this.getWidth();
var offset2 = offset/2;
switch(this.type)
{
case 1:
this.setSnapToGridAnchor(new draw2d.Point(offset,offset));
break;
case 2:
this.setSnapToGridAnchor(new draw2d.Point(offset2,offset));
break;
case 3:
this.setSnapToGridAnchor(new draw2d.Point(0,offset));
break;
case 4:
this.setSnapToGridAnchor(new draw2d.Point(0,offset2));
break;
case 5:
this.setSnapToGridAnchor(new draw2d.Point(0,0));
break;
case 6:
this.setSnapToGridAnchor(new draw2d.Point(offset2,0));
break;
case 7:
this.setSnapToGridAnchor(new draw2d.Point(offset,0));
break;
case 8:
this.setSnapToGridAnchor(new draw2d.Point(offset,offset2));
break;
}
this.setBackgroundColor(new draw2d.Color(0,255,0));
this.setWorkflow(workflow);
this.setZOrder(10000);
}
draw2d.ResizeHandle.prototype = new draw2d.Rectangle;
draw2d.ResizeHandle.prototype.type="ResizeHandle";
draw2d.ResizeHandle.prototype.getSnapToDirection=function()
{
switch(this.type)
{
case 1:
return draw2d.SnapToHelper.NORTH_WEST;
case 2:
return draw2d.SnapToHelper.NORTH;
case 3:
return draw2d.SnapToHelper.NORTH_EAST;
case 4:
return draw2d.SnapToHelper.EAST;
case 5:
return draw2d.SnapToHelper.SOUTH_EAST;
case 6:
return draw2d.SnapToHelper.SOUTH;
case 7:
return draw2d.SnapToHelper.SOUTH_WEST;
case 8:
return draw2d.SnapToHelper.WEST;
}
}
draw2d.ResizeHandle.prototype.onDragend = function()
{
if(this.commandMove==null)
return;
var figure = this.workflow.currentSelection;
this.commandMove.setPosition(figure.getX(), figure.getY());
this.commandResize.setDimension(figure.getWidth(), figure.getHeight());
this.workflow.getCommandStack().execute(this.commandResize);
this.workflow.getCommandStack().execute(this.commandMove);
this.commandMove = null;
this.commandResize = null;
this.workflow.hideSnapToHelperLines();
}
draw2d.ResizeHandle.prototype.setPosition=function( xPos , yPos )
{
this.x = xPos;
this.y = yPos;
this.html.style.left = this.x+"px";
this.html.style.top = this.y+"px";
}
draw2d.ResizeHandle.prototype.onDragstart = function( x, y)
{
if(!this.canDrag)
return false;
var figure = this.workflow.currentSelection;
this.commandMove = new draw2d.CommandMove(figure,figure.getX(), figure.getY());
this.commandResize = new draw2d.CommandResize(figure, figure.getWidth(),figure.getHeight());
return true;
}
draw2d.ResizeHandle.prototype.onDrag = function()
{
var oldX = this.getX()
var oldY = this.getY();
draw2d.Rectangle.prototype.onDrag.call(this);
var diffX = oldX-this.getX();
var diffY = oldY-this.getY();
var objPosX = this.workflow.currentSelection.getX();
var objPosY = this.workflow.currentSelection.getY();
var objWidth= this.workflow.currentSelection.getWidth();
var objHeight= this.workflow.currentSelection.getHeight();
switch(this.type)
{
case 1:
this.workflow.currentSelection.setPosition(objPosX-diffX, objPosY-diffY);
this.workflow.currentSelection.setDimension(objWidth+diffX, objHeight+diffY);
break;
case 2:
this.workflow.currentSelection.setPosition(objPosX, objPosY-diffY);
this.workflow.currentSelection.setDimension(objWidth, objHeight+diffY);
break;
case 3:
this.workflow.currentSelection.setPosition(objPosX, objPosY-diffY);
this.workflow.currentSelection.setDimension(objWidth-diffX, objHeight+diffY);
break;
case 4:
this.workflow.currentSelection.setPosition(objPosX, objPosY);
this.workflow.currentSelection.setDimension(objWidth-diffX, objHeight);
break;
case 5:
this.workflow.currentSelection.setPosition(objPosX, objPosY);
this.workflow.currentSelection.setDimension(objWidth-diffX, objHeight-diffY);
break;
case 6:
this.workflow.currentSelection.setPosition(objPosX, objPosY);
this.workflow.currentSelection.setDimension(objWidth, objHeight-diffY);
break;
case 7:
this.workflow.currentSelection.setPosition(objPosX-diffX, objPosY);
this.workflow.currentSelection.setDimension(objWidth+diffX, objHeight-diffY);
break;
case 8:
this.workflow.currentSelection.setPosition(objPosX-diffX, objPosY);
this.workflow.currentSelection.setDimension(objWidth+diffX, objHeight);
break;
}
this.workflow.moveResizeHandles(this.workflow.getCurrentSelection());
}
draw2d.ResizeHandle.prototype.setCanDrag=function( flag)
{
draw2d.Rectangle.prototype.setCanDrag.call(this,flag);
if(!flag)
{
this.html.style.cursor="";
return;
}
switch(this.type)
{
case 1:
this.html.style.cursor="nw-resize";
break;
case 2:
this.html.style.cursor="s-resize";
break;
case 3:
this.html.style.cursor="ne-resize";
break;
case 4:
this.html.style.cursor="w-resize";
break;
case 5:
this.html.style.cursor="se-resize";
break;
case 6:
this.html.style.cursor="n-resize";
break;
case 7:
this.html.style.cursor="sw-resize";
break;
case 8:
this.html.style.cursor="e-resize";
break;
}
}
draw2d.ResizeHandle.prototype.onKeyDown=function(keyCode, ctrl)
{
this.workflow.onKeyDown(keyCode,ctrl);
}
draw2d.ResizeHandle.prototype.fireMoveEvent=function()
{
}
Documentation generated by
JSDoc on Thu Feb 7 23:45:47 2008