Example usage for org.jfree.chart.axis NumberAxis setTickMarkPaint

List of usage examples for org.jfree.chart.axis NumberAxis setTickMarkPaint

Introduction

In this page you can find the example usage for org.jfree.chart.axis NumberAxis setTickMarkPaint.

Prototype

public void setTickMarkPaint(Paint paint) 

Source Link

Document

Sets the paint used to draw tick marks and sends an AxisChangeEvent to all registered listeners.

Usage

From source file:org.jfree.chart.demo.BarChartDemo9.java

private static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createBarChart("Bar Chart Demo 9", null, "Value", categorydataset,
            PlotOrientation.VERTICAL, false, true, false);
    TextTitle texttitle = jfreechart.getTitle();
    texttitle.setBorder(0.0D, 0.0D, 1.0D, 0.0D);
    texttitle.setBackgroundPaint(new GradientPaint(0.0F, 0.0F, Color.red, 350F, 0.0F, Color.white, true));
    texttitle.setExpandToFitSpace(true);
    jfreechart.setBackgroundPaint(new GradientPaint(0.0F, 0.0F, Color.yellow, 350F, 0.0F, Color.white, true));
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setNoDataMessage("NO DATA!");
    categoryplot.setBackgroundPaint(null);
    categoryplot.setInsets(new RectangleInsets(10D, 5D, 5D, 5D));
    categoryplot.setOutlinePaint(Color.black);
    categoryplot.setRangeGridlinePaint(Color.gray);
    categoryplot.setRangeGridlineStroke(new BasicStroke(1.0F));
    Paint apaint[] = createPaint();
    CustomBarRenderer custombarrenderer = new CustomBarRenderer(apaint);
    custombarrenderer.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_HORIZONTAL));
    categoryplot.setRenderer(custombarrenderer);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    numberaxis.setRange(0.0D, 800D);//from  www .  j ava2 s  .c  o m
    numberaxis.setTickMarkPaint(Color.black);
    return jfreechart;
}

From source file:com.javafxpert.neuralnetviz.scenario.PlotUtil.java

private static JFreeChart createChart(XYZDataset dataset, double[] mins, double[] maxs, int nPoints,
        XYDataset xyData) {//from  w  ww.j  a  va 2s.co m
    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;
}

From source file:org.jfree.chart.demo.XYBlockChartDemo1.java

private static JFreeChart createChart(XYZDataset xyzdataset) {
    NumberAxis numberaxis = new NumberAxis("X");
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    numberaxis.setLowerMargin(0.0D);/* w  w w.  j  a  v  a2  s.c om*/
    numberaxis.setUpperMargin(0.0D);
    numberaxis.setAxisLinePaint(Color.white);
    numberaxis.setTickMarkPaint(Color.white);
    NumberAxis numberaxis1 = new NumberAxis("Y");
    numberaxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    numberaxis1.setLowerMargin(0.0D);
    numberaxis1.setUpperMargin(0.0D);
    numberaxis1.setAxisLinePaint(Color.white);
    numberaxis1.setTickMarkPaint(Color.white);
    XYBlockRenderer xyblockrenderer = new XYBlockRenderer();
    GrayPaintScale graypaintscale = new GrayPaintScale(-2D, 1.0D);
    xyblockrenderer.setPaintScale(graypaintscale);
    XYPlot xyplot = new XYPlot(xyzdataset, numberaxis, numberaxis1, xyblockrenderer);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinesVisible(false);
    xyplot.setRangeGridlinePaint(Color.white);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    xyplot.setOutlinePaint(Color.blue);
    JFreeChart jfreechart = new JFreeChart("XYBlockChartDemo1", xyplot);
    jfreechart.removeLegend();
    NumberAxis numberaxis2 = new NumberAxis("Scale");
    numberaxis2.setAxisLinePaint(Color.white);
    numberaxis2.setTickMarkPaint(Color.white);
    numberaxis2.setTickLabelFont(new Font("Dialog", 0, 7));
    PaintScaleLegend paintscalelegend = new PaintScaleLegend(new GrayPaintScale(), numberaxis2);
    paintscalelegend.setAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    paintscalelegend.setAxisOffset(5D);
    paintscalelegend.setMargin(new RectangleInsets(5D, 5D, 5D, 5D));
    paintscalelegend.setFrame(new BlockBorder(Color.red));
    paintscalelegend.setPadding(new RectangleInsets(10D, 10D, 10D, 10D));
    paintscalelegend.setStripWidth(10D);
    paintscalelegend.setPosition(RectangleEdge.RIGHT);
    paintscalelegend.setBackgroundPaint(new Color(120, 120, 180));
    jfreechart.addSubtitle(paintscalelegend);
    jfreechart.setBackgroundPaint(new Color(180, 180, 250));
    return jfreechart;
}

