Summ:  Constr. Methods    Details:  Constr. Methods      Class:  Prev Next
com.artfulbits.aiCharts.Base
Class ChartArea

java.lang.Object com.artfulbits.aiCharts.Base.ChartArea

Declaration: public final class ChartArea extends Object
implements ILayout.IElement
All Interfaces: ILayout.IElement

 

Represents chart area class. Chart area is an integral part of ChartEngine. It handles series and axes drawing logic. By design, chart passes recursive draw and layout calls to its children. Parent ChartEngine is able to host several areas represented by areas collection. Legend may represent series from separate areas making possible complex layout design depending on desired output (i.e. couple pie charts with legend representing each of them).
 // Retrieving default ChartEngine from ChartView
 Chart chart = chartView.getChart();
 // Adding 3 pie areas to the chart.
 for(int i = 0; i < 3; i++)
 {
 	// Instantiating ChartArea.
 	ChartArea area = new ChartArea();
  // Setting the area name
  area.setName( "area" + i );
 	// Adding new area to chart.
 	chart.getAreas().add(area);
 
  // Instantiating ChartSeries.
 	ChartSeries series = new ChartSeries("Series" + Integer.toString(i),
 			ChartTypes.Pie);
 	// Caching points collection.
 	ChartPointCollection points = series.getPoints();
 	// Adding 10 points to series.
 	for(int j = 0; j < 10; j++)
 	{
 		points.addXY(j, j * 100);
 	}
 
  // Wiring series with area
  series.setArea( area.getName() );
  // Adding series to chart.
  chart.getSeries().add(series);
 }
 
Following output is expected:

XML Attributes
nameDefines area name
gridDefines grid background resource

 

Since: 1.0
See also: ChartLegendChartAxisChartSeries

 

 

Constructors Summary
ChartArea()
    
Initializes a new instance of ChartArea.
ChartArea(ChartAxis xAxis, ChartAxis yAxis)
    
Initializes a new instance of ChartArea class using passed axes.
ChartArea(java.lang.String name)
    
Initialize a new instance of ChartArea with specified Name.

 

 

Methods Summary
void draw(Canvas canvas)
    
Draws area on the provided Canvas.
java.util.List<ChartAxis> getAxes()
    
Gets ChartAxis collection.
Drawable getBackground()
    
Gets the Drawable that is used to draw background of area.
Rect getBounds()
    
Gets area bounding rectangle.
CoordinateSystem getCoordinateSystem()
    
Returns current coordinate system.
ChartAxis getDefaultXAxis()
    
Gets the default X axis.
ChartAxis getDefaultYAxis()
    
Gets the default Y axis.
Drawable getGridBackground()
    
Gets the Drawable that is used to draw background of area.
java.lang.String getName()
    
Gets the name of this area.
Rect getSeriesBounds()
    
Gets region occupied by series.
void layout(Rect rect)
    
Sets bounds for this element.
void measure(Point inOutSize)
    
Measures the element.
void refresh()
    
Refreshes the area.
void setBackground(Drawable drawable)
    
Sets the Drawable that is used to draw background of area grid.
void setBounds(Rect rect)
    
Sets bounds for this area.
void setDefaultXAxis(ChartAxis axis)
    
Sets the default X axis.
void setDefaultYAxis(ChartAxis axis)
    
Sets the default Y axis.
void setGridBackground(Drawable drawable)
    
Sets the Drawable that is used to draw background of area grid.
void setName(java.lang.String name)
    
Sets the name for area.

 

Methods inherited from class: java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

 

 

 

ChartArea

 

public ChartArea( )

 

Initializes a new instance of ChartArea. Sets default orientation for X and Y axes. Series should be added to area in order to be represented.

 

Since: 1.0
See also: ChartEngine.getAreas()ChartSeries

 

 

 

ChartArea

 

public ChartArea( java.lang.String name)

 

Initialize a new instance of ChartArea with specified Name. Sets default orientation for X and Y axes. Series should be added to area in order to be represented.

 

Parameters:
name-
unique chart area name

 

Since: 1.0
See also: ChartEngine.getAreas()ChartSeries

 

 

 

ChartArea

 

