Refactor Web2D to use mootool classes.
This commit is contained in:
@@ -1,35 +1,33 @@
|
||||
/*
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
web2d.peer.svg.ArialFont = function()
|
||||
{
|
||||
web2d.peer.svg.Font.call(this);
|
||||
this._fontFamily="Arial";
|
||||
};
|
||||
web2d.peer.svg.ArialFont = new Class({
|
||||
Extends: web2d.peer.svg.Font,
|
||||
initialize :function() {
|
||||
this.parent();
|
||||
this._fontFamily = "Arial";
|
||||
},
|
||||
|
||||
objects.extend(web2d.peer.svg.ArialFont, web2d.peer.svg.Font);
|
||||
getFontFamily : function () {
|
||||
return this._fontFamily;
|
||||
},
|
||||
|
||||
web2d.peer.svg.ArialFont.prototype.getFontFamily=function ()
|
||||
{
|
||||
return this._fontFamily;
|
||||
};
|
||||
|
||||
web2d.peer.svg.ArialFont.prototype.getFont=function ()
|
||||
{
|
||||
return web2d.Font.ARIAL;
|
||||
};
|
||||
getFont : function () {
|
||||
return web2d.Font.ARIAL;
|
||||
}
|
||||
});
|
@@ -1,99 +1,93 @@
|
||||
/*
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
web2d.peer.svg.ArrowPeer = function()
|
||||
{
|
||||
var svgElement = window.document.createElementNS(this.svgNamespace, 'path');
|
||||
web2d.peer.svg.ElementPeer.call(this, svgElement);
|
||||
this._style={};
|
||||
this._controlPoint=new core.Point();
|
||||
this._fromPoint = new core.Point();
|
||||
};
|
||||
web2d.peer.svg.ArrowPeer = new Class({
|
||||
Extends: web2d.peer.svg.ElementPeer,
|
||||
initialize : function() {
|
||||
var svgElement = window.document.createElementNS(this.svgNamespace, 'path');
|
||||
this.parent(svgElement);
|
||||
this._style = {};
|
||||
this._controlPoint = new core.Point();
|
||||
this._fromPoint = new core.Point();
|
||||
},
|
||||
|
||||
objects.extend(web2d.peer.svg.ArrowPeer, web2d.peer.svg.ElementPeer);
|
||||
setFrom : function(x, y) {
|
||||
this._fromPoint.x = x;
|
||||
this._fromPoint.y = y;
|
||||
this._redraw();
|
||||
},
|
||||
|
||||
web2d.peer.svg.ArrowPeer.prototype.setFrom = function(x,y)
|
||||
{
|
||||
this._fromPoint.x = x;
|
||||
this._fromPoint.y = y;
|
||||
this._redraw();
|
||||
};
|
||||
setControlPoint : function (point) {
|
||||
this._controlPoint = point;
|
||||
this._redraw();
|
||||
},
|
||||
|
||||
web2d.peer.svg.ArrowPeer.prototype.setControlPoint = function (point)
|
||||
{
|
||||
this._controlPoint = point;
|
||||
this._redraw();
|
||||
};
|
||||
setStrokeColor : function (color) {
|
||||
this.setStroke(null, null, color, null);
|
||||
},
|
||||
|
||||
web2d.peer.svg.ArrowPeer.prototype.setStrokeColor = function (color)
|
||||
{
|
||||
this.setStroke(null,null,color, null);
|
||||
};
|
||||
setStrokeWidth : function(width) {
|
||||
this.setStroke(width);
|
||||
},
|
||||
|
||||
web2d.peer.svg.ArrowPeer.prototype.setStrokeWidth = function(width)
|
||||
{
|
||||
this.setStroke(width);
|
||||
};
|
||||
setDashed : function(isDashed, length, spacing) {
|
||||
if ($defined(isDashed) && isDashed && $defined(length) && $defined(spacing)) {
|
||||
this._native.setAttribute("stroke-dasharray", length + "," + spacing);
|
||||
} else {
|
||||
this._native.setAttribute("stroke-dasharray", "");
|
||||
}
|
||||
},
|
||||
|
||||
web2d.peer.svg.ArrowPeer.prototype.setDashed = function(isDashed, length, spacing){
|
||||
if($defined(isDashed) && isDashed && $defined(length) && $defined(spacing)){
|
||||
this._native.setAttribute("stroke-dasharray",length+","+spacing);
|
||||
} else {
|
||||
this._native.setAttribute("stroke-dasharray","");
|
||||
}
|
||||
};
|
||||
_updateStyle : function() {
|
||||
var style = "";
|
||||
for (var key in this._style) {
|
||||
style += key + ":" + this._style[key] + " ";
|
||||
}
|
||||
this._native.setAttribute("style", style);
|
||||
},
|
||||
|
||||
web2d.peer.svg.ArrowPeer.prototype._updateStyle = function()
|
||||
{
|
||||
var style = "";
|
||||
for(var key in this._style){
|
||||
style+=key+":"+this._style[key]+" ";
|
||||
}
|
||||
this._native.setAttribute("style",style);
|
||||
};
|
||||
|
||||
web2d.peer.svg.ArrowPeer.prototype._redraw = function()
|
||||
{
|
||||
var x,y, xp, yp;
|
||||
if(this._controlPoint.y == 0)
|
||||
this._controlPoint.y=1;
|
||||
_redraw : function() {
|
||||
var x,y, xp, yp;
|
||||
if (this._controlPoint.y == 0)
|
||||
this._controlPoint.y = 1;
|
||||
var y0 = this._controlPoint.y;
|
||||
var x0 = this._controlPoint.x;
|
||||
var x2=x0+y0;
|
||||
var y2 = y0-x0;
|
||||
var x3 = x0-y0;
|
||||
var y3 = y0+x0;
|
||||
var m = y2/x2;
|
||||
var mp = y3/x3;
|
||||
var x2 = x0 + y0;
|
||||
var y2 = y0 - x0;
|
||||
var x3 = x0 - y0;
|
||||
var y3 = y0 + x0;
|
||||
var m = y2 / x2;
|
||||
var mp = y3 / x3;
|
||||
var l = 6;
|
||||
var pow = Math.pow;
|
||||
x = (x2==0?0:Math.sqrt(pow(l,2)/(1+pow(m,2))));
|
||||
x *=Math.sign(x2);
|
||||
y = (x2==0?l*Math.sign(y2):m*x);
|
||||
xp = (x3==0?0:Math.sqrt(pow(l,2)/(1+pow(mp,2))));
|
||||
xp *=Math.sign(x3);
|
||||
yp = (x3==0?l*Math.sign(y3):mp*xp);
|
||||
x = (x2 == 0 ? 0 : Math.sqrt(pow(l, 2) / (1 + pow(m, 2))));
|
||||
x *= Math.sign(x2);
|
||||
y = (x2 == 0 ? l * Math.sign(y2) : m * x);
|
||||
xp = (x3 == 0 ? 0 : Math.sqrt(pow(l, 2) / (1 + pow(mp, 2))));
|
||||
xp *= Math.sign(x3);
|
||||
yp = (x3 == 0 ? l * Math.sign(y3) : mp * xp);
|
||||
|
||||
var path = "M"+this._fromPoint.x+","+this._fromPoint.y+" "
|
||||
+"L"+(x+this._fromPoint.x)+","+(y+this._fromPoint.y)
|
||||
+"M"+this._fromPoint.x+","+this._fromPoint.y+" "
|
||||
+"L"+(xp+this._fromPoint.x)+","+(yp+this._fromPoint.y)
|
||||
var path = "M" + this._fromPoint.x + "," + this._fromPoint.y + " "
|
||||
+ "L" + (x + this._fromPoint.x) + "," + (y + this._fromPoint.y)
|
||||
+ "M" + this._fromPoint.x + "," + this._fromPoint.y + " "
|
||||
+ "L" + (xp + this._fromPoint.x) + "," + (yp + this._fromPoint.y)
|
||||
;
|
||||
this._native.setAttribute("d",path);
|
||||
};
|
||||
this._native.setAttribute("d", path);
|
||||
}
|
||||
});
|
||||
|
||||
|
@@ -1,209 +1,200 @@
|
||||
/*
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
web2d.peer.svg.CurvedLinePeer = function()
|
||||
{
|
||||
var svgElement = window.document.createElementNS(this.svgNamespace, 'path');
|
||||
web2d.peer.svg.ElementPeer.call(this, svgElement);
|
||||
this._style={fill:'#495879'};
|
||||
this._updateStyle();
|
||||
this._customControlPoint_1 = false;
|
||||
this._customControlPoint_2 = false;
|
||||
this._control1=new core.Point();
|
||||
this._control2=new core.Point();
|
||||
this._lineStyle=true;
|
||||
};
|
||||
|
||||
objects.extend(web2d.peer.svg.CurvedLinePeer, web2d.peer.svg.ElementPeer);
|
||||
|
||||
web2d.peer.svg.CurvedLinePeer.prototype.setSrcControlPoint = function(control){
|
||||
this._customControlPoint_1 = true;
|
||||
var change = this._control1.x!=control.x || this._control1.y!=control.y;
|
||||
if($defined(control.x)){
|
||||
this._control1 = control;
|
||||
this._control1.x = parseInt(this._control1.x);
|
||||
this._control1.y = parseInt(this._control1.y)
|
||||
}
|
||||
if(change)
|
||||
this._updatePath();
|
||||
};
|
||||
|
||||
web2d.peer.svg.CurvedLinePeer.prototype.setDestControlPoint = function(control){
|
||||
this._customControlPoint_2 = true;
|
||||
var change = this._control2.x!=control.x || this._control2.y!=control.y;
|
||||
if($defined(control.x)){
|
||||
this._control2 = control;
|
||||
this._control2.x = parseInt(this._control2.x);
|
||||
this._control2.y = parseInt(this._control2.y)
|
||||
}
|
||||
if(change)
|
||||
this._updatePath();
|
||||
};
|
||||
|
||||
web2d.peer.svg.CurvedLinePeer.prototype.isSrcControlPointCustom = function() {
|
||||
return this._customControlPoint_1;
|
||||
};
|
||||
|
||||
web2d.peer.svg.CurvedLinePeer.prototype.isDestControlPointCustom = function() {
|
||||
return this._customControlPoint_2;
|
||||
};
|
||||
|
||||
web2d.peer.svg.CurvedLinePeer.prototype.setIsSrcControlPointCustom = function(isCustom) {
|
||||
this._customControlPoint_1 = isCustom;
|
||||
};
|
||||
|
||||
web2d.peer.svg.CurvedLinePeer.prototype.setIsDestControlPointCustom = function(isCustom) {
|
||||
this._customControlPoint_2 = isCustom;
|
||||
};
|
||||
web2d.peer.svg.CurvedLinePeer = new Class({
|
||||
Extends: web2d.peer.svg.ElementPeer,
|
||||
initialize :function() {
|
||||
var svgElement = window.document.createElementNS(this.svgNamespace, 'path');
|
||||
this.parent(svgElement);
|
||||
this._style = {fill:'#495879'};
|
||||
this._updateStyle();
|
||||
this._customControlPoint_1 = false;
|
||||
this._customControlPoint_2 = false;
|
||||
this._control1 = new core.Point();
|
||||
this._control2 = new core.Point();
|
||||
this._lineStyle = true;
|
||||
},
|
||||
|
||||
|
||||
setSrcControlPoint : function(control) {
|
||||
this._customControlPoint_1 = true;
|
||||
var change = this._control1.x != control.x || this._control1.y != control.y;
|
||||
if ($defined(control.x)) {
|
||||
this._control1 = control;
|
||||
this._control1.x = parseInt(this._control1.x);
|
||||
this._control1.y = parseInt(this._control1.y)
|
||||
}
|
||||
if (change)
|
||||
this._updatePath();
|
||||
},
|
||||
|
||||
web2d.peer.svg.CurvedLinePeer.prototype.getControlPoints = function(){
|
||||
return [this._control1, this._control2];
|
||||
};
|
||||
setDestControlPoint : function(control) {
|
||||
this._customControlPoint_2 = true;
|
||||
var change = this._control2.x != control.x || this._control2.y != control.y;
|
||||
if ($defined(control.x)) {
|
||||
this._control2 = control;
|
||||
this._control2.x = parseInt(this._control2.x);
|
||||
this._control2.y = parseInt(this._control2.y)
|
||||
}
|
||||
if (change)
|
||||
this._updatePath();
|
||||
},
|
||||
|
||||
web2d.peer.svg.CurvedLinePeer.prototype.setFrom = function(x1, y1)
|
||||
{
|
||||
var change = this._x1!=parseInt(x1) || this._y1!=parseInt(y1);
|
||||
this._x1 = parseInt(x1);
|
||||
this._y1 = parseInt(y1);
|
||||
if(change)
|
||||
this._updatePath();
|
||||
};
|
||||
isSrcControlPointCustom : function() {
|
||||
return this._customControlPoint_1;
|
||||
},
|
||||
|
||||
web2d.peer.svg.CurvedLinePeer.prototype.setTo = function(x2, y2)
|
||||
{
|
||||
var change = this._x2!=parseInt(x2) || this._y2!=parseInt(y2);
|
||||
this._x2 = parseInt(x2);
|
||||
this._y2 = parseInt(y2);
|
||||
if(change)
|
||||
this._updatePath();
|
||||
};
|
||||
isDestControlPointCustom : function() {
|
||||
return this._customControlPoint_2;
|
||||
},
|
||||
|
||||
web2d.peer.svg.CurvedLinePeer.prototype.getFrom = function()
|
||||
{
|
||||
return new core.Point(this._x1,this._y1);
|
||||
};
|
||||
setIsSrcControlPointCustom : function(isCustom) {
|
||||
this._customControlPoint_1 = isCustom;
|
||||
},
|
||||
|
||||
web2d.peer.svg.CurvedLinePeer.prototype.getTo = function()
|
||||
{
|
||||
return new core.Point(this._x2,this._y2);
|
||||
};
|
||||
|
||||
web2d.peer.svg.CurvedLinePeer.prototype.setStrokeWidth = function(width)
|
||||
{
|
||||
this._style['stroke-width']= width;
|
||||
this._updateStyle();
|
||||
};
|
||||
|
||||
web2d.peer.svg.CurvedLinePeer.prototype.setColor = function(color)
|
||||
{
|
||||
this._style['stroke']= color;
|
||||
this._style['fill']=color;
|
||||
this._updateStyle();
|
||||
};
|
||||
|
||||
web2d.peer.svg.CurvedLinePeer.prototype.updateLine = function(avoidControlPointFix){
|
||||
this._updatePath(avoidControlPointFix);
|
||||
};
|
||||
|
||||
web2d.peer.svg.CurvedLinePeer.prototype.setLineStyle = function (style){
|
||||
this._lineStyle=style;
|
||||
if(this._lineStyle){
|
||||
this._style['fill']=this._fill;
|
||||
} else {
|
||||
this._fill = this._style['fill'];
|
||||
this._style['fill']='none';
|
||||
}
|
||||
this._updateStyle();
|
||||
this.updateLine();
|
||||
};
|
||||
|
||||
web2d.peer.svg.CurvedLinePeer.prototype.getLineStyle = function (){
|
||||
return this._lineStyle;
|
||||
};
|
||||
setIsDestControlPointCustom : function(isCustom) {
|
||||
this._customControlPoint_2 = isCustom;
|
||||
},
|
||||
|
||||
|
||||
web2d.peer.svg.CurvedLinePeer.prototype.setShowEndArrow = function(visible){
|
||||
this._showEndArrow =visible;
|
||||
this.updateLine();
|
||||
};
|
||||
getControlPoints : function() {
|
||||
return [this._control1, this._control2];
|
||||
},
|
||||
|
||||
web2d.peer.svg.CurvedLinePeer.prototype.isShowEndArrow = function(){
|
||||
return this._showEndArrow;
|
||||
};
|
||||
setFrom : function(x1, y1) {
|
||||
var change = this._x1 != parseInt(x1) || this._y1 != parseInt(y1);
|
||||
this._x1 = parseInt(x1);
|
||||
this._y1 = parseInt(y1);
|
||||
if (change)
|
||||
this._updatePath();
|
||||
},
|
||||
|
||||
web2d.peer.svg.CurvedLinePeer.prototype.setShowStartArrow = function(visible){
|
||||
this._showStartArrow =visible;
|
||||
this.updateLine();
|
||||
};
|
||||
setTo : function(x2, y2) {
|
||||
var change = this._x2 != parseInt(x2) || this._y2 != parseInt(y2);
|
||||
this._x2 = parseInt(x2);
|
||||
this._y2 = parseInt(y2);
|
||||
if (change)
|
||||
this._updatePath();
|
||||
},
|
||||
|
||||
web2d.peer.svg.CurvedLinePeer.prototype.isShowStartArrow = function(){
|
||||
return this._showStartArrow;
|
||||
};
|
||||
getFrom : function() {
|
||||
return new core.Point(this._x1, this._y1);
|
||||
},
|
||||
|
||||
getTo : function() {
|
||||
return new core.Point(this._x2, this._y2);
|
||||
},
|
||||
|
||||
setStrokeWidth : function(width) {
|
||||
this._style['stroke-width'] = width;
|
||||
this._updateStyle();
|
||||
},
|
||||
|
||||
setColor : function(color) {
|
||||
this._style['stroke'] = color;
|
||||
this._style['fill'] = color;
|
||||
this._updateStyle();
|
||||
},
|
||||
|
||||
updateLine : function(avoidControlPointFix) {
|
||||
this._updatePath(avoidControlPointFix);
|
||||
},
|
||||
|
||||
setLineStyle : function (style) {
|
||||
this._lineStyle = style;
|
||||
if (this._lineStyle) {
|
||||
this._style['fill'] = this._fill;
|
||||
} else {
|
||||
this._fill = this._style['fill'];
|
||||
this._style['fill'] = 'none';
|
||||
}
|
||||
this._updateStyle();
|
||||
this.updateLine();
|
||||
},
|
||||
|
||||
getLineStyle : function () {
|
||||
return this._lineStyle;
|
||||
},
|
||||
|
||||
|
||||
web2d.peer.svg.CurvedLinePeer.prototype._updatePath = function(avoidControlPointFix)
|
||||
{
|
||||
if($defined(this._x1) && $defined(this._y1) && $defined(this._x2) && $defined(this._y2))
|
||||
{
|
||||
this._calculateAutoControlPoints(avoidControlPointFix);
|
||||
var path = "M"+this._x1+","+this._y1
|
||||
+" C"+(this._control1.x + this._x1)+","+(this._control1.y+this._y1)+" "
|
||||
+(this._control2.x+this._x2)+","+(this._control2.y+this._y2)+" "
|
||||
+this._x2+","+this._y2+
|
||||
(this._lineStyle?" "
|
||||
+(this._control2.x+this._x2)+","+(this._control2.y+this._y2+3)+" "
|
||||
+(this._control1.x+this._x1)+","+(this._control1.y+this._y1+5)+" "
|
||||
+this._x1+","+(this._y1+7)+" Z"
|
||||
:""
|
||||
);
|
||||
this._native.setAttribute("d",path);
|
||||
}
|
||||
};
|
||||
setShowEndArrow : function(visible) {
|
||||
this._showEndArrow = visible;
|
||||
this.updateLine();
|
||||
},
|
||||
|
||||
web2d.peer.svg.CurvedLinePeer.prototype._updateStyle = function()
|
||||
{
|
||||
var style = "";
|
||||
for(var key in this._style){
|
||||
style+=key+":"+this._style[key]+" ";
|
||||
}
|
||||
this._native.setAttribute("style",style);
|
||||
};
|
||||
isShowEndArrow : function() {
|
||||
return this._showEndArrow;
|
||||
},
|
||||
|
||||
web2d.peer.svg.CurvedLinePeer.prototype._calculateAutoControlPoints = function(avoidControlPointFix){
|
||||
setShowStartArrow : function(visible) {
|
||||
this._showStartArrow = visible;
|
||||
this.updateLine();
|
||||
},
|
||||
|
||||
isShowStartArrow : function() {
|
||||
return this._showStartArrow;
|
||||
},
|
||||
|
||||
|
||||
_updatePath : function(avoidControlPointFix) {
|
||||
if ($defined(this._x1) && $defined(this._y1) && $defined(this._x2) && $defined(this._y2)) {
|
||||
this._calculateAutoControlPoints(avoidControlPointFix);
|
||||
var path = "M" + this._x1 + "," + this._y1
|
||||
+ " C" + (this._control1.x + this._x1) + "," + (this._control1.y + this._y1) + " "
|
||||
+ (this._control2.x + this._x2) + "," + (this._control2.y + this._y2) + " "
|
||||
+ this._x2 + "," + this._y2 +
|
||||
(this._lineStyle ? " "
|
||||
+ (this._control2.x + this._x2) + "," + (this._control2.y + this._y2 + 3) + " "
|
||||
+ (this._control1.x + this._x1) + "," + (this._control1.y + this._y1 + 5) + " "
|
||||
+ this._x1 + "," + (this._y1 + 7) + " Z"
|
||||
: ""
|
||||
);
|
||||
this._native.setAttribute("d", path);
|
||||
}
|
||||
},
|
||||
|
||||
_updateStyle : function() {
|
||||
var style = "";
|
||||
for (var key in this._style) {
|
||||
style += key + ":" + this._style[key] + " ";
|
||||
}
|
||||
this._native.setAttribute("style", style);
|
||||
},
|
||||
|
||||
_calculateAutoControlPoints : function(avoidControlPointFix) {
|
||||
//Both points available, calculate real points
|
||||
var defaultpoints = core.Utils.calculateDefaultControlPoints(new core.Point(this._x1, this._y1),new core.Point(this._x2,this._y2));
|
||||
if(!this._customControlPoint_1 && !($defined(avoidControlPointFix) && avoidControlPointFix==0)){
|
||||
var defaultpoints = core.Utils.calculateDefaultControlPoints(new core.Point(this._x1, this._y1), new core.Point(this._x2, this._y2));
|
||||
if (!this._customControlPoint_1 && !($defined(avoidControlPointFix) && avoidControlPointFix == 0)) {
|
||||
this._control1.x = defaultpoints[0].x;
|
||||
this._control1.y = defaultpoints[0].y;
|
||||
}
|
||||
if(!this._customControlPoint_2 && !($defined(avoidControlPointFix) && avoidControlPointFix==1)){
|
||||
if (!this._customControlPoint_2 && !($defined(avoidControlPointFix) && avoidControlPointFix == 1)) {
|
||||
this._control2.x = defaultpoints[1].x;
|
||||
this._control2.y = defaultpoints[1].y;
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
setDashed : function(length, spacing) {
|
||||
if ($defined(length) && $defined(spacing)) {
|
||||
this._native.setAttribute("stroke-dasharray", length + "," + spacing);
|
||||
} else {
|
||||
this._native.setAttribute("stroke-dasharray", "");
|
||||
}
|
||||
|
||||
web2d.peer.svg.CurvedLinePeer.prototype.setDashed = function(length,spacing){
|
||||
if($defined(length) && $defined(spacing)){
|
||||
this._native.setAttribute("stroke-dasharray",length+","+spacing);
|
||||
} else {
|
||||
this._native.setAttribute("stroke-dasharray","");
|
||||
}
|
||||
|
||||
};
|
||||
});
|
||||
|
@@ -16,218 +16,222 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
web2d.peer.svg.ElementPeer = function(svgElement) {
|
||||
this._native = svgElement;
|
||||
this._size = {width:1,height:1};
|
||||
this._changeListeners = {};
|
||||
// http://support.adobe.com/devsup/devsup.nsf/docs/50493.htm
|
||||
};
|
||||
web2d.peer.svg.ElementPeer = new Class({
|
||||
initialize :function(svgElement) {
|
||||
this._native = svgElement;
|
||||
this._size = {width:1,height:1};
|
||||
this._changeListeners = {};
|
||||
// http://support.adobe.com/devsup/devsup.nsf/docs/50493.htm
|
||||
},
|
||||
|
||||
setChildren : function(children) {
|
||||
this._children = children;
|
||||
},
|
||||
|
||||
getChildren : function() {
|
||||
var result = this._children;
|
||||
if (!$defined(result)) {
|
||||
result = [];
|
||||
this._children = result;
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
getParent : function() {
|
||||
return this._parent;
|
||||
},
|
||||
|
||||
setParent : function(parent) {
|
||||
this._parent = parent;
|
||||
},
|
||||
|
||||
appendChild : function(elementPeer) {
|
||||
// Store parent and child relationship.
|
||||
elementPeer.setParent(this);
|
||||
var children = this.getChildren();
|
||||
children.include(elementPeer);
|
||||
|
||||
// Append element as a child.
|
||||
this._native.appendChild(elementPeer._native);
|
||||
|
||||
// Broadcast events ...
|
||||
web2d.peer.utils.EventUtils.broadcastChangeEvent(this, "strokeStyle");
|
||||
},
|
||||
|
||||
|
||||
removeChild : function(elementPeer) {
|
||||
// Store parent and child relationship.
|
||||
elementPeer.setParent(null);
|
||||
var children = this.getChildren();
|
||||
|
||||
// Remove from children array ...
|
||||
var length = children.length;
|
||||
|
||||
children.erase(elementPeer);
|
||||
|
||||
var newLength = children.length;
|
||||
if (newLength >= length) {
|
||||
throw "Could not remove the element.";
|
||||
}
|
||||
// Append element as a child.
|
||||
this._native.removeChild(elementPeer._native);
|
||||
},
|
||||
|
||||
/**
|
||||
* http://www.w3.org/TR/DOM-Level-3-Events/events.html
|
||||
* http://developer.mozilla.org/en/docs/addEvent
|
||||
*/
|
||||
addEvent : function(type, listener) {
|
||||
|
||||
this._native.addEvent(type, listener);
|
||||
|
||||
},
|
||||
|
||||
removeEvent : function(type, listener) {
|
||||
this._native.removeEvent(type, listener);
|
||||
},
|
||||
|
||||
setSize : function(width, height) {
|
||||
if ($defined(width) && this._size.width != parseInt(width)) {
|
||||
this._size.width = parseInt(width);
|
||||
this._native.setAttribute('width', parseInt(width));
|
||||
}
|
||||
|
||||
if ($defined(height) && this._size.height != parseInt(height)) {
|
||||
this._size.height = parseInt(height);
|
||||
this._native.setAttribute('height', parseInt(height));
|
||||
}
|
||||
|
||||
web2d.peer.utils.EventUtils.broadcastChangeEvent(this, "strokeStyle");
|
||||
},
|
||||
|
||||
getSize : function() {
|
||||
return {width:this._size.width,height:this._size.height};
|
||||
},
|
||||
|
||||
setFill : function(color, opacity) {
|
||||
if ($defined(color)) {
|
||||
this._native.setAttribute('fill', color);
|
||||
}
|
||||
if ($defined(opacity)) {
|
||||
this._native.setAttribute('fill-opacity', opacity);
|
||||
}
|
||||
},
|
||||
|
||||
getFill : function() {
|
||||
var color = this._native.getAttribute('fill');
|
||||
var opacity = this._native.getAttribute('fill-opacity');
|
||||
return {color:color, opacity:Number(opacity)};
|
||||
},
|
||||
|
||||
getStroke : function() {
|
||||
var vmlStroke = this._native;
|
||||
var color = vmlStroke.getAttribute('stroke');
|
||||
var dashstyle = this._stokeStyle;
|
||||
var opacity = vmlStroke.getAttribute('stroke-opacity');
|
||||
var width = vmlStroke.getAttribute('stroke-width');
|
||||
return {color: color, style: dashstyle, opacity: opacity, width: width};
|
||||
},
|
||||
|
||||
setStroke : function(width, style, color, opacity) {
|
||||
if ($defined(width)) {
|
||||
this._native.setAttribute('stroke-width', width + "px");
|
||||
}
|
||||
if ($defined(color)) {
|
||||
this._native.setAttribute('stroke', color);
|
||||
}
|
||||
if ($defined(style)) {
|
||||
// Scale the dash array in order to be equal to VML. In VML, stroke style doesn't scale.
|
||||
var dashArrayPoints = this.__stokeStyleToStrokDasharray[style];
|
||||
var scale = 1 / web2d.peer.utils.TransformUtil.workoutScale(this).width;
|
||||
|
||||
var strokeWidth = this._native.getAttribute('stroke-width');
|
||||
strokeWidth = parseFloat(strokeWidth);
|
||||
|
||||
var scaledPoints = [];
|
||||
for (var i = 0; i < dashArrayPoints.length; i++) {
|
||||
// VML scale the stroke based on the stroke width.
|
||||
scaledPoints[i] = dashArrayPoints[i] * strokeWidth;
|
||||
|
||||
// Scale the points based on the scale.
|
||||
scaledPoints[i] = (scaledPoints[i] * scale) + "px";
|
||||
}
|
||||
|
||||
// this._native.setAttribute('stroke-dasharray', scaledPoints);
|
||||
this._stokeStyle = style;
|
||||
}
|
||||
|
||||
if ($defined(opacity)) {
|
||||
this._native.setAttribute('stroke-opacity', opacity);
|
||||
}
|
||||
},
|
||||
|
||||
/*
|
||||
* style='visibility: visible'
|
||||
*/
|
||||
setVisibility : function(isVisible) {
|
||||
this._native.setAttribute('visibility', (isVisible) ? 'visible' : 'hidden');
|
||||
},
|
||||
|
||||
isVisible : function() {
|
||||
var visibility = this._native.getAttribute('visibility');
|
||||
return !(visibility == 'hidden');
|
||||
},
|
||||
|
||||
updateStrokeStyle : function() {
|
||||
var strokeStyle = this._stokeStyle;
|
||||
if (this.getParent()) {
|
||||
if (strokeStyle && strokeStyle != 'solid') {
|
||||
this.setStroke(null, strokeStyle);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
attachChangeEventListener : function(type, listener) {
|
||||
var listeners = this.getChangeEventListeners(type);
|
||||
if (!$defined(listener)) {
|
||||
throw "Listener can not be null";
|
||||
}
|
||||
listeners.push(listener);
|
||||
},
|
||||
|
||||
getChangeEventListeners : function(type) {
|
||||
var listeners = this._changeListeners[type];
|
||||
if (!$defined(listeners)) {
|
||||
listeners = [];
|
||||
this._changeListeners[type] = listeners;
|
||||
}
|
||||
return listeners;
|
||||
},
|
||||
|
||||
positionRelativeTo : function(elem, options) {
|
||||
options = !$defined(options) ? {} : options;
|
||||
options['relativeTo'] = $(this._native);
|
||||
elem.position(options);
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Move element to the front
|
||||
*/
|
||||
moveToFront : function() {
|
||||
this._native.parentNode.appendChild(this._native);
|
||||
},
|
||||
|
||||
/**
|
||||
* Move element to the back
|
||||
*/
|
||||
moveToBack : function() {
|
||||
this._native.parentNode.insertBefore(this._native, this._native.parentNode.firstChild);
|
||||
},
|
||||
|
||||
setCursor : function(type) {
|
||||
this._native.style.cursor = type;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
web2d.peer.svg.ElementPeer.prototype.svgNamespace = 'http://www.w3.org/2000/svg';
|
||||
web2d.peer.svg.ElementPeer.prototype.linkNamespace = 'http://www.w3.org/1999/xlink';
|
||||
|
||||
web2d.peer.svg.ElementPeer.prototype.setChildren = function(children) {
|
||||
this._children = children;
|
||||
};
|
||||
|
||||
web2d.peer.svg.ElementPeer.prototype.getChildren = function() {
|
||||
var result = this._children;
|
||||
if (!$defined(result)) {
|
||||
result = [];
|
||||
this._children = result;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
web2d.peer.svg.ElementPeer.prototype.getParent = function() {
|
||||
return this._parent;
|
||||
};
|
||||
|
||||
web2d.peer.svg.ElementPeer.prototype.setParent = function(parent) {
|
||||
this._parent = parent;
|
||||
};
|
||||
|
||||
web2d.peer.svg.ElementPeer.prototype.appendChild = function(elementPeer) {
|
||||
// Store parent and child relationship.
|
||||
elementPeer.setParent(this);
|
||||
var children = this.getChildren();
|
||||
children.include(elementPeer);
|
||||
|
||||
// Append element as a child.
|
||||
this._native.appendChild(elementPeer._native);
|
||||
|
||||
// Broadcast events ...
|
||||
web2d.peer.utils.EventUtils.broadcastChangeEvent(this, "strokeStyle");
|
||||
};
|
||||
|
||||
|
||||
web2d.peer.svg.ElementPeer.prototype.removeChild = function(elementPeer) {
|
||||
// Store parent and child relationship.
|
||||
elementPeer.setParent(null);
|
||||
var children = this.getChildren();
|
||||
|
||||
// Remove from children array ...
|
||||
var length = children.length;
|
||||
|
||||
children.erase(elementPeer);
|
||||
|
||||
var newLength = children.length;
|
||||
if (newLength >= length) {
|
||||
throw "Could not remove the element.";
|
||||
}
|
||||
// Append element as a child.
|
||||
this._native.removeChild(elementPeer._native);
|
||||
};
|
||||
|
||||
/**
|
||||
* http://www.w3.org/TR/DOM-Level-3-Events/events.html
|
||||
* http://developer.mozilla.org/en/docs/addEvent
|
||||
*/
|
||||
web2d.peer.svg.ElementPeer.prototype.addEvent = function(type, listener) {
|
||||
|
||||
this._native.addEvent(type, listener);
|
||||
|
||||
};
|
||||
|
||||
web2d.peer.svg.ElementPeer.prototype.removeEvent = function(type, listener) {
|
||||
this._native.removeEvent(type, listener);
|
||||
};
|
||||
|
||||
web2d.peer.svg.ElementPeer.prototype.setSize = function(width, height) {
|
||||
if ($defined(width) && this._size.width != parseInt(width)) {
|
||||
this._size.width = parseInt(width);
|
||||
this._native.setAttribute('width', parseInt(width));
|
||||
}
|
||||
|
||||
if ($defined(height) && this._size.height != parseInt(height)) {
|
||||
this._size.height = parseInt(height);
|
||||
this._native.setAttribute('height', parseInt(height));
|
||||
}
|
||||
|
||||
web2d.peer.utils.EventUtils.broadcastChangeEvent(this, "strokeStyle");
|
||||
};
|
||||
|
||||
web2d.peer.svg.ElementPeer.prototype.getSize = function() {
|
||||
return {width:this._size.width,height:this._size.height};
|
||||
};
|
||||
|
||||
web2d.peer.svg.ElementPeer.prototype.setFill = function(color, opacity) {
|
||||
if ($defined(color)) {
|
||||
this._native.setAttribute('fill', color);
|
||||
}
|
||||
if ($defined(opacity)) {
|
||||
this._native.setAttribute('fill-opacity', opacity);
|
||||
}
|
||||
};
|
||||
|
||||
web2d.peer.svg.ElementPeer.prototype.getFill = function() {
|
||||
var color = this._native.getAttribute('fill');
|
||||
var opacity = this._native.getAttribute('fill-opacity');
|
||||
return {color:color, opacity:Number(opacity)};
|
||||
};
|
||||
|
||||
web2d.peer.svg.ElementPeer.prototype.getStroke = function() {
|
||||
var vmlStroke = this._native;
|
||||
var color = vmlStroke.getAttribute('stroke');
|
||||
var dashstyle = this._stokeStyle;
|
||||
var opacity = vmlStroke.getAttribute('stroke-opacity');
|
||||
var width = vmlStroke.getAttribute('stroke-width');
|
||||
return {color: color, style: dashstyle, opacity: opacity, width: width};
|
||||
};
|
||||
|
||||
web2d.peer.svg.ElementPeer.prototype.__stokeStyleToStrokDasharray = {solid:[],dot:[1,3],dash:[4,3],longdash:[10,2],dashdot:[5,3,1,3]};
|
||||
web2d.peer.svg.ElementPeer.prototype.setStroke = function(width, style, color, opacity) {
|
||||
if ($defined(width)) {
|
||||
this._native.setAttribute('stroke-width', width + "px");
|
||||
}
|
||||
if ($defined(color)) {
|
||||
this._native.setAttribute('stroke', color);
|
||||
}
|
||||
if ($defined(style)) {
|
||||
// Scale the dash array in order to be equal to VML. In VML, stroke style doesn't scale.
|
||||
var dashArrayPoints = this.__stokeStyleToStrokDasharray[style];
|
||||
var scale = 1 / web2d.peer.utils.TransformUtil.workoutScale(this).width;
|
||||
|
||||
var strokeWidth = this._native.getAttribute('stroke-width');
|
||||
strokeWidth = parseFloat(strokeWidth);
|
||||
|
||||
var scaledPoints = [];
|
||||
for (var i = 0; i < dashArrayPoints.length; i++) {
|
||||
// VML scale the stroke based on the stroke width.
|
||||
scaledPoints[i] = dashArrayPoints[i] * strokeWidth;
|
||||
|
||||
// Scale the points based on the scale.
|
||||
scaledPoints[i] = (scaledPoints[i] * scale) + "px";
|
||||
}
|
||||
|
||||
// this._native.setAttribute('stroke-dasharray', scaledPoints);
|
||||
this._stokeStyle = style;
|
||||
}
|
||||
|
||||
if ($defined(opacity)) {
|
||||
this._native.setAttribute('stroke-opacity', opacity);
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* style='visibility: visible'
|
||||
*/
|
||||
web2d.peer.svg.ElementPeer.prototype.setVisibility = function(isVisible) {
|
||||
this._native.setAttribute('visibility', (isVisible) ? 'visible' : 'hidden');
|
||||
};
|
||||
|
||||
web2d.peer.svg.ElementPeer.prototype.isVisible = function() {
|
||||
var visibility = this._native.getAttribute('visibility');
|
||||
return !(visibility == 'hidden');
|
||||
};
|
||||
|
||||
web2d.peer.svg.ElementPeer.prototype.updateStrokeStyle = function() {
|
||||
var strokeStyle = this._stokeStyle;
|
||||
if (this.getParent()) {
|
||||
if (strokeStyle && strokeStyle != 'solid') {
|
||||
this.setStroke(null, strokeStyle);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
web2d.peer.svg.ElementPeer.prototype.attachChangeEventListener = function(type, listener) {
|
||||
var listeners = this.getChangeEventListeners(type);
|
||||
if (!$defined(listener)) {
|
||||
throw "Listener can not be null";
|
||||
}
|
||||
listeners.push(listener);
|
||||
};
|
||||
|
||||
web2d.peer.svg.ElementPeer.prototype.getChangeEventListeners = function(type) {
|
||||
var listeners = this._changeListeners[type];
|
||||
if (!$defined(listeners)) {
|
||||
listeners = [];
|
||||
this._changeListeners[type] = listeners;
|
||||
}
|
||||
return listeners;
|
||||
};
|
||||
|
||||
web2d.peer.svg.ElementPeer.prototype.positionRelativeTo = function(elem, options) {
|
||||
options = !$defined(options) ? {} : options;
|
||||
options['relativeTo'] = $(this._native);
|
||||
elem.position(options);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Move element to the front
|
||||
*/
|
||||
web2d.peer.svg.ElementPeer.prototype.moveToFront = function() {
|
||||
this._native.parentNode.appendChild(this._native);
|
||||
};
|
||||
|
||||
/**
|
||||
* Move element to the back
|
||||
*/
|
||||
web2d.peer.svg.ElementPeer.prototype.moveToBack = function() {
|
||||
this._native.parentNode.insertBefore(this._native, this._native.parentNode.firstChild);
|
||||
};
|
||||
|
||||
web2d.peer.svg.ElementPeer.prototype.setCursor = function(type) {
|
||||
this._native.style.cursor = type;
|
||||
};
|
||||
|
@@ -1,66 +1,59 @@
|
||||
/*
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
web2d.peer.svg.ElipsePeer = function()
|
||||
{
|
||||
var svgElement = window.document.createElementNS(this.svgNamespace, 'ellipse');
|
||||
web2d.peer.svg.ElementPeer.call(this, svgElement);
|
||||
this.attachChangeEventListener("strokeStyle", web2d.peer.svg.ElementPeer.prototype.updateStrokeStyle);
|
||||
this._position={x:0, y:0};
|
||||
};
|
||||
web2d.peer.svg.ElipsePeer = new Class({
|
||||
Extends: web2d.peer.svg.ElementPeer,
|
||||
initialize : function() {
|
||||
var svgElement = window.document.createElementNS(this.svgNamespace, 'ellipse');
|
||||
this.parent(svgElement);
|
||||
this.attachChangeEventListener("strokeStyle", web2d.peer.svg.ElementPeer.prototype.updateStrokeStyle);
|
||||
this._position = {x:0, y:0};
|
||||
},
|
||||
|
||||
objects.extend(web2d.peer.svg.ElipsePeer, web2d.peer.svg.ElementPeer);
|
||||
setSize : function(width, height) {
|
||||
this.parent(width, height);
|
||||
if ($defined(width)) {
|
||||
this._native.setAttribute('rx', width / 2);
|
||||
}
|
||||
|
||||
web2d.peer.svg.ElipsePeer.prototype.setSize = function(width, height)
|
||||
{
|
||||
web2d.peer.svg.ElipsePeer.superClass.setSize.call(this, width, height);
|
||||
if ($defined(width))
|
||||
{
|
||||
this._native.setAttribute('rx', width / 2);
|
||||
if ($defined(height)) {
|
||||
this._native.setAttribute('ry', height / 2);
|
||||
}
|
||||
|
||||
var pos = this.getPosition();
|
||||
this.setPosition(pos.x, pos.y);
|
||||
},
|
||||
|
||||
setPosition : function(cx, cy) {
|
||||
var size = this.getSize();
|
||||
cx = cx + size.width / 2;
|
||||
cy = cy + size.height / 2;
|
||||
if ($defined(cx)) {
|
||||
this._native.setAttribute('cx', cx);
|
||||
}
|
||||
|
||||
if ($defined(cy)) {
|
||||
this._native.setAttribute('cy', cy);
|
||||
}
|
||||
},
|
||||
|
||||
getPosition : function() {
|
||||
return this._position;
|
||||
}
|
||||
|
||||
if ($defined(height))
|
||||
{
|
||||
this._native.setAttribute('ry', height / 2);
|
||||
}
|
||||
|
||||
var pos = this.getPosition();
|
||||
this.setPosition(pos.x, pos.y);
|
||||
};
|
||||
|
||||
web2d.peer.svg.ElipsePeer.prototype.setPosition = function(cx, cy)
|
||||
{
|
||||
var size =this.getSize();
|
||||
cx =cx + size.width/2;
|
||||
cy =cy + size.height/2;
|
||||
if ($defined(cx))
|
||||
{
|
||||
this._native.setAttribute('cx', cx);
|
||||
}
|
||||
|
||||
if ($defined(cy))
|
||||
{
|
||||
this._native.setAttribute('cy', cy);
|
||||
}
|
||||
};
|
||||
|
||||
web2d.peer.svg.ElipsePeer.prototype.getPosition = function()
|
||||
{
|
||||
return this._position;
|
||||
};
|
||||
});
|
||||
|
||||
|
@@ -1,108 +1,92 @@
|
||||
/*
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
web2d.peer.svg.Font = function()
|
||||
{
|
||||
this._size = 10;
|
||||
this._style = "normal";
|
||||
this._weight = "normal";
|
||||
};
|
||||
web2d.peer.svg.Font = new Class({
|
||||
initialize : function() {
|
||||
this._size = 10;
|
||||
this._style = "normal";
|
||||
this._weight = "normal";
|
||||
},
|
||||
|
||||
web2d.peer.svg.Font.prototype.init = function(args)
|
||||
{
|
||||
if ($defined(args.size))
|
||||
{
|
||||
this._size = parseInt(args.size);
|
||||
init : function(args) {
|
||||
if ($defined(args.size)) {
|
||||
this._size = parseInt(args.size);
|
||||
}
|
||||
if ($defined(args.style)) {
|
||||
this._style = args.style;
|
||||
}
|
||||
if ($defined(args.weight)) {
|
||||
this._weight = args.weight;
|
||||
}
|
||||
},
|
||||
|
||||
getHtmlSize : function (scale) {
|
||||
var result = 0;
|
||||
if (this._size == 6) {
|
||||
result = this._size * scale.height * 43 / 32;
|
||||
}
|
||||
if (this._size == 8) {
|
||||
result = this._size * scale.height * 42 / 32;
|
||||
}
|
||||
else if (this._size == 10) {
|
||||
result = this._size * scale.height * 42 / 32;
|
||||
}
|
||||
else if (this._size == 15) {
|
||||
result = this._size * scale.height * 42 / 32;
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
getGraphSize : function () {
|
||||
return this._size * 43 / 32;
|
||||
},
|
||||
|
||||
getSize : function () {
|
||||
return parseInt(this._size);
|
||||
},
|
||||
|
||||
getStyle : function () {
|
||||
return this._style;
|
||||
},
|
||||
|
||||
getWeight : function () {
|
||||
return this._weight;
|
||||
},
|
||||
|
||||
setSize : function (size) {
|
||||
this._size = size;
|
||||
},
|
||||
|
||||
setStyle : function (style) {
|
||||
this._style = style;
|
||||
},
|
||||
|
||||
setWeight : function (weight) {
|
||||
this._weight = weight;
|
||||
},
|
||||
|
||||
getWidthMargin : function () {
|
||||
var result = 0;
|
||||
if (this._size == 10 || this._size == 6) {
|
||||
result = 4;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
if ($defined(args.style))
|
||||
{
|
||||
this._style = args.style;
|
||||
}
|
||||
if ($defined(args.weight))
|
||||
{
|
||||
this._weight = args.weight;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
web2d.peer.svg.Font.prototype.getHtmlSize = function (scale)
|
||||
{
|
||||
var result = 0;
|
||||
if (this._size == 6)
|
||||
{
|
||||
result = this._size * scale.height * 43 / 32;
|
||||
}
|
||||
if (this._size == 8)
|
||||
{
|
||||
result = this._size * scale.height * 42 / 32;
|
||||
}
|
||||
else if (this._size == 10)
|
||||
{
|
||||
result = this._size * scale.height * 42 / 32;
|
||||
}
|
||||
else if (this._size == 15)
|
||||
{
|
||||
result = this._size * scale.height * 42 / 32;
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
web2d.peer.svg.Font.prototype.getGraphSize = function (scale)
|
||||
{
|
||||
return this._size * 43 / 32;
|
||||
};
|
||||
|
||||
web2d.peer.svg.Font.prototype.getSize = function ()
|
||||
{
|
||||
return parseInt(this._size);
|
||||
};
|
||||
|
||||
web2d.peer.svg.Font.prototype.getStyle = function ()
|
||||
{
|
||||
return this._style;
|
||||
};
|
||||
|
||||
web2d.peer.svg.Font.prototype.getWeight = function ()
|
||||
{
|
||||
return this._weight;
|
||||
};
|
||||
|
||||
web2d.peer.svg.Font.prototype.setSize = function (size)
|
||||
{
|
||||
this._size = size;
|
||||
};
|
||||
|
||||
web2d.peer.svg.Font.prototype.setStyle = function (style)
|
||||
{
|
||||
this._style = style;
|
||||
};
|
||||
|
||||
web2d.peer.svg.Font.prototype.setWeight = function (weight)
|
||||
{
|
||||
this._weight = weight;
|
||||
};
|
||||
|
||||
web2d.peer.svg.Font.prototype.getWidthMargin = function ()
|
||||
{
|
||||
var result = 0;
|
||||
if (this._size == 10 || this._size == 6)
|
||||
{
|
||||
result = 4;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
@@ -1,138 +1,120 @@
|
||||
/*
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
web2d.peer.svg.GroupPeer = function()
|
||||
{
|
||||
var svgElement = window.document.createElementNS(this.svgNamespace, 'g');
|
||||
web2d.peer.svg.ElementPeer.call(this, svgElement);
|
||||
this._native.setAttribute("preserveAspectRatio", "none");
|
||||
this._coordSize = {width:1,height:1};
|
||||
this._native.setAttribute("focusable","true");
|
||||
this._position = {x:0,y:0};
|
||||
this._coordOrigin = {x:0,y:0};
|
||||
};
|
||||
|
||||
objects.extend(web2d.peer.svg.GroupPeer, web2d.peer.svg.ElementPeer);
|
||||
|
||||
/*web2d.peer.svg.GroupPeer.prototype.setPosition = function(cx, cy)
|
||||
{
|
||||
this._native.setAttribute("transform", "translate(" + parseInt(cx) + " " + parseInt(cy) + ")");
|
||||
};*/
|
||||
|
||||
web2d.peer.svg.GroupPeer.prototype.setCoordSize = function(width, height)
|
||||
{
|
||||
var change = this._coordSize.width!=width || this._coordSize.height!=height;
|
||||
this._coordSize.width = width;
|
||||
this._coordSize.height = height;
|
||||
if(change)
|
||||
this.updateTransform();
|
||||
web2d.peer.utils.EventUtils.broadcastChangeEvent(this, "strokeStyle");
|
||||
};
|
||||
|
||||
web2d.peer.svg.GroupPeer.prototype.getCoordSize = function()
|
||||
{
|
||||
return {width:this._coordSize.width,height:this._coordSize.height};
|
||||
};
|
||||
|
||||
/**
|
||||
* http://www.w3.org/TR/SVG/coords.html#TransformAttribute
|
||||
* 7.6 The transform attribute
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* The value of the transform attribute is a <transform-list>, which is defined as a list of transform definitions, which are applied in the order provided. The individual transform definitions are separated by whitespace and/or a comma. The available types of transform definitions include:
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* * matrix(<a> <b> <c> <d> <e> <f>), which specifies a transformation in the form of a transformation matrix of six values. matrix(a,b,c,d,e,f) is equivalent to applying the transformation matrix [a b c d e f].
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* * translate(<tx> [<ty>]), which specifies a translation by tx and ty. If <ty> is not provided, it is assumed to be zero.
|
||||
*
|
||||
* * scale(<sx> [<sy>]), which specifies a scale operation by sx and sy. If <sy> is not provided, it is assumed to be equal to <sx>.
|
||||
*
|
||||
* * rotate(<rotate-angle> [<cx> <cy>]), which specifies a rotation by <rotate-angle> degrees about a given point.
|
||||
* If optional parameters <cx> and <cy> are not supplied, the rotate is about the origin of the current user coordinate system. The operation corresponds to the matrix [cos(a) sin(a) -sin(a) cos(a) 0 0].
|
||||
* If optional parameters <cx> and <cy> are supplied, the rotate is about the point (<cx>, <cy>). The operation represents the equivalent of the following specification: translate(<cx>, <cy>) rotate(<rotate-angle>) translate(-<cx>, -<cy>).
|
||||
*
|
||||
* * skewX(<skew-angle>), which specifies a skew transformation along the x-axis.
|
||||
*
|
||||
* * skewY(<skew-angle>), which specifies a skew transformation along the y-axis.
|
||||
**/
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
web2d.peer.svg.GroupPeer.prototype.updateTransform = function()
|
||||
{
|
||||
var sx = this._size.width / this._coordSize.width;
|
||||
var sy = this._size.height / this._coordSize.height;
|
||||
web2d.peer.svg.GroupPeer = new Class({
|
||||
Extends: web2d.peer.svg.ElementPeer,
|
||||
initialize : function() {
|
||||
var svgElement = window.document.createElementNS(this.svgNamespace, 'g');
|
||||
this.parent(svgElement);
|
||||
this._native.setAttribute("preserveAspectRatio", "none");
|
||||
this._coordSize = {width:1,height:1};
|
||||
this._native.setAttribute("focusable", "true");
|
||||
this._position = {x:0,y:0};
|
||||
this._coordOrigin = {x:0,y:0};
|
||||
},
|
||||
|
||||
var cx = this._position.x - this._coordOrigin.x * sx;
|
||||
var cy = this._position.y - this._coordOrigin.y * sy;
|
||||
setCoordSize : function(width, height) {
|
||||
var change = this._coordSize.width != width || this._coordSize.height != height;
|
||||
this._coordSize.width = width;
|
||||
this._coordSize.height = height;
|
||||
if (change)
|
||||
this.updateTransform();
|
||||
web2d.peer.utils.EventUtils.broadcastChangeEvent(this, "strokeStyle");
|
||||
},
|
||||
|
||||
this._native.setAttribute("transform", "translate(" + cx + "," + cy + ") scale(" + sx + "," + sy + ")");
|
||||
};
|
||||
getCoordSize : function() {
|
||||
return {width:this._coordSize.width,height:this._coordSize.height};
|
||||
},
|
||||
|
||||
web2d.peer.svg.GroupPeer.prototype.setCoordOrigin = function(x, y)
|
||||
{
|
||||
var change = x!=this._coordOrigin.x || y!=this._coordOrigin.y;
|
||||
if ($defined(x))
|
||||
{
|
||||
this._coordOrigin.x = x;
|
||||
/**
|
||||
* http://www.w3.org/TR/SVG/coords.html#TransformAttribute
|
||||
* 7.6 The transform attribute
|
||||
*
|
||||
* The value of the transform attribute is a <transform-list>, which is defined as a list of transform definitions, which are applied in the order provided. The individual transform definitions are separated by whitespace and/or a comma. The available types of transform definitions include:
|
||||
*
|
||||
* * matrix(<a> <b> <c> <d> <e> <f>), which specifies a transformation in the form of a transformation matrix of six values. matrix(a,b,c,d,e,f) is equivalent to applying the transformation matrix [a b c d e f].
|
||||
*
|
||||
* * translate(<tx> [<ty>]), which specifies a translation by tx and ty. If <ty> is not provided, it is assumed to be zero.
|
||||
*
|
||||
* * scale(<sx> [<sy>]), which specifies a scale operation by sx and sy. If <sy> is not provided, it is assumed to be equal to <sx>.
|
||||
*
|
||||
* * rotate(<rotate-angle> [<cx> <cy>]), which specifies a rotation by <rotate-angle> degrees about a given point.
|
||||
* If optional parameters <cx> and <cy> are not supplied, the rotate is about the origin of the current user coordinate system. The operation corresponds to the matrix [cos(a) sin(a) -sin(a) cos(a) 0 0].
|
||||
* If optional parameters <cx> and <cy> are supplied, the rotate is about the point (<cx>, <cy>). The operation represents the equivalent of the following specification: translate(<cx>, <cy>) rotate(<rotate-angle>) translate(-<cx>, -<cy>).
|
||||
*
|
||||
* * skewX(<skew-angle>), which specifies a skew transformation along the x-axis.
|
||||
*
|
||||
* * skewY(<skew-angle>), which specifies a skew transformation along the y-axis.
|
||||
**/
|
||||
|
||||
updateTransform : function() {
|
||||
var sx = this._size.width / this._coordSize.width;
|
||||
var sy = this._size.height / this._coordSize.height;
|
||||
|
||||
var cx = this._position.x - this._coordOrigin.x * sx;
|
||||
var cy = this._position.y - this._coordOrigin.y * sy;
|
||||
|
||||
this._native.setAttribute("transform", "translate(" + cx + "," + cy + ") scale(" + sx + "," + sy + ")");
|
||||
},
|
||||
|
||||
setCoordOrigin : function(x, y) {
|
||||
var change = x != this._coordOrigin.x || y != this._coordOrigin.y;
|
||||
if ($defined(x)) {
|
||||
this._coordOrigin.x = x;
|
||||
}
|
||||
|
||||
if ($defined(y)) {
|
||||
this._coordOrigin.y = y;
|
||||
}
|
||||
if (change)
|
||||
this.updateTransform();
|
||||
},
|
||||
|
||||
setSize : function(width, height) {
|
||||
var change = width != this._size.width || height != this._size.height;
|
||||
this.parent(width, height);
|
||||
if (change)
|
||||
this.updateTransform();
|
||||
},
|
||||
|
||||
setPosition : function(x, y) {
|
||||
var change = x != this._position.x || y != this._position.y;
|
||||
if ($defined(x)) {
|
||||
this._position.x = parseInt(x);
|
||||
}
|
||||
|
||||
if ($defined(y)) {
|
||||
this._position.y = parseInt(y);
|
||||
}
|
||||
if (change)
|
||||
this.updateTransform();
|
||||
},
|
||||
|
||||
getPosition : function() {
|
||||
return {x:this._position.x,y:this._position.y};
|
||||
},
|
||||
|
||||
appendChild : function(child) {
|
||||
this.parent(child);
|
||||
web2d.peer.utils.EventUtils.broadcastChangeEvent(child, "onChangeCoordSize");
|
||||
},
|
||||
|
||||
getCoordOrigin : function () {
|
||||
return {x:this._coordOrigin.x, y:this._coordOrigin.y};
|
||||
}
|
||||
|
||||
if ($defined(y))
|
||||
{
|
||||
this._coordOrigin.y = y;
|
||||
}
|
||||
if(change)
|
||||
this.updateTransform();
|
||||
};
|
||||
|
||||
web2d.peer.svg.GroupPeer.prototype.setSize = function(width, height)
|
||||
{
|
||||
var change = width != this._size.width || height!=this._size.height;
|
||||
web2d.peer.svg.GroupPeer.superClass.setSize.call(this, width, height);
|
||||
if(change)
|
||||
this.updateTransform();
|
||||
};
|
||||
|
||||
web2d.peer.svg.GroupPeer.prototype.setPosition = function(x, y)
|
||||
{
|
||||
var change = x!=this._position.x || y!=this._position.y;
|
||||
if ($defined(x))
|
||||
{
|
||||
this._position.x = parseInt(x);
|
||||
}
|
||||
|
||||
if ($defined(y))
|
||||
{
|
||||
this._position.y = parseInt(y);
|
||||
}
|
||||
if(change)
|
||||
this.updateTransform();
|
||||
};
|
||||
|
||||
web2d.peer.svg.GroupPeer.prototype.getPosition = function()
|
||||
{
|
||||
return {x:this._position.x,y:this._position.y};
|
||||
};
|
||||
|
||||
web2d.peer.svg.GroupPeer.prototype.appendChild = function(child)
|
||||
{
|
||||
web2d.peer.svg.GroupPeer.superClass.appendChild.call(this, child);
|
||||
web2d.peer.utils.EventUtils.broadcastChangeEvent(child, "onChangeCoordSize");
|
||||
};
|
||||
|
||||
web2d.peer.svg.GroupPeer.prototype.getCoordOrigin = function ()
|
||||
{
|
||||
return {x:this._coordOrigin.x, y:this._coordOrigin.y};
|
||||
};
|
||||
});
|
@@ -1,51 +1,46 @@
|
||||
/*
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
web2d.peer.svg.ImagePeer = function()
|
||||
{
|
||||
var svgElement = window.document.createElementNS(this.svgNamespace, 'image');
|
||||
web2d.peer.svg.ElementPeer.call(this, svgElement);
|
||||
this._position = {x:0,y:0};
|
||||
this._href="";
|
||||
};
|
||||
web2d.peer.svg.ImagePeer = new Class({
|
||||
Extends: web2d.peer.svg.ElementPeer,
|
||||
initialize : function() {
|
||||
var svgElement = window.document.createElementNS(this.svgNamespace, 'image');
|
||||
this.parent(svgElement);
|
||||
this._position = {x:0,y:0};
|
||||
this._href = "";
|
||||
},
|
||||
|
||||
objects.extend(web2d.peer.svg.ImagePeer, web2d.peer.svg.ElementPeer);
|
||||
setPosition : function(x, y) {
|
||||
this._position = {x:x, y:y};
|
||||
this._native.setAttribute('y', y);
|
||||
this._native.setAttribute('x', x);
|
||||
},
|
||||
|
||||
web2d.peer.svg.ImagePeer.prototype.setPosition = function(x, y)
|
||||
{
|
||||
this._position = {x:x, y:y};
|
||||
this._native.setAttribute('y', y);
|
||||
this._native.setAttribute('x', x);
|
||||
};
|
||||
getPosition : function() {
|
||||
return this._position;
|
||||
},
|
||||
|
||||
setHref : function(url) {
|
||||
this._native.setAttributeNS(this.linkNamespace, "href", url);
|
||||
this._href = url;
|
||||
},
|
||||
|
||||
web2d.peer.svg.ImagePeer.prototype.getPosition = function()
|
||||
{
|
||||
return this._position;
|
||||
};
|
||||
|
||||
web2d.peer.svg.ImagePeer.prototype.setHref = function(url)
|
||||
{
|
||||
this._native.setAttributeNS(this.linkNamespace, "href", url);
|
||||
this._href = url;
|
||||
};
|
||||
|
||||
web2d.peer.svg.ImagePeer.prototype.getHref = function()
|
||||
{
|
||||
return this._href;
|
||||
};
|
||||
getHref : function() {
|
||||
return this._href;
|
||||
}
|
||||
});
|
@@ -1,67 +1,61 @@
|
||||
/*
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
web2d.peer.svg.LinePeer = function()
|
||||
{
|
||||
var svgElement = window.document.createElementNS(this.svgNamespace, 'line');
|
||||
web2d.peer.svg.ElementPeer.call(this, svgElement);
|
||||
this.attachChangeEventListener("strokeStyle", web2d.peer.svg.ElementPeer.prototype.updateStrokeStyle);
|
||||
};
|
||||
web2d.peer.svg.LinePeer = new Class({
|
||||
Extends: web2d.peer.svg.ElementPeer,
|
||||
initialize : function() {
|
||||
var svgElement = window.document.createElementNS(this.svgNamespace, 'line');
|
||||
this.parent(svgElement);
|
||||
this.attachChangeEventListener("strokeStyle", web2d.peer.svg.ElementPeer.prototype.updateStrokeStyle);
|
||||
},
|
||||
|
||||
objects.extend(web2d.peer.svg.LinePeer, web2d.peer.svg.ElementPeer);
|
||||
setFrom : function(x1, y1) {
|
||||
this._x1 = x1;
|
||||
this._y1 = y1;
|
||||
this._native.setAttribute('x1', x1);
|
||||
this._native.setAttribute('y1', y1);
|
||||
},
|
||||
|
||||
web2d.peer.svg.LinePeer.prototype.setFrom = function(x1, y1)
|
||||
{
|
||||
this._x1=x1;
|
||||
this._y1=y1;
|
||||
this._native.setAttribute('x1', x1);
|
||||
this._native.setAttribute('y1', y1);
|
||||
};
|
||||
setTo : function(x2, y2) {
|
||||
this._x2 = x2;
|
||||
this._y2 = y2;
|
||||
this._native.setAttribute('x2', x2);
|
||||
this._native.setAttribute('y2', y2);
|
||||
},
|
||||
|
||||
web2d.peer.svg.LinePeer.prototype.setTo = function(x2, y2)
|
||||
{
|
||||
this._x2=x2;
|
||||
this._y2=y2;
|
||||
this._native.setAttribute('x2', x2);
|
||||
this._native.setAttribute('y2', y2);
|
||||
};
|
||||
getFrom : function() {
|
||||
return new core.Point(this._x1, this._y1);
|
||||
},
|
||||
|
||||
web2d.peer.svg.LinePeer.prototype.getFrom = function(){
|
||||
return new core.Point(this._x1,this._y1);
|
||||
};
|
||||
getTo : function() {
|
||||
return new core.Point(this._x2, this._y2);
|
||||
},
|
||||
|
||||
web2d.peer.svg.LinePeer.prototype.getTo = function(){
|
||||
return new core.Point(this._x2,this._y2);
|
||||
};
|
||||
/*
|
||||
* http://www.zvon.org/HowTo/Output/howto_jj_svg_27.html?at=marker-end
|
||||
*/
|
||||
setArrowStyle : function(startStyle, endStyle) {
|
||||
if ($defined(startStyle)) {
|
||||
// Todo: This must be implemented ...
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* http://www.zvon.org/HowTo/Output/howto_jj_svg_27.html?at=marker-end
|
||||
*/
|
||||
web2d.peer.svg.LinePeer.prototype.setArrowStyle = function(startStyle, endStyle)
|
||||
{
|
||||
if ($defined(startStyle))
|
||||
{
|
||||
// Todo: This must be implemented ...
|
||||
if ($defined(endStyle)) {
|
||||
// Todo: This must be implemented ...
|
||||
}
|
||||
}
|
||||
|
||||
if ($defined(endStyle))
|
||||
{
|
||||
// Todo: This must be implemented ...
|
||||
}
|
||||
};
|
||||
});
|
@@ -1,121 +1,104 @@
|
||||
/*
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
web2d.peer.svg.PolyLinePeer = function()
|
||||
{
|
||||
var svgElement = window.document.createElementNS(this.svgNamespace, 'polyline');
|
||||
web2d.peer.svg.ElementPeer.call(this, svgElement);
|
||||
this.setFill("none");
|
||||
this.breakDistance = 10;
|
||||
};
|
||||
web2d.peer.svg.PolyLinePeer = new Class({
|
||||
Extends: web2d.peer.svg.ElementPeer,
|
||||
initialize : function() {
|
||||
|
||||
objects.extend(web2d.peer.svg.PolyLinePeer, web2d.peer.svg.ElementPeer);
|
||||
var svgElement = window.document.createElementNS(this.svgNamespace, 'polyline');
|
||||
this.parent(svgElement);
|
||||
this.setFill("none");
|
||||
this.breakDistance = 10;
|
||||
},
|
||||
|
||||
web2d.peer.svg.PolyLinePeer.prototype.setFrom = function(x1, y1)
|
||||
{
|
||||
this._x1 = x1;
|
||||
this._y1 = y1;
|
||||
this._updatePath();
|
||||
};
|
||||
setFrom : function(x1, y1) {
|
||||
this._x1 = x1;
|
||||
this._y1 = y1;
|
||||
this._updatePath();
|
||||
},
|
||||
|
||||
web2d.peer.svg.PolyLinePeer.prototype.setTo = function(x2, y2)
|
||||
{
|
||||
this._x2 = x2;
|
||||
this._y2 = y2;
|
||||
this._updatePath();
|
||||
};
|
||||
setTo : function(x2, y2) {
|
||||
this._x2 = x2;
|
||||
this._y2 = y2;
|
||||
this._updatePath();
|
||||
},
|
||||
|
||||
web2d.peer.svg.PolyLinePeer.prototype.setStrokeWidth = function(width)
|
||||
{
|
||||
this._native.setAttribute('stroke-width', width);
|
||||
};
|
||||
setStrokeWidth : function(width) {
|
||||
this._native.setAttribute('stroke-width', width);
|
||||
},
|
||||
|
||||
web2d.peer.svg.PolyLinePeer.prototype.setColor = function(color)
|
||||
{
|
||||
this._native.setAttribute('stroke', color);
|
||||
};
|
||||
setColor : function(color) {
|
||||
this._native.setAttribute('stroke', color);
|
||||
},
|
||||
|
||||
web2d.peer.svg.PolyLinePeer.prototype.setStyle = function(style)
|
||||
{
|
||||
this._style = style;
|
||||
this._updatePath();
|
||||
};
|
||||
setStyle : function(style) {
|
||||
this._style = style;
|
||||
this._updatePath();
|
||||
},
|
||||
|
||||
web2d.peer.svg.PolyLinePeer.prototype.getStyle = function()
|
||||
{
|
||||
return this._style;
|
||||
};
|
||||
getStyle : function() {
|
||||
return this._style;
|
||||
},
|
||||
|
||||
web2d.peer.svg.PolyLinePeer.prototype._updatePath = function()
|
||||
{
|
||||
if (this._style == "Curved")
|
||||
{
|
||||
this._updateMiddleCurvePath();
|
||||
}
|
||||
else if (this._style == "Straight")
|
||||
{
|
||||
this._updateStraightPath();
|
||||
}
|
||||
else
|
||||
{
|
||||
this._updateCurvePath();
|
||||
}
|
||||
};
|
||||
|
||||
web2d.peer.svg.PolyLinePeer.prototype._updateStraightPath = function()
|
||||
{
|
||||
if ($defined(this._x1) && $defined(this._x2) && $defined(this._y1) && $defined(this._y2))
|
||||
{
|
||||
var path = web2d.PolyLine.buildStraightPath(this.breakDistance, this._x1, this._y1, this._x2, this._y2);
|
||||
this._native.setAttribute('points', path);
|
||||
}
|
||||
};
|
||||
|
||||
web2d.peer.svg.PolyLinePeer.prototype._updateMiddleCurvePath = function()
|
||||
{
|
||||
var x1 = this._x1;
|
||||
var y1 = this._y1;
|
||||
var x2 = this._x2;
|
||||
var y2 = this._y2;
|
||||
if ($defined(x1) && $defined(x2) && $defined(y1) && $defined(y2))
|
||||
{
|
||||
var diff = x2 - x1;
|
||||
var middlex = (diff / 2) + x1;
|
||||
var signx = 1;
|
||||
var signy = 1;
|
||||
if (diff < 0)
|
||||
{
|
||||
signx = -1;
|
||||
_updatePath : function() {
|
||||
if (this._style == "Curved") {
|
||||
this._updateMiddleCurvePath();
|
||||
}
|
||||
if (y2 < y1)
|
||||
{
|
||||
signy = -1;
|
||||
else if (this._style == "Straight") {
|
||||
this._updateStraightPath();
|
||||
}
|
||||
var path = x1 + ", " + y1 + " " + (middlex - 10 * signx) + ", " + y1 + " " + middlex + ", " + (y1 + 10 * signy) + " " + middlex + ", " + (y2 - 10 * signy) + " " + (middlex + 10 * signx) + ", " + y2 + " " + x2 + ", " + y2;
|
||||
this._native.setAttribute('points', path);
|
||||
}
|
||||
};
|
||||
else {
|
||||
this._updateCurvePath();
|
||||
}
|
||||
},
|
||||
|
||||
web2d.peer.svg.PolyLinePeer.prototype._updateCurvePath = function()
|
||||
{
|
||||
if ($defined(this._x1) && $defined(this._x2) && $defined(this._y1) && $defined(this._y2))
|
||||
{
|
||||
var path = web2d.PolyLine.buildCurvedPath(this.breakDistance, this._x1, this._y1, this._x2, this._y2);
|
||||
this._native.setAttribute('points', path);
|
||||
_updateStraightPath : function() {
|
||||
if ($defined(this._x1) && $defined(this._x2) && $defined(this._y1) && $defined(this._y2)) {
|
||||
var path = web2d.PolyLine.buildStraightPath(this.breakDistance, this._x1, this._y1, this._x2, this._y2);
|
||||
this._native.setAttribute('points', path);
|
||||
}
|
||||
},
|
||||
|
||||
_updateMiddleCurvePath : function() {
|
||||
var x1 = this._x1;
|
||||
var y1 = this._y1;
|
||||
var x2 = this._x2;
|
||||
var y2 = this._y2;
|
||||
if ($defined(x1) && $defined(x2) && $defined(y1) && $defined(y2)) {
|
||||
var diff = x2 - x1;
|
||||
var middlex = (diff / 2) + x1;
|
||||
var signx = 1;
|
||||
var signy = 1;
|
||||
if (diff < 0) {
|
||||
signx = -1;
|
||||
}
|
||||
if (y2 < y1) {
|
||||
signy = -1;
|
||||
}
|
||||
var path = x1 + ", " + y1 + " " + (middlex - 10 * signx) + ", " + y1 + " " + middlex + ", " + (y1 + 10 * signy) + " " + middlex + ", " + (y2 - 10 * signy) + " " + (middlex + 10 * signx) + ", " + y2 + " " + x2 + ", " + y2;
|
||||
this._native.setAttribute('points', path);
|
||||
}
|
||||
},
|
||||
|
||||
_updateCurvePath : function() {
|
||||
if ($defined(this._x1) && $defined(this._x2) && $defined(this._y1) && $defined(this._y2)) {
|
||||
var path = web2d.PolyLine.buildCurvedPath(this.breakDistance, this._x1, this._y1, this._x2, this._y2);
|
||||
this._native.setAttribute('points', path);
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
@@ -1,63 +1,57 @@
|
||||
/*
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* http://www.w3.org/TR/SVG/shapes.html#RectElement
|
||||
*/
|
||||
web2d.peer.svg.RectPeer = function(arc)
|
||||
{
|
||||
var svgElement = window.document.createElementNS(this.svgNamespace, 'rect');
|
||||
web2d.peer.svg.ElementPeer.call(this, svgElement);
|
||||
this._arc = arc;
|
||||
this.attachChangeEventListener("strokeStyle", web2d.peer.svg.ElementPeer.prototype.updateStrokeStyle);
|
||||
};
|
||||
web2d.peer.svg.RectPeer = new Class({
|
||||
Extends: web2d.peer.svg.ElementPeer,
|
||||
initialize : function(arc) {
|
||||
var svgElement = window.document.createElementNS(this.svgNamespace, 'rect');
|
||||
this.parent(svgElement);
|
||||
this._arc = arc;
|
||||
this.attachChangeEventListener("strokeStyle", web2d.peer.svg.ElementPeer.prototype.updateStrokeStyle);
|
||||
},
|
||||
|
||||
objects.extend(web2d.peer.svg.RectPeer, web2d.peer.svg.ElementPeer);
|
||||
setPosition :function(x, y) {
|
||||
if ($defined(x)) {
|
||||
this._native.setAttribute('x', parseInt(x));
|
||||
}
|
||||
if ($defined(y)) {
|
||||
this._native.setAttribute('y', parseInt(y));
|
||||
}
|
||||
},
|
||||
|
||||
web2d.peer.svg.RectPeer.prototype.setPosition = function(x, y)
|
||||
{
|
||||
if ($defined(x))
|
||||
{
|
||||
this._native.setAttribute('x', parseInt(x));
|
||||
getPosition :function() {
|
||||
var x = this._native.getAttribute('x');
|
||||
var y = this._native.getAttribute('y');
|
||||
return {x:parseInt(x),y:parseInt(y)};
|
||||
},
|
||||
|
||||
setSize :function(width, height) {
|
||||
this.parent(width, height);
|
||||
|
||||
var min = width < height ? width : height;
|
||||
if ($defined(this._arc)) {
|
||||
// Transform percentages to SVG format.
|
||||
var arc = (min / 2) * this._arc;
|
||||
this._native.setAttribute('rx', arc);
|
||||
this._native.setAttribute('ry', arc);
|
||||
}
|
||||
}
|
||||
if ($defined(y))
|
||||
{
|
||||
this._native.setAttribute('y', parseInt(y));
|
||||
}
|
||||
};
|
||||
|
||||
web2d.peer.svg.RectPeer.prototype.getPosition = function()
|
||||
{
|
||||
var x = this._native.getAttribute('x');
|
||||
var y = this._native.getAttribute('y');
|
||||
return {x:parseInt(x),y:parseInt(y)};
|
||||
};
|
||||
|
||||
web2d.peer.svg.RectPeer.prototype.setSize = function(width, height)
|
||||
{
|
||||
web2d.peer.svg.RectPeer.superClass.setSize.call(this, width, height);
|
||||
|
||||
var min = width < height?width:height;
|
||||
if ($defined(this._arc))
|
||||
{
|
||||
// Transform percentages to SVG format.
|
||||
var arc = (min / 2) * this._arc;
|
||||
this._native.setAttribute('rx', arc);
|
||||
this._native.setAttribute('ry', arc);
|
||||
}
|
||||
};
|
||||
});
|
@@ -1,35 +1,33 @@
|
||||
/*
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
web2d.peer.svg.TahomaFont = function()
|
||||
{
|
||||
web2d.peer.svg.Font.call(this);
|
||||
this._fontFamily="tahoma";
|
||||
};
|
||||
web2d.peer.svg.TahomaFont = new Class({
|
||||
Extends: web2d.peer.svg.Font,
|
||||
initialize : function() {
|
||||
this.parent();
|
||||
this._fontFamily = "tahoma";
|
||||
},
|
||||
|
||||
objects.extend(web2d.peer.svg.TahomaFont, web2d.peer.svg.Font);
|
||||
getFontFamily : function () {
|
||||
return this._fontFamily;
|
||||
},
|
||||
|
||||
web2d.peer.svg.TahomaFont.prototype.getFontFamily=function ()
|
||||
{
|
||||
return this._fontFamily;
|
||||
};
|
||||
|
||||
web2d.peer.svg.TahomaFont.prototype.getFont=function ()
|
||||
{
|
||||
return web2d.Font.TAHOMA;
|
||||
};
|
||||
getFont : function () {
|
||||
return web2d.Font.TAHOMA;
|
||||
}
|
||||
});
|
@@ -16,147 +16,139 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
web2d.peer.svg.TextPeer = function() {
|
||||
var svgElement = window.document.createElementNS(this.svgNamespace, 'text');
|
||||
web2d.peer.svg.ElementPeer.call(this, svgElement);
|
||||
this._position = {x:0,y:0};
|
||||
this._font = new web2d.Font("Arial", this);
|
||||
};
|
||||
web2d.peer.svg.TextPeer = new Class({
|
||||
Extends: web2d.peer.svg.ElementPeer,
|
||||
initialize : function() {
|
||||
var svgElement = window.document.createElementNS(this.svgNamespace, 'text');
|
||||
this.parent(svgElement);
|
||||
this._position = {x:0,y:0};
|
||||
this._font = new web2d.Font("Arial", this);
|
||||
},
|
||||
|
||||
objects.extend(web2d.peer.svg.TextPeer, web2d.peer.svg.ElementPeer);
|
||||
appendChild : function(element) {
|
||||
this._native.appendChild(element._native);
|
||||
},
|
||||
|
||||
//todo: use ths method to specify the maximum size of the text box
|
||||
/*web2d.web2d.peer.svg.TextPeer.prototype.setSize = function(width, height)
|
||||
{
|
||||
web2d.web2d.peer.svg.TextPeer.superClass.setSize.call(this,width,height);
|
||||
this._native.setAttribute('rx', width / 2);
|
||||
this._native.setAttribute('ry', height /ose 2);
|
||||
};
|
||||
*/
|
||||
setText : function(text) {
|
||||
text = core.Utils.escapeInvalidTags(text);
|
||||
var child = this._native.firstChild;
|
||||
if ($defined(child)) {
|
||||
this._native.removeChild(child);
|
||||
}
|
||||
this._text = text;
|
||||
var textNode = window.document.createTextNode(text);
|
||||
this._native.appendChild(textNode);
|
||||
},
|
||||
|
||||
web2d.peer.svg.TextPeer.prototype.appendChild = function(element) {
|
||||
this._native.appendChild(element._native);
|
||||
};
|
||||
getText : function() {
|
||||
return this._text;
|
||||
},
|
||||
|
||||
web2d.peer.svg.TextPeer.prototype.setText = function(text) {
|
||||
text = core.Utils.escapeInvalidTags(text);
|
||||
var child = this._native.firstChild;
|
||||
if ($defined(child)) {
|
||||
this._native.removeChild(child);
|
||||
}
|
||||
this._text = text;
|
||||
var textNode = window.document.createTextNode(text);
|
||||
this._native.appendChild(textNode);
|
||||
};
|
||||
setPosition : function(x, y) {
|
||||
this._position = {x:x, y:y};
|
||||
var height = this._font.getSize();
|
||||
if ($defined(this._parent) && $defined(this._native.getBBox))
|
||||
height = this.getHeight();
|
||||
var size = parseInt(height);
|
||||
this._native.setAttribute('y', y + size * 3 / 4);
|
||||
//y+size/2
|
||||
this._native.setAttribute('x', x);
|
||||
},
|
||||
|
||||
web2d.peer.svg.TextPeer.prototype.getText = function() {
|
||||
return this._text;
|
||||
};
|
||||
getPosition : function() {
|
||||
return this._position;
|
||||
},
|
||||
|
||||
web2d.peer.svg.TextPeer.prototype.setPosition = function(x, y) {
|
||||
this._position = {x:x, y:y};
|
||||
var height = this._font.getSize();
|
||||
if ($defined(this._parent) && $defined(this._native.getBBox))
|
||||
height = this.getHeight();
|
||||
var size = parseInt(height);
|
||||
this._native.setAttribute('y', y + size * 3 / 4);
|
||||
//y+size/2
|
||||
this._native.setAttribute('x', x);
|
||||
};
|
||||
setFont : function(font, size, style, weight) {
|
||||
if ($defined(font)) {
|
||||
this._font = new web2d.Font(font, this);
|
||||
}
|
||||
if ($defined(style)) {
|
||||
this._font.setStyle(style);
|
||||
}
|
||||
if ($defined(weight)) {
|
||||
this._font.setWeight(weight);
|
||||
}
|
||||
if ($defined(size)) {
|
||||
this._font.setSize(size);
|
||||
}
|
||||
this._updateFontStyle();
|
||||
},
|
||||
|
||||
web2d.peer.svg.TextPeer.prototype.getPosition = function() {
|
||||
return this._position;
|
||||
};
|
||||
_updateFontStyle : function() {
|
||||
this._native.setAttribute('font-family', this._font.getFontFamily());
|
||||
this._native.setAttribute('font-size', this._font.getGraphSize());
|
||||
this._native.setAttribute('font-style', this._font.getStyle());
|
||||
this._native.setAttribute('font-weight', this._font.getWeight());
|
||||
|
||||
web2d.peer.svg.TextPeer.prototype.setFont = function(font, size, style, weight) {
|
||||
if ($defined(font)) {
|
||||
this._font = new web2d.Font(font, this);
|
||||
}
|
||||
if ($defined(style)) {
|
||||
this._font.setStyle(style);
|
||||
}
|
||||
if ($defined(weight)) {
|
||||
this._font.setWeight(weight);
|
||||
}
|
||||
if ($defined(size)) {
|
||||
var scale = this._font.getFontScale();
|
||||
this._native.xFontScale = scale.toFixed(1);
|
||||
|
||||
},
|
||||
setColor : function(color) {
|
||||
this._native.setAttribute('fill', color);
|
||||
},
|
||||
|
||||
getColor : function() {
|
||||
return this._native.getAttribute('fill');
|
||||
},
|
||||
|
||||
setTextSize : function (size) {
|
||||
this._font.setSize(size);
|
||||
this._updateFontStyle();
|
||||
},
|
||||
|
||||
setContentSize : function(width, height) {
|
||||
this._native.xTextSize = width.toFixed(1) + "," + height.toFixed(1);
|
||||
},
|
||||
|
||||
setStyle : function (style) {
|
||||
this._font.setStyle(style);
|
||||
this._updateFontStyle();
|
||||
},
|
||||
|
||||
setWeight : function (weight) {
|
||||
this._font.setWeight(weight);
|
||||
this._updateFontStyle();
|
||||
},
|
||||
|
||||
setFontFamily : function (family) {
|
||||
var oldFont = this._font;
|
||||
this._font = new web2d.Font(family, this);
|
||||
this._font.setSize(oldFont.getSize());
|
||||
this._font.setStyle(oldFont.getStyle());
|
||||
this._font.setWeight(oldFont.getWeight());
|
||||
this._updateFontStyle();
|
||||
},
|
||||
|
||||
getFont : function () {
|
||||
return {
|
||||
font:this._font.getFont(),
|
||||
size:parseInt(this._font.getSize()),
|
||||
style:this._font.getStyle(),
|
||||
weight:this._font.getWeight()
|
||||
};
|
||||
},
|
||||
|
||||
setSize : function (size) {
|
||||
this._font.setSize(size);
|
||||
this._updateFontStyle();
|
||||
},
|
||||
|
||||
getWidth : function () {
|
||||
var computedWidth = this._native.getBBox().width;
|
||||
var width = parseInt(computedWidth);
|
||||
width = width + this._font.getWidthMargin();
|
||||
return width;
|
||||
},
|
||||
|
||||
getHeight : function () {
|
||||
var computedHeight = this._native.getBBox().height;
|
||||
return parseInt(computedHeight);
|
||||
},
|
||||
|
||||
getHtmlFontSize : function () {
|
||||
return this._font.getHtmlSize();
|
||||
}
|
||||
this._updateFontStyle();
|
||||
};
|
||||
|
||||
web2d.peer.svg.TextPeer.prototype._updateFontStyle = function() {
|
||||
this._native.setAttribute('font-family', this._font.getFontFamily());
|
||||
this._native.setAttribute('font-size', this._font.getGraphSize());
|
||||
this._native.setAttribute('font-style', this._font.getStyle());
|
||||
this._native.setAttribute('font-weight', this._font.getWeight());
|
||||
|
||||
var scale = this._font.getFontScale();
|
||||
this._native.xFontScale = scale.toFixed(1);
|
||||
|
||||
};
|
||||
web2d.peer.svg.TextPeer.prototype.setColor = function(color) {
|
||||
this._native.setAttribute('fill', color);
|
||||
};
|
||||
|
||||
web2d.peer.svg.TextPeer.prototype.getColor = function() {
|
||||
return this._native.getAttribute('fill');
|
||||
};
|
||||
|
||||
web2d.peer.svg.TextPeer.prototype.setTextSize = function (size) {
|
||||
this._font.setSize(size);
|
||||
this._updateFontStyle();
|
||||
};
|
||||
|
||||
web2d.peer.svg.TextPeer.prototype.setContentSize = function(width, height) {
|
||||
this._native.xTextSize = width.toFixed(1) + "," + height.toFixed(1);
|
||||
};
|
||||
|
||||
web2d.peer.svg.TextPeer.prototype.setStyle = function (style) {
|
||||
this._font.setStyle(style);
|
||||
this._updateFontStyle();
|
||||
};
|
||||
|
||||
web2d.peer.svg.TextPeer.prototype.setWeight = function (weight) {
|
||||
this._font.setWeight(weight);
|
||||
this._updateFontStyle();
|
||||
};
|
||||
|
||||
web2d.peer.svg.TextPeer.prototype.setFontFamily = function (family) {
|
||||
var oldFont = this._font;
|
||||
this._font = new web2d.Font(family, this);
|
||||
this._font.setSize(oldFont.getSize());
|
||||
this._font.setStyle(oldFont.getStyle());
|
||||
this._font.setWeight(oldFont.getWeight());
|
||||
this._updateFontStyle();
|
||||
};
|
||||
|
||||
web2d.peer.svg.TextPeer.prototype.getFont = function () {
|
||||
return {
|
||||
font:this._font.getFont(),
|
||||
size:parseInt(this._font.getSize()),
|
||||
style:this._font.getStyle(),
|
||||
weight:this._font.getWeight()
|
||||
};
|
||||
};
|
||||
|
||||
web2d.peer.svg.TextPeer.prototype.setSize = function (size) {
|
||||
this._font.setSize(size);
|
||||
this._updateFontStyle();
|
||||
};
|
||||
|
||||
web2d.peer.svg.TextPeer.prototype.getWidth = function () {
|
||||
var computedWidth = this._native.getBBox().width;
|
||||
var width = parseInt(computedWidth);
|
||||
width = width + this._font.getWidthMargin();
|
||||
return width;
|
||||
};
|
||||
|
||||
web2d.peer.svg.TextPeer.prototype.getHeight = function () {
|
||||
var computedHeight = this._native.getBBox().height;
|
||||
return parseInt(computedHeight);
|
||||
};
|
||||
|
||||
web2d.peer.svg.TextPeer.prototype.getHtmlFontSize = function () {
|
||||
return this._font.getHtmlSize();
|
||||
};
|
||||
});
|
||||
|
||||
|
@@ -1,35 +1,33 @@
|
||||
/*
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
web2d.peer.svg.TimesFont = function()
|
||||
{
|
||||
web2d.peer.svg.Font.call(this);
|
||||
this._fontFamily="times";
|
||||
};
|
||||
web2d.peer.svg.TimesFont = new Class({
|
||||
Extends: web2d.peer.svg.Font,
|
||||
initialize : function() {
|
||||
this.parent();
|
||||
this._fontFamily = "times";
|
||||
},
|
||||
|
||||
objects.extend(web2d.peer.svg.TimesFont, web2d.peer.svg.Font);
|
||||
getFontFamily :function () {
|
||||
return this._fontFamily;
|
||||
},
|
||||
|
||||
web2d.peer.svg.TimesFont.prototype.getFontFamily=function ()
|
||||
{
|
||||
return this._fontFamily;
|
||||
};
|
||||
|
||||
web2d.peer.svg.TimesFont.prototype.getFont=function ()
|
||||
{
|
||||
return web2d.Font.TIMES;
|
||||
};
|
||||
getFont : function () {
|
||||
return web2d.Font.TIMES;
|
||||
}
|
||||
});
|
@@ -1,35 +1,33 @@
|
||||
/*
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
web2d.peer.svg.VerdanaFont = function()
|
||||
{
|
||||
web2d.peer.svg.Font.call(this);
|
||||
this._fontFamily="verdana";
|
||||
};
|
||||
web2d.peer.svg.VerdanaFont = new Class({
|
||||
Extends: web2d.peer.svg.Font,
|
||||
initialize : function() {
|
||||
this.parent();
|
||||
this._fontFamily = "verdana";
|
||||
},
|
||||
|
||||
objects.extend(web2d.peer.svg.VerdanaFont, web2d.peer.svg.Font);
|
||||
getFontFamily : function () {
|
||||
return this._fontFamily;
|
||||
},
|
||||
|
||||
web2d.peer.svg.VerdanaFont.prototype.getFontFamily=function ()
|
||||
{
|
||||
return this._fontFamily;
|
||||
};
|
||||
|
||||
web2d.peer.svg.VerdanaFont.prototype.getFont=function ()
|
||||
{
|
||||
return web2d.Font.VERDANA;
|
||||
};
|
||||
getFont : function () {
|
||||
return web2d.Font.VERDANA;
|
||||
}
|
||||
});
|
@@ -1,123 +1,108 @@
|
||||
/*
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
web2d.peer.svg.WorkspacePeer = function(element)
|
||||
{
|
||||
this._element = element;
|
||||
var svgElement = window.document.createElementNS(this.svgNamespace, 'svg');
|
||||
web2d.peer.svg.ElementPeer.call(this, svgElement);
|
||||
this._native.setAttribute("focusable", "true");
|
||||
this._native.setAttribute("id", "workspace");
|
||||
this._native.setAttribute("preserveAspectRatio", "true");
|
||||
|
||||
};
|
||||
|
||||
objects.extend(web2d.peer.svg.WorkspacePeer, web2d.peer.svg.ElementPeer);
|
||||
|
||||
|
||||
/**
|
||||
* http://www.w3.org/TR/SVG/coords.html 7.7 The viewBox attribute
|
||||
* It is often desirable to specify that a given set of graphics stretch to fit a particular container element. The viewBox attribute provides this capability.
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* All elements that establish a new viewport (see elements that establish viewports), plus the 'marker', 'pattern' and 'view' elements have attribute viewBox. The value of the viewBox attribute is a list of four numbers <min-x>, <min-y>, <width> and <height>, separated by whitespace and/or a comma, which specify a rectangle in user space which should be mapped to the bounds of the viewport established by the given element, taking into account attribute preserveAspectRatio. If specified, an additional transformation is applied to all descendants of the given element to achieve the specified effect.
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* A negative value for <width> or <height> is an error (see Error processing). A value of zero disables rendering of the element.
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
web2d.peer.svg.WorkspacePeer.prototype.setCoordSize = function(width, height)
|
||||
{
|
||||
var viewBox = this._native.getAttribute('viewBox');
|
||||
var coords = [0,0,0,0];
|
||||
if (viewBox != null)
|
||||
{
|
||||
coords = viewBox.split(/ /);
|
||||
web2d.peer.svg.WorkspacePeer = new Class({
|
||||
Extends: web2d.peer.svg.ElementPeer,
|
||||
initialize : function(element) {
|
||||
this._element = element;
|
||||
var svgElement = window.document.createElementNS(this.svgNamespace, 'svg');
|
||||
this.parent(svgElement);
|
||||
this._native.setAttribute("focusable", "true");
|
||||
this._native.setAttribute("id", "workspace");
|
||||
this._native.setAttribute("preserveAspectRatio", "true");
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* http://www.w3.org/TR/SVG/coords.html 7.7 The viewBox attribute
|
||||
* It is often desirable to specify that a given set of graphics stretch to fit a particular container element. The viewBox attribute provides this capability.
|
||||
*
|
||||
* All elements that establish a new viewport (see elements that establish viewports), plus the 'marker', 'pattern' and 'view' elements have attribute viewBox. The value of the viewBox attribute is a list of four numbers <min-x>, <min-y>, <width> and <height>, separated by whitespace and/or a comma, which specify a rectangle in user space which should be mapped to the bounds of the viewport established by the given element, taking into account attribute preserveAspectRatio. If specified, an additional transformation is applied to all descendants of the given element to achieve the specified effect.
|
||||
*
|
||||
* A negative value for <width> or <height> is an error (see Error processing). A value of zero disables rendering of the element.
|
||||
*
|
||||
*/
|
||||
|
||||
setCoordSize : function (width, height) {
|
||||
var viewBox = this._native.getAttribute('viewBox');
|
||||
var coords = [0,0,0,0];
|
||||
if (viewBox != null) {
|
||||
coords = viewBox.split(/ /);
|
||||
}
|
||||
if ($defined(width)) {
|
||||
coords[2] = width;
|
||||
}
|
||||
|
||||
if ($defined(height)) {
|
||||
coords[3] = height;
|
||||
}
|
||||
|
||||
this._native.setAttribute('viewBox', coords.join(" "));
|
||||
this._native.setAttribute("preserveAspectRatio", "none");
|
||||
web2d.peer.utils.EventUtils.broadcastChangeEvent(this, "strokeStyle");
|
||||
},
|
||||
|
||||
getCoordSize : function () {
|
||||
var viewBox = this._native.getAttribute('viewBox');
|
||||
var coords = [1,1,1,1];
|
||||
if (viewBox != null) {
|
||||
coords = viewBox.split(/ /);
|
||||
}
|
||||
return {width:coords[2],height:coords[3]};
|
||||
},
|
||||
|
||||
setCoordOrigin : function (x, y) {
|
||||
var viewBox = this._native.getAttribute('viewBox');
|
||||
|
||||
// ViewBox min-x ,min-y by default initializated with 0 and 0.
|
||||
var coords = [0,0,0,0];
|
||||
if (viewBox != null) {
|
||||
coords = viewBox.split(/ /);
|
||||
}
|
||||
|
||||
if ($defined(x)) {
|
||||
coords[0] = x;
|
||||
}
|
||||
|
||||
if ($defined(y)) {
|
||||
coords[1] = y;
|
||||
}
|
||||
|
||||
this._native.setAttribute('viewBox', coords.join(" "));
|
||||
},
|
||||
|
||||
appendChild : function (child) {
|
||||
this.parent(child);
|
||||
web2d.peer.utils.EventUtils.broadcastChangeEvent(child, "onChangeCoordSize");
|
||||
},
|
||||
|
||||
getCoordOrigin : function (child) {
|
||||
var viewBox = this._native.getAttribute('viewBox');
|
||||
var coords = [1,1,1,1];
|
||||
if (viewBox != null) {
|
||||
coords = viewBox.split(/ /);
|
||||
}
|
||||
var x = parseFloat(coords[0]);
|
||||
var y = parseFloat(coords[1]);
|
||||
return {x:x,y:y};
|
||||
},
|
||||
|
||||
getPosition : function () {
|
||||
return {x:0,y:0};
|
||||
}
|
||||
if ($defined(width))
|
||||
{
|
||||
coords[2] = width;
|
||||
}
|
||||
|
||||
if ($defined(height))
|
||||
{
|
||||
coords[3] = height;
|
||||
}
|
||||
|
||||
this._native.setAttribute('viewBox', coords.join(" "));
|
||||
this._native.setAttribute("preserveAspectRatio", "none");
|
||||
web2d.peer.utils.EventUtils.broadcastChangeEvent(this, "strokeStyle");
|
||||
};
|
||||
|
||||
web2d.peer.svg.WorkspacePeer.prototype.getCoordSize = function()
|
||||
{
|
||||
var viewBox = this._native.getAttribute('viewBox');
|
||||
var coords = [1,1,1,1];
|
||||
if (viewBox != null)
|
||||
{
|
||||
coords = viewBox.split(/ /);
|
||||
}
|
||||
return {width:coords[2],height:coords[3]};
|
||||
};
|
||||
|
||||
web2d.peer.svg.WorkspacePeer.prototype.setCoordOrigin = function(x, y)
|
||||
{
|
||||
var viewBox = this._native.getAttribute('viewBox');
|
||||
|
||||
// ViewBox min-x ,min-y by default initializated with 0 and 0.
|
||||
var coords = [0,0,0,0];
|
||||
if (viewBox != null)
|
||||
{
|
||||
coords = viewBox.split(/ /);
|
||||
}
|
||||
|
||||
if ($defined(x))
|
||||
{
|
||||
coords[0] = x;
|
||||
}
|
||||
|
||||
if ($defined(y))
|
||||
{
|
||||
coords[1] = y;
|
||||
}
|
||||
|
||||
this._native.setAttribute('viewBox', coords.join(" "));
|
||||
};
|
||||
|
||||
web2d.peer.svg.WorkspacePeer.prototype.appendChild = function(child)
|
||||
{
|
||||
web2d.peer.svg.WorkspacePeer.superClass.appendChild.call(this, child);
|
||||
web2d.peer.utils.EventUtils.broadcastChangeEvent(child, "onChangeCoordSize");
|
||||
};
|
||||
|
||||
web2d.peer.svg.WorkspacePeer.prototype.getCoordOrigin = function(child)
|
||||
{
|
||||
var viewBox = this._native.getAttribute('viewBox');
|
||||
var coords = [1,1,1,1];
|
||||
if (viewBox != null)
|
||||
{
|
||||
coords = viewBox.split(/ /);
|
||||
}
|
||||
var x = parseFloat(coords[0]);
|
||||
var y = parseFloat(coords[1]);
|
||||
return {x:x,y:y};
|
||||
};
|
||||
|
||||
web2d.peer.svg.WorkspacePeer.prototype.getPosition = function()
|
||||
{
|
||||
return {x:0,y:0};
|
||||
};
|
||||
});
|
@@ -31,9 +31,9 @@ web2d.peer.utils.EventUtils =
|
||||
}
|
||||
|
||||
var children = elementPeer.getChildren();
|
||||
for (var i = 0; i < children.length; i++)
|
||||
for (var j = 0; j < children.length; j++)
|
||||
{
|
||||
var child = children[i];
|
||||
var child = children[j];
|
||||
web2d.peer.utils.EventUtils.broadcastChangeEvent(child, type);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user