List of usage examples for org.jfree.chart.plot XYPlot getRangeAxis
public ValueAxis getRangeAxis()
From source file:org.jfree.chart.demo.selection.SelectionDemo3.java
private static JFreeChart createChart(XYDataset dataset, DatasetSelectionExtension<XYCursor> ext) { JFreeChart chart = ChartFactory.createScatterPlot("SelectionDemo3", "X", "Y", dataset); XYPlot plot = (XYPlot) chart.getPlot(); plot.setNoDataMessage("NO DATA"); plot.setDomainPannable(true);//from w ww. j av a 2 s.c o m plot.setRangePannable(true); plot.setDomainZeroBaselineVisible(true); plot.setRangeZeroBaselineVisible(true); plot.setDomainGridlineStroke(new BasicStroke(0.0f)); plot.setRangeGridlineStroke(new BasicStroke(0.0f)); plot.setDomainMinorGridlinesVisible(true); plot.setRangeMinorGridlinesVisible(true); //XYItemRenderer r = plot.getRenderer(); XYDotRenderer r = new XYDotRenderer(); r.setDotHeight(2); r.setDotWidth(2); r.setSeriesPaint(0, Color.blue); r.setSeriesPaint(1, Color.green); r.setSeriesPaint(2, Color.yellow); r.setSeriesPaint(3, Color.orange); plot.setRenderer(r); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setAutoRangeIncludesZero(false); domainAxis.setTickMarkInsideLength(2.0f); domainAxis.setTickMarkOutsideLength(2.0f); domainAxis.setMinorTickMarksVisible(true); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setTickMarkInsideLength(2.0f); rangeAxis.setTickMarkOutsideLength(2.0f); rangeAxis.setMinorTickMarksVisible(true); //add selection specific rendering IRSUtilities.setSelectedItemPaint(r, ext, Color.red); //register plot as selection change listener ext.addChangeListener(plot); return chart; }
From source file:com.att.aro.ui.view.diagnostictab.CreateBarPlot.java
public XYPlot drawStandardXYPlot(Shape shape, Color color, int minSignal, int maxSignal) { // Set up renderer StandardXYItemRenderer batteryRenderer = new StandardXYItemRenderer( StandardXYItemRenderer.SHAPES_AND_LINES); batteryRenderer.setAutoPopulateSeriesShape(false); batteryRenderer.setBaseShape(shape); batteryRenderer.setSeriesPaint(0, color); // Normalize the throughput axis so that it represents max value NumberAxis axis = new NumberAxis(); axis.setVisible(false);//from ww w . j ava 2 s .com axis.setAutoRange(false); axis.setRange(minSignal, maxSignal); // Create plot XYPlot barPlot = new XYPlot(null, null, axis, batteryRenderer); barPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); barPlot.getRangeAxis().setVisible(false); return barPlot; }
From source file:eu.stratosphere.addons.visualization.swt.SWTGateToolTip.java
private ChartComposite createChart(GateVisualizationData visualizationData, Color backgroundColor) { final String yAxisLabel = this.managementGate.isInputGate() ? "No data available/sec." : "Capacity limit reached/sec."; final JFreeChart chart = ChartFactory.createXYLineChart(null, "Time [sec.]", yAxisLabel, visualizationData.getChartCollection(), PlotOrientation.VERTICAL, false, false, false); chart.setBackgroundPaint(new java.awt.Color(backgroundColor.getRed(), backgroundColor.getGreen(), backgroundColor.getBlue())); // Set axis properly final XYPlot xyPlot = chart.getXYPlot(); xyPlot.getDomainAxis().setAutoRange(true); xyPlot.getDomainAxis().setAutoRangeMinimumSize(60); xyPlot.getRangeAxis().setAutoRange(true); // xyPlot.getRangeAxis().setRange(0, 100); return new ChartComposite(getShell(), SWT.NONE, chart, true); }
From source file:org.jgrasstools.gears.utils.images.LineChartGenerator.java
/** * Creates the chart image and dumps it to file. * /*from w w w. j ava 2 s. com*/ * @param chartFile the file to which to write to. * @param autoRange flag to define if to auto define the range from the bounds. * @param withLegend flag to define the legend presence. * @param imageWidth the output image width (if -1 default is used). * @param imageHeight the output image height (if -1 default is used). * @throws IOException */ @SuppressWarnings("nls") public void dumpChart(File chartFile, boolean autoRange, boolean withLegend, int imageWidth, int imageHeight) throws IOException { JFreeChart chart = ChartFactory.createXYLineChart(title, xLabel, yLabel, collection, PlotOrientation.VERTICAL, withLegend, false, false); XYPlot plot = (XYPlot) chart.getPlot(); // plot.setDomainPannable(true); // plot.setRangePannable(true); // plot.setForegroundAlpha(0.85f); NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits()); if (autoRange) { double delta = (max - min) * 0.1; yAxis.setRange(min - delta, max + delta); yAxis.setMinorTickCount(4); yAxis.setMinorTickMarksVisible(true); } // ValueAxis xAxis = plot.getDomainAxis(); // xAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits(Locale.US)); // XYItemRenderer renderer = plot.getRenderer(); // renderer.setDrawBarOutline(false); // // flat bars look best... // renderer.setBarPainter(new StandardXYBarPainter()); // renderer.setShadowVisible(false); if (!chartFile.getName().endsWith(".png")) { chartFile = FileUtilities.substituteExtention(chartFile, "png"); } if (imageWidth == -1) { imageWidth = IMAGEWIDTH; } if (imageHeight == -1) { imageHeight = IMAGEHEIGHT; } BufferedImage bufferedImage = chart.createBufferedImage(imageWidth, imageHeight); ImageIO.write(bufferedImage, "png", chartFile); }
From source file:edu.ucla.stat.SOCR.chart.demo.HistogramChartDemo2.java
protected JFreeChart createChart(IntervalXYDataset dataset) { JFreeChart chart = ChartFactory.createXYBarChart(chartTitle, domainLabel, false, rangeLabel, dataset, PlotOrientation.VERTICAL, false, // !legendPanelOn, true, false);/*from www. j av a 2 s. c o m*/ // then customise it a little... // chart.addSubtitle(new TextTitle("Source: http://www.amnestyusa.org/abolish/listbyyear.do")); chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setRenderer(new ClusteredXYBarRenderer()); XYItemRenderer renderer = plot.getRenderer(); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); // domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // setXSummary(dataset); //X is time renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); return chart; }
From source file:eu.stratosphere.addons.visualization.swt.SWTInstanceToolTip.java
private ChartComposite createCPUChart(InstanceVisualizationData instanceVisualizationData, Color backgroundColor) {// www. j a v a 2s. co m final JFreeChart chart = ChartFactory.createStackedXYAreaChart(null, "Time [sec.]", "CPU", instanceVisualizationData.getCpuDataSet(), PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(new java.awt.Color(backgroundColor.getRed(), backgroundColor.getGreen(), backgroundColor.getBlue())); // Set axis properly final XYPlot xyPlot = chart.getXYPlot(); xyPlot.getDomainAxis().setAutoRange(true); xyPlot.getDomainAxis().setAutoRangeMinimumSize(60); xyPlot.getRangeAxis().setAutoRange(false); xyPlot.getRangeAxis().setRange(0, 100); return new ChartComposite(getShell(), SWT.NONE, chart, true); }
From source file:eu.stratosphere.addons.visualization.swt.SWTInstanceToolTip.java
private ChartComposite createMemoryChart(InstanceVisualizationData instanceVisualizationData, Color backgroundColor) {//w w w .ja v a 2 s .co m final JFreeChart chart = ChartFactory.createStackedXYAreaChart(null, "Time [sec.]", "Memory", instanceVisualizationData.getMemoryDataSet(), PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(new java.awt.Color(backgroundColor.getRed(), backgroundColor.getGreen(), backgroundColor.getBlue())); // Set axis properly final XYPlot xyPlot = chart.getXYPlot(); xyPlot.getDomainAxis().setAutoRange(true); xyPlot.getDomainAxis().setAutoRangeMinimumSize(60); xyPlot.getRangeAxis().setAutoRange(false); xyPlot.getRangeAxis().setRange(0, instanceVisualizationData.getUpperBoundForMemoryChart()); return new ChartComposite(getShell(), SWT.NONE, chart, true); }
From source file:org.jfree.chart.demo.CyclicXYPlotDemo.java
/** * A demonstration application showing an XY plot, with a cyclic axis and renderer * * @param title the frame title./*from w w w . j a v a 2 s . com*/ */ public CyclicXYPlotDemo(final String title) { super(title); this.series = new XYSeries("Random Data"); this.series.setMaximumItemCount(50); // Only 50 items are visible at the same time. // Keep more as a mean to test this. final XYSeriesCollection data = new XYSeriesCollection(this.series); final JFreeChart chart = ChartFactory.createXYLineChart("Cyclic XY Plot Demo", "X", "Y", data, PlotOrientation.VERTICAL, true, true, false); final XYPlot plot = chart.getXYPlot(); plot.setDomainAxis(new CyclicNumberAxis(10, 0)); plot.setRenderer(new CyclicXYItemRenderer()); final NumberAxis axis = (NumberAxis) plot.getRangeAxis(); axis.setAutoRangeIncludesZero(false); axis.setAutoRangeMinimumSize(1.0); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(400, 300)); final JPanel content = new JPanel(new BorderLayout()); content.add(chartPanel, BorderLayout.CENTER); final JButton button1 = new JButton("Start"); button1.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { timer.start(); } }); final JButton button2 = new JButton("Stop"); button2.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { timer.stop(); } }); final JButton button3 = new JButton("Step by step"); button3.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { CyclicXYPlotDemo.this.actionPerformed(null); } }); final JPanel buttonPanel = new JPanel(new FlowLayout()); buttonPanel.add(button1); buttonPanel.add(button2); buttonPanel.add(button3); content.add(buttonPanel, BorderLayout.SOUTH); setContentPane(content); this.timer = new Timer(200, this); }
From source file:visualizer.datamining.dataanalysis.CreateLineGraph.java
private JFreeChart createChart(XYDataset xydataset, String title, String xtitle, String ytitle) { JFreeChart chart = ChartFactory.createXYLineChart(title, xtitle, ytitle, xydataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.WHITE); XYPlot xyplot = (XYPlot) chart.getPlot(); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setAutoRangeIncludesZero(false); xyplot.setDomainGridlinePaint(Color.BLACK); xyplot.setRangeGridlinePaint(Color.BLACK); xyplot.setOutlinePaint(Color.BLACK); xyplot.setOutlineStroke(new BasicStroke(1.0f)); xyplot.setBackgroundPaint(Color.white); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); xyplot.setDrawingSupplier(new DefaultDrawingSupplier( new Paint[] { Color.RED, Color.BLUE, Color.GREEN, Color.MAGENTA, Color.CYAN, Color.ORANGE, Color.BLACK, Color.DARK_GRAY, Color.GRAY, Color.LIGHT_GRAY, Color.YELLOW }, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE)); XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseShapesFilled(true); xylineandshaperenderer.setDrawOutlines(true); return chart; }
From source file:com.att.aro.ui.view.diagnostictab.CreateBarPlot.java
public XYPlot drawXYItemPlot() { // Set up renderer XYItemRenderer throughputRenderer = new StandardXYItemRenderer(); throughputRenderer.setSeriesPaint(0, Color.red); // Normalize the throughput axis so that it represents max value NumberAxis axis = new NumberAxis(); axis.setVisible(false);/*from w w w . java 2s .c o m*/ // Create plot XYPlot throughputPlot = new XYPlot(null, null, axis, throughputRenderer); throughputPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); throughputPlot.getRangeAxis().setVisible(false); return throughputPlot; }