Android Open Source - customhellochartdemo Chart






From Project

Back to project page customhellochartdemo.

License

The source code is released under:

Apache License

If you think the Android project customhellochartdemo listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package lecho.lib.hellocharts.view;
/*w  w w . j  a  va2s  . co  m*/
import lecho.lib.hellocharts.ChartComputator;
import lecho.lib.hellocharts.ViewportChangeListener;
import lecho.lib.hellocharts.animation.ChartAnimationListener;
import lecho.lib.hellocharts.gesture.ChartTouchHandler;
import lecho.lib.hellocharts.gesture.ContainerScrollType;
import lecho.lib.hellocharts.gesture.ZoomType;
import lecho.lib.hellocharts.model.ChartData;
import lecho.lib.hellocharts.model.SelectedValue;
import lecho.lib.hellocharts.model.Viewport;
import lecho.lib.hellocharts.renderer.AxesRenderer;
import lecho.lib.hellocharts.renderer.ChartRenderer;

/**
 * Interface for all charts. Every chart must implements this interface but chart doesn't really have to extends View or
 * ViewGroup class. It can be any java class for example chart that only draw on in-memory bitmap and saves it on sd
 * card.
 */
public interface Chart {

  /**
   * Returns generic chart data. For specific class call get*ChartData method from data provider implementation.
   */
  public ChartData getChartData();

  public ChartRenderer getChartRenderer();

  public AxesRenderer getAxesRenderer();

  public ChartComputator getChartComputator();

  public ChartTouchHandler getTouchHandler();

  /**
   * Updates chart data with given scale. Called during chart data animation update.
   */
  public void animationDataUpdate(float scale);

  /**
   * Called when data animation finished.
   */
  public void animationDataFinished();

  /**
   * Starts chart data animation for given duration. Before you call this method you should change target values of
   * chart data.
   */
  public void startDataAnimation();

  /**
   * Starts chart data animation for given duration. If duration is negative the default value of 500ms will be used.
   * Before you call this method you should change target values of chart data.
   */
  public void startDataAnimation(long duration);

  /**
   * Stops chart data animation. All chart data values are set to their target values.
   */
  public void cancelDataAnimation();

  /**
   * Return true if auto viewports recalculations are enabled, false otherwise.
   */
  public boolean isViewportCalculationEnabled();

  /**
   * Set true to enable viewports(max and current) recalculations during animations or after set*ChartData method is
   * called. If you disable viewports calculations viewports will not change until you change them manually or enable
   * calculations again. Disabled viewport calculations is usefull if you want show only part of chart by setting
   * custom viewport and don't want any operation to change that viewport
   */
  public void setViewportCalculationEnabled(boolean isEnabled);

  /**
   * Set listener for data animation to be notified when data animation started and finished. By default that flag is
   * set to true so be careful with animation and custom viewports.
   */
  public void setDataAnimationListener(ChartAnimationListener animationListener);

  /**
   * Set listener for viewport animation to be notified when viewport animation started and finished.
   */
  public void setViewportAnimationListener(ChartAnimationListener animationListener);

  /**
   * Set listener for current viewport changes. It will be called when viewport change either by gesture or
   * programmatically. Note! This method works only for preview charts. It is intentionally disabled for other types
   * of charts to avoid unnecessary method calls during invalidation.
   * 
   */
  public void setViewportChangeListener(ViewportChangeListener viewportChangeListener);

  public void callTouchListener();

  /**
   * Returns true if chart is interactive.
   * 
   * @see #setInteractive(boolean)
   */
  public boolean isInteractive();

  /**
   * Set true to allow user use touch gestures. If set to false user will not be able zoom, scroll or select/touch
   * value. By default true.
   */
  public void setInteractive(boolean isInteractive);

  /**
   * Returns true if pitch to zoom and double tap zoom is enabled.
   * 
   * @see #setZoomEnabled(boolean)
   */
  public boolean isZoomEnabled();

  /**
   * Set true to enable zoom, false to disable, by default true;
   */
  public void setZoomEnabled(boolean isZoomEnabled);

  /**
   * Returns true if scrolling is enabled.
   * 
   * @see #setScrollEnabled(boolean)
   */
  public boolean isScrollEnabled();

  /**
   * Set true to enable touch scroll/fling, false to disable touch scroll/fling, by default true;
   */
  public void setScrollEnabled(boolean isScrollEnabled);

  /**
   * Move/Srcoll viewport to position x,y(that position must be within maximum chart viewport). If possible viewport
   * will be centered at this point. Width and height of viewport will not be modified.
   * 
   * @see #setCurrentViewport(Viewport, boolean);
   */
  public void moveTo(float x, float y, boolean isAnimated);

  /**
   * Returns current zoom type for this chart.
   * 
   * @see #setZoomType(ZoomType)
   */
  public ZoomType getZoomType();

