Android Open Source - sensorreadout X Y Value Series






From Project

Back to project page sensorreadout.

License

The source code is released under:

Apache License

If you think the Android project sensorreadout 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

/**
 * Copyright (C) 2009 - 2013 SC 4ViewSoft SRL
 *  /*from   w  w w.  j ava2 s.co m*/
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *  
 *      http://www.apache.org/licenses/LICENSE-2.0
 *  
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.achartengine.model;

import java.util.ArrayList;
import java.util.List;

import org.achartengine.util.MathHelper;

/**
 * An extension of the XY series which adds a third dimension. It is used for XY
 * charts like bubble.
 */
public class XYValueSeries extends XYSeries {
  /** A list to contain the series values. */
  private List<Double> mValue = new ArrayList<Double>();
  /** The minimum value. */
  private double mMinValue = MathHelper.NULL_VALUE;
  /** The maximum value. */
  private double mMaxValue = -MathHelper.NULL_VALUE;

  /**
   * Builds a new XY value series.
   * 
   * @param title the series title.
   */
  public XYValueSeries(String title) {
    super(title);
  }

  /**
   * Adds a new value to the series.
   * 
   * @param x the value for the X axis
   * @param y the value for the Y axis
   * @param value the value
   */
  public synchronized void add(double x, double y, double value) {
    super.add(x, y);
    mValue.add(value);
    updateRange(value);
  }

  /**
   * Initializes the values range.
   */
  private void initRange() {
    mMinValue = MathHelper.NULL_VALUE;
    mMaxValue = MathHelper.NULL_VALUE;
    int length = getItemCount();
    for (int k = 0; k < length; k++) {
      updateRange(getValue(k));
    }
  }

  /**
   * Updates the values range.
   * 
   * @param value the new value
   */
  private void updateRange(double value) {
    mMinValue = Math.min(mMinValue, value);
    mMaxValue = Math.max(mMaxValue, value);
  }

  /**
   * Adds a new value to the series.
   * 
   * @param x the value for the X axis
   * @param y the value for the Y axis
   */
  public synchronized void add(double x, double y) {
    add(x, y, 0d);
  }

  /**
   * Removes an existing value from the series.
   * 
   * @param index the index in the series of the value to remove
   */
  public synchronized void remove(int index) {
    super.remove(index);
    double removedValue = mValue.remove(index);
    if (removedValue == mMinValue || removedValue == mMaxValue) {
      initRange();
    }
  }

  /**
   * Removes all the values from the series.
   */
  public synchronized void clear() {
    super.clear();
    mValue.clear();
    initRange();
  }

  /**
   * Returns the value at the specified index.
   * 
   * @param index the index
   * @return the value
   */
  public synchronized double getValue(int index) {
    return mValue.get(index);
  }

  /**
   * Returns the minimum value.
   * 
   * @return the minimum value
   */
  public double getMinValue() {
    return mMinValue;
  }

  /**
   * Returns the maximum value.
   * 
   * @return the maximum value
   */
  public double getMaxValue() {
    return mMaxValue;
  }

}




Java Source Code List

de.onyxbits.sensorreadout.AppRater.java
de.onyxbits.sensorreadout.ExportTask.java
de.onyxbits.sensorreadout.OverviewActivity.java
de.onyxbits.sensorreadout.ReadoutActivity.java
de.onyxbits.sensorreadout.SensorAdapter.java
de.onyxbits.sensorreadout.Ticker.java
org.achartengine.ChartFactory.java
org.achartengine.GraphicalActivity.java
org.achartengine.GraphicalView.java
org.achartengine.ITouchHandler.java
org.achartengine.TouchHandlerOld.java
org.achartengine.TouchHandler.java
org.achartengine.chart.AbstractChart.java
org.achartengine.chart.BarChart.java
org.achartengine.chart.BubbleChart.java
org.achartengine.chart.ClickableArea.java
org.achartengine.chart.CombinedXYChart.java
org.achartengine.chart.CubicLineChart.java
org.achartengine.chart.DialChart.java
org.achartengine.chart.DoughnutChart.java
org.achartengine.chart.LineChart.java
org.achartengine.chart.PieChart.java
org.achartengine.chart.PieMapper.java
org.achartengine.chart.PieSegment.java
org.achartengine.chart.PointStyle.java
org.achartengine.chart.RangeBarChart.java
org.achartengine.chart.RangeStackedBarChart.java
org.achartengine.chart.RoundChart.java
org.achartengine.chart.ScatterChart.java
org.achartengine.chart.TimeChart.java
org.achartengine.chart.XYChart.java
org.achartengine.model.CategorySeries.java
org.achartengine.model.MultipleCategorySeries.java
org.achartengine.model.Point.java
org.achartengine.model.RangeCategorySeries.java
org.achartengine.model.SeriesSelection.java
org.achartengine.model.TimeSeries.java
org.achartengine.model.XYMultipleSeriesDataset.java
org.achartengine.model.XYSeries.java
org.achartengine.model.XYValueSeries.java
org.achartengine.renderer.BasicStroke.java
org.achartengine.renderer.DefaultRenderer.java
org.achartengine.renderer.DialRenderer.java
org.achartengine.renderer.SimpleSeriesRenderer.java
org.achartengine.renderer.XYMultipleSeriesRenderer.java
org.achartengine.renderer.XYSeriesRenderer.java
org.achartengine.tools.AbstractTool.java
org.achartengine.tools.FitZoom.java
org.achartengine.tools.PanListener.java
org.achartengine.tools.Pan.java
org.achartengine.tools.ZoomEvent.java
org.achartengine.tools.ZoomListener.java
org.achartengine.tools.Zoom.java
org.achartengine.util.IndexXYMap.java
org.achartengine.util.MathHelper.java
org.achartengine.util.XYEntry.java