From source file:org.spantus.exp.segment.draw.DrawDtw.java

protected JFreeChart createXYZChart() {
    NumberAxis xAxis = new NumberAxis("Sample");
    NumberAxis yAxis = new NumberAxis("target");
    List<List<Double>> data = info.getDistanceMatrix();
    XYZDataset xyzset = new XYZArrayDataset(data);
    XYPlot plot = new XYPlot(xyzset, xAxis, yAxis, null);
    XYBlockRenderer r = new XYBlockRenderer();
    PaintScale ps = new GrayPaintScale(min, max);
    //      LookupPaintScale ps = new LookupPaintScale(0.0, 4.0, Color.WHITE);
    //      ps.add(1, Color.red);
    //      ps.add(2, Color.green);
    //      ps.add(3, Color.gray);

    r.setPaintScale(ps);/*from  w  w w  . java  2  s .  c  om*/
    r.setBlockHeight(1.0f);
    r.setBlockWidth(1.0f);
    plot.setRenderer(r);
    JFreeChart chart = new JFreeChart("Chart Title", JFreeChart.DEFAULT_TITLE_FONT, plot, false);
    NumberAxis scaleAxis = new NumberAxis("Scale");
    scaleAxis.setUpperBound(100);
    scaleAxis.setAxisLinePaint(Color.white);
    scaleAxis.setTickMarkPaint(Color.white);
    scaleAxis.setTickLabelFont(new Font("Dialog", Font.PLAIN, 12));
    //      PaintScaleLegend legend = new PaintScaleLegend(ps, scaleAxis);
    //      legend.setAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    //      legend.setPadding(new RectangleInsets(5, 5, 5, 5));
    //      legend.setStripWidth(50);
    //      legend.setPosition(RectangleEdge.RIGHT);
    //      legend.setBackgroundPaint(Color.WHITE);
    //      chart.addSubtitle(legend);
    chart.setBackgroundPaint(Color.white);
    return chart;
}

From source file:net.sf.mzmine.chartbasics.chartthemes.EStandardChartTheme.java

@Override
public void apply(JFreeChart chart) {
    // TODO Auto-generated method stub
    super.apply(chart);
    ///*www  .  j  ava2 s  . c om*/
    chart.getXYPlot().setDomainGridlinesVisible(showXGrid);
    chart.getXYPlot().setRangeGridlinesVisible(showYGrid);
    // all axes
    for (int i = 0; i < chart.getXYPlot().getDomainAxisCount(); i++) {
        NumberAxis a = (NumberAxis) chart.getXYPlot().getDomainAxis(i);
        a.setTickMarkPaint(axisLinePaint);
        a.setAxisLinePaint(axisLinePaint);
        // visible?
        a.setVisible(showXAxis);
    }
    for (int i = 0; i < chart.getXYPlot().getRangeAxisCount(); i++) {
        NumberAxis a = (NumberAxis) chart.getXYPlot().getRangeAxis(i);
        a.setTickMarkPaint(axisLinePaint);
        a.setAxisLinePaint(axisLinePaint);
        // visible?
        a.setVisible(showYAxis);
    }
    // apply bg
    chart.setBackgroundPaint(this.getChartBackgroundPaint());
    chart.getPlot().setBackgroundPaint(this.getPlotBackgroundPaint());

    for (int i = 0; i < chart.getSubtitleCount(); i++) {
        // visible?
        chart.getSubtitle(i).setVisible(subtitleVisible);
        //
        if (PaintScaleLegend.class.isAssignableFrom(chart.getSubtitle(i).getClass()))
            ((PaintScaleLegend) chart.getSubtitle(i)).setBackgroundPaint(this.getChartBackgroundPaint());
    }
    if (chart.getLegend() != null)
        chart.getLegend().setBackgroundPaint(this.getChartBackgroundPaint());

    //
    chart.setAntiAlias(isAntiAliased());
    chart.getTitle().setVisible(isShowTitle());
    chart.getPlot().setBackgroundAlpha(isNoBackground() ? 0 : 1);
}

From source file:edu.ucla.stat.SOCR.chart.demo.BarChartDemo9.java