  /**
   * Set zoom type, available options: ZoomType.HORIZONTAL_AND_VERTICAL, ZoomType.HORIZONTAL, ZoomType.VERTICAL. By
   * default HORIZONTAL_AND_VERTICAL.
   */
  public void setZoomType(ZoomType zoomType);

  /**
   * Returns current maximum zoom value.
   * 
   */
  public float getMaxZoom();

  /**
   * Set max zoom value within range (1 - 20). Default maximum zoom is 20.
   * 
   */
  public void setMaxZoom(float maxZoom);

  /**
   * Returns current zoom level.
   */
  public float getZoomLevel();

  /**
   * Programatically zoom chart to given point(viewport point). Call this method after chart data had been set.
   * 
   * @param x
   *            x within chart maximum viewport
   * @param y
   *            y within chart maximum viewport
   * @param zoomLevel
   *            value from 1 to maxZoom(default 20). 1 means chart has no zoom, 20 means chart has maximum zoom.
   * @param isAnimated
   *            set true if zoom should be animated.
   */
  public void setZoomLevel(float x, float y, float zoomLevel, boolean isAnimated);

  /**
   * Return true if chart value can be touched.
   * 
   * @see #setValueTouchEnabled(boolean)
   */
  public boolean isValueTouchEnabled();

  /**
   * Set true if you want allow user to click value on chart, set false to disable that option. By default true.
   */
  public void setValueTouchEnabled(boolean isValueTouchEnabled);

  /**
   * Returns maximum viewport for this chart. Don't modify it directly, use {@link #setMaximumViewport(Viewport)}
   * instead.
   * 
   * @see #setMaximumViewport(Viewport)
   */
  public Viewport getMaximumViewport();

  /**
   * Set maximum viewport. If you set bigger maximum viewport data will be more concentrate and there will be more
   * empty spaces on sides.
   * 
   * Note. MaxViewport have to be set after chartData has been set.
   */
  public void setMaximumViewport(Viewport maxViewport);

  /**
   * Returns current viewport. Don't modify it directly, use {@link #setCurrentViewport(Viewport, boolean)} instead.
   * 
   * @see #setCurrentViewport(Viewport, boolean)
   */
  public Viewport getCurrentViewport();

  /**
   * Sets current viewport. If isAnimated is true chart will be animated during viewport changes.
   * 
   * Note. viewport have to be set after chartData has been set.
   */
  public void setCurrentViewport(Viewport targetViewport, boolean isAnimated);

  /**
   * Reset maximum viewport and current viewport. Values for both viewports will be auto-calculated using current
   * chart data ranges.
   */
  public void resetViewports();

  /**
   * Return true if value selection mode is enabled.
   * 
   * @see #setValueSelectionEnabled(boolean)
   */
  public boolean isValueSelectionEnabled();

  /**
   * Set true if you want value selection with touch - value will stay selected until you touch somewhere else on the
   * chart area. By default false and value is automatically unselected when user stop pressing on it.
   */
  public void setValueSelectionEnabled(boolean isValueSelectionEnabled);

  /**
   * Select single value on chart. If indexes are not valid IndexOutOfBoundsException will be thrown.
   */
  public void selectValue(SelectedValue selectedValue);

  /**
   * Return currently selected value indexes.
   */
  public SelectedValue getSelectedValue();

  /**
   * @see #setContainerScrollEnabled(boolean, ContainerScrollType)
   */
  public boolean isContainerScrollEnabled();

  /**
   * Set isContainerScrollEnabled to true and containerScrollType to HORIZONTAL or VERTICAL if you are using chart
   * within scroll container.
   */
  public void setContainerScrollEnabled(boolean isContainerScrollEnabled, ContainerScrollType containerScrollType);

}




Java Source Code List

