List of usage examples for org.jfree.chart ChartPanel getChart
public JFreeChart getChart()
From source file:UI.MainViewPanel.java
public ChartPanel getPanel3(Metric3 m3) { int totalRiskCount = m3.totalCriticalCount + m3.totalLowCount; String[][] risks = new String[totalRiskCount][3]; RingChart ringChart = new RingChart(m3.totalCriticalCount, m3.totalHighCount, m3.totalMediumCount, m3.totalLowCount, "", risks); ChartPanel thisChart = ringChart.drawRingChart(); thisChart.setBackground(Color.white); JFreeChart chart = thisChart.getChart(); chart.setBackgroundPaint(Color.white); Plot plot = chart.getPlot();//from w w w.j a v a 2s. co m plot.setBackgroundPaint(chartBackgroundColor); return thisChart; }
From source file:UI.MainViewPanel.java
public ChartPanel getPanel6(Metric6 m6) { int totalRiskCount = m6.totalCriticalCount + m6.totalHighCount + m6.totalLowCount + m6.totalMediumCount; String[][] risks = new String[totalRiskCount][3]; RingChart ringChart = new RingChart(m6.totalCriticalCount, m6.totalHighCount, m6.totalMediumCount, m6.totalLowCount, "", risks); ringChart.lowValue = ("Low (" + m6.totalLowCount + ")"); ChartPanel thisChart = ringChart.drawRingChart(); thisChart.setBackground(Color.white); JFreeChart chart = thisChart.getChart(); chart.setBackgroundPaint(new Color(0, 0, 0, 0)); Plot plot = chart.getPlot();/*from w ww. j a va2 s. c o m*/ plot.setBackgroundPaint(chartBackgroundColor); return thisChart; }
From source file:org.jfree.chart.demo.selection.SelectionDemo2.java
/** * A demonstration application showing a scatter plot. * * @param title the frame title.//from w w w .j av a 2 s . com */ public SelectionDemo2(String title) { super(title); ChartPanel chartPanel = (ChartPanel) createDemoPanel(); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); JFreeChart chart = chartPanel.getChart(); XYPlot plot = (XYPlot) chart.getPlot(); this.dataset = (XYSeriesCollection) plot.getDataset(); JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); split.add(chartPanel); this.model = new DefaultTableModel(new String[] { "Series:", "Item:", "X:", "Y:" }, 0); this.table = new JTable(this.model); TableColumnModel tcm = this.table.getColumnModel(); tcm.getColumn(2).setCellRenderer(new NumberCellRenderer()); tcm.getColumn(3).setCellRenderer(new NumberCellRenderer()); JPanel p = new JPanel(new BorderLayout()); JScrollPane scroller = new JScrollPane(this.table); p.add(scroller); p.setBorder(BorderFactory.createCompoundBorder(new TitledBorder("Selected Items: "), new EmptyBorder(4, 4, 4, 4))); split.add(p); setContentPane(split); }
From source file:org.jfree.chart.demo.selection.SelectionDemo3.java
/** * A demonstration application showing a scatter plot. * * @param title the frame title.//from ww w . jav a2 s . c o m */ public SelectionDemo3(String title) { super(title); ChartPanel chartPanel = (ChartPanel) createDemoPanel(); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); JFreeChart chart = chartPanel.getChart(); XYPlot plot = (XYPlot) chart.getPlot(); this.dataset = (XYSeriesCollection) plot.getDataset(); JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); split.add(chartPanel); this.model = new DefaultTableModel(new String[] { "Series:", "Item:", "X:", "Y:" }, 0); this.table = new JTable(this.model); TableColumnModel tcm = this.table.getColumnModel(); tcm.getColumn(2).setCellRenderer(new NumberCellRenderer()); tcm.getColumn(3).setCellRenderer(new NumberCellRenderer()); JPanel p = new JPanel(new BorderLayout()); JScrollPane scroller = new JScrollPane(this.table); p.add(scroller); p.setBorder(BorderFactory.createCompoundBorder(new TitledBorder("Selected Items: "), new EmptyBorder(4, 4, 4, 4))); split.add(p); setContentPane(split); }
From source file:net.sf.maltcms.common.charts.ui.XYChartTopComponent.java
private void customizeChart(ChartPanel customPanel) { ChartCustomizer.setSeriesColors(customPanel.getChart().getXYPlot(), 0.5f); ChartCustomizer.setSeriesStrokes(customPanel.getChart().getXYPlot(), 2.0f); }
From source file:net.sf.maltcms.common.charts.ui.CategoryChartTopComponent.java
private void createChartPanel(final CategoryChartBuilder cb, final ACategoryDataset<?, TARGET> dataset, final InstanceContent content) { content.add(dataset);/*from ww w . j a va2s . c om*/ ChartPanel customPanel = cb.buildPanel(); SelectionOverlay so = new SelectionOverlay(Color.RED, Color.BLUE, 1.75f, 1.75f, 0.66f); customPanel.getChart().getCategoryPlot().getRangeAxis().addChangeListener(so); customPanel.getChart().getCategoryPlot().getDomainAxis().addChangeListener(so); InstanceContentSelectionHandler selectionHandler = new InstanceContentSelectionHandler(content, so, InstanceContentSelectionHandler.Mode.ON_CLICK, dataset); CategoryMouseSelectionHandler<TARGET> sl = new CategoryMouseSelectionHandler<>(dataset); sl.addSelectionChangeListener(so); sl.addSelectionChangeListener(selectionHandler); customPanel.addChartMouseListener(sl); customPanel.addOverlay(so); so.addChangeListener(customPanel); customizeChart(customPanel); content.add(customPanel); content.add(selectionHandler); content.add(sl); }
From source file:org.jfree.chart.demo.selection.SelectionDemo1.java
/** * A demonstration application showing how to create a simple time series * chart. This example uses monthly data. * //from w ww . ja va 2 s. com * @param title the frame title. */ public SelectionDemo1(String title) { super(title); ChartPanel chartPanel = (ChartPanel) createDemoPanel(); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); JFreeChart chart = chartPanel.getChart(); XYPlot plot = (XYPlot) chart.getPlot(); this.dataset = (TimeSeriesCollection) plot.getDataset(); JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); split.add(chartPanel); this.model = new DefaultTableModel(new String[] { "Series:", "Item:", "Period:", "Value:" }, 0); this.table = new JTable(this.model); TableColumnModel tcm = this.table.getColumnModel(); tcm.getColumn(3).setCellRenderer(new NumberCellRenderer()); JPanel p = new JPanel(new BorderLayout()); JScrollPane scroller = new JScrollPane(this.table); p.add(scroller); p.setBorder(BorderFactory.createCompoundBorder(new TitledBorder("Selected Items: "), new EmptyBorder(4, 4, 4, 4))); split.add(p); setContentPane(split); }
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);/*from w ww . j a v a2 s . com*/ 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:techtonic.Techtonic.java
public static void setDisplayArea(ChartPanel cp) { displayAreaPanel1.removeAll();//from ww w . j ava 2s.co m displayAreaPanel1.setLayout(new java.awt.BorderLayout()); cp.getChart().getXYPlot().getRangeAxis().setInverted(true); displayAreaPanel1.add(cp, BorderLayout.CENTER); displayAreaPanel1.validate(); displayAreaPanel1.repaint(); }
From source file:net.sourceforge.processdash.ev.ui.chart.AbstractEVChart.java
public void writeChartAsHtml(Writer out, Map environment, Map parameters) throws IOException { Map htmlEnv = new HashMap(environment); htmlEnv.put(EVSnippetEnvironment.HTML_OUTPUT_KEY, Boolean.TRUE); D dataset = createDataset(htmlEnv, parameters); ChartPanel chartPanel = buildChart(dataset, htmlEnv, parameters); JFreeChart chart = chartPanel.getChart(); if (chart != null) { new HtmlWriter(out, parameters, chart).writeChartHtml(); }//from w ww . j a v a 2 s . c om }