org.ujac.chart
Class BaseChartItem

java.lang.Object
  extended by org.ujac.chart.BaseChartItem
All Implemented Interfaces:
ChartItem
Direct Known Subclasses:
TextChartItem

public abstract class BaseChartItem
extends Object
implements ChartItem

Name: BaseChartItem
Description: Base ChartItem implementation.

Author:
lauerc

Field Summary
protected  Rectangle2D outputArea
          The output area.
protected  ChartItemPosition position
          The position of the chart item.
 
Constructor Summary
BaseChartItem(ChartItemPosition position)
          Constructs a BaseChartItem instance with specific attributes.
 
Method Summary
 void alignItem(Rectangle2D viewport)
          Aligns the item inside the given viewport.
protected abstract  Rectangle2D calculateOutputArea(Rectangle2D viewport, Graphics2D graphics)
          Calculates the position of the item.
 double getHeight(Rectangle2D viewport, Graphics2D graphics)
          Gets the height of the item box.
 Rectangle2D getOutputArea(Rectangle2D viewport, Graphics2D graphics)
          Gets the output area ot the chart item.
 ChartItemPosition getPosition()
          Gets the position of the chart item.
 double getWidth(Rectangle2D viewport, Graphics2D graphics)
          Gets the width of the item box.
 void move(double x, double y)
          Moves the item position.
 void moveTo(double x, double y)
          Moves the item to the desired position.
 void resetMetrics()
          Resets the calculated metrics to enforce re-calculation of the item's output area.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.ujac.chart.ChartItem
draw
 

Field Detail

position

protected ChartItemPosition position
The position of the chart item.


outputArea

protected Rectangle2D outputArea
The output area.

Constructor Detail

BaseChartItem

public BaseChartItem(ChartItemPosition position)
Constructs a BaseChartItem instance with specific attributes.

Parameters:
position - The position of the chart item.
Method Detail

getPosition

public ChartItemPosition getPosition()
Gets the position of the chart item.

Specified by:
getPosition in interface ChartItem
Returns:
The current position.

getOutputArea

public Rectangle2D getOutputArea(Rectangle2D viewport,
                                 Graphics2D graphics)
Gets the output area ot the chart item.

Specified by:
getOutputArea in interface ChartItem
Parameters:
viewport - The viewport for chart output.
graphics - The graphics object, needed to calculate the metrics.
Returns:
The output area the item will be rendered to.

resetMetrics

public void resetMetrics()
Resets the calculated metrics to enforce re-calculation of the item's output area.

Specified by:
resetMetrics in interface ChartItem

calculateOutputArea

protected abstract Rectangle2D calculateOutputArea(Rectangle2D viewport,
                                                   Graphics2D graphics)
Calculates the position of the item.

Parameters:
viewport - The viewport for chart output.
graphics - The graphics object, needed to calculate the metrics.
Returns:
The calculated output area.

getWidth

public double getWidth(Rectangle2D viewport,
                       Graphics2D graphics)
Gets the width of the item box.

Specified by:
getWidth in interface ChartItem
Parameters:
viewport - The viewport for chart output.
graphics - The graphics object, used for output.
Returns:
The width of the item box.

getHeight

public double getHeight(Rectangle2D viewport,
                        Graphics2D graphics)
Gets the height of the item box.

Specified by:
getHeight in interface ChartItem
Parameters:
viewport - The viewport for chart output.
graphics - The graphics object, used for output.
Returns:
The height of the item box.

move

public void move(double x,
                 double y)
Moves the item position.

Specified by:
move in interface ChartItem
Parameters:
x - The number of pixels by which to move the item horizontally.
y - The number of pixels by which to move the item vertically.

moveTo

public void moveTo(double x,
                   double y)
Moves the item to the desired position.

Specified by:
moveTo in interface ChartItem
Parameters:
x - The new horizontal position.
y - The new vertical position.

alignItem

public void alignItem(Rectangle2D viewport)
Aligns the item inside the given viewport.

Specified by:
alignItem in interface ChartItem
Parameters:
viewport - The area to place the item.


Copyright © 2003-2004 UJAC.org. All Rights Reserved.