Remove trunk directory

This commit is contained in:
Paulo Gustavo Veiga
2009-11-06 23:30:29 -02:00
parent 2494133fed
commit 75470a91fd
715 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,362 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
web2d.Element = function(peer, attributes)
{
this._peer = peer;
if (peer == null)
{
throw "Element peer can not be null";
}
this._dispatcherByEventType = new Hash({});
if (core.Utils.isDefined(attributes))
{
this._initialize(attributes);
}
};
web2d.Element.prototype._SIGNATURE_MULTIPLE_ARGUMENTS = -1;
web2d.Element.prototype._initialize = function(attributes)
{
var batchExecute = {};
// Collect arguments ...
for (var key in attributes)
{
var funcName = this._attributeNameToFuncName(key, 'set');
var funcArgs = batchExecute[funcName];
if (!funcArgs)
{
funcArgs = [];
}
var signature = this._propertyNameToSignature[key];
var argPositions = signature[1];
if (argPositions != this._SIGNATURE_MULTIPLE_ARGUMENTS)
{
funcArgs[argPositions] = attributes[key];
} else
{
funcArgs = attributes[key].split(' ');
}
batchExecute[funcName] = funcArgs;
}
// Call functions ...
for (var key in batchExecute)
{
var func = this[key];
if (!func)
{
throw "Could not find function: " + key;
}
func.apply(this, batchExecute[key]);
}
};
web2d.Element.prototype.setSize = function(width, height)
{
this._peer.setSize(width, height);
};
web2d.Element.prototype.setPosition = function(cx, cy)
{
this._peer.setPosition(cx, cy);
};
web2d.Element.prototype._supportedEvents = ["click","dblclick","mousemove","mouseout","mouseover","mousedown","mouseup"];
/**
* Allows the registration of event listeners on the event target.
* type
* A string representing the event type to listen for.
* listener
* The object that receives a notification when an event of the specified type occurs. This must be an object implementing the EventListener interface, or simply a function in JavaScript.
*
* The following events types are supported:
*
*/
web2d.Element.prototype.addEventListener = function(type, listener)
{
if (!this._supportedEvents.include(type))
{
throw "Unsupported event type: " + type;
}
// Concat previous event listeners for a given type.
if (!this._dispatcherByEventType[type])
{
this._dispatcherByEventType[type] = new web2d.EventDispatcher(this);
var eventListener = this._dispatcherByEventType[type].eventListener;
this._peer.addEventListener(type, eventListener);
}
this._dispatcherByEventType[type].addListener(type, listener);
};
/**
*
* Allows the removal of event listeners from the event target.
*
* Parameters:
* type
* A string representing the event type being registered.
* 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.removeEventListener = function(type, listener)
{
var dispatcher = this._dispatcherByEventType[type];
if (dispatcher == null)
{
throw "There is no listener previously registered";
}
var result = dispatcher.removeListener(type, listener);
// If there is not listeners, EventDispatcher must be removed.
if (dispatcher.getListenersCount() <= 0)
{
this._peer.removeEventListener(type, dispatcher.eventListener);
this._dispatcherByEventType[type] = null;
}
};
/**
* /*
* Returns element type name.
*/
web2d.Element.prototype.getType = function()
{
throw "Not implemeneted yet. This method must be implemented by all the inherited objects.";
};
/**
* Todo: Doc
*/
web2d.Element.prototype.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)
{
this._peer.setFill(color, opacity);
};
web2d.Element.prototype.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)
{
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 =
{
// Format: [attribute name, argument position on setter, attribute name on getter]
size: ['size',-1],
width: ['size',0,'width'],
height: ['size',1,'height'],
position: ['position',-1],
x: ['position',0,'x'],
y: ['position',1,'y'],
stroke:['stroke',-1],
strokeWidth:['stroke',0,'width'],
strokeStyle:['stroke',1,'style'],
strokeColor:['stroke',2,'color'],
strokeOpacity:['stroke',3,'opacity'],
fill:['fill',-1],
fillColor:['fill',0,'color'],
fillOpacity:['fill',1,'opacity'],
coordSize:['coordSize',-1],
coordSizeWidth:['coordSize',0,'width'],
coordSizeHeight:['coordSize',1,'height'],
coordOrigin:['coordOrigin',-1],
coordOriginX:['coordOrigin',0,'x'],
coordOriginY:['coordOrigin',1,'y'],
visibility:['visibility',0],
opacity:['opacity',0]
};
web2d.Element.prototype._attributeNameToFuncName = function(attributeKey, prefix)
{
var signature = this._propertyNameToSignature[attributeKey];
if (!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 (!attibuteName)
{
throw "Could not find attribute mapping for:" + key;
}
var result = getterResult[attibuteName];
if (!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

@@ -0,0 +1,43 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
web2d.Elipse = 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)
{
defaultAttributes[key] = attributes[key];
}
web2d.Element.call(this, peer, defaultAttributes);
};
objects.extend(web2d.Elipse, web2d.Element);
web2d.Elipse.prototype.getType = function()
{
return "Elipse";
};
/**
* @Todo: Complete Doc
*/
web2d.Elipse.prototype.getSize = function()
{
return this._peer.getSize();
};

View File

@@ -0,0 +1,84 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
web2d.EventDispatcher = function(element)
{
this._listeners = [];
var dispatcher = this;
this.eventListener = function(event)
{
for (var i = 0; i < dispatcher._listeners.length; i++)
{
if (dispatcher._listeners[i] != null)
{
dispatcher._listeners[i].call(element, event || window.event);
}
}
};
};
web2d.EventDispatcher.prototype.addListener = function(type, listener)
{
if (!listener)
{
throw "Listener can not be null.";
}
this._listeners.include(listener);
};
web2d.EventDispatcher.prototype.removeListener = function(type, listener)
{
if (!listener)
{
throw "Listener can not be null.";
}
// var found = false;
var length = this._listeners.length;
this._listeners.remove(listener);
var newLength = this._listeners.length;
if (newLength >= length)
{
throw "There is not listener to remove";
}
/*this._listeners = this._listeners.reject(function(iter)
{
if (iter == listener)
{
found = true;
}
return iter == listener;
});
// Could I remove any listener ?
if (!found)
{
throw "There is not listener to remove";
}*/
};
web2d.EventDispatcher.prototype.getListenersCount = function()
{
return this._listeners.length;
};

View File

@@ -0,0 +1,94 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
web2d.Font = function(fontFamily, textPeer)
{
var font = "web2d.peer.Toolkit.create" + fontFamily + "Font();";
this._peer = eval(font);
this._textPeer = textPeer;
};
web2d.Font.prototype.getHtmlSize = function ()
{
var scale = web2d.peer.utils.TransformUtil.workoutScale(this._textPeer);
return this._peer.getHtmlSize(scale);
};
web2d.Font.prototype.getGraphSize = function ()
{
var scale = web2d.peer.utils.TransformUtil.workoutScale(this._textPeer);
return this._peer.getGraphSize(scale);
};
web2d.Font.prototype.getFontScale = function ()
{
return web2d.peer.utils.TransformUtil.workoutScale(this._textPeer).height;
};
web2d.Font.prototype.getSize = function ()
{
return this._peer.getSize();
};
web2d.Font.prototype.getStyle = function ()
{
return this._peer.getStyle();
};
web2d.Font.prototype.getWeight = function ()
{
return this._peer.getWeight();
};
web2d.Font.prototype.getFontFamily = function ()
{
return this._peer.getFontFamily();
};
web2d.Font.prototype.setSize = function (size)
{
return this._peer.setSize(size);
};
web2d.Font.prototype.setStyle = function (style)
{
return this._peer.setStyle(style);
};
web2d.Font.prototype.setWeight = function (weight)
{
return this._peer.setWeight(weight);
};
web2d.Font.prototype.getFont = function ()
{
return this._peer.getFont();
};
web2d.Font.prototype.getWidthMargin = function ()
{
return this._peer.getWidthMargin();
};
web2d.Font.ARIAL = "Arial";
web2d.Font.TIMES = "Times";
web2d.Font.TAHOMA = "Tahoma";
web2d.Font.VERDANA = "Verdana";

View File

@@ -0,0 +1,159 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
/**
* A group object can be used to collect shapes.
*/
web2d.Group = 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)
{
defaultAttributes[key] = attributes[key];
}
web2d.Element.call(this, peer, defaultAttributes);
};
objects.extend(web2d.Group, web2d.Element);
/**
* Remove an element as a child to the object.
*/
web2d.Group.prototype.removeChild = function(element)
{
if (!element)
{
throw "Child element can not be null";
}
if (element == this)
{
throw "It's not posible to add the group as a child of itself";
}
var elementType = element.getType();
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 (!element)
{
throw "Child element can not be null";
}
if (element == this)
{
throw "It's not posible to add the group as a child of itself";
}
var elementType = element.getType();
if (elementType == null)
{
throw "It seems not to be an element ->" + element;
}
if (elementType == "Workspace")
{
throw "A group can not have a workspace as a child";
}
this._peer.appendChild(element._peer);
};
web2d.Group.prototype.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)
{
this._peer.setCoordSize(width, height);
};
web2d.Group.prototype.getCoordSize = function(){
return this.peer.getCoordSize();
};
/**
* @Todo: Complete Doc
*/
web2d.Group.prototype.setCoordOrigin = function(x, y)
{
this._peer.setCoordOrigin(x, y);
};
web2d.Group.prototype.getCoordOrigin = function(){
return this._peer.getCoordOrigin();
};
/**
* @Todo: Complete Doc
*/
web2d.Group.prototype.getSize = function()
{
return this._peer.getSize();
};
web2d.Group.prototype.setFill = function(color, opacity)
{
throw "Unsupported operation. Fill can not be set to a group";
};
web2d.Group.prototype.setStroke = function(width, style, color, opacity)
{
throw "Unsupported operation. Stroke can not be set to a group";
};
web2d.Group.prototype.getCoordSize = function()
{
return this._peer.getCoordSize();
};
web2d.Group.prototype.appendDomChild = function(DomElement)
{
if (!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";
}
this._peer._native.appendChild(DomElement);
};

