Summ:  Fields Constr. Methods    Details:  Fields Constr. Methods      Class:  Constants Prev Next
com.artfulbits.aiCharts.Base
Class ChartEngine

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

Declaration: public final class ChartEngine extends Object

 

Represents Chart engine initially wrapped by ChartView class. Chart engine class is a top building block of aiCharts. Yet another way to initialize the chart is XML data inflation.
main.xml:
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="vertical"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     >
     <com.artfulbits.aiCharts.View.ChartView
     	android:id="@+id/chart"
     	<b>chart="@xml/chart"</b>
         android:layout_width="fill_parent"
     	android:layout_height="fill_parent"/>
 </LinearLayout>
 
chart.xml:
 <?xml version="1.0" encoding="UTF-8"?>
 <aiChart:chart
 	xmlns:aiChart="http://www.artfulbits.com/android/aiCharts">
 	<aiChart:area>
 		<aiChart:series
 			name="series1"
 			type="Line"
 			lineWidth="3" />
 	</aiChart:area>
 </aiChart:chart>
 
Activity.onCreate(Bundle):
 super.onCreate(savedInstanceState);
 setContentView(R.layout.main);
 //Retrieving ChartView from layout.
 ChartView chartView = (ChartView)findViewById(R.id.chart);
 //Retrieving inflated series.
 ChartSeries series = chartView.getSeries().get("series1");
 //Filling series with data.
 for(int i = 0; i < 10; i++)
 {
 	series.getPoints().addXY(i, Math.cos(i));
 }
 
Following output is expected:

XML Attributes
paletteDefines palette
spacingDefines spacing between chart elements

 

Since: 1.0
See also: ChartView

 

 

Fields Summary
static int AREAS_LAYOUT
    
static int LEGENDS_LAYOUT
    
static com.artfulbits.license.LicenseData LICENSE
    
Get License Information which used by aiCharts library.
static int TITLES_LAYOUT
    

 

 

Constructors Summary
ChartEngine()
    
Initializes a new instance of Chart.
ChartEngine(android.content.res.Resources res, int xmlId)
    
Initializes a new instance of ChartEngine.
ChartEngine(android.content.res.Resources res, org.xmlpull.v1.XmlPullParser parser)
    
Initializes a new instance of ChartEngine.

 

 

Methods Summary
void addInvalidateListener(IInvalidateListener listener)
    
Adds the invalidate listener that implements IInvalidateListener interface.
void draw(android.graphics.Canvas canvas)
    
Paints chart to canvas.
ChartCollection<ChartAnnotation> getAnnotations()
    
Gets the annotations collection.
boolean getAntiAlias()
    
Gets value indicating that chart is drawn anti-aliased.
ChartNamedCollection<ChartArea> getAreas()
    
Gets the area collection.
boolean getAutoAlignAreas()
    
Gets value indicating whether chart should align child areas.
android.graphics.Rect getBounds()
    
Gets the chart bounds.
ChartNamedCollection<ChartLegend> getLegends()
    
Gets the legend collection.
ChartPalette getPalette()
    
Returns current palette assigned to chart.
ChartNamedCollection<ChartSeries> getSeries()
    
Gets the collection containing series of chart.
int getSpacing()
    
Gets value indicating distance between chart and its elements.
ChartCollection<ChartTitle> getTitles()
    
Gets the title collection.
java.util.List<java.lang.Object> hitTest(int x, int y)
    
Retrieves all chart's objects that exist at specified coordinate.
boolean isHitTestEnabled()
    
Gets value indicating whether hit testing is enabled.
void removeInvalidateListener(IInvalidateListener listener)
    
Removes previously added invalidate listener.
void save(android.graphics.Bitmap bitmap, boolean fitToBitmap)
    
Saves chart to specified android.graphics.Bitmap
void save(java.io.OutputStream stream)
    
Saves chart image to specified stream.
void setAntiAlias(boolean antiAlias)
    
Sets value indicating that chart is drawn anti-aliased.
void setAutoAlignAreas(boolean autoAlignAreas)
    
Sets value indicating whether chart should align its areas.
void setBounds(int width, int height)
    
Sets the chart bounds
void setBounds(int left, int top, int right, int bottom)
    
Sets the chart bounds.
void setBounds(android.graphics.Rect bounds)
    
Sets the chart bounds.
void setHitTestEnabled(boolean enable)
    
