com.androidplot.xy.BoundaryMode Java Examples

The following examples show how to use com.androidplot.xy.BoundaryMode. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DataPlotZoomListener.java    From sensordatacollector with GNU General Public License v2.0 5 votes vote down vote up
public void start()
{
    series = new SimpleXYSeries[pc.domainValueNames.length];

    MainActivity main = (MainActivity) ActivityController.getInstance().get("MainActivity");
    main.refreshGraphBuilderProgressBar(R.string.analyze_analyzelive_loading2, 5);

    String tableName = SQLTableName.PREFIX + pc.deviceID + pc.tableName;
    DatabaseHelper.streamData(tableName, pc.domainValueNames, start, end, valueData);

    main.refreshGraphBuilderProgressBar(R.string.analyze_analyzelive_loading4, 20);

    for(int i = 0; i < pc.domainValueNames.length; i++) {
        series[i] = new SimpleXYSeries(valueData.get("attr_time"), valueData.get(pc.domainValueNames[i]), pc.domainValueNames[i].replace("attr_", ""));
        plot.addSeries(series[i], new LineAndPointFormatter(SensorDataUtil.getColor(i), Color.BLACK, null, null));
    }

    plot.calculateMinMaxVals();

    minXY = new PointF(plot.getCalculatedMinX().floatValue(), plot.getCalculatedMinY().floatValue());
    maxXY = new PointF(plot.getCalculatedMaxX().floatValue(), plot.getCalculatedMaxY().floatValue());

    maxY = plot.getCalculatedMaxY().doubleValue() + 1;
    minY = plot.getCalculatedMinY().doubleValue() - 1;

    plot.setRangeBoundaries(minY, maxY, BoundaryMode.FIXED);
    plot.setDomainBoundaries(minXY.x, maxXY.x, BoundaryMode.FIXED);

    main.refreshGraphBuilderProgressBar(R.string.analyze_analyzelive_loading5, 80);

    plot.redraw();
}
 
Example #2
Source File: DataPlotZoomListener.java    From sensordatacollector with GNU General Public License v2.0 5 votes vote down vote up
private void refreshSeries()
{
    for(int i = 0; i < pc.domainValueNames.length; i++) {
        plot.removeSeries(series[i]);
    }

    // New zoom
    double zoomStart = (((double) minXY.x) + 1388534400000d);
    double zoomEnd = (((double) maxXY.x) + 1388534400000d);

    //        DatabaseHelper.streamData(pc.tableName, "SELECT " + values + " FROM " + pc.tableName, start, "" + zoomStart, timeData, valueData, 150);
    //        DatabaseHelper.streamData(pc.tableName, "SELECT " + values + " FROM " + pc.tableName, "" + zoomStart, "" + zoomEnd, timeData, valueData, 400);
    //        DatabaseHelper.streamData(pc.tableName, "SELECT " + values + " FROM " + pc.tableName, "" + zoomEnd, end, timeData, valueData, 150);

    for(int i = 0; i < pc.domainValueNames.length; i++) {
        series[i] = new SimpleXYSeries(valueData.get("attr_time"), valueData.get(pc.domainValueNames[i]), pc.domainValueNames[i].replace("attr_", ""));

        plot.addSeries(series[i], new LineAndPointFormatter(SensorDataUtil.getColor(i), Color.BLACK, null, null));
    }

    plot.calculateMinMaxVals();

    if(plot.getCalculatedMaxY().doubleValue() > maxY || plot.getCalculatedMinY().doubleValue() < minY) {
        maxY = (plot.getCalculatedMaxY().doubleValue() > maxY) ? plot.getCalculatedMaxY().doubleValue() + 1 : maxY;
        minY = (plot.getCalculatedMinY().doubleValue() < minY) ? plot.getCalculatedMinY().doubleValue() - 1 : minY;

        plot.setRangeBoundaries(minY, maxY, BoundaryMode.FIXED);
        plot.setDomainBoundaries(minXY.x, maxXY.x, BoundaryMode.FIXED);
    }

    plot.redraw();
}
 
