com.androidplot.xy.LineAndPointFormatter Java Examples
The following examples show how to use
com.androidplot.xy.LineAndPointFormatter.
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: PositionErrorFragment.java From GNSS_Compare with Apache License 2.0 | 6 votes |
public void addSeries(CalculationModule calculationModule) { if(initialized) { data.put(calculationModule, new PoseErrorPlotDataSeries(MAX_PLOTTED_POINTS)); XYSeriesFormatter formatter = new LineAndPointFormatter( null, Color.argb(50, Color.red(calculationModule.getDataColor()), Color.green(calculationModule.getDataColor()), Color.blue(calculationModule.getDataColor())), Color.WHITE, //TODO: remove the black background from the legend null); plot.addSeries(data.get(calculationModule), formatter); formatSeries(formatter); } }
Example #2
Source File: PositionErrorFragment.java From GNSS_Compare with Apache License 2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup rootView = (ViewGroup) inflater.inflate( R.layout.pose_error_plot_page, container, false); plot = rootView.findViewById(R.id.plot); preformatPlot(plot); for(Map.Entry<CalculationModule, PoseErrorPlotDataSeries> entry : data.entrySet() ) { XYSeriesFormatter formatter = new LineAndPointFormatter( null, Color.argb(50, Color.red(entry.getKey().getDataColor()), Color.green(entry.getKey().getDataColor()), Color.blue(entry.getKey().getDataColor())), Color.WHITE, //TODO: remove the black background from the legend null); plot.addSeries(entry.getValue(), formatter); formatSeries(formatter); } initialized = true; return rootView; }
Example #3
Source File: DataPlotZoomListener.java From sensordatacollector with GNU General Public License v2.0 | 5 votes |
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 #4
Source File: DataPlotZoomListener.java From sensordatacollector with GNU General Public License v2.0 | 5 votes |
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 #5
Source File: CustomPointRenderer.java From sensordatacollector with GNU General Public License v2.0 | 5 votes |
@Override public void doDrawLegendIcon(Canvas canvas, RectF rect, LineAndPointFormatter formatter) { // do not draw icon if(formatter.getFillPaint() != null) { canvas.drawRect(rect, formatter.getFillPaint()); } }
Example #6
Source File: DynamicPlot.java From AccelerationAlert with Apache License 2.0 | 5 votes |
/** * Add a series to the plot. * * @param seriesName * The name of the series. * @param key * The unique series key. * @param color * The series color. */ public void addSeriesPlot(String seriesName, int key, int color) { history.append(key, new LinkedList<Number>()); series.append(key, new SimpleXYSeries(seriesName)); LineAndPointFormatter formatter = new LineAndPointFormatter(Color.rgb( 0, 153, 204), Color.rgb(0, 153, 204), Color.TRANSPARENT, new PointLabelFormatter(Color.TRANSPARENT)); Paint linePaint = new Paint(); linePaint.setAntiAlias(true); linePaint.setStyle(Paint.Style.STROKE); linePaint.setColor(color); linePaint.setStrokeWidth(LINE_WIDTH); formatter.setLinePaint(linePaint); Paint vertexPaint = new Paint(); vertexPaint.setAntiAlias(true); vertexPaint.setStyle(Paint.Style.STROKE); vertexPaint.setColor(color); vertexPaint.setStrokeWidth(VERTEX_WIDTH); formatter.setVertexPaint(vertexPaint); dynamicPlot.addSeries(series.get(key), formatter); }
Example #7
Source File: PositionErrorFragment.java From GNSS_Compare with Apache License 2.0 | 4 votes |
protected void formatSeries(XYSeriesFormatter formatter) { ((LineAndPointFormatter)formatter).getVertexPaint().setStrokeWidth(PixelUtils.dpToPix(10)); }
Example #8
Source File: Plotter.java From sensordatacollector with GNU General Public License v2.0 | 4 votes |
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); } }