/** * Creates a new instance. * * @param scale the scale (<code>null</code> not permitted). * @param axis the axis (<code>null</code> not permitted). */ public PaintScaleLegend(PaintScale scale, ValueAxis axis) { if (axis == null) { throw new IllegalArgumentException("Null 'axis' argument."); } this.scale = scale; this.axis = axis; this.axis.addChangeListener(this); this.axisLocation = AxisLocation.BOTTOM_OR_LEFT; this.axisOffset = 0.0; this.axis.setRange(scale.getLowerBound(), scale.getUpperBound()); this.stripWidth = 15.0; this.stripOutlineVisible = true; this.stripOutlinePaint = Color.gray; this.stripOutlineStroke = new BasicStroke(0.5f); this.backgroundPaint = Color.white; this.subdivisions = 100; }
private JFreeChart createScatChart( BufferedImage image, PaintScale ps, int plotWidth, int plotHeigh) { JFreeChart chart_temp = ChartFactory.createScatterPlot( null, null, null, new XYSeriesCollection(), PlotOrientation.VERTICAL, false, false, false); chart_temp.getXYPlot().getRangeAxis().setInverted(true); chart_temp.setBackgroundPaint(JFreeChart.DEFAULT_BACKGROUND_PAINT); XYDataImageAnnotation ann = new XYDataImageAnnotation(image, 0, 0, plotWidth, plotHeigh, true); XYPlot plot = (XYPlot) chart_temp.getPlot(); plot.setDomainPannable(true); plot.setRangePannable(true); plot.getRenderer().addAnnotation(ann, Layer.BACKGROUND); NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); xAxis.setLowerMargin(0.0); xAxis.setUpperMargin(0.0); xAxis.setVisible(false); NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); yAxis.setLowerMargin(0.0); yAxis.setUpperMargin(0.0); yAxis.setVisible(false); NumberAxis scaleAxis = new NumberAxis(); scaleAxis.setAxisLinePaint(Color.black); scaleAxis.setTickMarkPaint(Color.black); scaleAxis.setRange(ps.getLowerBound(), ps.getUpperBound()); scaleAxis.setTickLabelFont(new Font("Dialog", Font.PLAIN, 9)); PaintScaleLegend legend = new PaintScaleLegend(ps, scaleAxis); legend.setAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); legend.setMargin(new RectangleInsets(5, 5, 5, 5)); legend.setStripWidth(10); legend.setPosition(RectangleEdge.RIGHT); legend.setBackgroundPaint(chart_temp.getBackgroundPaint()); chart_temp.addSubtitle(legend); return chart_temp; }