Example #3
Source File: DynamicPlot.java    From AccelerationAlert with Apache License 2.0 5 votes vote down vote up
/**
 * Create the plot.
 */
private void initPlot()
{
	this.dynamicPlot.setRangeBoundaries(minRange, maxRange,
			BoundaryMode.FIXED);
	this.dynamicPlot.setDomainBoundaries(0, windowSize, BoundaryMode.FIXED);

	this.dynamicPlot.setDomainStepValue(5);
	this.dynamicPlot.setTicksPerRangeLabel(3);
	this.dynamicPlot.setDomainLabel("Update #");
	this.dynamicPlot.getDomainLabelWidget().pack();
	this.dynamicPlot.setRangeLabel("G's/Sec");
	this.dynamicPlot.getRangeLabelWidget().pack();
	this.dynamicPlot.getLegendWidget().setWidth(0.7f);
	this.dynamicPlot.setGridPadding(15, 15, 15, 15);
	this.dynamicPlot.getGraphWidget().setGridBackgroundPaint(null);
	this.dynamicPlot.getGraphWidget().setBackgroundPaint(null);
	this.dynamicPlot.getGraphWidget().setBorderPaint(null);

	Paint paint = new Paint();

	paint.setStyle(Paint.Style.FILL_AND_STROKE);
	paint.setColor(Color.rgb(119, 119, 119));
	paint.setStrokeWidth(2);

	this.dynamicPlot.getGraphWidget().setDomainOriginLinePaint(paint);
	this.dynamicPlot.getGraphWidget().setRangeOriginLinePaint(paint);

	this.dynamicPlot.setBorderPaint(null);
	this.dynamicPlot.setBackgroundPaint(null);

	this.dynamicPlot.redraw();
}
 
Example #4
Source File: ProfileChartActivity.java    From geopaparazzi with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onClick(View v) {
    minXYSpeed.x = seriesSpeed.getX(0).floatValue();
    maxXYSpeed.x = seriesSpeed.getX(seriesSpeed.size() - 1).floatValue();
    xyPlotSpeed.setDomainBoundaries(minXYSpeed.x, maxXYSpeed.x, BoundaryMode.FIXED);
    minXYElevation.x = seriesElev.getX(0).floatValue();
    maxXYElevation.x = seriesElev.getX(seriesElev.size() - 1).floatValue();
    xyPlotElev.setDomainBoundaries(minXYElevation.x, maxXYSpeed.x, BoundaryMode.FIXED);

    xyPlotElev.redraw();
    xyPlotSpeed.redraw();
    resetButton.hide();
}
 
