com.jfimagine.jfgraph.shape.base
Class Label

java.lang.Object
  |
  +--com.jfimagine.jfgraph.shape.base.AbstractObject
        |
        +--com.jfimagine.jfgraph.shape.base.Label
All Implemented Interfaces:
java.lang.Cloneable

public class Label
extends AbstractObject

Label Class. A label is to label the text of a shape.

Version:
$Revision: 1.1 $
Author:
CookieMaker

Field Summary
protected  java.awt.Font m_font
          A font format of this label.
protected  JFPoint m_labelPoint
          A point for x,y coordinates of the left-top corner of the label.
protected  boolean m_movable
          Label movable. e.g.
protected  AbstractObject m_parent
          A parent object of this label.
protected  java.lang.String m_text
          Label text.
protected  boolean m_visible
          Label visible or invisible.
static java.lang.String XML_LABEL
          A XML string tag represents a jflabel
static java.lang.String XML_MOVABLE
          A XML string tag represents the if movable of this label
static java.lang.String XML_TEXT
          A XML string tag represents the text of this label
static java.lang.String XML_VISIBLE
          A XML string tag represents the if visible of this label
static java.lang.String XML_XOFFSET
          A XML string tag represents the x coordinate offset of this label
static java.lang.String XML_YOFFSET
          A XML string tag represents the y coordinate offset of this label
 
Fields inherited from class com.jfimagine.jfgraph.shape.base.AbstractObject
m_lastError, XML_OBJECTID, XML_OBJECTTYPE
 
Constructor Summary
Label()
          Constructor for Label
Label(double x, double y)
          Constructor for Label
Label(JFPoint pnt)
          Constructor for Label
 
Method Summary
protected  void appendChildToDOM(Element element, JFVersion version)
          Append necessary xml child for current element, this method will be called internally by toDOM.
 java.lang.Object clone()
          Creates a new object of the same class and with the same contents as this object.
protected  AbstractObject cloneMe()
          Creates a new AbstractObject of the same class and with the same contents as this object.
 void draw(java.awt.Graphics g)
          Draw current object on graphic canvas.
protected  void drawLabel(java.awt.Graphics g)
          Draw current label on graphic canvas.
 void drawPicked(java.awt.Graphics g, boolean isXorMode)
          Draw picked state of current object on graphic canvas.
 boolean equals(java.lang.Object obj)
          Determines whether or not two objects are equal.
protected  void extractChildFromDOM(Element element, JFVersion version)
          Extract needed xml child from current element, this method will be called internally by fromDOM.
 Rect getBounds()
          Get the bounds of this label.
 java.awt.Font getFont()
          Get the font of current label.
 JFPoint getLabelPoint()
          Get the point of current label.
 boolean getMovable()
          Get if movable of current label.
 AbstractObject getParent()
          Get parent object of this label.
 java.lang.String getText()
          Get the text of current label.
 boolean getVisible()
          Get if visible of current label.
 double getXOffset()
          Get the x offset of current label.
 double getYOffset()
          Get the y offset of current label.
 java.awt.Font getZoomedFont()
          Get a zoomed font of current label.
 int hashCode()
          Returns the hashcode for this Object.
 boolean intersects(java.awt.Graphics g, JFPoint pnt)
          Test if current object intersects with a specified point.
 boolean intersects(java.awt.Graphics g, Rect rect)
          Test if current object intersects with a specified point.
 void loadFromStream(JFReader stream, boolean skipHead, JFVersion version)
          Load label data from a binary stream
 void moveBy(double x, double y)
          Move current object by an x and y offset.
 void saveToStream(JFWriter stream, JFVersion version)
          Save this label to a binary stream
 void setFont(java.awt.Font aFont)
          Set the font of current label.
 void setLabelPoint(JFPoint pnt)
          Set the point of current label.
 void setMovable(boolean movable)
          Set the movable of current label.
 void setParent(AbstractObject obj)
          Set parent object of this label.
 void setText(java.lang.String text)
          Set the text of current label.
 void setValue(Label aLabel)
          Set the value of current label.
 void setVisible(boolean visible)
          Set the visible of current label.
 void setXOffset(double xOffset)
          Set the x offset of current label.
 void setYOffset(double yOffset)
          Set the y offset of current label.
 java.lang.String toString()
          Convert this label to String
 
