Summ:  Nested Fields Constr. Methods    Details:  Fields Constr. Methods      Class:  Constants
com.artfulbits.aiCharts
Class ChartView

java.lang.Object android.view.View com.artfulbits.aiCharts.ChartView

Declaration: public class ChartView extends android.view.View
All Interfaces: android.view.accessibility.AccessibilityEventSource, android.graphics.drawable.Drawable.Callback, android.view.KeyEvent.Callback

 

Represents View-derived class used to draw chart. ChartView initially wraps ChartEngine objects and forwards layout and draw calls accordingly. All operations involving chart's objects manipulation have to be performed on wrapped ChartEngine. ChartView class could be instantiated directly in hosting activity or inflated along with the rest layout tree tree during regular call to Activity.setContentView().
Following snippet demonstrates instantiation the view from Activity.onCreate(Bundle) method.
Consider following layout defined in Android layout resources:
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:id="@+id/mainLayout"
 android:orientation="vertical"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent">
 </LinearLayout>
 
In Activity.onCreate(Bundle) ChartView is added to main layout:
 super.onCreate(savedInstanceState);
 setContentView(R.layout.main);
 // Retrieving main layout.
 LinearLayout mainLayout = (LinearLayout) findViewById(R.id.mainLayout);
 // Instantiating chart view.
 ChartView chartView = new ChartView(this);
 // Retrieving default ChartSeries
 ChartSeries defaultSereis = chartView.initDefaultChart();
 // Caching points collection.
 ChartPointCollection points = defaultSereis.getPoints();
 // Adding 10 points to series.
 for (int i = 0; i < 10; i++)
 {
 	points.addXY(i, i * 100);
 }
 // Adding chart view to main view.
 mainLayout.addView(chartView);
 
Following output is expected:

Identical behavior could be achieved by having Android framework inflate aiCharts instead:
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/chartView"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"/> 
 </LinearLayout>
 
Activity.onCreate(Bundle)
 ...
 super.onCreate(savedInstanceState);
 setContentView(R.layout.main);
 ChartView chartView = (ChartView)findViewById(R.id.chartView);
 ...
 
Samples along the SDK will give more idea of ChartView class usages.

 

Since: 1.0
See also: getChart()

 

 

Nested Members Summary

 

Nested members inherited from class: android.view.View
View.BaseSavedState, View.MeasureSpec, View.OnClickListener, View.OnCreateContextMenuListener, View.OnFocusChangeListener, View.OnKeyListener, View.OnLongClickListener, View.OnTouchListener

 

 

Fields Summary
static int PANNING_BOTH
    
Both: the horizontal and vertical panning.
static int PANNING_HORIZONTAL
    
Horizontal panning.
static int PANNING_NONE
    
No panning.
static int PANNING_VERTICAL
    
Vertical panning.

 

Fields inherited from class: android.view.View
DRAWING_CACHE_QUALITY_AUTO, DRAWING_CACHE_QUALITY_HIGH, DRAWING_CACHE_QUALITY_LOW, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUSABLES_ALL, FOCUSABLES_TOUCH_MODE, GONE, HAPTIC_FEEDBACK_ENABLED, INVISIBLE, KEEP_SCREEN_ON, NO_ID, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SOUND_EFFECTS_ENABLED, VISIBLE

 

 

Constructors Summary
ChartView(android.content.Context context)
    
Initializes a new instance of ChartView with context specified.
ChartView(android.content.Context context, android.util.AttributeSet attrributes)
    
Initializes a new instance of ChartView with context and attributes specified.
ChartView(android.content.Context context, android.util.AttributeSet attrributes, int defStyle)
    
Initializes a new instance of ChartView with context, attributes and style specified.
ChartView(android.content.Context context, int chartId)
    
Initializes a new instance of ChartView with context specified.

 

 

Methods Summary
ChartArea addArea()
    
Creates new instance of ChartArea and adds it to areas collection.
ChartCollection<ChartArea> getAreas()
    
Gets current areas collection linked to wrapped chart.
ChartEngine getChart()
    
Gets the instance of ChartEngine class that is currently wrapped by this view.
ChartCollection<ChartLegend> getLegends()
    
Gets the legend collection.
ChartPalette getPalette()
    
Gets the palette that is currently user for series of chart.
ChartNamedCollection<ChartSeries> getSeries()
    
Gets the series collection.
ChartCollection<ChartTitle> getTitles()
    
Returns titles 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.
boolean onTouchEvent(android.view.MotionEvent event)
    
void setChart(ChartEngine chart)
    
Sets the instance of chart engine class.
void setChart(int resId)
    
Set the instance of chart engine based on XML template file stored in application resources.
void setHitTestEnabled(boolean enable)
    
Controls hit testing tracks for series.
void setPalette(ChartPalette palette)
    
Sets the palette that is currently user for series of chart.
void setPanning(int orientation)
    
