List of usage examples for org.jfree.chart.plot XYPlot setOrientation
public void setOrientation(PlotOrientation orientation)
From source file:org.pentaho.platform.uifoundation.chart.JFreeChartEngine.java
private static void updatePlot(final Plot plot, final ChartDefinition chartDefinition) { plot.setBackgroundPaint(chartDefinition.getPlotBackgroundPaint()); plot.setBackgroundImage(chartDefinition.getPlotBackgroundImage()); plot.setNoDataMessage(chartDefinition.getNoDataMessage()); // create a custom palette if it was defined if (chartDefinition.getPaintSequence() != null) { DefaultDrawingSupplier drawingSupplier = new DefaultDrawingSupplier(chartDefinition.getPaintSequence(), DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE); plot.setDrawingSupplier(drawingSupplier); }/*w ww . ja va 2s .com*/ plot.setOutlineStroke(null); // TODO define outline stroke if (plot instanceof CategoryPlot) { CategoryPlot categoryPlot = (CategoryPlot) plot; CategoryDatasetChartDefinition categoryDatasetChartDefintion = (CategoryDatasetChartDefinition) chartDefinition; categoryPlot.setOrientation(categoryDatasetChartDefintion.getOrientation()); CategoryAxis domainAxis = categoryPlot.getDomainAxis(); if (domainAxis != null) { domainAxis.setLabel(categoryDatasetChartDefintion.getDomainTitle()); domainAxis.setLabelFont(categoryDatasetChartDefintion.getDomainTitleFont()); if (categoryDatasetChartDefintion.getDomainTickFont() != null) { domainAxis.setTickLabelFont(categoryDatasetChartDefintion.getDomainTickFont()); } domainAxis.setCategoryLabelPositions(categoryDatasetChartDefintion.getCategoryLabelPositions()); } NumberAxis numberAxis = (NumberAxis) categoryPlot.getRangeAxis(); if (numberAxis != null) { numberAxis.setLabel(categoryDatasetChartDefintion.getRangeTitle()); numberAxis.setLabelFont(categoryDatasetChartDefintion.getRangeTitleFont()); if (categoryDatasetChartDefintion.getRangeMinimum() != ValueAxis.DEFAULT_LOWER_BOUND) { numberAxis.setLowerBound(categoryDatasetChartDefintion.getRangeMinimum()); } if (categoryDatasetChartDefintion.getRangeMaximum() != ValueAxis.DEFAULT_UPPER_BOUND) { numberAxis.setUpperBound(categoryDatasetChartDefintion.getRangeMaximum()); } if (categoryDatasetChartDefintion.getRangeTickFormat() != null) { numberAxis.setNumberFormatOverride(categoryDatasetChartDefintion.getRangeTickFormat()); } if (categoryDatasetChartDefintion.getRangeTickFont() != null) { numberAxis.setTickLabelFont(categoryDatasetChartDefintion.getRangeTickFont()); } if (categoryDatasetChartDefintion.getRangeTickUnits() != null) { numberAxis.setTickUnit(new NumberTickUnit(categoryDatasetChartDefintion.getRangeTickUnits())); } } } if (plot instanceof PiePlot) { PiePlot pie = (PiePlot) plot; PieDatasetChartDefinition pieDefinition = (PieDatasetChartDefinition) chartDefinition; pie.setInteriorGap(pieDefinition.getInteriorGap()); pie.setStartAngle(pieDefinition.getStartAngle()); pie.setLabelFont(pieDefinition.getLabelFont()); if (pieDefinition.getLabelPaint() != null) { pie.setLabelPaint(pieDefinition.getLabelPaint()); } pie.setLabelBackgroundPaint(pieDefinition.getLabelBackgroundPaint()); if (pieDefinition.isLegendIncluded()) { StandardPieSectionLabelGenerator labelGen = new StandardPieSectionLabelGenerator("{0}"); //$NON-NLS-1$ pie.setLegendLabelGenerator(labelGen); } if (pieDefinition.getExplodedSlices() != null) { for (Iterator iter = pieDefinition.getExplodedSlices().iterator(); iter.hasNext();) { pie.setExplodePercent((Comparable) iter.next(), .30); } } pie.setLabelGap(pieDefinition.getLabelGap()); if (!pieDefinition.isDisplayLabels()) { pie.setLabelGenerator(null); } else { if (pieDefinition.isLegendIncluded()) { StandardPieSectionLabelGenerator labelGen = new StandardPieSectionLabelGenerator("{1} ({2})"); //$NON-NLS-1$ pie.setLabelGenerator(labelGen); } else { StandardPieSectionLabelGenerator labelGen = new StandardPieSectionLabelGenerator( "{0} = {1} ({2})"); //$NON-NLS-1$ pie.setLabelGenerator(labelGen); } } } if (plot instanceof MultiplePiePlot) { MultiplePiePlot pies = (MultiplePiePlot) plot; CategoryDatasetChartDefinition categoryDatasetChartDefintion = (CategoryDatasetChartDefinition) chartDefinition; pies.setDataset(categoryDatasetChartDefintion); } if (plot instanceof MeterPlot) { MeterPlot meter = (MeterPlot) plot; DialWidgetDefinition widget = (DialWidgetDefinition) chartDefinition; List intervals = widget.getIntervals(); Iterator intervalIterator = intervals.iterator(); while (intervalIterator.hasNext()) { MeterInterval interval = (MeterInterval) intervalIterator.next(); meter.addInterval(interval); } meter.setNeedlePaint(widget.getNeedlePaint()); meter.setDialShape(widget.getDialShape()); meter.setDialBackgroundPaint(widget.getPlotBackgroundPaint()); meter.setRange(new Range(widget.getMinimum(), widget.getMaximum())); } if (plot instanceof XYPlot) { XYPlot xyPlot = (XYPlot) plot; if (chartDefinition instanceof XYSeriesCollectionChartDefinition) { XYSeriesCollectionChartDefinition xySeriesCollectionChartDefintion = (XYSeriesCollectionChartDefinition) chartDefinition; xyPlot.setOrientation(xySeriesCollectionChartDefintion.getOrientation()); ValueAxis domainAxis = xyPlot.getDomainAxis(); if (domainAxis != null) { domainAxis.setLabel(xySeriesCollectionChartDefintion.getDomainTitle()); domainAxis.setLabelFont(xySeriesCollectionChartDefintion.getDomainTitleFont()); domainAxis.setVerticalTickLabels(xySeriesCollectionChartDefintion.isDomainVerticalTickLabels()); if (xySeriesCollectionChartDefintion.getDomainTickFormat() != null) { ((NumberAxis) domainAxis) .setNumberFormatOverride(xySeriesCollectionChartDefintion.getDomainTickFormat()); } if (xySeriesCollectionChartDefintion.getDomainTickFont() != null) { domainAxis.setTickLabelFont(xySeriesCollectionChartDefintion.getDomainTickFont()); } if (xySeriesCollectionChartDefintion.getDomainMinimum() != ValueAxis.DEFAULT_LOWER_BOUND) { domainAxis.setLowerBound(xySeriesCollectionChartDefintion.getDomainMinimum()); } if (xySeriesCollectionChartDefintion.getDomainMaximum() != ValueAxis.DEFAULT_UPPER_BOUND) { domainAxis.setUpperBound(xySeriesCollectionChartDefintion.getDomainMaximum()); } } ValueAxis rangeAxis = xyPlot.getRangeAxis(); if (rangeAxis != null) { rangeAxis.setLabel(xySeriesCollectionChartDefintion.getRangeTitle()); rangeAxis.setLabelFont(xySeriesCollectionChartDefintion.getRangeTitleFont()); if (xySeriesCollectionChartDefintion.getRangeMinimum() != ValueAxis.DEFAULT_LOWER_BOUND) { rangeAxis.setLowerBound(xySeriesCollectionChartDefintion.getRangeMinimum()); } if (xySeriesCollectionChartDefintion.getRangeMaximum() != ValueAxis.DEFAULT_UPPER_BOUND) { rangeAxis.setUpperBound(xySeriesCollectionChartDefintion.getRangeMaximum()); } if (xySeriesCollectionChartDefintion.getRangeMinimum() != ValueAxis.DEFAULT_LOWER_BOUND) { rangeAxis.setLowerBound(xySeriesCollectionChartDefintion.getRangeMinimum()); } if (xySeriesCollectionChartDefintion.getRangeMaximum() != ValueAxis.DEFAULT_UPPER_BOUND) { rangeAxis.setUpperBound(xySeriesCollectionChartDefintion.getRangeMaximum()); } if (xySeriesCollectionChartDefintion.getRangeTickFormat() != null) { ((NumberAxis) rangeAxis) .setNumberFormatOverride(xySeriesCollectionChartDefintion.getRangeTickFormat()); } if (xySeriesCollectionChartDefintion.getRangeTickFont() != null) { rangeAxis.setTickLabelFont(xySeriesCollectionChartDefintion.getRangeTickFont()); } } } else if (chartDefinition instanceof TimeSeriesCollectionChartDefinition) { TimeSeriesCollectionChartDefinition timeSeriesCollectionChartDefintion = (TimeSeriesCollectionChartDefinition) chartDefinition; xyPlot.setOrientation(timeSeriesCollectionChartDefintion.getOrientation()); ValueAxis domainAxis = xyPlot.getDomainAxis(); if (domainAxis != null) { domainAxis.setLabel(timeSeriesCollectionChartDefintion.getDomainTitle()); domainAxis.setLabelFont(timeSeriesCollectionChartDefintion.getDomainTitleFont()); domainAxis .setVerticalTickLabels(timeSeriesCollectionChartDefintion.isDomainVerticalTickLabels()); if (domainAxis instanceof DateAxis) { DateAxis da = (DateAxis) domainAxis; if (timeSeriesCollectionChartDefintion.getDateMinimum() != null) { da.setMinimumDate(timeSeriesCollectionChartDefintion.getDateMinimum()); } if (timeSeriesCollectionChartDefintion.getDateMaximum() != null) { da.setMaximumDate(timeSeriesCollectionChartDefintion.getDateMaximum()); } } } ValueAxis rangeAxis = xyPlot.getRangeAxis(); if (rangeAxis != null) { rangeAxis.setLabel(timeSeriesCollectionChartDefintion.getRangeTitle()); rangeAxis.setLabelFont(timeSeriesCollectionChartDefintion.getRangeTitleFont()); if (timeSeriesCollectionChartDefintion.getRangeMinimum() != ValueAxis.DEFAULT_LOWER_BOUND) { rangeAxis.setLowerBound(timeSeriesCollectionChartDefintion.getRangeMinimum()); } if (timeSeriesCollectionChartDefintion.getRangeMaximum() != ValueAxis.DEFAULT_UPPER_BOUND) { rangeAxis.setUpperBound(timeSeriesCollectionChartDefintion.getRangeMaximum()); } } } else if (chartDefinition instanceof XYZSeriesCollectionChartDefinition) { XYZSeriesCollectionChartDefinition xyzSeriesCollectionChartDefintion = (XYZSeriesCollectionChartDefinition) chartDefinition; xyPlot.setOrientation(xyzSeriesCollectionChartDefintion.getOrientation()); ValueAxis domainAxis = xyPlot.getDomainAxis(); if (domainAxis != null) { domainAxis.setLabel(xyzSeriesCollectionChartDefintion.getDomainTitle()); domainAxis.setLabelFont(xyzSeriesCollectionChartDefintion.getDomainTitleFont()); domainAxis .setVerticalTickLabels(xyzSeriesCollectionChartDefintion.isDomainVerticalTickLabels()); if (xyzSeriesCollectionChartDefintion.getDomainMinimum() != ValueAxis.DEFAULT_LOWER_BOUND) { domainAxis.setLowerBound(xyzSeriesCollectionChartDefintion.getDomainMinimum()); } if (xyzSeriesCollectionChartDefintion.getDomainMaximum() != ValueAxis.DEFAULT_UPPER_BOUND) { domainAxis.setUpperBound(xyzSeriesCollectionChartDefintion.getDomainMaximum()); } if (xyzSeriesCollectionChartDefintion.getDomainTickFormat() != null) { ((NumberAxis) domainAxis) .setNumberFormatOverride(xyzSeriesCollectionChartDefintion.getDomainTickFormat()); } if (xyzSeriesCollectionChartDefintion.getDomainTickFont() != null) { domainAxis.setTickLabelFont(xyzSeriesCollectionChartDefintion.getDomainTickFont()); } } ValueAxis rangeAxis = xyPlot.getRangeAxis(); if (rangeAxis != null) { rangeAxis.setLabel(xyzSeriesCollectionChartDefintion.getRangeTitle()); rangeAxis.setLabelFont(xyzSeriesCollectionChartDefintion.getRangeTitleFont()); rangeAxis.setLowerBound(xyzSeriesCollectionChartDefintion.getRangeMinimum()); if (xyzSeriesCollectionChartDefintion.getRangeMinimum() != ValueAxis.DEFAULT_LOWER_BOUND) { rangeAxis.setLowerBound(xyzSeriesCollectionChartDefintion.getRangeMinimum()); } if (xyzSeriesCollectionChartDefintion.getRangeMaximum() != ValueAxis.DEFAULT_UPPER_BOUND) { rangeAxis.setUpperBound(xyzSeriesCollectionChartDefintion.getRangeMaximum()); } if (xyzSeriesCollectionChartDefintion.getRangeTickFormat() != null) { ((NumberAxis) rangeAxis) .setNumberFormatOverride(xyzSeriesCollectionChartDefintion.getRangeTickFormat()); } if (xyzSeriesCollectionChartDefintion.getRangeTickFont() != null) { rangeAxis.setTickLabelFont(xyzSeriesCollectionChartDefintion.getRangeTickFont()); } } } } }
From source file:v800_trainer.JUebersicht.java
public JPanel Update_Uebersicht(JCicloTronic JTronicHandle) { int i;//from ww w. ja v a 2s . co m Day xTime[]; Today = new GregorianCalendar(); double y1Werte[]; double y2Werte[]; double y3Werte[]; double y4Werte[]; double y5Werte[]; double y6Werte[]; double y7Werte[]; double y8Werte[]; double y9Werte[]; double y10Werte[]; double SummeZeit = 0; double Summekm = 0; double Summehm = 0; double SummeZeit12Mon = 0; double Summekm12Mon = 0; double Summehm12Mon = 0; int AnzahlJahre = 0; int Selektiert = 0; int SelektiertVergl = 0; int Jahr; int Linecount = 0; boolean Vergleich = false; XYItemRenderer renderer; XYBarRenderer rendererb; JFreeChart chart; AnzahlJahre = JTronicHandle.Auswahl_bersicht.getItemCount(); Selektiert = JTronicHandle.Auswahl_bersicht.getSelectedIndex(); SelektiertVergl = JTronicHandle.JahrVergleich.getSelectedIndex(); if (SelektiertVergl == 0 || Selektiert == SelektiertVergl - 1) Vergleich = false; else Vergleich = true; xTime = new Day[366]; y1Werte = new double[366]; y2Werte = new double[366]; y3Werte = new double[366]; y4Werte = new double[366]; y5Werte = new double[366]; y6Werte = new double[366]; y7Werte = new double[366]; y8Werte = new double[366]; y9Werte = new double[366]; y10Werte = new double[366]; TimeSeries dataset; dataset = new TimeSeries("dummy"); dataset.add(new Day(1, 1, 1900), 1); TimeSeriesCollection dataset1 = new TimeSeriesCollection(dataset); chart = ChartFactory.createTimeSeriesChart( "Jahresbersicht " + JTronicHandle.Auswahl_bersicht.getSelectedItem().toString(), "Zeit", "", dataset1, true, true, true); XYToolTipGenerator ToolTip = new StandardXYToolTipGenerator("{0}: ({1}, {2})", (DateFormat) new SimpleDateFormat("dd.MM"), NumberFormat.getInstance()); if (SelektiertVergl != 0) chart.addSubtitle(new TextTitle( "Vergleich mit Jahr " + JTronicHandle.JahrVergleich.getSelectedItem().toString())); 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.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setRangeCrosshairLockedOnData(false); plot.setDomainCrosshairLockedOnData(false); if (!JTronicHandle.jRadioButton_jahresverlauf.isSelected()) { DateAxis MyAxis = new DateAxis(); MyAxis = (DateAxis) plot.getDomainAxis(); MyAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); MyAxis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); plot.setDomainGridlinesVisible(false); } plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.getRangeAxis().setFixedDimension(15.0); plot.getDomainAxis().setTickLabelInsets(new RectangleInsets(2.0, 1.0, 2.0, 1.0)); Jahr = Integer.parseInt(JTronicHandle.Auswahl_bersicht.getSelectedItem().toString()); for (i = 0; i < 366; i++) { SummeZeit12Mon += (double) Zeit[Selektiert + 1][i]; Summekm12Mon += (double) kmJahr[Selektiert + 1][i]; Summehm12Mon += (double) HmJahr[Selektiert + 1][i]; } y4Werte[0] = SummeZeit12Mon; y5Werte[0] = Summekm12Mon; y6Werte[0] = Summehm12Mon; xTime[0] = new Day(31, 12, Jahr - 1); for (i = 1; i < 366; i++) { try { xTime[i] = new Day(xTime[i - 1].next().getStart()); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Exception GregorianCalender " + e, "Achtung!", JOptionPane.ERROR_MESSAGE); } if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) { SummeZeit += (double) Zeit[Selektiert][i]; Summekm += (double) kmJahr[Selektiert][i]; Summehm += (double) HmJahr[Selektiert][i]; y1Werte[i] = SummeZeit; y2Werte[i] = Summekm; y3Werte[i] = Summehm; y4Werte[i] = y4Werte[i - 1] - (double) Zeit[Selektiert + 1][i] + (double) Zeit[Selektiert][i]; y5Werte[i] = y5Werte[i - 1] - (double) kmJahr[Selektiert + 1][i] + (double) kmJahr[Selektiert][i]; y6Werte[i] = y6Werte[i - 1] - (double) HmJahr[Selektiert + 1][i] + (double) HmJahr[Selektiert][i]; } else { Day n = new Day(1, xTime[i].getMonth(), xTime[i].getYear()); try { Kalender = new GregorianCalendar(xTime[i].getYear(), xTime[i].getMonth() - 1, 1); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Exception GregorianCalender " + e, "Achtung!", JOptionPane.ERROR_MESSAGE); } int j = (int) Kalender.get(Kalender.DAY_OF_YEAR); for (int m = 0; m < 6; m++) { y1Werte[j + m + 1] += (double) Zeit[Selektiert][i]; y2Werte[j + m + 11] += (double) kmJahr[Selektiert][i]; y3Werte[j + m + 21] += (double) HmJahr[Selektiert][i]; } } } dataset = new TimeSeries("Trainingszeit " + JTronicHandle.Auswahl_bersicht.getSelectedItem().toString()); for (i = 0; i < 366; i++) { dataset.add(xTime[i], y1Werte[i]); } dataset1 = new TimeSeriesCollection(dataset); NumberAxis axis = new NumberAxis(); try { axis = (NumberAxis) plot.getRangeAxis().clone(); } catch (Exception e) { } axis.setLabel("Stunden"); axis.setAutoRangeIncludesZero(true); axis.setLabelPaint(Color.BLACK); axis.setTickLabelPaint(Color.BLACK); plot.setRangeAxis(0, axis); plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_LEFT); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 0); if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) { renderer = new StandardXYItemRenderer(2, ToolTip); renderer.setSeriesPaint(0, getColour(Linecount, 255)); plot.setRenderer(Linecount, renderer); } else { rendererb = new XYBarRenderer(); rendererb.setSeriesPaint(0, getColour(Linecount, 150)); rendererb.setShadowVisible(false); rendererb.setDrawBarOutline(false); rendererb.setBarPainter(new StandardXYBarPainter()); plot.setRenderer(Linecount, rendererb); } Linecount++; dataset = new TimeSeries( "Trainingskilometer " + JTronicHandle.Auswahl_bersicht.getSelectedItem().toString()); for (i = 0; i < 366; i++) { dataset.add(xTime[i], y2Werte[i]); } TimeSeriesCollection dataset2 = new TimeSeriesCollection(dataset); NumberAxis axis2 = new NumberAxis(); try { axis2 = (NumberAxis) plot.getRangeAxis().clone(); } catch (Exception e) { } ; axis2.setLabel("Kilometer"); axis2.setAutoRangeIncludesZero(true); axis2.setLabelPaint(Color.BLACK); axis2.setTickLabelPaint(Color.BLACK); plot.setRangeAxis(1, axis2); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT); plot.setDataset(Linecount, dataset2); plot.mapDatasetToRangeAxis(Linecount, 1); if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) { renderer = new StandardXYItemRenderer(2, ToolTip); renderer.setSeriesPaint(0, getColour(Linecount, 255)); plot.setRenderer(Linecount, renderer); } else { rendererb = new XYBarRenderer(); rendererb.setSeriesPaint(0, getColour(Linecount, 150)); rendererb.setShadowVisible(false); rendererb.setDrawBarOutline(false); rendererb.setBarPainter(new StandardXYBarPainter()); plot.setRenderer(Linecount, rendererb); } Linecount++; dataset = new TimeSeries( "Trainingshhenmeter " + JTronicHandle.Auswahl_bersicht.getSelectedItem().toString()); for (i = 0; i < 366; i++) { dataset.add(xTime[i], y3Werte[i]); } TimeSeriesCollection dataset3 = new TimeSeriesCollection(dataset); NumberAxis axis3 = new NumberAxis("Hhenmeter"); try { axis3 = (NumberAxis) plot.getRangeAxis().clone(); } catch (Exception e) { } ; axis3.setLabel("Hhenmeter"); axis3.setAutoRangeIncludesZero(true); axis3.setLabelPaint(Color.BLACK); axis3.setTickLabelPaint(Color.BLACK); plot.setRangeAxis(2, axis3); plot.setRangeAxisLocation(2, AxisLocation.BOTTOM_OR_RIGHT); plot.setDataset(Linecount, dataset3); plot.mapDatasetToRangeAxis(Linecount, 2); if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) { renderer = new StandardXYItemRenderer(2, ToolTip); renderer.setSeriesPaint(0, getColour(Linecount, 255)); plot.setRenderer(Linecount, renderer); } else { rendererb = new XYBarRenderer(); rendererb.setSeriesPaint(0, getColour(Linecount, 150)); rendererb.setShadowVisible(false); rendererb.setDrawBarOutline(false); rendererb.setBarPainter(new StandardXYBarPainter()); plot.setRenderer(Linecount, rendererb); } Linecount++; if (Vergleich == true) { SummeZeit = 0; Summekm = 0; Summehm = 0; SummeZeit12Mon = 0; Summekm12Mon = 0; Summehm12Mon = 0; for (i = 0; i < 366; i++) { SummeZeit12Mon += (double) Zeit[SelektiertVergl - 1][i]; Summekm12Mon += (double) kmJahr[SelektiertVergl - 1][i]; Summehm12Mon += (double) HmJahr[SelektiertVergl - 1][i]; } y4Werte[0] = SummeZeit12Mon; y5Werte[0] = Summekm12Mon; y6Werte[0] = Summehm12Mon; for (i = 1; i < 366; i++) { try { } catch (Exception e) { JOptionPane.showMessageDialog(null, "Exception GregorianCalender " + e, "Achtung!", JOptionPane.ERROR_MESSAGE); } ; if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) { SummeZeit += (double) Zeit[SelektiertVergl - 1][i]; Summekm += (double) kmJahr[SelektiertVergl - 1][i]; Summehm += (double) HmJahr[SelektiertVergl - 1][i]; y7Werte[i] = SummeZeit; y8Werte[i] = Summekm; y9Werte[i] = Summehm; y4Werte[i] = y4Werte[i - 1] - (double) Zeit[SelektiertVergl - 1][i] + (double) Zeit[Selektiert][i]; y5Werte[i] = y5Werte[i - 1] - (double) kmJahr[SelektiertVergl - 1][i] + (double) kmJahr[Selektiert][i]; y6Werte[i] = y6Werte[i - 1] - (double) HmJahr[SelektiertVergl - 1][i] + (double) HmJahr[Selektiert][i]; } else { Day n = new Day(1, xTime[i].getMonth(), xTime[i].getYear()); try { Kalender = new GregorianCalendar(xTime[i].getYear(), xTime[i].getMonth() - 1, 1); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Exception GregorianCalender " + e, "Achtung!", JOptionPane.ERROR_MESSAGE); } int j = (int) Kalender.get(Kalender.DAY_OF_YEAR); for (int m = 0; m < 5; m++) { y7Werte[j + m + 4] += (double) Zeit[SelektiertVergl - 1][i]; y8Werte[j + m + 14] += (double) kmJahr[SelektiertVergl - 1][i]; y9Werte[j + m + 24] += (double) HmJahr[SelektiertVergl - 1][i]; } } } if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) { dataset = new TimeSeries("Trainingszeit ber 12 Monate "); for (i = 0; i < 366; i++) { dataset.add(xTime[i], y4Werte[i]); } TimeSeriesCollection dataset4 = new TimeSeriesCollection(dataset); plot.setDataset(Linecount, dataset4); plot.mapDatasetToRangeAxis(Linecount, 0); if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) { renderer = new StandardXYItemRenderer(2, ToolTip); renderer.setSeriesPaint(0, getColour(Linecount, 255)); plot.setRenderer(Linecount, renderer); } else { rendererb = new XYBarRenderer(); rendererb.setSeriesPaint(0, getColour(Linecount, 150)); rendererb.setShadowVisible(false); rendererb.setBarPainter(new StandardXYBarPainter()); plot.setRenderer(Linecount, rendererb); } Linecount++; dataset = new TimeSeries("Trainingskilometer ber 12 Monate "); for (i = 0; i < 366; i++) { dataset.add(xTime[i], y5Werte[i]); } TimeSeriesCollection dataset5 = new TimeSeriesCollection(dataset); plot.setDataset(Linecount, dataset5); plot.mapDatasetToRangeAxis(Linecount, 1); if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) { renderer = new StandardXYItemRenderer(2, ToolTip); renderer.setSeriesPaint(0, getColour(Linecount, 255)); plot.setRenderer(Linecount, renderer); } else { rendererb = new XYBarRenderer(); rendererb.setSeriesPaint(0, getColour(Linecount, 150)); rendererb.setShadowVisible(false); rendererb.setGradientPaintTransformer(null); rendererb.setBarPainter(new StandardXYBarPainter()); plot.setRenderer(Linecount, rendererb); } Linecount++; dataset = new TimeSeries("Trainingshhenmeter ber 12 Monate "); for (i = 0; i < 366; i++) { dataset.add(xTime[i], y6Werte[i]); } TimeSeriesCollection dataset6 = new TimeSeriesCollection(dataset); plot.setDataset(Linecount, dataset6); plot.mapDatasetToRangeAxis(Linecount, 2); if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) { renderer = new StandardXYItemRenderer(2, ToolTip); renderer.setSeriesPaint(0, getColour(Linecount, 255)); plot.setRenderer(Linecount, renderer); } else { rendererb = new XYBarRenderer(); rendererb.setSeriesPaint(0, getColour(Linecount, 150)); rendererb.setShadowVisible(false); rendererb.setGradientPaintTransformer(null); rendererb.setBarPainter(new StandardXYBarPainter()); plot.setRenderer(Linecount, rendererb); } } Linecount++; dataset = new TimeSeries("Trainingszeit " + JTronicHandle.JahrVergleich.getSelectedItem().toString()); for (i = 0; i < 366; i++) { dataset.add(xTime[i], y7Werte[i]); } TimeSeriesCollection dataset7 = new TimeSeriesCollection(dataset); plot.setDataset(Linecount, dataset7); plot.mapDatasetToRangeAxis(Linecount, 0); if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) { renderer = new StandardXYItemRenderer(2, ToolTip); renderer.setSeriesPaint(0, getColour(Linecount, 255)); plot.setRenderer(Linecount, renderer); } else { rendererb = new XYBarRenderer(); rendererb.setSeriesPaint(0, getColour(Linecount, 150)); rendererb.setShadowVisible(false); rendererb.setGradientPaintTransformer(null); rendererb.setBarPainter(new StandardXYBarPainter()); plot.setRenderer(Linecount, rendererb); } Linecount++; dataset = new TimeSeries( "Trainingskilometer " + JTronicHandle.JahrVergleich.getSelectedItem().toString()); for (i = 0; i < 366; i++) { dataset.add(xTime[i], y8Werte[i]); } TimeSeriesCollection dataset8 = new TimeSeriesCollection(dataset); plot.setDataset(Linecount, dataset8); plot.mapDatasetToRangeAxis(Linecount, 1); if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) { renderer = new StandardXYItemRenderer(2, ToolTip); renderer.setSeriesPaint(0, getColour(Linecount, 255)); plot.setRenderer(Linecount, renderer); } else { rendererb = new XYBarRenderer(); rendererb.setSeriesPaint(0, getColour(Linecount, 150)); rendererb.setShadowVisible(false); rendererb.setGradientPaintTransformer(null); rendererb.setBarPainter(new StandardXYBarPainter()); plot.setRenderer(Linecount, rendererb); } Linecount++; dataset = new TimeSeries( "Trainingshhenmeter " + JTronicHandle.JahrVergleich.getSelectedItem().toString()); for (i = 0; i < 366; i++) { dataset.add(xTime[i], y9Werte[i]); } TimeSeriesCollection dataset9 = new TimeSeriesCollection(dataset); plot.setDataset(Linecount, dataset9); plot.mapDatasetToRangeAxis(Linecount, 2); if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) { renderer = new StandardXYItemRenderer(2, ToolTip); renderer.setSeriesPaint(0, getColour(Linecount, 255)); plot.setRenderer(Linecount, renderer); } else { rendererb = new XYBarRenderer(); rendererb.setSeriesPaint(0, getColour(Linecount, 150)); rendererb.setShadowVisible(false); rendererb.setGradientPaintTransformer(null); rendererb.setBarPainter(new StandardXYBarPainter()); plot.setRenderer(Linecount, rendererb); } } if (!JTronicHandle.jRadioButton_jahresverlauf.isSelected()) { double max = axis.getRange().getUpperBound(); for (i = 0; i < 12; i++) { try { Kalender = new GregorianCalendar(Integer.parseInt(DataProperty.getProperty("Jahr", "0")), i, 1); } catch (Exception e) { JOptionPane.showMessageDialog(null, "JUebersicht\nException GregorianCalender " + e, "Achtung!", JOptionPane.ERROR_MESSAGE); } y10Werte[Kalender.get(Kalender.DAY_OF_YEAR)] = max; y10Werte[Kalender.get(Kalender.DAY_OF_YEAR) + 1] = 0; } dataset = new TimeSeries(""); for (i = 0; i < 366; i++) { dataset.add(xTime[i], y10Werte[i]); } TimeSeriesCollection dataset10 = new TimeSeriesCollection(dataset); plot.setDataset(Linecount + 1, dataset10); plot.mapDatasetToRangeAxis(Linecount + 1, 0); renderer = new StandardXYItemRenderer(2, ToolTip); renderer.setSeriesPaint(0, Color.white); plot.setRenderer(Linecount + 1, renderer); plot.getDomainAxis().setAutoRange(false); axis.setRange(0, max); } if (JTronicHandle.jRadioButton_jahresverlauf.isSelected()) { axis2.setRange(0, axis2.getRange().getUpperBound() * 1.5); axis3.setRange(0, axis3.getRange().getUpperBound() * 2); plot.setDomainCrosshairValue( (double) new GregorianCalendar(Jahr, Today.get(Today.MONTH), Today.get(Today.DAY_OF_MONTH)) .getTimeInMillis()); } chart.setPadding(padding); ChartPanel Panel = new ChartPanel(chart); Panel.setDismissDelay(100000); return Panel; }
From source file:edu.dlnu.liuwenpeng.ChartFactory.ChartFactory.java
/** * Creates a bubble chart with default settings. The chart is composed of * an {@link XYPlot}, with a {@link NumberAxis} for the domain axis, * a {@link NumberAxis} for the range axis, and an {@link XYBubbleRenderer} * to draw the data items. //from w ww . ja v a 2 s .c o m * * @param title the chart title (<code>null</code> permitted). * @param xAxisLabel a label for the X-axis (<code>null</code> permitted). * @param yAxisLabel a label for the Y-axis (<code>null</code> permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param orientation the orientation (horizontal or vertical) * (<code>null</code> NOT permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A bubble chart. */ public static JFreeChart createBubbleChart(String title, String xAxisLabel, String yAxisLabel, XYZDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } NumberAxis xAxis = new NumberAxis(xAxisLabel); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(yAxisLabel); yAxis.setAutoRangeIncludesZero(false); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null); XYItemRenderer renderer = new XYBubbleRenderer(XYBubbleRenderer.SCALE_ON_RANGE_AXIS); if (tooltips) { renderer.setBaseToolTipGenerator(new StandardXYZToolTipGenerator()); } if (urls) { renderer.setURLGenerator(new StandardXYZURLGenerator()); } plot.setRenderer(renderer); plot.setOrientation(orientation); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); return chart; }
From source file:OverlaidXYPlotDemo2.java
/** * Creates an overlaid chart.//from w w w . ja v a2 s . c o m * * @return The chart. */ private JFreeChart createOverlaidChart() { final DateAxis domainAxis = new DateAxis("Date"); domainAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); final ValueAxis rangeAxis = new NumberAxis("Value"); // create plot... final IntervalXYDataset data1 = createDataset1(); final XYItemRenderer renderer1 = new XYBarRenderer(0.20); renderer1.setToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00"))); final XYPlot plot = new XYPlot(data1, domainAxis, rangeAxis, renderer1); final double x = new Day(9, SerialDate.MARCH, 2002).getMiddleMillisecond(); final XYTextAnnotation annotation = new XYTextAnnotation("Hello!", x, 10000.0); annotation.setFont(new Font("SansSerif", Font.PLAIN, 9)); plot.addAnnotation(annotation); final ValueAxis rangeAxis2 = new NumberAxis("Value 2"); plot.setRangeAxis(1, rangeAxis2); // create subplot 2... final XYDataset data2A = createDataset2A(); final XYItemRenderer renderer2A = new StandardXYItemRenderer(); renderer2A.setToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00"))); plot.setDataset(1, data2A); plot.setRenderer(1, renderer2A); final XYDataset data2B = createDataset2B(); plot.setDataset(2, data2B); plot.setRenderer(2, new StandardXYItemRenderer()); plot.mapDatasetToRangeAxis(2, 1); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); plot.setOrientation(PlotOrientation.VERTICAL); // return a new chart containing the overlaid plot... return new JFreeChart("Overlaid Plot Example", JFreeChart.DEFAULT_TITLE_FONT, plot, true); }
From source file:KIDLYFactory.java
/** * Creates a bubble chart with default settings. The chart is composed of * an {@link XYPlot}, with a {@link NumberAxis} for the domain axis, * a {@link NumberAxis} for the range axis, and an {@link XYBubbleRenderer} * to draw the data items./*from w w w .j a va 2s . c o m*/ * * @param title the chart title (<code>null</code> permitted). * @param xAxisLabel a label for the X-axis (<code>null</code> permitted). * @param yAxisLabel a label for the Y-axis (<code>null</code> permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param orientation the orientation (horizontal or vertical) * (<code>null</code> NOT permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A bubble chart. */ public static JFreeChart createBubbleChart(String title, String xAxisLabel, String yAxisLabel, XYZDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } NumberAxis xAxis = new NumberAxis(xAxisLabel); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(yAxisLabel); yAxis.setAutoRangeIncludesZero(false); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null); XYItemRenderer renderer = new XYBubbleRenderer(XYBubbleRenderer.SCALE_ON_RANGE_AXIS); if (tooltips) { renderer.setBaseToolTipGenerator(new StandardXYZToolTipGenerator()); } if (urls) { renderer.setURLGenerator(new StandardXYZURLGenerator()); } plot.setRenderer(renderer); plot.setOrientation(orientation); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
From source file:org.moeaframework.analysis.plot.Plot.java
/** * If the chart has not yet been initialized, creates a chart for XY data. * If the chart is already initialized, checks if the chart is for XY data. * //from w ww . j av a2 s. com * @throws FrameworkException if the chart does not support XY data */ private void createXYPlot() { if (chart == null) { NumberAxis xAxis = new NumberAxis(""); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(""); yAxis.setAutoRangeIncludesZero(false); XYPlot plot = new XYPlot(); plot.setDomainAxis(xAxis); plot.setRangeAxis(yAxis); XYToolTipGenerator toolTipGenerator = new StandardXYToolTipGenerator(); XYItemRenderer renderer = new XYLineAndShapeRenderer(false, true); renderer.setBaseToolTipGenerator(toolTipGenerator); plot.setRenderer(renderer); plot.setOrientation(PlotOrientation.VERTICAL); chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true); ChartFactory.getChartTheme().apply(chart); } else if (!(chart.getPlot() instanceof XYPlot)) { throw new FrameworkException("Can not combine XY plot and categorial plot"); } }
From source file:edu.dlnu.liuwenpeng.ChartFactory.ChartFactory.java
/** * Creates a scatter plot with default settings. The chart object * returned by this method uses an {@link XYPlot} instance as the plot, * with a {@link NumberAxis} for the domain axis, a {@link NumberAxis} * as the range axis, and an {@link XYLineAndShapeRenderer} as the * renderer. // w w w . j a v a2 s. c o m * * @param title the chart title (<code>null</code> permitted). * @param xAxisLabel a label for the X-axis (<code>null</code> permitted). * @param yAxisLabel a label for the Y-axis (<code>null</code> permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param orientation the plot orientation (horizontal or vertical) * (<code>null</code> NOT permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A scatter plot. */ public static JFreeChart createScatterPlot(String title, String xAxisLabel, String yAxisLabel, XYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } NumberAxis xAxis = new NumberAxis(xAxisLabel); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(yAxisLabel); yAxis.setAutoRangeIncludesZero(false); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null); XYToolTipGenerator toolTipGenerator = null; if (tooltips) { toolTipGenerator = new StandardXYToolTipGenerator(); } XYURLGenerator urlGenerator = null; if (urls) { urlGenerator = new StandardXYURLGenerator(); } XYItemRenderer renderer = new XYLineAndShapeRenderer(false, true); renderer.setBaseToolTipGenerator(toolTipGenerator); renderer.setURLGenerator(urlGenerator); plot.setRenderer(renderer); plot.setOrientation(orientation); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); return chart; }
From source file:v800_trainer.XYGraphik.java
public JPanel StartGraphik(JCicloTronic JTronicHandle) { int num = 0;//from w w w . j ava 2 s . co m int num2 = 0, num0, num02; //fr Streckendifferenz int selected; int single; int i; int j; int Stunden; int Minuten; int Sekunden; int Tagadder = 0; int Linecount = 0; Second xTime[]; double xWerte[]; double xWerte2[];//fr Streckendifferenz double y1Werte[]; double y2Werte[]; double y3Werte[]; double y4Werte[]; double y5Werte[]; double y6Werte[]; double y7Werte[]; double y8Werte[]; double y8bWerte[]; double y9Werte[]; double y10Werte[]; JFreeChart chart; Rectangle2D.Double Legendenpunkt = new Rectangle2D.Double(); selected = JTronicHandle.Auswahl_Graphik.getSelectedIndex(); if (selected == 0) { single = 1; } else { single = 0; } //Defaultchart erstellen if (JTronicHandle.Graphik_Radio_Strecke.isSelected()) { XYSeries dataset = new XYSeries(""); dataset.add(1, 1); XYSeriesCollection dataset1 = new XYSeriesCollection(dataset); chart = ChartFactory.createXYLineChart("Multiple Axis Demo 1", "Strecke", "", dataset1, PlotOrientation.HORIZONTAL, true, true, false); } else { TimeSeries dataset = new TimeSeries(""); dataset.add(new Second(1, 1, 1, 1, 1, 1900), 1); TimeSeriesCollection dataset1 = new TimeSeriesCollection(dataset); chart = ChartFactory.createTimeSeriesChart("Multiple Axis Demo 1", "Zeit", "", dataset1, true, true, false); } ; //Tooltips fr Zeitachse einstellen // XYToolTipGenerator ToolTip = new StandardXYToolTipGenerator("{0}: ({1}, {2})", // (DateFormat) new SimpleDateFormat("kk:mm.ss"), // NumberFormat.getInstance()); // chart.setAntiAlias(true); chart.setNotify(false); if (single == 0) { chart.setTitle(JTronicHandle.Statistikhandle.TourData[JTronicHandle.Auswahl_Graphik .getSelectedIndex()].DataProperty.getProperty("Titel", "")); chart.addSubtitle(new TextTitle(JTronicHandle.Auswahl_Graphik.getItemAt(selected).toString())); } else { chart.setTitle("Mehrfache Daten"); } 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.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setRangeCrosshairLockedOnData(false); plot.setDomainCrosshairLockedOnData(false); int Anzahl_Kurven = Integer.parseInt(JTronicHandle.Properties.getProperty("AnzahlKurven", "5")) + 1; if (Anzahl_Kurven > JTronicHandle.Auswahl_Graphik.getItemCount()) { Anzahl_Kurven = JTronicHandle.Auswahl_Graphik.getItemCount(); } try { for (j = 0; j < (Anzahl_Kurven - 2) * single + 1; j++) { if (single == 1) { selected = j + 1; } num = JTronicHandle.Statistikhandle.TourData[selected].Datenpunkte; num2 = JTronicHandle.Statistikhandle.TourData[selected].ZahlStreckenPunkte; num0 = JTronicHandle.Statistikhandle.TourData[1].ZahlStreckenPunkte; num02 = JTronicHandle.Statistikhandle.TourData[1].Datenpunkte; xTime = new Second[num]; xWerte = new double[num]; y1Werte = new double[num]; y2Werte = new double[num]; y3Werte = new double[num]; y4Werte = new double[num]; y5Werte = new double[num]; y6Werte = new double[num]; y7Werte = new double[num]; y8Werte = new double[num]; y8bWerte = new double[num]; xWerte2 = new double[num2]; y9Werte = new double[num2]; y10Werte = new double[num]; for (i = 0; i < num; i++) { xWerte[i] = (double) JTronicHandle.Statistikhandle.TourData[selected].Strecke_gesZeit[i]; y1Werte[i] = (double) JTronicHandle.Statistikhandle.TourData[selected].Geschw_gesZeit[i]; y2Werte[i] = (double) JTronicHandle.Statistikhandle.TourData[selected].Hoehe_gesZeit[i]; y3Werte[i] = (double) JTronicHandle.Statistikhandle.TourData[selected].Hf_gesZeit[i]; y4Werte[i] = (double) JTronicHandle.Statistikhandle.TourData[selected].Temperatur_gesZeit[i]; y5Werte[i] = (double) JTronicHandle.Statistikhandle.TourData[selected].Steigp_gesZeit[i]; y6Werte[i] = (double) JTronicHandle.Statistikhandle.TourData[selected].Steigm_gesZeit[i]; y7Werte[i] = (double) JTronicHandle.Statistikhandle.TourData[selected].av_Geschw_gesZeit[i]; y8Werte[i] = (double) JTronicHandle.Statistikhandle.TourData[selected].Cadence_gesZeit[i]; y8bWerte[i] = (double) JTronicHandle.Statistikhandle.TourData[selected].Schritt_lnge[i]; } if (JTronicHandle.Graphik_check_Abstand.isSelected() && single == 1 && j != 0) { int p = 0; if (JTronicHandle.Graphik_Radio_Strecke.isSelected()) { for (i = 0; i < num2; i++) { xWerte2[i] = (double) JTronicHandle.Statistikhandle.TourData[selected].Streckenskala[i]; if (i < num0) { y9Werte[i] = (double) JTronicHandle.Statistikhandle.TourData[selected].ZeitberStrecke[i] - JTronicHandle.Statistikhandle.TourData[1].ZeitberStrecke[i]; } else { y9Werte[i] = y9Werte[i - 1]; } } } else { for (i = 0; i < num; i++) { p = 0; while (p < num02 - 1 && (JTronicHandle.Statistikhandle.TourData[selected].gesZeit[i] >= JTronicHandle.Statistikhandle.TourData[1].gesZeit[p])) { p++; } ; if (i < num02) { y10Werte[i] = (double) (JTronicHandle.Statistikhandle.TourData[selected].Strecke_gesZeit[i] - JTronicHandle.Statistikhandle.TourData[1].Strecke_gesZeit[p]) * 100.0; } else { y10Werte[i] = y10Werte[i - 1]; } } } } //Zeitbasis laden for (i = 0; i < num; i++) { Tagadder = 0; Stunden = (int) (JTronicHandle.Statistikhandle.TourData[selected].gesZeit[i] / 3600); Minuten = (int) ((JTronicHandle.Statistikhandle.TourData[selected].gesZeit[i] - Stunden * 3600) / 60); Sekunden = (int) (JTronicHandle.Statistikhandle.TourData[selected].gesZeit[i] - Stunden * 3600 - Minuten * 60); if (single == 0) { Minuten = Minuten + JTronicHandle.Statistikhandle.TourData[selected].StartMinuten; if (Minuten >= 60) { Minuten -= 60; Stunden++; } ; Stunden = Stunden + JTronicHandle.Statistikhandle.TourData[selected].StartStunden; } ; while (Stunden >= 24) { Stunden -= 24; Tagadder += 1; } ; try { if (single == 0) { xTime[i] = new Second(Sekunden, Minuten, Stunden, JTronicHandle.Statistikhandle.TourData[selected].Tag + Tagadder, JTronicHandle.Statistikhandle.TourData[selected].Monat, JTronicHandle.Statistikhandle.TourData[selected].Jahr); } else { xTime[i] = new Second(Sekunden, Minuten, Stunden, 1 + Tagadder, 1, 1900); } } catch (Exception e) { JOptionPane.showMessageDialog(null, "StartGraphik\n" + e + "Zeile " + i + " Zeitfehler " + Stunden + " " + Minuten + " " + Sekunden, "Achtung!", JOptionPane.ERROR_MESSAGE); } } if (JTronicHandle.Graphik_Radio_Strecke.isSelected()) { //Streckenachse if (JTronicHandle.Graphik_check_Geschwindigkeit.isSelected()) { XYSeries dataset = new XYSeries( "Geschwindigkeit [km/h] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr); for (i = 0; i < num; i++) { dataset.add(xWerte[i], y1Werte[i]); } XYSeriesCollection dataset1 = new XYSeriesCollection(dataset); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 0); XYItemRenderer renderer = new StandardXYItemRenderer(); renderer.setSeriesPaint(0, getColour(Linecount)); // renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); Linecount++; } if (JTronicHandle.Graphik_check_Hhe.isSelected()) { XYSeries dataset = new XYSeries( "Hhe [m] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr); for (i = 0; i < num; i++) { dataset.add(xWerte[i], y2Werte[i]); } XYSeriesCollection dataset1 = new XYSeriesCollection(dataset); NumberAxis axis2 = new NumberAxis("Hhe [m]"); axis2.setLabelFont(plot.getRangeAxis().getLabelFont()); axis2.setTickLabelFont(plot.getRangeAxis().getTickLabelFont()); axis2.setAutoRangeIncludesZero(true); axis2.setLabelPaint(Color.BLACK); axis2.setTickLabelPaint(Color.BLACK); axis2.setAxisLinePaint(Color.BLACK); plot.setRangeAxis(1, axis2); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 1); XYItemRenderer renderer = new StandardXYItemRenderer(); renderer.setSeriesPaint(0, getColour(Linecount)); // renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); Linecount++; } ; if (JTronicHandle.Graphik_check_HF.isSelected()) { XYSeries dataset = new XYSeries( "Herzfrequenz [b/min] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr); for (i = 0; i < num; i++) { dataset.add(xWerte[i], y3Werte[i]); } XYSeriesCollection dataset1 = new XYSeriesCollection(dataset); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 0); XYItemRenderer renderer = new StandardXYItemRenderer(); renderer.setSeriesPaint(0, getColour(Linecount)); // renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); Linecount++; } if (JTronicHandle.Graphik_check_Temp.isSelected()) { XYSeries dataset = new XYSeries( "Temperatur [C] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr); for (i = 0; i < num; i++) { dataset.add(xWerte[i], y4Werte[i]); } XYSeriesCollection dataset1 = new XYSeriesCollection(dataset); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 0); XYItemRenderer renderer = new StandardXYItemRenderer(); renderer.setSeriesPaint(0, getColour(Linecount)); // renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); Linecount++; } if (JTronicHandle.Graphik_check_Steigung_p.isSelected()) { XYSeries dataset = new XYSeries( "Steigung [%] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr); for (i = 0; i < num; i++) { dataset.add(xWerte[i], y5Werte[i]); } XYSeriesCollection dataset1 = new XYSeriesCollection(dataset); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 0); XYItemRenderer renderer = new StandardXYItemRenderer(); renderer.setSeriesPaint(0, getColour(Linecount)); // renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); Linecount++; } if (JTronicHandle.Graphik_check_Steigung_m.isSelected()) { XYSeries dataset = new XYSeries( "Steigung [m/min] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr); for (i = 0; i < num; i++) { dataset.add(xWerte[i], y6Werte[i]); } XYSeriesCollection dataset1 = new XYSeriesCollection(dataset); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 0); XYItemRenderer renderer = new StandardXYItemRenderer(); renderer.setSeriesPaint(0, getColour(Linecount)); // renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); Linecount++; } if (JTronicHandle.Graphik_check_av_Geschw.isSelected()) { XYSeries dataset = new XYSeries( "av Geschw. [km/h] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr); for (i = 0; i < num; i++) { dataset.add(xWerte[i], y7Werte[i]); } XYSeriesCollection dataset1 = new XYSeriesCollection(dataset); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 0); XYItemRenderer renderer = new StandardXYItemRenderer(); renderer.setSeriesPaint(0, getColour(Linecount)); // renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); Linecount++; } if (JTronicHandle.Graphik_check_Cadence.isSelected()) { XYSeries dataset = new XYSeries( "Cadence [n/min] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr); for (i = 0; i < num; i++) { dataset.add(xWerte[i], y8Werte[i]); } XYSeriesCollection dataset1 = new XYSeriesCollection(dataset); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 0); XYItemRenderer renderer = new StandardXYItemRenderer(); renderer.setSeriesPaint(0, getColour(Linecount)); // renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); Linecount++; } if (JTronicHandle.Graphik_check_Schrittlnge.isSelected()) { XYSeries dataset = new XYSeries( "Schrittlnge [cm] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr); for (i = 0; i < num; i++) { dataset.add(xWerte[i], y8bWerte[i]); } XYSeriesCollection dataset1 = new XYSeriesCollection(dataset); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 0); XYItemRenderer renderer = new StandardXYItemRenderer(); renderer.setSeriesPaint(0, getColour(Linecount)); // renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); Linecount++; } if (JTronicHandle.Graphik_check_Abstand.isSelected() && single == 1 && j != 0) { XYSeries dataset = new XYSeries( "Zeitabstand [s] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr + " - " + JTronicHandle.Statistikhandle.TourData[1].Tag + "." + JTronicHandle.Statistikhandle.TourData[1].Monat + "." + JTronicHandle.Statistikhandle.TourData[1].Jahr); for (i = 0; i < num2; i++) { dataset.add(xWerte2[i], y9Werte[i]); } XYSeriesCollection dataset1 = new XYSeriesCollection(dataset); NumberAxis axis3 = new NumberAxis("Abstand"); axis3.setLabelFont(plot.getRangeAxis().getLabelFont()); axis3.setTickLabelFont(plot.getRangeAxis().getTickLabelFont()); axis3.setAutoRangeIncludesZero(true); axis3.setLabelPaint(Color.BLACK); axis3.setTickLabelPaint(Color.BLACK); plot.setRangeAxis(2, axis3); plot.setRangeAxisLocation(2, AxisLocation.BOTTOM_OR_RIGHT); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 2); XYItemRenderer renderer = new StandardXYItemRenderer(); renderer.setSeriesPaint(0, getColour(Linecount)); // renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); Linecount++; } } else { //Zeitachse if (JTronicHandle.Graphik_check_Geschwindigkeit.isSelected()) { TimeSeries dataset = new TimeSeries( "Geschwindigkeit [km/h] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr); for (i = 0; i < num; i++) { dataset.add(xTime[i], y1Werte[i]); } TimeSeriesCollection dataset1 = new TimeSeriesCollection(dataset); ValueAxis axis = plot.getRangeAxis(); axis.setLabelPaint(Color.BLACK); axis.setTickLabelPaint(Color.BLACK); plot.setRangeAxis(0, axis); plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_LEFT); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 0); XYItemRenderer renderer = new StandardXYItemRenderer(2);//, ToolTip); renderer.setSeriesPaint(0, getColour(Linecount)); plot.setRenderer(Linecount, renderer); Linecount++; } if (JTronicHandle.Graphik_check_Hhe.isSelected()) { TimeSeries dataset = new TimeSeries( "Hoehe [m] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr); for (i = 0; i < num; i++) { dataset.add(xTime[i], y2Werte[i]); } TimeSeriesCollection dataset1 = new TimeSeriesCollection(dataset); NumberAxis axis2 = (NumberAxis) plot.getRangeAxis().clone(); axis2.setLabel("Hhe [m]"); axis2.setAutoRangeIncludesZero(true); axis2.setLabelPaint(Color.BLACK); axis2.setTickLabelPaint(Color.BLACK); axis2.setAxisLinePaint(Color.BLACK); plot.setRangeAxis(1, axis2); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 1); XYItemRenderer renderer = new StandardXYItemRenderer(2);//, ToolTip); renderer.setSeriesPaint(0, getColour(Linecount)); // renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); Linecount++; } if (JTronicHandle.Graphik_check_HF.isSelected()) { TimeSeries dataset = new TimeSeries( "Herzfrequenz [b/min] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr); for (i = 0; i < num; i++) { dataset.add(xTime[i], y3Werte[i]); } TimeSeriesCollection dataset1 = new TimeSeriesCollection(dataset); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 0); XYItemRenderer renderer = new StandardXYItemRenderer(2);//, ToolTip); renderer.setSeriesPaint(0, getColour(Linecount)); // renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); Linecount++; } if (JTronicHandle.Graphik_check_Temp.isSelected()) { TimeSeries dataset = new TimeSeries( "Temperatur [C] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr); for (i = 0; i < num; i++) { dataset.add(xTime[i], y4Werte[i]); } TimeSeriesCollection dataset1 = new TimeSeriesCollection(dataset); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 0); XYItemRenderer renderer = new StandardXYItemRenderer(2);//, ToolTip); renderer.setSeriesPaint(0, getColour(Linecount)); // renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); Linecount++; } if (JTronicHandle.Graphik_check_Steigung_p.isSelected()) { TimeSeries dataset = new TimeSeries("Steigung [%] "); for (i = 0; i < num; i++) { dataset.add(xTime[i], y5Werte[i]); } TimeSeriesCollection dataset1 = new TimeSeriesCollection(dataset); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 0); XYItemRenderer renderer = new StandardXYItemRenderer(2);//, ToolTip); renderer.setSeriesPaint(0, getColour(Linecount)); // renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); Linecount++; } if (JTronicHandle.Graphik_check_Steigung_m.isSelected()) { TimeSeries dataset = new TimeSeries( "Steigung [m/min] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr); for (i = 0; i < num; i++) { dataset.add(xTime[i], y6Werte[i]); } TimeSeriesCollection dataset1 = new TimeSeriesCollection(dataset); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 0); XYItemRenderer renderer = new StandardXYItemRenderer(2);//, ToolTip); renderer.setSeriesPaint(0, getColour(Linecount)); // renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); Linecount++; } if (JTronicHandle.Graphik_check_av_Geschw.isSelected()) { TimeSeries dataset = new TimeSeries( "av Geschw. [km/h] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr); for (i = 0; i < num; i++) { dataset.add(xTime[i], y7Werte[i]); } TimeSeriesCollection dataset1 = new TimeSeriesCollection(dataset); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 0); XYItemRenderer renderer = new StandardXYItemRenderer(2);//, ToolTip); renderer.setSeriesPaint(0, getColour(Linecount)); // renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); Linecount++; } if (JTronicHandle.Graphik_check_Cadence.isSelected()) { TimeSeries dataset = new TimeSeries( "Cadence [n/min] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr); for (i = 0; i < num; i++) { dataset.add(xTime[i], y8Werte[i]); } TimeSeriesCollection dataset1 = new TimeSeriesCollection(dataset); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 0); XYItemRenderer renderer = new StandardXYItemRenderer(2);//, ToolTip); renderer.setSeriesPaint(0, getColour(Linecount)); // renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); Linecount++; } if (JTronicHandle.Graphik_check_Schrittlnge.isSelected()) { TimeSeries dataset = new TimeSeries( "Schrittlnge [cm] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr); for (i = 0; i < num; i++) { dataset.add(xTime[i], y8bWerte[i]); } TimeSeriesCollection dataset1 = new TimeSeriesCollection(dataset); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 0); XYItemRenderer renderer = new StandardXYItemRenderer(2);//, ToolTip); renderer.setSeriesPaint(0, getColour(Linecount)); // renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); Linecount++; } if (JTronicHandle.Graphik_check_Abstand.isSelected() && single == 1 && j != 0) { TimeSeries dataset = new TimeSeries( "Streckenabstand [m] " + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr + " - " + JTronicHandle.Statistikhandle.TourData[1].Tag + "." + JTronicHandle.Statistikhandle.TourData[1].Monat + "." + JTronicHandle.Statistikhandle.TourData[1].Jahr); for (i = 0; i < num; i++) { dataset.add(xTime[i], y10Werte[i]); } TimeSeriesCollection dataset1 = new TimeSeriesCollection(dataset); ValueAxis axis3 = (ValueAxis) plot.getRangeAxis().clone(); axis3.setLabel("Abstand"); axis3.setLabelPaint(Color.BLACK); axis3.setTickLabelPaint(Color.BLACK); plot.setRangeAxis(2, axis3); plot.setRangeAxisLocation(2, AxisLocation.BOTTOM_OR_RIGHT); plot.setDataset(Linecount, dataset1); plot.mapDatasetToRangeAxis(Linecount, 2); XYItemRenderer renderer = new StandardXYItemRenderer(2);//, ToolTip); renderer.setSeriesPaint(0, getColour(Linecount)); // renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); Linecount++; } } } chart.setNotify(true); ChartPanel Panel = new ChartPanel(chart); return Panel; } catch (Exception e) { JOptionPane.showMessageDialog(null, "StartGraphik\nSchluss_Fehler: " + e, "Achtung!", JOptionPane.ERROR_MESSAGE); } return new ChartPanel(chart); }
From source file:KIDLYFactory.java
/** * Creates a scatter plot with default settings. The chart object * returned by this method uses an {@link XYPlot} instance as the plot, * with a {@link NumberAxis} for the domain axis, a {@link NumberAxis} * as the range axis, and an {@link XYLineAndShapeRenderer} as the * renderer.//from w ww. j a va2 s . c om * * @param title the chart title (<code>null</code> permitted). * @param xAxisLabel a label for the X-axis (<code>null</code> permitted). * @param yAxisLabel a label for the Y-axis (<code>null</code> permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param orientation the plot orientation (horizontal or vertical) * (<code>null</code> NOT permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A scatter plot. */ public static JFreeChart createScatterPlot(String title, String xAxisLabel, String yAxisLabel, XYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } NumberAxis xAxis = new NumberAxis(xAxisLabel); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(yAxisLabel); yAxis.setAutoRangeIncludesZero(false); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null); XYToolTipGenerator toolTipGenerator = null; if (tooltips) { toolTipGenerator = new StandardXYToolTipGenerator(); } XYURLGenerator urlGenerator = null; if (urls) { urlGenerator = new StandardXYURLGenerator(); } XYItemRenderer renderer = new XYLineAndShapeRenderer(false, true); renderer.setBaseToolTipGenerator(toolTipGenerator); renderer.setURLGenerator(urlGenerator); plot.setRenderer(renderer); plot.setOrientation(orientation); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
From source file:org.drools.planner.benchmark.core.statistic.bestscore.BestScoreProblemStatistic.java
protected void writeGraphStatistic() { NumberAxis xAxis = new NumberAxis("Time spend"); xAxis.setNumberFormatOverride(new MillisecondsSpendNumberFormat()); NumberAxis yAxis = new NumberAxis("Score"); yAxis.setAutoRangeIncludesZero(false); XYPlot plot = new XYPlot(null, xAxis, yAxis, null); int seriesIndex = 0; for (SingleBenchmark singleBenchmark : problemBenchmark.getSingleBenchmarkList()) { BestScoreSingleStatistic singleStatistic = (BestScoreSingleStatistic) singleBenchmark .getSingleStatistic(problemStatisticType); XYSeries series = new XYSeries(singleBenchmark.getSolverBenchmark().getName()); for (BestScoreSingleStatisticPoint point : singleStatistic.getPointList()) { long timeMillisSpend = point.getTimeMillisSpend(); Score score = point.getScore(); Double scoreGraphValue = scoreDefinition.translateScoreToGraphValue(score); if (scoreGraphValue != null) { series.add(timeMillisSpend, scoreGraphValue); }/*from w w w . j a va2s . co m*/ } XYSeriesCollection seriesCollection = new XYSeriesCollection(); seriesCollection.addSeries(series); plot.setDataset(seriesIndex, seriesCollection); XYItemRenderer renderer; // No direct lines between 2 points renderer = new XYStepRenderer(); if (singleStatistic.getPointList().size() <= 1) { // Workaround for https://sourceforge.net/tracker/?func=detail&aid=3387330&group_id=15494&atid=115494 renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES); } plot.setRenderer(seriesIndex, renderer); seriesIndex++; } plot.setOrientation(PlotOrientation.VERTICAL); JFreeChart chart = new JFreeChart(problemBenchmark.getName() + " best score statistic", JFreeChart.DEFAULT_TITLE_FONT, plot, true); BufferedImage chartImage = chart.createBufferedImage(1024, 768); graphStatisticFile = new File(problemBenchmark.getProblemReportDirectory(), problemBenchmark.getName() + "BestScoreStatistic.png"); OutputStream out = null; try { out = new FileOutputStream(graphStatisticFile); ImageIO.write(chartImage, "png", out); } catch (IOException e) { throw new IllegalArgumentException("Problem writing graphStatisticFile: " + graphStatisticFile, e); } finally { IOUtils.closeQuietly(out); } }