public ChartArea( ChartAxis xAxis,
ChartAxis yAxis)

 

Initializes a new instance of ChartArea class using passed axes.

 

Parameters:
xAxis-
Vertical axis that represents default X axis for area.
yAxis-
Horizontal axis that represents default Y axis for

 

Since: 1.0
See also: ChartArea()ChartAxisChartSeriesChartEngine

 

 

 

 

getName

 

public java.lang.String getName( )

 

Gets the name of this area.

 

Returns:
java.lang.String representation of area' name.

 

Since: 1.0

 

 

 

setName

 

public void setName( java.lang.String name)

 

Sets the name for area.

 

Parameters:
name-
java.lang.String representation of desired name.

 

Since: 1.0

 

 

 

setGridBackground

 

public void setGridBackground( Drawable drawable)

 

Sets the Drawable that is used to draw background of area grid.

 

Parameters:
drawable-
instance of Drawable class.

 

Since: 1.0

 

 

 

getGridBackground

 

public Drawable getGridBackground( )

 

Gets the Drawable that is used to draw background of area.

 

Returns:
instance of Drawable class.

 

Since: 1.0

 

 

 

setBackground

 

public void setBackground( Drawable drawable)

 

Sets the Drawable that is used to draw background of area grid.

 

Parameters:
drawable-
instance of Drawable class.

 

Since: 1.0

 

 

 

getBackground

 

public Drawable getBackground( )

 

Gets the Drawable that is used to draw background of area.

 

Returns:
instance of Drawable class.

 

Since: 1.0

 

 

 

getDefaultXAxis

 

public ChartAxis getDefaultXAxis( )

 

Gets the default X axis.

 

Returns:
instance of ChartAxis used as default X axis.

 

Since: 1.0

 

 

 

setDefaultXAxis

 

public void setDefaultXAxis( ChartAxis axis)

 

Sets the default X axis.

 

Parameters:
axis-
instance of ChartAxis that should be used as default X axis

 

Since: 1.0

 

 

 

getDefaultYAxis

 

public ChartAxis getDefaultYAxis( )

 

Gets the default Y axis.

 

Returns:
instance of ChartAxis used as default X axis.

 

Since: 1.0

 

 

 

setDefaultYAxis

 

public void setDefaultYAxis( ChartAxis axis)

 

Sets the default Y axis.

 

Parameters:
axis-
instance of ChartAxis that should be used as default Y axis

 

Since: 1.0

 

 

 

getBounds

 

public Rect getBounds( )

 

Gets area bounding rectangle.

 

Returns:
Rect representing current area bounds.

 

Since: 1.0

 

 

 

getSeriesBounds

 

public Rect getSeriesBounds( )

 

Gets region occupied by series.

 

Returns:
instance of RectF representing area's series bounds.

 

Since: 1.0

 

 

 

setBounds

 

public void setBounds( Rect rect)

 

Sets bounds for this area.

 

Parameters:
rect-
instance of Rect region that should be occupied by this area.

 

Since: 1.0

 

 

 

getAxes

 

public java.util.List<ChartAxis> getAxes( )

 

Gets ChartAxis collection.

 

Returns:
instance of java.util.List filled with axes.

 

Since: 1.0

 

 

 

getCoordinateSystem

 

public CoordinateSystem getCoordinateSystem( )

 

Returns current coordinate system.

 

Returns:
The coordinate system.

 

Since: 1.0

 

 

 

layout

 

public void layout( Rect rect)

 

[ description from ILayout.IElement.layout(Rect) ]
 
Sets bounds for this element.

 

Implements: ILayout.IElement.layout(Rect)

 

 

 

measure

 

public void measure( Point inOutSize)

 

[ description from ILayout.IElement.measure(Point) ]
 
Measures the element.

 

Implements: ILayout.IElement.measure(Point)

 

 

 

draw

 

public void draw( Canvas canvas)

 

Draws area on the provided Canvas.

 

Parameters:
canvas-
instance of Canvas class.

 

Since: 1.0

 

 

 

refresh

 

public void refresh( )

 

Refreshes the area. Ensures compatible series visibility, recalculates axes range.

 

Since: 1.0

 

 

© 2005 - 2010 ArtfulBits. All rights reserved.