/**
 * Creates a sample chart./*from  ww  w. j a  v a 2  s.  co m*/
 * 
 * @param dataset  the dataset.
 * 
 * @return a sample chart.
 */
protected JFreeChart createChart(CategoryDataset dataset) {

    JFreeChart chart = ChartFactory.createBarChart(chartTitle, // chart title
            domainLabel, // domain axis label
            rangeLabel, // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // the plot orientation
            !legendPanelOn, // include legend
            true, false);

    TextTitle title = chart.getTitle();
    title.setBorder(0, 0, 1, 0);
    title.setBackgroundPaint(new GradientPaint(0f, 0f, Color.red, 350f, 0f, Color.white, true));
    title.setExpandToFitSpace(true);

    chart.setBackgroundPaint(new GradientPaint(0f, 0f, Color.yellow, 350f, 0f, Color.white, true));

    // get a reference to the plot for further customisation...
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setNoDataMessage("NO DATA!");
    plot.setBackgroundPaint(null);
    plot.setInsets(new RectangleInsets(10, 5, 5, 5));
    plot.setOutlinePaint(Color.black);
    plot.setRangeGridlinePaint(Color.gray);
    plot.setRangeGridlineStroke(new BasicStroke(1.0f));
    Paint[] colors = createPaint();
    CustomBarRenderer renderer = new CustomBarRenderer(colors);
    renderer.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_HORIZONTAL));
    plot.setRenderer(renderer);

    renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator());

    // change the margin at the top of the range axis...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    //   rangeAxis.setRange(0.0, 800.0);
    rangeAxis.setTickMarkPaint(Color.black);

    setCategorySummary(dataset);
    return chart;

}

From source file:com.fr3ts0n.ecu.gui.application.ObdDataPlotter.java

/**
 * add a new series to the graph/*from   www . ja  v  a  2  s.co m*/
 *
 * @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);
}

From source file:org.jls.toolbox.math.chart.XYBarChart.java

/**
 * Permet de paramtrer le graphique une fois cr.
 *///from   w  w  w . ja va2  s. c om
private void setChartStyle() {
    // Paramtrage des courbes
    this.plot.setBackgroundAlpha((float) 0.0);
    this.plot.setDomainCrosshairVisible(this.isGridXVisible);
    this.plot.setDomainCrosshairLockedOnData(true);
    this.plot.setRangeCrosshairVisible(this.isGridYVisible);
    this.plot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);
    this.plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));

    this.chart.setBackgroundPaint(this.CHART_BACKGROUND_COLOR);

    NumberAxis xAxis = (NumberAxis) this.plot.getDomainAxis();
    NumberAxis yAxis = (NumberAxis) this.plot.getRangeAxis();

    xAxis.setAxisLinePaint(this.CHART_FOREGROUND_COLOR);
    xAxis.setLabelPaint(this.CHART_FOREGROUND_COLOR);
    xAxis.setTickLabelPaint(this.CHART_FOREGROUND_COLOR);
    xAxis.setTickMarkPaint(this.CHART_FOREGROUND_COLOR);
    xAxis.setAutoRange(true);
    xAxis.setAutoRangeIncludesZero(false);

    yAxis.setAxisLinePaint(this.CHART_FOREGROUND_COLOR);
    yAxis.setLabelPaint(this.CHART_FOREGROUND_COLOR);
    yAxis.setTickLabelPaint(this.CHART_FOREGROUND_COLOR);
    yAxis.setTickMarkPaint(this.CHART_FOREGROUND_COLOR);
    yAxis.setAutoRange(true);
    yAxis.setAutoRangeIncludesZero(false);

    this.plot.setBackgroundPaint(this.CHART_FOREGROUND_COLOR);
    this.plot.setDomainGridlinePaint(this.CHART_FOREGROUND_COLOR);
    this.plot.setRangeGridlinePaint(this.CHART_FOREGROUND_COLOR);
    this.plot.setDomainCrosshairPaint(this.CROSSHAIR_COLOR);
    this.plot.setRangeCrosshairPaint(this.CROSSHAIR_COLOR);
}

From source file:org.jls.toolbox.math.chart.XYLineChart.java

/**
 * Permet de paramtrer le graphique une fois cr.
 *//*w  ww .j  a va  2  s . c  o m*/
