removing VML support from client side

This commit is contained in:
Pablo Luna
2011-03-16 11:40:48 +00:00
parent 1b04d1effc
commit 7acfd763fa
41 changed files with 27 additions and 1914 deletions

View File

@@ -16,101 +16,6 @@
* limitations under the License.
*/
web2d.peer.ToolkitVML =
{
init: function()
{
var domDocument = window.document;
//ownerDocument;
// Add VML includes and namespace
var style = domDocument.createStyleSheet();
try
{
domDocument.namespaces.add("v", "urn:schemas-microsoft-com:vml");
} catch(j)
{
try
{
domDocument.namespaces.add("v", "urn:schemas-microsoft-com:vml", "#default#VML");
} catch(k)
{
}
}
try
{
style.addRule("v\\:*", "behavior:url(#default#VML); display:inline-block");
} catch(e)
{
style.addRule('v\\:polyline', 'behavior: url(#default#VML);display:inline-block');
style.addRule('v\\:fill', 'behavior: url(#default#VML);display:inline-block');
style.addRule('v\\:stroke', 'behavior: url(#default#VML);display:inline-block');
style.addRule('v\\:oval', 'behavior: url(#default#VML);display:inline-block');
style.addRule('v\\:group', 'behavior: url(#default#VML);display:inline-block');
style.addRule('v\\:image', 'behavior: url(#default#VML);display:inline-block');
style.addRule('v\\:line', 'behavior: url(#default#VML);display:inline-block');
style.addRule('v\\:rect', 'behavior: url(#default#VML);display:inline-block');
style.addRule('v\\:roundrect', 'behavior: url(#default#VML);display:inline-block');
style.addRule('v\\:shape', 'behavior: url(#default#VML);display:inline-block');
style.addRule('v\\:textbox', 'behavior: url(#default#VML);display:inline-block');
}
},
createWorkspace: function(element)
{
return new web2d.peer.vml.WorkspacePeer(element);
},
createGroup: function()
{
return new web2d.peer.vml.GroupPeer();
},
createElipse: function()
{
return new web2d.peer.vml.ElipsePeer();
},
createLine: function()
{
return new web2d.peer.vml.LinePeer();
},
createCurvedLine: function()
{
},
createArrow: function()
{
},
createImage: function ()
{
return new web2d.peer.vml.ImagePeer();
},
createText: function ()
{
return new web2d.peer.vml.TextBoxPeer();
},
createRect: function(arc)
{
return new web2d.peer.vml.RectPeer(arc);
},
createArialFont: function()
{
return new web2d.peer.vml.ArialFont();
},
createTimesFont: function()
{
return new web2d.peer.vml.TimesFont();
},
createVerdanaFont: function()
{
return new web2d.peer.vml.VerdanaFont();
},
createTahomaFont: function()
{
return new web2d.peer.vml.TahomaFont();
}
};
web2d.peer.ToolkitSVG =
{
init: function()
@@ -174,10 +79,4 @@ web2d.peer.ToolkitSVG =
}
};
if (core.UserAgent.isSVGSupported())
{
web2d.peer.Toolkit = web2d.peer.ToolkitSVG;
} else
{
web2d.peer.Toolkit = web2d.peer.ToolkitVML;
}
web2d.peer.Toolkit = web2d.peer.ToolkitSVG;

View File