View File

@@ -0,0 +1,44 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
web2d.Image = function(attributes)
{
var peer = web2d.peer.Toolkit.createImage();
web2d.Element.call(this, peer, attributes);
};
objects.extend(web2d.Image, web2d.Element);
web2d.Image.prototype.getType = function()
{
return "Image";
};
web2d.Image.prototype.setHref = function(href)
{
this._peer.setHref(href);
};
web2d.Image.prototype.getHref = function()
{
return this._peer.getHref();
};
web2d.Image.prototype.getSize = function()
{
return this._peer.getSize();
};

View File

@@ -0,0 +1,17 @@
- El Logger se come el procesador en Firefox. En el ejemplo del group.html si pones un logger que haga print de
algo periodico se cuelga el Firefox.
- Seria bueno que el tookit se inicialice bajo demanda, sin la necesidad de hacerlo por el usuario.
- Workspace setStroke fixiar los styles.
- Implementar setArrowStyle de svg en caso de ser necesario.
* Las funciones deben soportar el pasar objetos.?
- Delete isolated Node, throws an exception.
Test:
* Remove children.
* opacity,visibility

View File

@@ -0,0 +1,69 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
web2d.Line = function(attributes)
{
var peer = web2d.peer.Toolkit.createLine();
var defaultAttributes = {strokeColor:'#495879',strokeWidth:1};
for (var key in attributes)
{
defaultAttributes[key] = attributes[key];
}
web2d.Element.call(this, peer, defaultAttributes);
};
objects.extend(web2d.Line, web2d.Element);
web2d.Line.prototype.getType = function()
{
return "Line";
};
web2d.Line.prototype.setFrom = function(x, y)
{
this._peer.setFrom(x, y);
};
web2d.Line.prototype.setTo = function(x, y)
{
this._peer.setTo(x, y);
};
/**
* 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)
{
this._peer.setArrowStyle(startStyle, endStyle);
};
web2d.Line.prototype.setPosition = function(cx, cy)
{
throw "Unsupported operation";
};
web2d.Line.prototype.setSize = function(width, height)
{
throw "Unsupported operation";
};
web2d.Line.prototype.setFill = function(color, opacity)
{
throw "Unsupported operation";
};

View File

@@ -0,0 +1,89 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
web2d.PolyLine = function(attributes)
{
var peer = web2d.peer.Toolkit.createPolyLine();
var defaultAttributes = {strokeColor:'blue',strokeWidth:1,strokeStyle:'solid',strokeOpacity:1};
for (var key in attributes)
{
defaultAttributes[key] = attributes[key];
}
web2d.Element.call(this, peer, defaultAttributes);
};
objects.extend(web2d.PolyLine, web2d.Element);
web2d.PolyLine.prototype.getType = function()
{
return "PolyLine";
};
web2d.PolyLine.prototype.setFrom = function(x, y)
{
this._peer.setFrom(x, y);
};
web2d.PolyLine.prototype.setTo = function(x, y)
{
this._peer.setTo(x, y);
};
web2d.PolyLine.prototype.setStyle = function(style)
{
this._peer.setStyle(style);
};
web2d.PolyLine.prototype.getStyle = function()
{
return this._peer.getStyle();
};
web2d.PolyLine.buildCurvedPath = function(dist, x1, y1, x2, y2)
{
var signx = 1;
var signy = 1;
if (x2 < x1)
{
signx = -1;
}
if (y2 < y1)
{
signy = -1;
}
var path;
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
{
path = x1.toFixed(1) + ", " + y1.toFixed(1) + " " + x2.toFixed(1) + ", " + y2.toFixed(1);
}
return path;
};
web2d.PolyLine.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

@@ -0,0 +1,59 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
/**
* Create a rectangle and variations of a rectangle shape.
* arc must be specified to create rounded rectangles.
* 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)
{
throw "Arc must be 0<=arc<=1";
}
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)
{
defaultAttributes[key] = attributes[key];
}
web2d.Element.call(this, peer, defaultAttributes);
};
objects.extend(web2d.Rect, web2d.Element);
web2d.Rect.prototype.getType = function()
{
return "Rect";
};
/**
* @Todo: Complete Doc
*/
web2d.Rect.prototype.getSize = function()
{
return this._peer.getSize();
};