private void setChartStyle() {
    // Paramtrage des courbes
    this.plot.setBackgroundAlpha((float) 0.0);
    this.plot.setDomainCrosshairVisible(this.isGridXVisible);
    this.plot.setDomainCrosshairLockedOnData(true);
    this.plot.setRangeCrosshairVisible(this.isGridYVisible);
    this.plot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);
    this.plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));

    NumberAxis xAxis = (NumberAxis) this.plot.getDomainAxis();
    NumberAxis yAxis = (NumberAxis) this.plot.getRangeAxis();

    this.chart.setBackgroundPaint(this.CHART_BACKGROUND_COLOR);
    xAxis.setAxisLinePaint(this.CHART_FOREGROUND_COLOR);
    xAxis.setLabelPaint(this.CHART_FOREGROUND_COLOR);
    xAxis.setTickLabelPaint(this.CHART_FOREGROUND_COLOR);
    xAxis.setTickMarkPaint(this.CHART_FOREGROUND_COLOR);
    xAxis.setAutoRange(true);
    xAxis.setAutoRangeIncludesZero(false);

    yAxis.setAxisLinePaint(this.CHART_FOREGROUND_COLOR);
    yAxis.setLabelPaint(this.CHART_FOREGROUND_COLOR);
    yAxis.setTickLabelPaint(this.CHART_FOREGROUND_COLOR);
    yAxis.setTickMarkPaint(this.CHART_FOREGROUND_COLOR);
    yAxis.setAutoRange(true);
    yAxis.setAutoRangeIncludesZero(false);

    this.plot.setBackgroundPaint(this.CHART_FOREGROUND_COLOR);
    this.plot.setDomainGridlinePaint(this.CHART_FOREGROUND_COLOR);
    this.plot.setRangeGridlinePaint(this.CHART_FOREGROUND_COLOR);
    this.plot.setDomainCrosshairPaint(this.CROSSHAIR_COLOR);
    this.plot.setRangeCrosshairPaint(this.CROSSHAIR_COLOR);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) this.plot.getRenderer();
    renderer.setBaseShapesVisible(false);
    renderer.setBaseShapesFilled(false);
}

From source file:org.jls.toolbox.math.chart.XYBlockChart.java

/**
 * Permet de paramtrer le graphique une fois cr.
 *//*from   w  w  w .  java  2 s  .  c  o m*/
private void setChartStyle() {
    this.plot.setBackgroundAlpha((float) 0.0);
    this.plot.setDomainCrosshairLockedOnData(false);
    this.plot.setRangeCrosshairLockedOnData(false);
    this.plot.setDomainCrosshairVisible(true);
    this.plot.setRangeCrosshairVisible(true);
    this.plot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);
    this.plot.setDomainGridlinesVisible(true);
    this.plot.setRangeGridlinesVisible(true);
    this.plot.setRangeGridlinePaint(Color.white);

    this.plot.setDomainCrosshairStroke(new BasicStroke(1f));
    this.plot.setRangeCrosshairStroke(new BasicStroke(1f));
    this.chart.setBackgroundPaint(this.CHART_BACKGROUND_COLOR);

    NumberAxis xAxis = (NumberAxis) this.plot.getDomainAxis();
    NumberAxis yAxis = (NumberAxis) this.plot.getRangeAxis();

    xAxis.setAxisLinePaint(this.CHART_FOREGROUND_COLOR);
    xAxis.setLabelPaint(this.CHART_FOREGROUND_COLOR);
    xAxis.setTickLabelPaint(this.CHART_FOREGROUND_COLOR);
    xAxis.setTickMarkPaint(this.CHART_FOREGROUND_COLOR);
    xAxis.setAutoRange(true);
    xAxis.setAutoRangeIncludesZero(false);

    yAxis.setAxisLinePaint(this.CHART_FOREGROUND_COLOR);
    yAxis.setLabelPaint(this.CHART_FOREGROUND_COLOR);
    yAxis.setTickLabelPaint(this.CHART_FOREGROUND_COLOR);
    yAxis.setTickMarkPaint(this.CHART_FOREGROUND_COLOR);
    yAxis.setAutoRange(true);
    yAxis.setAutoRangeIncludesZero(false);

    this.plot.setBackgroundPaint(this.CHART_FOREGROUND_COLOR);
    this.plot.setDomainGridlinePaint(this.CHART_FOREGROUND_COLOR);
    this.plot.setRangeGridlinePaint(this.CHART_FOREGROUND_COLOR);
    this.plot.setDomainCrosshairPaint(this.CROSSHAIR_COLOR);
    this.plot.setRangeCrosshairPaint(this.CROSSHAIR_COLOR);
}