List of usage examples for org.jfree.chart.plot XYPlot getRangeAxis
public ValueAxis getRangeAxis()
From source file:daylightchart.daylightchart.chart.DaylightChart.java
private void adjustForChartOrientation(final ChartOrientation chartOrientation) { if (chartOrientation == null) { return;// ww w . j ava2 s . c o m } final XYPlot plot = getXYPlot(); final ValueAxis hoursAxis = plot.getRangeAxis(); final ValueAxis monthsAxis = plot.getDomainAxis(); switch (chartOrientation) { case STANDARD: hoursAxis.setInverted(true); plot.setDomainAxisLocation(AxisLocation.TOP_OR_LEFT); break; case CONVENTIONAL: break; case VERTICAL: plot.setOrientation(PlotOrientation.HORIZONTAL); monthsAxis.setInverted(true); break; default: break; } }
From source file:grafix.graficos.eixos.Eixo.java
public void configurarEscalaVertical(XYPlot plot) { NumberAxis nAxis = (NumberAxis) plot.getRangeAxis(); if (this.isAutoEscala()) { if (this.isIncluiZero()) { nAxis.setAutoRange(true);//from www.ja v a 2 s .com nAxis.setAutoRangeIncludesZero(true); } else { nAxis.setAutoRange(true); nAxis.setAutoRangeIncludesZero(false); } } else { if (this.isIncluiZero()) { nAxis.setRange(Math.min(getEscalaMin(), 0), Math.max(0, getEscalaMax())); } else { nAxis.setRange(getEscalaMin(), getEscalaMax()); } } }
From source file:org.drugis.addis.gui.ConvergencePlotsDialog.java
private JFreeChart createRhatChart(final XYDataset dataset) { final JFreeChart RhatChart = ChartFactory.createXYLineChart("Iterative PSRF Plot", "Iteration No.", "R-Hat(p)", dataset, PlotOrientation.VERTICAL, false, true, false); RhatChart.setBackgroundPaint(Color.white); final XYPlot RhatPlot = RhatChart.getXYPlot(); RhatPlot.setDomainGridlinePaint(Color.white); RhatPlot.setRangeGridlinePaint(Color.white); final NumberAxis rangeAxis = (NumberAxis) RhatPlot.getRangeAxis(); rangeAxis.setAutoRange(true);/* ww w . ja va 2s. c o m*/ rangeAxis.setAutoRangeIncludesZero(false); return RhatChart; }
From source file:edu.cmu.sv.modelinference.eventtool.charting.DataChart.java
private void createChartPanel(JFreeChart chart) { chartPanel = new ChartPanel(chart); chartPanel.addChartMouseListener(new ChartMouseListener() { @Override/*from ww w . jav a2 s.c o m*/ public void chartMouseClicked(ChartMouseEvent arg0) { //ignore } @Override public void chartMouseMoved(ChartMouseEvent event) { Rectangle2D dataArea = chartPanel.getScreenDataArea(); JFreeChart chart = event.getChart(); XYPlot plot = (XYPlot) chart.getPlot(); ValueAxis xAxis = plot.getDomainAxis(); double x = xAxis.java2DToValue(event.getTrigger().getX(), dataArea, RectangleEdge.BOTTOM); ValueAxis yAxis = plot.getRangeAxis(); double y = yAxis.java2DToValue(event.getTrigger().getY(), dataArea, RectangleEdge.LEFT); //Alternatively, obtain y for one of the subplots, which would be very neat. //We should find the "nearest" subplot to the cursor -- this is easy //double y = DatasetUtilities.findYValue(plot.getDataset(), 0, x); xCrosshair.setValue(x); yCrosshair.setValue(y); } }); CrosshairOverlay crosshairOverlay = new CrosshairOverlay(); xCrosshair = new Crosshair(Double.NaN, Color.GRAY, new BasicStroke(0f)); xCrosshair.setLabelVisible(true); yCrosshair = new Crosshair(Double.NaN, Color.GRAY, new BasicStroke(0f)); yCrosshair.setLabelVisible(true); crosshairOverlay.addDomainCrosshair(xCrosshair); crosshairOverlay.addRangeCrosshair(yCrosshair); chartPanel.addOverlay(crosshairOverlay); chartPanel.setPreferredSize(new java.awt.Dimension(800, 600)); setContentPane(chartPanel); }
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.jfree.chart.demo.XYTickLabelDemo.java
/** * When a checkbox is changed .../*from ww w . j a va2s . co m*/ * * @param event the event. */ public void actionPerformed(final ActionEvent event) { final ValueAxis[] axes = new ValueAxis[4]; final XYPlot plot = this.chart.getXYPlot(); axes[0] = plot.getDomainAxis(); axes[1] = plot.getRangeAxis(); axes[2] = plot.getDomainAxis(1); axes[3] = plot.getRangeAxis(1); final Object source = event.getSource(); if (source == this.symbolicAxesCheckBox) { final boolean val = this.symbolicAxesCheckBox.isSelected(); for (int i = 0; i < axes.length; i++) { ValueAxis axis = axes[i]; final String label = axis.getLabel(); final int maxTick = (int) axis.getUpperBound(); final String[] tickLabels = new String[maxTick]; final Font ft = axis.getTickLabelFont(); for (int itk = 0; itk < maxTick; itk++) { tickLabels[itk] = "Label " + itk; } axis = val ? new SymbolicAxis(label, tickLabels) : new NumberAxis(label); axis.setTickLabelFont(ft); axes[i] = axis; } plot.setDomainAxis(axes[0]); plot.setRangeAxis(axes[1]); plot.setDomainAxis(1, axes[2]); plot.setRangeAxis(1, axes[3]); } if (source == this.symbolicAxesCheckBox || source == this.verticalTickLabelsCheckBox) { final boolean val = this.verticalTickLabelsCheckBox.isSelected(); for (int i = 0; i < axes.length; i++) { axes[i].setVerticalTickLabels(val); } } else if (source == this.symbolicAxesCheckBox || source == this.horizontalPlotCheckBox) { final PlotOrientation val = this.horizontalPlotCheckBox.isSelected() ? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL; this.chart.getXYPlot().setOrientation(val); } else if (source == this.symbolicAxesCheckBox || source == this.fontSizeTextField) { final String s = this.fontSizeTextField.getText(); if (s.length() > 0) { final float sz = Float.parseFloat(s); for (int i = 0; i < axes.length; i++) { final ValueAxis axis = axes[i]; Font ft = axis.getTickLabelFont(); ft = ft.deriveFont(sz); axis.setTickLabelFont(ft); } } } }
From source file:org.ow2.clif.jenkins.chart.MovingStatChart.java
@Override protected JFreeChart createChart() { XYSeriesCollection coreDataset = new XYSeriesCollection(); coreDataset.addSeries(this.eventSerie); long periodMs = this.chartConfiguration.getStatisticalPeriod() * 1000L; XYSeriesCollection movingDataset = calculateMovingDataset(coreDataset, periodMs); XYSeriesCollection throughputDataset = calculateThroughputDataset(coreDataset, periodMs); JFreeChart chart;/*w w w . ja v a 2s .c o m*/ chart = ChartFactory .createXYLineChart( getBasicTitle() + " " + Messages.MovingChart_StatisticalPeriod( this.chartConfiguration.getStatisticalPeriod()), // chart title Messages.MovingChart_Time(), // x axis label Messages.MovingChart_ResponseTime(), // y axis label movingDataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... XYPlot plot = (XYPlot) chart.getPlot(); configureBasicPlotProperties(plot); // Force the 0 on vertical axis NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setAutoRangeIncludesZero(true); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // Force the 0 on horizontal axis NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setAutoRangeIncludesZero(true); attachThroughputDatasetToDedicatedAxis(throughputDataset, plot); // Global renderer for moving stats plot.setRenderer(getGlobalRenderer()); // Dedicated Throughput renderer plot.setRenderer(1, getThroughputRenderer()); return chart; }
From source file:com.intel.stl.ui.main.view.PacketRateChartRangeUpdater.java
@Override public void updateChartRange(JFreeChart chart, long lower, long upper) { if (lower > upper) { return;//from w w w .j av a2s. c o m } XYPlot xyplot = (XYPlot) chart.getPlot(); NumberAxis range = (NumberAxis) xyplot.getRangeAxis(); range.setRangeWithMargins(lower, upper); range.setLowerBound(0); // If upper is less than 1000, don't do anything to convert the y-axis // label and // convert the unit tick. TickUnitSource unitSrc = createTickUnits(upper); if (unitSrc != null) { // Change tick values only if upper is above 1000. range.setStandardTickUnits(unitSrc); xyplot.getRenderer().setBaseToolTipGenerator( new PktsRateToolTipGenerator("<html><b>{0}</b><br> Time: {1}<br> Data: {2}</html>", Util.getHHMMSS(), new DecimalFormat("#,##0.00" + " " + unitDes))); } else { range.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); } // y-axis label setChartRangeLabel(range); }
From source file:org.jfree.chart.demo.ScatterPlotDemo3.java
/** * Callback method for receiving notification of a mouse click on a chart. * * @param event information about the event. *//* w w w . ja va 2s . co m*/ public void chartMouseClicked(ChartMouseEvent event) { int x = event.getTrigger().getX(); int y = event.getTrigger().getY(); // the following translation takes account of the fact that the chart image may // have been scaled up or down to fit the panel... Point2D p = chartPanel.translateScreenToJava2D(new Point(x, y)); // now convert the Java2D coordinate to axis coordinates... XYPlot plot = chartPanel.getChart().getXYPlot(); Rectangle2D dataArea = chartPanel.getChartRenderingInfo().getPlotInfo().getDataArea(); double xx = plot.getDomainAxis().java2DToValue(p.getX(), dataArea, plot.getDomainAxisEdge()); double yy = plot.getRangeAxis().java2DToValue(p.getY(), dataArea, plot.getRangeAxisEdge()); // just for fun, lets convert the axis coordinates back to component coordinates... double xxx = plot.getDomainAxis().valueToJava2D(xx, dataArea, plot.getDomainAxisEdge()); double yyy = plot.getRangeAxis().valueToJava2D(yy, dataArea, plot.getRangeAxisEdge()); Point2D p2 = chartPanel.translateJava2DToScreen(new Point2D.Double(xxx, yyy)); System.out .println("Mouse coordinates are (" + x + ", " + y + "), in data space = (" + xx + ", " + yy + ")."); System.out.println("--> (" + p2.getX() + ", " + p2.getY() + ")"); }
From source file:org.vrjuggler.perfmon.PerformanceMonitorGUI.java
private JFreeChart createTimeSeriesChart(TimeSeriesCollection dataset) { JFreeChart result = ChartFactory.createTimeSeriesChart("Performance Monitoring Statistics", "Time", "Sample", dataset, true, true, false); XYPlot plot = result.getXYPlot(); ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true);/*from www. j av a 2 s. c o m*/ axis.setFixedAutoRange(60000.0); // 60 seconds axis = plot.getRangeAxis(); axis.setAutoRange(true); //axis.setRange( 0.0, 10.0 ); return result; }