Updated Zoom Function

This commit is contained in:
girish
2011-02-05 13:12:31 +00:00
parent 89e401cff8
commit 74cb80019d
3 changed files with 186 additions and 82 deletions

View File

@@ -1759,6 +1759,88 @@ MyWorkflow.prototype.getDeleteCriteria = function()
* @Param sType string(in/out)
* @Author Girish joshi
*/
//MyWorkflow.prototype.zoom = function(sType)
//{
// //workflow.zoomFactor = 1;
// var figures = workflow.getDocument().getFigures();
//
// var lines=workflow.getLines();
// var size=lines.getSize();
//
// if(typeof workflow.limitFlag == 'undefined')
// workflow.limitFlag = 0;
//
// var zoomFactor = 0.2;
// var figSize = figures.getSize();
// for(f = 0;f<figures.getSize();f++){
// var fig = figures.get(f);
// var width = fig.getWidth();
// var height = fig.getHeight();
// var xPos = fig.getX();
// var yPos = fig.getY();
//
// if(sType == 'in')
// {
// if(fig.type.match(/Event/) || fig.type.match(/Gateway/))
// {
// width += zoomFactor*25;
// height += zoomFactor*25;
// workflow.zoomWidth = width;
// workflow.zoomHeight = height;
// }
// else if(fig.type.match(/Annotation/)) {
// width += zoomFactor*50;
// height += zoomFactor*50;
// workflow.zoomAnnotationWidth = width;
// workflow.zoomAnnotationHeight = height;
// }
// else
// {
// width += zoomFactor*50;
// height += zoomFactor*50;
// workflow.zoomTaskWidth = width;
// workflow.zoomTaskHeight = height;
// }
// ++workflow.limitFlag;
// xPos = xPos + zoomFactor*xPos;
// yPos = yPos + zoomFactor*yPos
// fig.setPosition(xPos,yPos);
// }
// else if(sType == 'out' && workflow.limitFlag > 0)
// {
// if(fig.type.match(/Event/) || fig.type.match(/Gateway/) )
// {
// width -= zoomFactor*25;
// height -= zoomFactor*25;
// workflow.zoomWidth = width;
// workflow.zoomHeight = height;
// }
// else if(fig.type.match(/Annotation/)) {
// width -= zoomFactor*50;
// height -= zoomFactor*50;
// workflow.zoomAnnotationWidth = width;
// workflow.zoomAnnotationHeight = height;
// }
// else
// {
// width -= zoomFactor*50;
// height -= zoomFactor*50;
// workflow.zoomTaskWidth = width;
// workflow.zoomTaskHeight = height;
// }
// --workflow.limitFlag;
// xPos = xPos - zoomFactor*xPos;
// yPos = yPos - zoomFactor*yPos
// fig.setPosition(xPos,yPos);
// }
// fig.setDimension(width,height);
// if(fig.type == 'bpmnTask')
// workflow.redrawTaskText(fig,sType);
// else if(fig.type == 'bpmnAnnotation')
// workflow.redrawAnnotationText(fig,sType);
// }
//}
MyWorkflow.prototype.zoom = function(sType)
{
//workflow.zoomFactor = 1;
@@ -1767,80 +1849,64 @@ MyWorkflow.prototype.zoom = function(sType)
var lines=workflow.getLines();
var size=lines.getSize();
if(typeof workflow.limitFlag == 'undefined')
workflow.limitFlag = 0;
var zoomFactor = 0.2;
sType =sType/100;
//var zoomFactor = 0.2;
var figSize = figures.getSize();
for(f = 0;f<figures.getSize();f++){
var fig = figures.get(f);
var width = fig.getWidth();
var height = fig.getHeight();
var xPos = fig.getX();
var yPos = fig.getY();
if(sType == 'in')
// var width = fig.getWidth();
// var height = fig.getHeight();
// var xPos = fig.getX();
// var yPos = fig.getY();
if(typeof workflow.limitFlag == 'undefined')
{
fig.originalWidth = fig.getWidth();
fig.originalHeight = fig.getHeight();
fig.orgXPos = fig.getX();
fig.orgYPos = fig.getY();
fig.orgFontSize =fig.fontSize;
}
if(fig.type.match(/Event/) || fig.type.match(/Gateway/))
{
if(fig.type.match(/Event/) || fig.type.match(/Gateway/))
{
width += zoomFactor*25;
height += zoomFactor*25;
workflow.zoomWidth = width;
workflow.zoomHeight = height;
}
else if(fig.type.match(/Annotation/)) {
width += zoomFactor*50;
height += zoomFactor*50;
workflow.zoomAnnotationWidth = width;
workflow.zoomAnnotationHeight = height;
}
else
{
width += zoomFactor*50;
height += zoomFactor*50;
workflow.zoomTaskWidth = width;
workflow.zoomTaskHeight = height;
}
++workflow.limitFlag;
xPos = xPos + zoomFactor*xPos;
yPos = yPos + zoomFactor*yPos
fig.setPosition(xPos,yPos);
width = fig.originalWidth*sType;
height = fig.originalHeight*sType;
workflow.zoomWidth = width;
workflow.zoomHeight = height;
}
else if(sType == 'out' && workflow.limitFlag > 0)
{
if(fig.type.match(/Event/) || fig.type.match(/Gateway/) )
{
width -= zoomFactor*25;
height -= zoomFactor*25;
workflow.zoomWidth = width;
workflow.zoomHeight = height;
}
else if(fig.type.match(/Annotation/)) {
width -= zoomFactor*50;
height -= zoomFactor*50;
workflow.zoomAnnotationWidth = width;
workflow.zoomAnnotationHeight = height;
}
else
{
width -= zoomFactor*50;
height -= zoomFactor*50;
workflow.zoomTaskWidth = width;
workflow.zoomTaskHeight = height;
}
--workflow.limitFlag;
xPos = xPos - zoomFactor*xPos;
yPos = yPos - zoomFactor*yPos
fig.setPosition(xPos,yPos);
}
fig.setDimension(width,height);
if(fig.type == 'bpmnTask')
workflow.redrawTaskText(fig,sType);
else if(fig.type == 'bpmnAnnotation')
workflow.redrawAnnotationText(fig,sType);
else if(fig.type.match(/Annotation/)) {
width = fig.originalWidth*sType;
height = fig.originalHeight*sType;
workflow.zoomAnnotationWidth = width;
workflow.zoomAnnotationHeight = height;
}
}
else
{
width = fig.originalWidth*sType;
height = fig.originalHeight*sType;
workflow.zoomTaskWidth = width;
workflow.zoomTaskHeight = height;
}
xPos = fig.orgXPos * sType;
yPos = fig.orgYPos * sType;
fig.setPosition(xPos,yPos);
fig.setDimension(width,height);
if(fig.type == 'bpmnTask')
{
fig.fontSize = parseInt(fig.orgFontSize) * sType;
fig.paint();
}
else if(fig.type == 'bpmnAnnotation')
{
fig.fontSize = parseInt(fig.orgFontSize) * sType;
fig.paint();
}
}
workflow.limitFlag = 1;
}
MyWorkflow.prototype.redrawTaskText = function(fig,sType)
{

View File

@@ -44,12 +44,12 @@ bpmnTask.prototype.paint = function () {
VectorFigure.prototype.paint.call(this);
//Set the Task Limitation
if (this.getWidth() > 200 || this.getHeight() > 100) {
this.setDimension(200, 100);
}
else if (this.getWidth() < 165 || this.getHeight() < 40) {
this.setDimension(165, 40);
}
// if (this.getWidth() > 200 || this.getHeight() > 100) {
// this.setDimension(200, 100);
// }
// else if (this.getWidth() < 165 || this.getHeight() < 40) {
// this.setDimension(165, 40);
// }
var x = new Array(6, this.getWidth() - 3, this.getWidth(), this.getWidth(), this.getWidth() - 3, 6, 3, 3, 6);
var y = new Array(3, 3, 6, this.getHeight() - 3, this.getHeight(), this.getHeight(), this.getHeight() - 3, 6, 3);

View File

@@ -220,17 +220,55 @@ Ext.onReady ( function() {
})
}, {
text:'Zoom In',
xtype: 'tbsplit',
text:'Zoom',
iconCls: 'button_menu_ext ss_sprite ss_zoom_in',
handler: function() {
document.getElementById('designerFrame').contentWindow.workflow.zoom('in');
}
menu: new Ext.menu.Menu({
items: [{
text : '25%',
handler: function() {
document.getElementById('designerFrame').contentWindow.workflow.zoom('25');
}
},{
text : '50%',
handler: function() {
document.getElementById('designerFrame').contentWindow.workflow.zoom('50');
}
},{
text : '75%',
handler: function() {
document.getElementById('designerFrame').contentWindow.workflow.zoom('75');
}
},{
text : '100%',
handler: function() {
document.getElementById('designerFrame').contentWindow.workflow.zoom('100');
}
},{
text : '125%',
handler: function() {
document.getElementById('designerFrame').contentWindow.workflow.zoom('125');
}
},{
text : '150%',
handler: function() {
document.getElementById('designerFrame').contentWindow.workflow.zoom('150');
}
},{
text : '200%',
handler: function() {
document.getElementById('designerFrame').contentWindow.workflow.zoom('200');
}
}
]
})
}, {
text:'Zoom Out',
iconCls: 'button_menu_ext ss_sprite ss_zoom_out',
handler: function() {
document.getElementById('designerFrame').contentWindow.workflow.zoom('out');
}
// text:'Zoom Out',
// iconCls: 'button_menu_ext ss_sprite ss_zoom_out',
// handler: function() {
// document.getElementById('designerFrame').contentWindow.workflow.zoom('out');
// }
}, {
text:'Edit Process',
iconCls: 'button_menu_ext ss_sprite ss_pencil',