com.ijchart.xychart.shape
Class SectorChartShape

java.lang.Object
  extended by com.ijchart.xychart.shape.AbstractChartShape
      extended by com.ijchart.xychart.shape.AbstractTextChartShape
          extended by com.ijchart.xychart.shape.AbstractRectangleTextChartShape
              extended by com.ijchart.xychart.shape.SectorChartShape
All Implemented Interfaces:
IChartShapeChangeListener, IChartShape, java.io.Serializable, java.lang.Cloneable, java.util.EventListener
Direct Known Subclasses:
RingChartShape

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

Title: IJChart

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

Draw a sector shape

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 java.awt.Paint DEFAULT_ARC_BORDER_PAINT
           The paint used to draw border.
static double DEFAULT_DEPTH_3D
           The default depth of 3D pie.
static boolean DEFAULT_DRAW_RADIUS
           A default boolean flag controls whether or not draw arc radius.
static java.awt.Paint DEFAULT_LABEL_BACKGROUND_PAINT
           The default section label background paint.
static java.awt.Paint DEFAULT_LABEL_OUTLINE_PAINT
           The default section label outline paint.
static java.awt.Stroke DEFAULT_LABEL_OUTLINE_STROKE
           The default section label outline stroke.
static RectangleInsets DEFAULT_LABEL_PADDING
           The default padding between the labels and the label outlines.
static java.awt.Paint DEFAULT_LABEL_SHADOW_PAINT
           The default section label shadow paint.
static double DEFAULT_LABEL_SHADOW_X_OFFSET
           The default x-offset for the label shadow effect.
static double DEFAULT_LABEL_SHADOW_Y_OFFSET
           The default y-offset for the label shadow effect.
static boolean DEFAULT_SECTOR_IS_3D
           A default flag that controls whether or not the sector is 3D.
static java.awt.Paint DEFAULT_SECTOR_SHADOW_PAINT
           The default paint used to draw sector shadow.
static double DEFAULT_SECTOR_SHADOW_X_OFFSET
           The default x-offset for the sector shadow effect.
static double DEFAULT_SECTOR_SHADOW_Y_OFFSET
           The default y-offset for the sector shadow effect.
 
Fields inherited from class com.ijchart.xychart.shape.AbstractRectangleTextChartShape
DEFAULT_DRAW_AUTO_WRAP, DEFAULT_FORCE_INSIDE_TEXT_NO_WRAP, DEFAULT_FORCE_SHOW_ALL, DEFAULT_TEXT_MAX_SHOW_LINE
 
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
SectorChartShape(java.awt.geom.Arc2D arc, java.awt.geom.Rectangle2D drawArea, java.lang.String text)
           A constructor.
SectorChartShape(java.awt.geom.Arc2D arc, java.awt.geom.Rectangle2D drawArea, java.lang.String text, boolean sector3D)
           A constructor.
 
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.
 java.awt.geom.Arc2D getArc()
           Returns the arc shape.
 double getDepth3D()
           Returns the depth of 3D pie.
protected  java.awt.Shape getHotspotShape()
           Returns the hotspot shape.
 java.awt.Paint getLabelBackgroundPaint()
           Returns the color used to draw the background of the section labels.
 java.awt.Paint getLabelOutlinePaint()
           Returns the paint used to draw the outline of the section labels.
 java.awt.Stroke getLabelOutlineStroke()
           Returns the stroke used to draw the outline of the section labels.
 RectangleInsets getLabelPadding()
           Returns the padding between the labels and the label outlines.
 java.awt.Paint getLabelShadowPaint()
           Returns the paint used to draw sector shadow.
 double getLabelShadowXOffset()
           Returns the x-offset for the label shadow effect.
 double getLabelShadowYOffset()
           Returns the y-offset for the label shadow effect.
 java.awt.geom.Point2D getLockPoint()
           Returns the lock coordinates of this shape.
