List of usage examples for org.jfree.chart.plot XYPlot getDomainAxis
public ValueAxis getDomainAxis()
From source file:dbseer.gui.events.InformationChartMouseListener.java
@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); chartPanel.getVerticalCrossHair().setValue(x); }
From source file:neuronspike.NetPlot.java
public void plotSpikes(List<GenericNeuron> spikeList) { XYPlot xyPlot = chart.getXYPlot(); ValueAxis domain = xyPlot.getDomainAxis(); domain.setRange(Math.max(cursor - cutoffInterval, 0), Math.max(cursor, cutoffInterval)); domain = xyPlot.getRangeAxis();//from www . jav a 2 s . co m domain.setRange(-1, limit_y); for (int i = 0; i < spikeList.size(); i++) { addPoint(cursor, spikeList.get(i).getLocation()[1]); } cursor++; // Remove too old points while (!spikes.isEmpty() && spikes.getDataItem(0).getX().doubleValue() < cursor - cutoffInterval) spikes.remove(0); }
From source file:org.jfree.chart.demo.MouseListenerDemo3.java
public MouseListenerDemo3(String s) { super(s);//w w w. j a v a2 s .c o m String s1 = "Legal & General Unit Trust Prices"; XYDataset xydataset = createDataset(); chart = ChartFactory.createTimeSeriesChart(s1, "Date", "Price Per Unit", xydataset, true, true, false); chart.addSubtitle(new TextTitle("Click on the legend to see series highlighted...")); XYPlot xyplot = (XYPlot) chart.getPlot(); DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); dateaxis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); ChartPanel chartpanel = new ChartPanel(chart); chartpanel.setPreferredSize(new Dimension(500, 270)); chartpanel.setMouseZoomable(true, false); chartpanel.addChartMouseListener(this); setContentPane(chartpanel); }
From source file:edu.emory.library.tast.database.graphs.GraphTypeScatter.java
public JFreeChart createChart(Object[] data) { CategoryTableXYDataset dataset = new CategoryTableXYDataset(); JFreeChart chart = ChartFactory.createScatterPlot(null, getSelectedIndependentVariable().getLabel(), TastResource.getText("components_charts_barvalue"), dataset, PlotOrientation.VERTICAL, true, true, false);/*from www. jav a2 s .c o m*/ //getSelectedIndependentVariable().getFormat(); XYPlot plot = chart.getXYPlot(); ((NumberAxis) plot.getDomainAxis()).setNumberFormatOverride(new DecimalFormat("0")); chart.setBackgroundPaint(Color.white); List allDataSeries = getDataSeries(); for (int j = 0; j < allDataSeries.size(); j++) { DataSeries dataSearies = (DataSeries) allDataSeries.get(j); String dataSeriesLabel = dataSearies.formatForDisplay(); for (int i = 0; i < data.length; i++) { Object[] row = (Object[]) data[i]; Number x = (Number) row[0]; Number y = (Number) row[j + 1]; if (x != null && y != null) dataset.add(x.doubleValue(), y.doubleValue(), dataSeriesLabel); } } return chart; }
From source file:com.testmax.framework.CreateGraph.java
protected void createChart(double timeout) { TimeSeriesCollection dataset = new TimeSeriesCollection(ts); this.chart = ChartFactory.createTimeSeriesChart(this.graphName, this.xName, this.yName, dataset, true, true, false);/*from w w w .j a v a 2 s. com*/ final XYPlot plot = chart.getXYPlot(); ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); axis.setFixedAutoRange(timeout * 1000.0); JFrame frame = new JFrame(this.graphName); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ChartPanel label = new ChartPanel(chart); frame.getContentPane().add(label); //Suppose I add combo boxes and buttons here later frame.pack(); if (ConfigLoader.getConfig("SHOW_GRAPH_RUNTIME").equalsIgnoreCase("yes")) { frame.setVisible(true); } else { frame.setVisible(false); } }
From source file:dbseer.gui.events.InformationChartMouseListener.java
@Override public void chartMouseClicked(ChartMouseEvent event) { Rectangle2D dataArea = chartPanel.getScreenDataArea(); JFreeChart chart = event.getChart(); XYPlot plot = (XYPlot) chart.getPlot(); ValueAxis xAxis = plot.getDomainAxis(); int x = (int) Math.round(xAxis.java2DToValue(event.getTrigger().getX(), dataArea, RectangleEdge.BOTTOM)); XYDataset dataset = plot.getDataset(); int maxX = DatasetUtilities.findMaximumDomainValue(dataset).intValue(); if (x >= 1 && x <= maxX) { int seriesCount = dataset.getSeriesCount(); int[] mixtures = new int[seriesCount - 1]; int total = 0; for (int i = 0; i < seriesCount - 1; ++i) { mixtures[i] = (int) dataset.getYValue(i, x - 1); total += mixtures[i];/*from www . j ava2s . com*/ } for (int i = 0; i < seriesCount - 1; ++i) { mixtures[i] = (int) Math.round((double) mixtures[i] / (double) total * 100.0); tpsMixturePanel.setMixture(i, mixtures[i]); } } }
From source file:net.sf.statcvs.output.xml.chart.TimeLineChart.java
/** * @param filename/*from ww w . j av a2 s .com*/ * @param title */ public TimeLineChart(String filename, String title) { super(filename, title); Paint[] colors = new Paint[1]; colors[0] = Color.blue; tsc = new TimeSeriesCollection(); //collection.addSeries(createTimeSeries(timeline)); //String range = timeline.getRangeLabel(); String domain = I18n.tr("Date"); setChart(ChartFactory.createTimeSeriesChart(Settings.getProjectName(), I18n.tr("Date"), rangeLabel, (XYDataset) tsc, true, true, false)); //getChart().getPlot().setSeriesPaint(colors); XYPlot plot = getChart().getXYPlot(); ValueAxis axis = plot.getDomainAxis(); axis.setVerticalTickLabels(true); plot.setRenderer(new XYStepRenderer()); }
From source file:diplomawork.model.JPEGSaver.java
public void saveChartToFile(JFreeChart chart, boolean trainFlag) { chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.getDomainAxis().setVisible(false); plot.getRangeAxis().setVisible(false); plot.setBackgroundAlpha(0);// w ww . j a va2 s .c o m plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setOutlinePaint(null); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(false); renderer.setSeriesPaint(0, Color.BLACK); } plot.getRenderer().setSeriesStroke(0, new java.awt.BasicStroke(4f)); File f = null; if (trainFlag) { nameOfJPGFile = "src/resorce/TranePlot" + trainCount++ + ".jpg"; f = new File(nameOfJPGFile); } else { // f = new File("src/resorce/Plot" + n++ + ".jpg"); f = new File("src/resorce/Plot" + ".jpg"); } try { ChartUtilities.saveChartAsJPEG(f, chart, 80, 80); } catch (IOException ex) { Logger.getLogger(JPEGSaver.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:org.jfree.chart.demo.XYBarChartDemo.java
/** * Constructs the demo application./*from w ww . ja va 2s .c o m*/ * * @param title the frame title. */ public XYBarChartDemo(final String title) { super(title); final TimeSeriesCollection data = DemoDatasetFactory.createTimeSeriesCollection1(); data.setDomainIsPointsInTime(false); final JFreeChart chart = ChartFactory.createXYBarChart(title, "X", true, "Y", data, PlotOrientation.VERTICAL, true, false, false); // then customise it a little... chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 1000, 0, Color.blue)); final XYItemRenderer renderer = chart.getXYPlot().getRenderer(); final StandardXYToolTipGenerator generator = new StandardXYToolTipGenerator("{1} = {2}", new SimpleDateFormat("yyyy"), new DecimalFormat("0.00")); renderer.setToolTipGenerator(generator); final XYPlot plot = chart.getXYPlot(); final DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); // add the chart to a panel... final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 300)); setContentPane(chartPanel); }
From source file:mls.FramePlot.java
private JFreeChart createChartVarianza(final XYDataset datasetVarianza) { final JFreeChart result = ChartFactory.createXYLineChart("Varianza campionaria", "n", "vc", datasetVarianza, PlotOrientation.VERTICAL, false, true, false); final XYPlot plot = result.getXYPlot(); ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true);/*from w ww . j av a 2s. c o m*/ axis.setFixedAutoRange(1500); axis = plot.getRangeAxis(); axis.setAutoRange(true); axis.setRange(10, 100); plot.getRenderer().setSeriesPaint(0, Color.MAGENTA); return result; }