List of usage examples for org.jfree.chart.plot XYPlot XYPlot
public XYPlot(XYDataset dataset, ValueAxis domainAxis, ValueAxis rangeAxis, XYItemRenderer renderer)
From source file:org.geoserver.monitor.web.ActivityChartBasePanel.java
JFreeChart createTimeSeriesChart(String title, String timeAxisLabel, String valueAxisLabel, XYDataset dataset) { ValueAxis timeAxis = new DateAxis(timeAxisLabel); timeAxis.setLowerMargin(0.02); // reduce the default margins timeAxis.setUpperMargin(0.02);//w w w .ja v a 2 s .c o m NumberAxis valueAxis = new NumberAxis(valueAxisLabel); valueAxis.setAutoRangeIncludesZero(false); // override default XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); plot.setRenderer(renderer); JFreeChart chart = new JFreeChart(plot); //TextTitle t = new TextTitle(title); //t.setTextAlignment(HorizontalAlignment.LEFT); //chart.setTitle(t); chart.setBackgroundPaint(Color.WHITE); chart.setAntiAlias(true); chart.clearSubtitles(); return chart; }
From source file:org.fhcrc.cpl.toolbox.gui.chart.PanelWithScatterPlot.java
protected void init() { seriesColors = new Color[SERIES_COLORS.length]; System.arraycopy(SERIES_COLORS, 0, seriesColors, 0, SERIES_COLORS.length); dataset = new XYSeriesCollection(); renderer = new StandardXYItemRenderer(); renderer.setPlotLines(false);/* w ww. j a va2 s .co m*/ renderer.setBaseShapesVisible(true); renderer.setShapesFilled(true); //set all possible series to the default shape for (int i = 0; i < 10; i++) renderer.setSeriesShape(i, defaultShape); XYPlot scatterPlot = new XYPlot(dataset, xAxis, yAxis, renderer); init(scatterPlot); }
From source file:org.jtotus.gui.graph.GraphPrinter.java
private XYPlot createSubPlot(String plotName, GraphSeriesType type) { final TimeSeriesCollection collection = new TimeSeriesCollection(); final NumberAxis range = new NumberAxis("Value"); final XYPlot newSubPlot = new XYPlot(collection, null, range, this.getRenderer(type)); newSubPlot.setDomainCrosshairVisible(true); newSubPlot.setRangeCrosshairVisible(true); newSubPlot.setDomainGridlinesVisible(true); if (!plotMap.containsKey(plotName)) { plotMap.put(plotName, newSubPlot); mainPlot.add(newSubPlot);/*from w w w . ja v a 2s .c om*/ return newSubPlot; } return null; }
From source file:com.joey.software.memoryToolkit.MemoryUsagePanel.java
/** * Creates a new application./* w w w . j av a 2s .c om*/ * * @param historyCount * the history count (in milliseconds). */ public MemoryUsagePanel(int historyCount, int interval) { super(new BorderLayout()); // create two series that automatically discard data more than 30 // seconds old... this.total = new TimeSeries("Total Memory", Millisecond.class); this.total.setMaximumItemCount(historyCount); this.free = new TimeSeries("Free Memory", Millisecond.class); this.free.setMaximumItemCount(historyCount); this.used = new TimeSeries("Used Memory", Millisecond.class); this.used.setMaximumItemCount(historyCount); this.max = new TimeSeries("Used Memory", Millisecond.class); this.max.setMaximumItemCount(historyCount); TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(this.total); dataset.addSeries(this.free); dataset.addSeries(this.used); dataset.addSeries(this.max); DateAxis domain = new DateAxis("Time"); NumberAxis range = new NumberAxis("Memory"); domain.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12)); range.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12)); domain.setLabelFont(new Font("SansSerif", Font.PLAIN, 14)); range.setLabelFont(new Font("SansSerif", Font.PLAIN, 14)); XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false); renderer.setSeriesPaint(0, Color.red); renderer.setSeriesPaint(1, Color.green); renderer.setSeriesPaint(2, Color.black); renderer.setStroke(new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); XYPlot plot = new XYPlot(dataset, domain, range, renderer); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); domain.setAutoRange(true); domain.setLowerMargin(0.0); domain.setUpperMargin(0.0); domain.setTickLabelsVisible(true); range.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); JFreeChart chart = new JFreeChart("JVM Memory Usage", new Font("SansSerif", Font.BOLD, 24), plot, true); chart.setBackgroundPaint(Color.white); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4), BorderFactory.createLineBorder(Color.black))); add(chartPanel); gen = new DataGenerator(interval); }
From source file:inflor.core.plots.CategoryResponseChart.java
public JFreeChart createChart(FCSFrame dataFrame) { CategoryXYZDataSet categoryData = new CategoryXYZDataSet(); double zMin = Double.MAX_VALUE; double zMax = 1; if (dataFrame.getKeywords().containsKey(FCSUtilities.KEY_MERGE_MAP)) { String[] mergeMap = dataFrame.getKeywordValue(FCSUtilities.KEY_MERGE_MAP) .split(NodeUtilities.DELIMITER_REGEX); FCSDimension dim = dataFrame.getDimension(axisName); double[] transformedData = transform.transform(dim.getData()); int perFileSize = dim.getData().length / mergeMap.length; for (int i = 0; i < mergeMap.length; i++) { double[] unMergedData = new double[perFileSize]; for (int j = 0; j < unMergedData.length; j++) { unMergedData[j] = transformedData[i * unMergedData.length + j]; }/*from ww w.ja v a2s. c om*/ double tMin = transform.getMinTranformedValue(); double tMax = transform.getMaxTransformedValue(); Histogram1D hist = new Histogram1D(unMergedData, tMin, tMax, ChartingDefaults.BIN_COUNT); double[] x = hist.getNonZeroX(); double[] y = new double[x.length]; for (int j = 0; j < y.length; j++) { y[j] = i; } double[] z = hist.getNonZeroY(); double currentZMin = Doubles.min(z); double currentZMax = Doubles.max(z); if (currentZMin < zMin) { zMin = currentZMin; } else if (currentZMax > zMax) { zMax = currentZMax; } categoryData.addCategoricalSeries(mergeMap[i], x, z); } } else { FCSDimension dim = dataFrame.getDimension(axisName); double[] transformedData = transform.transform(dim.getData()); Histogram1D hist = new Histogram1D(transformedData, transform.getMinTranformedValue(), transform.getMaxTransformedValue(), ChartingDefaults.BIN_COUNT); double[] x = hist.getNonZeroX(); double[] y = new double[x.length]; for (int j = 0; j < y.length; j++) { y[j] = 0; } double[] z = hist.getNonZeroY(); double currentZMin = Doubles.min(z); double currentZMax = Doubles.max(z); if (currentZMin < zMin) { zMin = currentZMin; } else if (currentZMax > zMax) { zMax = currentZMax; } categoryData.addCategoricalSeries(dataFrame.getDisplayName(), x, z); } ValueAxis domainAxis = PlotUtils.createAxis(axisName, transform); NumberAxis rangeAxis = new CategoricalNumberAxis("", categoryData.getLabelMap()); // Renderer configuration XYBlockRenderer renderer = new XYBlockRenderer(); double xWidth = (transform.getMaxTransformedValue() - transform.getMinTranformedValue()) / ChartingDefaults.BIN_COUNT; renderer.setBlockWidth(xWidth); renderer.setBlockHeight(0.5); renderer.setBlockAnchor(RectangleAnchor.LEFT); PaintScale paintScale = PlotUtils.createPaintScale(zMax, ChartingDefaults.DEFAULT_COLOR_SCHEME); renderer.setPaintScale(paintScale); // Add to panel. XYPlot responsePlot = new XYPlot(categoryData, domainAxis, rangeAxis, renderer); JFreeChart chart = new JFreeChart(responsePlot); chart.removeLegend(); return chart; }
From source file:net.sf.mzmine.modules.peaklistmethods.peakpicking.adap3decompositionV2.EICPlot.java
public EICPlot(List<List<NavigableMap<Double, Double>>> clusters, List<Double> colors, List<List<String>> info, List<NavigableMap<Double, Double>> modelPeaks) { super(null, true); setBackground(Color.white);/*w w w .j av a2s .c o m*/ setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); NumberAxis xAxis = new NumberAxis("Retention Time"); xAxis.setAutoRangeIncludesZero(false); xAxis.setUpperMargin(0); xAxis.setLowerMargin(0); NumberAxis yAxis = new NumberAxis("Intensity"); yAxis.setAutoRangeIncludesZero(false); yAxis.setUpperMargin(0); yAxis.setLowerMargin(0); xyDataset = new XYSeriesCollection(); colorDataset = new ArrayList<>(); toolTips = new ArrayList<>(); widths = new ArrayList<>(); int seriesID = 0; for (int i = 0; i < clusters.size(); ++i) { List<NavigableMap<Double, Double>> cluster = clusters.get(i); double color = colors.get(i); for (int j = 0; j < cluster.size(); ++j) { XYSeries series = new XYSeries(seriesID++); for (Entry<Double, Double> e : cluster.get(j).entrySet()) series.add(e.getKey(), e.getValue()); xyDataset.addSeries(series); colorDataset.add(color); toolTips.add(info.get(i).get(j)); } } XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer() { @Override public Paint getItemPaint(int row, int col) { String type = xyDataset.getSeries(row).getDescription(); Paint color; if (type.equals(PeakType.MODEL.name())) color = COLORS[row % COLORS.length]; else color = new Color(0, 0, 0, 50); return color; } @Override public Stroke getSeriesStroke(int series) { XYSeries s = xyDataset.getSeries(series); String type = s.getDescription(); float width; if (type.equals((PeakType.MODEL.name()))) width = 2.0f; else width = 1.0f; return new BasicStroke(width); } }; renderer.setDefaultShapesVisible(false); renderer.setDefaultToolTipGenerator(new XYToolTipGenerator() { @Override public String generateToolTip(XYDataset dataset, int series, int item) { try { return toolTips.get(series); } catch (NullPointerException | IndexOutOfBoundsException e) { return ""; } } }); XYPlot plot = new XYPlot(xyDataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinesVisible(true); JFreeChart chart = new JFreeChart("", new Font("SansSerif", Font.BOLD, 12), plot, false); chart.setBackgroundPaint(Color.white); super.setChart(chart); }
From source file:Interfaz.adminZone.java
private void graficar() { ChartPanel panel;// w ww .jav a 2 s . c om JFreeChart chart = null; int validar = 1; XYSplineRenderer renderer = new XYSplineRenderer(); XYSeriesCollection dataset = new XYSeriesCollection(); ValueAxis x = new NumberAxis(); ValueAxis y = new NumberAxis(); XYSeries serie = new XYSeries("Ventas"); XYPlot plot; lineas.removeAll(); try { for (int fila = 0; fila < this.modeloVentasMes.getRowCount(); fila++) { serie.add(Float.parseFloat(String.valueOf(this.modeloVentasMes.getValueAt(fila, 0))), Float.parseFloat(String.valueOf(modeloVentasMes.getValueAt(fila, 1)))); } } catch (Exception es) { validar = 0; } if (validar == 1) { dataset.addSeries(serie); x.setLabel("Mes"); y.setLabel("Ventas"); plot = new XYPlot(dataset, x, y, renderer); chart = new JFreeChart(plot); chart.setTitle("Cambio en las Ventas 2016"); } panel = new ChartPanel(chart); panel.setBounds(5, 10, 229, 219); lineas.add(panel); lineas.repaint(); }
From source file:Presentation.MainWindow.java
/** Ajout la fentre des graphiques de temprature et d'humidit en temps rel */ public void initGraphs() { XYSeriesCollection datasetT = new XYSeriesCollection(); XYSeriesCollection datasetH = new XYSeriesCollection(); datasetT.addSeries(seriesT);/* ww w .j ava2 s .co m*/ datasetH.addSeries(seriesH); XYPlot plotT = new XYPlot(datasetT, new NumberAxis(), new NumberAxis(), new DefaultXYItemRenderer()); XYPlot plotH = new XYPlot(datasetH, new NumberAxis(), new NumberAxis(), new DefaultXYItemRenderer()); //plot.setDataset(1, datasetT); // plot.setRenderer(1, new DefaultXYItemRenderer()); plotH.getRenderer().setSeriesPaint(0, Color.BLUE); JFreeChart chartT = new JFreeChart("Graphique de temprature", JFreeChart.DEFAULT_TITLE_FONT, plotT, true); JFreeChart chartH = new JFreeChart("Graphique d'humidit", JFreeChart.DEFAULT_TITLE_FONT, plotH, true); ChartPanel gPanelT = new ChartPanel(chartT); ChartPanel gPanelH = new ChartPanel(chartH); mPanel.add(gPanelT); mPanel.add(gPanelH); }
From source file:telas.TelaGrafico.java
public void criaGrafico(ArrayList<Processo> listapronto) { JFreeChart chart = null;//from w ww .jav a2s . co m XYSplineRenderer renderer = new XYSplineRenderer(); XYSeriesCollection dataset = new XYSeriesCollection(); ValueAxis x = new NumberAxis(); ValueAxis y = new NumberAxis(); XYSeries serie = new XYSeries("Processos"); XYPlot plot; for (int fila = 0; fila < listapronto.size(); fila++) { serie.add(listapronto.get(fila).getTsurto(), listapronto.get(fila).getTespera()); } dataset.addSeries(serie); x.setLabel("Processos"); y.setLabel("Tempo de espera"); plot = new XYPlot(dataset, x, y, renderer); chart = new JFreeChart(plot); chart.setTitle("Processos"); ChartPanel myChartPanel = new ChartPanel(chart, true); myChartPanel.setSize(jPanel1.getWidth(), jPanel1.getHeight()); myChartPanel.setVisible(true); jPanel1.removeAll(); jPanel1.add(myChartPanel); jPanel1.revalidate(); jPanel1.repaint(); }