Sets panning value for chart view.

 

Methods inherited from class: android.view.View
addFocusables, addFocusables, addTouchables, bringToFront, buildDrawingCache, buildDrawingCache, cancelLongPress, checkInputConnectionProxy, clearAnimation, clearFocus, computeScroll, createContextMenu, destroyDrawingCache, dispatchKeyEvent, dispatchKeyEventPreIme, dispatchKeyShortcutEvent, dispatchPopulateAccessibilityEvent, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchWindowFocusChanged, dispatchWindowVisibilityChanged, draw, findFocus, findViewById, findViewWithTag, focusSearch, forceLayout, getAnimation, getApplicationWindowToken, getBackground, getBaseline, getBottom, getContentDescription, getContext, getDefaultSize, getDrawableState, getDrawingCache, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getFocusables, getFocusedRect, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHeight, getHitRect, getHorizontalFadingEdgeLength, getId, getKeepScreenOn, getLayoutParams, getLeft, getLocalVisibleRect, getLocationInWindow, getLocationOnScreen, getMeasuredHeight, getMeasuredWidth, getNextFocusDownId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getPaddingBottom, getPaddingLeft, getPaddingRight, getPaddingTop, getParent, getResources, getRight, getRootView, getScrollBarStyle, getScrollX, getScrollY, getSolidColor, getTag, getTag, getTop, getTouchables, getTouchDelegate, getVerticalFadingEdgeLength, getVerticalScrollbarWidth, getViewTreeObserver, getVisibility, getWidth, getWindowToken, getWindowVisibility, getWindowVisibleDisplayFrame, hasFocus, hasFocusable, hasWindowFocus, inflate, invalidate, invalidate, invalidate, invalidateDrawable, isClickable, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isHapticFeedbackEnabled, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isInEditMode, isInTouchMode, isLayoutRequested, isLongClickable, isPressed, isSaveEnabled, isSelected, isShown, isSoundEffectsEnabled, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, layout, measure, offsetLeftAndRight, offsetTopAndBottom, onCheckIsTextEditor, onCreateInputConnection, onFinishTemporaryDetach, onKeyDown, onKeyMultiple, onKeyPreIme, onKeyShortcut, onKeyUp, onStartTemporaryDetach, onTrackballEvent, onWindowFocusChanged, performClick, performHapticFeedback, performHapticFeedback, performLongClick, playSoundEffect, post, postDelayed, postInvalidate, postInvalidate, postInvalidateDelayed, postInvalidateDelayed, refreshDrawableState, removeCallbacks, requestFocus, requestFocus, requestFocus, requestFocusFromTouch, requestLayout, requestRectangleOnScreen, requestRectangleOnScreen, resolveSize, restoreHierarchyState, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, sendAccessibilityEvent, sendAccessibilityEventUnchecked, setAnimation, setBackgroundColor, setBackgroundDrawable, setBackgroundResource, setClickable, setContentDescription, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setEnabled, setFadingEdgeLength, setFocusable, setFocusableInTouchMode, setHapticFeedbackEnabled, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setId, setKeepScreenOn, setLayoutParams, setLongClickable, setMinimumHeight, setMinimumWidth, setNextFocusDownId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnClickListener, setOnCreateContextMenuListener, setOnFocusChangeListener, setOnKeyListener, setOnLongClickListener, setOnTouchListener, setPadding, setPressed, setSaveEnabled, setScrollBarStyle, setScrollContainer, setSelected, setSoundEffectsEnabled, setTag, setTag, setTouchDelegate, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVisibility, setWillNotCacheDrawing, setWillNotDraw, showContextMenu, startAnimation, unscheduleDrawable, unscheduleDrawable, willNotCacheDrawing, willNotDraw

 

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

 

 

 

 

PANNING_NONE

 

public static final int PANNING_NONE

 

No panning.

 

Since: 1.0
See also: Constants

 

 

 

PANNING_VERTICAL

 

public static final int PANNING_VERTICAL

 

Vertical panning.

 

Since: 1.0
See also: Constants

 

 

 

PANNING_HORIZONTAL

 

public static final int PANNING_HORIZONTAL

 

Horizontal panning.

 

Since: 1.0
See also: Constants

 

 

 

PANNING_BOTH

 

public static final int PANNING_BOTH

 

Both: the horizontal and vertical panning.

 

Since: 1.0
See also: Constants

 

 

 

 

ChartView

 

public ChartView( android.content.Context context)

 

Initializes a new instance of ChartView with context specified.

 

Parameters:
context-
instance of android.content.Context informational class.

 

Since: 1.0

 

 

 

ChartView

 

public ChartView( android.content.Context context,
int chartId)

 

Initializes a new instance of ChartView with context specified.

 

Parameters:
context-
instance of android.content.Context informational class.
chartId-
The identifier of the chart xml resource.

 

Since: 1.5

 

 

 

ChartView

 