@@ -175,7 +175,7 @@ web2d.Workspace.prototype.getCoordOrigin = function()
// Private method declaration area
/**
* All the VML or SVG elements will be children of this HTML element.
* All the SVG elements will be children of this HTML element.
*/
web2d.Workspace.prototype._getHtmlContainer = function()
{

View File

@@ -19,7 +19,6 @@
var web2d = {};
web2d.peer =
{
svg: {},
vml: {}
svg: {}
};
web2d.peer.utils = {};

View File

@@ -1,35 +0,0 @@
/*
* 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.vml.ArialFont = function()
{
web2d.peer.vml.Font.call(this);
this._fontFamily="Arial";
};
objects.extend(web2d.peer.vml.ArialFont, web2d.peer.vml.Font);
web2d.peer.vml.ArialFont.prototype.getFontFamily=function ()
{
return this._fontFamily;
};
web2d.peer.vml.ArialFont.prototype.getFont=function ()
{
return web2d.Font.ARIAL;
};

View File

@@ -1,360 +0,0 @@
/*
* 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.vml.ElementPeer = function(vmlElement)
{
this._native = vmlElement;
this._native.style.position = 'absolute';
this._position = {x:0,y:0};
this._strokeWidth = -1;
this._changeListeners = {};
};
/**
* http://www.quirksmode.org/js/events_advanced.html
*
* Drawbacks
*
* When compared to the W3C model, the Microsoft model has two important drawbacks:
* 1. Events always bubble, no capturing possibility.
* 2. The event handling function is referenced, not copied, so the this keyword always refers to the window and is completely useless.
*
* The result of these two weaknesses is that when an event bubbles up it is impossible to know which HTML element currently handles the event. I explain this problem more fully on the Event order page.
* Since the Microsoft event adding model is only supported by Explorer 5 and higher on Windows, it cannot be used for cross<73>browser scripts. But even for Explorer<65>on<6F>Windows only applications it<69>s best not to use it, since the bubbling problem can be quite nasty in complex applications.
*/
web2d.peer.vml.ElementPeer.prototype.addEventListener = function(type, listener)
{
var element = this.getElementToAttachEvent();
element.attachEvent("on" + type, listener);
};
web2d.peer.vml.ElementPeer.prototype.getElementToAttachEvent = function()
{
return this._native;
};
web2d.peer.vml.ElementPeer.prototype.removeEventListener = function(type, listener, useCapture)
{
var element = this.getElementToAttachEvent();
element.detachEvent("on" + type, listener);
};
web2d.peer.vml.ElementPeer.prototype.getChangeEventListeners = function(type)
{
var listeners = this._changeListeners[type];
if (!listeners)
{
listeners = [];
this._changeListeners[type] = listeners;
}
return listeners;
};
web2d.peer.vml.ElementPeer.prototype.attachChangeEventListener = function(type, listener)
{
var listeners = this.getChangeEventListeners(type);
if (!listener)
{
throw "Listener can not be null";
}
listeners.push(listener);
};
web2d.peer.vml.ElementPeer.prototype.setSize = function(width, height)
{
// First set the size of the group element.
if (core.Utils.isDefined(width))
{
this._native.style.width = parseInt(width);
}
if (core.Utils.isDefined(height))
{
this._native.style.height = parseInt(height);
}
};
web2d.peer.vml.ElementPeer.prototype.getChildren = function()
{
var result = this._children;
if (!result)
{
result = [];
this._children = result;
}
return result;
};
web2d.peer.vml.ElementPeer.prototype.setChildren = function(children)
{
this._children = children;
};
web2d.peer.vml.ElementPeer.prototype.removeChild = function(elementPeer)
{
// Store parent and child relationship.
elementPeer.setParent(null);
var children = this.getChildren();
// Remove from children array ...
var length = children.length;
children.remove(elementPeer);
var newLength = children.length;
if (newLength >= length)
{
throw "Could not remove the element.";
}
/*var found = false;
children = children.reject(function(iter)
{
var equals = (iter._native === elementPeer._native);
if (equals)
{
found = true;
}
return equals;
});
// Could found the element ?
if (!found)
{
throw "Could not remove the element.";
}*/
// Append element as a child.
this._native.removeChild(elementPeer._native);
};
web2d.peer.vml.ElementPeer.prototype.appendChild = function(elementPeer)
{
// Warning: Posible memory leak.
// Store parent and child relationship.
elementPeer.setParent(this);
var children = this.getChildren();
children.push(elementPeer);
// Add native element ..
this._native.appendChild(elementPeer._native);
elementPeer._appededToParent();
// Broadcast events ...
web2d.peer.utils.EventUtils.broadcastChangeEvent(this, "onChangeCoordSize");
};
// IE 8 hack ...
web2d.peer.vml.ElementPeer.prototype._appededToParent = function()
{
var fillElem = this.getVMLFill();
this._native.appendChild(fillElem);
var strokeElem = this.getVMLStroke();
this._native.appendChild(strokeElem);
}
web2d.peer.vml.ElementPeer.prototype.getSize = function()
{
return {
width:parseFloat(this._native.style.width),
height:parseFloat(this._native.style.height)
};
};
web2d.peer.vml.ElementPeer.prototype.setPosition = function(x, y)
{
if (core.Utils.isDefined(x))
{
this._position.x = parseInt(x);
this._native.style.left = x;
}
if (core.Utils.isDefined(y))
{
this._position.y = parseInt(y);
this._native.style.top = y;
}
};
web2d.peer.vml.ElementPeer.prototype.getPosition = function()
{
return {x:this._position.x, y:this._position.y};
};
web2d.peer.vml.ElementPeer.prototype.getVMLFill = function()
{
if (!this._vmlFill)
{
this._vmlFill = window.document.createElement('v:fill');
}
return this._vmlFill;
};
web2d.peer.vml.ElementPeer.prototype.setFill = function(color, opacity)
{
var vmlFill = this.getVMLFill();
if (core.Utils.isDefined(color))
{
vmlFill.color = color;
}
if (core.Utils.isDefined(opacity))
{
vmlFill.opacitopacity;
}
};
web2d.peer.vml.ElementPeer.prototype.getFill = function()
{
var vmlFill = this.getVMLFill();
var color = vmlFill.getAttribute('color');
var opacity = vmlFill.getAttribute('opacity');
opacity = opacity.toFixed(1);
return {color:String(color), opacity:Number(opacity)};
};
web2d.peer.vml.ElementPeer.prototype.getVMLStroke = function()
{
if (!this._vmlStroke)
{
this._vmlStroke = window.document.createElement('v:stroke');
}
return this._vmlStroke;
};
web2d.peer.vml.ElementPeer.prototype.getStroke = function()
{
var vmlStroke = this.getVMLStroke();
var color = vmlStroke.getAttribute('color');
var dashstyle = vmlStroke.getAttribute('dashstyle');
var opacity = vmlStroke.getAttribute('opacity');
var width = this._strokeWidth;
if (width == -1)
{
width = 0;
}
return {color: color, style: dashstyle, opacity: opacity, width: width};
};
/*
* http://msdn.microsoft.com/workshop/author/VML/ref/adv2.asp
* "solid|dot|dash|dashdot|longdash|longdashdot|longdashdotdot".
* /**
* The opacity of the entire shape. A fraction between 0 (completely transparent) and 1 (completely opaque.)
*/
web2d.peer.vml.ElementPeer.prototype.setStroke = function(width, style, color, opacity)
{
var vmlStroke = this.getVMLStroke();
if (core.Utils.isDefined(color))
{
vmlStroke.setAttribute('color', color);
}
if (core.Utils.isDefined(style))
{
vmlStroke.setAttribute('dashstyle', style);
}
if (core.Utils.isDefined(opacity))
{
vmlStroke.setAttribute('opacity', opacity);
}
if (core.Utils.isDefined(width))
{
var scaleStrokeWidth = 0;
if (width !== 0)
{
this._strokeWidth = width;
var scale = web2d.peer.utils.TransformUtil.workoutScale(this);
scaleStrokeWidth = scale.width * this._strokeWidth;
scaleStrokeWidth = scaleStrokeWidth.toFixed(2);
vmlStroke.setAttribute('weight', scaleStrokeWidth + "px");
vmlStroke.setAttribute('on', 'true');
}
else
{
vmlStroke.setAttribute('strokeweight', 0);
vmlStroke.setAttribute('on', 'false');
}
}
};
/**
* If hidden the shape is not rendered and does not generate mouse events.
*/
web2d.peer.vml.ElementPeer.prototype.setVisibility = function(isVisible)
{
this._native.style.visibility = (isVisible) ? 'visible' : 'hidden';
};
web2d.peer.vml.ElementPeer.prototype.isVisible = function(isVisible)
{
var visibility = this._native.style.visibility;
return !(visibility == 'hidden');
};
;
web2d.peer.vml.ElementPeer.prototype._updateStrokeWidth = function()
{
if (this.getParent())
{
this.setStroke(this._strokeWidth);
}
};
web2d.peer.vml.ElementPeer.prototype.getParent = function()
{
return this._parent;
};
web2d.peer.vml.ElementPeer.prototype.setParent = function(parent)
{
this._parent = parent;
};
/**
* Move element to the front
*/
web2d.peer.vml.ElementPeer.prototype.moveToFront = function()
{
this._native.parentNode.appendChild(this._native);
};
/**
* Move element to the back
*/
web2d.peer.vml.ElementPeer.prototype.moveToBack = function()
{
this._native.parentNode.insertBefore(this._native, this._native.parentNode.firstChild);
};
web2d.peer.vml.ElementPeer.prototype.setCursor = function(type)
{
this._native.style.cursor = type;
};

View File

@@ -1,57 +0,0 @@
/*
* 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.vml.ElipsePeer = function()
{
var vmlElement = window.document.createElement('v:oval');
web2d.peer.vml.ElementPeer.call(this, vmlElement);
this.attachChangeEventListener("onChangeCoordSize", web2d.peer.vml.ElementPeer.prototype._updateStrokeWidth);
};
objects.extend(web2d.peer.vml.ElipsePeer, web2d.peer.vml.ElementPeer);
web2d.peer.vml.ElipsePeer.prototype.setPosition = function(cx, cy)
{
// VML position is positioned the coorner of the oval.
// That's why, I have to move the circle to the center by hand.
if (core.Utils.isDefined(cx))
{
this._position.x = parseInt(cx);
this._native.style.left = cx;// + parseInt(this.getSize().width / 2);
}
if (core.Utils.isDefined(cy))
{
this._position.y = parseInt(cy);
this._native.style.top = cy;// + parseInt(this.getSize().height / 2);
}
};
web2d.peer.vml.ElementPeer.prototype.getPosition = function()
{
return {x:this._position.x, y:this._position.y};
};
web2d.peer.vml.ElipsePeer.prototype.setSize = function(width, height)
{
web2d.peer.vml.ElipsePeer.superClass.setSize.call(this, width, height);
var coord = this.getPosition();
this.setPosition(coord.x, coord.y);
};

View File

@@ -1,88 +0,0 @@
/*
* 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.vml.Font = function()
{
this._size = 10;
this._style = "normal";
this._weight = "normal";
};
web2d.peer.vml.Font.prototype.init = function(args)
{
if (core.Utils.isDefined(args.size))
{
this._size = parseInt(args.size);
}
if (core.Utils.isDefined(args.style))
{
this._style = args.style;
}
if (core.Utils.isDefined(args.weight))
{
this._weight = args.weight;
}
};
web2d.peer.vml.Font.prototype.getHtmlSize = function (scale)
{
var result = this._size * scale.height * 43 / 32;
return result;
};
web2d.peer.vml.Font.prototype.getGraphSize = function (scale)
{
var result = parseInt(this._size) * scale.height * 43 / 32;
return result;
};
web2d.peer.vml.Font.prototype.getSize = function ()
{
return parseInt(this._size);
};
web2d.peer.vml.Font.prototype.getStyle = function ()
{
return this._style;
};
web2d.peer.vml.Font.prototype.getWeight = function ()
{
return this._weight;
};
web2d.peer.vml.Font.prototype.setSize = function (size)
{
this._size = size;
};
web2d.peer.vml.Font.prototype.setStyle = function (style)
{
this._style = style;
};
web2d.peer.vml.Font.prototype.setWeight = function (weight)
{
this._weight = weight;
};
web2d.peer.vml.Font.prototype.getWidthMargin = function ()
{
var result = 0;
return result;
};

View File

@@ -1,76 +0,0 @@
/*
* 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.vml.GroupPeer = function()
{
var vmlElement = window.document.createElement('v:group');
web2d.peer.vml.ElementPeer.call(this, vmlElement);
this._native.style.cursor = 'move';
};
objects.extend(web2d.peer.vml.GroupPeer, web2d.peer.vml.ElementPeer);
web2d.peer.vml.ElementPeer.prototype.setCoordOrigin = function(x, y)
{
this._native.coordorigin = x + "," + y;
};
web2d.peer.vml.GroupPeer.prototype.setCoordSize = function(width, height)
{
this._native.coordsize = width + "," + height;
web2d.peer.utils.EventUtils.broadcastChangeEvent(this, "onChangeCoordSize");
};
web2d.peer.vml.GroupPeer.prototype.getCoordSize = function()
{
var coordSize = this._native.coordsize + "";
var coord;
if (coordSize)
{
coord = coordSize.split(",");
} else
{
coord = [1,1];
}
return { width:coord[0], height:coord[1] };
};
web2d.peer.vml.GroupPeer.prototype.setSize = function(width, height)
{
web2d.peer.vml.ElipsePeer.superClass.setSize.call(this, width, height);
web2d.peer.utils.EventUtils.broadcastChangeEvent(this, "onChangeCoordSize");
};
web2d.peer.vml.GroupPeer.prototype.appendChild = function(child)
{
web2d.peer.vml.GroupPeer.superClass.appendChild.call(this, child);
web2d.peer.utils.EventUtils.broadcastChangeEvent(child, "onChangeCoordSize");
};
web2d.peer.vml.GroupPeer.prototype.getCoordOrigin = function()
{
var coordOrigin = this._native.coordorigin + "";
var coord;
if (coordOrigin)
{
coord = coordOrigin.split(",");
} else
{
coord = [1,1];
}
return { x:coord[0], y:coord[1] };
};

View File

@@ -1,37 +0,0 @@
/*
* 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.vml.ImagePeer = function()
{
var vmlElement = window.document.createElement('v:image');
web2d.peer.vml.ElementPeer.call(this, vmlElement);
};
objects.extend(web2d.peer.vml.ImagePeer, web2d.peer.vml.ElementPeer);
web2d.peer.vml.ImagePeer.prototype.setHref = function(url)
{
this._native.setAttribute("src", url);
this._href = url;
};
web2d.peer.vml.ImagePeer.prototype.getHref = function()
{
return this._href;
};

View File

@@ -1,68 +0,0 @@
/*
* 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.vml.LinePeer = function()
{
var vmlElement = window.document.createElement('v:line');
web2d.peer.vml.ElementPeer.call(this, vmlElement);
this._native.setAttribute('fillcolor', 'none');
};
objects.extend(web2d.peer.vml.LinePeer, web2d.peer.vml.ElementPeer);
web2d.peer.vml.LinePeer.prototype.setFrom = function(x1, y1)
{
this._native.setAttribute('from', x1 + "," + y1);
};
web2d.peer.vml.LinePeer.prototype.setTo = function(x2, y2)
{
this._native.setAttribute('to', x2 + "," + y2);
};
web2d.peer.vml.LinePeer.prototype.setStroke = function(width, style, color, opacity)
{
web2d.peer.vml.LinePeer.superClass.setStroke.call(this, width, style, color, opacity);
if (core.Utils.isDefined(width))
{
this._vmlStroke.setAttribute('weight', width + "px");
}
};
web2d.peer.vml.LinePeer.prototype.setArrowStyle = function(startStyle, endStyle)
{
var vmlStroke = this.getVMLStroke();
if (core.Utils.isDefined(startStyle))
{
vmlStroke.setAttribute('startarrow', startStyle);
vmlStroke.setAttribute('startarrowwidth', 'narrow');
vmlStroke.setAttribute('startarrowlength', 'short');
}
if (core.Utils.isDefined(endStyle))
{
vmlStroke.setAttribute('endarrow', endStyle);
vmlStroke.setAttribute('endarrowwidth', 'narrow');
vmlStroke.setAttribute('endarrowlength', 'short');
}
};

View File

@@ -1,150 +0,0 @@
/*
* 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.vml.PolyLinePeer = function()
{
var vmlElement = window.document.createElement('v:polyline');
web2d.peer.vml.ElementPeer.call(this, vmlElement);
this._native.setAttribute('filled', 'false');
this.breakDistance = 10;
};
objects.extend(web2d.peer.vml.PolyLinePeer, web2d.peer.vml.ElementPeer);
web2d.peer.vml.PolyLinePeer.prototype.setFrom = function(x1, y1)
{
this._x1 = x1;
this._y1 = y1;
this._updatePath();
};
web2d.peer.vml.PolyLinePeer.prototype.setTo = function(x2, y2)
{
this._x2 = x2;
this._y2 = y2;
this._updatePath();
};
web2d.peer.vml.PolyLinePeer.prototype.setStyle = function(style)
{
this._style = style;
this._updatePath();
};
web2d.peer.vml.PolyLinePeer.prototype.getStyle = function()
{
return this._style;
};
web2d.peer.vml.PolyLinePeer.prototype._updatePath = function()
{
if (this._style == "Curved")
{
this._updateMiddleCurvePath();
}
else if (this._style == "Straight")
{
this._updateStraightPath();
}
else
{
this._updateCurvePath();
}
};
web2d.peer.vml.PolyLinePeer.prototype._updateStraightPath = function()
{
if (core.Utils.isDefined(this._x1) && core.Utils.isDefined(this._x2) && core.Utils.isDefined(this._y1) && core.Utils.isDefined(this._y2))
{
this.buildStraightPath(this.breakDistance, this._x1, this._y1, this._x2, this._y2);
// Hack: I could not solve why this is happening...
if (!this._native.points)
{
this._native.setAttribute('points', path);
} else
{
this._native.points.value = path;
}
}
};
web2d.peer.vml.PolyLinePeer.prototype._updateMiddleCurvePath = function()
{
var x1 = this._x1;
var y1 = this._y1;
var x2 = this._x2;
var y2 = this._y2;
if (core.Utils.isDefined(x1) && core.Utils.isDefined(x2) && core.Utils.isDefined(y1) && core.Utils.isDefined(y2))
{
var diff = x2 - x1;
var middlex = (diff / 2) + x1;
var signx = 1;
var signy = 1;
if (diff < 0)
{
signx = -1;
}
if (y2 < y1)
{
signy = -1;
}
var path = x1 + ", " + y1 + " " + (middlex - 10 * signx) + ", " + y1 + " " + middlex + ", " + (y1 + 10 * signy) + " " + middlex + ", " + (y2 - 10 * signy) + " " + (middlex + 10 * signx) + ", " + y2 + " " + x2 + ", " + y2;
// Hack: I could not solve why this is happening...
if (!this._native.points)
{
this._native.setAttribute('points', path);
} else
{
this._native.points.value = path;
}
}
};
web2d.peer.vml.PolyLinePeer.prototype._updateCurvePath = function()
{
if (core.Utils.isDefined(this._x1) && core.Utils.isDefined(this._x2) && core.Utils.isDefined(this._y1) && core.Utils.isDefined(this._y2))
{
var path = web2d.PolyLine.buildCurvedPath(this.breakDistance, this._x1, this._y1, this._x2, this._y2);
// Hack: I could not solve why this is happening...
if (!this._native.points)
{
this._native.setAttribute('points', path);
} else
{
this._native.points.value = path;
this._native.xPoints = path;
}
}
};
web2d.peer.vml.PolyLinePeer.prototype.setStroke = function(width, style, color, opacity)
{
web2d.peer.vml.LinePeer.superClass.setStroke.call(this, null, style, color, opacity);
if (core.Utils.isDefined(width))
{
this._vmlStroke.setAttribute('weight', width + "px");
}
};

View File

@@ -1,46 +0,0 @@
/*
* 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/NOTE-VML#_Toc416858381
* VML arcsize number "0.2"
* Defines rounded corners as a percentage of half the smaller dimension of the rectangle. 0.0 (0%)
* square corners, 1.0 (100%) - smaller dimension forms a semi-circle.
*/
web2d.peer.vml.RectPeer = function(arc)
{
this.__act = arc;
var vmlElement;
if (!arc)
{
vmlElement = window.document.createElement('v:rect');
} else
{
vmlElement = window.document.createElement('v:roundrect');
// In all examples, arc size 1 looks similiar to 0.5 arc size. This helps to solve look and feel incompatibilities with Fire
arc = arc / 2;
vmlElement.setAttribute('arcsize', arc);
}
web2d.peer.vml.ElementPeer.call(this, vmlElement);
this.attachChangeEventListener("onChangeCoordSize", web2d.peer.vml.ElementPeer.prototype._updateStrokeWidth);
};
objects.extend(web2d.peer.vml.RectPeer, web2d.peer.vml.ElementPeer);

View File

@@ -1,35 +0,0 @@
/*
* 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.vml.TahomaFont = function()
{
web2d.peer.vml.Font.call(this);
this._fontFamily="tahoma";
};
objects.extend(web2d.peer.vml.TahomaFont, web2d.peer.vml.Font);
web2d.peer.vml.TahomaFont.prototype.getFontFamily=function ()
{
return this._fontFamily;
};
web2d.peer.vml.TahomaFont.prototype.getFont=function ()
{
return web2d.Font.TAHOMA;
};

View File

@@ -1,235 +0,0 @@
/*
* 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.vml.TextBoxPeer = function()
{
var container = window.document.createElement('v:shape');
this._textElement = window.document.createElement('v:textbox');
web2d.peer.vml.ElementPeer.call(this, container);
this._native.appendChild(this._textElement);
this._container = window.document.createElement('span');
this._container.style.width = "100%";
this._container.style.height = "100%";
this._textContainer = window.document.createElement('span');
this._container.appendChild(this._textContainer);
this._textElement.appendChild(this._container);
container.style.position = "absolute";
container.style.top = "0";
container.style.left = "0";
container.style.width = "1";
container.style.height = "1";
container.style.antialias = "true";
container.style.zIndex = 10;
this._textElement.style.position = "absolute";
this._textElement.style.overflow = "visible";
this._textElement.inset = "0 0 0 0";
this.attachChangeEventListener("onChangeCoordSize", web2d.peer.vml.TextBoxPeer.prototype._updateTextSize);
this._font = new web2d.Font("Arial", this);
};
objects.extend(web2d.peer.vml.TextBoxPeer, web2d.peer.vml.ElementPeer);
web2d.peer.vml.TextBoxPeer.prototype._updateTextSize = function()
{
if (core.Utils.isDefined(this._font.getSize()))
{
this._updateFontStyle();
}
};
//todo: use ths method to specify the maximum size of the text box
/*web2d.web2d.peer.vml.TextBoxPeer.prototype.setSize = function(width, height)
{
web2d.web2d.peer.vml.TextBoxPeer.superClass.setSize.call(this,width,height);
this._native.setAttribute('rx', width / 2);
this._native.setAttribute('ry', height /ose 2);
};
*/
web2d.peer.vml.TextBoxPeer.prototype.appendChild = function(element)
{
this._native.appendChild(element._native);
};
web2d.peer.vml.TextBoxPeer.prototype.setText = function(text)
{
text = core.Utils.escapeInvalidTags(text);
//remove previous text
//var child = this._textContainer.firstChild;
var child = this._textContainer.firstChild;
if (child)
{
this._textContainer.removeChild(child);
}
this._text = text;
var textNode = window.document.createTextNode(text);
this._textContainer.appendChild(textNode);
this._updateSize();
};
web2d.peer.vml.TextBoxPeer.prototype.getText = function()
{
//todo(discutir): deberiamos buscar recursivamente por todos los hijos (textspan)?
return this._text;
};
web2d.peer.vml.TextBoxPeer.prototype._updateSize = function()
{
var size = 0;
if (this._font.getSize())
{
size = this._font.getSize();
}
var length = 0;
if (this._text)
{
length = this._text.length;
}
this._native.style.width = length * size;
//this._textElement.style.marginleft="0px";
};
web2d.peer.vml.TextBoxPeer.prototype.setPosition = function(x, y)
{
if (core.Utils.isDefined(x))
{
this._position.x = parseInt(x);
var leftmargin = 0;
//0.375;
this._native.style.left = x - leftmargin;
}
if (core.Utils.isDefined(y))
{
this._position.y = parseInt(y);
var topmargin = 0;
//2.375;
this._native.style.top = y - topmargin;
}
};
web2d.peer.vml.TextBoxPeer.prototype.setFont = function(font, size, style, weight)
{
if (core.Utils.isDefined(font))
{
this._font = new web2d.Font(font, this);
}
if (core.Utils.isDefined(style))
{
this._font.setStyle(style);
}
if (core.Utils.isDefined(weight))
{
this._font.setWeight(weight);
}
if (core.Utils.isDefined(size))
{
this._font.setSize(size);
}
this._updateFontStyle();
};
web2d.peer.vml.TextBoxPeer.prototype.setColor = function(color)
{
this._textElement.style.color = color;
};
web2d.peer.vml.TextBoxPeer.prototype.getColor = function()
{
return this._textElement.style.color;
};
web2d.peer.vml.TextBoxPeer.prototype.setTextSize = function (size)
{
this._font.setSize(size);
this._updateFontStyle();
};
web2d.peer.vml.TextBoxPeer.prototype.setStyle = function (style)
{
this._font.setStyle(style);
this._updateFontStyle();
};
web2d.peer.vml.TextBoxPeer.prototype.setWeight = function (weight)
{
this._font.setWeight(weight);
this._updateFontStyle();
};
web2d.peer.vml.TextBoxPeer.prototype.setSize = function (size)
{
this._font.setSize(size);
this._updateFontStyle();
};
web2d.peer.vml.TextBoxPeer.prototype.setFontFamily = function (family)
{
var oldFont = this._font;
this._font = new web2d.Font(family, this);
this._font.setSize(oldFont.getSize());
this._font.setStyle(oldFont.getStyle());
this._font.setWeight(oldFont.getWeight());
this._updateFontStyle();
};
web2d.peer.vml.TextBoxPeer.prototype._updateFontStyle = function ()
{
this._textElement.style.font = this._font.getStyle() + " " + this._font.getWeight() + " " + this._font.getGraphSize() + " " + this._font.getFontFamily();
this._updateSize();
var scale = this._font.getFontScale();
this._textElement.xFontScale = scale.toFixed(1);
};
web2d.peer.vml.TextBoxPeer.prototype.setContentSize = function(width, height)
{
this._textElement.xTextSize = width.toFixed(1) + "," + height.toFixed(1);
};
web2d.peer.vml.TextBoxPeer.prototype.getFont = function()
{
return {
font:this._font.getFont(),
size:parseInt(this._font.getSize()),
style:this._font.getStyle(),
weight:this._font.getWeight()
};
};
web2d.peer.vml.TextBoxPeer.prototype.getWidth = function ()
{
var scale = web2d.peer.utils.TransformUtil.workoutScale(this);
var size = (this._textContainer.offsetWidth / scale.width);
return size;
};
web2d.peer.vml.TextBoxPeer.prototype.getHeight = function ()
{
//return this._font.getGraphSize();
var scale = web2d.peer.utils.TransformUtil.workoutScale(this);
var size = (this._textContainer.offsetHeight / scale.height);
return size;
};
web2d.peer.vml.TextBoxPeer.prototype.getHtmlFontSize = function ()
{
return this._font.getHtmlSize();
};

View File

@@ -1,118 +0,0 @@
/*
* 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.vml.TextPeer = function()
{
var container = window.document.createElement('v:shape');
this._textElement = window.document.createElement('v:textpath');
web2d.peer.vml.ElementPeer.call(this, container);
this._native.appendChild(this._textElement);
container.style.position = "absolute";
container.style.top = "1";
container.style.left = "1";
container.style.width = "2";
container.style.height = "2";
container.style.antialias = "true";
container.style.zIndex = 10;
// Create the path object
var myPath = document.createElement("v:path");
myPath.textpathok = "True";
myPath.v = "m 0,0 l 10,0 m 0,20 l 10,20";
// Add it to the DOM hierarchy
container.appendChild(myPath);
// Create the fill object
this._fontColor = document.createElement("v:fill");
this._fontColor.on = "true";
this._fontColor.color = "red";
// Add it to the DOM hierarchy
container.appendChild(this._fontColor);
// The border is not going to be shown. To show it change .on to true
this._fontBorderColor = document.createElement("v:stroke");
this._fontBorderColor.on = "false";
this._fontBorderColor.color="red";
// Add it to the DOM hierarchy
container.appendChild(this._fontBorderColor);
this._textElement.on = "true";
this._textElement.fitpath = "false";
this._textElement.style.setAttribute("V-Text-Align","left");
this._size=12;
};
objects.extend(web2d.peer.vml.TextPeer, web2d.peer.vml.ElementPeer);
web2d.peer.vml.TextPeer.prototype.setPosition = function(x, y)
{
// VML position is positioned the coorner of the oval.
// That's why, I have to move the circle to the center by hand.
if (core.Utils.isDefined(x))
{
this._position.x = parseInt(x);
this._native.style.left = x;
}
if (core.Utils.isDefined(y))
{
this._position.y = parseInt(y);
this._native.style.top = y - parseInt(parseInt(this._size)/8);
}
};
web2d.peer.vml.TextPeer.prototype.getPosition = function()
{
return this._position;
};
web2d.peer.vml.TextPeer.prototype.appendChild = function(element)
{
this._textElement.appendChild(element._native);
};
web2d.peer.vml.TextPeer.prototype.setText = function(text)
{
this._text = text;
this._textElement.string=text;
};
web2d.peer.vml.TextPeer.prototype.getText = function()
{
return this._text;
};
web2d.peer.vml.TextPeer.prototype.setFont = function(font, size, style, weight)
{
var scale=web2d.peer.utils.TransformUtil.workoutScale(this);
this._size=parseInt(size)*scale.height*43/32;
this._textElement.style.font = style + " " + weight + " " + this._size + " " + font;
};
web2d.peer.vml.TextPeer.prototype.setColor = function(color)
{
this._fontColor.color=color;
this._fontBorderColor.color=color;
};
web2d.peer.vml.TextPeer.prototype.getHtmlFontSize = function ()
{
return this._font.getHtmlSize();
};

View File

@@ -1,35 +0,0 @@
/*
* 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.vml.TimesFont = function()
{
web2d.peer.vml.Font.call(this);
this._fontFamily="times";
};
objects.extend(web2d.peer.vml.TimesFont, web2d.peer.vml.Font);
web2d.peer.vml.TimesFont.prototype.getFontFamily=function ()
{
return this._fontFamily;
};
web2d.peer.vml.TimesFont.prototype.getFont=function ()
{
return web2d.Font.TIMES;
};

View File

@@ -1,35 +0,0 @@
/*
* 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.vml.VerdanaFont = function()
{
web2d.peer.vml.Font.call(this);
this._fontFamily="verdana";
};
objects.extend(web2d.peer.vml.VerdanaFont, web2d.peer.vml.Font);
web2d.peer.vml.VerdanaFont.prototype.getFontFamily=function ()
{
return this._fontFamily;
};
web2d.peer.vml.VerdanaFont.prototype.getFont=function ()
{
return web2d.Font.VERDANA;
};

View File

@@ -1,93 +0,0 @@
/*
* 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.vml.WorkspacePeer = function(element)
{
var vmlElement = window.document.createElement('v:group');
this._element = element;
web2d.peer.vml.ElementPeer.call(this, vmlElement);
};
objects.extend(web2d.peer.vml.WorkspacePeer, web2d.peer.vml.ElementPeer);
// Note: For some reason, VML groups are not able to receive events such as "onclick".
// As a workaround, all the workspace events will be registered in the container div element.
web2d.peer.vml.WorkspacePeer.prototype.getElementToAttachEvent = function()
{
return this._element;
};
web2d.peer.vml.WorkspacePeer.prototype.setCoordOrigin = function(x, y)
{
this._native.coordorigin = x + "," + y;
};
web2d.peer.vml.WorkspacePeer.prototype.setCoordSize = function(width, height)
{
this._native.coordsize = width + "," + height;
web2d.peer.utils.EventUtils.broadcastChangeEvent(this, "onChangeCoordSize");
//web2d.peer.utils.EventUtils.broadcastChangeEvent(this, "textSize");
};
web2d.peer.vml.WorkspacePeer.prototype.getCoordSize = function()
{
var coordSize = this._native.coordsize + "";
var coord;
if (coordSize)
{
coord = coordSize.split(",");
} else
{
coord = [1,1];
}
return { width:coord[0], height:coord[1] };
};
web2d.peer.vml.WorkspacePeer.prototype.setSize = function(width, height)
{
web2d.peer.vml.ElipsePeer.superClass.setSize.call(this, width, height);
};
web2d.peer.vml.WorkspacePeer.prototype.appendChild = function(child)
{
web2d.peer.vml.WorkspacePeer.superClass.appendChild.call(this, child);
web2d.peer.utils.EventUtils.broadcastChangeEvent(child, "onChangeCoordSize");
};
web2d.peer.vml.WorkspacePeer.prototype.getCoordOrigin = function()
{
var coordOrigin = this._native.coordorigin + "";
var coord;
if (coordOrigin)
{
coord = coordOrigin.split(",");
} else
{
coord = [1,1];
}
var y = parseFloat(coord[1]);
var x = parseFloat(coord[0]);
return { x:x, y:y };
};
web2d.peer.vml.WorkspacePeer.prototype.getPosition = function()
{
return {x:0,y:0};
};