View File

@@ -0,0 +1,100 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
web2d.Text = function(attributes)
{
var peer = web2d.peer.Toolkit.createText();
web2d.Element.call(this, peer, attributes);
};
objects.extend(web2d.Text, web2d.Element);
web2d.Text.prototype.getType = function()
{
return "Text";
};
web2d.Text.prototype.setText = function(text)
{
this._peer.setText(text);
};
web2d.Text.prototype.setTextSize = function(width, height)
{
this._peer.setContentSize(width, height);
};
web2d.Text.prototype.getText = function()
{
return this._peer.getText();
};
web2d.Text.prototype.setFont = function(font, size, style, weight)
{
this._peer.setFont(font, size, style, weight);
};
web2d.Text.prototype.setColor = function(color)
{
this._peer.setColor(color);
};
web2d.Text.prototype.getColor = function()
{
return this._peer.getColor();
};
web2d.Text.prototype.setStyle = function(style)
{
this._peer.setStyle(style);
};
web2d.Text.prototype.setWeight = function(weight)
{
this._peer.setWeight(weight);
};
web2d.Text.prototype.setFontFamily = function(family)
{
this._peer.setFontFamily(family);
};
web2d.Text.prototype.getFont = function()
{
return this._peer.getFont();
};
web2d.Text.prototype.setSize = function(size)
{
this._peer.setSize(size);
};
web2d.Text.prototype.getHtmlFontSize = function()
{
return this._peer.getHtmlFontSize();
};
web2d.Text.prototype.getWidth = function()
{
return this._peer.getWidth();
};
web2d.Text.prototype.getHeight = function()
{
return parseInt(this._peer.getHeight());
};

View File

@@ -0,0 +1,174 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
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();
},
createPolyLine: function()
{
return new web2d.peer.vml.PolyLinePeer();
},
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()
{
},
createWorkspace: function(element)
{
return new web2d.peer.svg.WorkspacePeer(element);
},
createGroup: function(element)
{
return new web2d.peer.svg.GroupPeer();
},
createElipse: function()
{
return new web2d.peer.svg.ElipsePeer();
},
createLine: function()
{
return new web2d.peer.svg.LinePeer();
},
createPolyLine: function()
{
return new web2d.peer.svg.PolyLinePeer();
},
createText: function ()
{
return new web2d.peer.svg.TextPeer();
},
createImage: function ()
{
return new web2d.peer.svg.ImagePeer();
},
createRect: function(arc)
{
return new web2d.peer.svg.RectPeer(arc);
},
createArialFont: function()
{
return new web2d.peer.svg.ArialFont();
},
createTimesFont: function()
{
return new web2d.peer.svg.TimesFont();
},
createVerdanaFont: function()
{
return new web2d.peer.svg.VerdanaFont();
},
createTahomaFont: function()
{
return new web2d.peer.svg.TahomaFont();
}
};
if (core.UserAgent.isSVGSupported())
{
web2d.peer.Toolkit = web2d.peer.ToolkitSVG;
} else
{
web2d.peer.Toolkit = web2d.peer.ToolkitVML;
}

View File