Methods inherited from class com.jfimagine.jfgraph.shape.base.AbstractObject
fromDOM, getLastError, getMaxObjectId, getObjectId, getObjectType, getXMLTag, getZoomScale, isShowDesign, setLastError, setObjectId, setObjectType, setShowDesign, setValue, setXMLTag, setZoomScale, toDOM
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

XML_LABEL

public static final java.lang.String XML_LABEL
A XML string tag represents a jflabel

See Also:
Constant Field Values

XML_XOFFSET

public static final java.lang.String XML_XOFFSET
A XML string tag represents the x coordinate offset of this label

See Also:
Constant Field Values

XML_YOFFSET

public static final java.lang.String XML_YOFFSET
A XML string tag represents the y coordinate offset of this label

See Also:
Constant Field Values

XML_TEXT

public static final java.lang.String XML_TEXT
A XML string tag represents the text of this label

See Also:
Constant Field Values

XML_VISIBLE

public static final java.lang.String XML_VISIBLE
A XML string tag represents the if visible of this label

See Also:
Constant Field Values

XML_MOVABLE

public static final java.lang.String XML_MOVABLE
A XML string tag represents the if movable of this label

See Also:
Constant Field Values

m_labelPoint

protected JFPoint m_labelPoint
A point for x,y coordinates of the left-top corner of the label.


m_text

protected java.lang.String m_text
Label text.


m_visible

protected boolean m_visible
Label visible or invisible.


m_movable

protected boolean m_movable
Label movable. e.g. Not movable in JFLabelLine.


m_parent

protected AbstractObject m_parent
A parent object of this label.


m_font

protected java.awt.Font m_font
A font format of this label.

Constructor Detail

Label

public Label()
Constructor for Label


Label

public Label(double x,
             double y)
Constructor for Label


Label

public Label(JFPoint pnt)
Constructor for Label

Method Detail

getParent

public AbstractObject getParent()
Get parent object of this label.

Returns:
parent object.

setParent

public void setParent(AbstractObject obj)
Set parent object of this label.


getXOffset

public double getXOffset()
Get the x offset of current label.

Returns:
The x offset of current label.

setXOffset

public void setXOffset(double xOffset)
Set the x offset of current label.

Parameters:
xOffset - The x offset of current label.
Returns:
No return.

getYOffset

public double getYOffset()
Get the y offset of current label.

Returns:
The y offset of current label.

setYOffset

public void setYOffset(double yOffset)
Set the y offset of current label.

Parameters:
yOffset - The y offset of current label.

getLabelPoint

public JFPoint getLabelPoint()
Get the point of current label.

Returns:
The position of current label.

setLabelPoint

public void setLabelPoint(JFPoint pnt)
Set the point of current label.

Parameters:
pnt - The point of current label.

getVisible

public boolean getVisible()
Get if visible of current label.

Returns:
True if visible, false otherwise.

setVisible

public void setVisible(boolean visible)
Set the visible of current label.

Parameters:
visible - A new visible state of current label.

getMovable

public boolean getMovable()
Get if movable of current label.

Returns:
True if movable, false otherwise.

setMovable

public void setMovable(boolean movable)
Set the movable of current label.

Parameters:
movable - A new movable state of current label.

getText

public java.lang.String getText()
Get the text of current label.

Returns:
The text of current label.

setText

public void setText(java.lang.String text)
Set the text of current label.

Parameters:
text - The text of current label.

getFont

public java.awt.Font getFont()
Get the font of current label.

Returns:
The font of current label.

getZoomedFont

public java.awt.Font getZoomedFont()
Get a zoomed font of current label.

Returns:
A new zoomed font of current label.

setFont

