Refactor Web2D to use mootool classes.

This commit is contained in:
Paulo Veiga 2011-08-30 14:21:55 -03:00
parent 7f02ed5cf4
commit e437e0e329
30 changed files with 2344 additions and 2599 deletions

View File

@ -30,29 +30,25 @@ mindplot.ShirinkConnector = new Class({
var topicId = topic.getId();
var actionDispatcher = mindplot.ActionDispatcher.getInstance();
actionDispatcher.shrinkBranch([topicId],collapse);
actionDispatcher.shrinkBranch([topicId], collapse);
var e = new Event(event).stop();
e.preventDefault();
event.stopPropagation();
});
elipse.addEvent('mousedown', function(event) {
// Avoid node creation ...
var e = new Event(event).stop();
e.preventDefault();
event.stopPropagation();
});
elipse.addEvent('dblclick', function(event) {
// Avoid node creation ...
event = new Event(event).stop();
event.preventDefault();
event.stopPropagation();
});
elipse.addEvent('mouseover', function(event) {
this.setFill('rgb(153, 0, 255)');
elipse.setFill('rgb(153, 0, 255)');
});
elipse.addEvent('mouseout', function(event) {

View File

@ -1,64 +1,54 @@
/*
* 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.Arrow = function(attributes)
{
web2d.Arrow = new Class({
Extends: web2d.Element,
initialize : function(attributes) {
var peer = web2d.peer.Toolkit.createArrow();
var defaultAttributes = {strokeColor:'black',strokeWidth:1,strokeStyle:'solid',strokeOpacity:1};
for (var key in attributes)
{
for (var key in attributes) {
defaultAttributes[key] = attributes[key];
}
web2d.Element.call(this, peer, defaultAttributes);
};
objects.extend(web2d.Arrow, web2d.Element);
this.parent(peer, defaultAttributes);
},
web2d.Arrow.prototype.getType = function()
{
getType : function() {
return "Arrow";
};
},
web2d.Arrow.prototype.setFrom = function(x,y)
{
this._peer.setFrom(x,y);
};
setFrom : function(x, y) {
this._peer.setFrom(x, y);
},
web2d.Arrow.prototype.setControlPoint = function (point)
{
setControlPoint : function (point) {
this._peer.setControlPoint(point);
};
},
web2d.Arrow.prototype.setStrokeColor = function (color)
{
setStrokeColor : function (color) {
this._peer.setStrokeColor(color);
};
},
web2d.Arrow.prototype.setStrokeWidth = function(width)
{
setStrokeWidth : function(width) {
this._peer.setStrokeWidth(width);
};
},
web2d.Arrow.prototype.setDashed = function(isDashed, length, spacing){
setDashed : function(isDashed, length, spacing) {
this._peer.setDashed(isDashed, length, spacing);
};
web2d.Arrow.prototype.reDraw = function()
{
this._peer._redraw();
};
}
});

View File

@ -1,118 +1,113 @@
/*
* 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.CurvedLine = function(attributes)
{
web2d.CurvedLine = new Class({
Extends: web2d.Element,
initialize: function(attributes) {
var peer = web2d.peer.Toolkit.createCurvedLine();
var defaultAttributes = {strokeColor:'blue',strokeWidth:1,strokeStyle:'solid',strokeOpacity:1};
for (var key in attributes)
{
for (var key in attributes) {
defaultAttributes[key] = attributes[key];
}
web2d.Element.call(this, peer, defaultAttributes);
};
objects.extend(web2d.CurvedLine, web2d.Element);
this.parent(peer, defaultAttributes);
},
web2d.CurvedLine.prototype.getType = function()
{
getType : function() {
return "CurvedLine";
};
},
web2d.CurvedLine.prototype.setFrom = function(x, y)
{
setFrom : function(x, y) {
this._peer.setFrom(x, y);
};
},
web2d.CurvedLine.prototype.setTo = function(x, y)
{
setTo : function(x, y) {
this._peer.setTo(x, y);
};
},
web2d.CurvedLine.prototype.getFrom = function()
{
getFrom : function() {
return this._peer.getFrom();
};
},
web2d.CurvedLine.prototype.getTo = function()
{
getTo : function() {
return this._peer.getTo();
};
},
web2d.CurvedLine.prototype.setShowEndArrow = function(visible){
setShowEndArrow : function(visible) {
this._peer.setShowEndArrow(visible);
};
},
web2d.CurvedLine.prototype.isShowEndArrow = function(){
isShowEndArrow : function() {
return this._peer.isShowEndArrow();
};
},
web2d.CurvedLine.prototype.setShowStartArrow = function(visible){
setShowStartArrow : function(visible) {
this._peer.setShowStartArrow(visible);
};
},
web2d.CurvedLine.prototype.isShowStartArrow = function(){
isShowStartArrow : function() {
return this._peer.isShowStartArrow();
};
},
web2d.CurvedLine.prototype.setSrcControlPoint = function(control){
setSrcControlPoint : function(control) {
this._peer.setSrcControlPoint(control);
};
},
web2d.CurvedLine.prototype.setDestControlPoint = function(control){
setDestControlPoint : function(control) {
this._peer.setDestControlPoint(control);
};
},
web2d.CurvedLine.prototype.getControlPoints = function(){
getControlPoints : function() {
return this._peer.getControlPoints();
};
},
web2d.CurvedLine.prototype.isSrcControlPointCustom = function(){
isSrcControlPointCustom : function() {
return this._peer.isSrcControlPointCustom();
};
},
web2d.CurvedLine.prototype.isDestControlPointCustom = function(){
isDestControlPointCustom : function() {
return this._peer.isDestControlPointCustom();
};
},
web2d.CurvedLine.prototype.setIsSrcControlPointCustom = function(isCustom){
setIsSrcControlPointCustom : function(isCustom) {
this._peer.setIsSrcControlPointCustom(isCustom);
};
},
web2d.CurvedLine.prototype.setIsDestControlPointCustom = function(isCustom){
setIsDestControlPointCustom : function(isCustom) {
this._peer.setIsDestControlPointCustom(isCustom);
};
},
web2d.CurvedLine.prototype.updateLine= function(avoidControlPointFix){
updateLine : function(avoidControlPointFix) {
return this._peer.updateLine(avoidControlPointFix);
};
},
web2d.CurvedLine.prototype.setStyle = function(style){
setStyle : function(style) {
this._peer.setLineStyle(style);
};
},
web2d.CurvedLine.prototype.getStyle = function(){
getStyle : function() {
return this._peer.getLineStyle();
};
},
web2d.CurvedLine.prototype.setDashed = function(length,spacing){
setDashed : function(length, spacing) {
this._peer.setDashed(length, spacing);
};
}
});
web2d.CurvedLine.SIMPLE_LINE = false;
web2d.CurvedLine.NICE_LINE = true;

View File

@ -16,7 +16,8 @@
* limitations under the License.
*/
web2d.Element = function(peer, attributes) {
web2d.Element = new Class({
initialize : function(peer, attributes) {
this._peer = peer;
if (peer == null) {
throw "Element peer can not be null";
@ -26,11 +27,9 @@ web2d.Element = function(peer, attributes) {
if ($defined(attributes)) {
this._initialize(attributes);
}
};
},
web2d.Element.prototype._SIGNATURE_MULTIPLE_ARGUMENTS = -1;
web2d.Element.prototype._initialize = function(attributes) {
_initialize : function(attributes) {
var batchExecute = {};
// Collect arguments ...
@ -41,9 +40,9 @@ web2d.Element.prototype._initialize = function(attributes) {
funcArgs = [];
}
var signature = this._propertyNameToSignature[key];
var signature = web2d.Element._propertyNameToSignature[key];
var argPositions = signature[1];
if (argPositions != this._SIGNATURE_MULTIPLE_ARGUMENTS) {
if (argPositions != web2d.Element._SIGNATURE_MULTIPLE_ARGUMENTS) {
funcArgs[argPositions] = attributes[key];
} else {
funcArgs = attributes[key].split(' ');
@ -59,24 +58,23 @@ web2d.Element.prototype._initialize = function(attributes) {
}
func.apply(this, batchExecute[key]);
}
};
},
web2d.Element.prototype.setSize = function(width, height) {
setSize : function(width, height) {
this._peer.setSize(width, height);
};
},
web2d.Element.prototype.setPosition = function(cx, cy) {
setPosition : function(cx, cy) {
this._peer.setPosition(cx, cy);
};
},
web2d.Element.prototype._supportedEvents = ["click","dblclick","mousemove","mouseout","mouseover","mousedown","mouseup"];
web2d.Element.prototype.positionRelativeTo = function(elem, options) {
positionRelativeTo : function(elem, options) {
this._peer.positionRelativeTo(elem, options);
};
},
/**
/**
* Allows the registration of event listeners on the event target.
* type
* A string representing the event type to listen for.
@ -86,10 +84,10 @@ web2d.Element.prototype.positionRelativeTo = function(elem, options) {
* The following events types are supported:
*
*/
web2d.Element.prototype.addEvent = function(type, listener) {
addEvent : function(type, listener) {
this._peer.addEvent(type, listener);
};
/**
},
/**
*
* Allows the removal of event listeners from the event target.
*
@ -100,53 +98,177 @@ web2d.Element.prototype.addEvent = function(type, listener) {
* The listener parameter takes an interface implemented by the user which contains the methods to be called when the event occurs.
* This interace will be invoked passing an event as argument and the 'this' referece in the function will be the element.
*/
web2d.Element.prototype.removeEvent = function(type, listener) {
removeEvent : function(type, listener) {
this._peer.removeEvent(type, listener);
};
},
/**
/**
* /*
* Returns element type name.
*/
web2d.Element.prototype.getType = function() {
getType : function() {
throw "Not implemeneted yet. This method must be implemented by all the inherited objects.";
};
},
/**
/**
* Todo: Doc
*/
web2d.Element.prototype.getFill = function() {
getFill : function() {
return this._peer.getFill();
};
},
/**
/**
* Used to define the fill element color and element opacity.
* color: Fill color
* opacity: Opacity of the fill. It must be less than 1.
*/
web2d.Element.prototype.setFill = function(color, opacity) {
setFill : function(color, opacity) {
this._peer.setFill(color, opacity);
};
},
web2d.Element.prototype.getPosition = function() {
getPosition : function() {
return this._peer.getPosition();
};
},
/*
/*
* Defines the element stroke properties.
* width: stroke width
* style: "solid|dot|dash|dashdot|longdash".
* color: stroke color
* opacity: stroke visibility
*/
web2d.Element.prototype.setStroke = function(width, style, color, opacity) {
setStroke : function(width, style, color, opacity) {
if (style != null && style != undefined && style != 'dash' && style != 'dot' && style != 'solid' && style != 'longdash' && style != "dashdot") {
throw "Unsupported stroke style: '" + style + "'";
}
this._peer.setStroke(width, style, color, opacity);
};
},
web2d.Element.prototype._propertyNameToSignature =
_attributeNameToFuncName : function(attributeKey, prefix) {
var signature = web2d.Element._propertyNameToSignature[attributeKey];
if (!$defined(signature)) {
throw "Unsupported attribute: " + attributeKey;
}
var firstLetter = signature[0].charAt(0);
return prefix + firstLetter.toUpperCase() + signature[0].substring(1);
},
/**
* All element properties can be setted using either a method invocation or attribute invocation.
* key: size, width, height, position, x, y, stroke, strokeWidth, strokeStyle, strokeColor, strokeOpacity,
* fill, fillColor, fillOpacity, coordSize, coordSizeWidth, coordSizeHeight, coordOrigin, coordOriginX, coordOrigiY
*/
setAttribute : function(key, value) {
var funcName = this._attributeNameToFuncName(key, 'set');
var signature = web2d.Element._propertyNameToSignature[key];
if (signature == null) {
throw "Could not find the signature for:" + key;
}
// Parse arguments ..
var argPositions = signature[1];
var args = [];
if (argPositions !== this._SIGNATURE_MULTIPLE_ARGUMENTS) {
args[argPositions] = value;
}
else if (typeof value == "array") {
args = value;
} else {
var strValue = String(value);
args = strValue.split(' ');
}
// Look up method ...
var setter = this[funcName];
if (setter == null) {
throw "Could not find the function name:" + funcName;
}
setter.apply(this, args);
},
getAttribute : function(key) {
var funcName = this._attributeNameToFuncName(key, 'get');
var signature = web2d.Element._propertyNameToSignature[key];
if (signature == null) {
throw "Could not find the signature for:" + key;
}
var getter = this[funcName];
if (getter == null) {
throw "Could not find the function name:" + funcName;
}
var getterResult = getter.apply(this, []);
var attibuteName = signature[2];
if (!$defined(attibuteName)) {
throw "Could not find attribute mapping for:" + key;
}
var result = getterResult[attibuteName];
if (!$defined(result)) {
throw "Could not find attribute with name:" + attibuteName;
}
return result;
},
/**
* Defines the element opacity.
* Parameters:
* opacity: A value between 0 and 1.
*/
setOpacity : function(opacity) {
this._peer.setStroke(null, null, null, opacity);
this._peer.setFill(null, opacity);
},
setVisibility : function(isVisible) {
this._peer.setVisibility(isVisible);
},
isVisible : function() {
return this._peer.isVisible();
},
/**
* Move the element to the front
*/
moveToFront : function() {
this._peer.moveToFront();
},
/**
* Move the element to the back
*/
moveToBack : function() {
this._peer.moveToBack();
},
getStroke : function() {
return this._peer.getStroke();
},
setCursor : function(type) {
this._peer.setCursor(type);
},
getParent : function() {
return this._peer.getParent();
}
});
web2d.Element._SIGNATURE_MULTIPLE_ARGUMENTS = -1;
web2d.Element._supportedEvents = ["click","dblclick","mousemove","mouseout","mouseover","mousedown","mouseup"];
web2d.Element._propertyNameToSignature =
{
// Format: [attribute name, argument position on setter, attribute name on getter]
size: ['size',-1],
@ -178,123 +300,3 @@ web2d.Element.prototype._propertyNameToSignature =
visibility:['visibility',0],
opacity:['opacity',0]
};
web2d.Element.prototype._attributeNameToFuncName = function(attributeKey, prefix) {
var signature = this._propertyNameToSignature[attributeKey];
if (!$defined(signature)) {
throw "Unsupported attribute: " + attributeKey;
}
var firstLetter = signature[0].charAt(0);
return prefix + firstLetter.toUpperCase() + signature[0].substring(1);
};
/**
* All element properties can be setted using either a method invocation or attribute invocation.
* key: size, width, height, position, x, y, stroke, strokeWidth, strokeStyle, strokeColor, strokeOpacity,
* fill, fillColor, fillOpacity, coordSize, coordSizeWidth, coordSizeHeight, coordOrigin, coordOriginX, coordOrigiY
*/
web2d.Element.prototype.setAttribute = function(key, value) {
var funcName = this._attributeNameToFuncName(key, 'set');
var signature = this._propertyNameToSignature[key];
if (signature == null) {
throw "Could not find the signature for:" + key;
}
// Parse arguments ..
var argPositions = signature[1];
var args = [];
if (argPositions !== this._SIGNATURE_MULTIPLE_ARGUMENTS) {
args[argPositions] = value;
}
else if (typeof value == "array") {
args = value;
} else {
var strValue = String(value);
args = strValue.split(' ');
}
// Look up method ...
var setter = this[funcName];
if (setter == null) {
throw "Could not find the function name:" + funcName;
}
setter.apply(this, args);
};
web2d.Element.prototype.getAttribute = function(key) {
var funcName = this._attributeNameToFuncName(key, 'get');
var signature = this._propertyNameToSignature[key];
if (signature == null) {
throw "Could not find the signature for:" + key;
}
var getter = this[funcName];
if (getter == null) {
throw "Could not find the function name:" + funcName;
}
var getterResult = getter.apply(this, []);
var attibuteName = signature[2];
if (!$defined(attibuteName)) {
throw "Could not find attribute mapping for:" + key;
}
var result = getterResult[attibuteName];
if (!$defined(result)) {
throw "Could not find attribute with name:" + attibuteName;
}
return result;
};
/**
* Defines the element opacity.
* Parameters:
* opacity: A value between 0 and 1.
*/
web2d.Element.prototype.setOpacity = function(opacity) {
this._peer.setStroke(null, null, null, opacity);
this._peer.setFill(null, opacity);
};
web2d.Element.prototype.setVisibility = function(isVisible) {
this._peer.setVisibility(isVisible);
};
web2d.Element.prototype.isVisible = function() {
return this._peer.isVisible();
};
/**
* Move the element to the front
*/
web2d.Element.prototype.moveToFront = function() {
this._peer.moveToFront();
};
/**
* Move the element to the back
*/
web2d.Element.prototype.moveToBack = function() {
this._peer.moveToBack();
};
web2d.Element.prototype.getStroke = function() {
return this._peer.getStroke();
};
web2d.Element.prototype.setCursor = function(type) {
this._peer.setCursor(type);
};
web2d.Element.prototype.getParent = function() {
return this._peer.getParent();
}

View File

@ -1,42 +1,37 @@
/*
* 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.Elipse = function(attributes)
{
web2d.Elipse = new Class({
Extends: web2d.Element,
initialize: function(attributes) {
var peer = web2d.peer.Toolkit.createElipse();
var defaultAttributes = {width:40, height:40, x:5, y:5,stroke:'1 solid black',fillColor:'blue'};
for (var key in attributes)
{
for (var key in attributes) {
defaultAttributes[key] = attributes[key];
}
web2d.Element.call(this, peer, defaultAttributes);
};
objects.extend(web2d.Elipse, web2d.Element);
this.parent(peer, defaultAttributes);
},
web2d.Elipse.prototype.getType = function()
{
getType : function() {
return "Elipse";
};
},
/**
* @Todo: Complete Doc
*/
web2d.Elipse.prototype.getSize = function()
{
getSize : function() {
return this._peer.getSize();
};
}
});

View File

@ -1,89 +1,78 @@
/*
* 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.Font = function(fontFamily, textPeer)
{
web2d.Font = new Class({
initialize :function(fontFamily, textPeer) {
var font = "web2d.peer.Toolkit.create" + fontFamily + "Font();";
this._peer = eval(font);
this._textPeer = textPeer;
};
},
web2d.Font.prototype.getHtmlSize = function ()
{
getHtmlSize : function() {
var scale = web2d.peer.utils.TransformUtil.workoutScale(this._textPeer);
return this._peer.getHtmlSize(scale);
};
},
web2d.Font.prototype.getGraphSize = function ()
{
getGraphSize : function() {
var scale = web2d.peer.utils.TransformUtil.workoutScale(this._textPeer);
return this._peer.getGraphSize(scale);
};
},
web2d.Font.prototype.getFontScale = function ()
{
getFontScale : function() {
return web2d.peer.utils.TransformUtil.workoutScale(this._textPeer).height;
};
},
web2d.Font.prototype.getSize = function ()
{
getSize : function() {
return this._peer.getSize();
};
},
web2d.Font.prototype.getStyle = function ()
{
getStyle : function() {
return this._peer.getStyle();
};
},
web2d.Font.prototype.getWeight = function ()
{
getWeight : function() {
return this._peer.getWeight();
};
},
web2d.Font.prototype.getFontFamily = function ()
{
getFontFamily : function() {
return this._peer.getFontFamily();
};
},
web2d.Font.prototype.setSize = function (size)
{
setSize : function(size) {
return this._peer.setSize(size);
};
},
web2d.Font.prototype.setStyle = function (style)
{
setStyle : function(style) {
return this._peer.setStyle(style);
};
},
web2d.Font.prototype.setWeight = function (weight)
{
setWeight : function(weight) {
return this._peer.setWeight(weight);
};
},
web2d.Font.prototype.getFont = function ()
{
getFont : function() {
return this._peer.getFont();
};
},
web2d.Font.prototype.getWidthMargin = function ()
{
getWidthMargin : function() {
return this._peer.getWidthMargin();
};
}
});
web2d.Font.ARIAL = "Arial";

View File

@ -1,158 +1,127 @@
/*
* 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.
*/
/**
* A group object can be used to collect shapes.
*/
web2d.Group = function(attributes)
{
web2d.Group = new Class({
Extends: web2d.Element,
initialize : function(attributes) {
var peer = web2d.peer.Toolkit.createGroup();
var defaultAttributes = {width:50, height:50, x:50, y:50,coordOrigin:'0 0',coordSize:'50 50'};
for (var key in attributes)
{
for (var key in attributes) {
defaultAttributes[key] = attributes[key];
}
web2d.Element.call(this, peer, defaultAttributes);
};
this.parent(peer, defaultAttributes);
},
objects.extend(web2d.Group, web2d.Element);
/**
/**
* Remove an element as a child to the object.
*/
web2d.Group.prototype.removeChild = function(element)
{
if (!$defined(element))
{
removeChild : function(element) {
if (!$defined(element)) {
throw "Child element can not be null";
}
if (element == this)
{
if (element == this) {
throw "It's not posible to add the group as a child of itself";
}
var elementType = element.getType();
if (elementType == null)
{
if (elementType == null) {
throw "It seems not to be an element ->" + element;
}
this._peer.removeChild(element._peer);
};
},
/**
/**
* Appends an element as a child to the object.
*/
web2d.Group.prototype.appendChild = function(element)
{
if (!$defined(element))
{
appendChild : function(element) {
if (!$defined(element)) {
throw "Child element can not be null";
}
if (element == this)
{
if (element == this) {
throw "It's not posible to add the group as a child of itself";
}
var elementType = element.getType();
if (elementType == null)
{
if (elementType == null) {
throw "It seems not to be an element ->" + element;
}
if (elementType == "Workspace")
{
if (elementType == "Workspace") {
throw "A group can not have a workspace as a child";
}
this._peer.appendChild(element._peer);
};
},
web2d.Group.prototype.getType = function()
{
getType : function() {
return "Group";
};
},
/**
/**
* The group element is a containing blocks for this content - they define a CSS2 "block level box".
* Inside the containing block a local coordinate system is defined for any sub-elements using the coordsize and coordorigin attributes.
* All CSS2 positioning information is expressed in terms of this local coordinate space.
* Consequently CSS2 position attributes (left, top, width, height and so on) have no unit specifier -
* they are simple numbers, not CSS length quantities.
*/
web2d.Group.prototype.setCoordSize = function(width, height)
{
setCoordSize : function(width, height) {
this._peer.setCoordSize(width, height);
};
},
web2d.Group.prototype.getCoordSize = function(){
return this.peer.getCoordSize();
};
/**
* @Todo: Complete Doc
*/
web2d.Group.prototype.setCoordOrigin = function(x, y)
{
setCoordOrigin : function(x, y) {
this._peer.setCoordOrigin(x, y);
};
},
web2d.Group.prototype.getCoordOrigin = function(){
getCoordOrigin : function() {
return this._peer.getCoordOrigin();
};
/**
* @Todo: Complete Doc
*/
web2d.Group.prototype.getSize = function()
{
},
getSize : function() {
return this._peer.getSize();
};
},
web2d.Group.prototype.setFill = function(color, opacity)
{
setFill : function(color, opacity) {
throw "Unsupported operation. Fill can not be set to a group";
};
},
web2d.Group.prototype.setStroke = function(width, style, color, opacity)
{
setStroke : function(width, style, color, opacity) {
throw "Unsupported operation. Stroke can not be set to a group";
};
},
web2d.Group.prototype.getCoordSize = function()
{
getCoordSize : function() {
return this._peer.getCoordSize();
};
},
web2d.Group.prototype.appendDomChild = function(DomElement)
{
if (!$defined(DomElement))
{
appendDomChild : function(DomElement) {
if (!$defined(DomElement)) {
throw "Child element can not be null";
}
if (DomElement == this)
{
throw "It's not posible to add the group as a child of itself";
if (DomElement == this) {
throw "It's not possible to add the group as a child of itself";
}
this._peer._native.appendChild(DomElement);
};
}
});

View File

@ -16,23 +16,26 @@
* limitations under the License.
*/
web2d.Image = function(attributes) {
web2d.Image = new Class({
Extends: web2d.Element,
initialize : function(attributes) {
var peer = web2d.peer.Toolkit.createImage();
web2d.Element.call(this, peer, attributes);
};
objects.extend(web2d.Image, web2d.Element);
this.parent(peer, attributes);
},
web2d.Image.prototype.getType = function() {
getType : function() {
return "Image";
};
},
web2d.Image.prototype.setHref = function(href) {
setHref : function(href) {
this._peer.setHref(href);
};
},
web2d.Image.prototype.getHref = function() {
getHref : function() {
return this._peer.getHref();
};
web2d.Image.prototype.getSize = function() {
},
getSize : function() {
return this._peer.getSize();
};
}
});

View File

@ -1,78 +1,69 @@
/*
* 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.Line = function(attributes)
{
web2d.Line = new Class({
Extends: web2d.Element,
initialize: function(attributes) {
var peer = web2d.peer.Toolkit.createLine();
var defaultAttributes = {strokeColor:'#495879',strokeWidth:1, strokeOpacity:1};
for (var key in attributes)
{
for (var key in attributes) {
defaultAttributes[key] = attributes[key];
}
web2d.Element.call(this, peer, defaultAttributes);
};
objects.extend(web2d.Line, web2d.Element);
this.parent(peer, defaultAttributes);
},
web2d.Line.prototype.getType = function()
{
getType : function() {
return "Line";
};
},
web2d.Line.prototype.setFrom = function(x, y)
{
setFrom : function(x, y) {
this._peer.setFrom(x, y);
};
},
web2d.Line.prototype.setTo = function(x, y)
{
setTo : function(x, y) {
this._peer.setTo(x, y);
};
},
web2d.Line.prototype.getFrom = function()
{
getFrom : function() {
return this._peer.getFrom();
};
},
web2d.Line.prototype.getTo = function()
{
getTo : function() {
return this._peer.getTo();
};
},
/**
/**
* Defines the start and the end line arrow style.
* Can have values "none | block | classic | diamond | oval | open | chevron | doublechevron"
**/
web2d.Line.prototype.setArrowStyle = function(startStyle, endStyle)
{
setArrowStyle : function(startStyle, endStyle) {
this._peer.setArrowStyle(startStyle, endStyle);
};
},
web2d.Line.prototype.setPosition = function(cx, cy)
{
setPosition : function(cx, cy) {
throw "Unsupported operation";
};
},
web2d.Line.prototype.setSize = function(width, height)
{
setSize : function(width, height) {
throw "Unsupported operation";
};
},
web2d.Line.prototype.setFill = function(color, opacity)
{
setFill : function(color, opacity) {
throw "Unsupported operation";
};
}
});

View File

@ -1,88 +1,77 @@
/*
* 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.PolyLine = function(attributes)
{
web2d.PolyLine = new Class({
Extends: web2d.Element,
initialize:function(attributes) {
var peer = web2d.peer.Toolkit.createPolyLine();
var defaultAttributes = {strokeColor:'blue',strokeWidth:1,strokeStyle:'solid',strokeOpacity:1};
for (var key in attributes)
{
for (var key in attributes) {
defaultAttributes[key] = attributes[key];
}
web2d.Element.call(this, peer, defaultAttributes);
};
objects.extend(web2d.PolyLine, web2d.Element);
this.parent(peer, defaultAttributes);
},
web2d.PolyLine.prototype.getType = function()
{
getType : function() {
return "PolyLine";
};
},
web2d.PolyLine.prototype.setFrom = function(x, y)
{
setFrom : function(x, y) {
this._peer.setFrom(x, y);
};
},
web2d.PolyLine.prototype.setTo = function(x, y)
{
setTo : function(x, y) {
this._peer.setTo(x, y);
};
},
web2d.PolyLine.prototype.setStyle = function(style)
{
setStyle : function(style) {
this._peer.setStyle(style);
};
},
web2d.PolyLine.prototype.getStyle = function()
{
getStyle : function() {
return this._peer.getStyle();
};
},
web2d.PolyLine.buildCurvedPath = function(dist, x1, y1, x2, y2)
{
buildCurvedPath : function(dist, x1, y1, x2, y2) {
var signx = 1;
var signy = 1;
if (x2 < x1)
{
if (x2 < x1) {
signx = -1;
}
if (y2 < y1)
{
if (y2 < y1) {
signy = -1;
}
var path;
if (Math.abs(y1 - y2) > 2)
{
if (Math.abs(y1 - y2) > 2) {
var middlex = x1 + ((x2 - x1 > 0) ? dist : -dist);
path = x1.toFixed(1) + ", " + y1.toFixed(1) + " " + middlex.toFixed(1) + ", " + y1.toFixed(1) + " " + middlex.toFixed(1) + ", " + (y2 - 5 * signy).toFixed(1) + " " + (middlex + 5 * signx).toFixed(1) + ", " + y2.toFixed(1) + " " + x2.toFixed(1) + ", " + y2.toFixed(1);
} else
{
} else {
path = x1.toFixed(1) + ", " + y1.toFixed(1) + " " + x2.toFixed(1) + ", " + y2.toFixed(1);
}
return path;
};
},
web2d.PolyLine.buildStraightPath = function(dist, x1, y1, x2, y2)
{
buildStraightPath : function(dist, x1, y1, x2, y2) {
var middlex = x1 + ((x2 - x1 > 0) ? dist : -dist);
return x1 + ", " + y1 + " " + middlex + ", " + y1 + " " + middlex + ", " + y2 + " " + x2 + ", " + y2;
};
}
});

View File

@ -1,20 +1,20 @@
/*
* 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.
*/
/**
* Create a rectangle and variations of a rectangle shape.
@ -22,37 +22,30 @@
* arc = "<length>"
* For rounded rectangles, radius of the ellipse used to round off the corners of the rectangle.
*/
web2d.Rect = function(arc, attributes)
{
if (arc && arc > 1)
{
web2d.Rect = new Class({
Extends: web2d.Element,
initialize : function(arc, attributes) {
if (arc && arc > 1) {
throw "Arc must be 0<=arc<=1";
}
if (arguments.length <= 0)
{
if (arguments.length <= 0) {
var rx = 0;
var ry = 0;
}
var peer = web2d.peer.Toolkit.createRect(arc);
var defaultAttributes = {width:40, height:40, x:5, y:5,stroke:'1 solid black',fillColor:'green'};
for (var key in attributes)
{
for (var key in attributes) {
defaultAttributes[key] = attributes[key];
}
web2d.Element.call(this, peer, defaultAttributes);
};
objects.extend(web2d.Rect, web2d.Element);
this.parent(peer, defaultAttributes);
},
web2d.Rect.prototype.getType = function()
{
getType : function() {
return "Rect";
};
},
/**
* @Todo: Complete Doc
*/
web2d.Rect.prototype.getSize = function()
{
getSize : function() {
return this._peer.getSize();
};
}
});

View File

@ -1,99 +1,85 @@
/*
* 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.Text = function(attributes)
{
web2d.Text = new Class({
Extends:web2d.Element,
initialize:function(attributes) {
var peer = web2d.peer.Toolkit.createText();
web2d.Element.call(this, peer, attributes);
};
objects.extend(web2d.Text, web2d.Element);
this.parent(peer, attributes);
},
web2d.Text.prototype.getType = function()
{
getType : function() {
return "Text";
};
},
web2d.Text.prototype.setText = function(text)
{
setText : function(text) {
this._peer.setText(text);
};
},
web2d.Text.prototype.setTextSize = function(width, height)
{
setTextSize : function(width, height) {
this._peer.setContentSize(width, height);
};
},
web2d.Text.prototype.getText = function()
{
getText : function() {
return this._peer.getText();
};
},
web2d.Text.prototype.setFont = function(font, size, style, weight)
{
setFont : function(font, size, style, weight) {
this._peer.setFont(font, size, style, weight);
};
},
web2d.Text.prototype.setColor = function(color)
{
setColor : function(color) {
this._peer.setColor(color);
};
},
web2d.Text.prototype.getColor = function()
{
getColor : function() {
return this._peer.getColor();
};
},
web2d.Text.prototype.setStyle = function(style)
{
setStyle : function(style) {
this._peer.setStyle(style);
};
},
web2d.Text.prototype.setWeight = function(weight)
{
setWeight : function(weight) {
this._peer.setWeight(weight);
};
},
web2d.Text.prototype.setFontFamily = function(family)
{
setFontFamily : function(family) {
this._peer.setFontFamily(family);
};
},
web2d.Text.prototype.getFont = function()
{
getFont : function() {
return this._peer.getFont();
};
},
web2d.Text.prototype.setSize = function(size)
{
setSize : function(size) {
this._peer.setSize(size);
};
},
web2d.Text.prototype.getHtmlFontSize = function()
{
getHtmlFontSize : function() {
return this._peer.getHtmlFontSize();
};
},
web2d.Text.prototype.getWidth = function()
{
getWidth : function() {
return this._peer.getWidth();
};
},
web2d.Text.prototype.getHeight = function()
{
getHeight : function() {
return parseInt(this._peer.getHeight());
};
}
});

View File

@ -1,83 +1,69 @@
/*
* 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.Workspace = function(attributes)
{
web2d.Workspace = new Class({
Extends:web2d.Element,
initialize:function(attributes) {
this._htmlContainer = this._createDivContainer();
var peer = web2d.peer.Toolkit.createWorkspace(this._htmlContainer);
var defaultAttributes = {width:'200px',height:'200px',stroke:'1px solid #edf1be',
fillColor:"white",coordOrigin:'0 0',coordSize:'200 200' };
for (var key in attributes)
{
for (var key in attributes) {
defaultAttributes[key] = attributes[key];
}
web2d.Element.call(this, peer, defaultAttributes);
this.parent(peer, defaultAttributes);
this._htmlContainer.appendChild(this._peer._native);
};
},
objects.extend(web2d.Workspace, web2d.Element);
web2d.Workspace.prototype.getType = function()
{
getType : function() {
return "Workspace";
};
/**
},
/**
* Appends an element as a child to the object.
*/
web2d.Workspace.prototype.appendChild = function(element)
{
if (!$defined(element))
{
appendChild : function(element) {
if (!$defined(element)) {
throw "Child element can not be null";
}
var elementType = element.getType();
if (elementType == null)
{
if (elementType == null) {
throw "It seems not to be an element ->" + element;
}
if (elementType == "Workspace")
{
if (elementType == "Workspace") {
throw "A workspace can not have a workspace as a child";
}
this._peer.appendChild(element._peer);
};
},
/**
* @todo: Write doc.
*/
web2d.Workspace.prototype.addItAsChildTo = function(element)
{
if (!$defined(element))
{
addItAsChildTo : function(element) {
if (!$defined(element)) {
throw "Workspace div container can not be null";
}
element.appendChild(this._htmlContainer);
};
},
/**
/**
* Create a new div element that will be responsible for containing the workspace elements.
*/
web2d.Workspace.prototype._createDivContainer = function(domElement)
{
_createDivContainer : function(domElement) {
var container = window.document.createElement("div");
container.id = "workspaceContainer";
container.style.overflow = "hidden";
@ -88,9 +74,9 @@ web2d.Workspace.prototype._createDivContainer = function(domElement)
container.style.border = '1px solid red';
return container;
};
},
/**
/**
* Set the workspace area size. It can be defined using different units:
* in (inches; 1in=2.54cm)
* cm (centimeters; 1cm=10mm)
@ -98,132 +84,110 @@ web2d.Workspace.prototype._createDivContainer = function(domElement)
* pt (points; 1pt=1/72in)
* pc (picas; 1pc=12pt)
*/
web2d.Workspace.prototype.setSize = function(width, height)
{
setSize : function(width, height) {
// HTML container must have the size of the group element.
if ($defined(width))
{
if ($defined(width)) {
this._htmlContainer.style.width = width;
}
if ($defined(height))
{
if ($defined(height)) {
this._htmlContainer.style.height = height;
}
this._peer.setSize(width, height);
};
},
/**
/**
* The workspace element is a containing blocks for this content - they define a CSS2 "block level box".
* Inside the containing block a local coordinate system is defined for any sub-elements using the coordsize and coordorigin attributes.
* All CSS2 positioning information is expressed in terms of this local coordinate space.
* Consequently CSS2 position attributes (left, top, width, height and so on) have no unit specifier -
* they are simple numbers, not CSS length quantities.
*/
web2d.Workspace.prototype.setCoordSize = function(width, height)
{
setCoordSize : function(width, height) {
this._peer.setCoordSize(width, height);
};
},
/**
/**
* @Todo: Complete Doc
*/
web2d.Workspace.prototype.setCoordOrigin = function(x, y)
{
setCoordOrigin : function(x, y) {
this._peer.setCoordOrigin(x, y);
};
},
/**
/**
* @Todo: Complete Doc
*/
web2d.Workspace.prototype.getCoordOrigin = function()
{
getCoordOrigin : function() {
return this._peer.getCoordOrigin();
};
},
// Private method declaration area
/**
/**
* All the SVG elements will be children of this HTML element.
*/
web2d.Workspace.prototype._getHtmlContainer = function()
{
_getHtmlContainer : function() {
return this._htmlContainer;
};
},
web2d.Workspace.prototype.setFill = function(color, opacity)
{
setFill : function(color, opacity) {
this._htmlContainer.style.backgroundColor = color;
if (opacity || opacity === 0)
{
if (opacity || opacity === 0) {
throw "Unsupported operation. Opacity not supported.";
}
};
},
web2d.Workspace.prototype.getFill = function()
{
getFill : function() {
var color = this._htmlContainer.style.backgroundColor;
return {color:color};
};
},
/**
* @Todo: Complete Doc
*/
web2d.Workspace.prototype.getSize = function()
{
getSize : function() {
var width = this._htmlContainer.style.width;
var height = this._htmlContainer.style.height;
return {width:width,height:height};
};
},
web2d.Workspace.prototype.setStroke = function(width, style, color, opacity)
{
if (style != 'solid')
{
setStroke : function(width, style, color, opacity) {
if (style != 'solid') {
throw 'Not supported style stroke style:' + style;
}
this._htmlContainer.style.border = width + ' ' + style + ' ' + color;
if (opacity || opacity === 0)
{
if (opacity || opacity === 0) {
throw "Unsupported operation. Opacity not supported.";
}
};
},
web2d.Workspace.prototype.getCoordSize = function()
{
getCoordSize : function() {
return this._peer.getCoordSize();
};
},
/**
/**
* Remove an element as a child to the object.
*/
web2d.Workspace.prototype.removeChild = function(element)
{
if (!$defined(element))
{
removeChild : function(element) {
if (!$defined(element)) {
throw "Child element can not be null";
}
if (element == this)
{
if (element == this) {
throw "It's not posible to add the group as a child of itself";
}
var elementType = element.getType();
if (elementType == null)
{
if (elementType == null) {
throw "It seems not to be an element ->" + element;
}
this._peer.removeChild(element._peer);
};
},
web2d.Workspace.prototype.dumpNativeChart = function()
{
dumpNativeChart : function() {
var elem = this._htmlContainer
return elem.innerHTML;
};
}
});

View File

@ -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);
web2d.peer.svg.ArialFont.prototype.getFontFamily=function ()
{
getFontFamily : function () {
return this._fontFamily;
};
},
web2d.peer.svg.ArialFont.prototype.getFont=function ()
{
getFont : function () {
return web2d.Font.ARIAL;
};
}
});

View File

@ -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()
{
web2d.peer.svg.ArrowPeer = new Class({
Extends: web2d.peer.svg.ElementPeer,
initialize : function() {
var svgElement = window.document.createElementNS(this.svgNamespace, 'path');
web2d.peer.svg.ElementPeer.call(this, svgElement);
this._style={};
this._controlPoint=new core.Point();
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);
web2d.peer.svg.ArrowPeer.prototype.setFrom = function(x,y)
{
setFrom : function(x, y) {
this._fromPoint.x = x;
this._fromPoint.y = y;
this._redraw();
};
},
web2d.peer.svg.ArrowPeer.prototype.setControlPoint = function (point)
{
setControlPoint : function (point) {
this._controlPoint = point;
this._redraw();
};
},
web2d.peer.svg.ArrowPeer.prototype.setStrokeColor = function (color)
{
this.setStroke(null,null,color, null);
};
setStrokeColor : function (color) {
this.setStroke(null, null, color, null);
},
web2d.peer.svg.ArrowPeer.prototype.setStrokeWidth = function(width)
{
setStrokeWidth : function(width) {
this.setStroke(width);
};
},
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);
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","");
this._native.setAttribute("stroke-dasharray", "");
}
};
},
web2d.peer.svg.ArrowPeer.prototype._updateStyle = function()
{
_updateStyle : function() {
var style = "";
for(var key in this._style){
style+=key+":"+this._style[key]+" ";
for (var key in this._style) {
style += key + ":" + this._style[key] + " ";
}
this._native.setAttribute("style",style);
};
this._native.setAttribute("style", style);
},
web2d.peer.svg.ArrowPeer.prototype._redraw = function()
{
_redraw : function() {
var x,y, xp, yp;
if(this._controlPoint.y == 0)
this._controlPoint.y=1;
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);
}
});

View File

@ -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()
{
web2d.peer.svg.CurvedLinePeer = new Class({
Extends: web2d.peer.svg.ElementPeer,
initialize :function() {
var svgElement = window.document.createElementNS(this.svgNamespace, 'path');
web2d.peer.svg.ElementPeer.call(this, svgElement);
this._style={fill:'#495879'};
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;
};
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){
setSrcControlPoint : function(control) {
this._customControlPoint_1 = true;
var change = this._control1.x!=control.x || this._control1.y!=control.y;
if($defined(control.x)){
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)
if (change)
this._updatePath();
};
},
web2d.peer.svg.CurvedLinePeer.prototype.setDestControlPoint = function(control){
setDestControlPoint : function(control) {
this._customControlPoint_2 = true;
var change = this._control2.x!=control.x || this._control2.y!=control.y;
if($defined(control.x)){
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)
if (change)
this._updatePath();
};
},
web2d.peer.svg.CurvedLinePeer.prototype.isSrcControlPointCustom = function() {
isSrcControlPointCustom : function() {
return this._customControlPoint_1;
};
},
web2d.peer.svg.CurvedLinePeer.prototype.isDestControlPointCustom = function() {
isDestControlPointCustom : function() {
return this._customControlPoint_2;
};
},
web2d.peer.svg.CurvedLinePeer.prototype.setIsSrcControlPointCustom = function(isCustom) {
setIsSrcControlPointCustom : function(isCustom) {
this._customControlPoint_1 = isCustom;
};
},
web2d.peer.svg.CurvedLinePeer.prototype.setIsDestControlPointCustom = function(isCustom) {
setIsDestControlPointCustom : function(isCustom) {
this._customControlPoint_2 = isCustom;
};
},
web2d.peer.svg.CurvedLinePeer.prototype.getControlPoints = function(){
getControlPoints : function() {
return [this._control1, this._control2];
};
},
web2d.peer.svg.CurvedLinePeer.prototype.setFrom = function(x1, y1)
{
var change = this._x1!=parseInt(x1) || this._y1!=parseInt(y1);
setFrom : function(x1, y1) {
var change = this._x1 != parseInt(x1) || this._y1 != parseInt(y1);
this._x1 = parseInt(x1);
this._y1 = parseInt(y1);
if(change)
if (change)
this._updatePath();
};
},
web2d.peer.svg.CurvedLinePeer.prototype.setTo = function(x2, y2)
{
var change = this._x2!=parseInt(x2) || this._y2!=parseInt(y2);
setTo : function(x2, y2) {
var change = this._x2 != parseInt(x2) || this._y2 != parseInt(y2);
this._x2 = parseInt(x2);
this._y2 = parseInt(y2);
if(change)
if (change)
this._updatePath();
};
},
web2d.peer.svg.CurvedLinePeer.prototype.getFrom = function()
{
return new core.Point(this._x1,this._y1);
};
getFrom : function() {
return new core.Point(this._x1, this._y1);
},
web2d.peer.svg.CurvedLinePeer.prototype.getTo = function()
{
return new core.Point(this._x2,this._y2);
};
getTo : function() {
return new core.Point(this._x2, this._y2);
},
web2d.peer.svg.CurvedLinePeer.prototype.setStrokeWidth = function(width)
{
this._style['stroke-width']= width;
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;
setColor : function(color) {
this._style['stroke'] = color;
this._style['fill'] = color;
this._updateStyle();
};
},
web2d.peer.svg.CurvedLinePeer.prototype.updateLine = function(avoidControlPointFix){
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;
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._style['fill'] = 'none';
}
this._updateStyle();
this.updateLine();
};
},
web2d.peer.svg.CurvedLinePeer.prototype.getLineStyle = function (){
getLineStyle : function () {
return this._lineStyle;
};
},
web2d.peer.svg.CurvedLinePeer.prototype.setShowEndArrow = function(visible){
this._showEndArrow =visible;
setShowEndArrow : function(visible) {
this._showEndArrow = visible;
this.updateLine();
};
},
web2d.peer.svg.CurvedLinePeer.prototype.isShowEndArrow = function(){
isShowEndArrow : function() {
return this._showEndArrow;
};
},
web2d.peer.svg.CurvedLinePeer.prototype.setShowStartArrow = function(visible){
this._showStartArrow =visible;
setShowStartArrow : function(visible) {
this._showStartArrow = visible;
this.updateLine();
};
},
web2d.peer.svg.CurvedLinePeer.prototype.isShowStartArrow = function(){
isShowStartArrow : function() {
return this._showStartArrow;
};
},
web2d.peer.svg.CurvedLinePeer.prototype._updatePath = function(avoidControlPointFix)
{
if($defined(this._x1) && $defined(this._y1) && $defined(this._x2) && $defined(this._y2))
{
_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"
:""
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);
this._native.setAttribute("d", path);
}
};
},
web2d.peer.svg.CurvedLinePeer.prototype._updateStyle = function()
{
_updateStyle : function() {
var style = "";
for(var key in this._style){
style+=key+":"+this._style[key]+" ";
for (var key in this._style) {
style += key + ":" + this._style[key] + " ";
}
this._native.setAttribute("style",style);
};
this._native.setAttribute("style", style);
},
web2d.peer.svg.CurvedLinePeer.prototype._calculateAutoControlPoints = function(avoidControlPointFix){
_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;
}
};
},
web2d.peer.svg.CurvedLinePeer.prototype.setDashed = function(length,spacing){
if($defined(length) && $defined(spacing)){
this._native.setAttribute("stroke-dasharray",length+","+spacing);
setDashed : function(length, spacing) {
if ($defined(length) && $defined(spacing)) {
this._native.setAttribute("stroke-dasharray", length + "," + spacing);
} else {
this._native.setAttribute("stroke-dasharray","");
this._native.setAttribute("stroke-dasharray", "");
}
};
}
});

View File

@ -16,38 +16,36 @@
* limitations under the License.
*/
web2d.peer.svg.ElementPeer = function(svgElement) {
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
};
},
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) {
setChildren : function(children) {
this._children = children;
};
},
web2d.peer.svg.ElementPeer.prototype.getChildren = function() {
getChildren : function() {
var result = this._children;
if (!$defined(result)) {
result = [];
this._children = result;
}
return result;
};
},
web2d.peer.svg.ElementPeer.prototype.getParent = function() {
getParent : function() {
return this._parent;
};
},
web2d.peer.svg.ElementPeer.prototype.setParent = function(parent) {
setParent : function(parent) {
this._parent = parent;
};
},
web2d.peer.svg.ElementPeer.prototype.appendChild = function(elementPeer) {
appendChild : function(elementPeer) {
// Store parent and child relationship.
elementPeer.setParent(this);
var children = this.getChildren();
@ -58,10 +56,10 @@ web2d.peer.svg.ElementPeer.prototype.appendChild = function(elementPeer) {
// Broadcast events ...
web2d.peer.utils.EventUtils.broadcastChangeEvent(this, "strokeStyle");
};
},
web2d.peer.svg.ElementPeer.prototype.removeChild = function(elementPeer) {
removeChild : function(elementPeer) {
// Store parent and child relationship.
elementPeer.setParent(null);
var children = this.getChildren();
@ -77,23 +75,23 @@ web2d.peer.svg.ElementPeer.prototype.removeChild = function(elementPeer) {
}
// 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) {
addEvent : function(type, listener) {
this._native.addEvent(type, listener);
};
},
web2d.peer.svg.ElementPeer.prototype.removeEvent = function(type, listener) {
removeEvent : function(type, listener) {
this._native.removeEvent(type, listener);
};
},
web2d.peer.svg.ElementPeer.prototype.setSize = function(width, height) {
setSize : function(width, height) {
if ($defined(width) && this._size.width != parseInt(width)) {
this._size.width = parseInt(width);
this._native.setAttribute('width', parseInt(width));
@ -105,38 +103,37 @@ web2d.peer.svg.ElementPeer.prototype.setSize = function(width, height) {
}
web2d.peer.utils.EventUtils.broadcastChangeEvent(this, "strokeStyle");
};
},
web2d.peer.svg.ElementPeer.prototype.getSize = function() {
getSize : function() {
return {width:this._size.width,height:this._size.height};
};
},
web2d.peer.svg.ElementPeer.prototype.setFill = function(color, opacity) {
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() {
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() {
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) {
setStroke : function(width, style, color, opacity) {
if ($defined(width)) {
this._native.setAttribute('stroke-width', width + "px");
}
@ -167,67 +164,74 @@ web2d.peer.svg.ElementPeer.prototype.setStroke = function(width, style, color, o
if ($defined(opacity)) {
this._native.setAttribute('stroke-opacity', opacity);
}
};
},
/*
/*
* style='visibility: visible'
*/
web2d.peer.svg.ElementPeer.prototype.setVisibility = function(isVisible) {
setVisibility : function(isVisible) {
this._native.setAttribute('visibility', (isVisible) ? 'visible' : 'hidden');
};
},
web2d.peer.svg.ElementPeer.prototype.isVisible = function() {
isVisible : function() {
var visibility = this._native.getAttribute('visibility');
return !(visibility == 'hidden');
};
},
web2d.peer.svg.ElementPeer.prototype.updateStrokeStyle = function() {
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) {
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) {
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) {
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() {
moveToFront : function() {
this._native.parentNode.appendChild(this._native);
};
},
/**
/**
* Move element to the back
*/
web2d.peer.svg.ElementPeer.prototype.moveToBack = function() {
moveToBack : function() {
this._native.parentNode.insertBefore(this._native, this._native.parentNode.firstChild);
};
},
web2d.peer.svg.ElementPeer.prototype.setCursor = function(type) {
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.__stokeStyleToStrokDasharray = {solid:[],dot:[1,3],dash:[4,3],longdash:[10,2],dashdot:[5,3,1,3]};

View File

@ -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()
{
web2d.peer.svg.ElipsePeer = new Class({
Extends: web2d.peer.svg.ElementPeer,
initialize : function() {
var svgElement = window.document.createElementNS(this.svgNamespace, 'ellipse');
web2d.peer.svg.ElementPeer.call(this, svgElement);
this.parent(svgElement);
this.attachChangeEventListener("strokeStyle", web2d.peer.svg.ElementPeer.prototype.updateStrokeStyle);
this._position={x:0, y:0};
};
this._position = {x:0, y:0};
},
objects.extend(web2d.peer.svg.ElipsePeer, web2d.peer.svg.ElementPeer);
web2d.peer.svg.ElipsePeer.prototype.setSize = function(width, height)
{
web2d.peer.svg.ElipsePeer.superClass.setSize.call(this, width, height);
if ($defined(width))
{
setSize : function(width, height) {
this.parent(width, height);
if ($defined(width)) {
this._native.setAttribute('rx', width / 2);
}
if ($defined(height))
{
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))
{
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))
{
if ($defined(cy)) {
this._native.setAttribute('cy', cy);
}
};
},
web2d.peer.svg.ElipsePeer.prototype.getPosition = function()
{
getPosition : function() {
return this._position;
};
}
});

View File

@ -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()
{
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))
{
init : function(args) {
if ($defined(args.size)) {
this._size = parseInt(args.size);
}
if ($defined(args.style))
{
if ($defined(args.style)) {
this._style = args.style;
}
if ($defined(args.weight))
{
if ($defined(args.weight)) {
this._weight = args.weight;
}
};
},
web2d.peer.svg.Font.prototype.getHtmlSize = function (scale)
{
getHtmlSize : function (scale) {
var result = 0;
if (this._size == 6)
{
if (this._size == 6) {
result = this._size * scale.height * 43 / 32;
}
if (this._size == 8)
{
if (this._size == 8) {
result = this._size * scale.height * 42 / 32;
}
else if (this._size == 10)
{
else if (this._size == 10) {
result = this._size * scale.height * 42 / 32;
}
else if (this._size == 15)
{
else if (this._size == 15) {
result = this._size * scale.height * 42 / 32;
}
return result;
};
},
web2d.peer.svg.Font.prototype.getGraphSize = function (scale)
{
getGraphSize : function () {
return this._size * 43 / 32;
};
},
web2d.peer.svg.Font.prototype.getSize = function ()
{
getSize : function () {
return parseInt(this._size);
};
},
web2d.peer.svg.Font.prototype.getStyle = function ()
{
getStyle : function () {
return this._style;
};
},
web2d.peer.svg.Font.prototype.getWeight = function ()
{
getWeight : function () {
return this._weight;
};
},
web2d.peer.svg.Font.prototype.setSize = function (size)
{
setSize : function (size) {
this._size = size;
};
},
web2d.peer.svg.Font.prototype.setStyle = function (style)
{
setStyle : function (style) {
this._style = style;
};
},
web2d.peer.svg.Font.prototype.setWeight = function (weight)
{
setWeight : function (weight) {
this._weight = weight;
};
},
web2d.peer.svg.Font.prototype.getWidthMargin = function ()
{
getWidthMargin : function () {
var result = 0;
if (this._size == 10 || this._size == 6)
{
if (this._size == 10 || this._size == 6) {
result = 4;
}
return result;
};
}
});

View File

@ -1,55 +1,47 @@
/*
* 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.GroupPeer = function()
{
web2d.peer.svg.GroupPeer = new Class({
Extends: web2d.peer.svg.ElementPeer,
initialize : function() {
var svgElement = window.document.createElementNS(this.svgNamespace, 'g');
web2d.peer.svg.ElementPeer.call(this, svgElement);
this.parent(svgElement);
this._native.setAttribute("preserveAspectRatio", "none");
this._coordSize = {width:1,height:1};
this._native.setAttribute("focusable","true");
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;
setCoordSize : function(width, height) {
var change = this._coordSize.width != width || this._coordSize.height != height;
this._coordSize.width = width;
this._coordSize.height = height;
if(change)
if (change)
this.updateTransform();
web2d.peer.utils.EventUtils.broadcastChangeEvent(this, "strokeStyle");
};
},
web2d.peer.svg.GroupPeer.prototype.getCoordSize = function()
{
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
*
@ -70,8 +62,7 @@ web2d.peer.svg.GroupPeer.prototype.getCoordSize = function()
* * skewY(<skew-angle>), which specifies a skew transformation along the y-axis.
**/
web2d.peer.svg.GroupPeer.prototype.updateTransform = function()
{
updateTransform : function() {
var sx = this._size.width / this._coordSize.width;
var sy = this._size.height / this._coordSize.height;
@ -79,60 +70,51 @@ web2d.peer.svg.GroupPeer.prototype.updateTransform = function()
var cy = this._position.y - this._coordOrigin.y * sy;
this._native.setAttribute("transform", "translate(" + cx + "," + cy + ") scale(" + sx + "," + sy + ")");
};
},
web2d.peer.svg.GroupPeer.prototype.setCoordOrigin = function(x, y)
{
var change = x!=this._coordOrigin.x || y!=this._coordOrigin.y;
if ($defined(x))
{
setCoordOrigin : function(x, y) {
var change = x != this._coordOrigin.x || y != this._coordOrigin.y;
if ($defined(x)) {
this._coordOrigin.x = x;
}
if ($defined(y))
{
if ($defined(y)) {
this._coordOrigin.y = y;
}
if(change)
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)
setSize : function(width, height) {
var change = width != this._size.width || height != this._size.height;
this.parent(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))
{
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))
{
if ($defined(y)) {
this._position.y = parseInt(y);
}
if(change)
if (change)
this.updateTransform();
};
},
web2d.peer.svg.GroupPeer.prototype.getPosition = function()
{
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);
appendChild : function(child) {
this.parent(child);
web2d.peer.utils.EventUtils.broadcastChangeEvent(child, "onChangeCoordSize");
};
},
web2d.peer.svg.GroupPeer.prototype.getCoordOrigin = function ()
{
getCoordOrigin : function () {
return {x:this._coordOrigin.x, y:this._coordOrigin.y};
};
}
});

View File

@ -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()
{
web2d.peer.svg.ImagePeer = new Class({
Extends: web2d.peer.svg.ElementPeer,
initialize : function() {
var svgElement = window.document.createElementNS(this.svgNamespace, 'image');
web2d.peer.svg.ElementPeer.call(this, svgElement);
this.parent(svgElement);
this._position = {x:0,y:0};
this._href="";
};
this._href = "";
},
objects.extend(web2d.peer.svg.ImagePeer, web2d.peer.svg.ElementPeer);
web2d.peer.svg.ImagePeer.prototype.setPosition = function(x, y)
{
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.getPosition = function()
{
getPosition : function() {
return this._position;
};
},
web2d.peer.svg.ImagePeer.prototype.setHref = function(url)
{
setHref : function(url) {
this._native.setAttributeNS(this.linkNamespace, "href", url);
this._href = url;
};
},
web2d.peer.svg.ImagePeer.prototype.getHref = function()
{
getHref : function() {
return this._href;
};
}
});

View File

@ -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()
{
web2d.peer.svg.LinePeer = new Class({
Extends: web2d.peer.svg.ElementPeer,
initialize : function() {
var svgElement = window.document.createElementNS(this.svgNamespace, 'line');
web2d.peer.svg.ElementPeer.call(this, svgElement);
this.parent(svgElement);
this.attachChangeEventListener("strokeStyle", web2d.peer.svg.ElementPeer.prototype.updateStrokeStyle);
};
},
objects.extend(web2d.peer.svg.LinePeer, web2d.peer.svg.ElementPeer);
web2d.peer.svg.LinePeer.prototype.setFrom = function(x1, y1)
{
this._x1=x1;
this._y1=y1;
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.setTo = function(x2, y2)
{
this._x2=x2;
this._y2=y2;
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.getFrom = function(){
return new core.Point(this._x1,this._y1);
};
getFrom : function() {
return new core.Point(this._x1, this._y1);
},
web2d.peer.svg.LinePeer.prototype.getTo = function(){
return new core.Point(this._x2,this._y2);
};
getTo : function() {
return new core.Point(this._x2, this._y2);
},
/*
* 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))
{
/*
* 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 ...
}
if ($defined(endStyle))
{
if ($defined(endStyle)) {
// Todo: This must be implemented ...
}
};
}
});

View File

@ -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 = new Class({
Extends: web2d.peer.svg.ElementPeer,
initialize : function() {
web2d.peer.svg.PolyLinePeer = function()
{
var svgElement = window.document.createElementNS(this.svgNamespace, 'polyline');
web2d.peer.svg.ElementPeer.call(this, svgElement);
this.parent(svgElement);
this.setFill("none");
this.breakDistance = 10;
};
},
objects.extend(web2d.peer.svg.PolyLinePeer, web2d.peer.svg.ElementPeer);
web2d.peer.svg.PolyLinePeer.prototype.setFrom = function(x1, y1)
{
setFrom : function(x1, y1) {
this._x1 = x1;
this._y1 = y1;
this._updatePath();
};
},
web2d.peer.svg.PolyLinePeer.prototype.setTo = function(x2, y2)
{
setTo : function(x2, y2) {
this._x2 = x2;
this._y2 = y2;
this._updatePath();
};
},
web2d.peer.svg.PolyLinePeer.prototype.setStrokeWidth = function(width)
{
setStrokeWidth : function(width) {
this._native.setAttribute('stroke-width', width);
};
},
web2d.peer.svg.PolyLinePeer.prototype.setColor = function(color)
{
setColor : function(color) {
this._native.setAttribute('stroke', color);
};
},
web2d.peer.svg.PolyLinePeer.prototype.setStyle = function(style)
{
setStyle : function(style) {
this._style = style;
this._updatePath();
};
},
web2d.peer.svg.PolyLinePeer.prototype.getStyle = function()
{
getStyle : function() {
return this._style;
};
},
web2d.peer.svg.PolyLinePeer.prototype._updatePath = function()
{
if (this._style == "Curved")
{
_updatePath : function() {
if (this._style == "Curved") {
this._updateMiddleCurvePath();
}
else if (this._style == "Straight")
{
else if (this._style == "Straight") {
this._updateStraightPath();
}
else
{
else {
this._updateCurvePath();
}
};
},
web2d.peer.svg.PolyLinePeer.prototype._updateStraightPath = function()
{
if ($defined(this._x1) && $defined(this._x2) && $defined(this._y1) && $defined(this._y2))
{
_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()
{
_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))
{
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)
{
if (diff < 0) {
signx = -1;
}
if (y2 < y1)
{
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);
}
};
},
web2d.peer.svg.PolyLinePeer.prototype._updateCurvePath = function()
{
if ($defined(this._x1) && $defined(this._x2) && $defined(this._y1) && $defined(this._y2))
{
_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);
}
};
}
});

View File

@ -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)
{
web2d.peer.svg.RectPeer = new Class({
Extends: web2d.peer.svg.ElementPeer,
initialize : function(arc) {
var svgElement = window.document.createElementNS(this.svgNamespace, 'rect');
web2d.peer.svg.ElementPeer.call(this, svgElement);
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);
web2d.peer.svg.RectPeer.prototype.setPosition = function(x, y)
{
if ($defined(x))
{
setPosition :function(x, y) {
if ($defined(x)) {
this._native.setAttribute('x', parseInt(x));
}
if ($defined(y))
{
if ($defined(y)) {
this._native.setAttribute('y', parseInt(y));
}
};
},
web2d.peer.svg.RectPeer.prototype.getPosition = function()
{
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);
setSize :function(width, height) {
this.parent(width, height);
var min = width < height?width:height;
if ($defined(this._arc))
{
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);
}
};
}
});

View File

@ -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);
web2d.peer.svg.TahomaFont.prototype.getFontFamily=function ()
{
getFontFamily : function () {
return this._fontFamily;
};
},
web2d.peer.svg.TahomaFont.prototype.getFont=function ()
{
getFont : function () {
return web2d.Font.TAHOMA;
};
}
});

View File

@ -16,29 +16,20 @@
* limitations under the License.
*/
web2d.peer.svg.TextPeer = function() {
web2d.peer.svg.TextPeer = new Class({
Extends: web2d.peer.svg.ElementPeer,
initialize : function() {
var svgElement = window.document.createElementNS(this.svgNamespace, 'text');
web2d.peer.svg.ElementPeer.call(this, svgElement);
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);
//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);
};
*/
web2d.peer.svg.TextPeer.prototype.appendChild = function(element) {
appendChild : function(element) {
this._native.appendChild(element._native);
};
},
web2d.peer.svg.TextPeer.prototype.setText = function(text) {
setText : function(text) {
text = core.Utils.escapeInvalidTags(text);
var child = this._native.firstChild;
if ($defined(child)) {
@ -47,13 +38,13 @@ web2d.peer.svg.TextPeer.prototype.setText = function(text) {
this._text = text;
var textNode = window.document.createTextNode(text);
this._native.appendChild(textNode);
};
},
web2d.peer.svg.TextPeer.prototype.getText = function() {
getText : function() {
return this._text;
};
},
web2d.peer.svg.TextPeer.prototype.setPosition = function(x, y) {
setPosition : function(x, y) {
this._position = {x:x, y:y};
var height = this._font.getSize();
if ($defined(this._parent) && $defined(this._native.getBBox))
@ -62,13 +53,13 @@ web2d.peer.svg.TextPeer.prototype.setPosition = function(x, y) {
this._native.setAttribute('y', y + size * 3 / 4);
//y+size/2
this._native.setAttribute('x', x);
};
},
web2d.peer.svg.TextPeer.prototype.getPosition = function() {
getPosition : function() {
return this._position;
};
},
web2d.peer.svg.TextPeer.prototype.setFont = function(font, size, style, weight) {
setFont : function(font, size, style, weight) {
if ($defined(font)) {
this._font = new web2d.Font(font, this);
}
@ -82,9 +73,9 @@ web2d.peer.svg.TextPeer.prototype.setFont = function(font, size, style, weight)
this._font.setSize(size);
}
this._updateFontStyle();
};
},
web2d.peer.svg.TextPeer.prototype._updateFontStyle = function() {
_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());
@ -93,70 +84,71 @@ web2d.peer.svg.TextPeer.prototype._updateFontStyle = function() {
var scale = this._font.getFontScale();
this._native.xFontScale = scale.toFixed(1);
};
web2d.peer.svg.TextPeer.prototype.setColor = function(color) {
},
setColor : function(color) {
this._native.setAttribute('fill', color);
};
},
web2d.peer.svg.TextPeer.prototype.getColor = function() {
getColor : function() {
return this._native.getAttribute('fill');
};
},
web2d.peer.svg.TextPeer.prototype.setTextSize = function (size) {
setTextSize : function (size) {
this._font.setSize(size);
this._updateFontStyle();
};
},
web2d.peer.svg.TextPeer.prototype.setContentSize = function(width, height) {
setContentSize : function(width, height) {
this._native.xTextSize = width.toFixed(1) + "," + height.toFixed(1);
};
},
web2d.peer.svg.TextPeer.prototype.setStyle = function (style) {
setStyle : function (style) {
this._font.setStyle(style);
this._updateFontStyle();
};
},
web2d.peer.svg.TextPeer.prototype.setWeight = function (weight) {
setWeight : function (weight) {
this._font.setWeight(weight);
this._updateFontStyle();
};
},
web2d.peer.svg.TextPeer.prototype.setFontFamily = function (family) {
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 () {
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) {
setSize : function (size) {
this._font.setSize(size);
this._updateFontStyle();
};
},
web2d.peer.svg.TextPeer.prototype.getWidth = function () {
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 () {
getHeight : function () {
var computedHeight = this._native.getBBox().height;
return parseInt(computedHeight);
};
},
web2d.peer.svg.TextPeer.prototype.getHtmlFontSize = function () {
getHtmlFontSize : function () {
return this._font.getHtmlSize();
};
}
});

View File

@ -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);
web2d.peer.svg.TimesFont.prototype.getFontFamily=function ()
{
getFontFamily :function () {
return this._fontFamily;
};
},
web2d.peer.svg.TimesFont.prototype.getFont=function ()
{
getFont : function () {
return web2d.Font.TIMES;
};
}
});

View File

@ -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);
web2d.peer.svg.VerdanaFont.prototype.getFontFamily=function ()
{
getFontFamily : function () {
return this._fontFamily;
};
},
web2d.peer.svg.VerdanaFont.prototype.getFont=function ()
{
getFont : function () {
return web2d.Font.VERDANA;
};
}
});

View File

@ -1,36 +1,34 @@
/*
* 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.WorkspacePeer = function(element)
{
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');
web2d.peer.svg.ElementPeer.call(this, svgElement);
this.parent(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.
*
@ -40,84 +38,71 @@ objects.extend(web2d.peer.svg.WorkspacePeer, web2d.peer.svg.ElementPeer);
*
*/
web2d.peer.svg.WorkspacePeer.prototype.setCoordSize = function(width, height)
{
setCoordSize : function (width, height) {
var viewBox = this._native.getAttribute('viewBox');
var coords = [0,0,0,0];
if (viewBox != null)
{
if (viewBox != null) {
coords = viewBox.split(/ /);
}
if ($defined(width))
{
if ($defined(width)) {
coords[2] = width;
}
if ($defined(height))
{
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()
{
getCoordSize : function () {
var viewBox = this._native.getAttribute('viewBox');
var coords = [1,1,1,1];
if (viewBox != null)
{
if (viewBox != null) {
coords = viewBox.split(/ /);
}
return {width:coords[2],height:coords[3]};
};
},
web2d.peer.svg.WorkspacePeer.prototype.setCoordOrigin = function(x, y)
{
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)
{
if (viewBox != null) {
coords = viewBox.split(/ /);
}
if ($defined(x))
{
if ($defined(x)) {
coords[0] = x;
}
if ($defined(y))
{
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);
appendChild : function (child) {
this.parent(child);
web2d.peer.utils.EventUtils.broadcastChangeEvent(child, "onChangeCoordSize");
};
},
web2d.peer.svg.WorkspacePeer.prototype.getCoordOrigin = function(child)
{
getCoordOrigin : function (child) {
var viewBox = this._native.getAttribute('viewBox');
var coords = [1,1,1,1];
if (viewBox != null)
{
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()
{
getPosition : function () {
return {x:0,y:0};
};
}
});

View File

@ -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);
}
}