public ChartView( android.content.Context context,
android.util.AttributeSet attrributes)

 

Initializes a new instance of ChartView with context and attributes specified.

 

Parameters:
context-
instance of android.content.Context informational class.
attrributes-
instance of XML attributes.

 

Since: 1.0

 

 

 

ChartView

 

public ChartView( android.content.Context context,
android.util.AttributeSet attrributes,
int defStyle)

 

Initializes a new instance of ChartView with context, attributes and style specified.

 

Parameters:
context-
instance of android.content.Context informational class.
attrributes-
instance of XML attributes.
defStyle-
the default style to apply to this view.

 

Since: 1.0

 

 

 

 

setPanning

 

public void setPanning( int orientation)

 

Sets panning value for chart view.

 

Parameters:
orientation-
value of orientation.

 

Since: 1.0
See also: PANNING_BOTHPANNING_HORIZONTALPANNING_VERTICAL

 

 

 

getChart

 

public ChartEngine getChart( )

 

Gets the instance of ChartEngine class that is currently wrapped by this view.

 

Returns:
instance of ChartEngine class.

 

Since: 1.0

 

 

 

setChart

 

public void setChart( ChartEngine chart)

 

Sets the instance of chart engine class. It will be used for charts painting.

 

Parameters:
chart-
reference on chart engine instance.

 

Since: 1.0

 

 

 

setChart

 

public void setChart( int resId)

 

Set the instance of chart engine based on XML template file stored in application resources.

 

Parameters:
resId-
application resource identifier valid for set in constructor context.

 

Since: 1.0

 

 

 

getPalette

 

public ChartPalette getPalette( )

 

Gets the palette that is currently user for series of chart.

 

Returns:
instance of ChartPalette class.

 

Since: 1.0
See also: getChart()

 

 

 

setPalette

 

public void setPalette( ChartPalette palette)

 

Sets the palette that is currently user for series of chart.
For customization purposes, default series coloring can be replaced with a custom one:
 chartView.setPalette(new ChartPalette(Color.GREEN));
 
aiCharts has several predefined palettes:
 // Set the OpenOffice palette.
 chartView.setPalette(ChartPalette.OpenOffice);
 
 // Set the grayscale palette.
 chartView.setPalette(ChartPalette.Grayscale);
 

 

Parameters:
palette-
instance of ChartPalette class that provides colors for series.

 

Since: 1.0
See also: ChartPalettegetPalette()getChart()

 

 

 

setHitTestEnabled

 

public void setHitTestEnabled( boolean enable)

 

Controls hit testing tracks for series.

 

Parameters:
enable-
value that indicates whether chart has its hit testing enabeled.

 

Since: 1.5

 

 

 

isHitTestEnabled

 

public boolean isHitTestEnabled( )

 

Gets value indicating whether hit testing is enabled.

 

Returns:
true if hit testing is enabled, otherwise false.

 

Since: 1.5

 

 

 

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

 

 

 

addArea

 

public ChartArea addArea( )

 

Creates new instance of ChartArea and adds it to areas collection. Following snippet demonstrated addArea() usage:
 ChartSeries series = new ChartSeries("Series 1", ChartTypes.Line);
 // Caching points collection.
 ChartPointCollection points = series.getPoints();
 // Adding 10 points to series.
 for (int i = 0; i < 10; i++)
 {
 	points.addXY(i, i * 100);
 }
 // Retrieving added area.
 ChartArea area = chartView.addArea();
 // Adding series to chart.
 chartView.getSeries().add(series);
 

 

Returns:
new instance of ChartArea class that was added to areas collection by this call.

 

Since: 1.0
See also: getChart()

 

 

 

getAreas

 

public ChartCollection<ChartArea> getAreas( )

 

Gets current areas collection linked to wrapped chart.

 

Returns:
instance of ChartCollection class containing current areas of chart

 

Since: 1.0
See also: addArea()

 

 

 

getSeries

 

public ChartNamedCollection<ChartSeries> getSeries( )

 

Gets the series collection.
 // Iterate over series collection.
 for(ChartSeries series : chartView.getSeries())
 {
 	// Set series properties here
 	...
 }
 

 

Returns:
instance of ChartNamedCollection containing series objects

 

Since: 1.0

 

 

 

getLegends

 

public ChartCollection<ChartLegend> getLegends( )

 

Gets the legend collection.

 

Returns:
instance of ChartCollection containing currently assigned legends.

 

Since: 1.0

 

 

 

getTitles

 

public ChartCollection<ChartTitle> getTitles( )

 

Returns titles collection.

 

Returns:
instance of ChartCollection containing titles.

 

Since: 1.0

 

 

 

onTouchEvent

 

public boolean onTouchEvent( android.view.MotionEvent event)

 

Overrides: android.view.View.onTouchEvent(MotionEvent)

 

 

© 2005 - 2010 ArtfulBits. All rights reserved.