public void setFont(java.awt.Font aFont)
Set the font of current label.


setValue

public void setValue(Label aLabel)
Set the value of current label.

Parameters:
aLabel - A new label value.

getBounds

public Rect getBounds()
Get the bounds of this label.

Returns:
The bounds rectangle of this label.

drawLabel

protected void drawLabel(java.awt.Graphics g)
Draw current label on graphic canvas.

Parameters:
g - A graphic canvas.

drawPicked

public void drawPicked(java.awt.Graphics g,
                       boolean isXorMode)
Draw picked state of current object on graphic canvas.

Parameters:
g - A graphic canvas.
isXorMode - If is in xor mode now.

draw

public void draw(java.awt.Graphics g)
Draw current object on graphic canvas.

Parameters:
g - A graphic canvas.

intersects

public boolean intersects(java.awt.Graphics g,
                          JFPoint pnt)
Test if current object intersects with a specified point.

Parameters:
g - A graphics context necessary used to measure intersection.
pnt - A JFPoint used to test intersection.

intersects

public boolean intersects(java.awt.Graphics g,
                          Rect rect)
Test if current object intersects with a specified point.

Parameters:
g - A graphics context necessary used to measure intersection.
rect - A rectangle used to test intersection.

moveBy

public void moveBy(double x,
                   double y)
Move current object by an x and y offset.


toString

public java.lang.String toString()
Convert this label to String

Overrides:
toString in class AbstractObject
Returns:
An string represents the content of the label

cloneMe

protected AbstractObject cloneMe()
                          throws java.lang.CloneNotSupportedException
Creates a new AbstractObject of the same class and with the same contents as this object. This method implements the method defined in AbstractObject.

Specified by:
cloneMe in class AbstractObject
Returns:
A clone of this class.
java.lang.CloneNotSupportedException

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Creates a new object of the same class and with the same contents as this object.

Overrides:
clone in class AbstractObject
Returns:
A clone of this instance.
java.lang.CloneNotSupportedException

hashCode

public int hashCode()
Returns the hashcode for this Object.

Overrides:
hashCode in class AbstractObject
Returns:
hash code for this Label.

equals

public boolean equals(java.lang.Object obj)
Determines whether or not two objects are equal.

Overrides:
equals in class AbstractObject
Parameters:
obj - an object to be compared with this object
Returns:
true if the object to be compared is an instance of Label and has the same values; false otherwise.

appendChildToDOM

protected void appendChildToDOM(Element element,
                                JFVersion version)
Append necessary xml child for current element, this method will be called internally by toDOM.

Overrides:
appendChildToDOM in class AbstractObject
Parameters:
element - A XML element to append child xml labels
version - A file version notification so this object can obey the rules to save data.

extractChildFromDOM

protected void extractChildFromDOM(Element element,
                                   JFVersion version)
Extract needed xml child from current element, this method will be called internally by fromDOM.

Overrides:
extractChildFromDOM in class AbstractObject
Parameters:
element - An element used to extract needed xml child
version - A file version notification so this object can obey the rules to fetch data.

saveToStream

public void saveToStream(JFWriter stream,
                         JFVersion version)
                  throws java.io.IOException
Save this label to a binary stream

Overrides:
saveToStream in class AbstractObject
Parameters:
stream - An binary output stream
version - A file version notification so this object can obey the rules to save data.
Throws:
java.io.IOException

loadFromStream

public void loadFromStream(JFReader stream,
                           boolean skipHead,
                           JFVersion version)
                    throws java.io.IOException
Load label data from a binary stream

Overrides:
loadFromStream in class AbstractObject
Parameters:
stream - An binary input stream
skipHead - Skip head 'TYPE' check, an shape object should always has its own shape-type stored, if this shape-type has already been readed, this loadFromStream should/could not read the type anymore.
version - A file version notification so this object can obey the rules to fetch data.
Throws:
java.io.IOException


Copyright 2004 ~ 2005 JingFei International Cooperation LTD. All Rights Reserved.