com.ijchart.xychart.shape
Class LegendItemChartShape

java.lang.Object
  extended by com.ijchart.xychart.shape.AbstractChartShape
      extended by com.ijchart.xychart.shape.LegendItemChartShape
All Implemented Interfaces:
IChartShapeChangeListener, IChartShape, java.io.Serializable, java.lang.Cloneable, java.util.EventListener

public class LegendItemChartShape
extends AbstractChartShape
implements java.lang.Cloneable, java.io.Serializable

Title: IJChart

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

A legend item chart shape,composite by a chart shape and a label. Note:Some super class method does not affect graphics

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_LABEL
           A default flag that controls whether or not the label is drawn.
static double DEFAULT_GAP_SIZE
           The default space between shape and label.
 
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
LegendItemChartShape(IChartShape shape, java.lang.String label)
           Construct a legend shape by chart shape and label.
 
Method Summary
protected  void calculateTransformedShape()
           Calculate the transformed shape.
 java.lang.Object clone()
           Creates and returns a copy of this object.
 void draw(java.awt.Graphics2D g2)
           Draw the ChartShape on a Java 2d graphics device(such as the screen or the printer).
protected  void drawSelect(java.awt.Graphics2D g2)
           Draw the selected ChartShape on a Java 2d graphics device(such as the screen or the printer).
 boolean equals(java.lang.Object obj)
           Indicates whether some other object is "equal to" this one.
 Rectangle estimateDrawBound(java.awt.Graphics2D g2)
           Estimate the Rectangle of draw this shape.
 java.awt.geom.Rectangle2D getDrawArea()
           Returns the area of draw this legend shape.
 double getGapSize()
           Returns the space between shape and label.
 java.lang.String getHotspotPolyCoords()
           Returns a string containing the coordinates for a given shape.This string is intended for use in an image map.
protected  java.awt.Shape getHotspotShape()
           Returns the hotspot shape.
 java.lang.String getLabel()
           Returns the label text.
 java.awt.Font getLabelFont()
           Returns the label font.
 java.awt.Paint getLabelPaint()
           Get the ChartShape label Paint
 IChartShape getShape()
           Returns the chart shape.
 ShapeType getShapeType()
           The type for describe this 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 isDrawLabel()
           Returns a flag that controls whether or not the label is drawn.
 void setDrawArea(java.awt.geom.Rectangle2D drawArea)
           Sets the area of draw this legend shape and sends a ChartShapeChangeEvent to all registered listeners.
 void setDrawLabel(boolean drawLabel)
           Sets a flag that controls whether or not the label is drawn and sends a ChartShapeChangeEvent to all registered listeners.
 void setGapSize(double gap)
           Sets the space between shape and label and sends a ChartShapeChangeEvent to all registered listeners.
 void setLabel(java.lang.String label)
           Sets the label text,and sends a ChartShapeChangeEvent to all registered listeners..
 void setLabelFont(java.awt.Font font)
           Sets the label font and sends a ChartShapeChangeEvent to all registered listeners.
 void setLabelPaint(java.awt.Paint paint)
           Sets the shape label Paint and sends a ChartShapeChangeEvent to all registered listeners.
 void setShape(IChartShape shape)
           Sets the chart shape and sends a ChartShapeChangeEvent to all registered listeners.
 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.AbstractChartShape
addChangeListener, afterDraw, beforeDraw, chartShapeChanged, contains, contains, drawAnchorByPoints, drawBackground, drawBorder, drawShapeBorder, fillShape, fireChartShapeChanged, forceChartShapeChanged, getBorderPaint, getBorderStroke, getBound, getData, getFillAlpha, getFillPaint, getGradientPaintTransformType, getHotspotPolyCoords, getHotspotType, getHotspotType, getId, getLockPoint, getMargin, getOriginTooltipShape, getRotate, getSelectAnchorPaint, getSelectRectAlpha, getSelectRectWidth, getShapeChange, getShapeDrawType, getTooltipShape, getTooltipShapeRotate, getTooltipShapeTranslatePoint, 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, toString, wait, wait, wait
 

Field Detail

DEFAULT_DRAW_LABEL

public static final boolean DEFAULT_DRAW_LABEL
A default flag that controls whether or not the label is drawn.

See Also:
Constant Field Values

DEFAULT_GAP_SIZE

public static final double DEFAULT_GAP_SIZE
The default space between shape and label.

