Java Code Examples for org.jfree.chart.axis.NumberAxis#setAxisLinePaint()

The following examples show how to use org.jfree.chart.axis.NumberAxis#setAxisLinePaint() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChartJFreeChartOutputScatter.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
public NumberAxis formatYAxis(final IScope scope, final NumberAxis axis) {
	axis.setAxisLinePaint(axesColor);
	axis.setTickLabelFont(getTickFont());
	axis.setLabelFont(getLabelFont());
	if (textColor != null) {
		axis.setLabelPaint(textColor);
		axis.setTickLabelPaint(textColor);
	}
	axis.setAxisLinePaint(axesColor);
	axis.setLabelFont(getLabelFont());
	axis.setTickLabelFont(getTickFont());
	if (textColor != null) {
		axis.setLabelPaint(textColor);
		axis.setTickLabelPaint(textColor);
	}
	if (!this.getYTickValueVisible(scope)) {
		axis.setTickMarksVisible(false);
		axis.setTickLabelsVisible(false);

	}
	return axis;

}
 
Example 2
Source File: DSWorkbenchStatsFrame.java    From dsworkbench with Apache License 2.0 5 votes vote down vote up
private void addDataset(String pId, XYDataset pDataset) {
    if (chart == null) {
        setupChart(pId, pDataset);
    } else {
        XYPlot plot = (XYPlot) chart.getPlot();
        plot.setDataset(plot.getDatasetCount(), pDataset);
        NumberAxis axis = new NumberAxis(pId);
        NumberFormat nf = NumberFormat.getInstance();
        nf.setMinimumFractionDigits(0);
        nf.setMaximumFractionDigits(0);
        axis.setNumberFormatOverride(nf);
        plot.setRangeAxis(plot.getDatasetCount() - 1, axis);
        plot.setRangeAxisLocation(plot.getDatasetCount() - 1, AxisLocation.TOP_OR_LEFT);
        plot.mapDatasetToRangeAxis(plot.getDatasetCount() - 1, plot.getDatasetCount() - 1);
        XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
        renderer.setSeriesLinesVisible(0, jShowLines.isSelected());
        renderer.setSeriesShapesVisible(0, jShowDataPoints.isSelected());
        plot.setRenderer(plot.getDatasetCount() - 1, renderer);
        renderer.setDefaultItemLabelsVisible(jShowItemValues.isSelected());
        renderer.setDefaultItemLabelGenerator(new org.jfree.chart.labels.StandardXYItemLabelGenerator());
        renderer.setDefaultToolTipGenerator(new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"), NumberFormat.getInstance()));
        axis.setAxisLinePaint(plot.getLegendItems().get(plot.getDatasetCount() - 1).getLinePaint());
        axis.setLabelPaint(plot.getLegendItems().get(plot.getDatasetCount() - 1).getLinePaint());
        axis.setTickLabelPaint(plot.getLegendItems().get(plot.getDatasetCount() - 1).getLinePaint());
        axis.setTickMarkPaint(plot.getLegendItems().get(plot.getDatasetCount() - 1).getLinePaint());
    }
}
 
Example 3
Source File: ObdDataPlotter.java    From AndrOBD with GNU General Public License v3.0 5 votes vote down vote up
/**
 * add a new series to the graph
 *
 * @param series The new series to be added
 */
public synchronized void addSeries(TimeSeries series)
{

	if (oneRangePerSeries)
	{
		// get paint for current axis/range/...
		Paint currPaint =
			DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE[
				raIndex % DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE.length];

		XYPlot plot = (XYPlot) chart.getPlot();
		// set dataset
		plot.setDataset(raIndex, new TimeSeriesCollection(series));
		// ** set axis
		NumberAxis axis = new NumberAxis();
		axis.setTickLabelFont(legendFont);
		axis.setAxisLinePaint(currPaint);
		axis.setTickLabelPaint(currPaint);
		axis.setTickMarkPaint(currPaint);
		// ** set axis in plot
		plot.setRangeAxis(raIndex, axis);
		plot.setRangeAxisLocation(raIndex, raIndex % 2 == 0 ? AxisLocation.TOP_OR_LEFT : AxisLocation.BOTTOM_OR_RIGHT);
		plot.mapDatasetToRangeAxis(raIndex, raIndex);
		// ** create renderer
		XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false);
		renderer.setBaseToolTipGenerator(toolTipGen);
		renderer.setSeriesPaint(0, currPaint);
		// ** set renderer in plot
		plot.setRenderer(raIndex, renderer);

		raIndex++;
	}
	dataset.addSeries(series);
}
 