protected  java.awt.geom.Point2D[] getPointsOfArc(java.awt.geom.Arc2D arc)
           Returns the points of arc:center,left,right.
 java.awt.Paint getSectorShadowPaint()
           Returns the paint used to draw the shadow for the section labels.
 double getSectorShadowXOffset()
           Returns the x-offset for the sector shadow effect.
 double getSectorShadowYOffset()
           Returns the y-offset for the sector shadow effect.
 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 isDrawRadius()
           A boolean flag controls whether or not draw arc radius.
 boolean isSector3D()
           Returns the flag that controls whether or not the sector is 3D.
 void setArc(java.awt.geom.Arc2D arc)
           Sets the arc shape,and sends a ChartShapeChangeEvent to all registered listeners.
 void setDepth3D(double depth3D)
           Sets the depth of 3D pie and sends a ChartShapeChangeEvent to all registered listeners.
 void setDrawRadius(boolean flag)
           A boolean flag controls whether or not draw arc radius,and sends a ChartShapeChangeEvent to all registered listeners.
 void setLabelBackgroundPaint(java.awt.Paint paint)
           Sets the color used to draw the background of the section labels and sends a ChartShapeChangeEvent to all registered listeners.
 void setLabelOutlinePaint(java.awt.Paint paint)
           Sets the paint used to draw the outline of the section labels and sends a ChartShapeChangeEvent to all registered listeners.
 void setLabelOutlineStroke(java.awt.Stroke stroke)
           Sets the stroke used to draw the outline of the section labels and sends a ChartShapeChangeEvent to all registered listeners.
 void setLabelPadding(RectangleInsets padding)
           Sets the padding between the labels and the label outlines and sends a ChartShapeChangeEvent to all registered listeners.
 void setLabelShadowPaint(java.awt.Paint paint)
           Sets the paint used to draw sector shadow and sends a ChartShapeChangeEvent to all registered listeners.
 void setLabelShadowXOffset(double offset)
           Sets the x-offset for the label shadow effect and sends a ChartShapeChangeEvent to all registered listeners.
 void setLabelShadowYOffset(double offset)
           Sets the y-offset for the label shadow effect and sends a ChartShapeChangeEvent to all registered listeners.
 void setSector3D(boolean flag)
           Sets the flag that controls whether or not the sector is 3D and sends a ChartShapeChangeEvent to all registered listeners.
 void setSectorShadowPaint(java.awt.Paint paint)
           Sets the paint used to draw the shadow for the section labels and sends a ChartShapeChangeEvent to all registered listeners.
 void setSectorShadowXOffset(double offset)
           Sets the x-offset for the sector shadow effect and sends a ChartShapeChangeEvent to all registered listeners.
 void setSectorShadowYOffset(double offset)
           Sets the y-offset for the sector shadow effect 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.AbstractRectangleTextChartShape
drawText, drawTextWithTrimMarginRect, getDrawArea, getTextMaxShowLine, getTooltipShapeTranslatePoint, isAutoWrap, isForceInsideTextNoWrap, isForceShowAll, setAutoWrap, setDrawArea, setForceInsideTextNoWrap, setForceShowAllText, setTextMaxShowLine, splitString, toString
 
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, chartShapeChanged, contains, contains, drawAnchorByPoints, drawBackground, drawBorder, drawShapeBorder, fillShape, fireChartShapeChanged, forceChartShapeChanged, getBorderPaint, getBorderStroke, getBound, getData, getFillAlpha, getFillPaint, getGradientPaintTransformType, getHotspotPolyCoords, 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
 

Field Detail

DEFAULT_DRAW_RADIUS

public static final boolean DEFAULT_DRAW_RADIUS
A default boolean flag controls whether or not draw arc radius.

See Also:
Constant Field Values

DEFAULT_ARC_BORDER_PAINT

public static final java.awt.Paint DEFAULT_ARC_BORDER_PAINT
The paint used to draw border.


DEFAULT_LABEL_BACKGROUND_PAINT

public static final java.awt.Paint DEFAULT_LABEL_BACKGROUND_PAINT
The default section label background paint.


DEFAULT_LABEL_OUTLINE_PAINT

public static final java.awt.Paint DEFAULT_LABEL_OUTLINE_PAINT
The default section label outline paint.


DEFAULT_LABEL_OUTLINE_STROKE

public static final java.awt.Stroke DEFAULT_LABEL_OUTLINE_STROKE
The default section label outline stroke.


DEFAULT_LABEL_SHADOW_PAINT

