List of usage examples for org.jfree.chart.plot XYPlot getDomainAxis
public ValueAxis getDomainAxis()
From source file:ws.moor.bt.gui.charts.RemotePeerCompletion.java
private JFreeChart createChart(HistogramDataset dataset) { JFreeChart chart = ChartFactory.createHistogram("Remote Peer Completion", "Completion %", "Peers", dataset, PlotOrientation.VERTICAL, false, false, false); chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); 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.setRangeCrosshairVisible(true); plot.getDomainAxis().setAutoRange(false); plot.getDomainAxis().setRange(0.0, 100.0); return chart; }
From source file:de.perdian.apps.dashboard.support.chart.ChartCreator.java
public JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createXYLineChart(this.getTitle(), null, null, dataset, PlotOrientation.VERTICAL, false, false, false); chart.setBackgroundPaint(null);/*from w w w.j av a 2 s. c o m*/ chart.setBackgroundImageAlpha(0.0f); if (chart.getTitle() != null) { chart.getTitle().setFont(new Font(this.getFontName(), Font.BOLD, 14)); } XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(null); plot.setBackgroundAlpha(0.0f); plot.setOutlinePaint(this.getColor()); plot.getDomainAxis().setVisible(false); plot.getDomainAxis().setAxisLineVisible(false); plot.getDomainAxis().setMinorTickCount(10); plot.getDomainAxis().setTickMarksVisible(false); if (this.getDomainTickUnits() != null) { plot.getDomainAxis().setStandardTickUnits(this.getDomainTickUnits()); } plot.getRangeAxis().setVisible(true); plot.getRangeAxis().setAxisLineVisible(false); plot.getRangeAxis().setTickLabelFont(new Font(this.getFontName(), Font.PLAIN, 10)); plot.getRangeAxis().setTickLabelPaint(this.getColor()); plot.getRangeAxis().setTickMarksVisible(false); if (this.getRangeTickUnits() != null) { plot.getRangeAxis().setStandardTickUnits(this.getRangeTickUnits()); } plot.getRangeAxis().setAttributedLabel(this.getRangeAxisLabel()); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); for (int i = 0; i < this.getStrokeDefinitions().size(); i++) { ChartStrokeDefinition strokeDefinition = this.getStrokeDefinitions().get(i); strokeDefinition.applyTo(renderer, i); } return chart; }
From source file:org.nees.rpi.vis.ui.ProfilePlotFrame.java
private void initChartArea() { JFreeChart chart;/*from w ww. j a v a 2 s .c o m*/ xyDataset = new XYSeriesCollection(); chart = ChartFactory.createXYLineChart(null, "Sensor Reading", "Sensor Depth", xyDataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.WHITE); XYPlot plot = (XYPlot) chart.getPlot(); plot.getDomainAxis().setAutoRange(false); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setShapesVisible(true); renderer.setShapesFilled(true); chartPanel = new ChartPanel(chart); chartPanel.setFillZoomRectangle(true); chartPanel.setHorizontalAxisTrace(true); chartPanel.setVerticalAxisTrace(true); chartPanel.setOpaque(false); VisSaveJChartPlotToImageButton saveButton = new VisSaveJChartPlotToImageButton(this, chart); JPanel buttonArea = new JPanel(); buttonArea.setOpaque(false); buttonArea.setLayout(new FlowLayout(FlowLayout.LEFT)); buttonArea.setBorder(BorderFactory.createEmptyBorder(3, 3, 0, 3)); buttonArea.add(saveButton); JPanel chartArea = new JPanel(); chartArea.setOpaque(false); chartArea.setLayout(new BorderLayout()); chartArea.add(chartPanel, BorderLayout.CENTER); chartArea.add(buttonArea, BorderLayout.NORTH); contentPane.add(chartArea, BorderLayout.CENTER); }
From source file:com.mxgraph.examples.swing.chart.TimeSeriesChartDemo1.java
/** * Creates a chart.// ww w. j ava 2s . c o m * * @param dataset a dataset. * * @return A chart. */ public static JFreeChart createChart(XYDataset dataset, String name) { JFreeChart chart = ChartFactory.createTimeSeriesChart(name, // title "Date", // x-axis label "Value", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); 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); renderer.setItemLabelGenerator(new StandardXYItemLabelGenerator()); renderer.setBaseItemLabelsVisible(true); // renderer.setItemLabelsVisible(true); // renderer.setBaseShapesVisible(true); // renderer.setBaseShapesFilled(true); // renderer.setLegendItemLabelGenerator(new StandardPieSectionLabelGenerator("{0}={1}({2})")); } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss"/*"yyyy-MM-dd HH:mm:ss"*/)); chart.getTitle().setFont(new Font("", Font.BOLD, 15)); chart.getLegend().setItemFont(new Font("", Font.BOLD, 15)); // plot.getRangeAxis().setLabelFont(new Font("", Font.BOLD, 15)); // chart.getLegend().setItemFont(new Font("", Font.ITALIC, 15)); // plot.getDomainAxis().setTickLabelFont(new Font("", 1, 15)); // plot.getDomainAxis().setLabelFont(new Font("", 1, 12)); return chart; }
From source file:org.jfree.chart.demo.XYTickLabelDemo.java
/** * A demonstration application showing some bugs with tick labels in version 0.9.13 * * @param title the frame title./* ww w .j a va 2 s . c o m*/ */ public XYTickLabelDemo(final String title) { super(title); this.chart = createChart(); final ChartPanel chartPanel = new ChartPanel(this.chart); chartPanel.setPreferredSize(new java.awt.Dimension(600, 270)); final JPanel mainPanel = new JPanel(new BorderLayout()); setContentPane(mainPanel); mainPanel.add(chartPanel); final JPanel optionsPanel = new JPanel(); mainPanel.add(optionsPanel, BorderLayout.SOUTH); this.symbolicAxesCheckBox = new JCheckBox("Symbolic axes"); this.symbolicAxesCheckBox.addActionListener(this); optionsPanel.add(this.symbolicAxesCheckBox); this.verticalTickLabelsCheckBox = new JCheckBox("Tick labels vertical"); this.verticalTickLabelsCheckBox.addActionListener(this); optionsPanel.add(this.verticalTickLabelsCheckBox); this.fontSizeTextField = new JTextField(3); this.fontSizeTextField.addActionListener(this); optionsPanel.add(new JLabel("Font size:")); optionsPanel.add(this.fontSizeTextField); final ValueAxis axis = this.chart.getXYPlot().getDomainAxis(); this.fontSizeTextField.setText(DEFAULT_FONT_SIZE + ""); final XYPlot plot = this.chart.getXYPlot(); Font ft = axis.getTickLabelFont(); ft = ft.deriveFont((float) DEFAULT_FONT_SIZE); plot.getDomainAxis().setTickLabelFont(ft); plot.getRangeAxis().setTickLabelFont(ft); plot.getDomainAxis(1).setTickLabelFont(ft); plot.getRangeAxis(1).setTickLabelFont(ft); this.horizontalPlotCheckBox = new JCheckBox("Plot horizontal"); this.horizontalPlotCheckBox.addActionListener(this); optionsPanel.add(this.horizontalPlotCheckBox); }
From source file:org.n52.io.img.ChartRenderer.java
private void configureTimeAxis(XYPlot xyPlot) { String timespan = getChartStyleDefinitions().getTimespan(); DateAxis timeAxis = (DateAxis) xyPlot.getDomainAxis(); timeAxis.setRange(getStartTime(timespan), getEndTime(timespan)); timeAxis.setDateFormatOverride(new SimpleDateFormat()); }
From source file:org.n52.io.type.quantity.handler.img.ChartIoHandler.java
private void configureTimeAxis(XYPlot plot) { DateAxis timeAxis = (DateAxis) plot.getDomainAxis(); final Date start = getStartTime(getTimespan()); final Date end = getEndTime(getTimespan()); timeAxis.setRange(start, end);/*from ww w .j a va 2 s.co m*/ final Locale locale = i18n.getLocale(); IoParameters parameters = getParameters(); String timeformat = parameters.getTimeFormat(); DateFormat requestTimeFormat = new SimpleDateFormat(timeformat, locale); final DateTimeZone timezone = getTimezone(); requestTimeFormat.setTimeZone(timezone.toTimeZone()); timeAxis.setDateFormatOverride(requestTimeFormat); timeAxis.setTimeZone(timezone.toTimeZone()); }
From source file:test.integ.be.fedict.performance.util.PerformanceResultDialog.java
private JFreeChart getMemoryChart(int intervalSize, List<MemoryData> memory) { if (null == memory || memory.isEmpty()) { return null; }/*from ww w . j a va2 s .c o m*/ JFreeChart chart; TimeSeries freeSeries = new TimeSeries("Free"); TimeSeries maxSeries = new TimeSeries("Max"); TimeSeries totalSeries = new TimeSeries("Total"); memory.remove(memory.size() - 1); for (MemoryData memoryEntry : memory) { freeSeries.add(new Second(memoryEntry.getDate()), memoryEntry.getFreeMemory()); maxSeries.add(new Second(memoryEntry.getDate()), memoryEntry.getMaxMemory()); totalSeries.add(new Second(memoryEntry.getDate()), memoryEntry.getTotalMemory()); } TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(freeSeries); dataset.addSeries(maxSeries); dataset.addSeries(totalSeries); chart = ChartFactory.createTimeSeriesChart("eID Trust Service Memory Usage History", "Time (interval size " + intervalSize + " msec)", "Memory", dataset, true, false, false); chart.addSubtitle(new TextTitle( memory.get(0).getDate().toString() + " - " + memory.get(memory.size() - 1).getDate().toString())); chart.setBackgroundPaint(Color.WHITE); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss")); ValueAxis valueAxis = plot.getRangeAxis(); valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); plot.setRangeGridlinePaint(Color.black); plot.setDomainGridlinePaint(Color.black); plot.setRenderer(renderer); return chart; }
From source file:com.haskins.cloudtrailviewer.feature.MetricsFeature.java
@Override public void chartMouseMoved(ChartMouseEvent event) { Rectangle2D dataArea = this.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); this.xCrosshair.setValue(x); }
From source file:io.github.mzmine.modules.plots.chromatogram.ChromatogramPlotWindowController.java
public void handleZoomOut(Event e) { XYPlot plot = chartNode.getChart().getXYPlot(); plot.getDomainAxis().setAutoRange(true); plot.getRangeAxis().setAutoRange(true); }