@@ -0,0 +1,260 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
web2d.Workspace = 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)
{
defaultAttributes[key] = attributes[key];
}
web2d.Element.call(this, peer, defaultAttributes);
this._htmlContainer.appendChild(this._peer._native);
this._disableTextSelection();
};
objects.extend(web2d.Workspace, web2d.Element);
/**
* Avoid element selection. This remove some odd effect in IE when a element is draged.
*/
web2d.Workspace.prototype._disableTextSelection = function()
{
var contaier = this._htmlContainer;
function disabletext(e) {
return false;
}
;
function reEnable() {
return true;
}
;
//if the browser is IE4+
contaier.onselectstart = new Function("return false");
//if the browser is NS6
if (window.sidebar)
{
contaier.onmousedown = disabletext;
contaier.onclick = reEnable;
}
;
};
web2d.Workspace.prototype.getType = function()
{
return "Workspace";
};
/**
* Appends an element as a child to the object.
*/
web2d.Workspace.prototype.appendChild = function(element)
{
if (!element)
{
throw "Child element can not be null";
}
var elementType = element.getType();
if (elementType == null)
{
throw "It seems not to be an element ->" + element;
}
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 (!element)
{
throw "Workspace div container can not be null";
}
element.appendChild(this._htmlContainer);
};
/**
* Create a new div element that will be resposible for containing the workspace elements.
*/
web2d.Workspace.prototype._createDivContainer = function(domElement)
{
var container = window.document.createElement("div");
container.id = "workspaceContainer";
container.style.overflow = "hidden";
container.style.position = "relative";
container.style.top = "0px";
container.style.left = "0px";
container.style.height = "688px";
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)
* mm (millimeters)
* pt (points; 1pt=1/72in)
* pc (picas; 1pc=12pt)
*/
web2d.Workspace.prototype.setSize = function(width, height)
{
// HTML container must have the size of the group element.
if (core.Utils.isDefined(width))
{
this._htmlContainer.style.width = width;
}
if (core.Utils.isDefined(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)
{
this._peer.setCoordSize(width, height);
};
/**
* @Todo: Complete Doc
*/
web2d.Workspace.prototype.setCoordOrigin = function(x, y)
{
this._peer.setCoordOrigin(x, y);
};
/**
* @Todo: Complete Doc
*/
web2d.Workspace.prototype.getCoordOrigin = function()
{
return this._peer.getCoordOrigin();
};
// Private method declaration area
/**
* All the VML or SVG elements will be children of this HTML element.
*/
web2d.Workspace.prototype._getHtmlContainer = function()
{
return this._htmlContainer;
};
web2d.Workspace.prototype.setFill = function(color, opacity)
{
this._htmlContainer.style.backgroundColor = color;
if (opacity || opacity === 0)
{
throw "Unsupported operation. Opacity not supported.";
}
};
web2d.Workspace.prototype.getFill = function()
{
var color = this._htmlContainer.style.backgroundColor;
return {color:color};
};
/**
* @Todo: Complete Doc
*/
web2d.Workspace.prototype.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')
{
throw 'Not supported style stroke style:' + style;
}
this._htmlContainer.style.border = width + ' ' + style + ' ' + color;
if (opacity || opacity === 0)
{
throw "Unsupported operation. Opacity not supported.";
}
};
web2d.Workspace.prototype.getCoordSize = function()
{
return this._peer.getCoordSize();
};
/**
* Remove an element as a child to the object.
*/
web2d.Workspace.prototype.removeChild = function(element)
{
if (!element)
{
throw "Child element can not be null";
}
if (element == this)
{
throw "It's not posible to add the group as a child of itself";
}
var elementType = element.getType();
if (elementType == null)
{
throw "It seems not to be an element ->" + element;
}
this._peer.removeChild(element._peer);
};
web2d.Workspace.prototype.dumpNativeChart = function()
{
var elem = this._htmlContainer
return elem.innerHTML;
};

View File

@@ -0,0 +1,26 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
var web2d = {};
web2d.peer =
{
svg: {},
vml: {}
};
web2d.peer.utils = {};

View File

@@ -0,0 +1,36 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
web2d.peer.svg.ArialFont = function()
{
web2d.peer.svg.Font.call(this);
this._fontFamily="Arial";
};
objects.extend(web2d.peer.svg.ArialFont, web2d.peer.svg.Font);
web2d.peer.svg.ArialFont.prototype.getFontFamily=function ()
{
return this._fontFamily;
};
web2d.peer.svg.ArialFont.prototype.getFont=function ()
{
return web2d.Font.ARIAL;
};

View File

@@ -0,0 +1,311 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
web2d.peer.svg.ElementPeer = function(svgElement)
{
this._native = svgElement;
this._dblClickListeners = new Hash();
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)
{
this._children = children;
};
web2d.peer.svg.ElementPeer.prototype.getChildren = function()
{
var result = this._children;
if (!result)
{
result = [];
this._children = result;
}
return result;
};
web2d.peer.svg.ElementPeer.prototype.getParent = function()
{
return this._parent;
};
web2d.peer.svg.ElementPeer.prototype.setParent = function(parent)
{
this._parent = parent;
};
web2d.peer.svg.ElementPeer.prototype.appendChild = function(elementPeer)
{
// Store parent and child relationship.
elementPeer.setParent(this);
var children = this.getChildren();
children.include(elementPeer);
// Append element as a child.
this._native.appendChild(elementPeer._native);
// Broadcast events ...
web2d.peer.utils.EventUtils.broadcastChangeEvent(this, "strokeStyle");
};
web2d.peer.svg.ElementPeer.prototype.removeChild = function(elementPeer)
{
// Store parent and child relationship.
elementPeer.setParent(null);
var children = this.getChildren();
// Remove from children array ...
var length = children.length;
children.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);
};
/**
* http://www.w3.org/TR/DOM-Level-3-Events/events.html
* http://developer.mozilla.org/en/docs/addEventListener
*/
web2d.peer.svg.ElementPeer.prototype.addEventListener = function(type, listener)
{
if (type == 'dblclick')
{
// This is workaround to support double click...
var dblListener = function(e)
{
if (e.detail >= 2)
{
listener.call(this, e);
}
};
this._dblClickListeners[listener] = dblListener;
this._native.addEventListener(type, dblListener, false);
} else
{
this._native.addEventListener(type, listener, false);
}
};
web2d.peer.svg.ElementPeer.prototype.removeEventListener = function(type, listener)
{
if (type == 'dblclick')
{
// This is workaround to support double click...
var dblClickListener = this._dblClickListeners[listener];
if (dblClickListener == null)
{
throw "Could not find listener to remove";
}
type = 'click';
this._native.removeEventListener(type, dblClickListener, false);
delete this._dblClickListeners[listener];
} else
{
this._native.removeEventListener(type, listener, false);
}
};
web2d.peer.svg.ElementPeer.prototype.setSize = function(width, height)
{
if (core.Utils.isDefined(width))
{
this._size.width = parseInt(width);
this._native.setAttribute('width', parseInt(width));
}
if (core.Utils.isDefined(height))
{
this._size.height = parseInt(height);
this._native.setAttribute('height', parseInt(height));
}
web2d.peer.utils.EventUtils.broadcastChangeEvent(this, "strokeStyle");
};
web2d.peer.svg.ElementPeer.prototype.getSize = function()
{
return {width:this._size.width,height:this._size.height};
};
web2d.peer.svg.ElementPeer.prototype.setFill = function(color, opacity)
{
if (core.Utils.isDefined(color))
{
this._native.setAttribute('fill', color);
}
if (core.Utils.isDefined(opacity))
{
this._native.setAttribute('fill-opacity', opacity);
}
};
web2d.peer.svg.ElementPeer.prototype.getFill = function()
{
var color = this._native.getAttribute('fill');
var opacity = this._native.getAttribute('fill-opacity');
return {color:color, opacity:Number(opacity)};
};
web2d.peer.svg.ElementPeer.prototype.getStroke = function()
{
var vmlStroke = this._native;
var color = vmlStroke.getAttribute('stroke');
var dashstyle = this._stokeStyle;
var opacity = vmlStroke.getAttribute('stroke-opacity');
var width = vmlStroke.getAttribute('stroke-width');
return {color: color, style: dashstyle, opacity: opacity, width: width};
};
web2d.peer.svg.ElementPeer.prototype.__stokeStyleToStrokDasharray = {solid:[],dot:[1,3],dash:[4,3],longdash:[10,2],dashdot:[5,3,1,3]};
web2d.peer.svg.ElementPeer.prototype.setStroke = function(width, style, color, opacity)
{
if (core.Utils.isDefined(width))
{
this._native.setAttribute('stroke-width', width + "px");
}
if (core.Utils.isDefined(color))
{
this._native.setAttribute('stroke', color);
}
if (core.Utils.isDefined(style))
{
// Scale the dash array in order to be equal to VML. In VML, stroke style doesn't scale.
var dashArrayPoints = this.__stokeStyleToStrokDasharray[style];
var scale = 1 / web2d.peer.utils.TransformUtil.workoutScale(this).width;
var strokeWidth = this._native.getAttribute('stroke-width');
strokeWidth = parseFloat(strokeWidth);
var scaledPoints = [];
for (var i = 0; i < dashArrayPoints.length; i++)
{
// VML scale the stroke based on the stroke width.
scaledPoints[i] = dashArrayPoints[i] * strokeWidth;
// Scale the points based on the scale.
scaledPoints[i] = (scaledPoints[i] * scale) + "px";
}
// this._native.setAttribute('stroke-dasharray', scaledPoints);
this._stokeStyle = style;
}
if (core.Utils.isDefined(opacity))
{
this._native.setAttribute('stroke-opacity', opacity);
}
};
/*
* style='visibility: visible'
*/
web2d.peer.svg.ElementPeer.prototype.setVisibility = function(isVisible)
{
this._native.setAttribute('visibility', (isVisible) ? 'visible' : 'hidden');
};
web2d.peer.svg.ElementPeer.prototype.isVisible = function()
{
var visibility = this._native.getAttribute('visibility');
return !(visibility == 'hidden');
};
web2d.peer.svg.ElementPeer.prototype.updateStrokeStyle = function()
{
var strokeStyle = this._stokeStyle;
if (this.getParent())
{
if (strokeStyle && strokeStyle != 'solid')
{
this.setStroke(null, strokeStyle);
}
}
};
web2d.peer.svg.ElementPeer.prototype.attachChangeEventListener = function(type, listener)
{
var listeners = this.getChangeEventListeners(type);
if (!listener)
{
throw "Listener can not be null";
}
listeners.push(listener);
};
web2d.peer.svg.ElementPeer.prototype.getChangeEventListeners = function(type)
{
var listeners = this._changeListeners[type];
if (!listeners)
{
listeners = [];
this._changeListeners[type] = listeners;
}
return listeners;
};
/**
* Move element to the front
*/
web2d.peer.svg.ElementPeer.prototype.moveToFront = function()
{
this._native.parentNode.appendChild(this._native);
};
/**
* Move element to the back
*/
web2d.peer.svg.ElementPeer.prototype.moveToBack = function()
{
this._native.parentNode.insertBefore(this._native, this._native.parentNode.firstChild);
};
web2d.peer.svg.ElementPeer.prototype.setCursor = function(type)
{
this._native.style.cursor = type;
};