Sets value indicating whether hit testing is enabled.
void setPalette(ChartPalette palette)
    
Sets chart palette.
void setSpacing(int spacing)
    
Sets value indicating distance between chart and its elements.

 

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

 

 

 

 

LICENSE

 

public static final com.artfulbits.license.LicenseData LICENSE

 

Get License Information which used by aiCharts library.

 

 

 

AREAS_LAYOUT

 

public static final int AREAS_LAYOUT

 

See also: Constants

 

 

 

LEGENDS_LAYOUT

 

public static final int LEGENDS_LAYOUT

 

See also: Constants

 

 

 

TITLES_LAYOUT

 

public static final int TITLES_LAYOUT

 

See also: Constants

 

 

 

 

ChartEngine

 

public ChartEngine( )

 

Initializes a new instance of Chart. Instantiates areas, series, legend and titles collections. Initially, instance of Chart class is created by parent ChartView.

 

Since: 1.0
See also: ChartView.getChart()

 

 

 

ChartEngine

 

public ChartEngine( android.content.res.Resources res,
int xmlId)

 

Initializes a new instance of ChartEngine. Inflates xml properties from specified resources by passed id.

 

Parameters:
res-
instance of android.content.res.Resources containing XML to inflate.
xmlId-
resource ID.

 

Since: 1.0

 

 

 

ChartEngine

 

public ChartEngine( android.content.res.Resources res,
org.xmlpull.v1.XmlPullParser parser)

 

Initializes a new instance of ChartEngine. Inflates xml properties from specified resources using specified parser.

 

Parameters:
res-
instance of android.content.res.Resources containing XML to inflate.
parser-
instance of org.xmlpull.v1.XmlPullParser that is used to parse specified resource.

 

Since: 1.0

 

 

 

 

setAntiAlias

 

public void setAntiAlias( boolean antiAlias)

 

Sets value indicating that chart is drawn anti-aliased.
If AntiAlias is set to true, the chart might work slowly, should you experience performance issues, set this property to false.

 

Parameters:
antiAlias-
true if chart is to be drawn anti-aliased, otherwise false.

 

Since: 1.0

 

 

 

getAntiAlias

 

public boolean getAntiAlias( )

 

Gets value indicating that chart is drawn anti-aliased.

 

Returns:
true if chart is drawn anti-aliased, otherwise false.

 

Since: 1.0

 

 

 

getAreas

 

public ChartNamedCollection<ChartArea> getAreas( )

 

Gets the area collection.

 

Returns:
Instance of chart area collection.

 

Since: 1.0
See also: ChartView.getAreas()

 

 

 

getSeries

 

public ChartNamedCollection<ChartSeries> getSeries( )

 

Gets the collection containing series of chart.

 

Returns:
instance of series ChartNamedCollection.

 

Since: 1.0
See also: ChartView.getSeries()

 

 

 

getLegends

 

public ChartNamedCollection<ChartLegend> getLegends( )

 

Gets the legend collection.

 

Returns:
instance of legend collection.

 

Since: 1.0

 

 

 

getTitles

 

public ChartCollection<ChartTitle> getTitles( )

 

Gets the title collection.

 

Returns:
instance of title collection.

 

Since: 1.0
See also: ChartView.getTitles()

 

 

 

getAnnotations

 

public ChartCollection<ChartAnnotation> getAnnotations( )

 

Gets the annotations collection. Annotation should be added to this collection in order to be rendered on chart's surface.

 

Returns:
instance of ChartCollection used to control annotations of the chart.

 

Since: 1.0

 

 

 

setBounds

 

public void setBounds( android.graphics.Rect bounds)

 

Sets the chart bounds.

 

Parameters:
bounds-
android.graphics.Rect representing chart bounds.

 

Since: 1.0

 

 

 

setBounds

 

public void setBounds( int left,
int top,
int right,
int bottom)

 

Sets the chart bounds.

 

Parameters:
left-
The X coordinate of the left side of the rectagle
top-
The Y coordinate of the top of the rectangle
right-
The X coordinate of the right side of the rectagle
bottom-
The Y coordinate of the bottom of the rectangle

 

Since: 1.5.4

 

 

 

setBounds

 

public void setBounds( int width,
int height)

 

Sets the chart bounds

 

Parameters:
width-
desired width of chart.
height-
bounds height of chart.

 

Since: 1.0

 

 

 

getBounds

 

public android.graphics.Rect getBounds( )

 

