sgtplot
Class SGLabel
- java.lang.Object
-
- sgtplot.SGLabel
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, LayerChild, Moveable, Selectable
public class SGLabel extends java.lang.Object implements java.lang.Cloneable, LayerChild, Moveable, java.io.Serializable
Draws text on a layer object. SGLabel uses the drawString() method of the Graphics class. SGLabel allows the user to align the text both vertically (TOP, MIDDLE, and BOTTOM) and horizontally (LEFT, MIDDLE, and RIGHT). The font, color, and height (in user coordinates) can also be specified. The SGLabel can also be drawn either HORIZONTAL or VERTICAL.- Since:
- 1.0
- See Also:
Graphics, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field and Description static intANGLEOrient label at an anglestatic intBOTTOMAlign bottom of labelstatic intCENTERAlign center of labelstatic intHORIZONTALOrient label horizontalstatic intLEFTAlign left of labelstatic intMIDDLEAlign middle of labelstatic intRIGHTAlign right of labelstatic intTOPAlign top of labelstatic intVERTICALOrient label vertical
-
Constructor Summary
Constructors Constructor and Description SGLabel(java.lang.String id, java.lang.String lbl, double hgt, Point2D.Double loc, int valign, int halign)Long SGLabel constructor.SGLabel(java.lang.String id, java.lang.String lbl, Point2D.Double loc)Quick SGLabel constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddPropertyChangeListener(java.beans.PropertyChangeListener l)Add a new PropertyChangeListener.LayerChildcopy()Create a copy of theLayerChild.voiddraw(org.freehep.graphics2d.VectorGraphics g)Draw theLayerChild.booleanequals(java.lang.Object obj)doublegetAngle()Get label drawing angle.java.awt.RectanglegetBounds()Get the label bounds in device units.Rectangle2D.DoublegetBoundsP()Get the label bounds in physical units.java.awt.ColorgetColor()Get the color.java.awt.FontgetFont()Get the font.intgetHAlign()Get the horizontal alignment.intgetHeight()Get the label height in device coordinates.doublegetHeightP()Get the label height in physical coordinates.java.lang.StringgetId()Get the label identifier.LayergetLayer()Get the layer.java.awt.PointgetLocation()Get the label position in device coordinates.Point2D.DoublegetLocationP()Get the label reference location in physcial coordinates.intgetOrientation()Get the origentation.AbstractPanegetPane()GetAbstractPaneof theLayerChild.floatgetStringHeight(org.freehep.graphics2d.VectorGraphics g)Get the string height in device units.floatgetStringWidth(org.freehep.graphics2d.VectorGraphics g)Get the string width in device units.java.lang.StringgetText()Get the label text.intgetVAlign()Get the vertical alignment.booleanisMoveable()Returns true if the current state is moveablebooleanisSelectable()Returns true if the current state is selectable.booleanisSelected()Returns true if the object's selected property is set.booleanisVisible()Check ifLayerChildis visible.voidmodified(java.lang.String text)Used by sgtplot internally.voidremovePropertyChangeListener(java.beans.PropertyChangeListener l)Remove a listener.voidsetAlign(int vert, int horz)Set the vertical and horizontal alignment.voidsetAngle(double angle)Draw label at arbitrary rotation.voidsetBounds(int x, int y, int width, int height)Set the label bounds in device units.voidsetBounds(java.awt.Rectangle r)Set the label bounds in device units.voidsetColor(java.awt.Color color)Set the color.voidsetFont(java.awt.Font fnt)Set the font.voidsetHAlign(int horz)Set the horizontal alignment.voidsetHeightP(double hgt)Set the height of the label in physical coordinates.voidsetId(java.lang.String id)Set the label identifier.voidsetLayer(Layer l)Associate aLayerwith theLayerChild.voidsetLocation(java.awt.Point loc)Set the label reference location in pixel coordinates.voidsetLocationP(Point2D.Double loc)Set the label reference location in physcial coordinates.voidsetMoveable(boolean moveable)Set the moveable property.voidsetOrientation(int orient)Set the orientation.voidsetSelectable(boolean select)Set the Selectable property.voidsetSelected(boolean sel)Sets the selected property.voidsetText(java.lang.String lbl)Set the label text.voidsetVAlign(int vert)Set the vertical alignment.voidsetVisible(boolean visible)Set visibility for aLayerChild.java.lang.StringtoString()Return a string that represents theLayerChild.
-
-
-
Field Detail
-
TOP
public static final int TOP
Align top of label- See Also:
- Constant Field Values
-
MIDDLE
public static final int MIDDLE
Align middle of label- See Also:
- Constant Field Values
-
BOTTOM
public static final int BOTTOM
Align bottom of label- See Also:
- Constant Field Values
-
LEFT
public static final int LEFT
Align left of label- See Also:
- Constant Field Values
-
CENTER
public static final int CENTER
Align center of label- See Also:
- Constant Field Values
-
RIGHT
public static final int RIGHT
Align right of label- See Also:
- Constant Field Values
-
HORIZONTAL
public static final int HORIZONTAL
Orient label horizontal- See Also:
- Constant Field Values
-
VERTICAL
public static final int VERTICAL
Orient label vertical- See Also:
- Constant Field Values
-
ANGLE
public static final int ANGLE
Orient label at an angle- Since:
- 2.0
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SGLabel
public SGLabel(java.lang.String id, java.lang.String lbl, Point2D.Double loc)Quick SGLabel constructor. Default alignment of BOTTOM and LEFT are used. Default height is 0.12.- Parameters:
id- Label identifierlbl- String to be plotted.
-
SGLabel
public SGLabel(java.lang.String id, java.lang.String lbl, double hgt, Point2D.Double loc, int valign, int halign)Long SGLabel constructor.- Parameters:
id- Label identifierlbl- String to be plottedhgt- String height in physical unitsloc- Location to plot label in physical unitsvalign- Vertical alignmenthalign- Horizontal alignment
-
-
Method Detail
-
copy
public LayerChild copy()
Description copied from interface:LayerChildCreate a copy of theLayerChild.- Specified by:
copyin interfaceLayerChild- Returns:
- A copy of the
LayerChild.
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object- Since:
- 3.0
-
draw
public void draw(org.freehep.graphics2d.VectorGraphics g) throws LayerNotFoundExceptionDescription copied from interface:LayerChildDraw theLayerChild.- Specified by:
drawin interfaceLayerChild- Parameters:
g- Graphics context- Throws:
LayerNotFoundException- No layer is associated with theLayerChild.
-
setSelected
public void setSelected(boolean sel)
Description copied from interface:SelectableSets the selected property.- Specified by:
setSelectedin interfaceSelectable- Parameters:
sel- true if selected, false if not.
-
isSelected
public boolean isSelected()
Description copied from interface:SelectableReturns true if the object's selected property is set.- Specified by:
isSelectedin interfaceSelectable- Returns:
- true if selected, false if not.
-
setSelectable
public void setSelectable(boolean select)
Description copied from interface:SelectableSet the Selectable property.- Specified by:
setSelectablein interfaceSelectable- Parameters:
select- if true object is selectable
-
isSelectable
public boolean isSelectable()
Description copied from interface:SelectableReturns true if the current state is selectable.- Specified by:
isSelectablein interfaceSelectable- Returns:
- true if selectable
-
setColor
public void setColor(java.awt.Color color)
Set the color.- Parameters:
color- The color of the label.- See Also:
Color
-
getColor
public java.awt.Color getColor()
Get the color.- Returns:
- The current color of the label.
-
setFont
public void setFont(java.awt.Font fnt)
Set the font.- Parameters:
fnt- The Font to use to draw the label.- See Also:
Font
-
getFont
public java.awt.Font getFont()
Get the font.- Returns:
- The current font for the label.
-
setHeightP
public void setHeightP(double hgt)
Set the height of the label in physical coordinates.- Parameters:
hgt- The label height.
-
getHeightP
public double getHeightP()
Get the label height in physical coordinates.- Returns:
- The label height.
-
setAlign
public void setAlign(int vert, int horz)Set the vertical and horizontal alignment. The vertical alignment can be TOP, MIDDLE, or BOTTOM, and the horizontal alignment LEFT, CENTER, or RIGHT.- Parameters:
vert- The vertical alignment.horz- The horizontal alignment.
-
setHAlign
public void setHAlign(int horz)
Set the horizontal alignment. The alignment can be LEFT, CENTER, or RIGHT.- Parameters:
horz- The horizontal alignment.
-
getHAlign
public int getHAlign()
Get the horizontal alignment.- Returns:
- the horizontal alignment.
-
setVAlign
public void setVAlign(int vert)
Set the vertical alignment. The alignment can be TOP, MIDDLE, or BOTTOM.- Parameters:
vert- The vertical alignment.
-
getVAlign
public int getVAlign()
Get the vertical alignment.- Returns:
- the vertical alignment.
-
setLocationP
public void setLocationP(Point2D.Double loc)
Set the label reference location in physcial coordinates.
Property Change:location.- Parameters:
loc- physical location of label
-
getLocationP
public Point2D.Double getLocationP()
Get the label reference location in physcial coordinates.- Returns:
- the labels position.
-
setOrientation
public void setOrientation(int orient)
Set the orientation. The orientation can be HORIZONTAL or VERTICAL.- Parameters:
orient- The orientation.
-
getOrientation
public int getOrientation()
Get the origentation.- Returns:
- the orientation
-
setAngle
public void setAngle(double angle)
Draw label at arbitrary rotation. Warning: Rotated labels are not drawn very well when using JDK1.1. For best results use JDK1.2 or newer.- Since:
- 2.0
-
getAngle
public double getAngle()
Get label drawing angle.- Since:
- 2.0
-
setLayer
public void setLayer(Layer l)
Description copied from interface:LayerChildAssociate aLayerwith theLayerChild.- Specified by:
setLayerin interfaceLayerChild- Parameters:
l- Parent layer.
-
getLayer
public Layer getLayer()
Get the layer.- Specified by:
getLayerin interfaceLayerChild- Returns:
- the layer object.
-
getPane
public AbstractPane getPane()
Description copied from interface:LayerChildGetAbstractPaneof theLayerChild.- Specified by:
getPanein interfaceLayerChild
-
modified
public void modified(java.lang.String text)
Description copied from interface:LayerChildUsed by sgtplot internally.- Specified by:
modifiedin interfaceLayerChild
-
getText
public java.lang.String getText()
Get the label text.- Returns:
- the label text
-
setText
public void setText(java.lang.String lbl)
Set the label text.- Parameters:
lbl- the label text
-
getId
public java.lang.String getId()
Get the label identifier.- Specified by:
getIdin interfaceLayerChild- Returns:
- the identifier
-
setId
public void setId(java.lang.String id)
Set the label identifier.- Specified by:
setIdin interfaceLayerChild- Parameters:
id- the label identifier
-
getHeight
public int getHeight()
Get the label height in device coordinates.- Returns:
- the label height
-
getLocation
public java.awt.Point getLocation()
Get the label position in device coordinates.- Specified by:
getLocationin interfaceMoveable- Returns:
- the label position
-
setLocation
public void setLocation(java.awt.Point loc)
Set the label reference location in pixel coordinates.
Property Change:location.- Specified by:
setLocationin interfaceMoveable- Parameters:
loc- physical location of label
-
getBoundsP
public Rectangle2D.Double getBoundsP()
Get the label bounds in physical units.- Returns:
- the label bounds
-
getBounds
public java.awt.Rectangle getBounds()
Get the label bounds in device units.- Specified by:
getBoundsin interfaceMoveable- Specified by:
getBoundsin interfaceSelectable- Returns:
- the label bounds
-
setBounds
public void setBounds(java.awt.Rectangle r)
Set the label bounds in device units.
-
setBounds
public void setBounds(int x, int y, int width, int height)Set the label bounds in device units.
-
toString
public java.lang.String toString()
Description copied from interface:LayerChildReturn a string that represents theLayerChild.- Specified by:
toStringin interfaceLayerChild- Overrides:
toStringin classjava.lang.Object- Returns:
- Stringified
LayerChildrepresentation.
-
isVisible
public boolean isVisible()
Description copied from interface:LayerChildCheck ifLayerChildis visible.- Specified by:
isVisiblein interfaceLayerChild- Returns:
- true if visible
-
setVisible
public void setVisible(boolean visible)
Description copied from interface:LayerChildSet visibility for aLayerChild.- Specified by:
setVisiblein interfaceLayerChild- Parameters:
visible- visible if true
-
isMoveable
public boolean isMoveable()
Description copied from interface:MoveableReturns true if the current state is moveable- Specified by:
isMoveablein interfaceMoveable- Returns:
- true if moveable
-
setMoveable
public void setMoveable(boolean moveable)
Description copied from interface:MoveableSet the moveable property.- Specified by:
setMoveablein interfaceMoveable
-
getStringWidth
public float getStringWidth(org.freehep.graphics2d.VectorGraphics g)
Get the string width in device units.- Since:
- 2.0
-
getStringHeight
public float getStringHeight(org.freehep.graphics2d.VectorGraphics g)
Get the string height in device units.- Since:
- 2.0
-
addPropertyChangeListener
public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Description copied from interface:MoveableAdd a new PropertyChangeListener. Properties will include "moved". Implementation of the following two methods will normally be via the PropertyChangeSupport class.- Specified by:
addPropertyChangeListenerin interfaceMoveable
-
removePropertyChangeListener
public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
Description copied from interface:MoveableRemove a listener.- Specified by:
removePropertyChangeListenerin interfaceMoveable
-
-
DMelt 3.0 © DataMelt by jWork.ORG