public static final java.awt.Paint DEFAULT_LABEL_SHADOW_PAINT
The default section label shadow paint.


DEFAULT_LABEL_PADDING

public static final RectangleInsets DEFAULT_LABEL_PADDING
The default padding between the labels and the label outlines.


DEFAULT_LABEL_SHADOW_X_OFFSET

public static final double DEFAULT_LABEL_SHADOW_X_OFFSET
The default x-offset for the label shadow effect.

See Also:
Constant Field Values

DEFAULT_LABEL_SHADOW_Y_OFFSET

public static final double DEFAULT_LABEL_SHADOW_Y_OFFSET
The default y-offset for the label shadow effect.

See Also:
Constant Field Values

DEFAULT_SECTOR_SHADOW_PAINT

public static final java.awt.Paint DEFAULT_SECTOR_SHADOW_PAINT
The default paint used to draw sector shadow.


DEFAULT_SECTOR_SHADOW_X_OFFSET

public static final double DEFAULT_SECTOR_SHADOW_X_OFFSET
The default x-offset for the sector shadow effect.

See Also:
Constant Field Values

DEFAULT_SECTOR_SHADOW_Y_OFFSET

public static final double DEFAULT_SECTOR_SHADOW_Y_OFFSET
The default y-offset for the sector shadow effect.

See Also:
Constant Field Values

DEFAULT_SECTOR_IS_3D

public static final boolean DEFAULT_SECTOR_IS_3D
A default flag that controls whether or not the sector is 3D.

See Also:
Constant Field Values

DEFAULT_DEPTH_3D

public static final double DEFAULT_DEPTH_3D
The default depth of 3D pie.

See Also:
Constant Field Values
Constructor Detail

SectorChartShape

public SectorChartShape(java.awt.geom.Arc2D arc,
                        java.awt.geom.Rectangle2D drawArea,
                        java.lang.String text)
A constructor.

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

SectorChartShape

public SectorChartShape(java.awt.geom.Arc2D arc,
                        java.awt.geom.Rectangle2D drawArea,
                        java.lang.String text,
                        boolean sector3D)
A constructor.

Parameters:
arc - Arc2D A arc shape (null not permitted).
drawArea - Rectangle2D The draw area (null not permitted).
text - String The text (null permitted).
sector3D - boolean A flag that controls whether or not the sector is 3D.
Method Detail

getArc

public java.awt.geom.Arc2D getArc()
Returns the arc shape.

Returns:
Arc2D The arc shape (never null).

setArc

public void setArc(java.awt.geom.Arc2D arc)
Sets the arc shape,and sends a ChartShapeChangeEvent to all registered listeners.

Parameters:
arc - Arc2D The arc shape (null not permitted).

isDrawRadius

public boolean isDrawRadius()
A boolean flag controls whether or not draw arc radius.

Returns:
boolean A boolean.

setDrawRadius

public void setDrawRadius(boolean flag)
A boolean flag controls whether or not draw arc radius,and sends a ChartShapeChangeEvent to all registered listeners.

Parameters:
flag - boolean A boolean.

getLabelBackgroundPaint

public java.awt.Paint getLabelBackgroundPaint()
Returns the color used to draw the background of the section labels.

Returns:
Paint The paint.

setLabelBackgroundPaint

public void setLabelBackgroundPaint(java.awt.Paint paint)
Sets the color used to draw the background of the section labels and sends a ChartShapeChangeEvent to all registered listeners.

Parameters:
paint - Paint The paint (null permitted).

getLabelOutlinePaint

public java.awt.Paint getLabelOutlinePaint()
Returns the paint used to draw the outline of the section labels.

Returns:
Paint The paint.

setLabelOutlinePaint

public void setLabelOutlinePaint(java.awt.Paint paint)
Sets the paint used to draw the outline of the section labels and sends a ChartShapeChangeEvent to all registered listeners.

Parameters:
paint - Paint The paint (null permitted).

getLabelOutlineStroke

public java.awt.Stroke getLabelOutlineStroke()
Returns the stroke used to draw the outline of the section labels.

Returns:
Stroke The stroke.

setLabelOutlineStroke

