List of usage examples for org.jfree.chart.plot XYPlot getRenderer
public XYItemRenderer getRenderer()
From source file:entrenamiento.grafica2.java
public grafica2() { XYSeries sxy = new XYSeries("pesos"); datosxy.removeAllSeries();/*from w w w . j a va 2s . co m*/ //sxy.add(x[0], y[0]); y = new double[Entrenamiento2.valor.length]; y = Entrenamiento2.valor; int n = y.length; for (int i = 0; i < n; i++) { sxy.add(i, y[i]); // System.out.print(x[i]+"-"+i+" "); } datosxy.addSeries(sxy); graficaxy = ChartFactory.createXYLineChart("Grafica de Progreso", "tiempo", "RM-pesos", datosxy, PlotOrientation.VERTICAL, true, true, true); graficaxy.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) graficaxy.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); final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); configurarDomainAxis(domainAxis); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); } }
From source file:visualizer.projection.distance.view.DistanceHistogram.java
private JFreeChart createChart(IntervalXYDataset intervalxydataset) { JFreeChart chart = ChartFactory.createHistogram("Distance Histogram", "Distances Values", "Occurences", intervalxydataset, PlotOrientation.VERTICAL, true, true, false); // JFreeChart chart = ChartFactory.createHistogram("Histograma das Distncias", // "Valores", "Ocorrncias", intervalxydataset, // PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.WHITE); XYPlot xyplot = (XYPlot) chart.getPlot(); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setAutoRangeIncludesZero(false); xyplot.setDomainGridlinePaint(Color.BLACK); xyplot.setRangeGridlinePaint(Color.BLACK); xyplot.setOutlinePaint(Color.BLACK); xyplot.setOutlineStroke(new BasicStroke(1.0f)); xyplot.setBackgroundPaint(Color.white); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer(); xybarrenderer.setDrawBarOutline(false); return chart; }
From source file:CargarEntrenamiento.grafica2.java
public grafica2() { datosxy.removeAllSeries();/* ww w . ja v a 2 s .co m*/ XYSeries sxy = new XYSeries("pesos"); //sxy.add(x[0], y[0]); y = new double[cargarEntreno.valorentreno.length]; y = cargarEntreno.valorentreno; int n = y.length; for (int i = 0; i < n; i++) { sxy.add(i, y[i]); // System.out.print(x[i]+"-"+i+" "); } datosxy.addSeries(sxy); graficaxy = ChartFactory.createXYLineChart("Grafica de Progreso", "tiempo", "RM-pesos", datosxy, PlotOrientation.VERTICAL, true, true, true); graficaxy.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) graficaxy.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); final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); configurarDomainAxis(domainAxis); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); } }
From source file:org.tiefaces.components.websheet.chart.ChartHelper.java
/** * Set color of series.//from w w w . j a va2 s .co m * * @param chart * JFreeChart. * @param seriesIndex * Index of series to set color of (0 = first series) * @param style * One of STYLE_xxx. */ public final void setSeriesStyle(final JFreeChart chart, final int seriesIndex, final String style) { if (chart != null && style != null) { BasicStroke stroke = ChartUtility.toStroke(style); Plot plot = chart.getPlot(); if (plot instanceof CategoryPlot) { CategoryPlot categoryPlot = chart.getCategoryPlot(); CategoryItemRenderer cir = categoryPlot.getRenderer(); try { cir.setSeriesStroke(seriesIndex, stroke); // series line // style } catch (Exception e) { LOG.log(Level.SEVERE, "Error setting style '" + style + "' for series '" + Integer.toString(seriesIndex) + "' of chart '" + chart.toString() + "': " + e.getLocalizedMessage(), e); } } else if (plot instanceof XYPlot) { XYPlot xyPlot = chart.getXYPlot(); XYItemRenderer xyir = xyPlot.getRenderer(); try { xyir.setSeriesStroke(seriesIndex, stroke); // series line // style } catch (Exception e) { LOG.log(Level.SEVERE, "Error setting style '" + style + "' for series '" + Integer.toString(seriesIndex) + "' of chart '" + chart.toString() + "': " + e.getLocalizedMessage(), e); } } else { LOG.log(Level.FINE, "setSeriesColor() unsupported plot: {}", plot.toString()); } } }
From source file:MWC.GUI.JFreeChart.NewFormattedJFreeChart.java
/** * set the width of the data line/*from www. j a v a2 s . c om*/ * * @param dataLineWidth * width in pixels */ public void setDataLineWidth(final int dataLineWidth) { this._dataLineWidth = dataLineWidth; // and update the data final XYPlot thePlot = (XYPlot) getPlot(); final Stroke[] theStrokes = new Stroke[] { new BasicStroke(_dataLineWidth) }; for (int i = 0; i < theStrokes.length; i++) { final Stroke stroke = theStrokes[i]; thePlot.getRenderer().setSeriesStroke(i, stroke); } }
From source file:edu.ucla.stat.SOCR.applications.demo.PortfolioApplication.java
void updateGraph() { //System.out.println("UpdateGraph get called"); setupStockOptions();//ww w . j av a2s . c o m computeDataPoints(); e_serie = new XYSeries("equal", false); b_serie = new XYSeries("bigger", false); s_serie = new XYSeries("smaller", false); m_serie = new XYSeries("mouse", false); StringBuffer text = new StringBuffer(); text.append("mouse clicked at " + tooltip + "\n"); text.append("The stock combinations are:"); Iterator i = dataPoints.iterator(); while (i.hasNext()) { DataPoint dp = (DataPoint) i.next(); if (dp == minPoint) { e_serie.add(dp.std, dp.mean); } else if (dp.mean < minPoint.mean) s_serie.add(dp.std, dp.mean); else b_serie.add(dp.std, dp.mean); if (mouseClicked) { if (Double.parseDouble(tooltip_formatter.format(dp.std)) == Double .parseDouble(tooltip_formatter.format(mouse_x)) && Double.parseDouble(tooltip_formatter.format(dp.mean)) == Double .parseDouble(tooltip_formatter.format(mouse_y))) { for (int j = 0; j < numStocks; j++) text.append("Stock " + (j + 1) + ": x[" + (j + 1) + "]=" + tooltip_formatter.format(dp.x[j]) + " ,"); text.append("\n---\n"); } } } if (!mouseClicked) { mouse_x = minPoint.std; mouse_y = minPoint.mean; } m_serie.add(mouse_x, mouse_y); XYSeriesCollection ds = new XYSeriesCollection(); ds.addSeries(e_serie); ds.addSeries(m_serie); ds.addSeries(b_serie); ds.addSeries(s_serie); JFreeChart chart = ChartFactory.createXYLineChart("", // chart title "Risk (Standard Deviation)", // x axis label "Expected Return", // y axis label ds, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); XYPlot subplot1 = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer1 = (XYLineAndShapeRenderer) subplot1.getRenderer(); renderer1.setSeriesPaint(1, Color.red); renderer1.setSeriesPaint(3, Color.blue); renderer1.setSeriesPaint(2, Color.blue); //grey renderer1.setSeriesPaint(0, Color.blue); //green Shape shape = renderer1.getBaseShape(); renderer1.setSeriesShape(2, shape); renderer1.setSeriesShape(3, shape); renderer1.setBaseLinesVisible(false); renderer1.setBaseShapesVisible(true); renderer1.setBaseShapesFilled(true); chartPanel = new ChartPanel(chart, false); chartPanel.setPreferredSize(new Dimension(CHART_SIZE_X, CHART_SIZE_Y)); chartPanel.addChartMouseListener(this); super.updateGraph(chartPanel); // if (mouseClicked) { getRecordTable().setText(text.toString()); } else { text = new StringBuffer(); text.append("(" + tooltip_formatter.format(minPoint.mean) + " , " + tooltip_formatter.format(minPoint.std) + ")\n"); for (int j = 0; j < numStocks; j++) text.append("Stock " + (j + 1) + ": x[" + (j + 1) + "]=" + tooltip_formatter.format(minPoint.x[j]) + ","); text.append("\n---\n"); getRecordTable().setText(text.toString()); ; } mouseClicked = false; }
From source file:edu.ucla.stat.SOCR.chart.SuperXYChart.java
/** * Creates a chart.// ww w . j av a 2s . c om * * @param dataset the dataset. * * @return a chart. */ protected JFreeChart createChart(XYDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title "X", // x axis label "Y", // y axis label dataset, // data PlotOrientation.VERTICAL, !legendPanelOn, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); // change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:binky.reportrunner.ui.actions.admin.GetAuditChartAction.java
@Override @PreAuthorize("hasRole('ROLE_ADMIN')") public String execute() throws Exception { // do some stuff and get a chart going // DefaultCategoryDataset dataSet = new DefaultCategoryDataset(); TimeSeriesCollection dataSet = new TimeSeriesCollection(); List<RunnerHistoryEvent> events = auditService.getSuccessEvents(module, new Date(fromDate), new Date(toDate)); Map<String, TimeSeries> serieses = new HashMap<String, TimeSeries>(); for (RunnerHistoryEvent e : events) { TimeSeries s = serieses.get(e.getMethod()); if (s == null) { s = new TimeSeries(e.getMethod()); serieses.put(e.getMethod(), s); }//from w w w.ja v a 2 s .c om s.addOrUpdate(new Millisecond(e.getTimeStamp()), e.getRunTime()); } for (TimeSeries s : serieses.values()) { dataSet.addSeries(s); } chart = ChartFactory.createTimeSeriesChart(module, "", "run time (ms)", dataSet, true, false, false); // .createLineChart("","","Run Time (ms)",dataSet,PlotOrientation.VERTICAL, // true,false,false); XYPlot linePlot = (XYPlot) chart.getPlot(); linePlot.setDomainGridlinesVisible(true); linePlot.setRangeGridlinesVisible(true); linePlot.setRangeGridlinePaint(Color.black); linePlot.setDomainGridlinePaint(Color.black); TextTitle subTitle = new TextTitle("Successful Executions"); subTitle.setFont(new Font("Arial", Font.ITALIC, 10)); chart.addSubtitle(subTitle); chart.getTitle().setFont(new Font("Arial", Font.BOLD, 12)); DateAxis axis = (DateAxis) linePlot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("hh:mm:ss dd-MM-yyyy")); XYItemRenderer r = linePlot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); } chart.setAntiAlias(true); chart.setTextAntiAlias(true); return SUCCESS; }
From source file:edu.ucla.stat.SOCR.chart.demo.DotChart.java
/** * Creates a chart.// w w w . j a v a 2s. co m * * @param dataset the data for the chart. * * @return a chart. */ protected JFreeChart createChart1(XYDataset dataset) { //System.out.println("createChart1 called"); // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title "", // x axis label domain rangeLabel, // y axis label range dataset, // data PlotOrientation.HORIZONTAL, !legendPanelOn, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); // renderer.setSeriesShape(0, java.awt.Shape.round); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setBaseLinesVisible(false); renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); //change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(true); rangeAxis.setUpperMargin(0.01); rangeAxis.setLowerMargin(0.01); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); //domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); domainAxis.setAutoRangeIncludesZero(true); domainAxis.setTickLabelsVisible(false); domainAxis.setTickMarksVisible(false); domainAxis.setUpperMargin(5); domainAxis.setLowerMargin(0.01); // OPTIONAL CUSTOMISATION COMPLETED. setYSummary(dataset); try { // System.out.println("setting the common RangeAxis to null"); common_rangeAxis = null; common_rangeAxis = (NumberAxis) rangeAxis.clone(); // System.out.println("creating the common RangeAxis"); } catch (CloneNotSupportedException e) { System.out.println("CloneNotSupportedException!, exception caught"); } return chart; }
From source file:com.att.aro.ui.view.diagnostictab.plot.DLPacketPlot.java
@Override public void populate(XYPlot plot, AROTraceData analysis) { LinkedHashMap<Color, PacketSeries> dlDatasets = new LinkedHashMap<Color, PacketSeries>(); AnalysisFilter filter = null;//from w w w. jav a 2 s. c o m // logger.info("isDownloadPacket(): "+ isDownloadPacket()); if (analysis != null) { filter = analysis.getAnalyzerResult().getFilter(); for (Session session : analysis.getAnalyzerResult().getSessionlist()) { addSeries(session, dlDatasets, filter); } } // Create the XY data set YIntervalSeriesCollection coll = new YIntervalSeriesCollection(); XYItemRenderer renderer = plot.getRenderer(); for (PacketSeries series : dlDatasets.values()) { coll.addSeries(series); renderer.setSeriesPaint(coll.indexOf(series.getKey()), series.getColor()); } // Create tooltip generator renderer.setBaseToolTipGenerator(new PacketToolTipGenerator()); plot.setDataset(coll); // return plot; }