List of usage examples for org.jfree.chart.renderer.xy XYLineAndShapeRenderer setBasePaint
public void setBasePaint(Paint paint)
From source file:org.jax.maanova.plot.PlotUtil.java
/** * Create a simple monochrome XY renderer which can be used for scatter plots * @return the renderer//from w w w .ja v a2 s .c o m */ public static XYLineAndShapeRenderer createMonochromeScatterPlotRenderer() { XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true); renderer.setAutoPopulateSeriesShape(false); renderer.setAutoPopulateSeriesOutlinePaint(false); renderer.setAutoPopulateSeriesOutlineStroke(false); renderer.setAutoPopulateSeriesPaint(false); renderer.setBaseShape(new Ellipse2D.Float(-PlotUtil.SCATTER_PLOT_DOT_SIZE_PIXELS / 2F, -PlotUtil.SCATTER_PLOT_DOT_SIZE_PIXELS / 2F, PlotUtil.SCATTER_PLOT_DOT_SIZE_PIXELS, PlotUtil.SCATTER_PLOT_DOT_SIZE_PIXELS)); renderer.setUseOutlinePaint(true); renderer.setBaseOutlinePaint(Color.BLACK); renderer.setBaseOutlineStroke(new BasicStroke(0.25F)); renderer.clearSeriesPaints(false); renderer.setBasePaint(new Color(0x55, 0x55, 0xFF)); // blue return renderer; }
From source file:ec.nbdemetra.benchmarking.calendarization.CalendarizationChartView.java
@Override protected void onColorSchemeChange() { XYPlot plot = chartPanel.getChart().getXYPlot(); plot.setBackgroundPaint(themeSupport.getPlotColor()); plot.setDomainGridlinePaint(themeSupport.getGridColor()); plot.setRangeGridlinePaint(themeSupport.getGridColor()); chartPanel.getChart().setBackgroundPaint(themeSupport.getBackColor()); XYLineAndShapeRenderer main = (XYLineAndShapeRenderer) plot.getRenderer(DAILY_INDEX); main.setBasePaint(themeSupport.getLineColor(DAILY_COLOR)); XYDifferenceRenderer difference = ((XYDifferenceRenderer) plot.getRenderer(DIFF_INDEX)); difference.setPositivePaint(themeSupport.getAreaColor(DIFF_COLOR)); difference.setNegativePaint(themeSupport.getAreaColor(DIFF_COLOR)); difference.setBasePaint(themeSupport.getLineColor(DIFF_COLOR)); XYLineAndShapeRenderer smooth = (XYLineAndShapeRenderer) plot.getRenderer(SMOOTH_INDEX); smooth.setBasePaint(themeSupport.getLineColor(SMOOTH_COLOR)); }
From source file:be.nbb.demetra.dfm.output.FactorChart.java
@Override protected void onColorSchemeChange() { XYPlot plot = chartPanel.getChart().getXYPlot(); plot.setBackgroundPaint(themeSupport.getPlotColor()); plot.setDomainGridlinePaint(themeSupport.getGridColor()); plot.setRangeGridlinePaint(themeSupport.getGridColor()); chartPanel.getChart().setBackgroundPaint(themeSupport.getBackColor()); XYLineAndShapeRenderer factor = (XYLineAndShapeRenderer) plot.getRenderer(FACTOR_INDEX); factor.setBasePaint(themeSupport.getLineColor(FACTOR_COLOR)); XYLineAndShapeRenderer filtered = (XYLineAndShapeRenderer) plot.getRenderer(FILTERED_INDEX); filtered.setBasePaint(themeSupport.getLineColor(FILTERED_COLOR)); XYDifferenceRenderer difference = ((XYDifferenceRenderer) plot.getRenderer(DIFFERENCE_INDEX)); Color diffArea = SwingColorSchemeSupport.withAlpha(themeSupport.getAreaColor(DIFFERENCE_COLOR), 150); difference.setPositivePaint(diffArea); difference.setNegativePaint(diffArea); difference.setBasePaint(themeSupport.getLineColor(DIFFERENCE_COLOR)); }
From source file:netplot.GenericPlotPanel.java
void genericConfig(JFreeChart chart, XYPlot plot, int plotIndex) { if (!enableLegend) { chart.removeLegend();/* www.jav a2s . c o m*/ } XYItemRenderer xyItemRenderer = plot.getRenderer(); //May also be XYBarRenderer if (xyItemRenderer instanceof XYLineAndShapeRenderer) { XYToolTipGenerator xyToolTipGenerator = xyItemRenderer.getBaseToolTipGenerator(); //If currently an XYLineAndShapeRenderer replace it so that we inc the colour for every plotIndex XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(linesEnabled, shapesEnabled); //Ensure we don't loose the tool tips on the new renderer renderer.setBaseToolTipGenerator(xyToolTipGenerator); renderer.setBasePaint(getPlotColour(plotIndex)); renderer.setSeriesStroke(0, new BasicStroke(lineWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL), true); plot.setRenderer(plotIndex, renderer); } //If we have a new y axis then we need a new data set if (yAxisName != null && yAxisName.length() > 0) { if (logYAxis) { LogAxis yAxis = new LogAxis(yAxisName); yAxis.setAutoRange(false); yAxis.setNumberFormatOverride(new LogFormat(10, "10", true)); yAxis.setRange(minScaleValue, maxScaleValue); yAxis.setLowerBound(minScaleValue); yAxis.setUpperBound(maxScaleValue); plot.setRangeAxis(yAxisIndex, yAxis); plot.setRangeAxisLocation(yAxisIndex, AxisLocation.BOTTOM_OR_LEFT); } else { NumberAxis axis = new NumberAxis(yAxisName); axis.setAutoRangeIncludesZero(zeroOnYScale); if (autoScaleEnabled) { axis.setAutoRange(true); } else { Range range = new Range(minScaleValue, maxScaleValue); axis.setRangeWithMargins(range, true, true); } if (yAxisTickCount > 0) { NumberTickUnit tick = new NumberTickUnit(yAxisTickCount); axis.setTickUnit(tick); } plot.setRangeAxis(yAxisIndex, axis); plot.setRangeAxisLocation(yAxisIndex, AxisLocation.BOTTOM_OR_LEFT); } yAxisIndex++; } plot.mapDatasetToRangeAxis(plotIndex, yAxisIndex - 1); ValueAxis a = plot.getDomainAxis(); if (xAxisName.length() > 0) { a.setLabel(xAxisName); } //We can enable/disable zero on the axis if we have a NumberAxis if (a instanceof NumberAxis) { ((NumberAxis) a).setAutoRangeIncludesZero(zeroOnXScale); } }
From source file:ec.ui.view.MarginView.java
@Override protected void onColorSchemeChange() { XYPlot plot = chartPanel.getChart().getXYPlot(); plot.setBackgroundPaint(themeSupport.getPlotColor()); plot.setDomainGridlinePaint(themeSupport.getGridColor()); plot.setRangeGridlinePaint(themeSupport.getGridColor()); chartPanel.getChart().setBackgroundPaint(themeSupport.getBackColor()); XYLineAndShapeRenderer main = (XYLineAndShapeRenderer) plot.getRenderer(MAIN_INDEX); main.setBasePaint(themeSupport.getLineColor(MAIN_COLOR)); XYDifferenceRenderer difference = ((XYDifferenceRenderer) plot.getRenderer(DIFFERENCE_INDEX)); Color diffArea = SwingColorSchemeSupport.withAlpha(themeSupport.getAreaColor(DIFFERENCE_COLOR), 150); difference.setPositivePaint(diffArea); difference.setNegativePaint(diffArea); difference.setBasePaint(themeSupport.getLineColor(DIFFERENCE_COLOR)); Collection<Marker> markers = (Collection<Marker>) plot.getDomainMarkers(Layer.FOREGROUND); if (!Jdk6.Collections.isNullOrEmpty(markers)) { Color markerColor = themeSupport.getLineColor(DATE_MARKER_COLOR); for (Marker o : markers) { o.setPaint(markerColor);/*from w ww.jav a2s . c o m*/ } } Collection<Marker> intervalMarkers = (Collection<Marker>) plot.getDomainMarkers(Layer.BACKGROUND); if (!Jdk6.Collections.isNullOrEmpty(intervalMarkers)) { Color markerColor = themeSupport.getLineColor(KnownColor.ORANGE); for (Marker o : intervalMarkers) { o.setPaint(markerColor); } } }
From source file:org.jfree.eastwood.ChartEngine.java
/** * Creates a scatter chart.//from ww w .j a v a2 s. co m * * @return A scatter chart. */ private static JFreeChart createScatterChart() { JFreeChart chart = ChartFactory.createScatterPlot(null, null, null, null, PlotOrientation.VERTICAL, false, false, false); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(null); plot.setOutlinePaint(null); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBasePaint(new Color(0x76A4FB)); renderer.setAutoPopulateSeriesPaint(false); GValueAxis xAxis = new GValueAxis(); xAxis.setTickLabelsVisible(false); xAxis.setTickMarksVisible(false); plot.setDomainAxis(xAxis); GValueAxis yAxis = new GValueAxis(); yAxis.setTickLabelsVisible(false); yAxis.setTickMarksVisible(false); plot.setRangeAxis(yAxis); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); return chart; }
From source file:be.nbb.demetra.dfm.output.ConfidenceGraph.java
@Override protected void onColorSchemeChange() { highValueColour = themeSupport.getLineColor(CONFIDENCE_COLOR); lowValueColour = themeSupport.getPlotColor(); updateColourDistance();/*from w w w . ja v a2 s . c o m*/ XYPlot plot = chartPanel.getChart().getXYPlot(); plot.setBackgroundPaint(themeSupport.getPlotColor()); plot.setDomainGridlinePaint(themeSupport.getGridColor()); plot.setRangeGridlinePaint(themeSupport.getGridColor()); chartPanel.getChart().setBackgroundPaint(themeSupport.getBackColor()); XYLineAndShapeRenderer main = (XYLineAndShapeRenderer) plot.getRenderer(MAIN_INDEX); main.setBasePaint(themeSupport.getLineColor(MAIN_COLOR)); XYLineAndShapeRenderer original = (XYLineAndShapeRenderer) plot.getRenderer(ORIGINAL_DATA_INDEX); original.setBasePaint(themeSupport.getLineColor(ORIGINAL_DATA_COLOR)); for (int i = 0; i < indexes.length; i++) { XYDifferenceRenderer confidence = ((XYDifferenceRenderer) plot.getRenderer(indexes[i])); Color diffArea = getCellColour(indexes[i]); confidence.setPositivePaint(diffArea); confidence.setNegativePaint(diffArea); confidence.setBasePaint(diffArea); if (i != indexes.length - 1) { for (int j = 1; j < intermediateValues; j++) { confidence = ((XYDifferenceRenderer) plot.getRenderer(indexes[i] - j)); diffArea = getCellColour(indexes[i] - ((10 / intermediateValues) * j)); confidence.setPositivePaint(diffArea); confidence.setNegativePaint(diffArea); confidence.setBasePaint(diffArea); } } } }
From source file:org.jfree.eastwood.ChartEngine.java
/** * Creates a line chart./*from www . ja v a2 s .c o m*/ * * @return A line chart. */ private static JFreeChart createLineChart() { GXYPlot plot = new GXYPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setBaseShapesVisible(false); plot.setRenderer(renderer); JFreeChart chart = new JFreeChart(plot); chart.removeLegend(); chart.setBackgroundPaint(Color.white); renderer.setBasePaint(new Color(0xFF9900)); renderer.setBaseStroke(new BasicStroke(1.5f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); renderer.setAutoPopulateSeriesPaint(false); renderer.setItemLabelsVisible(true); renderer.setItemLabelGenerator(new GXYPlot.LabelGenerator()); renderer.setItemLabelPaint(new Color(0x333435)); renderer.setPositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT)); GValueAxis xAxis = new GValueAxis(); xAxis.setTickLabelsVisible(false); xAxis.setTickMarksVisible(false); plot.setDomainAxis(xAxis); GValueAxis yAxis = new GValueAxis(); yAxis.setTickLabelsVisible(false); yAxis.setTickMarksVisible(false); plot.setRangeAxis(yAxis); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); return chart; }
From source file:org.jfree.eastwood.ChartEngine.java
/** * Creates a sparkline chart./* w ww .j a va 2 s . c o m*/ * * @return A sparkline chart. */ private static JFreeChart createSparklineChart() { GXYPlot plot = new GXYPlot(); plot.setInsets(RectangleInsets.ZERO_INSETS); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setBaseShapesVisible(false); plot.setRenderer(renderer); JFreeChart chart = new JFreeChart(plot); chart.setPadding(RectangleInsets.ZERO_INSETS); chart.removeLegend(); chart.setBackgroundPaint(Color.white); renderer.setBasePaint(new Color(0xFF9900)); renderer.setBaseStroke(new BasicStroke(1.5f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); renderer.setAutoPopulateSeriesPaint(false); GValueAxis xAxis = new GValueAxis(); xAxis.setVisible(false); plot.setDomainAxis(xAxis); GValueAxis yAxis = new GValueAxis(); yAxis.setVisible(false); plot.setRangeAxis(yAxis); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); return chart; }
From source file:org.moeaframework.analysis.plot.Plot.java
/** * Creates a new line plot series. The series is added to the given * dataset, or if {@code null} a new dataset is created. * /*from ww w . j a v a 2s. com*/ * @param label the label for the series * @param x the x values * @param y the y values * @param dataset the dataset, or {@code null} if a new dataset should be * created * @return a reference to this {@code Plot} instance */ private Plot line(String label, List<? extends Number> x, List<? extends Number> y, XYSeriesCollection dataset) { if (dataset == null) { createXYPlot(); currentDataset++; dataset = new XYSeriesCollection(); } // generate the dataset XYSeries series = new XYSeries(label, false, true); for (int i = 0; i < x.size(); i++) { series.add(x.get(i), y.get(i)); } dataset.addSeries(series); // add the dataset to the plot XYPlot plot = chart.getXYPlot(); plot.setDataset(currentDataset, dataset); // setup the renderer Paint paint = paintHelper.get(dataset.getSeriesKey(0)); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); renderer.setAutoPopulateSeriesStroke(false); renderer.setBaseStroke(new BasicStroke(3f, 1, 1)); renderer.setBasePaint(paint); renderer.setBaseFillPaint(paint); plot.setRenderer(currentDataset, renderer); return this; }