List of usage examples for org.jfree.chart.plot XYPlot setAxisOffset
public void setAxisOffset(RectangleInsets offset)
From source file:msi.gama.outputs.layers.charts.ChartJFreeChartOutputScatter.java
@Override public void initChart(final IScope scope, final String chartname) { super.initChart(scope, chartname); final XYPlot pp = (XYPlot) chart.getPlot(); pp.setDomainGridlinePaint(axesColor); pp.setRangeGridlinePaint(axesColor); pp.setDomainCrosshairPaint(axesColor); pp.setRangeCrosshairPaint(axesColor); pp.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); pp.setDomainCrosshairVisible(false); pp.setRangeCrosshairVisible(false);/* ww w .j av a2 s.com*/ pp.getDomainAxis().setAxisLinePaint(axesColor); pp.getDomainAxis().setTickLabelFont(getTickFont()); pp.getDomainAxis().setLabelFont(getLabelFont()); if (textColor != null) { pp.getDomainAxis().setLabelPaint(textColor); pp.getDomainAxis().setTickLabelPaint(textColor); } NumberAxis axis = (NumberAxis) pp.getRangeAxis(); axis = formatYAxis(scope, axis); pp.setRangeAxis(axis); if (ytickunit > 0) { ((NumberAxis) pp.getRangeAxis()).setTickUnit(new NumberTickUnit(ytickunit)); pp.setRangeGridlinesVisible(true); } else pp.setRangeGridlinesVisible(GamaPreferences.Displays.CHART_GRIDLINES.getValue()); // resetAutorange(scope); if (getType() == ChartOutput.SERIES_CHART) { if (xlabel == null) xlabel = "time"; } if (getType() == ChartOutput.XY_CHART) { } if (getType() == ChartOutput.SCATTER_CHART) { } if (!this.getXTickValueVisible(scope)) { pp.getDomainAxis().setTickMarksVisible(false); pp.getDomainAxis().setTickLabelsVisible(false); } }
From source file:org.esa.beam.visat.toolviews.stat.ScatterPlotPanel.java
private void createUI() { final XYPlot plot = getPlot(); plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5)); plot.setNoDataMessage(NO_DATA_MESSAGE); plot.setDataset(CONFIDENCE_DSINDEX, acceptableDeviationDataset); plot.setDataset(REGRESSION_DSINDEX, regressionDataset); plot.setDataset(SCATTERPOINTS_DSINDEX, scatterpointsDataset); plot.addAnnotation(r2Annotation); final DeviationRenderer identityRenderer = new DeviationRenderer(true, false); identityRenderer.setSeriesPaint(0, StatisticChartStyling.SAMPLE_DATA_PAINT); identityRenderer.setSeriesFillPaint(0, StatisticChartStyling.SAMPLE_DATA_FILL_PAINT); plot.setRenderer(CONFIDENCE_DSINDEX, identityRenderer); final DeviationRenderer regressionRenderer = new DeviationRenderer(true, false); regressionRenderer.setSeriesPaint(0, StatisticChartStyling.REGRESSION_DATA_PAINT); regressionRenderer.setSeriesFillPaint(0, StatisticChartStyling.REGRESSION_DATA_FILL_PAINT); plot.setRenderer(REGRESSION_DSINDEX, regressionRenderer); final XYErrorRenderer scatterPointsRenderer = new XYErrorRenderer(); scatterPointsRenderer.setDrawXError(true); scatterPointsRenderer.setErrorStroke(new BasicStroke(1)); scatterPointsRenderer.setErrorPaint(StatisticChartStyling.CORRELATIVE_POINT_OUTLINE_PAINT); scatterPointsRenderer.setSeriesShape(0, StatisticChartStyling.CORRELATIVE_POINT_SHAPE); scatterPointsRenderer.setSeriesOutlinePaint(0, StatisticChartStyling.CORRELATIVE_POINT_OUTLINE_PAINT); scatterPointsRenderer.setSeriesFillPaint(0, StatisticChartStyling.CORRELATIVE_POINT_FILL_PAINT); scatterPointsRenderer.setSeriesLinesVisible(0, false); scatterPointsRenderer.setSeriesShapesVisible(0, true); scatterPointsRenderer.setSeriesOutlineStroke(0, new BasicStroke(1.0f)); scatterPointsRenderer.setSeriesToolTipGenerator(0, new XYToolTipGenerator() { @Override/*from w ww .jav a2 s.co m*/ public String generateToolTip(XYDataset dataset, int series, int item) { final XYIntervalSeriesCollection collection = (XYIntervalSeriesCollection) dataset; final Comparable key = collection.getSeriesKey(series); final double xValue = collection.getXValue(series, item); final double endYValue = collection.getEndYValue(series, item); final double yValue = collection.getYValue(series, item); return String.format("%s: mean = %6.2f, sigma = %6.2f | %s: value = %6.2f", getRasterName(), yValue, endYValue - yValue, key, xValue); } }); plot.setRenderer(SCATTERPOINTS_DSINDEX, scatterPointsRenderer); final boolean autoRangeIncludesZero = false; final boolean xLog = scatterPlotModel.xAxisLogScaled; final boolean yLog = scatterPlotModel.yAxisLogScaled; plot.setDomainAxis( StatisticChartStyling.updateScalingOfAxis(xLog, plot.getDomainAxis(), autoRangeIncludesZero)); plot.setRangeAxis( StatisticChartStyling.updateScalingOfAxis(yLog, plot.getRangeAxis(), autoRangeIncludesZero)); createUI(createChartPanel(chart), createInputParameterPanel(), bindingContext); plot.getDomainAxis().addChangeListener(domainAxisChangeListener); scatterPlotDisplay.setMouseWheelEnabled(true); scatterPlotDisplay.setMouseZoomable(true); }
From source file:speedbagalg.OscopeView.java
/** * Creates new form OscopeView/*from w ww . ja v a 2 s. c om*/ */ /* public OscopeView(String fileName) { this.fileName = fileName; initComponents(); updateThread = new RunnableMember2(this, "updateGUI"); ChartFactory.setChartTheme(new StandardChartTheme("JFree/Shadow", true)); // create a dataset... int maxAge = 2400; this.xData = new TimeSeries("X axis"); this.xData.setMaximumItemAge(maxAge); this.yData = new TimeSeries("Y axis"); this.yData.setMaximumItemAge(maxAge); this.zData = new TimeSeries("Z axis"); this.zData.setMaximumItemAge(maxAge); this.averageData = new TimeSeries("Avg. Data"); this.averageData.setMaximumItemAge(maxAge); //this.windSpeedSeries = new TimeSeries("Wind Speed"); //this.windSpeedSeries.setMaximumItemAge(maxAge); //this.rainSeries = new TimeSeries("Rain 24hrs"); //this.rainSeries.setMaximumItemAge(maxAge); final TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(xData); dataset.addSeries(yData); dataset.addSeries(zData); dataset.addSeries(averageData); //dataset.addSeries(windSpeedSeries); //dataset.addSeries(rainSeries); final JFreeChart chart = ChartFactory.createTimeSeriesChart( "Accel Data", "Time", "Value", dataset, true, true, false); final XYPlot plot = chart.getXYPlot(); ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); axis = plot.getRangeAxis(); axis.setRange(-1000.0, 10000.0); chart.setBackgroundPaint(Color.white); //XYPlot plot = (XYPlot) chart.getPlot(); 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); // create and display a frame... thePanel = new ChartPanel(chart); Dimension d = new Dimension(200, 100); thePanel.setSize(d); thePanel.setPreferredSize(d); BorderLayout layout = new BorderLayout(); jPanelOscope.setLayout(layout); jPanelOscope.add(thePanel, BorderLayout.CENTER); plotXCheckBox.setSelected(plotX); plotYCheckBox.setSelected(plotY); plotZCheckBox.setSelected(plotZ); } */ public OscopeView(String fileName) { this.fileName = fileName; initComponents(); updateThread = new RunnableMember2(this, "updateGUI"); ChartFactory.setChartTheme(new StandardChartTheme("JFree/Shadow", true)); // create a dataset... this.xData = new XYSeries("Min"); //this.xData.setMaximumItemAge(maxAge); this.yData = new XYSeries("Peak"); //this.yData.setMaximumItemAge(maxAge); this.zData = new XYSeries("Z axis"); //this.zData.setMaximumItemAge(maxAge); this.averageData = new XYSeries("Avg. Data"); //this.averageData.setMaximumItemAge(maxAge); //this.windSpeedSeries = new TimeSeries("Wind Speed"); //this.windSpeedSeries.setMaximumItemAge(maxAge); //this.rainSeries = new TimeSeries("Rain 24hrs"); //this.rainSeries.setMaximumItemAge(maxAge); final XYSeriesCollection dataset = new XYSeriesCollection(); //SlidingCategoryDataset dataset = new SlidingCategoryDataset(0, 10); dataset.addSeries(xData); dataset.addSeries(yData); dataset.addSeries(zData); dataset.addSeries(averageData); //dataset.addSeries(windSpeedSeries); //dataset.addSeries(rainSeries); chart = ChartFactory.createXYLineChart("Accel Data", "Time", "Value", dataset, PlotOrientation.VERTICAL, true, true, false); final XYPlot plot = chart.getXYPlot(); ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(false); axis.setRange(minStart, maxDomain); axis = plot.getRangeAxis(); axis.setRange(vMin, vMax); chart.setBackgroundPaint(Color.white); //XYPlot plot = (XYPlot) chart.getPlot(); 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); // create and display a frame... thePanel = new ChartPanel(chart); Dimension d = new Dimension(200, 100); thePanel.setSize(d); thePanel.setPreferredSize(d); BorderLayout layout = new BorderLayout(); jPanelOscope.setLayout(layout); jPanelOscope.add(thePanel, BorderLayout.CENTER); plotXCheckBox.setSelected(plotX); plotYCheckBox.setSelected(plotY); plotZCheckBox.setSelected(plotZ); vMaxSpinner.setValue(vMax); }
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);//from w w w . j a v a 2 s. co m 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 StartHistoHf(JCicloTronic JTronicHandle) { boolean Summenhisto; int von = 0;//from w ww .j a v a 2 s . com 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("", "Herzfrequenz [p/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; } //einzelne Tour oder alle Touren von = Integer.parseInt(JTronicHandle.Properties.getProperty("HistovonHf", "100")); bis = Integer.parseInt(JTronicHandle.Properties.getProperty("HistobisHf", "200")); Gruppen = Integer.parseInt(JTronicHandle.Properties.getProperty("HistostepHf", "10")); Anzahl = (JTronicHandle.Auswahl_Histogramm.getItemCount() - 2) * single + 1; //komische Mathe; //wenn nur eine Tour ausgewhlt ist single = 0 und damit Anzahl =1 // sonst single gleich 1 und die Anzahl ist ItemCont - 1 for (j = 0; j < Anzahl; j++) { if (single == 1) { selected = j + 1; // single = 1 => Summe ist ausgewhlt und selected muss ein hher gesetz werden } 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++) { //hier wird nun ber alle Daten gezhlt Buffer = (double) JTronicHandle.Statistikhandle.TourData[selected].Hf_gesZeit[i]; //aktueller Wert zwischengespeichert if (Buffer >= von && Buffer <= bis) { Bufferarray.add(Buffer); //wenn im ges. Intervall dann in das Bufferarray } } } else { //Summenhist ist ausgewhlt for (i = 0; i < j + 1; i++) { //schlechte Schleifensteuerung i=1;i<j htte es auch getan create_Start_Stop(JTronicHandle, i + 1); for (m = start; m < stop; m++) { // Schleife ber alle Datenpunkte Buffer = (double) JTronicHandle.Statistikhandle.TourData[i + 1].Hf_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 histoHF = new HistogramDataset(); histoHF.addSeries( "" + JTronicHandle.Statistikhandle.TourData[selected].Tag + "." + JTronicHandle.Statistikhandle.TourData[selected].Monat + "." + JTronicHandle.Statistikhandle.TourData[selected].Jahr, DummyData, Gruppen, (double) von, (double) bis); histoHF.setType(HistogramType.RELATIVE_FREQUENCY); plot.setDataset(Linecount, histoHF); plot.mapDatasetToRangeAxis(Linecount, 0); XYBarRenderer renderer = new XYBarRenderer(); renderer.setDrawBarOutline(true); // renderer.setShadowVisible(false); renderer.setSeriesPaint(0, getColour(Linecount, (int) 255 / Anzahl)); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(Linecount, renderer); } Linecount++; } if (Summenhisto) { HistogramDataset histoHF = new HistogramDataset(); histoHF.addSeries("Summenhistogram", DummyData, Gruppen, (double) von, (double) bis); histoHF.setType(HistogramType.RELATIVE_FREQUENCY); plot.setDataset(0, histoHF); 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 StartHistoSp(JCicloTronic JTronicHandle) { boolean Summenhisto; int von = 0;//from w w w.java 2s . co m 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 StartHistoSchrittlnge(JCicloTronic JTronicHandle) { boolean Summenhisto; int von = 0;/*w ww . j a v a 2s. c o m*/ 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 StartHistoHm(JCicloTronic JTronicHandle) { boolean Summenhisto; int von = 0;//from ww w . j a v a 2 s . com 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 StartHistoCd(JCicloTronic JTronicHandle) { boolean Summenhisto; int von = 0;//from w w w .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("", "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; }
From source file:de.fau.amos.ChartRenderer.java
/** * Creates Chart with TimeLine (JFreeChart object) from TimeSeriesCollection. Is used when granularity is set to hours. * Adjusts display of the chart, not the values itself. * /*from www. j a va2 s .com*/ * @param collection TimeSeriesCollection that should be used as basis of chart. * @param timeGranularity Selected granularity. Value is similar to granularity contained in TimeSeriesCollection "collection". * @param time first element of time that is displayed. Is used for caption text and axis text. * @param unit Unit of displayed values (kWh or kWh/TNF). * @return Returns finished JFreeChart object. */ private JFreeChart createTimeLineChart(TimeSeriesCollection collection, String timeGranularity, String time, String unit) { // Modification of X-Axis Label int day = Integer.parseInt(time.substring(8, 10)); int month = Integer.parseInt(time.substring(5, 7)); int year = Integer.parseInt(time.substring(0, 4)); //get Weekday Calendar c = Calendar.getInstance(); c.set(year, month - 1, day, 0, 0); int weekDay = c.get(Calendar.DAY_OF_WEEK); String dayString = new DateFormatSymbols(Locale.US).getWeekdays()[weekDay] + ", " + day + ". "; String monthString = new DateFormatSymbols(Locale.US).getMonths()[month - 1]; String xAxisLabel = "" + dayString + monthString + " " + time.substring(0, 4); //Creation of the lineChart JFreeChart lineChart = ChartFactory.createTimeSeriesChart("Line Chart", // title xAxisLabel, // x-axis label // "Energy Consumption "+("1".equals(unit)?"[kWh]":("2".equals(unit)?"[kWh/TNF]":("3".equals(unit)?"[TNF]":""))), // y-axis label ("1".equals(unit) ? "Energy Consumption [kWh]" : ("2".equals(unit) ? "Energy Consumption [kWh/TNF]" : ("3".equals(unit) ? "Produced Pieces [TNF]" : ""))), collection, // data true, // create legend? false, // generate tooltips? false // generate URLs? ); //graphical modifications for LineChart lineChart.setBackgroundPaint(Color.white); XYPlot plot = lineChart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(0, 0, 0, 0)); return lineChart; }