JavaScript Graphics Library (JSGL.org) Draw and move interactive vector graphics easily in Javascript!

Label Element (jsgl.elements.LabelElement)

This page documents how text labels can be put into the drawing and manipulated using JSGL.

The class inherits from jsgl.elements.AbstractElement.

UML

Creation

To draw a text label, use the .createLabel() method of a jsgl.Panel object and add it to its viewport:

var myLabel = myPanel.createLabel();
myPanel.addElement(myLabel);

The object created is of type jsgl.elements.LabelElement and provides a cross-browser API described below.

Method Summary

Location, Anchor Point

Setters
setX(newX: Number) Sets the X-axis coordinate of the label's anchor point.
setY(newY: Number) Sets the Y-axis coordinate of the label's anchor point.
setLocationXY(newX: Number, newY: Number) Sets the location of the label's anchor point using couple of real-valued coordinates (X and Y).
setLocation(newLocation: jsgl.Vector2D) Sets the location of the label's anchor point using jsgl.Vector2D object.
setHorizontalAnchor(anchor: jsgl.HorizontalAnchor) Sets the horizontal anchor of the label. This allows the label to be aligned left, center, or right to its anchor point.
setVerticalAnchor(anchor: jsgl.VerticalAnchor) Sets the vertical anchor of the label. This allows the label to be aligned top, middle, or bottom to its anchor point.
Getters
getX() : Number Gets the X-axis coordinate of the label's anchor point.
getY() : Number Gets the Y-axis coordinate of the label's anchor point.
getLocation() : jsgl.Vector2D Gets the location of the label's anchor point.
getHorizontalAnchor() : jsgl.HorizontalAnchor Gets the current horizontal anchor of the label.
getVerticalAnchor() : jsgl.VerticalAnchor Gets the current vertical anchor of the label.

Text and Font

Setters
setText(newText: String) Sets the new string to be displayed by the label.
setFontFamily(fontFamily: String) Sets the new CSS font-family string for the label.
setFontSize(fontSize: Number) Sets the new font size of the label in pixels.
setFontColor(fontColor: String) Sets the new color of the label's font in the CSS color format.
setBold(bold: Boolean) Sets whether or not the font weight of the label should be bold.
setItalics(italics: Boolean) Sets whether or not the font style of the label should be italics.
setUnderlined(underlined: Boolean) Sets whether or not the label should be underlined.
setOverlined(overlined: Boolean) Sets whether or not the label should be overlined or not.
setStruckThrough(struckThrough: Boolean) Sets whether or not the label should be struck-through or not.
setOpacity(newOpacity: Number) Sets the opacity of the label.
Getters
getText() : String Gets the string currently displayed by the label.
getFontFamily() : String Gets the current CSS font-family string for the label.
getFontSize() : Number Gets the current font size of the label in pixels.
getFontColor() : Number Gets the current CSS color of the label's font.
isBold() : Boolean Determines whether or not the font weight of the label is currently bold.
isItalics() : Boolean Determines whether or not the font style of the label is currently italics.
isUnderlined() : Boolean Determines whether or not the label is currently underlined.
isOverlined() : Boolean Determines whether the label is currently overlined or not.
isStruckThrough() : Boolean Determines whether the label is currently struck-through or not.
getOpacity() : Number Gets the current opacity of the label.

Method Detail

See Also

 
label-element.txt · Last modified: 2013/03/14 03:17 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license: GNU Free Documentation License 1.3
Driven by DokuWiki Powered by PHP Valid XHTML 1.0 Valid CSS