public void setLabelOutlineStroke(java.awt.Stroke stroke)
Sets the stroke used to draw the outline of the section labels and sends a ChartShapeChangeEvent to all registered listeners.

Parameters:
stroke - Stroke The stroke (null permitted).

getLabelShadowPaint

public java.awt.Paint getLabelShadowPaint()
Returns the paint used to draw sector shadow.

Returns:
Paint The paint (maybe null).

setLabelShadowPaint

public void setLabelShadowPaint(java.awt.Paint paint)
Sets the paint used to draw sector shadow and sends a ChartShapeChangeEvent to all registered listeners.

Parameters:
paint - Paint The paint (null permitted).

getLabelPadding

public RectangleInsets getLabelPadding()
Returns the padding between the labels and the label outlines.

Returns:
RectangleInsets The padding (never null).

setLabelPadding

public void setLabelPadding(RectangleInsets padding)
Sets the padding between the labels and the label outlines and sends a ChartShapeChangeEvent to all registered listeners.

Parameters:
padding - RectangleInsets The padding (null not permitted).

getLabelShadowXOffset

public double getLabelShadowXOffset()
Returns the x-offset for the label shadow effect.

Returns:
double The x-offset.

setLabelShadowXOffset

public void setLabelShadowXOffset(double offset)
Sets the x-offset for the label shadow effect and sends a ChartShapeChangeEvent to all registered listeners.

Parameters:
offset - double The x-offset.

getLabelShadowYOffset

public double getLabelShadowYOffset()
Returns the y-offset for the label shadow effect.

Returns:
double The y-offset.

setLabelShadowYOffset

public void setLabelShadowYOffset(double offset)
Sets the y-offset for the label shadow effect and sends a ChartShapeChangeEvent to all registered listeners.

Parameters:
offset - double The y-offset.

getSectorShadowPaint

public java.awt.Paint getSectorShadowPaint()
Returns the paint used to draw the shadow for the section labels.

Returns:
Paint The paint.

setSectorShadowPaint

public void setSectorShadowPaint(java.awt.Paint paint)
Sets the paint used to draw the shadow for the section labels and sends a ChartShapeChangeEvent to all registered listeners.

Parameters:
paint - Paint

getSectorShadowXOffset

public double getSectorShadowXOffset()
Returns the x-offset for the sector shadow effect.

Returns:
double The x-offset.

setSectorShadowXOffset

public void setSectorShadowXOffset(double offset)
Sets the x-offset for the sector shadow effect and sends a ChartShapeChangeEvent to all registered listeners.

Parameters:
offset - double The x-offset.

getSectorShadowYOffset

public double getSectorShadowYOffset()
Returns the y-offset for the sector shadow effect.

Returns:
double The y-offset.

setSectorShadowYOffset

public void setSectorShadowYOffset(double offset)
Sets the y-offset for the sector shadow effect and sends a ChartShapeChangeEvent to all registered listeners.

Parameters:
offset - double The y-offset.

isSector3D

public boolean isSector3D()
Returns the flag that controls whether or not the sector is 3D.

Returns:
boolean A boolean.

setSector3D

public void setSector3D(boolean flag)
Sets the flag that controls whether or not the sector is 3D and sends a ChartShapeChangeEvent to all registered listeners.

Parameters:
flag - boolean A boolean.

getDepth3D

public double getDepth3D()
Returns the depth of 3D pie.

Returns:
double The depth.

setDepth3D

public void setDepth3D(double depth3D)
Sets the depth of 3D pie and sends a ChartShapeChangeEvent to all registered listeners.

Parameters:
depth3D - double The depth.

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).

getLockPoint

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

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

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
Overrides:
translate in class AbstractRectangleTextChartShape
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
Overrides:
getTopLeftPoint in class AbstractRectangleTextChartShape
Returns:
Point2D The coordinate.

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.

getPointsOfArc

protected java.awt.geom.Point2D[] getPointsOfArc(java.awt.geom.Arc2D arc)
Returns the points of arc:center,left,right.

Parameters:
arc - Arc2D
Returns:
Point2D[]

hashCode

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

Overrides:
hashCode in class AbstractRectangleTextChartShape
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 AbstractRectangleTextChartShape
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 AbstractRectangleTextChartShape
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.