lecho.lib.hellocharts.ChartComputator.java
lecho.lib.hellocharts.DummyChartAnimationListener.java
lecho.lib.hellocharts.DummyVieportChangeListener.java
lecho.lib.hellocharts.PreviewChartComputator.java
lecho.lib.hellocharts.ViewportChangeListener.java
lecho.lib.hellocharts.animation.ChartAnimationListener.java
lecho.lib.hellocharts.animation.ChartDataAnimatorV14.java
lecho.lib.hellocharts.animation.ChartDataAnimatorV8.java
lecho.lib.hellocharts.animation.ChartDataAnimator.java
lecho.lib.hellocharts.animation.ChartViewportAnimatorV14.java
lecho.lib.hellocharts.animation.ChartViewportAnimatorV8.java
lecho.lib.hellocharts.animation.ChartViewportAnimator.java
lecho.lib.hellocharts.animation.PieChartRotationAnimatorV14.java
lecho.lib.hellocharts.animation.PieChartRotationAnimatorV8.java
lecho.lib.hellocharts.animation.PieChartRotationAnimator.java
lecho.lib.hellocharts.gesture.ChartScroller.java
lecho.lib.hellocharts.gesture.ChartTouchHandler.java
lecho.lib.hellocharts.gesture.ChartZoomer.java
lecho.lib.hellocharts.gesture.ContainerScrollType.java
lecho.lib.hellocharts.gesture.PieChartTouchHandler.java
lecho.lib.hellocharts.gesture.PreviewChartTouchHandler.java
lecho.lib.hellocharts.gesture.ZoomType.java
lecho.lib.hellocharts.gesture.ZoomerCompat.java
lecho.lib.hellocharts.model.AbstractChartData.java
lecho.lib.hellocharts.model.ArcValue.java
lecho.lib.hellocharts.model.AxisValue.java
lecho.lib.hellocharts.model.Axis.java
lecho.lib.hellocharts.model.BubbleChartData.java
lecho.lib.hellocharts.model.BubbleValue.java
lecho.lib.hellocharts.model.ChartData.java
lecho.lib.hellocharts.model.ColumnChartData.java
lecho.lib.hellocharts.model.ColumnValue.java
lecho.lib.hellocharts.model.Column.java
lecho.lib.hellocharts.model.ComboLineColumnChartData.java
lecho.lib.hellocharts.model.LineChartData.java
lecho.lib.hellocharts.model.Line.java
lecho.lib.hellocharts.model.PieChartData.java
lecho.lib.hellocharts.model.PointValue.java
lecho.lib.hellocharts.model.SelectedValue.java
lecho.lib.hellocharts.model.SimpleValueFormatter.java
lecho.lib.hellocharts.model.ValueFormatter.java
lecho.lib.hellocharts.model.ValueShape.java
lecho.lib.hellocharts.model.Viewport.java
lecho.lib.hellocharts.provider.BubbleChartDataProvider.java
lecho.lib.hellocharts.provider.ColumnChartDataProvider.java
lecho.lib.hellocharts.provider.ComboLineColumnChartDataProvider.java
lecho.lib.hellocharts.provider.LineChartDataProvider.java
lecho.lib.hellocharts.provider.PieChartDataProvider.java
lecho.lib.hellocharts.renderer.AbstractChartRenderer.java
lecho.lib.hellocharts.renderer.AxesRenderer.java
lecho.lib.hellocharts.renderer.BubbleChartRenderer.java
lecho.lib.hellocharts.renderer.ChartRenderer.java
lecho.lib.hellocharts.renderer.ColumnChartRenderer.java
lecho.lib.hellocharts.renderer.ComboLineColumnChartRenderer.java
lecho.lib.hellocharts.renderer.LineChartRenderer.java
lecho.lib.hellocharts.renderer.PieChartRenderer.java
lecho.lib.hellocharts.renderer.PreviewColumnChartRenderer.java
lecho.lib.hellocharts.renderer.PreviewLineChartRenderer.java
lecho.lib.hellocharts.samples.AboutActivity.java
lecho.lib.hellocharts.samples.BrokenLineChartActivity.java
lecho.lib.hellocharts.samples.BrokenLineView.java
lecho.lib.hellocharts.samples.BubbleChartActivity.java
lecho.lib.hellocharts.samples.ColumnChartActivity.java
lecho.lib.hellocharts.samples.ComboLineColumnChartActivity.java
lecho.lib.hellocharts.samples.GoodBadChartActivity.java
lecho.lib.hellocharts.samples.LineChartActivity.java
lecho.lib.hellocharts.samples.LineColumnDependencyActivity.java
lecho.lib.hellocharts.samples.MainActivity.java
lecho.lib.hellocharts.samples.PieChartActivity.java
lecho.lib.hellocharts.samples.PreviewColumnChartActivity.java
lecho.lib.hellocharts.samples.PreviewLineChartActivity.java
lecho.lib.hellocharts.samples.SpeedChartActivity.java
lecho.lib.hellocharts.samples.TempoChartActivity.java
lecho.lib.hellocharts.samples.ViewPagerChartsActivity.java
lecho.lib.hellocharts.util.AxisAutoValues.java
lecho.lib.hellocharts.util.Utils.java
lecho.lib.hellocharts.view.AbstractChartView.java
lecho.lib.hellocharts.view.BubbleChartView.java
lecho.lib.hellocharts.view.Chart.java
lecho.lib.hellocharts.view.ColumnChartView.java
lecho.lib.hellocharts.view.ComboLineColumnChartView.java
lecho.lib.hellocharts.view.LineChartView.java
lecho.lib.hellocharts.view.PieChartView.java
lecho.lib.hellocharts.view.PreviewColumnChartView.java
lecho.lib.hellocharts.view.PreviewLineChartView.java
lecho.lib.hellocharts.view.hack.HackyDrawerLayout.java
lecho.lib.hellocharts.view.hack.HackyViewPager.java