List of usage examples for org.jfree.chart JFreeChart JFreeChart
public JFreeChart(Plot plot)
From source file:org.qsos.radar.GenerateRadar.java
/** * This class creates a composite in which the radar char will be * implemented//w w w . j a v a 2 s.co m * * @param parent * Composite where the chart will be seen * @param Categories * String[] that contains the name of the elements [4 min and 7 max] the user has chosen to visualize * @param Scores * Double[] that contains the average score of each category * @return Control * */ public static Control createChart(Composite parent, String[] Categories, double[] Scores) { Composite Charcomposite = new Composite(parent, SWT.EMBEDDED); Charcomposite.setLayout(new FillLayout()); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); // for (int i = 0; i < CatNumber; i++) { dataset.addValue(Scores[i], getTitle(), Categories[i]); } String BackGroundMire = null; //Configuration of the spiderwebplot SpiderWebPlot plot = new SpiderWebPlot(); plot.setDataset(dataset); plot.setMaxValue(JQConst.RADAR_MAX_VALUE); plot.setSeriesPaint(JQConst.RADAR_SERIES_PAINT); plot.setAxisLabelGap(JQConst.RADAR_AXIS_LABEL_GAP); plot.setHeadPercent(JQConst.RADAR_HEAD_PERCENT); plot.setInteriorGap(JQConst.RADAR_INTERIOR_GAP); plot.setWebFilled(true); //The backgroundpicture used as a spiderweb is chosen according to the //number of categories selected switch (CatNumber) { case 4: BackGroundMire = JQConst.RADAR_SPIDERWEB_4; break; case 5: BackGroundMire = JQConst.RADAR_SPIDERWEB_5; break; case 6: BackGroundMire = JQConst.RADAR_SPIDERWEB_6; break; case 7: BackGroundMire = JQConst.RADAR_SPIDERWEB_7; break; } javax.swing.ImageIcon icon = new javax.swing.ImageIcon(BackGroundMire); plot.setBackgroundImage(icon.getImage()); //chart creation JFreeChart chart = new JFreeChart(plot); //Here the background color from the shell is taken in order to match AWT and SWT backgrounds Color backgroundColor = parent.getBackground(); //JFreechart doesn't support SWT so we create an AWT Frame that will depend on Charcomposite java.awt.Frame chartPanel = SWT_AWT.new_Frame(Charcomposite); chartPanel.setLayout(new java.awt.GridLayout()); ChartPanel jfreeChartPanel = new ChartPanel(chart); chartPanel.setBackground(new java.awt.Color(backgroundColor.getRed(), backgroundColor.getGreen(), backgroundColor.getBlue())); chartPanel.add(jfreeChartPanel); chartPanel.pack(); return parent; }
From source file:it.alus.GPSreceiver.instruments.Turnometer.java
public Turnometer() { super(null);/* w w w . ja va 2 s. co m*/ dataset = new DefaultValueDataset(0.0); DialPlot plot = new DialPlot(); plot.setView(0.0, 0.0, 1.0, 1.0); plot.setDataset(0, dataset); StandardDialFrame dialFrame = new StandardDialFrame(); dialFrame.setBackgroundPaint(Color.lightGray); dialFrame.setForegroundPaint(Color.gray); //DialTextAnnotation titleLabel = new DialTextAnnotation("Vertical speed"); //titleLabel.setFont(new Font("Arial",1,18)); //titleLabel.setRadius(0.45D); //titleLabel.setAngle(90); //titleLabel.setPaint(Color.lightGray); //plot.addLayer(titleLabel); DialTextAnnotation L = new DialTextAnnotation("L"); L.setFont(new Font("Arial", Font.BOLD, 30)); L.setRadius(0.4); L.setPaint(Color.white); L.setAngle(200); plot.addLayer(L); DialTextAnnotation R = new DialTextAnnotation("R"); R.setFont(new Font("Arial", Font.BOLD, 30)); R.setRadius(0.4); R.setPaint(Color.white); R.setAngle(-20); plot.addLayer(R); DialValueIndicator valueindicator = new DialValueIndicator(0); plot.addLayer(valueindicator); DialTextAnnotation annotation = new DialTextAnnotation("deg/min"); annotation.setFont(new Font("Arial", 1, 14)); annotation.setRadius(0.4D); annotation.setPaint(Color.lightGray); plot.addLayer(annotation); plot.setDialFrame(dialFrame); StandardDialScale scale = new StandardDialScale(-540, 540, -135, -270, 90, 9); scale.setMajorTickPaint(Color.white); scale.setMinorTickPaint(Color.lightGray); scale.setFirstTickLabelVisible(true); scale.setTickRadius(0.88); scale.setTickLabelOffset(0.15); NumberFormat formatter = new DecimalFormat("#"); scale.setTickLabelFormatter(formatter); scale.setTickLabelFont(new Font("Arial", Font.BOLD, 24)); scale.setTickLabelPaint(Color.white); plot.addScale(0, scale); plot.setBackground(new DialBackground(Color.black)); Pointer needle = new Pointer(0); needle.setFillPaint(Color.white); plot.addLayer(needle); plot.mapDatasetToScale(1, 1); DialCap cap = new DialCap(); cap.setRadius(0.10); cap.setFillPaint(Color.gray); plot.setCap(cap); jChart = new JFreeChart(plot); super.setChart(jChart); super.setPreferredSize(new Dimension(400, 400)); }
From source file:it.alus.GPSreceiver.instruments.Variometer.java
public Variometer() { super(null);/*ww w. j a v a2 s .co m*/ dataset = new DefaultValueDataset(0.0); DialPlot plot = new DialPlot(); plot.setView(0.0, 0.0, 1.0, 1.0); plot.setDataset(0, dataset); StandardDialFrame dialFrame = new StandardDialFrame(); dialFrame.setBackgroundPaint(Color.lightGray); dialFrame.setForegroundPaint(Color.gray); DialTextAnnotation titleLabel = new DialTextAnnotation("Vertical speed"); titleLabel.setFont(new Font("Arial", 1, 18)); titleLabel.setRadius(0.45D); titleLabel.setAngle(90); titleLabel.setPaint(Color.lightGray); plot.addLayer(titleLabel); DialTextAnnotation unitLabel = new DialTextAnnotation("100 Ft/min"); unitLabel.setFont(new Font("Arial", 1, 18)); unitLabel.setRadius(0.3D); unitLabel.setAngle(90); unitLabel.setPaint(Color.white); plot.addLayer(unitLabel); DialValueIndicator valueindicator = new DialValueIndicator(0); plot.addLayer(valueindicator); DialTextAnnotation annotation = new DialTextAnnotation("Ft/min"); annotation.setFont(new Font("Arial", 1, 14)); annotation.setRadius(0.4D); annotation.setPaint(Color.lightGray); plot.addLayer(annotation); plot.setDialFrame(dialFrame); StandardDialScale realScale = new StandardDialScale(-3000, 3000, -10, -340, 100, 10); realScale.setVisible(false); plot.addScale(0, realScale); StandardDialScale dispScale = new StandardDialScale(-30, 30, -10, -340, 5, 10); dispScale.setMajorTickPaint(Color.white); dispScale.setMinorTickPaint(Color.lightGray); dispScale.setFirstTickLabelVisible(true); dispScale.setTickRadius(0.88); dispScale.setTickLabelOffset(0.15); NumberFormat formatter = new DecimalFormat("#"); dispScale.setTickLabelFormatter(formatter); dispScale.setTickLabelFont(new Font("Arial", Font.BOLD, 24)); dispScale.setTickLabelPaint(Color.white); plot.addScale(1, dispScale); plot.setBackground(new DialBackground(Color.black)); Pointer needle = new Pointer(0); needle.setFillPaint(Color.white); plot.addLayer(needle); plot.mapDatasetToScale(1, 1); DialCap cap = new DialCap(); cap.setRadius(0.10); cap.setFillPaint(Color.gray); plot.setCap(cap); jChart = new JFreeChart(plot); super.setChart(jChart); super.setPreferredSize(new Dimension(400, 400)); }
From source file:de.bund.bfr.knime.pmmlite.views.chart.ChartCreator.java
public ChartCreator(Map<String, Plotable> plotables, Map<String, String> legend) { this.plotables = plotables; this.legend = legend; colors = new LinkedHashMap<>(); shapes = new LinkedHashMap<>(); colorLists = new LinkedHashMap<>(); shapeLists = new LinkedHashMap<>(); chartPanel = new ChartPanel(new JFreeChart(new XYPlot())) { private static final long serialVersionUID = 1L; @Override//w w w. j av a2s . c o m public void mouseReleased(MouseEvent e) { ValueAxis domainAxis = ((XYPlot) getChart().getPlot()).getDomainAxis(); ValueAxis rangeAxis = ((XYPlot) getChart().getPlot()).getRangeAxis(); Range xRange1 = domainAxis.getRange(); Range yRange1 = rangeAxis.getRange(); super.mouseReleased(e); Range xRange2 = domainAxis.getRange(); Range yRange2 = rangeAxis.getRange(); if (!xRange1.equals(xRange2) || !yRange1.equals(yRange2)) { minX = xRange2.getLowerBound(); maxX = xRange2.getUpperBound(); minY = yRange2.getLowerBound(); maxY = yRange2.getUpperBound(); fireZoomChanged(); } } }; chartPanel.getPopupMenu().removeAll(); setLayout(new BorderLayout()); add(chartPanel, BorderLayout.CENTER); }
From source file:inflor.core.plots.DensityPlot.java
@Override public JFreeChart createChart(FCSFrame data, TransformSet transforms) { Optional<FCSDimension> domainDimension = FCSUtilities.findCompatibleDimension(data, spec.getDomainAxisName());//from w ww . j a v a2s. co m Optional<FCSDimension> rangeDimension = FCSUtilities.findCompatibleDimension(data, spec.getRangeAxisName()); if (domainDimension.isPresent() && rangeDimension.isPresent()) { AbstractTransform domainTransform = transforms.get(domainDimension.get().getShortName()); double[] domainData = domainTransform.transform(domainDimension.get().getData()); double domainMin = domainTransform.getMinTranformedValue(); double domainMax = domainTransform.getMaxTransformedValue(); AbstractTransform rangeTransform = transforms.get(rangeDimension.get().getShortName()); double[] rangeData = rangeTransform.transform(rangeDimension.get().getData()); double rangeMin = rangeTransform.getMinTranformedValue(); double rangeMax = rangeTransform.getMaxTransformedValue(); histogram = new Histogram2D(domainData, domainMin, domainMax, rangeData, rangeMin, rangeMax); DefaultXYZDataset plotData = new DefaultXYZDataset(); BitSet nonEmptyMask = histogram.getNonEmptyBins(); double[] x = FCSUtilities.filterColumn(nonEmptyMask, histogram.getXBins()); double[] y = FCSUtilities.filterColumn(nonEmptyMask, histogram.getYBins()); double[] z = FCSUtilities.filterColumn(nonEmptyMask, histogram.getZValues()); plotData.addSeries(data.toString(), new double[][] { x, y, z }); XYBlockRenderer renderer = updateRenderer(histogram); plot = new XYPlot(); // Create the plot plot.setDataset(plotData); plot.setDomainAxis(PlotUtils.createAxis(domainDimension.get().getDisplayName(), domainTransform)); plot.setRangeAxis(PlotUtils.createAxis(rangeDimension.get().getDisplayName(), rangeTransform)); plot.setRenderer(renderer); // Add to panel. JFreeChart chart = new JFreeChart(plot); chart.removeLegend(); return chart; } else { return null; } }
From source file:ui.results.ResultChartPanel.java
/** * Construct new Result panel//from w w w .j a v a 2s.c o m */ public ResultChartPanel() { // The charting objects dataset = new DefaultStatisticalCategoryDataset(); upper = new DefaultCategoryDataset(); lower = new DefaultCategoryDataset(); // The Renderers lineRenderer0 = new LineAndShapeRenderer(); lineRenderer1 = new LineAndShapeRenderer(); lineRenderer2 = new LineAndShapeRenderer(); lineRenderer0.setSeriesPaint(0, lowerColor); lineRenderer1.setSeriesPaint(0, mspColor); lineRenderer2.setSeriesPaint(0, upperColor); lineRenderer0.setSeriesShapesVisible(0, false); lineRenderer1.setSeriesShapesVisible(0, false); lineRenderer2.setSeriesShapesVisible(0, false); barRenderer = new StatisticalBarRenderer(); barRenderer.setSeriesPaint(0, mspColor); // The Plot: begin as a line plot CategoryPlot plot = new CategoryPlot(); plot.setDomainAxis(new CategoryAxis("Datasets")); plot.setRangeAxis(new NumberAxis("MSP")); plot.setRenderer(0, lineRenderer0); plot.setRenderer(1, lineRenderer1); plot.setRenderer(2, lineRenderer2); plot.setDataset(0, lower); plot.setDataset(1, dataset); plot.setDataset(2, upper); // Adding the new plot chart = new JFreeChart(plot); panel = new ChartPanel(chart); // Listening to changes //dataset.addChangeListener(chart.getPlot()); chart.getPlot().addChangeListener(chart); chart.addChangeListener(panel); ((CategoryPlot) chart.getPlot()).getRangeAxis().setAutoRange(true); // Choice panel: choicing between line and bar chart JPanel choicePanel = createChoicePanel(); // Doing the interface setLayout(new BorderLayout()); add(choicePanel, BorderLayout.NORTH); add(panel, BorderLayout.CENTER); setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Chart")); // size stuff //setPreferredSize(new Dimension(500, 400)); }
From source file:nextapp.echo.chart.testapp.testscreen.PieChartTest.java
public PieChartTest() { super(SplitPane.ORIENTATION_HORIZONTAL, new Extent(250, Extent.PX)); setStyleName("DefaultResizable"); ButtonColumn controlsColumn = new ButtonColumn(); controlsColumn.setStyleName("TestControlsColumn"); add(controlsColumn);//from ww w . j a va 2 s .co m DefaultKeyedValues values = new DefaultKeyedValues(); values.addValue("Widgets", 500.2); values.addValue("Cubits", 216.0); values.addValue("Zonkits", 125.9); final DefaultPieDataset pieDataset = new DefaultPieDataset(new DefaultPieDataset(values)); PiePlot piePlot = new PiePlot(pieDataset); piePlot.setToolTipGenerator(new StandardPieToolTipGenerator()); final ChartDisplay chartDisplay = new ChartDisplay(piePlot); add(chartDisplay); chartDisplay.setActionCommands(new String[] { "Widgets", "Cubits", "Zonkits" }); chartDisplay.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { WindowPane window = new WindowPane("Chart series clicked", new Extent(300), new Extent(200)); window.add(new Label("You clicked on " + arg0.getActionCommand())); Component contentPane = getParent(); while (!(contentPane instanceof ContentPane)) { contentPane = contentPane.getParent(); } contentPane.add(window); } }); ChartPanel chartPanel = new ChartPanel(new JFreeChart(piePlot)); chartPanel.setRefreshBuffer(true); ChartEntity entity = chartPanel.getEntityForPoint(50, 50); System.out.println("Entity: " + entity); controlsColumn.addButton("Set Width = 800px", new ActionListener() { public void actionPerformed(ActionEvent e) { synchronized (chartDisplay) { chartDisplay.setWidth(new Extent(800)); } } }); controlsColumn.addButton("Set Width = null", new ActionListener() { public void actionPerformed(ActionEvent e) { synchronized (chartDisplay) { chartDisplay.setWidth(null); } } }); controlsColumn.addButton("Set Height = 600px", new ActionListener() { public void actionPerformed(ActionEvent e) { synchronized (chartDisplay) { chartDisplay.setHeight(new Extent(600)); } } }); controlsColumn.addButton("Set Height = null", new ActionListener() { public void actionPerformed(ActionEvent e) { synchronized (chartDisplay) { chartDisplay.setHeight(null); } } }); controlsColumn.addButton("Update a Value", new ActionListener() { public void actionPerformed(ActionEvent e) { synchronized (chartDisplay) { pieDataset.setValue("Cubits", Math.random() * 500); } } }); }
From source file:org.mwc.debrief.multipath2.MultiPathView.java
private void createPlot(final Composite ui) { // create a date-formatting axis final DateAxis dateAxis = new RelativeDateAxis(); dateAxis.setStandardTickUnits(DateAxisEditor.createStandardDateTickUnitsAsTickUnits()); final NumberAxis valAxis = new NumberAxis("Delay (Secs)"); final DefaultXYItemRenderer theRenderer = new DefaultXYItemRenderer(); theRenderer.setBaseShapesVisible(false); _thePlot = new XYPlot(null, dateAxis, valAxis, theRenderer); final JFreeChart _plotArea = new JFreeChart(_thePlot); final ChartComposite _plotControl = new ChartComposite(ui, SWT.NONE, null, true) { @Override/*from w w w . j ava2 s. c om*/ public void mouseUp(MouseEvent event) { super.mouseUp(event); JFreeChart c = getChart(); if (c != null) { c.setNotify(true); // force redraw } } }; _plotControl.setChart(_plotArea); }
From source file:de.bund.bfr.knime.pmm.common.chart.ChartCreator.java
public ChartCreator(Plotable plotable) { super(new JFreeChart(new XYPlot())); zoomListeners = new ArrayList<>(); getPopupMenu().remove(10);/*from w w w .j ava 2 s . c o m*/ getPopupMenu().remove(9); getPopupMenu().remove(8); getPopupMenu().remove(7); getPopupMenu().remove(6); getPopupMenu().remove(3); getPopupMenu().add(new DataAndModelChartSaveAsItem(), 3); plotables = new LinkedHashMap<>(); shortLegend = new LinkedHashMap<>(); longLegend = new LinkedHashMap<>(); colors = new LinkedHashMap<>(); shapes = new LinkedHashMap<>(); colorLists = new LinkedHashMap<>(); shapeLists = new LinkedHashMap<>(); plotables.put("", plotable); shortLegend.put("", ""); longLegend.put("", ""); }
From source file:nextapp.echo.chart.app.ChartDisplay.java
/** * Creates a new <code>ChartDisplay</code> component that is initially displaying * a new <code>JFreeChart</code> displaying the specified <code>Plot</code>. */// w w w.ja va 2s . co m public ChartDisplay(Plot plot) { this(new JFreeChart(plot)); }