See Also:
Constant Field Values
Constructor Detail

LegendItemChartShape

public LegendItemChartShape(IChartShape shape,
                            java.lang.String label)
Construct a legend shape by chart shape and label.

Parameters:
shape - IChartShape The chart shape (null not permitted).
label - String The label (null permitted).
Method Detail

getShape

public IChartShape getShape()
Returns the chart shape.

Returns:
IChartShape The chart shape (never null).

setShape

public void setShape(IChartShape shape)
Sets the chart shape and sends a ChartShapeChangeEvent to all registered listeners.

Parameters:
shape - IChartShape The chart shape (null not permitted).

setDrawLabel

public void setDrawLabel(boolean drawLabel)
Sets a flag that controls whether or not the label is drawn and sends a ChartShapeChangeEvent to all registered listeners.

Parameters:
drawLabel - boolean

isDrawLabel

public boolean isDrawLabel()
Returns a flag that controls whether or not the label is drawn.

Returns:
boolean

setLabelPaint

public void setLabelPaint(java.awt.Paint paint)
Sets the shape label Paint and sends a ChartShapeChangeEvent to all registered listeners.

Parameters:
paint - Paint The ChartShape label Paint(null not permitted).

getLabelPaint

public java.awt.Paint getLabelPaint()
Get the ChartShape label Paint

Returns:
Paint The label Paint

getLabel

public java.lang.String getLabel()
Returns the label text.

Returns:
String The label text,maybe null.

setLabel

public void setLabel(java.lang.String label)
Sets the label text,and sends a ChartShapeChangeEvent to all registered listeners..

Parameters:
label - String The label text (null permitted).

getLabelFont

public java.awt.Font getLabelFont()
Returns the label font.

Returns:
Font

setLabelFont

public void setLabelFont(java.awt.Font font)
Sets the label font and sends a ChartShapeChangeEvent to all registered listeners.

Parameters:
font - Font The label font (null not permitted).

getGapSize

public double getGapSize()
Returns the space between shape and label.

Returns:
double The space between shape and label.

setGapSize

public void setGapSize(double gap)
Sets the space between shape and label and sends a ChartShapeChangeEvent to all registered listeners.

Parameters:
gap - double The space between shape and label.

getDrawArea

public java.awt.geom.Rectangle2D getDrawArea()
Returns the area of draw this legend shape.

Returns:
Rectangle2D The draw area (maybe null).

setDrawArea

public void setDrawArea(java.awt.geom.Rectangle2D drawArea)
Sets the area of draw this legend shape and sends a ChartShapeChangeEvent to all registered listeners.

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

estimateDrawBound

public Rectangle estimateDrawBound(java.awt.Graphics2D g2)
Estimate the Rectangle of draw this shape.

Parameters:
g2 - Graphics2D The graphics device (such as the screen or the printer) (null not permitted).
Returns:
Rectangle The Rectangle of draw this shape.

draw

public void draw(java.awt.Graphics2D g2)
Draw the ChartShape on a Java 2d graphics device(such as the screen or the printer). The shape's coordinate is ignored.

Specified by:
draw in interface IChartShape
Parameters:
g2 - Graphics2D The graphics device (such as the screen or the printer) (null not permitted).

drawSelect

protected void drawSelect(java.awt.Graphics2D g2)
Draw the selected ChartShape on a Java 2d graphics device(such as the screen or the printer).

Specified by:
drawSelect in class AbstractChartShape
Parameters:
g2 - Graphics2D the graphics device (such as the screen or the printer) (null not permitted).

calculateTransformedShape

protected void calculateTransformedShape()
Calculate the transformed shape.

Specified by:
calculateTransformedShape in class AbstractChartShape

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.

getHotspotPolyCoords

public java.lang.String getHotspotPolyCoords()
Returns a string containing the coordinates for a given shape.This string is intended for use in an image map.

Returns:
String The coordinates of hotspot.

getHotspotShape

protected java.awt.Shape getHotspotShape()
Returns the hotspot shape.

Specified by:
getHotspotShape in class AbstractChartShape
Returns:
Shape The hotspot shape (maybe null).

getShapeType

public ShapeType getShapeType()
The type for describe this shape.

Specified by:
getShapeType in interface IChartShape
Returns:
ShapeType The constant value in class ShapeType.

hashCode

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

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

equals

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

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

clone

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

Overrides:
clone in class AbstractChartShape
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.