com.ijchart.xychart.shape
Class AbstractRectangleTextChartShape

java.lang.Object
  extended by com.ijchart.xychart.shape.AbstractChartShape
      extended by com.ijchart.xychart.shape.AbstractTextChartShape
          extended by com.ijchart.xychart.shape.AbstractRectangleTextChartShape
All Implemented Interfaces:
IChartShapeChangeListener, IChartShape, java.io.Serializable, java.lang.Cloneable, java.util.EventListener
Direct Known Subclasses:
BoxAndWhiskerChartShape, CylinderTextChartShape, DblHeadMatchstickChartShape, DualBreakLineChartShape, EllipseTextChartShape, GeneralPathChartShape, HighLowChartShape, LineAndShapeChartShape, ParallelepipedTextChartShape, PieOutsideLabelChartShape, RectangleTextChartShape, SectorChartShape, StatisticalBarChartShape, StatisticalLineChartShape, StockChartShape, TextAndPointerChartShape

public abstract class AbstractRectangleTextChartShape
extends AbstractTextChartShape
implements java.lang.Cloneable, java.io.Serializable

Title: IJChart

Description: a chart library for the Java(tm) platform.

Draw a text inside or outside a Rectangle,with or not have a border.

Copyright: Copyright (c) 2013

Company:

Version:
1.0
Author:
zhang feng min,shanghai china. Contract me by email.
See Also:
Serialized Form

Field Summary
static boolean DEFAULT_DRAW_AUTO_WRAP
           The default auto wrap.
static boolean DEFAULT_FORCE_INSIDE_TEXT_NO_WRAP
           A default boolean flag controls whether or not the inside text is no wrap.
static boolean DEFAULT_FORCE_SHOW_ALL
           A default boolean flag controls whether or not draw text even if it's too long to show.
static int DEFAULT_TEXT_MAX_SHOW_LINE
           The default maximum number of lines for text (default is all).
 
Fields inherited from class com.ijchart.xychart.shape.AbstractTextChartShape
DEFAULT_TEXT_DIRECTION, DEFAULT_TEXT_HORIZONTAL_ALIGNMENT, DEFAULT_TEXT_POSITION, DEFAULT_TEXT_VERTICAL_ALIGNMENT
 
Fields inherited from class com.ijchart.xychart.shape.AbstractChartShape
DEFAULT_DRAW_TYPE, DEFAULT_SHAPE_ID, DEFAULT_VISIBLE, transformedShape
 
Fields inherited from interface com.ijchart.xychart.shape.IChartShape
DEFAULT_BORDER_PAINT, DEFAULT_BORDER_STROKE, DEFAULT_CONTENT_PAINT, DEFAULT_DRAW_BORDER, DEFAULT_FILL_ALPHA, DEFAULT_FILL_PAINT, DEFAULT_FILL_SHAPE, DEFAULT_GRADIENT_PAINT_TRANSFORM_TYPE, DEFAULT_MARGIN, DEFAULT_SELECT_FILL_PAINT, DEFAULT_SELECT_RECT_ALPHA, DEFAULT_SELECT_RECT_WIDTH, DEFAULT_SELECTED, DEFAULT_TEXT_FONT, DEFAULT_TOOLTIP_SHAPE_WIDTH, HOTSPOT_TYPE_CIRCLE, HOTSPOT_TYPE_POLYGON, HOTSPOT_TYPE_RECTANGLE
 
Constructor Summary
protected AbstractRectangleTextChartShape(java.awt.geom.Rectangle2D drawArea, java.lang.String text)
           Draw text in area drawArea.
protected AbstractRectangleTextChartShape(java.awt.geom.Rectangle2D drawArea, java.lang.String text, java.awt.Font font)
           Draw text in area drawArea.
 
Method Summary
 java.lang.Object clone()
           Creates and returns a copy of this object.
protected  void drawText(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area)
           Draw text.
protected  void drawTextWithTrimMarginRect(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D drawArea)
           Draw text on rectangle area.
 boolean equals(java.lang.Object obj)
           Indicates whether some other object is "equal to" this one.
 java.awt.geom.Rectangle2D getDrawArea()
           Returns the text draw area.
 java.awt.geom.Point2D getLockPoint()
           Returns the lock coordinates of this shape.
 int getTextMaxShowLine()
           Returns the maximum number of lines for text.