Example 4
Source File: PlotUtil.java    From dl4j-tutorials with MIT License 4 votes vote down vote up
private static JFreeChart createChart(XYZDataset dataset, double[] mins, double[] maxs, int nPoints, XYDataset xyData) {
    NumberAxis xAxis = new NumberAxis("X");
    xAxis.setRange(mins[0],maxs[0]);


    NumberAxis yAxis = new NumberAxis("Y");
    yAxis.setRange(mins[1], maxs[1]);

    XYBlockRenderer renderer = new XYBlockRenderer();
    renderer.setBlockWidth((maxs[0]-mins[0])/(nPoints-1));
    renderer.setBlockHeight((maxs[1] - mins[1]) / (nPoints - 1));
    PaintScale scale = new GrayPaintScale(0, 1.0);
    renderer.setPaintScale(scale);
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);
    plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));
    JFreeChart chart = new JFreeChart("", plot);
    chart.getXYPlot().getRenderer().setSeriesVisibleInLegend(0, false);


    NumberAxis scaleAxis = new NumberAxis("Probability (class 0)");
    scaleAxis.setAxisLinePaint(Color.white);
    scaleAxis.setTickMarkPaint(Color.white);
    scaleAxis.setTickLabelFont(new Font("Dialog", Font.PLAIN, 7));
    PaintScaleLegend legend = new PaintScaleLegend(new GrayPaintScale(),
            scaleAxis);
    legend.setStripOutlineVisible(false);
    legend.setSubdivisionCount(20);
    legend.setAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    legend.setAxisOffset(5.0);
    legend.setMargin(new RectangleInsets(5, 5, 5, 5));
    legend.setFrame(new BlockBorder(Color.red));
    legend.setPadding(new RectangleInsets(10, 10, 10, 10));
    legend.setStripWidth(10);
    legend.setPosition(RectangleEdge.LEFT);
    chart.addSubtitle(legend);

    ChartUtilities.applyCurrentTheme(chart);

    plot.setDataset(1, xyData);
    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
    renderer2.setBaseLinesVisible(false);
    plot.setRenderer(1, renderer2);

    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

    return chart;
}
 
Example 5
Source File: ChartJFreeChartOutputHeatmap.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
protected void resetRenderer(final IScope scope, final String serieid) {
	final XYBlockRenderer newr = (XYBlockRenderer) this.getOrCreateRenderer(scope, serieid);

	// newr.setSeriesStroke(0, new BasicStroke(0));
	final ChartDataSeries myserie = this.getChartdataset().getDataSeries(scope, serieid);

	if (myserie.getMycolor() != null) {
		newr.setSeriesPaint(0, myserie.getMycolor());
	}
	if (myserie.getSValues(scope).size() > 0) {
		final double maxval = Collections.max(myserie.getSValues(scope));
		final double minval = Collections.min(myserie.getSValues(scope));
		Color cdeb = new Color(0, 0, 0, 0);
		if (myserie.getMyMincolor() != null) {
			cdeb = myserie.getMyMincolor();
		}
		Color cend = new Color(0.9f, 0.9f, 0.9f, 1.0f);
		if (myserie.getMycolor() != null) {
			cend = myserie.getMycolor();
		}

		LookupPaintScale paintscale = createLUT(100, (float) minval, (float) maxval, cdeb, cend);
		if (myserie.getMyMedcolor() != null) {
			paintscale = createLUT(100, (float) minval, (float) maxval, cdeb, myserie.getMyMedcolor(), cend);
		}

		newr.setPaintScale(paintscale);

		final NumberAxis scaleAxis = new NumberAxis(myserie.getName());
		scaleAxis.setAxisLinePaint(this.axesColor);
		scaleAxis.setTickMarkPaint(this.axesColor);
		scaleAxis.setTickLabelFont(this.getTickFont());
		scaleAxis.setRange(minval, maxval);
		scaleAxis.setAxisLinePaint(axesColor);
		scaleAxis.setLabelFont(getLabelFont());
		if (textColor != null) {
			scaleAxis.setLabelPaint(textColor);
			scaleAxis.setTickLabelPaint(textColor);
		}
		if (!this.getXTickValueVisible(scope)) {
			scaleAxis.setTickMarksVisible(false);
			scaleAxis.setTickLabelsVisible(false);

		}

		final PaintScaleLegend legend = new PaintScaleLegend(paintscale, scaleAxis);
		legend.setAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
		legend.setAxisOffset(5.0);
		// legend.setMargin(new RectangleInsets(5, 5, 5, 5));
		// legend.setFrame(new BlockBorder(Color.red));
		// legend.setPadding(new RectangleInsets(10, 10, 10, 10));
		// legend.setStripWidth(10);
		legend.setPosition(RectangleEdge.RIGHT);
		legend.setBackgroundPaint(this.backgroundColor);
		// ArrayList<PaintScaleLegend> caxe=new
		// ArrayList<PaintScaleLegend>();
		// caxe.add(legend);
		// chart.setSubtitles(caxe);
		if (!this.series_label_position.equals("none")) {
			chart.addSubtitle(legend);
		}

	}
}