Example #5
Source File: Plotter.java    From sensordatacollector with GNU General Public License v2.0 4 votes vote down vote up
public void startPlotting(XYPlot levelXYPlot, XYPlot historyXYPlot)
{
    levelPlot.plot = levelXYPlot;
    historyPlot.plot = historyXYPlot;

    levelsValues = new SimpleXYSeries(levelPlot.SeriesName);
    levelsValues.useImplicitXVals();
    levelPlot.plot.addSeries(levelsValues, new BarFormatter(Color.argb(180, 0, 200, 0), Color.rgb(0, 100, 0)));
    levelPlot.plot.addSeries(new SimpleXYSeries(Arrays.asList(-10, 0, 10, 0), SimpleXYSeries.ArrayFormat.XY_VALS_INTERLEAVED, "0"), new LineAndPointFormatter(Color.argb(140, 200, 80, 80), Color.BLACK, null, null));
    levelPlot.plot.setTitle(levelPlot.plotName);

    levelPlot.plot.setDomainStepValue(levelPlot.domainValueNames.length);
    levelPlot.plot.setTicksPerRangeLabel(3);

    // per the android documentation, the minimum and maximum readings we can get from
    // any of the orientation sensors is -180 and 359 respectively so we will fix our plot's
    // boundaries to those values. If we did not do this, the plot would auto-range which
    // can be visually confusing in the case of dynamic plots.
    levelPlot.plot.setRangeBoundaries(levelPlot.rangeMin, levelPlot.rangeMax, levelPlot.rangeBoundary);

    levelPlot.plot.setDomainBoundaries(0, levelPlot.domainValueNames.length - 1, BoundaryMode.FIXED);

    // use our custom domain value formatter:
    levelPlot.plot.setDomainValueFormat(new BarPlotFormat(levelPlot.domainValueNames));

    // update our domain and range axis labels:
    levelPlot.plot.setDomainLabel(levelPlot.domainName);
    levelPlot.plot.getDomainLabelWidget().pack();
    levelPlot.plot.setRangeLabel(levelPlot.rangeName);
    levelPlot.plot.getRangeLabelWidget().pack();
    levelPlot.plot.setGridPadding(15, 0, 15, 0);

    // History Plot
    historyPlot.plot.setTitle(historyPlot.plotName);
    historyPlot.plot.setDomainStepValue(5);
    historyPlot.plot.setTicksPerRangeLabel(3);

    historyValues = new SimpleXYSeries[historyPlot.seriesValueNames.length];

    int Colors[] = new int[6];

    Colors[0] = Color.rgb(100, 100, 250);
    Colors[1] = Color.rgb(250, 100, 100);
    Colors[2] = Color.rgb(100, 250, 100);
    Colors[3] = Color.rgb(250, 100, 250);
    Colors[4] = Color.rgb(250, 250, 100);
    Colors[5] = Color.rgb(100, 250, 250);

    for(int i = 0; i < historyPlot.seriesValueNames.length; i++) {
        historyValues[i] = new SimpleXYSeries(historyPlot.seriesValueNames[i].replace("attr_", ""));
        historyValues[i].useImplicitXVals();

        if(i > 5) {
            historyPlot.plot.addSeries(historyValues[i], new LineAndPointFormatter(Color.rgb(100, 100, 200), Color.BLACK, null, null));
        } else {
            historyPlot.plot.addSeries(historyValues[i], new LineAndPointFormatter(Colors[i], Color.BLACK, null, null));
        }
    }

    historyPlot.plot.setRangeBoundaries(historyPlot.rangeMin, historyPlot.rangeMax, historyPlot.rangeBoundary);
    historyPlot.plot.setDomainBoundaries(historyPlot.domainMin, historyPlot.domainMax, historyPlot.domainBoundary);
    historyPlot.plot.setDomainStepValue(5);
    historyPlot.plot.setTicksPerRangeLabel(3);
    historyPlot.plot.setDomainLabel(historyPlot.domainName);
    historyPlot.plot.getDomainLabelWidget().pack();
    historyPlot.plot.setRangeLabel(historyPlot.rangeName);
    historyPlot.plot.getRangeLabelWidget().pack();

    // get a ref to the BarRenderer so we can make some changes to it:
    @SuppressWarnings( "rawtypes" ) BarRenderer barRenderer = (BarRenderer) levelPlot.plot.getRenderer(BarRenderer.class);
    if(barRenderer != null) {
        // make our bars a little thicker than the default so they can be seen better:
        // barRenderer.setBarWidth(300);
        barRenderer.setBarWidthStyle(BarRenderer.BarWidthStyle.VARIABLE_WIDTH);
        barRenderer.setBarGap(20);
    }
}
 
Example #6
Source File: DynamicPlot.java    From AccelerationAlert with Apache License 2.0 2 votes vote down vote up
/**
 * Set the max range of the plot.
 * 
 * @param maxRange
 *            The maximum range of the plot.
 */
public void setMaxRange(double maxRange)
{
	this.maxRange = maxRange;
	dynamicPlot.setRangeBoundaries(minRange, maxRange, BoundaryMode.FIXED);
}
 
Example #7
Source File: DynamicPlot.java    From AccelerationAlert with Apache License 2.0 2 votes vote down vote up
/**
 * Set the min range of the plot.
 * 
 * @param minRange
 *            The minimum range of the plot.
 */
public void setMinRange(double minRange)
{
	this.minRange = minRange;
	dynamicPlot.setRangeBoundaries(minRange, maxRange, BoundaryMode.FIXED);
}