protected  java.awt.geom.Point2D getTooltipShapeTranslatePoint()
           Returns the translate point of tooltip shape.
 java.awt.geom.Point2D getTopLeftPoint()
           Returns the top left corner coordinates of this shape.
 int hashCode()
           Returns a hash code value for the object.
 boolean isAutoWrap()
           Returns a boolean flag controls whether or not the string is auto wrap when text can not be drawn in one line.
 boolean isForceInsideTextNoWrap()
           Returns whether or not the inside text is no wrap.
 boolean isForceShowAll()
           Returns whether or not draw text even if it's too long to show.
 void setAutoWrap(boolean autoWrap)
           Sets a boolean flag controls whether or not the string is auto wrap when text can not be drawn in one line,and sends a ChartShapeChangeEvent to all registered listeners.
 void setDrawArea(java.awt.geom.Rectangle2D drawArea)
           Sets the text draw area,and sends a ChartShapeChangeEvent to all registered listeners.
 void setForceInsideTextNoWrap(boolean flag)
           Sets whether or not the inside text is no wrap,and sends a ChartShapeChangeEvent to all registered listeners.
 void setForceShowAllText(boolean flag)
           Sets the boolean flag whether or not draw text even if it's too long to show,and sends a ChartShapeChangeEvent to all registered listeners.
 void setTextMaxShowLine(int textMaxShowLine)
           Sets the maximum number of lines for text,and sends a ChartShapeChangeEvent to all registered listeners.
protected  java.lang.String[] splitString(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area)
           Split a line to multiple line for drawing in the canvas.
 java.lang.String toString()
           Returns a string representation of the object.
 void translate(double tx, double ty)
           Concatenates the current Graphics2D Transform with a translation transform.and sends a ChartShapeChangeEvent to all registered listeners.
 
Methods inherited from class com.ijchart.xychart.shape.AbstractTextChartShape
getText, getTextDirection, getTextFont, getTextHorizontalAlign, getTextPaint, getTextPosition, getTextVerticalAlign, isDrawText, setDrawText, setText, setTextDirection, setTextFont, setTextHorizontalAlign, setTextPaint, setTextPosition, setTextVerticalAlign
 
Methods inherited from class com.ijchart.xychart.shape.AbstractChartShape
addChangeListener, afterDraw, beforeDraw, calculateTransformedShape, chartShapeChanged, contains, contains, drawAnchorByPoints, drawBackground, drawBorder, drawSelect, drawShapeBorder, fillShape, fireChartShapeChanged, forceChartShapeChanged, getBorderPaint, getBorderStroke, getBound, getData, getFillAlpha, getFillPaint, getGradientPaintTransformType, getHotspotPolyCoords, getHotspotShape, getHotspotType, getHotspotType, getId, getMargin, getOriginTooltipShape, getRotate, getSelectAnchorPaint, getSelectRectAlpha, getSelectRectWidth, getShapeChange, getShapeDrawType, getTooltipShape, getTooltipShapeRotate, getTooltipText, getURL, hasListener, isDrawBorder, isFillShape, isSelected, isVisible, notifyListeners, removeAllChangeListener, removeChangeListener, setBorderPaint, setBorderStroke, setData, setDrawBorder, setFillAlpha, setFillPaint, setFillShape, setGradientPaintTransformType, setId, setMargin, setOriginTooltipShape, setRotate, setSelectAnchorPaint, setSelected, setSelectRectAlpha, setSelectRectWidth, setShapeChange, setShapeDrawType, setTooltipText, setURL, setVisible
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.ijchart.xychart.shape.IChartShape
draw, getShapeType
 

Field Detail

DEFAULT_DRAW_AUTO_WRAP

public static final boolean DEFAULT_DRAW_AUTO_WRAP
The default auto wrap.

See Also:
Constant Field Values

DEFAULT_TEXT_MAX_SHOW_LINE

public static final int DEFAULT_TEXT_MAX_SHOW_LINE
The default maximum number of lines for text (default is all).

See Also:
Constant Field Values

DEFAULT_FORCE_INSIDE_TEXT_NO_WRAP

public static final boolean DEFAULT_FORCE_INSIDE_TEXT_NO_WRAP
A default boolean flag controls whether or not the inside text is no wrap.

See Also:
Constant Field Values

DEFAULT_FORCE_SHOW_ALL

public static final boolean DEFAULT_FORCE_SHOW_ALL
A default boolean flag controls whether or not draw text even if it's too long to show.

See Also:
Constant Field Values
Constructor Detail

AbstractRectangleTextChartShape

protected AbstractRectangleTextChartShape(java.awt.geom.Rectangle2D drawArea,
                                          java.lang.String text)
Draw text in area drawArea.

Parameters:
drawArea - Rectangle2D The draw area (null not permitted).
text - String The text (null permitted).

AbstractRectangleTextChartShape

protected AbstractRectangleTextChartShape(java.awt.geom.Rectangle2D drawArea,
                                          java.lang.String text,
                                          java.awt.Font font)
Draw text in area drawArea.

Parameters:
drawArea - Rectangle2D The draw area (null not permitted).
text - String The text (null permitted).
font - The specified font (null permitted).If font is null, IChartShape.DEFAULT_TEXT_FONT is used.
Method Detail

getDrawArea

public java.awt.geom.Rectangle2D getDrawArea()
Returns the text draw area.

Returns:
Rectangle2D The text draw area (never null).

setDrawArea