Gets the chart bounds.

 

Returns:
android.graphics.Rect representing chart bounds.

 

Since: 1.0

 

 

 

setHitTestEnabled

 

public void setHitTestEnabled( boolean enable)

 

Sets value indicating whether hit testing is enabled.

 

Parameters:
enable-
true, if ChartEngine should track its children for further hit testing, otherwise false.

 

Since: 1.5

 

 

 

isHitTestEnabled

 

public boolean isHitTestEnabled( )

 

Gets value indicating whether hit testing is enabled.

 

Returns:
true, if ChartEngine tracks its children for further hit testing.

 

Since: 1.5

 

 

 

setPalette

 

public void setPalette( ChartPalette palette)

 

Sets chart palette.

 

Parameters:
palette-
instance of ChartPalette class.

 

Since: 1.0
See also: ChartView.setPalette(ChartPalette)

 

 

 

getPalette

 

public ChartPalette getPalette( )

 

Returns current palette assigned to chart.

 

Returns:
instance of ChartPalette class

 

Since: 1.0
See also: ChartView.getPalette()

 

 

 

setSpacing

 

public void setSpacing( int spacing)

 

Sets value indicating distance between chart and its elements.

 

Parameters:
spacing-
distance between chart elements.

 

Since: 1.0

 

 

 

getSpacing

 

public int getSpacing( )

 

Gets value indicating distance between chart and its elements.

 

Returns:
spacing distance between chart elements.

 

Since: 1.0
See also: setSpacing(int)

 

 

 

getAutoAlignAreas

 

public boolean getAutoAlignAreas( )

 

Gets value indicating whether chart should align child areas. Value is true by default.

 

Returns:
true if chart will align its areas, otherwise false.

 

Since: 1.0
See also: getSpacing()

 

 

 

setAutoAlignAreas

 

public void setAutoAlignAreas( boolean autoAlignAreas)

 

Sets value indicating whether chart should align its areas.

 

Parameters:
autoAlignAreas-
true if chart will align its areas, otherwise false

 

Since: 1.0
See also: setSpacing(int)

 

 

 

addInvalidateListener

 

public void addInvalidateListener( IInvalidateListener listener)

 

Adds the invalidate listener that implements IInvalidateListener interface. Target IInvalidateListener.onInvalidate() is called when invalidation process was triggered.
 chart.addInvalidateListener(new IInvalidateListener()
 {
 	
 	public void onInvalidate()
 	{
 		//Desired actions to respond chart invalidation.
 	}
 });
 

 

Parameters:
listener-
instance of IInvalidateListener.

 

Since: 1.0

 

 

 

removeInvalidateListener

 

public void removeInvalidateListener( IInvalidateListener listener)

 

Removes previously added invalidate listener.

 

Parameters:
listener-
instance of previously added IInvalidateListener descendant.

 

Since: 1.0

 

 

 

draw

 

public void draw( android.graphics.Canvas canvas)

 

Paints chart to canvas. Generally, invoked via the recursive draw call from parent ChartView. However, this method could be used to draw chart on optionally supplied android.graphics.Canvas.
 Bitmap b = Bitmap.createBitmap(source);
 Canvas canvas = new Canvas(b);
 chart.draw(canvas);
 

 

Parameters:
canvas-
instance of android.graphics.Canvas class.

 

Since: 1.0
See also: save(OutputStream)save(Bitmap,boolean)

 

 

 

hitTest

 

public java.util.List<java.lang.Object> hitTest( int x,
int y)

 

Retrieves all chart's objects that exist at specified coordinate.

 

Parameters:
x-
X coordinate of target point.
y-
Y coordinate of target point.
Returns:
java.util.List filled with charts objects that exist beneath specified point.

 

Since: 1.5

 

 

 

save

 

public void save( java.io.OutputStream stream)

 

Saves chart image to specified stream. Compress format - PNG.

 

Parameters:
stream-
stream to save the chart.

 

Since: 1.0
See also: save(Bitmap,boolean)

 

 

 

save

 

public void save( android.graphics.Bitmap bitmap,
boolean fitToBitmap)

 

Saves chart to specified android.graphics.Bitmap

 

Parameters:
bitmap-
a bitmap to save
fitToBitmap-
indicates whether chart should be fitted to bitmap size.

 

Since: 1.0
See also: save(OutputStream)

 

 

© 2005 - 2010 ArtfulBits. All rights reserved.