List of usage examples for org.jfree.chart.plot XYPlot getDomainAxis
public ValueAxis getDomainAxis()
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:eu.stratosphere.addons.visualization.swt.SWTInstanceToolTip.java
private ChartComposite createCPUChart(InstanceVisualizationData instanceVisualizationData, Color backgroundColor) {//from ww w .ja v a2 s .c o 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) {//from w w w .j a v a2 s . c o 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:eu.stratosphere.addons.visualization.swt.SWTInstanceToolTip.java
private ChartComposite createNetworkChart(InstanceVisualizationData instanceVisualizationData, Color backgroundColor) {/*from w ww . j av a 2 s.c o m*/ final JFreeChart chart = ChartFactory.createStackedXYAreaChart(null, "Time [sec.]", "Network", instanceVisualizationData.getNetworkDataSet(), 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); // TODO: Repair auto range for range axis xyPlot.getRangeAxis().setAutoRange(false); xyPlot.getRangeAxis().setRange(0, 4096); return new ChartComposite(getShell(), SWT.NONE, chart, true); }
From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.MultiAxesCrosshairOverlay.java
@Override public void paintOverlay(Graphics2D g2, ChartPanel chartPanel) { Shape savedClip = g2.getClip(); Rectangle2D dataArea = chartPanel.getScreenDataArea(); g2.clip(dataArea);//ww w .ja va2s.c om JFreeChart chart = chartPanel.getChart(); XYPlot plot = (XYPlot) chart.getPlot(); ValueAxis xAxis = plot.getDomainAxis(); RectangleEdge xAxisEdge = plot.getDomainAxisEdge(); Iterator iterator = this.getDomainCrosshairs().iterator(); while (iterator.hasNext()) { Crosshair ch = (Crosshair) iterator.next(); if (ch.isVisible()) { double x = ch.getValue(); double xx = xAxis.valueToJava2D(x, dataArea, xAxisEdge); if (plot.getOrientation() == PlotOrientation.VERTICAL) { drawVerticalCrosshair(g2, dataArea, xx, ch); } else { drawHorizontalCrosshair(g2, dataArea, xx, ch); } } } int rangeAxisIdx = 0; for (ArrayList<Crosshair> crosshairsForRange : rangeCrosshairs) { ValueAxis yAxis = plot.getRangeAxis(rangeAxisIdx); RectangleEdge yAxisEdge = plot.getRangeAxisEdge(rangeAxisIdx); iterator = crosshairsForRange.iterator(); while (iterator.hasNext()) { Crosshair ch = (Crosshair) iterator.next(); if (ch.isVisible()) { double y = ch.getValue(); double yy = yAxis.valueToJava2D(y, dataArea, yAxisEdge); if (plot.getOrientation() == PlotOrientation.VERTICAL) { drawHorizontalCrosshair(g2, dataArea, yy, ch); } else { drawVerticalCrosshair(g2, dataArea, yy, ch); } } } g2.setClip(savedClip); ++rangeAxisIdx; } }
From source file:pharoslabut.logger.CompassLoggerGUI.java
/** * Creates a new demo./*from w w w . java 2 s.c o m*/ * * @param title the frame title. */ public CompassLoggerGUI(final String title) { super(title); final XYDataset dataset = createDataset(); final JFreeChart chart = createChart(dataset); final XYPlot plot = chart.getXYPlot(); ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); axis.setFixedAutoRange(60); // 60 seconds final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); // new Thread(new ChartUpdater(chart.getXYPlot())).start(); }
From source file:org.fhcrc.cpl.toolbox.gui.chart.ChartMouseAndMotionListener.java
public ChartMouseAndMotionListener(PanelWithChart panelWithChart) { _chartPanel = panelWithChart.getChartPanel(); XYPlot p = _chartPanel.getChart().getXYPlot(); domainAxis = (NumberAxis) p.getDomainAxis(); rangeAxis = (NumberAxis) p.getRangeAxis(); }
From source file:org.yccheok.jstock.gui.charting.DynamicChart.java
/** Creates new form DynamicChart */ public DynamicChart() { this.price = new TimeSeries("Price"); // Sets the maximumItemAge attribute, which specifies the maximum age of data items in the series // (in terms of the RegularTimePeriod type used by this series). Whenever a new data value is // added, any data items that are older than the limit specified by maximumItemAge are automatically // discarded//from w ww . j a v a 2 s . com // Maximum 2 hours. this.price.setMaximumItemAge(2 * 60 * 60); TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(this.price); JFreeChart freeChart = ChartFactory.createTimeSeriesChart(null, null, null, dataset, false, true, false); freeChart.setAntiAlias(true); while (freeChart.getSubtitleCount() > 0) { freeChart.removeSubtitle(freeChart.getSubtitle(0)); } // Due to limited spacing, we remove all information regarding x and y axis // as well. XYPlot plot = freeChart.getXYPlot(); plot.getRangeAxis().setVisible(false); plot.getDomainAxis().setVisible(false); XYItemRenderer renderer1 = plot.getRenderer(); renderer1.setBaseToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("h:mm:ss a"), new DecimalFormat("0.00#"))); org.yccheok.jstock.charting.Utils.applyChartTheme(freeChart); // Disable zoom. chartPanel = new ChartPanel(freeChart, true, true, true, false, true); chartPanel.setMouseZoomable(false); }
From source file:edu.utexas.ece.pharos.proteus3.sensors.CompassChartGUI.java
/** * Creates a new demo./*from w w w . j a v a 2 s . co m*/ * * @param title the frame title. */ public CompassChartGUI(final String title) { super(title); final XYDataset dataset = createDataset(); final JFreeChart chart = createChart(dataset); final XYPlot plot = chart.getXYPlot(); ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); axis.setFixedAutoRange(60); // 60 seconds final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); // new Thread(new ChartUpdater(chart.getXYPlot())).start(); }
From source file:com.hello2morrow.sonargraph.jenkinsplugin.model.TimeSeriesPlot.java
@Override protected void applyRendering(XYPlot plot) { DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(StringUtility.getDateFormat()); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(false); renderer.setSeriesPaint(0, DATA_COLOR); if (m_markerTimestamp > 0) { final Marker target = new ValueMarker(m_markerTimestamp); target.setPaint(Color.RED); target.setLabel("Short Term"); if ((m_markerPosition * 2) > getDatasetSize()) { //Move the label to the left of the marker target.setLabelAnchor(RectangleAnchor.TOP_RIGHT); target.setLabelTextAnchor(TextAnchor.TOP_LEFT); } else {/*from ww w . j a va2 s . co m*/ target.setLabelAnchor(RectangleAnchor.TOP_LEFT); target.setLabelTextAnchor(TextAnchor.TOP_RIGHT); } plot.addDomainMarker(target); } }