public void setDrawArea(java.awt.geom.Rectangle2D drawArea)
Sets the text draw area,and sends a ChartShapeChangeEvent to all registered listeners.

Parameters:
drawArea - Rectangle2D The text draw area (null not permitted).

isAutoWrap

public boolean isAutoWrap()
Returns a boolean flag controls whether or not the string is auto wrap when text can not be drawn in one line.

Returns:
boolean

setAutoWrap

public void setAutoWrap(boolean autoWrap)
Sets a boolean flag controls whether or not the string is auto wrap when text can not be drawn in one line,and sends a ChartShapeChangeEvent to all registered listeners.

Parameters:
autoWrap - A boolean.

isForceInsideTextNoWrap

public boolean isForceInsideTextNoWrap()
Returns whether or not the inside text is no wrap.

Returns:
boolean

setForceInsideTextNoWrap

public void setForceInsideTextNoWrap(boolean flag)
Sets whether or not the inside text is no wrap,and sends a ChartShapeChangeEvent to all registered listeners.

Parameters:
flag - boolean

getTextMaxShowLine

public int getTextMaxShowLine()
Returns the maximum number of lines for text.

Returns:
int The maximum number of lines for text,must greater or equal to 1 .

setTextMaxShowLine

public void setTextMaxShowLine(int textMaxShowLine)
Sets the maximum number of lines for text,and sends a ChartShapeChangeEvent to all registered listeners.

Parameters:
textMaxShowLine - int The maximum number of lines for text,must greater or equal to 1 .

isForceShowAll

public boolean isForceShowAll()
Returns whether or not draw text even if it's too long to show.

Returns:
boolean A boolean.

setForceShowAllText

public void setForceShowAllText(boolean flag)
Sets the boolean flag whether or not draw text even if it's too long to show,and sends a ChartShapeChangeEvent to all registered listeners.

Parameters:
flag - boolean A boolean.

drawText

protected void drawText(java.awt.Graphics2D g2,
                        java.awt.geom.Rectangle2D area)
Draw text.

Parameters:
g2 - Graphics2D the graphics device (such as the screen or the printer) (null not permitted).
area - Rectangle2D The draw area (null not permitted).

drawTextWithTrimMarginRect

protected void drawTextWithTrimMarginRect(java.awt.Graphics2D g2,
                                          java.awt.geom.Rectangle2D drawArea)
Draw text on rectangle area.

Parameters:
g2 - Graphics2D the graphics device (such as the screen or the printer) (null not permitted).
drawArea - Rectangle2D The draw area (null not permitted).

translate

public void translate(double tx,
                      double ty)
Concatenates the current Graphics2D Transform with a translation transform.and sends a ChartShapeChangeEvent to all registered listeners. Subsequent rendering is translated by the specified distance relative to the previous position. This is equivalent to calling transform(T), where T is an AffineTransform represented by the following matrix:
                [   1    0    tx  ]
                [   0    1    ty  ]
                [   0    0    1   ]
 
.

Specified by:
translate in interface IChartShape
Parameters:
tx - double The distance to translate along the x-axis.
ty - double The distance to translate along the y-axis.

getTopLeftPoint

public java.awt.geom.Point2D getTopLeftPoint()
Returns the top left corner coordinates of this shape.

Specified by:
getTopLeftPoint in interface IChartShape
Returns:
Point2D The coordinate.

getLockPoint

public java.awt.geom.Point2D getLockPoint()
Returns the lock coordinates of this shape.

Specified by:
getLockPoint in interface IChartShape
Overrides:
getLockPoint in class AbstractChartShape
Returns:
Point2D The coordinate.

splitString

protected java.lang.String[] splitString(java.awt.Graphics2D g2,
                                         java.awt.geom.Rectangle2D area)
Split a line to multiple line for drawing in the canvas.

Parameters:
g2 - Graphics2D The specified Graphics context.
area - Rectangle2D The area of draw text.
Returns:
String[] The splited string array.

getTooltipShapeTranslatePoint

protected java.awt.geom.Point2D getTooltipShapeTranslatePoint()
Returns the translate point of tooltip shape.

Overrides:
getTooltipShapeTranslatePoint in class AbstractChartShape
Returns:
Point2D The translate point (null permitted).

equals

public boolean equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this one.

Overrides:
equals in class AbstractTextChartShape
Parameters:
obj - the reference object with which to compare.
Returns:
true if this object is the same as the obj argument; false otherwise.

hashCode

public int hashCode()
Returns a hash code value for the object.

Overrides:
hashCode in class AbstractTextChartShape
Returns:
int A hash code value for this object.

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Creates and returns a copy of this object.

Overrides:
clone in class AbstractTextChartShape
Returns:
object a clone of this instance.
Throws:
java.lang.CloneNotSupportedException - if the object's class does not support the Cloneable interface. Subclasses that override the clone method can also throw this exception to indicate that an instance cannot be cloned.

toString

public java.lang.String toString()
Returns a string representation of the object.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of the object.