List of usage examples for org.jfree.chart.plot XYPlot mapDatasetToRangeAxis
public void mapDatasetToRangeAxis(int index, int axisIndex)
From source file:de.dmarcini.submatix.pclogger.gui.spx42LogGraphPanel.java
/** * Erzeuge je einen Graphen fr die Sensoren Project: SubmatixBTForPC Package: de.dmarcini.submatix.pclogger.gui * // w w w .j a v a 2 s.co m * @author Dirk Marciniak (dirk_marciniak@arcor.de) Stand: 02.08.2012 * @param diveList * @param thePlot * @param sensor */ private void makePpoGraph(Vector<Integer[]> diveList, XYPlot thePlot, int sensor) { XYDataset ppo2DataSet; int indexForCreate; int posForGraph; int posColor; String title; // lg.debug("create Sensor <" + sensor + "> dataset"); // Titel schon mal... title = String.format(LangStrings.getString("spx42LogGraphPanel.graph.ppo2SensorScalaTitle"), sensor); // // Dataset Index einstellen switch (sensor) { case 0: indexForCreate = LogDerbyDatabaseUtil.PPO2; posForGraph = GRAPH_PPO2ALL; posColor = ProjectConst.GRAPH_PPO2ALL_RCOLOR; title = LangStrings.getString("spx42LogGraphPanel.graph.ppo2ScalaTitle"); break; case 1: indexForCreate = LogDerbyDatabaseUtil.PPO2_01; posForGraph = GRAPH_PPO2_01; posColor = ProjectConst.GRAPH_PPO2_01_RCOLOR; break; case 2: indexForCreate = LogDerbyDatabaseUtil.PPO2_02; posForGraph = GRAPH_PPO2_02; posColor = ProjectConst.GRAPH_PPO2_02_RCOLOR; break; case 3: indexForCreate = LogDerbyDatabaseUtil.PPO2_03; posForGraph = GRAPH_PPO2_03; posColor = ProjectConst.GRAPH_PPO2_02_RCOLOR; break; default: indexForCreate = LogDerbyDatabaseUtil.PPO2_01; posForGraph = GRAPH_PPO2_01; posColor = ProjectConst.GRAPH_PPO2_01_RCOLOR; } if (showingUnitSystem == savedUnitSystem || showingUnitSystem == ProjectConst.UNITS_DEFAULT) { ppo2DataSet = createXYDataset(title, diveList, ProjectConst.UNITS_DEFAULT, 0, indexForCreate); } else { ppo2DataSet = createXYDataset(title, diveList, showingUnitSystem, 0, indexForCreate); } final XYLineAndShapeRenderer ppo2Renderer = new XYLineAndShapeRenderer(true, true); // die Achse sollte schon erstellt sein thePlot.setDataset(posForGraph, ppo2DataSet); thePlot.mapDatasetToRangeAxis(posForGraph, GRAPH_PPO2ALL); ppo2Renderer.setSeriesPaint(0, new Color(posColor)); ppo2Renderer.setSeriesShapesVisible(0, false); ppo2Renderer.setDrawSeriesLineAsPath(true); thePlot.setRenderer(posForGraph, ppo2Renderer); }
From source file:org.codehaus.mojo.dashboard.report.plugin.chart.time.SurefirePercentAxisDecorator.java
/** * *///from w w w. j av a 2s . c o m public void createChart() { XYPlot xyplot = (XYPlot) report.getPlot(); if (this.decoratedChart instanceof TimeChartRenderer && this.results != null && !this.results.isEmpty()) { Iterator iter = this.results.iterator(); TimeSeriesCollection defaultdataset = new TimeSeriesCollection(); TimeSeries s1 = new TimeSeries("% success", Day.class); while (iter.hasNext()) { SurefireReportBean surefire = (SurefireReportBean) iter.next(); Date date = surefire.getDateGeneration(); s1.addOrUpdate(new Day(TimePeriod.DAY.normalize(date)), surefire.getSucessRate() / PCENT); } defaultdataset.addSeries(s1); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setSeriesPaint(0, ChartColor.DARK_BLUE); renderer.setBaseShapesVisible(true); renderer.setDrawOutlines(true); StandardXYItemLabelGenerator labelgenerator = new StandardXYItemLabelGenerator( StandardXYItemLabelGenerator.DEFAULT_ITEM_LABEL_FORMAT, TimePeriod.DAY.getDateFormat(), NumberFormat.getPercentInstance(Locale.getDefault())); renderer.setBaseItemLabelGenerator(labelgenerator); renderer.setBaseItemLabelFont(new Font("SansSerif", Font.BOLD, ITEM_LABEL_FONT_SIZE)); renderer.setBaseItemLabelsVisible(true); renderer.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE10, TextAnchor.BASELINE_RIGHT)); renderer.setBaseStroke(new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); LegendTitle legendtitle = new LegendTitle(xyplot.getRenderer(0)); legendtitle.setMargin(new RectangleInsets(2D, 2D, 2D, 2D)); legendtitle.setFrame(new BlockBorder()); legendtitle.setBackgroundPaint(ChartColor.WHITE); LegendTitle legendtitle1 = new LegendTitle(renderer); legendtitle1.setMargin(new RectangleInsets(2D, 2D, 2D, 2D)); legendtitle1.setFrame(new BlockBorder()); legendtitle1.setBackgroundPaint(ChartColor.WHITE); BlockContainer blockcontainer = new BlockContainer(new BorderArrangement()); blockcontainer.add(legendtitle, RectangleEdge.LEFT); blockcontainer.add(legendtitle1, RectangleEdge.RIGHT); blockcontainer.add(new EmptyBlock(BLOCK_CONTAINER_WIDTH, 0.0D)); CompositeTitle compositetitle = new CompositeTitle(blockcontainer); compositetitle.setPosition(RectangleEdge.BOTTOM); report.clearSubtitles(); report.addSubtitle(compositetitle); xyplot.setDataset(1, defaultdataset); NumberAxis valueaxis = new NumberAxis("% success"); valueaxis.setLowerMargin(0.0D); valueaxis.setUpperMargin(AXIS_UPPER_MARGIN); valueaxis.setRangeWithMargins(0.0D, 1.0D); valueaxis.setNumberFormatOverride(NumberFormat.getPercentInstance()); xyplot.setRangeAxis(1, valueaxis); xyplot.mapDatasetToRangeAxis(1, 1); xyplot.setRenderer(1, renderer); } }
From source file:org.locationtech.udig.processingtoolbox.tools.ScatterPlotDialog.java
private void updateChart(SimpleFeatureCollection features, String xField, String yField) { // 1. Create a single plot containing both the scatter and line XYPlot plot = new XYPlot(); plot.setOrientation(PlotOrientation.VERTICAL); plot.setBackgroundPaint(java.awt.Color.WHITE); plot.setDomainPannable(false);//from www .ja va2 s . c om plot.setRangePannable(false); plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); // 2. Setup Scatter plot // Create the scatter data, renderer, and axis int fontStyle = java.awt.Font.BOLD; FontData fontData = getShell().getDisplay().getSystemFont().getFontData()[0]; NumberAxis xPlotAxis = new NumberAxis(xField); // Independent variable xPlotAxis.setLabelFont(new Font(fontData.getName(), fontStyle, 12)); xPlotAxis.setTickLabelFont(new Font(fontData.getName(), fontStyle, 10)); NumberAxis yPlotAxis = new NumberAxis(yField); // Dependent variable yPlotAxis.setLabelFont(new Font(fontData.getName(), fontStyle, 12)); yPlotAxis.setTickLabelFont(new Font(fontData.getName(), fontStyle, 10)); XYToolTipGenerator plotToolTip = new StandardXYToolTipGenerator(); XYItemRenderer plotRenderer = new XYLineAndShapeRenderer(false, true); // Shapes only plotRenderer.setSeriesShape(0, new Ellipse2D.Double(0, 0, 3, 3)); plotRenderer.setSeriesPaint(0, java.awt.Color.BLUE); // dot plotRenderer.setBaseToolTipGenerator(plotToolTip); // Set the scatter data, renderer, and axis into plot plot.setDataset(0, getScatterPlotData(features, xField, yField)); xPlotAxis.setAutoRangeIncludesZero(false); xPlotAxis.setAutoRange(false); double differUpper = minMaxVisitor.getMaxX() - minMaxVisitor.getAverageX(); double differLower = minMaxVisitor.getAverageX() - minMaxVisitor.getMinX(); double gap = Math.abs(differUpper - differLower); if (differUpper > differLower) { xPlotAxis.setRange(minMaxVisitor.getMinX() - gap, minMaxVisitor.getMaxX()); } else { xPlotAxis.setRange(minMaxVisitor.getMinX(), minMaxVisitor.getMaxX() + gap); } yPlotAxis.setAutoRangeIncludesZero(false); yPlotAxis.setAutoRange(false); differUpper = minMaxVisitor.getMaxY() - minMaxVisitor.getAverageY(); differLower = minMaxVisitor.getAverageY() - minMaxVisitor.getMinY(); gap = Math.abs(differUpper - differLower); if (differUpper > differLower) { yPlotAxis.setRange(minMaxVisitor.getMinY() - gap, minMaxVisitor.getMaxY()); } else { yPlotAxis.setRange(minMaxVisitor.getMinY(), minMaxVisitor.getMaxY() + gap); } plot.setRenderer(0, plotRenderer); plot.setDomainAxis(0, xPlotAxis); plot.setRangeAxis(0, yPlotAxis); // Map the scatter to the first Domain and first Range plot.mapDatasetToDomainAxis(0, 0); plot.mapDatasetToRangeAxis(0, 0); // 3. Setup line // Create the line data, renderer, and axis XYItemRenderer lineRenderer = new XYLineAndShapeRenderer(true, false); // Lines only lineRenderer.setSeriesPaint(0, java.awt.Color.GRAY); lineRenderer.setSeriesPaint(1, java.awt.Color.GRAY); lineRenderer.setSeriesPaint(2, java.awt.Color.GRAY); // Set the line data, renderer, and axis into plot NumberAxis xLineAxis = new NumberAxis(EMPTY); xLineAxis.setTickMarksVisible(false); xLineAxis.setTickLabelsVisible(false); NumberAxis yLineAxis = new NumberAxis(EMPTY); yLineAxis.setTickMarksVisible(false); yLineAxis.setTickLabelsVisible(false); XYSeriesCollection lineDataset = new XYSeriesCollection(); // AverageY XYSeries horizontal = new XYSeries("AverageY"); //$NON-NLS-1$ horizontal.add(xPlotAxis.getRange().getLowerBound(), minMaxVisitor.getAverageY()); horizontal.add(xPlotAxis.getRange().getUpperBound(), minMaxVisitor.getAverageY()); lineDataset.addSeries(horizontal); // AverageX XYSeries vertical = new XYSeries("AverageX"); //$NON-NLS-1$ vertical.add(minMaxVisitor.getAverageX(), yPlotAxis.getRange().getLowerBound()); vertical.add(minMaxVisitor.getAverageX(), yPlotAxis.getRange().getUpperBound()); lineDataset.addSeries(vertical); // Degree XYSeries degree = new XYSeries("Deegree"); //$NON-NLS-1$ degree.add(xPlotAxis.getRange().getLowerBound(), yPlotAxis.getRange().getLowerBound()); degree.add(xPlotAxis.getRange().getUpperBound(), yPlotAxis.getRange().getUpperBound()); lineDataset.addSeries(degree); plot.setDataset(1, lineDataset); plot.setRenderer(1, lineRenderer); plot.setDomainAxis(1, xLineAxis); plot.setRangeAxis(1, yLineAxis); // Map the line to the second Domain and second Range plot.mapDatasetToDomainAxis(1, 0); plot.mapDatasetToRangeAxis(1, 0); // 4. Setup Selection NumberAxis xSelectionAxis = new NumberAxis(EMPTY); xSelectionAxis.setTickMarksVisible(false); xSelectionAxis.setTickLabelsVisible(false); NumberAxis ySelectionAxis = new NumberAxis(EMPTY); ySelectionAxis.setTickMarksVisible(false); ySelectionAxis.setTickLabelsVisible(false); XYItemRenderer selectionRenderer = new XYLineAndShapeRenderer(false, true); // Shapes only selectionRenderer.setSeriesShape(0, new Ellipse2D.Double(0, 0, 6, 6)); selectionRenderer.setSeriesPaint(0, java.awt.Color.RED); // dot plot.setDataset(2, new XYSeriesCollection(new XYSeries(EMPTY))); plot.setRenderer(2, selectionRenderer); plot.setDomainAxis(2, xSelectionAxis); plot.setRangeAxis(2, ySelectionAxis); // Map the scatter to the second Domain and second Range plot.mapDatasetToDomainAxis(2, 0); plot.mapDatasetToRangeAxis(2, 0); // 5. Finally, Create the chart with the plot and a legend java.awt.Font titleFont = new Font(fontData.getName(), fontStyle, 20); JFreeChart chart = new JFreeChart(EMPTY, titleFont, plot, false); chart.setBackgroundPaint(java.awt.Color.WHITE); chart.setBorderVisible(false); chartComposite.setChart(chart); chartComposite.forceRedraw(); }
From source file:org.n52.server.sos.render.DiagramRenderer.java
/** * <pre>/*from w w w .j av a 2 s .c om*/ * dataset := associated to one range-axis; * corresponds to one observedProperty; * may contain multiple series; * series := corresponds to a time series for one foi * </pre> * * . * * @param entireCollMap * the entire coll map * @param options * the options * @param begin * the begin * @param end * the end * @param compress * @return the j free chart */ public JFreeChart renderChart(Map<String, OXFFeatureCollection> entireCollMap, DesignOptions options, Calendar begin, Calendar end, boolean compress) { DesignDescriptionList designDescriptions = buildUpDesignDescriptionList(options); /*** FIRST RUN ***/ JFreeChart chart = initializeTimeSeriesChart(); chart.setBackgroundPaint(Color.white); if (!this.isOverview) { chart.addSubtitle(new TextTitle(ConfigurationContext.COPYRIGHT, new Font(LABEL_FONT, Font.PLAIN, 9), Color.black, RectangleEdge.BOTTOM, HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, new RectangleInsets(0, 0, 20, 20))); } XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(2.0, 2.0, 2.0, 2.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setDomainGridlinesVisible(options.getGrid()); plot.setRangeGridlinesVisible(options.getGrid()); // add additional datasets: DateAxis dateAxis = (DateAxis) plot.getDomainAxis(); dateAxis.setRange(begin.getTime(), end.getTime()); dateAxis.setDateFormatOverride(new SimpleDateFormat()); // add all axes String[] phenomenaIds = options.getAllPhenomenIds(); // all the axis indices to map them later HashMap<String, Integer> axes = new HashMap<String, Integer>(); for (int i = 0; i < phenomenaIds.length; i++) { axes.put(phenomenaIds[i], i); plot.setRangeAxis(i, new NumberAxis(phenomenaIds[i])); } // list range markers ArrayList<ValueMarker> referenceMarkers = new ArrayList<ValueMarker>(); HashMap<String, double[]> referenceBounds = new HashMap<String, double[]>(); // create all TS collections for (int i = 0; i < options.getProperties().size(); i++) { TimeseriesProperties prop = options.getProperties().get(i); String phenomenonId = prop.getPhenomenon(); TimeSeriesCollection dataset = createDataset(entireCollMap, prop, phenomenonId, compress); dataset.setGroup(new DatasetGroup(prop.getTimeseriesId())); XYDataset additionalDataset = dataset; NumberAxis axe = (NumberAxis) plot.getRangeAxis(axes.get(phenomenonId)); if (this.isOverview) { axe.setAutoRange(true); axe.setAutoRangeIncludesZero(false); } else if (prop.getAxisUpperBound() == prop.getAxisLowerBound() || prop.isAutoScale()) { if (prop.isZeroScaled()) { axe.setAutoRangeIncludesZero(true); } else { axe.setAutoRangeIncludesZero(false); } } else { if (prop.isZeroScaled()) { if (axe.getUpperBound() < prop.getAxisUpperBound()) { axe.setUpperBound(prop.getAxisUpperBound()); } if (axe.getLowerBound() > prop.getAxisLowerBound()) { axe.setLowerBound(prop.getAxisLowerBound()); } } else { axe.setRange(prop.getAxisLowerBound(), prop.getAxisUpperBound()); axe.setAutoRangeIncludesZero(false); } } plot.setDataset(i, additionalDataset); plot.mapDatasetToRangeAxis(i, axes.get(phenomenonId)); // set bounds new for reference values if (!referenceBounds.containsKey(phenomenonId)) { double[] bounds = new double[] { axe.getLowerBound(), axe.getUpperBound() }; referenceBounds.put(phenomenonId, bounds); } else { double[] bounds = referenceBounds.get(phenomenonId); if (bounds[0] >= axe.getLowerBound()) { bounds[0] = axe.getLowerBound(); } if (bounds[1] <= axe.getUpperBound()) { bounds[1] = axe.getUpperBound(); } } double[] bounds = referenceBounds.get(phenomenonId); for (String string : prop.getReferenceValues()) { if (prop.getRefValue(string).show()) { Double value = prop.getRefValue(string).getValue(); if (value <= bounds[0]) { bounds[0] = value; } else if (value >= bounds[1]) { bounds[1] = value; } } } Axis axis = prop.getAxis(); if (axis == null) { axis = new Axis(axe.getUpperBound(), axe.getLowerBound()); } else if (prop.isAutoScale()) { axis.setLowerBound(axe.getLowerBound()); axis.setUpperBound(axe.getUpperBound()); axis.setMaxY(axis.getMaxY()); axis.setMinY(axis.getMinY()); } prop.setAxisData(axis); this.axisMapping.put(prop.getTimeseriesId(), axis); for (String string : prop.getReferenceValues()) { if (prop.getRefValue(string).show()) { referenceMarkers.add(new ValueMarker(prop.getRefValue(string).getValue(), Color.decode(prop.getRefValue(string).getColor()), new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f))); } } plot.mapDatasetToRangeAxis(i, axes.get(phenomenonId)); } for (ValueMarker valueMarker : referenceMarkers) { plot.addRangeMarker(valueMarker); } // show actual time ValueMarker nowMarker = new ValueMarker(System.currentTimeMillis(), Color.orange, new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f)); plot.addDomainMarker(nowMarker); if (!this.isOverview) { Iterator<Entry<String, double[]>> iterator = referenceBounds.entrySet().iterator(); while (iterator.hasNext()) { Entry<String, double[]> boundsEntry = iterator.next(); String phenId = boundsEntry.getKey(); NumberAxis axe = (NumberAxis) plot.getRangeAxis(axes.get(phenId)); axe.setAutoRange(true); // add a margin double marginOffset = (boundsEntry.getValue()[1] - boundsEntry.getValue()[0]) / 25; boundsEntry.getValue()[0] -= marginOffset; boundsEntry.getValue()[1] += marginOffset; axe.setRange(boundsEntry.getValue()[0], boundsEntry.getValue()[1]); } } /**** SECOND RUN ***/ // set domain axis labels: plot.getDomainAxis().setLabelFont(label); plot.getDomainAxis().setLabelPaint(LABEL_COLOR); plot.getDomainAxis().setTickLabelFont(tickLabelDomain); plot.getDomainAxis().setTickLabelPaint(LABEL_COLOR); plot.getDomainAxis().setLabel(designDescriptions.getDomainAxisLabel()); // define the design for each series: for (int datasetIndex = 0; datasetIndex < plot.getDatasetCount(); datasetIndex++) { TimeSeriesCollection dataset = (TimeSeriesCollection) plot.getDataset(datasetIndex); for (int seriesIndex = 0; seriesIndex < dataset.getSeriesCount(); seriesIndex++) { String timeseriesId = (String) dataset.getSeries(seriesIndex).getKey(); RenderingDesign dd = designDescriptions.get(timeseriesId); if (dd != null) { // LINESTYLE: String lineStyle = dd.getLineStyle(); int width = dd.getLineWidth(); if (this.isOverview) { width = width / 2; width = (width == 0) ? 1 : width; } // "1" is lineStyle "line" if (lineStyle.equalsIgnoreCase(LINE)) { XYLineAndShapeRenderer ren = new XYLineAndShapeRenderer(true, false); ren.setStroke(new BasicStroke(width)); plot.setRenderer(datasetIndex, ren); } // "2" is lineStyle "area" else if (lineStyle.equalsIgnoreCase(AREA)) { plot.setRenderer(datasetIndex, new XYAreaRenderer()); } // "3" is lineStyle "dotted" else if (lineStyle.equalsIgnoreCase(DOTTED)) { XYLineAndShapeRenderer ren = new XYLineAndShapeRenderer(false, true); ren.setShape(new Ellipse2D.Double(-width, -width, 2 * width, 2 * width)); plot.setRenderer(datasetIndex, ren); } // "4" is dashed else if (lineStyle.equalsIgnoreCase("4")) { XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); renderer.setSeriesStroke(0, new BasicStroke(width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 4.0f * width, 4.0f * width }, 0.0f)); plot.setRenderer(datasetIndex, renderer); } else if (lineStyle.equalsIgnoreCase("5")) { // lines and dots XYLineAndShapeRenderer ren = new XYLineAndShapeRenderer(true, true); int thickness = 2 * width; ren.setShape(new Ellipse2D.Double(-width, -width, thickness, thickness)); ren.setStroke(new BasicStroke(width)); plot.setRenderer(datasetIndex, ren); } else { // default is lineStyle "line" plot.setRenderer(datasetIndex, new XYLineAndShapeRenderer(true, false)); } plot.getRenderer(datasetIndex).setSeriesPaint(seriesIndex, dd.getColor()); // plot.getRenderer(datasetIndex).setShapesVisible(true); XYToolTipGenerator toolTipGenerator = StandardXYToolTipGenerator.getTimeSeriesInstance(); XYURLGenerator urlGenerator = new MetadataInURLGenerator(designDescriptions); plot.getRenderer(datasetIndex).setBaseToolTipGenerator(toolTipGenerator); plot.getRenderer(datasetIndex).setURLGenerator(urlGenerator); // GRID: // PROBLEM: JFreeChart only allows to switch the grid on/off // for the whole XYPlot. And the // grid will always be displayed for the first series in the // plot. I'll always show the // grid. // --> plot.setDomainGridlinesVisible(visible) // RANGE AXIS LABELS: if (isOverview) { plot.getRangeAxisForDataset(datasetIndex).setTickLabelsVisible(false); plot.getRangeAxisForDataset(datasetIndex).setTickMarksVisible(false); plot.getRangeAxisForDataset(datasetIndex).setVisible(false); } else { plot.getRangeAxisForDataset(datasetIndex).setLabelFont(label); plot.getRangeAxisForDataset(datasetIndex).setLabelPaint(LABEL_COLOR); plot.getRangeAxisForDataset(datasetIndex).setTickLabelFont(tickLabelDomain); plot.getRangeAxisForDataset(datasetIndex).setTickLabelPaint(LABEL_COLOR); StringBuilder unitOfMeasure = new StringBuilder(); unitOfMeasure.append(dd.getPhenomenon().getLabel()); String uomLabel = dd.getUomLabel(); if (uomLabel != null && !uomLabel.isEmpty()) { unitOfMeasure.append(" (").append(uomLabel).append(")"); } plot.getRangeAxisForDataset(datasetIndex).setLabel(unitOfMeasure.toString()); } } } } return chart; }
From source file:org.n52.server.io.render.DiagramRenderer.java
/** * <pre>/*from ww w . j ava 2 s .c om*/ * dataset := associated to one range-axis; * corresponds to one observedProperty; * may contain multiple series; * series := corresponds to a time series for one foi * </pre> * * . * * @param entireCollMap * the entire coll map * @param options * the options * @param begin * the begin * @param end * the end * @param compress * @return the j free chart */ public JFreeChart renderChart(Map<String, OXFFeatureCollection> entireCollMap, DesignOptions options, Calendar begin, Calendar end, boolean compress) { DesignDescriptionList designDescriptions = buildUpDesignDescriptionList(options); /*** FIRST RUN ***/ JFreeChart chart = initializeTimeSeriesChart(); chart.setBackgroundPaint(Color.white); if (!this.isOverview) { chart.addSubtitle(new TextTitle(ConfigurationContext.COPYRIGHT, new Font(LABEL_FONT, Font.PLAIN, 9), Color.black, RectangleEdge.BOTTOM, HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, new RectangleInsets(0, 0, 20, 20))); } XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(2.0, 2.0, 2.0, 2.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setDomainGridlinesVisible(options.getGrid()); plot.setRangeGridlinesVisible(options.getGrid()); // add additional datasets: DateAxis dateAxis = (DateAxis) plot.getDomainAxis(); dateAxis.setRange(begin.getTime(), end.getTime()); dateAxis.setDateFormatOverride(new SimpleDateFormat()); dateAxis.setTimeZone(end.getTimeZone()); // add all axes String[] phenomenaIds = options.getAllPhenomenIds(); // all the axis indices to map them later HashMap<String, Integer> axes = new HashMap<String, Integer>(); for (int i = 0; i < phenomenaIds.length; i++) { axes.put(phenomenaIds[i], i); plot.setRangeAxis(i, new NumberAxis(phenomenaIds[i])); } // list range markers ArrayList<ValueMarker> referenceMarkers = new ArrayList<ValueMarker>(); HashMap<String, double[]> referenceBounds = new HashMap<String, double[]>(); // create all TS collections for (int i = 0; i < options.getProperties().size(); i++) { TimeseriesProperties prop = options.getProperties().get(i); String phenomenonId = prop.getPhenomenon(); TimeSeriesCollection dataset = createDataset(entireCollMap, prop, phenomenonId, compress); dataset.setGroup(new DatasetGroup(prop.getTimeseriesId())); XYDataset additionalDataset = dataset; NumberAxis axe = (NumberAxis) plot.getRangeAxis(axes.get(phenomenonId)); if (this.isOverview) { axe.setAutoRange(true); axe.setAutoRangeIncludesZero(false); } else if (prop.getAxisUpperBound() == prop.getAxisLowerBound() || prop.isAutoScale()) { if (prop.isZeroScaled()) { axe.setAutoRangeIncludesZero(true); } else { axe.setAutoRangeIncludesZero(false); } } else { if (prop.isZeroScaled()) { if (axe.getUpperBound() < prop.getAxisUpperBound()) { axe.setUpperBound(prop.getAxisUpperBound()); } if (axe.getLowerBound() > prop.getAxisLowerBound()) { axe.setLowerBound(prop.getAxisLowerBound()); } } else { axe.setRange(prop.getAxisLowerBound(), prop.getAxisUpperBound()); axe.setAutoRangeIncludesZero(false); } } plot.setDataset(i, additionalDataset); plot.mapDatasetToRangeAxis(i, axes.get(phenomenonId)); // set bounds new for reference values if (!referenceBounds.containsKey(phenomenonId)) { double[] bounds = new double[] { axe.getLowerBound(), axe.getUpperBound() }; referenceBounds.put(phenomenonId, bounds); } else { double[] bounds = referenceBounds.get(phenomenonId); if (bounds[0] >= axe.getLowerBound()) { bounds[0] = axe.getLowerBound(); } if (bounds[1] <= axe.getUpperBound()) { bounds[1] = axe.getUpperBound(); } } double[] bounds = referenceBounds.get(phenomenonId); for (String string : prop.getReferenceValues()) { if (prop.getRefValue(string).show()) { Double value = prop.getRefValue(string).getValue(); if (value <= bounds[0]) { bounds[0] = value; } else if (value >= bounds[1]) { bounds[1] = value; } } } Axis axis = prop.getAxis(); if (axis == null) { axis = new Axis(axe.getUpperBound(), axe.getLowerBound()); } else if (prop.isAutoScale()) { axis.setLowerBound(axe.getLowerBound()); axis.setUpperBound(axe.getUpperBound()); axis.setMaxY(axis.getMaxY()); axis.setMinY(axis.getMinY()); } prop.setAxisData(axis); this.axisMapping.put(prop.getTimeseriesId(), axis); for (String string : prop.getReferenceValues()) { if (prop.getRefValue(string).show()) { referenceMarkers.add(new ValueMarker(prop.getRefValue(string).getValue(), Color.decode(prop.getRefValue(string).getColor()), new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f))); } } plot.mapDatasetToRangeAxis(i, axes.get(phenomenonId)); } for (ValueMarker valueMarker : referenceMarkers) { plot.addRangeMarker(valueMarker); } // show actual time ValueMarker nowMarker = new ValueMarker(System.currentTimeMillis(), Color.orange, new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f)); plot.addDomainMarker(nowMarker); if (!this.isOverview) { Iterator<Entry<String, double[]>> iterator = referenceBounds.entrySet().iterator(); while (iterator.hasNext()) { Entry<String, double[]> boundsEntry = iterator.next(); String phenId = boundsEntry.getKey(); NumberAxis axe = (NumberAxis) plot.getRangeAxis(axes.get(phenId)); axe.setAutoRange(true); // add a margin double marginOffset = (boundsEntry.getValue()[1] - boundsEntry.getValue()[0]) / 25; boundsEntry.getValue()[0] -= marginOffset; boundsEntry.getValue()[1] += marginOffset; axe.setRange(boundsEntry.getValue()[0], boundsEntry.getValue()[1]); } } /**** SECOND RUN ***/ // set domain axis labels: plot.getDomainAxis().setLabelFont(label); plot.getDomainAxis().setLabelPaint(LABEL_COLOR); plot.getDomainAxis().setTickLabelFont(tickLabelDomain); plot.getDomainAxis().setTickLabelPaint(LABEL_COLOR); plot.getDomainAxis().setLabel(designDescriptions.getDomainAxisLabel()); // define the design for each series: for (int datasetIndex = 0; datasetIndex < plot.getDatasetCount(); datasetIndex++) { TimeSeriesCollection dataset = (TimeSeriesCollection) plot.getDataset(datasetIndex); for (int seriesIndex = 0; seriesIndex < dataset.getSeriesCount(); seriesIndex++) { String timeseriesId = (String) dataset.getSeries(seriesIndex).getKey(); RenderingDesign dd = designDescriptions.get(timeseriesId); if (dd != null) { // LINESTYLE: String lineStyle = dd.getLineStyle(); int width = dd.getLineWidth(); if (this.isOverview) { width = width / 2; width = (width == 0) ? 1 : width; } // "1" is lineStyle "line" if (lineStyle.equalsIgnoreCase(LINE)) { XYLineAndShapeRenderer ren = new XYLineAndShapeRenderer(true, false); ren.setStroke(new BasicStroke(width)); plot.setRenderer(datasetIndex, ren); } // "2" is lineStyle "area" else if (lineStyle.equalsIgnoreCase(AREA)) { plot.setRenderer(datasetIndex, new XYAreaRenderer()); } // "3" is lineStyle "dotted" else if (lineStyle.equalsIgnoreCase(DOTTED)) { XYLineAndShapeRenderer ren = new XYLineAndShapeRenderer(false, true); ren.setShape(new Ellipse2D.Double(-width, -width, 2 * width, 2 * width)); plot.setRenderer(datasetIndex, ren); } // "4" is dashed else if (lineStyle.equalsIgnoreCase("4")) { // dashed XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); renderer.setSeriesStroke(0, new BasicStroke(width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 4.0f * width, 4.0f * width }, 0.0f)); plot.setRenderer(datasetIndex, renderer); } else if (lineStyle.equalsIgnoreCase("5")) { // lines and dots XYLineAndShapeRenderer ren = new XYLineAndShapeRenderer(true, true); int thickness = 2 * width; ren.setShape(new Ellipse2D.Double(-width, -width, thickness, thickness)); ren.setStroke(new BasicStroke(width)); plot.setRenderer(datasetIndex, ren); } else { // default is lineStyle "line" plot.setRenderer(datasetIndex, new XYLineAndShapeRenderer(true, false)); } plot.getRenderer(datasetIndex).setSeriesPaint(seriesIndex, dd.getColor()); // plot.getRenderer(datasetIndex).setShapesVisible(true); XYToolTipGenerator toolTipGenerator = StandardXYToolTipGenerator.getTimeSeriesInstance(); XYURLGenerator urlGenerator = new MetadataInURLGenerator(designDescriptions); plot.getRenderer(datasetIndex).setBaseToolTipGenerator(toolTipGenerator); plot.getRenderer(datasetIndex).setURLGenerator(urlGenerator); // GRID: // PROBLEM: JFreeChart only allows to switch the grid on/off // for the whole XYPlot. And the // grid will always be displayed for the first series in the // plot. I'll always show the // grid. // --> plot.setDomainGridlinesVisible(visible) // RANGE AXIS LABELS: if (isOverview) { plot.getRangeAxisForDataset(datasetIndex).setTickLabelsVisible(false); plot.getRangeAxisForDataset(datasetIndex).setTickMarksVisible(false); plot.getRangeAxisForDataset(datasetIndex).setVisible(false); } else { plot.getRangeAxisForDataset(datasetIndex).setLabelFont(label); plot.getRangeAxisForDataset(datasetIndex).setLabelPaint(LABEL_COLOR); plot.getRangeAxisForDataset(datasetIndex).setTickLabelFont(tickLabelDomain); plot.getRangeAxisForDataset(datasetIndex).setTickLabelPaint(LABEL_COLOR); StringBuilder unitOfMeasure = new StringBuilder(); unitOfMeasure.append(dd.getPhenomenon().getLabel()); String uomLabel = dd.getUomLabel(); if (uomLabel != null && !uomLabel.isEmpty()) { unitOfMeasure.append(" (").append(uomLabel).append(")"); } plot.getRangeAxisForDataset(datasetIndex).setLabel(unitOfMeasure.toString()); } } } } return chart; }
From source file:org.locationtech.udig.processingtoolbox.tools.BubbleChartDialog.java
private void updateChart(SimpleFeatureCollection features, String xField, String yField, String sizeField) { // 1. Create a single plot containing both the scatter and line XYPlot plot = new XYPlot(); plot.setOrientation(PlotOrientation.VERTICAL); plot.setBackgroundPaint(java.awt.Color.WHITE); plot.setDomainPannable(false);//ww w .j a va 2s .c om plot.setRangePannable(false); plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setForegroundAlpha(0.75f); // 2. Setup Scatter plot // Create the bubble chart data, renderer, and axis int fontStyle = java.awt.Font.BOLD; FontData fontData = getShell().getDisplay().getSystemFont().getFontData()[0]; NumberAxis xPlotAxis = new NumberAxis(xField); // Independent variable xPlotAxis.setLabelFont(new Font(fontData.getName(), fontStyle, 12)); xPlotAxis.setTickLabelFont(new Font(fontData.getName(), fontStyle, 10)); NumberAxis yPlotAxis = new NumberAxis(yField); // Dependent variable yPlotAxis.setLabelFont(new Font(fontData.getName(), fontStyle, 12)); yPlotAxis.setTickLabelFont(new Font(fontData.getName(), fontStyle, 10)); XYItemRenderer plotRenderer = new XYBubbleRenderer(XYBubbleRenderer.SCALE_ON_RANGE_AXIS); plotRenderer.setSeriesPaint(0, java.awt.Color.ORANGE); // dot plotRenderer.setBaseItemLabelGenerator(new BubbleXYItemLabelGenerator()); plotRenderer.setBaseToolTipGenerator(new StandardXYZToolTipGenerator()); plotRenderer .setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER)); // Set the bubble chart data, renderer, and axis into plot plot.setDataset(0, getBubbleChartData(features, xField, yField, sizeField)); xPlotAxis.setAutoRangeIncludesZero(false); xPlotAxis.setAutoRange(false); double differUpper = minMaxVisitor.getMaxX() - minMaxVisitor.getAverageX(); double differLower = minMaxVisitor.getAverageX() - minMaxVisitor.getMinX(); double gap = Math.abs(differUpper - differLower); if (differUpper > differLower) { xPlotAxis.setRange(minMaxVisitor.getMinX() - gap, minMaxVisitor.getMaxX()); } else { xPlotAxis.setRange(minMaxVisitor.getMinX(), minMaxVisitor.getMaxX() + gap); } yPlotAxis.setAutoRangeIncludesZero(false); yPlotAxis.setAutoRange(false); differUpper = minMaxVisitor.getMaxY() - minMaxVisitor.getAverageY(); differLower = minMaxVisitor.getAverageY() - minMaxVisitor.getMinY(); gap = Math.abs(differUpper - differLower); if (differUpper > differLower) { yPlotAxis.setRange(minMaxVisitor.getMinY() - gap, minMaxVisitor.getMaxY()); } else { yPlotAxis.setRange(minMaxVisitor.getMinY(), minMaxVisitor.getMaxY() + gap); } plot.setRenderer(0, plotRenderer); plot.setDomainAxis(0, xPlotAxis); plot.setRangeAxis(0, yPlotAxis); // Map the scatter to the first Domain and first Range plot.mapDatasetToDomainAxis(0, 0); plot.mapDatasetToRangeAxis(0, 0); // 3. Setup line // Create the line data, renderer, and axis XYItemRenderer lineRenderer = new XYLineAndShapeRenderer(true, false); // Lines only lineRenderer.setSeriesPaint(0, java.awt.Color.GRAY); lineRenderer.setSeriesPaint(1, java.awt.Color.GRAY); lineRenderer.setSeriesPaint(2, java.awt.Color.GRAY); // Set the line data, renderer, and axis into plot NumberAxis xLineAxis = new NumberAxis(EMPTY); xLineAxis.setTickMarksVisible(false); xLineAxis.setTickLabelsVisible(false); NumberAxis yLineAxis = new NumberAxis(EMPTY); yLineAxis.setTickMarksVisible(false); yLineAxis.setTickLabelsVisible(false); XYSeriesCollection lineDataset = new XYSeriesCollection(); // AverageY XYSeries horizontal = new XYSeries("AverageY"); //$NON-NLS-1$ horizontal.add(xPlotAxis.getRange().getLowerBound(), minMaxVisitor.getAverageY()); horizontal.add(xPlotAxis.getRange().getUpperBound(), minMaxVisitor.getAverageY()); lineDataset.addSeries(horizontal); // AverageX XYSeries vertical = new XYSeries("AverageX"); //$NON-NLS-1$ vertical.add(minMaxVisitor.getAverageX(), yPlotAxis.getRange().getLowerBound()); vertical.add(minMaxVisitor.getAverageX(), yPlotAxis.getRange().getUpperBound()); lineDataset.addSeries(vertical); plot.setDataset(1, lineDataset); plot.setRenderer(1, lineRenderer); plot.setDomainAxis(1, xLineAxis); plot.setRangeAxis(1, yLineAxis); // Map the line to the second Domain and second Range plot.mapDatasetToDomainAxis(1, 0); plot.mapDatasetToRangeAxis(1, 0); // 4. Setup Selection NumberAxis xSelectionAxis = new NumberAxis(EMPTY); xSelectionAxis.setTickMarksVisible(false); xSelectionAxis.setTickLabelsVisible(false); NumberAxis ySelectionAxis = new NumberAxis(EMPTY); ySelectionAxis.setTickMarksVisible(false); ySelectionAxis.setTickLabelsVisible(false); XYItemRenderer selectionRenderer = new XYBubbleRenderer(XYBubbleRenderer.SCALE_ON_RANGE_AXIS); selectionRenderer.setSeriesPaint(0, java.awt.Color.RED); // dot selectionRenderer.setSeriesOutlinePaint(0, java.awt.Color.RED); plot.setDataset(2, new DefaultXYZDataset2()); plot.setRenderer(2, selectionRenderer); plot.setDomainAxis(2, xSelectionAxis); plot.setRangeAxis(2, ySelectionAxis); // Map the scatter to the second Domain and second Range plot.mapDatasetToDomainAxis(2, 0); plot.mapDatasetToRangeAxis(2, 0); // 5. Finally, Create the chart with the plot and a legend java.awt.Font titleFont = new Font(fontData.getName(), fontStyle, 20); JFreeChart chart = new JFreeChart(EMPTY, titleFont, plot, false); chart.setBackgroundPaint(java.awt.Color.WHITE); chart.setBorderVisible(false); chartComposite.setChart(chart); chartComposite.forceRedraw(); }
From source file:v800_trainer.JHistogram.java
public JPanel StartHistoSp(JCicloTronic JTronicHandle) { boolean Summenhisto; int von = 0;/*from www.j a v a2 s . c om*/ int bis = 0; int num = 0; int selected; int single; int Gruppen = 0; int i = 100; int j = 10; int m = 0; int n = 0; int Linecount = 0; int Anzahl = 1; JFreeChart chart; double DummyData[] = new double[1]; selected = JTronicHandle.Auswahl_Histogramm.getSelectedIndex(); Summenhisto = JTronicHandle.Summenhistogramm_Check.isSelected(); chart = ChartFactory.createHistogram("", "Geschwindigkeit [km/h]", "Hufigkeit", new HistogramDataset(), PlotOrientation.HORIZONTAL, true, true, true); chart.setBackgroundPaint(Color.white); JTronicHandle.applyChartTheme(chart); XYPlot plot = chart.getXYPlot(); plot.setOrientation(PlotOrientation.VERTICAL); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.getRangeAxis().setFixedDimension(15.0); ArrayList Bufferarray = new ArrayList(); double Buffer; if (selected == 0) { single = 1; } else { single = 0; Summenhisto = false; } try { von = Integer.parseInt(JTronicHandle.Properties.getProperty("HistovonSp", "100")); bis = Integer.parseInt(JTronicHandle.Properties.getProperty("HistobisSp", "200")); Gruppen = Integer.parseInt(JTronicHandle.Properties.getProperty("HistostepSp", "10")); Anzahl = (JTronicHandle.Auswahl_Histogramm.getItemCount() - 2) * single + 1; for (j = 0; j < Anzahl; j++) { if (single == 1) { selected = j + 1; } if (!Summenhisto) { num = JTronicHandle.Statistikhandle.TourData[selected].Datenpunkte; } else { num += JTronicHandle.Statistikhandle.TourData[selected].Datenpunkte; } n = 0; if (!Summenhisto) { create_Start_Stop(JTronicHandle, selected); //die limits einer gezoomten Graphik ermitteln for (i = start; i < stop; i++) { Buffer = (double) JTronicHandle.Statistikhandle.TourData[selected].Geschw_gesZeit[i]; if (Buffer >= von && Buffer <= bis) { Bufferarray.add(Buffer); } } } else { for (i = 0; i < j + 1; i++) { create_Start_Stop(JTronicHandle, i + 1); for (m = start; m < stop; m++) { Buffer = (double) JTronicHandle.Statistikhandle.TourData[i + 1].Geschw_gesZeit[m]; if (Buffer >= von && Buffer <= bis) { Bufferarray.add(Buffer); } } } } DummyData = new double[Bufferarray.size()]; for (i = 0; i < Bufferarray.size(); i++) { DummyData[i] = new Double(Bufferarray.get(i).toString()); } if (!Summenhisto) { HistogramDataset histoHM = new HistogramDataset(); histoHM.addSeries( "" + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr, DummyData, Gruppen, (double) von, (double) bis); histoHM.setType(HistogramType.RELATIVE_FREQUENCY); plot.setDataset(Linecount, histoHM); plot.mapDatasetToRangeAxis(Linecount, 0); XYBarRenderer renderer = new XYBarRenderer(); renderer.setDrawBarOutline(true); renderer.setSeriesPaint(0, getColour(Linecount, (int) 255 / Anzahl)); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); } Linecount++; } } catch (Exception e) { JOptionPane.showMessageDialog(null, "StartHistoSp\nFehler: Sp " + e + " " + i + " " + j, "Achtung!", JOptionPane.ERROR_MESSAGE); } if (Summenhisto) { HistogramDataset histoHM = new HistogramDataset(); histoHM.addSeries("Summenhistogram", DummyData, Gruppen, (double) von, (double) bis); histoHM.setType(HistogramType.RELATIVE_FREQUENCY); plot.setDataset(0, histoHM); plot.mapDatasetToRangeAxis(0, 0); XYItemRenderer renderer = new XYBarRenderer(); renderer.setSeriesPaint(0, Color.blue); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(0, renderer); } chart.setPadding(padding); ChartPanel Panel = new ChartPanel(chart); return Panel; }
From source file:v800_trainer.JHistogram.java
public JPanel StartHistoHm(JCicloTronic JTronicHandle) { boolean Summenhisto; int von = 0;/*from w w w.j a v a 2 s . c om*/ int bis = 0; int num = 0; int selected; int single; int Gruppen = 0; int i = 100; int j = 10; int m = 0; int n = 0; int Linecount = 0; int Anzahl = 1; JFreeChart chart; double DummyData[] = new double[1]; selected = JTronicHandle.Auswahl_Histogramm.getSelectedIndex(); Summenhisto = JTronicHandle.Summenhistogramm_Check.isSelected(); chart = ChartFactory.createHistogram("", "Steigung [m/min]", "Hufigkeit", new HistogramDataset(), PlotOrientation.HORIZONTAL, true, true, true); chart.setBackgroundPaint(Color.white); JTronicHandle.applyChartTheme(chart); XYPlot plot = chart.getXYPlot(); plot.setOrientation(PlotOrientation.VERTICAL); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.getRangeAxis().setFixedDimension(15.0); ArrayList Bufferarray = new ArrayList(); double Buffer; if (selected == 0) { single = 1; } else { single = 0; Summenhisto = false; } ; try { von = Integer.parseInt(JTronicHandle.Properties.getProperty("HistovonHm", "100")); bis = Integer.parseInt(JTronicHandle.Properties.getProperty("HistobisHm", "200")); Gruppen = Integer.parseInt(JTronicHandle.Properties.getProperty("HistostepHm", "10")); Anzahl = (JTronicHandle.Auswahl_Histogramm.getItemCount() - 2) * single + 1; for (j = 0; j < Anzahl; j++) { if (single == 1) { selected = j + 1; } if (!Summenhisto) { num = JTronicHandle.Statistikhandle.TourData[selected].Datenpunkte; } else { num += JTronicHandle.Statistikhandle.TourData[selected].Datenpunkte; } n = 0; if (!Summenhisto) { create_Start_Stop(JTronicHandle, selected); //die limits einer gezoomten Graphik ermitteln for (i = start; i < stop; i++) { Buffer = (double) JTronicHandle.Statistikhandle.TourData[selected].Steigm_gesZeit[i]; if (Buffer >= von && Buffer <= bis) { Bufferarray.add(Buffer); } } } else { for (i = 0; i < j + 1; i++) { create_Start_Stop(JTronicHandle, i + 1); for (m = start; m < stop; m++) { Buffer = (double) JTronicHandle.Statistikhandle.TourData[i + 1].Steigm_gesZeit[m]; if (Buffer >= von && Buffer <= bis) { Bufferarray.add(Buffer); } } } } DummyData = new double[Bufferarray.size()]; for (i = 0; i < Bufferarray.size(); i++) { DummyData[i] = new Double(Bufferarray.get(i).toString()); } if (!Summenhisto) { HistogramDataset histoHM = new HistogramDataset(); histoHM.addSeries( "" + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr, DummyData, Gruppen, (double) von, (double) bis); histoHM.setType(HistogramType.RELATIVE_FREQUENCY); plot.setDataset(Linecount, histoHM); plot.mapDatasetToRangeAxis(Linecount, 0); XYBarRenderer renderer = new XYBarRenderer(); renderer.setDrawBarOutline(true); renderer.setSeriesPaint(0, getColour(Linecount, (int) 255 / Anzahl)); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); } Linecount++; } } catch (Exception e) { JOptionPane.showMessageDialog(null, "StartHistoSp\nFehler: Hm " + e + " " + i + " " + j, "Achtung!", JOptionPane.ERROR_MESSAGE); } if (Summenhisto) { HistogramDataset histoHM = new HistogramDataset(); histoHM.addSeries("Summenhistogram", DummyData, Gruppen, (double) von, (double) bis); histoHM.setType(HistogramType.RELATIVE_FREQUENCY); plot.setDataset(0, histoHM); plot.mapDatasetToRangeAxis(0, 0); XYItemRenderer renderer = new XYBarRenderer(); renderer.setSeriesPaint(0, Color.blue); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(0, renderer); } chart.setPadding(padding); ChartPanel Panel = new ChartPanel(chart); return Panel; }
From source file:v800_trainer.JHistogram.java
public JPanel StartHistoSchrittlnge(JCicloTronic JTronicHandle) { boolean Summenhisto; int von = 0;/*from w ww . ja v a 2 s . c om*/ int bis = 0; int num = 0; int selected; int single; int Gruppen = 0; int i = 100; int j = 10; int m = 0; int n = 0; int Linecount = 0; int Anzahl = 1; JFreeChart chart; double DummyData[] = new double[1]; selected = JTronicHandle.Auswahl_Histogramm.getSelectedIndex(); Summenhisto = JTronicHandle.Summenhistogramm_Check.isSelected(); chart = ChartFactory.createHistogram("", "Schrittlnge [cm]", "Hufigkeit", new HistogramDataset(), PlotOrientation.HORIZONTAL, true, true, true); chart.setBackgroundPaint(Color.white); JTronicHandle.applyChartTheme(chart); XYPlot plot = chart.getXYPlot(); plot.setOrientation(PlotOrientation.VERTICAL); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.getRangeAxis().setFixedDimension(15.0); ArrayList Bufferarray = new ArrayList(); double Buffer; if (selected == 0) { single = 1; } else { single = 0; Summenhisto = false; } try { von = Integer.parseInt(JTronicHandle.Properties.getProperty("HistovonSchrittlnge", "100")); bis = Integer.parseInt(JTronicHandle.Properties.getProperty("HistobisSchrittlnge", "200")); Gruppen = Integer.parseInt(JTronicHandle.Properties.getProperty("HistostepSchrittlnge", "10")); Anzahl = (JTronicHandle.Auswahl_Histogramm.getItemCount() - 2) * single + 1; for (j = 0; j < Anzahl; j++) { if (single == 1) { selected = j + 1; } if (!Summenhisto) { num = JTronicHandle.Statistikhandle.TourData[selected].Datenpunkte; } else { num += JTronicHandle.Statistikhandle.TourData[selected].Datenpunkte; } n = 0; if (!Summenhisto) { create_Start_Stop(JTronicHandle, selected); //die limits einer gezoomten Graphik ermitteln for (i = start; i < stop; i++) { Buffer = (double) JTronicHandle.Statistikhandle.TourData[selected].Schritt_lnge[i]; if (Buffer >= von && Buffer <= bis) { Bufferarray.add(Buffer); } } } else { for (i = 0; i < j + 1; i++) { create_Start_Stop(JTronicHandle, i + 1); for (m = start; m < stop; m++) { Buffer = (double) JTronicHandle.Statistikhandle.TourData[i + 1].Schritt_lnge[m]; if (Buffer >= von && Buffer <= bis) { Bufferarray.add(Buffer); } } } } DummyData = new double[Bufferarray.size()]; for (i = 0; i < Bufferarray.size(); i++) { DummyData[i] = new Double(Bufferarray.get(i).toString()); } if (!Summenhisto) { HistogramDataset histoHM = new HistogramDataset(); histoHM.addSeries( "" + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr, DummyData, Gruppen, (double) von, (double) bis); histoHM.setType(HistogramType.RELATIVE_FREQUENCY); plot.setDataset(Linecount, histoHM); plot.mapDatasetToRangeAxis(Linecount, 0); XYBarRenderer renderer = new XYBarRenderer(); renderer.setDrawBarOutline(true); renderer.setSeriesPaint(0, getColour(Linecount, (int) 255 / Anzahl)); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); } Linecount++; } } catch (Exception e) { JOptionPane.showMessageDialog(null, "StartHistoSchrittlnge\nFehler: Hm " + e + " " + i + " " + j, "Achtung!", JOptionPane.ERROR_MESSAGE); } if (Summenhisto) { HistogramDataset histoHM = new HistogramDataset(); histoHM.addSeries("Summenhistogram", DummyData, Gruppen, (double) von, (double) bis); histoHM.setType(HistogramType.RELATIVE_FREQUENCY); plot.setDataset(0, histoHM); plot.mapDatasetToRangeAxis(0, 0); XYItemRenderer renderer = new XYBarRenderer(); renderer.setSeriesPaint(0, Color.blue); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(0, renderer); } chart.setPadding(padding); ChartPanel Panel = new ChartPanel(chart); return Panel; }
From source file:v800_trainer.JHistogram.java
public JPanel StartHistoCd(JCicloTronic JTronicHandle) { boolean Summenhisto; int von = 0;/* w w w .j ava2 s . c om*/ int bis = 0; int num = 0; int selected; int single; int Gruppen = 0; int i = 100; int j = 10; int m = 0; int n = 0; int Linecount = 0; int Anzahl = 1; JFreeChart chart; double DummyData[] = new double[1]; selected = JTronicHandle.Auswahl_Histogramm.getSelectedIndex(); Summenhisto = JTronicHandle.Summenhistogramm_Check.isSelected(); chart = ChartFactory.createHistogram("", "Cadence [n/min]", "Hufigkeit", new HistogramDataset(), PlotOrientation.HORIZONTAL, true, true, true); chart.setBackgroundPaint(Color.white); JTronicHandle.applyChartTheme(chart); XYPlot plot = chart.getXYPlot(); plot.setOrientation(PlotOrientation.VERTICAL); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.getRangeAxis().setFixedDimension(15.0); ArrayList Bufferarray = new ArrayList(); double Buffer; if (selected == 0) { single = 1; } else { single = 0; Summenhisto = false; } try { von = Integer.parseInt(JTronicHandle.Properties.getProperty("HistovonCd", "100")); bis = Integer.parseInt(JTronicHandle.Properties.getProperty("HistobisCd", "200")); Gruppen = Integer.parseInt(JTronicHandle.Properties.getProperty("HistostepCd", "10")); Anzahl = (JTronicHandle.Auswahl_Histogramm.getItemCount() - 2) * single + 1; for (j = 0; j < Anzahl; j++) { if (single == 1) { selected = j + 1; } if (!Summenhisto) { num = JTronicHandle.Statistikhandle.TourData[selected].Datenpunkte; } else { num += JTronicHandle.Statistikhandle.TourData[selected].Datenpunkte; } n = 0; if (!Summenhisto) { create_Start_Stop(JTronicHandle, selected); //die limits einer gezoomten Graphik ermitteln for (i = start; i < stop; i++) { Buffer = (double) JTronicHandle.Statistikhandle.TourData[selected].Cadence_gesZeit[i]; if (Buffer >= von && Buffer <= bis) { Bufferarray.add(Buffer); } } } else { for (i = 0; i < j + 1; i++) { create_Start_Stop(JTronicHandle, i + 1); for (m = start; m < stop; m++) { Buffer = (double) JTronicHandle.Statistikhandle.TourData[i + 1].Cadence_gesZeit[m]; if (Buffer >= von && Buffer <= bis) { Bufferarray.add(Buffer); } } n += m; } } DummyData = new double[Bufferarray.size()]; for (i = 0; i < Bufferarray.size(); i++) { DummyData[i] = new Double(Bufferarray.get(i).toString()); } if (!Summenhisto) { HistogramDataset histoHM = new HistogramDataset(); histoHM.addSeries( "" + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr, DummyData, Gruppen, (double) von, (double) bis); histoHM.setType(HistogramType.RELATIVE_FREQUENCY); plot.setDataset(Linecount, histoHM); plot.mapDatasetToRangeAxis(Linecount, 0); XYBarRenderer renderer = new XYBarRenderer(); renderer.setDrawBarOutline(true); renderer.setSeriesPaint(0, getColour(Linecount, (int) 255 / Anzahl)); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); } Linecount++; } } catch (Exception e) { JOptionPane.showMessageDialog(null, "StartHistoCd\nFehler: Cd " + e + " " + i + " " + j, "Achtung!", JOptionPane.ERROR_MESSAGE); } if (Summenhisto) { HistogramDataset histoHM = new HistogramDataset(); histoHM.addSeries("Summenhistogram", DummyData, Gruppen, (double) von, (double) bis); histoHM.setType(HistogramType.RELATIVE_FREQUENCY); plot.setDataset(0, histoHM); plot.mapDatasetToRangeAxis(0, 0); XYItemRenderer renderer = new XYBarRenderer(); renderer.setSeriesPaint(0, Color.blue); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(0, renderer); } ; chart.setPadding(padding); ChartPanel Panel = new ChartPanel(chart); return Panel; }