Rectangle.js
Summary
No overview generated for 'Rectangle.js'
draw2d.Rectangle=function( width, height)
{
this.bgColor = null;
this.lineColor = new draw2d.Color(0,0,0);
this.lineStroke=1;
draw2d.Figure.call(this);
if(width && height)
this.setDimension(width, height);
}
draw2d.Rectangle.prototype = new draw2d.Figure;
draw2d.Rectangle.prototype.type="Rectangle";
draw2d.Rectangle.prototype.dispose=function()
{
draw2d.Figure.prototype.dispose.call(this);
this.bgColor=null;
this.lineColor = null;
}
draw2d.Rectangle.prototype.createHTMLElement=function()
{
var item = draw2d.Figure.prototype.createHTMLElement.call(this);
item.style.width="auto";
item.style.height="auto";
item.style.margin="0px";
item.style.padding="0px";
item.style.border= this.lineStroke+"px solid "+this.lineColor.getHTMLStyle();
item.style.fontSize="1px";
item.style.lineHeight="1px";
item.innerHTML=" ";
if(this.bgColor!=null)
item.style.backgroundColor=this.bgColor.getHTMLStyle();
return item;
}
draw2d.Rectangle.prototype.setBackgroundColor= function( color)
{
this.bgColor = color;
if(this.bgColor!=null)
this.html.style.backgroundColor=this.bgColor.getHTMLStyle();
else
this.html.style.backgroundColor="transparent";
}
draw2d.Rectangle.prototype.getBackgroundColor=function()
{
return this.bgColor;
}
draw2d.Rectangle.prototype.setColor= function( color)
{
this.lineColor = color;
if(this.lineColor!=null)
{
this.html.style.border= this.lineStroke+"px solid "+this.lineColor.getHTMLStyle();
}
else
{
this.html.style.border= this.lineStroke+"0px";
}
}
draw2d.Rectangle.prototype.getColor=function()
{
return this.lineColor;
}
draw2d.Rectangle.prototype.getWidth=function()
{
return draw2d.Figure.prototype.getWidth.call(this)+2*this.lineStroke;
}
draw2d.Rectangle.prototype.getHeight=function()
{
return draw2d.Figure.prototype.getHeight.call(this)+2*this.lineStroke;
}
draw2d.Rectangle.prototype.setDimension=function( w , h)
{
return draw2d.Figure.prototype.setDimension.call(this, w-2*this.lineStroke, h-2*this.lineStroke);
}
draw2d.Rectangle.prototype.setLineWidth=function( w)
{
var diff = w-this.lineStroke;
this.setDimension(this.getWidth()-2*diff, this.getHeight()-2*diff);
this.lineStroke=w;
var c = "transparent";
if(this.lineColor!=null)
c=this.lineColor.getHTMLStyle();
this.html.style.border= this.lineStroke+"px solid "+c;
}
draw2d.Rectangle.prototype.getLineWidth=function()
{
return this.lineStroke;
}
Documentation generated by
JSDoc on Thu Feb 7 23:45:47 2008