List of usage examples for org.jfree.chart.renderer.xy XYLineAndShapeRenderer setPaint
public void setPaint(Paint paint)
From source file:ca.nengo.plot.impl.DefaultPlotter.java
private static void configSpikeRenderer(XYLineAndShapeRenderer renderer) { renderer.setShape(ShapeUtilities.createDiamond(1f)); renderer.setShapesVisible(true);/*from w w w . j a v a 2s . co m*/ renderer.setShapesFilled(true); renderer.setLinesVisible(false); renderer.setPaint(Color.BLACK); }
From source file:uk.ac.leeds.ccg.andyt.projects.moses.process.RegressionReport.java
public static JFreeChart[] createRegressionCharts(JFreeChart[] t_ScatterPlots, Object[] t_RegressionParametersAndXYLineCharts) throws IOException { JFreeChart[] result = new JFreeChart[t_ScatterPlots.length]; Object[] t_RegressionParameters = (Object[]) t_RegressionParametersAndXYLineCharts[0]; JFreeChart[] t_regressionXYLineCharts = (JFreeChart[]) t_RegressionParametersAndXYLineCharts[1]; JFreeChart[] t_yequalsxXYLineCharts = (JFreeChart[]) t_RegressionParametersAndXYLineCharts[2]; for (int i = 0; i < result.length; i++) { double[] a_RegressionParameters = (double[]) t_RegressionParameters[i]; int maxLengthOfIntString = 6; String b = String.valueOf(a_RegressionParameters[0]); String a = String.valueOf(a_RegressionParameters[1]); String rsquare = String.valueOf(a_RegressionParameters[2]); String title = "Y=" + a.substring(0, Math.min(a.length(), maxLengthOfIntString)) + "X"; if (a_RegressionParameters[0] < 0) { title += b.substring(0, Math.min(b.length(), maxLengthOfIntString)); } else {/*from w w w . j ava 2 s .c o m*/ title += "+" + b.substring(0, Math.min(b.length(), maxLengthOfIntString)); } if (a_RegressionParameters.length > 2) { title += " RSquare " + rsquare.substring(0, Math.min(rsquare.length(), maxLengthOfIntString)); } XYLineAndShapeRenderer points_XYLineAndShapeRenderer = new XYLineAndShapeRenderer(false, true); XYPlot a_ScatterPlotXYPlot = (XYPlot) t_ScatterPlots[i].getPlot(); a_ScatterPlotXYPlot.setDataset(0, a_ScatterPlotXYPlot.getDataset()); points_XYLineAndShapeRenderer.setSeriesPaint(0, Color.blue); //Shape[] _Shapes = DefaultDrawingSupplier.createStandardSeriesShapes(); // System.out.println("There are " + _Shapes.length + // " number of Shapes to try..."); // 0 are square // 1 are circles // 2 are up-pointing triangle // 3 are diamond // 4 are horizontal rectangle // 5 are down-pointing triangle // 6 are horizontal ellipse // 7 are right-pointing triangle // 8 are vertical rectangle // 9 are left-pointing triangle int a_SpikeLength = 3; int[] xpoints = new int[9]; int[] ypoints = new int[9]; xpoints[0] = 0; ypoints[0] = 0; xpoints[1] = 0; ypoints[1] = a_SpikeLength; xpoints[2] = 0; ypoints[2] = 0; xpoints[3] = a_SpikeLength; ypoints[3] = 0; xpoints[4] = 0; ypoints[4] = 0; xpoints[5] = 0; ypoints[5] = -a_SpikeLength; xpoints[6] = 0; ypoints[6] = 0; xpoints[7] = -a_SpikeLength; ypoints[7] = 0; xpoints[8] = 0; ypoints[8] = 0; Shape a_Shape = new Polygon(xpoints, ypoints, xpoints.length); // points_XYLineAndShapeRenderer.setSeriesShape( 0, _Shapes[2] ); points_XYLineAndShapeRenderer.setSeriesShape(0, a_Shape); a_ScatterPlotXYPlot.setRenderer(0, points_XYLineAndShapeRenderer); XYDataset a_regressionXYLineChartXYDataset = ((XYPlot) t_regressionXYLineCharts[i].getPlot()) .getDataset(); XYLineAndShapeRenderer line_XYLineAndShapeRenderer = new XYLineAndShapeRenderer(true, false); a_ScatterPlotXYPlot.setDataset(1, a_regressionXYLineChartXYDataset); line_XYLineAndShapeRenderer.setPaint(Color.red); a_ScatterPlotXYPlot.setRenderer(1, line_XYLineAndShapeRenderer); XYDataset a_yequalsxXYLineChartXYDataset = ((XYPlot) t_yequalsxXYLineCharts[i].getPlot()).getDataset(); XYLineAndShapeRenderer yequalsxline_XYLineAndShapeRenderer = new XYLineAndShapeRenderer(true, false); a_ScatterPlotXYPlot.setDataset(2, a_yequalsxXYLineChartXYDataset); yequalsxline_XYLineAndShapeRenderer.setPaint(Color.green); a_ScatterPlotXYPlot.setRenderer(2, yequalsxline_XYLineAndShapeRenderer); result[i] = new JFreeChart(title, a_ScatterPlotXYPlot); } return result; }
From source file:web.diva.server.unused.ProfilePlotGenerator.java
/** * Creates a line chart (based on an {@link XYDataset}) with default * settings.//from w ww .j ava2s. c o m * * @param title the chart title (<code>null</code> permitted). * @param xAxisLabel a label for the X-axis (<code>null</code> permitted). * @param yAxisLabel a label for the Y-axis (<code>null</code> permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param orientation the plot orientation (horizontal or vertical) * (<code>null</code> NOT permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return The chart. */ private JFreeChart createXYLineChart(String title, String[] columnIds, XYDataset dataset, PlotOrientation orientation, boolean legend, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } Font f = new Font("ARIAL", 1, 7); // NumberAxis xAxis = new NumberAxis(xAxisLabel); // xAxis.setAutoRangeIncludesZero(false); SymbolAxis xAxis = new SymbolAxis("", columnIds); xAxis.setAxisLineVisible(false); xAxis.setGridBandsVisible(false); xAxis.setVerticalTickLabels(true); xAxis.setVisible(true); xAxis.setTickLabelPaint(shadowColor); xAxis.setTickLabelFont(f); xAxis.setFixedDimension(51.0); boolean auto = xAxis.getAutoRangeIncludesZero(); xAxis.setAutoRangeIncludesZero(true ^ auto); xAxis.setTickUnit(new NumberTickUnit(1)); xAxis.setRange(0, columnIds.length); // NumberAxis yAxis = new NumberAxis(yAxisLabel); NumberAxis yAxis = new NumberAxis(); yAxis.setAutoRangeIncludesZero(true ^ auto); yAxis.setAxisLineVisible(false); yAxis.setTickLabelFont(f); yAxis.setTickLabelPaint(Color.BLUE); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); renderer.setBaseShapesVisible(false); renderer.setPaint(shadowColor); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setOrientation(orientation); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(shadowColor); plot.setRangeGridlinePaint(shadowColor); plot.setOutlinePaint(Color.BLUE); // XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); // plot.setRenderer(renderer); plot.setSeriesRenderingOrder(SeriesRenderingOrder.REVERSE); plot.setDomainAxis(xAxis); if (urls) { renderer.setURLGenerator(new StandardXYURLGenerator()); } JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); return chart; }
From source file:com.haskins.cloudtrailviewer.feature.MetricsFeature.java
private void showChart(String service) { final TimeSeriesCollection chartData = generateTimeSeriesData(service); JFreeChart chart = ChartFactory.createTimeSeriesChart(service, "Time", "Calls", chartData, false, true, false);/*w ww . j a va 2 s . co m*/ // draw outter line XYLineAndShapeRenderer lineAndShapeRenderer = new XYLineAndShapeRenderer(); lineAndShapeRenderer.setPaint(new Color(64, 168, 228, 75)); lineAndShapeRenderer.setSeriesShape(0, new Ellipse2D.Double(-3, -3, 6, 6)); lineAndShapeRenderer.setSeriesShapesFilled(0, true); lineAndShapeRenderer.setSeriesShapesVisible(0, true); lineAndShapeRenderer.setUseOutlinePaint(true); lineAndShapeRenderer.setUseFillPaint(true); // draw filled area XYAreaRenderer renderer = new XYAreaRenderer(); renderer.setPaint(new Color(64, 168, 228, 50)); // configure Plot final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setOutlineVisible(false); plot.setDataset(0, chartData); plot.setDataset(1, chartData); plot.setRenderer(0, lineAndShapeRenderer); plot.setRenderer(1, renderer); plot.getDomainAxis().setLowerMargin(0); plot.getDomainAxis().setUpperMargin(0); // format chart title TextTitle t = chart.getTitle(); t.setFont(new Font("Arial", Font.BOLD, 14)); // Cross Hairs xCrosshair = new Crosshair(Double.NaN, Color.GRAY, new BasicStroke(0f)); xCrosshair.setLabelVisible(true); xCrosshair.setLabelGenerator(new DateTimeCrosshairLabelGenerator()); CrosshairOverlay crosshairOverlay = new CrosshairOverlay(); crosshairOverlay.addDomainCrosshair(xCrosshair); // Create the panel chartPanel = new ChartPanel(chart); chartPanel.setMinimumDrawWidth(0); chartPanel.setMaximumDrawWidth(Integer.MAX_VALUE); chartPanel.setMinimumDrawHeight(0); chartPanel.setMaximumDrawHeight(Integer.MAX_VALUE); chartPanel.setMouseZoomable(true, false); chartPanel.setDomainZoomable(true); chartPanel.setRangeZoomable(false); chartPanel.addChartMouseListener(this); chartPanel.addOverlay(crosshairOverlay); // update the display chartCards.removeAll(); chartCards.add(chartPanel, ""); chartCards.revalidate(); }
From source file:grafix.graficos.indices.Indice.java
public void plotar(final XYPlot plot, final JanelaGraficos janela, final int contador) { XYLineAndShapeRenderer indicesRenderer = new XYLineAndShapeRenderer(); indicesRenderer.setSeriesLinesVisible(0, isTracoContinuo()); indicesRenderer.setSeriesShapesVisible(0, !isTracoContinuo()); indicesRenderer.setSeriesShape(0, ShapeUtilities.createDiamond(1.5f)); indicesRenderer.setStroke(new BasicStroke(getEspessura() * 0.5f)); indicesRenderer.setToolTipGenerator(new IndiceToolTipGenerator(this)); indicesRenderer.setPaint(getCor()); plot.setRenderer(contador, indicesRenderer); plot.setDataset(contador, getDataSet(janela)); }
From source file:ca.nengo.plot.impl.DefaultPlotter.java
/** * @see ca.nengo.plot.Plotter#doPlot(java.util.List, java.util.List, java.lang.String) *//*ww w.j av a 2s . c o m*/ public void doPlot(List<TimeSeries> series, List<SpikePattern> patterns, String title) { JFreeChart chart = ChartFactory.createXYLineChart(title, "Time (s)", "", null, PlotOrientation.VERTICAL, true, false, false); XYPlot plot = (XYPlot) chart.getPlot(); //we will change the legend to show one item per series/pattern (rather than dimension/neuron) LegendItemCollection revisedItems = new LegendItemCollection(); int legendItemIndex = 0; int i = 0; for (; series != null && i < series.size(); i++) { plot.setDataset(i, getDataset(series.get(i))); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); renderer.setDrawSeriesLineAsPath(true); renderer.setPaint(getColor(i)); plot.setRenderer(i, renderer); String seriesName = series.get(i).getName(); if (seriesName == null) seriesName = "Time Series " + i; revisedItems.add(getCopy(plot.getLegendItems().get(legendItemIndex), seriesName)); legendItemIndex += series.get(i).getDimension(); } for (int j = 0; patterns != null && j < patterns.size(); j++) { int index = i + j; plot.setDataset(index, getDataset(patterns.get(j))); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); configSpikeRenderer(renderer); renderer.setPaint(getColor(j)); plot.setRenderer(index, renderer); revisedItems.add(getCopy(plot.getLegendItems().get(legendItemIndex), "Spike Pattern " + j)); legendItemIndex += patterns.get(j).getNumNeurons(); } plot.setFixedLegendItems(revisedItems); showChart(chart, title); }
From source file:web.diva.server.unused.ProfilePlotGenerator.java
private XYLineAndShapeRenderer chartColorUpdate(XYLineAndShapeRenderer renderer, String[] colors, HashMap<String, Color> colorMap) { if (renderer == null) { renderer = new XYLineAndShapeRenderer(); }/*from ww w. ja v a2 s . c om*/ renderer.setBaseShapesVisible(false);//setShapesVisible(false); if (colorMap.size() > 2) { for (int x = 0; x < colors.length; x++) { if (colors[x].equalsIgnoreCase("#000000")) { renderer.setSeriesPaint(x, Color.BLACK); continue; } renderer.setSeriesPaint(x, colorMap.get(colors[x])); } } else { renderer.setPaint(Color.BLACK); } return renderer; }