List of usage examples for org.jfree.chart.plot XYPlot setRangeAxisLocation
public void setRangeAxisLocation(AxisLocation location)
From source file:wsattacker.plugin.intelligentdos.ui.helper.ChartHelper.java
public static JFreeChart createOverlaidChart(SuccessfulAttack sa) { // create subplot 1... final XYSeries data1 = createDatasetResponseTime(RequestType.UNTAMPERED, sa.getUntamperedMetrics()); final XYSeries data2 = createDatasetResponseTime(RequestType.TAMPERED, sa.getTamperedMetrics()); final XYSeries data3 = createDatasetResponseTime(RequestType.TESTPROBES, sa.getTestProbes()); final XYSeriesCollection collection = new XYSeriesCollection(); collection.addSeries(data1);//from w ww. ja v a 2s. c o m collection.addSeries(data2); collection.addSeries(data3); final XYItemRenderer renderer = new StandardXYItemRenderer(); final NumberAxis rangeAxis1 = new NumberAxis("duration in ms"); final XYPlot plot = new XYPlot(collection, new NumberAxis(""), rangeAxis1, renderer); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); renderer.setSeriesPaint(0, Color.GREEN); renderer.setSeriesPaint(1, Color.RED); renderer.setSeriesPaint(2, Color.BLUE); // return a new chart containing the overlaid plot... return new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true); }
From source file:de.cebitec.readXplorer.plotting.CreatePlots.java
private synchronized static JFreeChart createCombinedChart(XYSeriesCollection normal, XYSeriesCollection posInf, XYSeriesCollection negInf, String xName, String yName, XYToolTipGenerator toolTip) { final NumberAxis domainAxis = new NumberAxis(xName); // create subplot 1... final XYDataset data1 = normal; final XYItemRenderer renderer1 = new XYShapeRenderer(); renderer1.setBaseToolTipGenerator(toolTip); final NumberAxis rangeAxis1 = new NumberAxis(yName); final XYPlot subplot1 = new XYPlot(data1, domainAxis, rangeAxis1, renderer1); subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); // create subplot 2... final XYDataset data2 = negInf; final XYItemRenderer renderer2 = new XYShapeRenderer(); renderer2.setBaseToolTipGenerator(toolTip); final NumberAxis rangeAxis2 = new NumberAxis() { @Override/*ww w. jav a 2 s . c o m*/ public List refreshTicks(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) { List myTicks = new ArrayList(); myTicks.add(new NumberTick(0, "-Inf", TextAnchor.CENTER_RIGHT, TextAnchor.CENTER_RIGHT, 0.0)); return myTicks; } }; rangeAxis2.setAutoRangeIncludesZero(false); final XYPlot subplot2 = new XYPlot(data2, domainAxis, rangeAxis2, renderer2); subplot2.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); // create subplot 3... final XYDataset data3 = posInf; final XYItemRenderer renderer3 = new XYShapeRenderer(); renderer3.setBaseToolTipGenerator(toolTip); final NumberAxis rangeAxis3 = new NumberAxis() { @Override public List refreshTicks(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) { List myTicks = new ArrayList(); myTicks.add(new NumberTick(0, "Inf", TextAnchor.CENTER_RIGHT, TextAnchor.CENTER_RIGHT, 0.0)); return myTicks; } }; rangeAxis3.setAutoRangeIncludesZero(false); final XYPlot subplot3 = new XYPlot(data3, domainAxis, rangeAxis3, renderer3); subplot2.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); // parent plot... final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(domainAxis); plot.setGap(0); // add the subplots... plot.add(subplot3, 1); plot.add(subplot1, 10); plot.add(subplot2, 1); plot.setOrientation(PlotOrientation.VERTICAL); // return a new chart containing the overlaid plot... return new JFreeChart(plot); }
From source file:org.codehaus.mojo.chronos.chart.SummaryThroughputChartSource.java
private XYPlot createThreadCountPlot(ResourceBundle bundle, ReportConfig config) { TimeSeriesCollection dataset2 = createThreadCountdataset(bundle, config); String label = bundle.getString("chronos.label.threadcount.y"); XYPlot threadCountPlot = ChartUtil.newPlot(dataset2, label, false); threadCountPlot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); threadCountPlot.getRenderer().setSeriesPaint(0, Color.GRAY); return threadCountPlot; }
From source file:sernet.gs.ui.rcp.main.bsi.views.chart.RealisierungLineChart.java
private JFreeChart createProgressChart(Object dataset) { final double plotGap = 10.0; final int axisUpperBoundPadding = 50; final int labelFontSize = 10; XYDataset data1 = (XYDataset) dataset; XYItemRenderer renderer1 = new StandardXYItemRenderer(); NumberAxis rangeAxis1 = new NumberAxis(Messages.RealisierungLineChart_1); XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1); subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new DateAxis(Messages.RealisierungLineChart_2)); plot.setGap(plotGap);/*from w w w . j a va 2s . com*/ plot.add(subplot1, 1); plot.setOrientation(PlotOrientation.VERTICAL); CountMassnahmen command = new CountMassnahmen(); try { command = ServiceFactory.lookupCommandService().executeCommand(command); } catch (CommandException e) { ExceptionUtil.log(e, Messages.RealisierungLineChart_3); } int totalNum = command.getTotalCount(); NumberAxis axis = (NumberAxis) subplot1.getRangeAxis(); axis.setUpperBound(totalNum + axisUpperBoundPadding); ValueMarker bst = new ValueMarker(totalNum); bst.setPaint(Color.GREEN); bst.setLabel(Messages.RealisierungLineChart_4); bst.setLabelAnchor(RectangleAnchor.LEFT); bst.setLabelFont(new Font("SansSerif", Font.ITALIC + Font.BOLD, labelFontSize)); //$NON-NLS-1$ bst.setLabelTextAnchor(TextAnchor.CENTER_LEFT); subplot1.addRangeMarker(bst, Layer.BACKGROUND); // return a new chart containing the overlaid plot... JFreeChart chart = new JFreeChart(Messages.RealisierungLineChart_6, JFreeChart.DEFAULT_TITLE_FONT, plot, true); chart.setBackgroundPaint(Color.white); return chart; }
From source file:br.prof.salesfilho.oci.image.GraphicBuilder.java
public void createCombinedChart(Map<String, double[]> mapSeries, String legendTitle) { XYSeriesCollection xds;//from w w w . j av a2 s .c o m final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis(legendTitle)); plot.setGap(10.0); for (Map.Entry<String, double[]> entrySet : mapSeries.entrySet()) { String serieName = entrySet.getKey(); double[] values = entrySet.getValue(); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); final XYSeries series = new XYSeries(serieName); for (int i = 0; i < values.length; i++) { series.add(i, Precision.round(values[i], 2)); renderer.setSeriesVisible(i, true, true); renderer.setSeriesShapesVisible(i, true); } xds = new XYSeriesCollection(); xds.addSeries(series); final NumberAxis rangeAxis = new NumberAxis(serieName); final XYPlot subplot = new XYPlot(xds, null, rangeAxis, renderer); subplot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); plot.add(subplot); } this.chart = new JFreeChart(this.title, JFreeChart.DEFAULT_TITLE_FONT, plot, true); chartPanel.setChart(chart); }
From source file:org.codehaus.mojo.chronos.chart.SummaryThroughputChartSource.java
private XYPlot createThroughputPlot(ResourceBundle bundle, ReportConfig config) { TimeSeriesCollection dataset1 = createThroughputDataset(bundle, config); XYPlot throughputPlot = ChartUtil.newPlot(dataset1, bundle.getString("chronos.label.throughput.requests"), true);/* w ww .j ava 2 s . c o m*/ throughputPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); throughputPlot.getRenderer().setSeriesPaint(0, Color.GREEN); throughputPlot.getRenderer().setSeriesPaint(1, Color.BLUE); throughputPlot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD); double maxAvgThroughput = samples.getMaxAverageThroughput(config.getAverageduration(), config.getResponsetimedivider()); String maxThroughputLabel = bundle.getString("chronos.label.maxaveragethroughput"); ChartUtil.addRangeMarker(throughputPlot, maxThroughputLabel, maxAvgThroughput); return throughputPlot; }
From source file:org.codehaus.mojo.chronos.chart.HistoryChartGenerator.java
public final void createGcChart(HistoricSamples samples, String dataId) throws IOException { XYPlot xyplot1 = newPlot(samples.getGcRatio(dataId), "chronos.label.gc.ratio", true); xyplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); xyplot1.getRenderer().setSeriesPaint(0, Color.GREEN); xyplot1.getRangeAxis().setStandardTickUnits(NumberAxis.createStandardTickUnits()); XYPlot xyplot2 = newPlot(samples.getKbCollectedPrSecond(dataId), "chronos.label.gc.kbpersec", true); xyplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); xyplot2.getRenderer().setSeriesPaint(0, Color.GRAY); xyplot2.getRangeAxis().setStandardTickUnits(NumberAxis.createStandardTickUnits()); String timeLabel = bundle.getString("chronos.label.gc.historytime"); DateAxis timeAxis = ChartUtil.createTimeAxis(timeLabel, new SimpleDateFormat()); XYPlot combinedPlot = ChartUtil.createCombinedPlot(timeAxis, xyplot1, xyplot2); // xyplot1.setDomainAxis( timeAxis ); // XYPlot combinedPlot = xyplot1; JFreeChart chart = new JFreeChart(bundle.getString("chronos.label.gc"), combinedPlot); renderer.renderChart("history-gc-" + dataId, chart); }
From source file:org.codehaus.mojo.chronos.chart.HistoryChartGenerator.java
public final void createThroughputChart(HistoricSamples samples, String dataId) throws IOException { XYPlot xyplot = newPlot(samples.getThroughput(dataId), "chronos.label.throughput.requests", true); xyplot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); xyplot.getRenderer().setSeriesPaint(0, Color.GREEN); String timeLabel = bundle.getString("chronos.label.throughput.historytime"); DateAxis timeAxis = ChartUtil.createTimeAxis(timeLabel, new SimpleDateFormat()); xyplot.setDomainAxis(timeAxis);//from w w w . j a v a 2s . c om JFreeChart chart = new JFreeChart(bundle.getString("chronos.label.throughput"), xyplot); renderer.renderChart("history-throughput-" + dataId, chart); }
From source file:r2d2e.solution.moduloteste.teste.GraficoD2.java
/** * Creates a combined chart./*from w w w.j av a 2 s . com*/ * * @return the combined chart. */ private JFreeChart createCombinedChart() { // create subplot 1... final XYDataset data1 = collection; final XYItemRenderer renderer1 = new StandardXYItemRenderer(); final NumberAxis rangeAxis1 = new NumberAxis("Nvel (cm)"); final XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1); subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); /* final XYTextAnnotation annotation = new XYTextAnnotation("Hello!", 50.0, 10000.0); annotation.setFont(new Font("SansSerif", Font.PLAIN, 9)); annotation.setRotationAngle(Math.PI / 4.0); subplot1.addAnnotation(annotation); */ // create subplot 2... final XYDataset data2 = collection2; final XYItemRenderer renderer2 = new StandardXYItemRenderer(); final NumberAxis rangeAxis2 = new NumberAxis("Tenso (volts)"); final XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2); subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); // create subplot 3... final XYDataset data3 = collection3; final XYItemRenderer renderer3 = new StandardXYItemRenderer(); final NumberAxis rangeAxis3 = new NumberAxis("Tenso (volts)"); final XYPlot subplot3 = new XYPlot(data3, null, rangeAxis3, renderer3); subplot3.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); // parent plot... final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Tempo")); plot.setGap(10.0); // add the subplots... plot.add(subplot1, 1); plot.add(subplot2, 1); plot.add(subplot3, 1); plot.setOrientation(PlotOrientation.VERTICAL); // return a new chart containing the overlaid plot... return new JFreeChart("Grficos", JFreeChart.DEFAULT_TITLE_FONT, plot, true); }
From source file:org.jfree.chart.demo.CombinedXYPlotDemo1.java
/** * Creates a combined chart./*from ww w . ja v a 2 s . c om*/ * * @return the combined chart. */ private JFreeChart createCombinedChart() { // create subplot 1... final XYDataset data1 = createDataset1(); final XYItemRenderer renderer1 = new StandardXYItemRenderer(); final NumberAxis rangeAxis1 = new NumberAxis("Range 1"); final XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1); subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); final XYTextAnnotation annotation = new XYTextAnnotation("Hello!", 50.0, 10000.0); annotation.setFont(new Font("SansSerif", Font.PLAIN, 9)); annotation.setRotationAngle(Math.PI / 4.0); subplot1.addAnnotation(annotation); // create subplot 2... final XYDataset data2 = createDataset2(); final XYItemRenderer renderer2 = new StandardXYItemRenderer(); final NumberAxis rangeAxis2 = new NumberAxis("Range 2"); rangeAxis2.setAutoRangeIncludesZero(false); final XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2); subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); // parent plot... final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Domain")); plot.setGap(10.0); // add the subplots... plot.add(subplot1, 1); plot.add(subplot2, 1); plot.setOrientation(PlotOrientation.VERTICAL); // return a new chart containing the overlaid plot... return new JFreeChart("CombinedDomainXYPlot Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, true); }