View File

@@ -0,0 +1,67 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
web2d.peer.svg.ElipsePeer = function()
{
var svgElement = window.document.createElementNS(this.svgNamespace, 'ellipse');
web2d.peer.svg.ElementPeer.call(this, svgElement);
this.attachChangeEventListener("strokeStyle", web2d.peer.svg.ElementPeer.prototype.updateStrokeStyle);
this._position={x:0, y:0};
};
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 (core.Utils.isDefined(width))
{
this._native.setAttribute('rx', width / 2);
}
if (core.Utils.isDefined(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 (core.Utils.isDefined(cx))
{
this._native.setAttribute('cx', cx);
}
if (core.Utils.isDefined(cy))
{
this._native.setAttribute('cy', cy);
}
};
web2d.peer.svg.ElipsePeer.prototype.getPosition = function()
{
return this._position;
};

View File

@@ -0,0 +1,109 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
web2d.peer.svg.Font = function()
{
this._size = 10;
this._style = "normal";
this._weight = "normal";
};
web2d.peer.svg.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.svg.Font.prototype.getHtmlSize = function (scale)
{
var result = 0;
if (this._size == 6)
{
result = this._size * scale.height * 43 / 32;
}
if (this._size == 8)
{
result = this._size * scale.height * 42 / 32;
}
else if (this._size == 10)
{
result = this._size * scale.height * 42 / 32;
}
else if (this._size == 15)
{
result = this._size * scale.height * 42 / 32;
}
return result;
};
web2d.peer.svg.Font.prototype.getGraphSize = function (scale)
{
return this._size * 43 / 32;
};
web2d.peer.svg.Font.prototype.getSize = function ()
{
return parseInt(this._size);
};
web2d.peer.svg.Font.prototype.getStyle = function ()
{
return this._style;
};
web2d.peer.svg.Font.prototype.getWeight = function ()
{
return this._weight;
};
web2d.peer.svg.Font.prototype.setSize = function (size)
{
this._size = size;
};
web2d.peer.svg.Font.prototype.setStyle = function (style)
{
this._style = style;
};
web2d.peer.svg.Font.prototype.setWeight = function (weight)
{
this._weight = weight;
};
web2d.peer.svg.Font.prototype.getWidthMargin = function ()
{
var result = 0;
if (this._size == 10 || this._size == 6)
{
result = 4;
}
return result;
};

View File

@@ -0,0 +1,131 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
web2d.peer.svg.GroupPeer = function()
{
var svgElement = window.document.createElementNS(this.svgNamespace, 'g');
web2d.peer.svg.ElementPeer.call(this, svgElement);
this._native.setAttribute("preserveAspectRatio", "none");
this._coordSize = {width:1,height:1};
this._native.setAttribute("focusable","true");
this._position = {x:0,y:0};
this._coordOrigin = {x:0,y:0};
};
objects.extend(web2d.peer.svg.GroupPeer, web2d.peer.svg.ElementPeer);
/*web2d.peer.svg.GroupPeer.prototype.setPosition = function(cx, cy)
{
this._native.setAttribute("transform", "translate(" + parseInt(cx) + " " + parseInt(cy) + ")");
};*/
web2d.peer.svg.GroupPeer.prototype.setCoordSize = function(width, height)
{
this._coordSize.width = width;
this._coordSize.height = height;
this.updateTransform();
web2d.peer.utils.EventUtils.broadcastChangeEvent(this, "strokeStyle");
};
web2d.peer.svg.GroupPeer.prototype.getCoordSize = function()
{
return {width:this._coordSize.width,height:this._coordSize.height};
};
/**
* http://www.w3.org/TR/SVG/coords.html#TransformAttribute
* 7.6 The transform attribute
*
* The value of the transform attribute is a <transform-list>, which is defined as a list of transform definitions, which are applied in the order provided. The individual transform definitions are separated by whitespace and/or a comma. The available types of transform definitions include:
*
* * matrix(<a> <b> <c> <d> <e> <f>), which specifies a transformation in the form of a transformation matrix of six values. matrix(a,b,c,d,e,f) is equivalent to applying the transformation matrix [a b c d e f].
*
* * translate(<tx> [<ty>]), which specifies a translation by tx and ty. If <ty> is not provided, it is assumed to be zero.
*
* * scale(<sx> [<sy>]), which specifies a scale operation by sx and sy. If <sy> is not provided, it is assumed to be equal to <sx>.
*
* * rotate(<rotate-angle> [<cx> <cy>]), which specifies a rotation by <rotate-angle> degrees about a given point.
* If optional parameters <cx> and <cy> are not supplied, the rotate is about the origin of the current user coordinate system. The operation corresponds to the matrix [cos(a) sin(a) -sin(a) cos(a) 0 0].
* If optional parameters <cx> and <cy> are supplied, the rotate is about the point (<cx>, <cy>). The operation represents the equivalent of the following specification: translate(<cx>, <cy>) rotate(<rotate-angle>) translate(-<cx>, -<cy>).
*
* * skewX(<skew-angle>), which specifies a skew transformation along the x-axis.
*
* * skewY(<skew-angle>), which specifies a skew transformation along the y-axis.
**/
web2d.peer.svg.GroupPeer.prototype.updateTransform = function()
{
var sx = this._size.width / this._coordSize.width;
var sy = this._size.height / this._coordSize.height;
var cx = this._position.x - this._coordOrigin.x * sx;
var cy = this._position.y - this._coordOrigin.y * sy;
this._native.setAttribute("transform", "translate(" + cx + "," + cy + ") scale(" + sx + "," + sy + ")");
};
web2d.peer.svg.GroupPeer.prototype.setCoordOrigin = function(x, y)
{
if (core.Utils.isDefined(x))
{
this._coordOrigin.x = x;
}
if (core.Utils.isDefined(y))
{
this._coordOrigin.y = y;
}
this.updateTransform();
};
web2d.peer.svg.GroupPeer.prototype.setSize = function(width, height)
{
web2d.peer.svg.GroupPeer.superClass.setSize.call(this, width, height);
this.updateTransform();
};
web2d.peer.svg.GroupPeer.prototype.setPosition = function(x, y)
{
if (core.Utils.isDefined(x))
{
this._position.x = parseInt(x);
}
if (core.Utils.isDefined(y))
{
this._position.y = parseInt(y);
}
this.updateTransform();
};
web2d.peer.svg.GroupPeer.prototype.getPosition = function()
{
return {x:this._position.x,y:this._position.y};
};
web2d.peer.svg.GroupPeer.prototype.appendChild = function(child)
{
web2d.peer.svg.GroupPeer.superClass.appendChild.call(this, child);
web2d.peer.utils.EventUtils.broadcastChangeEvent(child, "onChangeCoordSize");
};
web2d.peer.svg.GroupPeer.prototype.getCoordOrigin = function ()
{
return {x:this._coordOrigin.x, y:this._coordOrigin.y};
};

View File

@@ -0,0 +1,52 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
web2d.peer.svg.ImagePeer = function()
{
var svgElement = window.document.createElementNS(this.svgNamespace, 'image');
web2d.peer.svg.ElementPeer.call(this, svgElement);
this._position = {x:0,y:0};
this._href="";
};
objects.extend(web2d.peer.svg.ImagePeer, web2d.peer.svg.ElementPeer);
web2d.peer.svg.ImagePeer.prototype.setPosition = function(x, y)
{
this._position = {x:x, y:y};
this._native.setAttribute('y', y);
this._native.setAttribute('x', x);
};
web2d.peer.svg.ImagePeer.prototype.getPosition = function()
{
return this._position;
};
web2d.peer.svg.ImagePeer.prototype.setHref = function(url)
{
this._native.setAttributeNS(this.linkNamespace, "href", url);
this._href = url;
};
web2d.peer.svg.ImagePeer.prototype.getHref = function()
{
return this._href;
};

View File

@@ -0,0 +1,55 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
web2d.peer.svg.LinePeer = function()
{
var svgElement = window.document.createElementNS(this.svgNamespace, 'line');
web2d.peer.svg.ElementPeer.call(this, svgElement);
this.attachChangeEventListener("strokeStyle", web2d.peer.svg.ElementPeer.prototype.updateStrokeStyle);
};
objects.extend(web2d.peer.svg.LinePeer, web2d.peer.svg.ElementPeer);
web2d.peer.svg.LinePeer.prototype.setFrom = function(x1, y1)
{
this._native.setAttribute('x1', x1);
this._native.setAttribute('y1', y1);
};
web2d.peer.svg.LinePeer.prototype.setTo = function(x2, y2)
{
this._native.setAttribute('x2', x2);
this._native.setAttribute('y2', 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 (core.Utils.isDefined(startStyle))
{
// Todo: This must be implemented ...
}
if (core.Utils.isDefined(endStyle))
{
// Todo: This must be implemented ...
}
};

View File

@@ -0,0 +1,122 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
web2d.peer.svg.PolyLinePeer = function()
{
var svgElement = window.document.createElementNS(this.svgNamespace, 'polyline');
web2d.peer.svg.ElementPeer.call(this, svgElement);
this.setFill("none");
this.breakDistance = 10;
};
objects.extend(web2d.peer.svg.PolyLinePeer, web2d.peer.svg.ElementPeer);
web2d.peer.svg.PolyLinePeer.prototype.setFrom = function(x1, y1)
{
this._x1 = x1;
this._y1 = y1;
this._updatePath();
};
web2d.peer.svg.PolyLinePeer.prototype.setTo = function(x2, y2)
{
this._x2 = x2;
this._y2 = y2;
this._updatePath();
};
web2d.peer.svg.PolyLinePeer.prototype.setStrokeWidth = function(width)
{
this._native.setAttribute('stroke-width', width);
};
web2d.peer.svg.PolyLinePeer.prototype.setColor = function(color)
{
this._native.setAttribute('stroke', color);
};
web2d.peer.svg.PolyLinePeer.prototype.setStyle = function(style)
{
this._style = style;
this._updatePath();
};
web2d.peer.svg.PolyLinePeer.prototype.getStyle = function()
{
return this._style;
};
web2d.peer.svg.PolyLinePeer.prototype._updatePath = function()
{
if (this._style == "Curved")
{
this._updateMiddleCurvePath();
}
else if (this._style == "Straight")
{
this._updateStraightPath();
}
else
{
this._updateCurvePath();
}
};
web2d.peer.svg.PolyLinePeer.prototype._updateStraightPath = function()
{
if (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);
this._native.setAttribute('points', path);
}
};
web2d.peer.svg.PolyLinePeer.prototype._updateMiddleCurvePath = function()
{
var x1 = this._x1;
var y1 = this._y1;
var x2 = this._x2;
var y2 = this._y2;
if (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;
this._native.setAttribute('points', path);
}
};
web2d.peer.svg.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);
this._native.setAttribute('points', path);
}
};

