List of usage examples for org.jfree.chart.plot XYPlot setDomainAxis
public void setDomainAxis(ValueAxis axis)
From source file:ec.ui.view.StabilityView.java
private void configureAxis(XYPlot plot) { int nb = graphs_.size(); List<String> names = new ArrayList<>(); for (Map.Entry<Bornes, Graphs> entry : graphs_.entrySet()) { names.add(entry.getValue().label_); }//from w w w .j a va 2 s .c o m NumberAxis xAxis = new NumberAxis(); xAxis.setTickLabelPaint(Color.GRAY); xAxis.setTickUnit(new StabilityTickUnit(names)); xAxis.setRange(-0.5, nb - 0.5); plot.setDomainAxis(xAxis); plot.setDomainGridlinesVisible(false); NumberAxis yaxis = new NumberAxis(); rescaleAxis(yaxis); plot.setRangeAxis(yaxis); for (int i = 0; i < nb; i++) { ValueMarker marker = new ValueMarker(i + 0.5); marker.setStroke(MARKER_STROKE); marker.setPaint(MARKER_PAINT); marker.setAlpha(MARKER_ALPHA); plot.addDomainMarker(marker); } }
From source file:com.intel.stl.ui.common.view.ComponentFactory.java
public static JFreeChart createXYAreaSparkline(XYDataset dataset) { JFreeChart jfreechart = ChartFactory.createXYAreaChart(null, null, null, dataset, PlotOrientation.VERTICAL, false, false, false);/* w w w .j av a 2 s . com*/ XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setDomainPannable(true); xyplot.setBackgroundPaint(null); xyplot.setOutlinePaint(null); xyplot.setForegroundAlpha(0.8F); xyplot.setDomainGridlinesVisible(false); xyplot.setDomainCrosshairVisible(false); xyplot.setRangeGridlinesVisible(false); xyplot.setRangeCrosshairVisible(false); DateAxis dateaxis = new DateAxis(""); dateaxis.setTickLabelsVisible(false); dateaxis.setTickMarksVisible(false); dateaxis.setAxisLineVisible(false); dateaxis.setNegativeArrowVisible(false); dateaxis.setPositiveArrowVisible(false); dateaxis.setVisible(false); xyplot.setDomainAxis(dateaxis); ValueAxis rangeAxis = xyplot.getRangeAxis(); rangeAxis.setTickLabelsVisible(false); rangeAxis.setTickMarksVisible(false); rangeAxis.setAxisLineVisible(false); rangeAxis.setNegativeArrowVisible(false); rangeAxis.setPositiveArrowVisible(false); rangeAxis.setVisible(false); XYItemRenderer xyitemrenderer = xyplot.getRenderer(); xyitemrenderer.setSeriesPaint(1, UIConstants.INTEL_DARK_GRAY); xyitemrenderer.setSeriesPaint(0, NodeTypeViz.SWITCH.getColor()); return jfreechart; }
From source file:com.sun.japex.ChartGenerator.java
private JFreeChart generateDriverScatterChart() { try {//w ww .j a va2 s .c o m DefaultTableXYDataset xyDataset = new DefaultTableXYDataset(); // Generate charts for (DriverImpl di : _testSuite.getDriverInfoList()) { if (!di.hasParam(Constants.RESULT_ARIT_MEAN_X)) { System.out.println("Error: Driver '" + di.getName() + "' does not define" + " any values for the X axis needed to generate a scatter chart"); System.exit(1); } XYSeries xySeries = new XYSeries(di.getName(), true, false); xySeries.add(di.getDoubleParamNoNaN(Constants.RESULT_ARIT_MEAN_X), di.getDoubleParamNoNaN(Constants.RESULT_ARIT_MEAN)); xySeries.add(di.getDoubleParamNoNaN(Constants.RESULT_GEOM_MEAN_X), di.getDoubleParamNoNaN(Constants.RESULT_GEOM_MEAN)); xySeries.add(di.getDoubleParamNoNaN(Constants.RESULT_HARM_MEAN_X), di.getDoubleParamNoNaN(Constants.RESULT_HARM_MEAN)); xyDataset.addSeries(xySeries); } String resultUnit = _testSuite.getParam(Constants.RESULT_UNIT); String resultUnitX = _testSuite.getParam(Constants.RESULT_UNIT_X); JFreeChart chart = ChartFactory.createScatterPlot("Result Summary", resultUnitX, resultUnit, xyDataset, PlotOrientation.VERTICAL, true, true, false); // Set log scale depending on japex.resultAxis[_X] XYPlot plot = chart.getXYPlot(); if (_testSuite.getParam(Constants.RESULT_AXIS_X).equalsIgnoreCase("logarithmic")) { LogarithmicAxis logAxisX = new LogarithmicAxis(resultUnitX); logAxisX.setAllowNegativesFlag(true); plot.setDomainAxis(logAxisX); } if (_testSuite.getParam(Constants.RESULT_AXIS).equalsIgnoreCase("logarithmic")) { LogarithmicAxis logAxis = new LogarithmicAxis(resultUnit); logAxis.setAllowNegativesFlag(true); plot.setRangeAxis(logAxis); } return chart; } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new RuntimeException(e); } }
From source file:com.sun.japex.ChartGenerator.java
private int generateTestCaseScatterCharts(String baseName, String extension) { int nOfFiles = 0; List<DriverImpl> driverInfoList = _testSuite.getDriverInfoList(); try {//from w w w . j av a2 s . c o m // Get number of tests from first driver final int nOfTests = driverInfoList.get(0).getAggregateTestCases().size(); DefaultTableXYDataset xyDataset = new DefaultTableXYDataset(); // Generate charts for (DriverImpl di : driverInfoList) { XYSeries xySeries = new XYSeries(di.getName(), true, false); for (int j = 0; j < nOfTests; j++) { TestCaseImpl tc = (TestCaseImpl) di.getAggregateTestCases().get(j); try { xySeries.add(tc.getDoubleParamNoNaN(Constants.RESULT_VALUE_X), tc.getDoubleParamNoNaN(Constants.RESULT_VALUE)); } catch (SeriesException e) { // Ignore duplicate x-valued points } } xyDataset.addSeries(xySeries); } String resultUnit = _testSuite.getParam(Constants.RESULT_UNIT); String resultUnitX = _testSuite.getParam(Constants.RESULT_UNIT_X); JFreeChart chart = ChartFactory.createScatterPlot("Results Per Test", resultUnitX, resultUnit, xyDataset, PlotOrientation.VERTICAL, true, true, false); // Set log scale depending on japex.resultAxis[_X] XYPlot plot = chart.getXYPlot(); if (_testSuite.getParam(Constants.RESULT_AXIS_X).equalsIgnoreCase("logarithmic")) { LogarithmicAxis logAxisX = new LogarithmicAxis(resultUnitX); logAxisX.setAllowNegativesFlag(true); plot.setDomainAxis(logAxisX); } if (_testSuite.getParam(Constants.RESULT_AXIS).equalsIgnoreCase("logarithmic")) { LogarithmicAxis logAxis = new LogarithmicAxis(resultUnit); logAxis.setAllowNegativesFlag(true); plot.setRangeAxis(logAxis); } chart.setAntiAlias(true); ChartUtilities.saveChartAsJPEG(new File(baseName + Integer.toString(nOfFiles) + extension), chart, _chartWidth, _chartHeight); nOfFiles++; } catch (RuntimeException e) { throw e; } catch (Exception e) { e.printStackTrace(); } return nOfFiles; }
From source file:org.jfree.eastwood.ChartEngine.java
/** * Creates a scatter chart.//from ww w . j av a2 s . com * * @return A scatter chart. */ private static JFreeChart createScatterChart() { JFreeChart chart = ChartFactory.createScatterPlot(null, null, null, null, PlotOrientation.VERTICAL, false, false, false); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(null); plot.setOutlinePaint(null); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBasePaint(new Color(0x76A4FB)); renderer.setAutoPopulateSeriesPaint(false); GValueAxis xAxis = new GValueAxis(); xAxis.setTickLabelsVisible(false); xAxis.setTickMarksVisible(false); plot.setDomainAxis(xAxis); GValueAxis yAxis = new GValueAxis(); yAxis.setTickLabelsVisible(false); yAxis.setTickMarksVisible(false); plot.setRangeAxis(yAxis); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); return chart; }
From source file:de.tud.kom.p2psim.impl.skynet.visualization.MetricsPlot.java
private void updateChartPanel(String plotTitle) { XYPlot plot = (XYPlot) chart.getPlot(); YIntervalSeriesCollection dataset = new YIntervalSeriesCollection();// (YIntervalSeriesCollection) // plot.getDataset() String[] names = displayedSeries.keySet().toArray(new String[displayedSeries.keySet().size()]); Arrays.sort(names, null);/* ww w . j a v a 2 s. c o m*/ if (!autoScrolling && displayedSeries.get(names[0]).getDataSeries().getItemCount() == displayedSeries .get(names[0]).getDataSeries().getMaximumItemCount()) { autoScrolling = true; DateAxis domain = (DateAxis) plot.getDomainAxis(); domain.setAutoRange(true); plot.setDomainAxis(domain); } for (int i = 0; i < names.length; i++) { if (names[i].startsWith("Min_")) { if (showMin) dataset.addSeries(displayedSeries.get(names[i]).getDataSeries()); } else if (names[i].startsWith("Max_")) { if (showMax) dataset.addSeries(displayedSeries.get(names[i]).getDataSeries()); } else { dataset.addSeries(displayedSeries.get(names[i]).getDataSeries()); } } plot.setDataset(dataset); plot.setRenderer(configureRendererForDataSet(plot.getRenderer(), dataset)); plotPanel.setChart(chart); setSizeOfComponent(plotPanel, new Dimension(plotWidth, plotHeight)); container.add(plotPanel, BorderLayout.CENTER); setSizeOfComponent(container, new Dimension(plotWidth, plotHeight + boxOffset)); }
From source file:daylightchart.daylightchart.chart.DaylightChart.java
@SuppressWarnings("deprecation") private void createMonthsAxis(final XYPlot plot) { final DateAxis axis = new DateAxis(); axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setLowerMargin(0.0f);/*from w w w. j a va 2s . c o m*/ axis.setUpperMargin(0.0f); axis.setTickLabelFont(ChartConfiguration.chartFont.deriveFont(Font.PLAIN, 12)); axis.setDateFormatOverride(ChartConfiguration.monthsFormat); axis.setVerticalTickLabels(true); axis.setTickUnit(new DateTickUnit(DateTickUnit.MONTH, 1), true, true); // Fix the axis range for all the months in the year final int dateYear = riseSetData.getYear() - 1900; axis.setRange(new Date(dateYear, 0, 1), new Date(dateYear, 11, 31)); // plot.setDomainAxis(axis); }
From source file:org.peerfact.impl.service.aggregation.skyeye.visualization.MetricsPlot.java
private void updateChartPanel(String plotTitle) { XYPlot plot = (XYPlot) chart.getPlot(); YIntervalSeriesCollection dataset = new YIntervalSeriesCollection();// (YIntervalSeriesCollection) // plot.getDataset() String[] names = displayedSeries.keySet().toArray(new String[displayedSeries.keySet().size()]); Arrays.sort(names, null);/* ww w. j a v a 2 s. c o m*/ if (!autoScrolling && displayedSeries.get(names[0]).getDataSeries().getItemCount() == displayedSeries .get(names[0]).getDataSeries().getMaximumItemCount()) { autoScrolling = true; DateAxis domain = (DateAxis) plot.getDomainAxis(); domain.setAutoRange(true); plot.setDomainAxis(domain); } for (int i = 0; i < names.length; i++) { if (names[i].startsWith("Min_")) { if (showMin) { dataset.addSeries(displayedSeries.get(names[i]).getDataSeries()); } } else if (names[i].startsWith("Max_")) { if (showMax) { dataset.addSeries(displayedSeries.get(names[i]).getDataSeries()); } } else { dataset.addSeries(displayedSeries.get(names[i]).getDataSeries()); } } plot.setDataset(dataset); plot.setRenderer(configureRendererForDataSet(plot.getRenderer(), dataset)); plotPanel.setChart(chart); setSizeOfComponent(plotPanel, new Dimension(plotWidth, plotHeight)); container.add(plotPanel, BorderLayout.CENTER); setSizeOfComponent(container, new Dimension(plotWidth, plotHeight + boxOffset)); }
From source file:SciTK.PlotXYStep.java
/** Initialization routine (common to both constructors) */ private void init(String x_label, String y_label, String window_title, double x_min, double x_max) { chart = ChartFactory.createXYStepChart("", x_label, y_label, data, PlotOrientation.VERTICAL, false, true, false);// ww w. j a va 2 s . c o m chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); // the plot itself // Use a step renderer for this type of chart: XYStepRenderer renderer = new XYStepRenderer(); renderer.setBaseStroke(new BasicStroke(2.0f)); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); renderer.setDefaultEntityRadius(6); renderer.setLegendItemLabelGenerator(new MultipleXYSeriesLabelGenerator()); // need to tell the plot to use this renderer plot.setRenderer(renderer); // create new axis with range set by dataset max/min: NumberAxis domainAxis = new NumberAxis(x_label); domainAxis.setRange(x_min, x_max); plot.setDomainAxis(domainAxis); // for some reason default is white, change it to black: setGridlineColor(Color.BLACK); super.window_title = window_title; super.initUI(); }
From source file:pipeline.parameter_cell_views.FloatRangeSlider.java
private void updatePlot() { final XYPlot plot = chart.getXYPlot(); final NumberAxis domainAxis = new NumberAxis(null); domainAxis.setAutoRange(false);//from ww w. j a v a 2 s.co m domainAxis.setTickLabelFont(new Font("Times", 0, 20)); domainAxis.setLowerBound(minimum); domainAxis.setUpperBound(maximum); plot.setDomainAxis(domainAxis); if (selectionRange != null) { // if we're displaying a histogram selectionRange.setStartValue(currentValue0); selectionRange.setEndValue(currentValue1); } }