List of usage examples for org.jfree.chart.plot XYPlot getDomainAxis
public ValueAxis getDomainAxis()
From source file:GUI.PlotCreator.java
private ChartPanel createSeaCurrentSpeedByTimePanel() { JFreeChart jfreechart = ChartFactory.createScatterPlot(title, "Time(Hours)", "Sea Current Speed", createSeaCurrentSpeedDataByTime(), PlotOrientation.VERTICAL, true, true, false); XYPlot xyPlot = (XYPlot) jfreechart.getPlot(); xyPlot.setDomainCrosshairVisible(true); xyPlot.setRangeCrosshairVisible(true); XYItemRenderer renderer = xyPlot.getRenderer(); renderer.setSeriesPaint(0, Color.blue); NumberAxis domain = (NumberAxis) xyPlot.getDomainAxis(); domain.setTickUnit(new NumberTickUnit(1.0)); domain.setVerticalTickLabels(true);/*from w w w . j a va2 s . c o m*/ return new ChartPanel(jfreechart); }
From source file:GUI.PlotCreator.java
private ChartPanel createWindDirectionByTimePanel() { JFreeChart jfreechart = ChartFactory.createScatterPlot(title, "Time(Hours)", "Wind Direction", createWindDirectionByTime(), PlotOrientation.VERTICAL, true, true, false); XYPlot xyPlot = (XYPlot) jfreechart.getPlot(); xyPlot.setDomainCrosshairVisible(true); xyPlot.setRangeCrosshairVisible(true); XYItemRenderer renderer = xyPlot.getRenderer(); renderer.setSeriesPaint(0, Color.BLACK); NumberAxis domain = (NumberAxis) xyPlot.getDomainAxis(); domain.setTickUnit(new NumberTickUnit(1.0)); domain.setVerticalTickLabels(true);//from w w w. j a v a 2 s . c o m return new ChartPanel(jfreechart); }
From source file:GUI.PlotCreator.java
private ChartPanel createWindIntensityByTimePanel() { JFreeChart jfreechart = ChartFactory.createScatterPlot(title, "Time(Hours)", "Wind Instensity", createWindIntensityByTime(), PlotOrientation.VERTICAL, true, true, false); XYPlot xyPlot = (XYPlot) jfreechart.getPlot(); xyPlot.setDomainCrosshairVisible(true); xyPlot.setRangeCrosshairVisible(true); XYItemRenderer renderer = xyPlot.getRenderer(); renderer.setSeriesPaint(0, Color.GREEN); NumberAxis domain = (NumberAxis) xyPlot.getDomainAxis(); //domain.setRange(0,24); domain.setTickUnit(new NumberTickUnit(1.0)); domain.setVerticalTickLabels(true);/*from w w w . j a va 2s. co m*/ return new ChartPanel(jfreechart); }
From source file:de.xirp.ui.widgets.panels.LiveChartComposite.java
/** * Creates a chart for the given data set. * //from w w w. j a v a2 s . c o m * @param dataset * The data. * @return The chart. */ private JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart(null, I18n.getString("LiveChartComposite.text.time"), //$NON-NLS-1$ I18n.getString("LiveChartComposite.text.value"), dataset, true, true, false); //$NON-NLS-1$ XYPlot plot = chart.getXYPlot(); plot.setDomainAxis(new DateAxis(I18n.getString("LiveChartComposite.text.absoluteTime"))); //$NON-NLS-1$ ValueAxis vaxis = plot.getDomainAxis(); vaxis.setAutoRange(true); vaxis.setFixedAutoRange(TIME); plot.setNoDataMessage(ChartManager.NO_DATA_AVAILABLE); return chart; }
From source file:org.griphyn.vdl.karajan.monitor.monitors.swing.GraphPanel.java
private double valueFromPosition(ChartMouseEvent e) { Rectangle2D chartArea = cp.getScreenDataArea(); XYPlot plot = chart.getXYPlot(); return plot.getDomainAxis().java2DToValue(e.getTrigger().getX(), chartArea, plot.getDomainAxisEdge()); }
From source file:com.imaging100x.tracker.TrackerUtils.java
/** * Create a frame with a plot of the data given in XYSeries *//*from ww w . ja v a 2s . c o m*/ public static void plotData(String title, final XYSeries data, String xTitle, String yTitle, int xLocation, int yLocation) { // JFreeChart code XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(data); JFreeChart chart = ChartFactory.createScatterPlot(title, // Title xTitle, // x-axis Label yTitle, // y-axis Label dataset, // Dataset PlotOrientation.VERTICAL, // Plot Orientation false, // Show Legend true, // Use tooltips false // Configure chart to generate URLs? ); final XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.lightGray); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setSeriesPaint(0, Color.black); renderer.setSeriesFillPaint(0, Color.white); renderer.setSeriesLinesVisible(0, true); Shape circle = new Ellipse2D.Float(-2.0f, -2.0f, 4.0f, 4.0f); renderer.setSeriesShape(0, circle, false); renderer.setUseFillPaint(true); ChartFrame graphFrame = new ChartFrame(title, chart); graphFrame.getChartPanel().setMouseWheelEnabled(true); graphFrame.setPreferredSize(new Dimension(SIZE, SIZE)); graphFrame.setResizable(true); graphFrame.pack(); graphFrame.setLocation(xLocation, yLocation); graphFrame.setVisible(true); dataset.addChangeListener(new DatasetChangeListener() { public void datasetChanged(DatasetChangeEvent dce) { double xRange = data.getMaxX() - data.getMinX(); double yRange = data.getMaxY() - data.getMinY(); double xAvg = (data.getMaxX() + data.getMinX()) / 2; double yAvg = (data.getMaxY() + data.getMinY()) / 2; double range = xRange; if (yRange > range) { range = yRange; } double offset = 0.55 * range; plot.getDomainAxis().setRange(xAvg - offset, xAvg + offset); plot.getRangeAxis().setRange(yAvg - offset, yAvg + offset); } }); }
From source file:opensonata.dataDisplays.BaselineImage.java
private JFreeChart createChart(String inFilename, String userTitle, NssBaseline nssBaseline) { XYSeries series = new XYSeries(""); float[] baselineValues = nssBaseline.getBaselineValues(); // plot subband values for (int i = 0; i < baselineValues.length; i++) { series.add(i, baselineValues[i]); }/*from w ww . j a va2 s . c o m*/ System.err.println("HERE!!!!"); // add a final point at the end with a zero Y value, series.add(baselineValues.length, 0.0); XYDataset data = new XYSeriesCollection(series); String inFilenameBase = new File(inFilename).getName(); DecimalFormat freqFormatter = new DecimalFormat("0000.000 MHz "); String freqString = freqFormatter.format(nssBaseline.getCenterFreqMhz()); DecimalFormat bandwidthFormatter = new DecimalFormat("0.00 MHz "); String bandwidthString = bandwidthFormatter.format(nssBaseline.getBandwidthMhz()); String mainTitle = ""; String xAxisLabel = "Subband"; String yAxisLabel = "Power"; JFreeChart chart = ChartFactory.createXYLineChart(mainTitle, xAxisLabel, yAxisLabel, data, PlotOrientation.VERTICAL, false, // legend true, // tooltips false // urls ); String subTitle1 = "Baseline: "; if (!userTitle.equals("")) { subTitle1 += userTitle; } else { subTitle1 += inFilenameBase; } chart.addSubtitle(new TextTitle(subTitle1)); String subTitle2 = "Center Freq: " + freqString + "Bandwidth: " + bandwidthString; chart.addSubtitle(new TextTitle(subTitle2)); // move the data off of the axes // by extending the minimum axis value XYPlot plot = (XYPlot) ((JFreeChart) chart).getPlot(); double axisMarginPercent = 0.02; NumberAxis valueAxis = (NumberAxis) plot.getRangeAxis(); valueAxis.setLowerBound(-1.0 * valueAxis.getUpperBound() * axisMarginPercent); valueAxis = (NumberAxis) plot.getDomainAxis(); valueAxis.setLowerBound(-1.0 * valueAxis.getUpperBound() * axisMarginPercent); return chart; }
From source file:Chart.JFreeChartDemo.java
/** * Create a chart./*from w w w . j av a 2s .c om*/ * * @param dataset the dataset * @return the chart */ private JFreeChart createChart(XYDataset dataset) { // WHAT IS THIS LINE??? // JFreeChart chart = ChartFactory.createTimeSeriesChart(null, null, null, dataset, rootPaneCheckingEnabled, rootPaneCheckingEnabled, rootPaneCheckingEnabled) // create the chart... JFreeChart chart = ChartFactory.createXYLineChart("", // chart title "Time", // domain axis label "Range", // range axis label dataset, // initial series PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); // set chart background chart.setBackgroundPaint(Color.white); // set a few custom plot features XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(new Color(0xffffe0)); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); // set the plot's axes to display integers TickUnitSource ticks = NumberAxis.createIntegerTickUnits(); NumberAxis domain = (NumberAxis) plot.getDomainAxis(); domain.setStandardTickUnits(ticks); NumberAxis range = (NumberAxis) plot.getRangeAxis(); range.setStandardTickUnits(ticks); // render shapes and lines // XYLineAndShapeRenderer renderer = // new XYLineAndShapeRenderer(true, true); // plot.setRenderer(renderer); // renderer.setBaseShapesVisible(true); // renderer.setBaseShapesFilled(true); // // // set the renderer's stroke // Stroke stroke = new BasicStroke( // 3f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL); // // renderer.setBaseOutlineStroke(stroke); // //Shape theshape = ShapeUtilities.createDiamond(1); //renderer.setSeriesShape(5, theshape); // label the points // NumberFormat format = NumberFormat.getNumberInstance(); // format.setMaximumFractionDigits(2); // XYItemLabelGenerator generator = // new StandardXYItemLabelGenerator( // StandardXYItemLabelGenerator.DEFAULT_ITEM_LABEL_FORMAT, // format, format); // renderer.setBaseItemLabelGenerator(generator); // renderer.setBaseItemLabelsVisible(true); return chart; }
From source file:com.intel.stl.ui.common.view.ComponentFactory.java
public static JFreeChart createHistogramChart(String xAxisLabel, String yAxisLabel, IntervalXYDataset dataset) { JFreeChart jfreechart = ChartFactory.createHistogram(null, xAxisLabel, yAxisLabel, dataset, PlotOrientation.VERTICAL, false, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(null);//w w w . ja v a 2 s . co m xyplot.setOutlinePaint(null); xyplot.setRangeGridlinePaint(UIConstants.INTEL_DARK_GRAY); NumberAxis yAxis = (NumberAxis) xyplot.getRangeAxis(); yAxis.setRangeType(RangeType.POSITIVE); yAxis.setLabelFont(UIConstants.H5_FONT); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); xyplot.getDomainAxis().setLabelFont(UIConstants.H5_FONT); xyplot.getRangeAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); XYBarRenderer renderer = (XYBarRenderer) xyplot.getRenderer(); renderer.setShadowVisible(false); renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelFont(UIConstants.H5_FONT); renderer.setBarPainter(new StandardXYBarPainter()); renderer.setSeriesPaint(0, UIConstants.INTEL_BLUE); return jfreechart; }
From source file:com.compomics.cell_coord.gui.controller.summary.VisualizeTracksController.java
/** * Scale the axes to the experiment coordinates ranges. * * @param chart/* ww w . j a va2 s.co m*/ */ private void scaleAxes(JFreeChart chart, boolean useRawData) { XYPlot xYPlot = chart.getXYPlot(); Double[][] coordinatesRanges; if (useRawData) { coordinatesRanges = coordRanges; } else { coordinatesRanges = shiftedCoordRange; } Double[] xCoords = coordinatesRanges[0]; Double[] yCoords = coordinatesRanges[1]; xYPlot.getDomainAxis().setRange(new Range(yCoords[0], yCoords[1])); xYPlot.getRangeAxis().setRange(new Range(xCoords[0], xCoords[1])); }