View File

@@ -0,0 +1,64 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
/**
* http://www.w3.org/TR/SVG/shapes.html#RectElement
*/
web2d.peer.svg.RectPeer = function(arc)
{
var svgElement = window.document.createElementNS(this.svgNamespace, 'rect');
web2d.peer.svg.ElementPeer.call(this, svgElement);
this._arc = arc;
this.attachChangeEventListener("strokeStyle", web2d.peer.svg.ElementPeer.prototype.updateStrokeStyle);
};
objects.extend(web2d.peer.svg.RectPeer, web2d.peer.svg.ElementPeer);
web2d.peer.svg.RectPeer.prototype.setPosition = function(x, y)
{
if (core.Utils.isDefined(x))
{
this._native.setAttribute('x', parseInt(x));
}
if (core.Utils.isDefined(y))
{
this._native.setAttribute('y', parseInt(y));
}
};
web2d.peer.svg.RectPeer.prototype.getPosition = function()
{
var x = this._native.getAttribute('x');
var y = this._native.getAttribute('y');
return {x:parseInt(x),y:parseInt(y)};
};
web2d.peer.svg.RectPeer.prototype.setSize = function(width, height)
{
web2d.peer.svg.RectPeer.superClass.setSize.call(this, width, height);
var min = width < height?width:height;
if (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

@@ -0,0 +1,36 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
web2d.peer.svg.TahomaFont = function()
{
web2d.peer.svg.Font.call(this);
this._fontFamily="tahoma";
};
objects.extend(web2d.peer.svg.TahomaFont, web2d.peer.svg.Font);
web2d.peer.svg.TahomaFont.prototype.getFontFamily=function ()
{
return this._fontFamily;
};
web2d.peer.svg.TahomaFont.prototype.getFont=function ()
{
return web2d.Font.TAHOMA;
};

View File

@@ -0,0 +1,184 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
web2d.peer.svg.TextPeer = function()
{
var svgElement = window.document.createElementNS(this.svgNamespace, 'text');
web2d.peer.svg.ElementPeer.call(this, svgElement);
this._native.setAttribute("focusable", "true");
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)
{
this._native.appendChild(element._native);
};
web2d.peer.svg.TextPeer.prototype.setText = function(text)
{
text = core.Utils.escapeInvalidTags(text);
var child = this._native.firstChild;
if (child)
{
this._native.removeChild(child);
}
this._text = text;
var textNode = window.document.createTextNode(text);
this._native.appendChild(textNode);
};
web2d.peer.svg.TextPeer.prototype.getText = function()
{
return this._text;
};
web2d.peer.svg.TextPeer.prototype.setPosition = function(x, y)
{
this._position = {x:x, y:y};
var size = parseInt(this._font.getSize());
this._native.setAttribute('y', y + size);
//y+size/2
this._native.setAttribute('x', x);
};
web2d.peer.svg.TextPeer.prototype.getPosition = function()
{
return this._position;
};
web2d.peer.svg.TextPeer.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.svg.TextPeer.prototype._updateFontStyle = function()
{
this._native.setAttribute('font-family', this._font.getFontFamily());
this._native.setAttribute('font-size', this._font.getGraphSize());
this._native.setAttribute('font-style', this._font.getStyle());
this._native.setAttribute('font-weight', this._font.getWeight());
var scale = this._font.getFontScale();
this._native.xFontScale = scale.toFixed(1);
};
web2d.peer.svg.TextPeer.prototype.setColor = function(color)
{
this._native.setAttribute('fill', color);
};
web2d.peer.svg.TextPeer.prototype.getColor = function()
{
return this._native.getAttribute('fill');
};
web2d.peer.svg.TextPeer.prototype.setTextSize = function (size)
{
this._font.setSize(size);
this._updateFontStyle();
};
web2d.peer.svg.TextPeer.prototype.setContentSize = function(width, height)
{
this._native.xTextSize = width.toFixed(1) + "," + height.toFixed(1);
};
web2d.peer.svg.TextPeer.prototype.setStyle = function (style)
{
this._font.setStyle(style);
this._updateFontStyle();
};
web2d.peer.svg.TextPeer.prototype.setWeight = function (weight)
{
this._font.setWeight(weight);
this._updateFontStyle();
};
web2d.peer.svg.TextPeer.prototype.setFontFamily = function (family)
{
var oldFont = this._font;
this._font = new web2d.Font(family, this);
this._font.setSize(oldFont.getSize());
this._font.setStyle(oldFont.getStyle());
this._font.setWeight(oldFont.getWeight());
this._updateFontStyle();
};
web2d.peer.svg.TextPeer.prototype.getFont = function ()
{
return {
font:this._font.getFont(),
size:parseInt(this._font.getSize()),
style:this._font.getStyle(),
weight:this._font.getWeight()
};
};
web2d.peer.svg.TextPeer.prototype.setSize = function (size)
{
this._font.setSize(size);
this._updateFontStyle();
};
web2d.peer.svg.TextPeer.prototype.getWidth = function ()
{
var width = parseInt(this._native.getComputedTextLength());
width = width + this._font.getWidthMargin();
return width;
};
web2d.peer.svg.TextPeer.prototype.getHeight = function ()
{
return this._font.getGraphSize();
};
web2d.peer.svg.TextPeer.prototype.getHtmlFontSize = function ()
{
return this._font.getHtmlSize();
};

View File

@@ -0,0 +1,36 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
web2d.peer.svg.TimesFont = function()
{
web2d.peer.svg.Font.call(this);
this._fontFamily="times";
};
objects.extend(web2d.peer.svg.TimesFont, web2d.peer.svg.Font);
web2d.peer.svg.TimesFont.prototype.getFontFamily=function ()
{
return this._fontFamily;
};
web2d.peer.svg.TimesFont.prototype.getFont=function ()
{
return web2d.Font.TIMES;
};

View File

@@ -0,0 +1,36 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
web2d.peer.svg.VerdanaFont = function()
{
web2d.peer.svg.Font.call(this);
this._fontFamily="verdana";
};
objects.extend(web2d.peer.svg.VerdanaFont, web2d.peer.svg.Font);
web2d.peer.svg.VerdanaFont.prototype.getFontFamily=function ()
{
return this._fontFamily;
};
web2d.peer.svg.VerdanaFont.prototype.getFont=function ()
{
return web2d.Font.VERDANA;
};

View File

@@ -0,0 +1,122 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
web2d.peer.svg.WorkspacePeer = function(element)
{
this._element = element;
var svgElement = window.document.createElementNS(this.svgNamespace, 'svg');
web2d.peer.svg.ElementPeer.call(this, svgElement);
this._native.setAttribute("focusable", "true");
this._native.setAttribute("id", "workspace");
};
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.
*
* All elements that establish a new viewport (see elements that establish viewports), plus the 'marker', 'pattern' and 'view' elements have attribute viewBox. The value of the viewBox attribute is a list of four numbers <min-x>, <min-y>, <width> and <height>, separated by whitespace and/or a comma, which specify a rectangle in user space which should be mapped to the bounds of the viewport established by the given element, taking into account attribute preserveAspectRatio. If specified, an additional transformation is applied to all descendants of the given element to achieve the specified effect.
*
* A negative value for <width> or <height> is an error (see Error processing). A value of zero disables rendering of the element.
*
*/
web2d.peer.svg.WorkspacePeer.prototype.setCoordSize = function(width, height)
{
var viewBox = this._native.getAttribute('viewBox');
var coords = [0,0,0,0];
if (viewBox != null)
{
coords = viewBox.split(/ /);
}
if (core.Utils.isDefined(width))
{
coords[2] = width;
}
if (core.Utils.isDefined(height))
{
coords[3] = height;
}
this._native.setAttribute('viewBox', coords.join(" "));
this._native.setAttribute("preserveAspectRatio", "none");
web2d.peer.utils.EventUtils.broadcastChangeEvent(this, "strokeStyle");
};
web2d.peer.svg.WorkspacePeer.prototype.getCoordSize = function()
{
var viewBox = this._native.getAttribute('viewBox');
var coords = [1,1,1,1];
if (viewBox != null)
{
coords = viewBox.split(/ /);
}
return {width:coords[2],height:coords[3]};
};
web2d.peer.svg.WorkspacePeer.prototype.setCoordOrigin = function(x, y)
{
var viewBox = this._native.getAttribute('viewBox');
// ViewBox min-x ,min-y by default initializated with 0 and 0.
var coords = [0,0,0,0];
if (viewBox != null)
{
coords = viewBox.split(/ /);
}
if (core.Utils.isDefined(x))
{
coords[0] = x;
}
if (core.Utils.isDefined(y))
{
coords[1] = y;
}
this._native.setAttribute('viewBox', coords.join(" "));
};
web2d.peer.svg.WorkspacePeer.prototype.appendChild = function(child)
{
web2d.peer.svg.WorkspacePeer.superClass.appendChild.call(this, child);
web2d.peer.utils.EventUtils.broadcastChangeEvent(child, "onChangeCoordSize");
};
web2d.peer.svg.WorkspacePeer.prototype.getCoordOrigin = function(child)
{
var viewBox = this._native.getAttribute('viewBox');
var coords = [1,1,1,1];
if (viewBox != null)
{
coords = viewBox.split(/ /);
}
var x = parseFloat(coords[0]);
var y = parseFloat(coords[1]);
return {x:x,y:y};
};
web2d.peer.svg.WorkspacePeer.prototype.getPosition = function()
{
return {x:0,y:0};
};

View File

@@ -0,0 +1,41 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
web2d.peer.utils.EventUtils =
{
broadcastChangeEvent:function (elementPeer, type)
{
var listeners = elementPeer.getChangeEventListeners(type);
if (listeners)
{
for (var i = 0; i < listeners.length; i++)
{
var listener = listeners[i];
listener.call(elementPeer, null);
}
}
var children = elementPeer.getChildren();
for (var i = 0; i < children.length; i++)
{
var child = children[i];
web2d.peer.utils.EventUtils.broadcastChangeEvent(child, type);
}
}
};

View File

@@ -0,0 +1,39 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
web2d.peer.utils.TransformUtil =
{
workoutScale: function(elementPeer)
{
var current = elementPeer.getParent();
var width = 1;
var height = 1;
while (current)
{
var coordSize = current.getCoordSize();
var size = current.getSize();
width = width * (parseInt(size.width) / coordSize.width);
height = height * (parseInt(size.height) / coordSize.height);
current = current.getParent();
}
return {width:width,height:height};
}
};

View File

@@ -0,0 +1,36 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
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

@@ -0,0 +1,361 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
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

@@ -0,0 +1,58 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
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

@@ -0,0 +1,89 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
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

@@ -0,0 +1,77 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
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

@@ -0,0 +1,38 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
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

@@ -0,0 +1,69 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
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

@@ -0,0 +1,151 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
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

@@ -0,0 +1,47 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
/**
* 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

@@ -0,0 +1,36 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
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

@@ -0,0 +1,236 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
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

@@ -0,0 +1,119 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
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

@@ -0,0 +1,36 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
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

@@ -0,0 +1,36 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
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

@@ -0,0 +1,94 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
* $Id: file 64488 2006-03-10 17:32:09Z paulo $
*/
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};
};