List of usage examples for org.jfree.chart.renderer LookupPaintScale add
public void add(double value, Paint paint)
From source file:org.jfree.chart.demo.XYShapeRendererDemo1.java
private static JFreeChart createChart(XYZDataset xyzdataset) { NumberAxis numberaxis = new NumberAxis("X"); numberaxis.setAutoRangeIncludesZero(false); NumberAxis numberaxis1 = new NumberAxis("Y"); numberaxis1.setAutoRangeIncludesZero(false); XYShapeRenderer xyshaperenderer = new XYShapeRenderer(); LookupPaintScale lookuppaintscale = new LookupPaintScale(1.0D, 4D, new Color(0, 0, 255)); lookuppaintscale.add(2D, new Color(100, 100, 255)); lookuppaintscale.add(3D, new Color(200, 200, 255)); xyshaperenderer.setPaintScale(lookuppaintscale); XYPlot xyplot = new XYPlot(xyzdataset, numberaxis, numberaxis1, xyshaperenderer); xyplot.setDomainPannable(true);//w ww. j a va 2 s. c om xyplot.setRangePannable(true); JFreeChart jfreechart = new JFreeChart("XYShapeRendererDemo1", xyplot); jfreechart.removeLegend(); NumberAxis numberaxis2 = new NumberAxis("Score"); numberaxis2.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); PaintScaleLegend paintscalelegend = new PaintScaleLegend(lookuppaintscale, numberaxis2); paintscalelegend.setPosition(RectangleEdge.RIGHT); paintscalelegend.setMargin(4D, 4D, 40D, 4D); paintscalelegend.setAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); jfreechart.addSubtitle(paintscalelegend); ChartUtilities.applyCurrentTheme(jfreechart); return jfreechart; }
From source file:org.jfree.chart.demo.XYBlockChartDemo2.java
private static JFreeChart createChart(XYZDataset xyzdataset) { DateAxis dateaxis = new DateAxis("Date"); dateaxis.setLowerMargin(0.0D);/*from w w w .j a va2s .c o m*/ dateaxis.setUpperMargin(0.0D); dateaxis.setInverted(true); NumberAxis numberaxis = new NumberAxis("Hour"); numberaxis.setUpperMargin(0.0D); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); XYBlockRenderer xyblockrenderer = new XYBlockRenderer(); xyblockrenderer.setBlockWidth(86400000D); xyblockrenderer.setBlockAnchor(RectangleAnchor.BOTTOM_LEFT); LookupPaintScale lookuppaintscale = new LookupPaintScale(0.5D, 4.5D, Color.white); lookuppaintscale.add(0.5D, Color.red); lookuppaintscale.add(1.5D, Color.green); lookuppaintscale.add(2.5D, Color.blue); lookuppaintscale.add(3.5D, Color.yellow); xyblockrenderer.setPaintScale(lookuppaintscale); XYPlot xyplot = new XYPlot(xyzdataset, dateaxis, numberaxis, xyblockrenderer); xyplot.setOrientation(PlotOrientation.HORIZONTAL); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); JFreeChart jfreechart = new JFreeChart("XYBlockChartDemo2", xyplot); jfreechart.removeLegend(); jfreechart.setBackgroundPaint(Color.white); SymbolAxis symbolaxis = new SymbolAxis(null, new String[] { "", "Unavailable", "Free", "Group 1", "Group 2" }); symbolaxis.setRange(0.5D, 4.5D); symbolaxis.setPlot(new PiePlot()); symbolaxis.setGridBandsVisible(false); PaintScaleLegend paintscalelegend = new PaintScaleLegend(lookuppaintscale, symbolaxis); paintscalelegend.setMargin(new RectangleInsets(3D, 10D, 3D, 10D)); paintscalelegend.setPosition(RectangleEdge.BOTTOM); paintscalelegend.setAxisOffset(5D); jfreechart.addSubtitle(paintscalelegend); return jfreechart; }
From source file:org.jfree.chart.demo.XYBlockChartDemo3.java
private static JFreeChart createChart(XYZDataset xyzdataset) { NumberAxis numberaxis = new NumberAxis("X"); numberaxis.setLowerMargin(0.0D);/*from w ww . j av a 2s . co m*/ numberaxis.setUpperMargin(0.0D); NumberAxis numberaxis1 = new NumberAxis("Y"); numberaxis1.setAutoRangeIncludesZero(false); numberaxis1.setInverted(true); numberaxis1.setLowerMargin(0.0D); numberaxis1.setUpperMargin(0.0D); numberaxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); XYBlockRenderer xyblockrenderer = new XYBlockRenderer(); LookupPaintScale lookuppaintscale = new LookupPaintScale(0.5D, 3.5D, Color.black); lookuppaintscale.add(0.5D, Color.green); lookuppaintscale.add(1.5D, Color.orange); lookuppaintscale.add(2.5D, Color.red); xyblockrenderer.setPaintScale(lookuppaintscale); XYPlot xyplot = new XYPlot(xyzdataset, numberaxis, numberaxis1, xyblockrenderer); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setForegroundAlpha(0.66F); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); JFreeChart jfreechart = new JFreeChart("XYBlockChartDemo3", xyplot); jfreechart.removeLegend(); jfreechart.setBackgroundPaint(Color.white); SymbolAxis symbolaxis = new SymbolAxis(null, new String[] { "", "OK", "Uncertain", "Bad" }); symbolaxis.setRange(0.5D, 3.5D); symbolaxis.setPlot(new PiePlot()); symbolaxis.setGridBandsVisible(false); PaintScaleLegend paintscalelegend = new PaintScaleLegend(lookuppaintscale, symbolaxis); paintscalelegend.setAxisOffset(5D); paintscalelegend.setPosition(RectangleEdge.BOTTOM); paintscalelegend.setMargin(new RectangleInsets(5D, 5D, 5D, 5D)); jfreechart.addSubtitle(paintscalelegend); return jfreechart; }
From source file:inflor.core.utils.PlotUtils.java
public static LookupPaintScale createPaintScale(double zMax, ColorSchemes colorScheme) { PaintModel pm = new PaintModel(colorScheme, zMax); Paint[] paints = pm.getPaints(); double[] levels = pm.getLevels(); LookupPaintScale paintScale = new LookupPaintScale(0, pm.getThreshold(), Color.GRAY); for (int i = 0; i < levels.length; i++) { paintScale.add(levels[i], paints[i]); }//from w w w . j a va 2 s. c o m return paintScale; }
From source file:gov.llnl.lc.infiniband.opensm.plugin.gui.chart.PaintScaleFactory.java
public static LookupPaintScale getLookupPaintScale(int type, double lower, double upper, double maxValue) { LookupPaintScale lps = new LookupPaintScale(lower, upper, defaultColor); double inc = maxColor / maxDivisions; double cinc = inc * 2.0; int half = maxDivisions / 2; double cdiv = maxValue / maxDivisions; lps.add(0, Color.black); if (type == 0) { Color[] gColors = generateColors(maxDivisions - 1); for (int i = 1; i < maxDivisions; i++) { double cval = (double) i * cdiv; lps.add(cval, gColors[i - 1]); }//from ww w. ja va 2 s .c o m } else if (type == 1) { for (int i = 1; i < maxDivisions; i++) { // boolean firstHalf = i < half; int rval = firstHalf ? 0 : (int) ((i - half) * cinc); int gval = firstHalf ? (int) (i * cinc) : 510 - (int) (i * cinc); int bval = firstHalf ? 255 - (int) (i * cinc) : 0; double cval = (double) i * cdiv; lps.add(cval, new Color(rval, gval, bval)); // System.err.println(i + ") V:" + cval + ", R:" + rval + ", G:" + gval + ", B:" + bval); } } else { for (int i = 1; i < maxDivisions; i++) { // red slowly ramps up, and blue slowly ramps down boolean firstHalf = i < half; int rval = (int) (i * inc); int gval = firstHalf ? (int) (i * cinc) : 510 - (int) (i * cinc); int bval = 255 - rval; double cval = (double) i * cdiv; lps.add(cval, new Color(rval, gval, bval)); // System.err.println(i + ") V:" + cval + ", R:" + rval + ", G:" + gval + ", B:" + bval); } } // System.err.println("Color type: " + type); return lps; }
From source file:msi.gama.outputs.layers.charts.ChartJFreeChartOutputHeatmap.java
protected static final LookupPaintScale createLUT(final int ncol, final float vmin, final float vmax, final Color start, final Color end) { final float[][] colors = new float[][] { { start.getRed() / 255f, start.getGreen() / 255f, start.getBlue() / 255f, start.getAlpha() / 255f }, { end.getRed() / 255f, end.getGreen() / 255f, end.getBlue() / 255f, end.getAlpha() / 255f } }; final float[] limits = new float[] { 0, 1 }; final LookupPaintScale lut = new LookupPaintScale(vmin, vmax, start); float val; float r, g, b, a; for (int j = 0; j < ncol; j++) { val = j / (ncol - 0.99f); final int i = 0; r = colors[i][0] + (val - limits[i]) / (limits[i + 1] - limits[i]) * (colors[i + 1][0] - colors[i][0]); g = colors[i][1] + (val - limits[i]) / (limits[i + 1] - limits[i]) * (colors[i + 1][1] - colors[i][1]); b = colors[i][2] + (val - limits[i]) / (limits[i + 1] - limits[i]) * (colors[i + 1][2] - colors[i][2]); a = colors[i][3] + (val - limits[i]) / (limits[i + 1] - limits[i]) * (colors[i + 1][3] - colors[i][3]); lut.add(val * (vmax - vmin) + vmin, new Color(r, g, b, a)); }// ww w . j a v a 2 s. c om return lut; }
From source file:org.esa.beam.smos.visat.GridPointBtDataFlagmatrixToolView.java
@Override protected JComponent createGridPointComponent() { dataset = new DefaultXYZDataset(); final NumberAxis xAxis = new NumberAxis("Record #"); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); xAxis.setAutoRangeIncludesZero(false); xAxis.setLowerMargin(0.0);/*w w w. j a va 2 s.c o m*/ xAxis.setUpperMargin(0.0); flagNames = createFlagNames(Dddb.getInstance().getFlagDescriptors(DEFAULT_FLAG_DESCRIPTOR_IDENTIFIER)); final NumberAxis yAxis = createRangeAxis(flagNames); final LookupPaintScale paintScale = new LookupPaintScale(0.0, 4.0, Color.WHITE); paintScale.add(0.0, Color.BLACK); paintScale.add(1.0, Color.RED); paintScale.add(2.0, Color.GREEN); paintScale.add(3.0, Color.BLUE); paintScale.add(4.0, Color.YELLOW); final XYBlockRenderer renderer = new XYBlockRenderer(); renderer.setPaintScale(paintScale); renderer.setBaseToolTipGenerator(new FlagToolTipGenerator(flagNames)); plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.LIGHT_GRAY); plot.setDomainGridlinePaint(Color.WHITE); plot.setRangeGridlinePaint(Color.WHITE); plot.setForegroundAlpha(0.5f); plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5)); plot.setNoDataMessage("No data"); chart = new JFreeChart(null, plot); chart.removeLegend(); chartPanel = new ChartPanel(chart); return chartPanel; }
From source file:org.esa.smos.gui.gridpoint.GridPointBtDataFlagmatrixTopComponent.java
@Override protected JComponent createGridPointComponent() { dataset = new DefaultXYZDataset(); final NumberAxis xAxis = new NumberAxis("Record #"); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); xAxis.setAutoRangeIncludesZero(false); xAxis.setLowerMargin(0.0);//w w w .ja v a2 s. c o m xAxis.setUpperMargin(0.0); final List<FlagDescriptor> flagDescriptorList = Dddb.getInstance() .getFlagDescriptors(DEFAULT_FLAG_DESCRIPTOR_IDENTIFIER).asList(); flagDescriptors = flagDescriptorList.toArray(new FlagDescriptor[flagDescriptorList.size()]); final String[] flagNames = createFlagNames(flagDescriptors); final NumberAxis yAxis = createRangeAxis(flagNames); final LookupPaintScale paintScale = new LookupPaintScale(0.0, 4.0, Color.WHITE); paintScale.add(0.0, Color.BLACK); paintScale.add(1.0, Color.RED); paintScale.add(2.0, Color.GREEN); paintScale.add(3.0, Color.BLUE); paintScale.add(4.0, Color.YELLOW); renderer = new XYBlockRenderer(); renderer.setPaintScale(paintScale); renderer.setBaseToolTipGenerator(new FlagToolTipGenerator(flagNames)); plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.LIGHT_GRAY); plot.setDomainGridlinePaint(Color.WHITE); plot.setRangeGridlinePaint(Color.WHITE); plot.setForegroundAlpha(0.5f); plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5)); plot.setNoDataMessage("No data"); chart = new JFreeChart(null, plot); chart.removeLegend(); chartPanel = new ChartPanel(chart); return chartPanel; }
From source file:net.sf.dynamicreports.design.transformation.chartcustomizer.XyBlockRendererCustomizer.java
@Override public void customize(JFreeChart chart, ReportParameters reportParameters) { chart.getXYPlot().getDomainAxis().setUpperMargin(0); chart.getXYPlot().getRangeAxis().setUpperMargin(0); XYBlockRenderer renderer = new XYBlockRenderer(); if (xyBlockPlot.getBlockWidth() != null) { renderer.setBlockWidth(xyBlockPlot.getBlockWidth()); }/*from w ww. j av a 2 s .c o m*/ if (xyBlockPlot.getBlockHeight() != null) { renderer.setBlockHeight(xyBlockPlot.getBlockHeight()); } if (xyBlockPlot.getBlockAnchor() != null) { renderer.setBlockAnchor(ConstantTransform.rectangleAnchor(xyBlockPlot.getBlockAnchor())); } LookupPaintScale paintScale = new LookupPaintScale(xyBlockPlot.getDefaultLowerBound(), xyBlockPlot.getDefaultUpperBound(), xyBlockPlot.getDefaultPaint()); for (DRIPaintScale scale : xyBlockPlot.getPaintScales()) { paintScale.add(scale.getValue(), scale.getPaint()); } renderer.setPaintScale(paintScale); chart.getXYPlot().setRenderer(renderer); LegendItemCollection legendItems = new LegendItemCollection(); for (DRIPaintScale scale : xyBlockPlot.getPaintScales()) { legendItems.add(new LegendItem(scale.getLabel(), scale.getPaint())); } chart.getXYPlot().setFixedLegendItems(legendItems); }
From source file:msi.gama.outputs.layers.charts.ChartJFreeChartOutputHeatmap.java
protected static final LookupPaintScale createLUT(final int ncol, final float vmin, final float vmax, final Color start, final Color med, final Color end) { final float[][] colors = new float[][] { { start.getRed() / 255f, start.getGreen() / 255f, start.getBlue() / 255f, start.getAlpha() / 255f }, { med.getRed() / 255f, med.getGreen() / 255f, med.getBlue() / 255f, med.getAlpha() / 255f }, { end.getRed() / 255f, end.getGreen() / 255f, end.getBlue() / 255f, end.getAlpha() / 255f } }; final float[] limits = new float[] { 0, 0.5f, 1 }; final LookupPaintScale lut = new LookupPaintScale(vmin, vmax, med); float val; float r, g, b, a; for (int j = 0; j < ncol; j++) { val = j / (ncol - 0.99f); int i = 0; for (i = 0; i < limits.length; i++) { if (val < limits[i]) { break; }//ww w . j av a 2 s. co m } i = i - 1; r = colors[i][0] + (val - limits[i]) / (limits[i + 1] - limits[i]) * (colors[i + 1][0] - colors[i][0]); g = colors[i][1] + (val - limits[i]) / (limits[i + 1] - limits[i]) * (colors[i + 1][1] - colors[i][1]); b = colors[i][2] + (val - limits[i]) / (limits[i + 1] - limits[i]) * (colors[i + 1][2] - colors[i][2]); a = colors[i][3] + (val - limits[i]) / (limits[i + 1] - limits[i]) * (colors[i + 1][3] - colors[i][3]); lut.add(val * (vmax - vmin) + vmin, new Color(r, g, b, a)); } return lut; }