List of usage examples for org.jfree.chart.plot XYPlot setDomainCrosshairVisible
public void setDomainCrosshairVisible(boolean flag)
From source file:net.liuxuan.device.VACVBS.JIF_DrawChart_vacvbs.java
/** * ?jfreechart/*from w ww . j av a2 s .c om*/ */ public void initChart() { ts_LP = new TimeSeries("LowPressure", Millisecond.class); ts_HP = new TimeSeries("HighPressure", Millisecond.class); ts_humidity = new TimeSeries("Humidity", Millisecond.class); ts_temprature = new TimeSeries("Temperature", Millisecond.class); ts_time = new TimeSeries("TestTime", Millisecond.class); ts_num = new TimeSeries("num", Millisecond.class); ts_reserved1 = new TimeSeries("reserved1", Millisecond.class); ts_reserved2 = new TimeSeries("reserved2", Millisecond.class); ts_reserved3 = new TimeSeries("reserved3", Millisecond.class); trcollection = new TimeSeriesCollection(ts_LP); trcollection.addSeries(ts_HP); trcollection2 = new TimeSeriesCollection(ts_humidity); trcollection2.addSeries(ts_temprature); // trcollection2.addSeries(ts_num); // trcollection2.addSeries(ts_time); //trcollection2.addSeries(ts_reserved1); //trcollection2.addSeries(ts_reserved2); //trcollection2.addSeries(ts_reserved3); // timeseriescopylist.add(getTimeSeries(3).createCopy(0, getTimeSeries(3).getItemCount() - 1)); JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("", "Time(s)", "PPM", trcollection, true, true, false); XYPlot xyplot = jfreechart.getXYPlot(); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); Font fs = new Font("", Font.BOLD, 14); Font fs2 = new Font("", Font.BOLD, 12); XYLineAndShapeRenderer line0render = (XYLineAndShapeRenderer) xyplot.getRenderer(0); Color purple = new Color(139, 0, 255); line0render.setSeriesPaint(0, Color.blue); line0render.setSeriesPaint(1, Color.green); line0render.setSeriesPaint(2, Color.red); line0render.setSeriesPaint(3, purple); // line0render.setSeriesPaint(3, Color.ORANGE); XYLineAndShapeRenderer line1render = new XYLineAndShapeRenderer(); Color Rosered = new Color(230, 28, 100); line1render.setSeriesPaint(0, Color.cyan); line1render.setSeriesPaint(1, Rosered); line1render.setSeriesPaint(2, Color.orange); line1render.setSeriesPaint(3, Color.yellow); line1render.setBaseShapesVisible(false); xyplot.setRenderer(1, line1render); //?? ValueAxis valueaxis = xyplot.getDomainAxis(); // valueaxis.setLabelFont(fs); // valueaxis.setTickLabelFont(fs2); ValueAxis valueaxis2 = new NumberAxis(""); valueaxis2.setLabelFont(fs); valueaxis2.setTickLabelFont(fs2); xyplot.setRangeAxis(1, valueaxis2); xyplot.setDataset(1, trcollection2); xyplot.mapDatasetToRangeAxis(1, 1); //?? valueaxis.setAutoRange(true); //?? 7days // valueaxis.setFixedAutoRange(604800000D); valueaxis = xyplot.getRangeAxis(); valueaxis.setLabelFont(new Font("", Font.BOLD, 14)); valueaxis.setLabelPaint(line0render.getSeriesPaint(0)); valueaxis2.setLabelPaint(line1render.getSeriesPaint(0)); jfreechart.getTitle().setFont(new Font("", Font.BOLD, 20));// jfreechart.getLegend().setItemFont(new Font("", Font.ITALIC, 15)); xyplot.getRenderer(0).setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator("{1}, {2}", new SimpleDateFormat("MM-dd HH:mm:ss"), new DecimalFormat("0.0000"))); xyplot.getRenderer(1).setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator("{1}, {2}", new SimpleDateFormat("MM-dd HH:mm:ss"), new DecimalFormat("0.0000"))); chartPanel = new ChartPanel(jfreechart); initChartMenu(); // chartPanel.getPopupMenu().add(jmenuitem2); // chartPanel.getPopupMenu().getPopupMenuListeners(); chartPanel.setSize(950, 620); chartPanel.setPreferredSize(new Dimension(950, 620)); jPanel_Show.add(chartPanel, BorderLayout.CENTER); }
From source file:ec.util.chart.swing.JTimeSeriesChart.java
private void onCrosshairValueChange(ObsIndex value) { if (isElementVisible(Element.CROSSHAIR) && existPredicate.apply(value)) { double x = dataset.getXValue(value.getSeries(), value.getObs()); double y = dataset.getYValue(value.getSeries(), value.getObs()); int index = plotDispatcher.apply(value.getSeries()); for (XYPlot subPlot : roSubPlots) { subPlot.setDomainCrosshairValue(x); subPlot.setDomainCrosshairVisible(crosshairOrientation != CrosshairOrientation.HORIZONTAL); if (roSubPlots.indexOf(subPlot) == index && crosshairOrientation != CrosshairOrientation.VERTICAL) { subPlot.setRangeCrosshairValue(y); subPlot.setRangeCrosshairVisible(true); } else { subPlot.setRangeCrosshairVisible(false); }/*from w w w . j ava2s . c om*/ } } else { for (XYPlot subPlot : roSubPlots) { subPlot.setRangeCrosshairVisible(false); subPlot.setDomainCrosshairVisible(false); } } }
From source file:edu.dlnu.liuwenpeng.ChartFactory.ChartFactory.java
/** * Creates a stepped XY plot with default settings. * /*from w w w . j a va 2 s . c o m*/ * @param title the chart title (<code>null</code> permitted). * @param xAxisLabel a label for the X-axis (<code>null</code> permitted). * @param yAxisLabel a label for the Y-axis (<code>null</code> permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param orientation the plot orientation (horizontal or vertical) * (<code>null</code> NOT permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A chart. */ public static JFreeChart createXYStepChart(String title, String xAxisLabel, String yAxisLabel, XYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } DateAxis xAxis = new DateAxis(xAxisLabel); NumberAxis yAxis = new NumberAxis(yAxisLabel); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); XYToolTipGenerator toolTipGenerator = null; if (tooltips) { toolTipGenerator = new StandardXYToolTipGenerator(); } XYURLGenerator urlGenerator = null; if (urls) { urlGenerator = new StandardXYURLGenerator(); } XYItemRenderer renderer = new XYStepRenderer(toolTipGenerator, urlGenerator); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null); plot.setRenderer(renderer); plot.setOrientation(orientation); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); return chart; }
From source file:edu.dlnu.liuwenpeng.ChartFactory.ChartFactory.java
/** * Creates a filled stepped XY plot with default settings. * //from w w w .ja v a 2s . com * @param title the chart title (<code>null</code> permitted). * @param xAxisLabel a label for the X-axis (<code>null</code> permitted). * @param yAxisLabel a label for the Y-axis (<code>null</code> permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param orientation the plot orientation (horizontal or vertical) * (<code>null</code> NOT permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A chart. */ public static JFreeChart createXYStepAreaChart(String title, String xAxisLabel, String yAxisLabel, XYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } NumberAxis xAxis = new NumberAxis(xAxisLabel); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(yAxisLabel); XYToolTipGenerator toolTipGenerator = null; if (tooltips) { toolTipGenerator = new StandardXYToolTipGenerator(); } XYURLGenerator urlGenerator = null; if (urls) { urlGenerator = new StandardXYURLGenerator(); } XYItemRenderer renderer = new XYStepAreaRenderer(XYStepAreaRenderer.AREA_AND_SHAPES, toolTipGenerator, urlGenerator); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null); plot.setRenderer(renderer); plot.setOrientation(orientation); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); return chart; }
From source file:desmoj.extensions.visualization2d.engine.modelGrafic.StatisticGrafic.java
/** * Build content for animationType StatisticGrafic.ANIMATION_Histogram * @return/*ww w . ja v a 2 s.c om*/ * @throws ModelException */ private JPanel buildHistogramPanel() throws ModelException { XIntervalSeriesCollection dataset = new XIntervalSeriesCollection(); dataset.addSeries(this.statistic.getHistogram()); this.chart = ChartFactory.createXYBarChart(null, "Observation", false, "Count", dataset, PlotOrientation.VERTICAL, false, true, false); this.chart.setBackgroundPaint(Grafic.COLOR_BACKGROUND); XYPlot plot = this.chart.getXYPlot(); plot.setBackgroundPaint(StatisticGrafic.DIAGRAM_BACKGROUND); plot.setDomainGridlinePaint(StatisticGrafic.DIAGRAM_GRID); plot.setRangeGridlinePaint(StatisticGrafic.DIAGRAM_GRID); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); ValueAxis rangeAxis = (ValueAxis) plot.getRangeAxis(); rangeAxis.setLabelFont(Grafic.FONT_DEFAULT); ValueAxis domainAxis = plot.getDomainAxis(); domainAxis.setLabelFont(Grafic.FONT_DEFAULT); domainAxis.setAutoRange(true); XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer(); renderer.setShadowVisible(false); renderer.setBarPainter(new StandardXYBarPainter()); renderer.setDrawBarOutline(true); renderer.setSeriesPaint(0, StatisticGrafic.DIAGRAM_FORGROUND); renderer.setSeriesOutlinePaint(0, StatisticGrafic.DIAGRAM_BORDER); renderer.setSeriesOutlineStroke(0, new BasicStroke(1.0f)); this.buildHistogramAxisFormat(plot, "Observations"); JPanel out = new ChartPanel(chart); out.setPreferredSize(new Dimension(350, 200)); return out; }
From source file:jchrest.gui.VisualSearchPane.java
private ChartPanel createPanel() { XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(_trainingTimes);/*from ww w . j av a 2s . c o m*/ JFreeChart chart = ChartFactory.createXYLineChart("Plot of network size vs. number of training patterns", "Number of training patterns", "Network size", dataset, org.jfree.chart.plot.PlotOrientation.VERTICAL, true, true, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); } return new ChartPanel(chart); }
From source file:com.android.ddmuilib.log.event.EventDisplay.java
Control createCompositeChart(final Composite parent, EventLogParser logParser, String title) { mChart = ChartFactory.createTimeSeriesChart(null, null /* timeAxisLabel */, null /* valueAxisLabel */, null, /* dataset. set below */ true /* legend */, false /* tooltips */, false /* urls */); // get the font to make a proper title. We need to convert the swt font, // into an awt font. Font f = parent.getFont();//from w w w . j a va 2 s . c o m FontData[] fData = f.getFontData(); // event though on Mac OS there could be more than one fontData, we'll only use // the first one. FontData firstFontData = fData[0]; java.awt.Font awtFont = SWTUtils.toAwtFont(parent.getDisplay(), firstFontData, true /* ensureSameSize */); mChart.setTitle(new TextTitle(title, awtFont)); final XYPlot xyPlot = mChart.getXYPlot(); xyPlot.setRangeCrosshairVisible(true); xyPlot.setRangeCrosshairLockedOnData(true); xyPlot.setDomainCrosshairVisible(true); xyPlot.setDomainCrosshairLockedOnData(true); mChart.addChangeListener(new ChartChangeListener() { @Override public void chartChanged(ChartChangeEvent event) { ChartChangeEventType type = event.getType(); if (type == ChartChangeEventType.GENERAL) { // because the value we need (rangeCrosshair and domainCrosshair) are // updated on the draw, but the notification happens before the draw, // we process the click in a future runnable! parent.getDisplay().asyncExec(new Runnable() { @Override public void run() { processClick(xyPlot); } }); } } }); mChartComposite = new ChartComposite(parent, SWT.BORDER, mChart, ChartComposite.DEFAULT_WIDTH, ChartComposite.DEFAULT_HEIGHT, ChartComposite.DEFAULT_MINIMUM_DRAW_WIDTH, ChartComposite.DEFAULT_MINIMUM_DRAW_HEIGHT, 3000, // max draw width. We don't want it to zoom, so we put a big number 3000, // max draw height. We don't want it to zoom, so we put a big number true, // off-screen buffer true, // properties true, // save true, // print true, // zoom true); // tooltips mChartComposite.addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { mValueTypeDataSetMap.clear(); mDataSetCount = 0; mOccurrenceDataSet = null; mChart = null; mChartComposite = null; mValueDescriptorSeriesMap.clear(); mOcurrenceDescriptorSeriesMap.clear(); } }); return mChartComposite; }
From source file:msi.gama.outputs.layers.charts.ChartJFreeChartOutputScatter.java
@Override public void initChart(final IScope scope, final String chartname) { super.initChart(scope, chartname); final XYPlot pp = (XYPlot) chart.getPlot(); pp.setDomainGridlinePaint(axesColor); pp.setRangeGridlinePaint(axesColor); pp.setDomainCrosshairPaint(axesColor); pp.setRangeCrosshairPaint(axesColor); pp.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); pp.setDomainCrosshairVisible(false); pp.setRangeCrosshairVisible(false);//from ww w. jav a 2 s.c om pp.getDomainAxis().setAxisLinePaint(axesColor); pp.getDomainAxis().setTickLabelFont(getTickFont()); pp.getDomainAxis().setLabelFont(getLabelFont()); if (textColor != null) { pp.getDomainAxis().setLabelPaint(textColor); pp.getDomainAxis().setTickLabelPaint(textColor); } NumberAxis axis = (NumberAxis) pp.getRangeAxis(); axis = formatYAxis(scope, axis); pp.setRangeAxis(axis); if (ytickunit > 0) { ((NumberAxis) pp.getRangeAxis()).setTickUnit(new NumberTickUnit(ytickunit)); pp.setRangeGridlinesVisible(true); } else pp.setRangeGridlinesVisible(GamaPreferences.Displays.CHART_GRIDLINES.getValue()); // resetAutorange(scope); if (getType() == ChartOutput.SERIES_CHART) { if (xlabel == null) xlabel = "time"; } if (getType() == ChartOutput.XY_CHART) { } if (getType() == ChartOutput.SCATTER_CHART) { } if (!this.getXTickValueVisible(scope)) { pp.getDomainAxis().setTickMarksVisible(false); pp.getDomainAxis().setTickLabelsVisible(false); } }
From source file:KIDLYFactory.java
/** * Creates a stepped XY plot with default settings. * * @param title the chart title (<code>null</code> permitted). * @param xAxisLabel a label for the X-axis (<code>null</code> permitted). * @param yAxisLabel a label for the Y-axis (<code>null</code> permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param orientation the plot orientation (horizontal or vertical) * (<code>null</code> NOT permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A chart.// ww w . j a v a2 s . c om */ public static JFreeChart createXYStepChart(String title, String xAxisLabel, String yAxisLabel, XYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } DateAxis xAxis = new DateAxis(xAxisLabel); NumberAxis yAxis = new NumberAxis(yAxisLabel); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); XYToolTipGenerator toolTipGenerator = null; if (tooltips) { toolTipGenerator = new StandardXYToolTipGenerator(); } XYURLGenerator urlGenerator = null; if (urls) { urlGenerator = new StandardXYURLGenerator(); } XYItemRenderer renderer = new XYStepRenderer(toolTipGenerator, urlGenerator); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null); plot.setRenderer(renderer); plot.setOrientation(orientation); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
From source file:KIDLYFactory.java
/** * Creates a filled stepped XY plot with default settings. * * @param title the chart title (<code>null</code> permitted). * @param xAxisLabel a label for the X-axis (<code>null</code> permitted). * @param yAxisLabel a label for the Y-axis (<code>null</code> permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param orientation the plot orientation (horizontal or vertical) * (<code>null</code> NOT permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A chart.//from w ww . j a va 2 s. c o m */ public static JFreeChart createXYStepAreaChart(String title, String xAxisLabel, String yAxisLabel, XYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } NumberAxis xAxis = new NumberAxis(xAxisLabel); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(yAxisLabel); XYToolTipGenerator toolTipGenerator = null; if (tooltips) { toolTipGenerator = new StandardXYToolTipGenerator(); } XYURLGenerator urlGenerator = null; if (urls) { urlGenerator = new StandardXYURLGenerator(); } XYItemRenderer renderer = new XYStepAreaRenderer(XYStepAreaRenderer.AREA_AND_SHAPES, toolTipGenerator, urlGenerator); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null); plot.setRenderer(renderer); plot.setOrientation(orientation); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }