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

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

Introduction

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

Prototype

public void setTickLabelPaint(Paint paint) 

Source Link

Document

Sets the paint used to draw tick labels (if they are showing) and sends an AxisChangeEvent to all registered listeners.

Usage

From source file:no.met.jtimeseries.marinogram.MarinogramWavePlot.java

private XYPlot createPlot(TimeZone timezone, boolean plotWaveDirection, boolean plotWaveHeight) {
    ChartPlotter plotter = new ChartPlotter();
    // default setting
    plotter.setHeight(this.getHeight());
    plotter.setWidth(this.getWidth());
    plotter.setPlotDefaultProperties("", "");
    Color waveHeightColor = new Color(0, 105, 161);
    Color waveDirectionColor = new Color(0, 105, 161);
    // plot style
    PlotStyle.Builder waveStyleBuilder = new PlotStyle.Builder("Wave");
    PlotStyle plotStyle;/*from   w w w .  jav  a 2 s  .  c om*/
    NumberPhenomenon waveDirection = getOceanForecastDataModel()
            .getPhenomenen(PhenomenonName.WaveDirection.toString(), NumberPhenomenon.class);
    NumberPhenomenon waveHeight = getOceanForecastDataModel()
            .getPhenomenen(PhenomenonName.WaveHeight.toString(), NumberPhenomenon.class);
    if (waveHeight == null || waveDirection == null) {
        return null;
    }

    double tick = (waveHeight.getMaxValue() - waveHeight.getMinValue()) / 2;
    tick = Math.ceil(tick);
    double lowBound = Math.floor(waveHeight.getMinValue() / (tick)) * (tick);
    //The minimum scale is 0
    lowBound = lowBound < 0 ? 0 : lowBound;
    lowBound = lowBound - tick / 2;
    double upperBound = lowBound + tick * 4;

    // reference the range axis
    NumberAxis leftNumberAxis = new NumberAxis();
    leftNumberAxis.setLabel(messages.getString("parameter.wave") + " (m)");
    leftNumberAxis.setLabelPaint(waveHeightColor);
    leftNumberAxis.setTickLabelPaint(waveHeightColor);
    leftNumberAxis.setLowerBound(lowBound);
    leftNumberAxis.setUpperBound(upperBound);
    leftNumberAxis.setTickUnit(new NumberTickUnit(tick));

    NumberAxis rightNumberAxis = new NumberAxis();
    rightNumberAxis.setLabelPaint(waveHeightColor);
    rightNumberAxis.setTickLabelPaint(waveHeightColor);
    rightNumberAxis.setLowerBound(lowBound);
    rightNumberAxis.setUpperBound(upperBound);
    rightNumberAxis.setTickUnit(new NumberTickUnit(tick));

    List<Date> shortTermTime = this.getShortTermTime(waveDirection.getTime().get(0));

    //set thte plot wave height color to be transparent if show wave height is false
    if (!plotWaveHeight) {
        waveHeightColor = new Color(0, 0, 0, 0);
    }

    // plot style
    plotStyle = waveStyleBuilder.spline(SplineStyle.HYBRID).stroke(new BasicStroke(2.0f))
            .seriesColor(waveHeightColor).numberAxis(leftNumberAxis).nonNegative(true).build();

    //Draw the wave height even if plotWaveHeight is false (but with transparent in such a case)
    //for the purpose to keep the same background grid and tick label on the y-axis 
    //no matter the wave height is shown or not
    plotter.addLineChart(TimeBase.SECOND, waveHeight, plotStyle);

    plotter.getPlot().setRangeAxis(1, rightNumberAxis);
    plotter.getPlot().setOutlineVisible(true);

    // first set domain date format and then add hour based domain grid
    // lines
    // TODO: wrap this inside the addHourBasedDomainGridLines for
    // simplicity

    Date minDate = shortTermTime.get(0);
    Date maxDate = shortTermTime.get(shortTermTime.size() - 1);
    plotter.setDomainRange(minDate, maxDate);
    plotter.setDomainDateFormat(timezone, "HH");
    // set domain range after (must) plot all the data
    plotter.addHourBasedDomainGridLines();
    // invisible domain axis
    plotter.getPlot().getDomainAxis().setTickLabelsVisible(false);
    // add markers
    plotter.addDomainMarkers(shortTermTime, timezone, locale);

    if (plotWaveDirection) {
        List<Date> symbolTimes = Utility.filterMinimumHourInterval(waveDirection.getTime(), 2, 1);
        InListFromDateFilter symbolTimesFilter = new InListFromDateFilter(symbolTimes);
        waveDirection.filter(symbolTimesFilter);
        waveHeight = null;
        if (plotWaveHeight) {
            waveHeight = getOceanForecastDataModel().getPhenomenen(PhenomenonName.WaveHeight.toString(),
                    NumberPhenomenon.class);
            waveHeight.filter(symbolTimesFilter);
        }

        plotStyle = waveStyleBuilder.seriesColor(waveDirectionColor).build();
        plotter.addArrowDirectionPlot(waveDirection, waveHeight, 0.1, plotStyle);
    }
    plotter.getPlot().setRangeZeroBaselineVisible(false);

    return plotter.getPlot();

}

From source file:org.n52.io.measurement.img.ChartIoHandler.java

public ValueAxis createRangeAxis(DatasetOutput metadata) {
    NumberAxis axis = new NumberAxis(createRangeLabel(metadata));
    axis.setTickLabelFont(FONT_LABEL);//ww  w.ja v  a  2s.c o  m
    axis.setLabelFont(FONT_LABEL);
    axis.setTickLabelPaint(COLOR);
    axis.setLabelPaint(COLOR);
    return axis;
}

From source file:web.diva.server.unused.ProfilePlotGenerator.java

/**
 * Creates a line chart (based on an {@link XYDataset}) with default
 * settings./*from   w  w  w.  j  a  v  a2 s.  co m*/
 *
 * @param title the chart title (<code>null</code> permitted).
 * @param xAxisLabel a label for the X-axis (<code>null</code> permitted).
 * @param yAxisLabel a label for the Y-axis (<code>null</code> permitted).
 * @param dataset the dataset for the chart (<code>null</code> permitted).
 * @param orientation the plot orientation (horizontal or vertical)
 * (<code>null</code> NOT permitted).
 * @param legend a flag specifying whether or not a legend is required.
 * @param tooltips configure chart to generate tool tips?
 * @param urls configure chart to generate URLs?
 *
 * @return The chart.
 */
private JFreeChart createXYLineChart(String title, String[] columnIds, XYDataset dataset,
        PlotOrientation orientation, boolean legend, boolean urls) {

    if (orientation == null) {
        throw new IllegalArgumentException("Null 'orientation' argument.");
    }
    Font f = new Font("ARIAL", 1, 7);
    //        NumberAxis xAxis = new NumberAxis(xAxisLabel);
    //        xAxis.setAutoRangeIncludesZero(false);
    SymbolAxis xAxis = new SymbolAxis("", columnIds);
    xAxis.setAxisLineVisible(false);
    xAxis.setGridBandsVisible(false);
    xAxis.setVerticalTickLabels(true);
    xAxis.setVisible(true);

    xAxis.setTickLabelPaint(shadowColor);
    xAxis.setTickLabelFont(f);
    xAxis.setFixedDimension(51.0);

    boolean auto = xAxis.getAutoRangeIncludesZero();
    xAxis.setAutoRangeIncludesZero(true ^ auto);
    xAxis.setTickUnit(new NumberTickUnit(1));
    xAxis.setRange(0, columnIds.length);
    //        NumberAxis yAxis = new NumberAxis(yAxisLabel);
    NumberAxis yAxis = new NumberAxis();
    yAxis.setAutoRangeIncludesZero(true ^ auto);
    yAxis.setAxisLineVisible(false);
    yAxis.setTickLabelFont(f);
    yAxis.setTickLabelPaint(Color.BLUE);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);
    renderer.setBaseShapesVisible(false);
    renderer.setPaint(shadowColor);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setOrientation(orientation);

    plot.setBackgroundPaint(Color.WHITE);

    plot.setDomainGridlinePaint(shadowColor);
    plot.setRangeGridlinePaint(shadowColor);
    plot.setOutlinePaint(Color.BLUE);
    //        XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();

    //        plot.setRenderer(renderer);
    plot.setSeriesRenderingOrder(SeriesRenderingOrder.REVERSE);

    plot.setDomainAxis(xAxis);

    if (urls) {
        renderer.setURLGenerator(new StandardXYURLGenerator());
    }

    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    return chart;

}

From source file:no.met.jtimeseries.marinogram.MarinogramCurrentPlot.java

private XYPlot createPlot(TimeZone timezone, boolean plotCurrentDirection, boolean plotCurrentSpeed) {
    ChartPlotter plotter = new ChartPlotter();
    // default setting
    plotter.setHeight(this.getHeight());
    plotter.setWidth(this.getWidth());
    plotter.setPlotDefaultProperties("", "");
    Color currentSpeedColor = new Color(142, 25, 131);
    Color currentDirectionColor = new Color(142, 25, 131);
    // plot style
    PlotStyle.Builder currentStyleBuilder = new PlotStyle.Builder("Current");
    PlotStyle plotStyle;//from  w ww.  j  av a  2 s.c  om
    NumberPhenomenon currentDirection = getOceanForecastDataModel()
            .getPhenomenen(PhenomenonName.CurrentDirection.toString(), NumberPhenomenon.class);
    NumberPhenomenon currentSpeed = getOceanForecastDataModel()
            .getPhenomenen(PhenomenonName.CurrentSpeed.toString(), NumberPhenomenon.class);
    if (currentSpeed == null || currentDirection == null) {
        return null;
    }
    currentSpeed = currentSpeed.scaling(100);
    double tick = (currentSpeed.getMaxValue() - currentSpeed.getMinValue()) / 2;
    tick = Math.ceil(tick / 10) * 10;
    double lowBound = Math.floor(currentSpeed.getMinValue() / (tick)) * (tick);
    //The minimum scale is 0
    lowBound = lowBound < 0 ? 0 : lowBound;
    lowBound = lowBound - tick / 2;
    double upperBound = lowBound + tick * 4;

    // reference the range axis
    NumberAxis leftNumberAxis = new NumberAxis();
    leftNumberAxis.setLabel(messages.getString("parameter.current") + " (cm/s)");
    leftNumberAxis.setLabelPaint(currentSpeedColor);
    leftNumberAxis.setTickLabelPaint(currentSpeedColor);
    leftNumberAxis.setLowerBound(lowBound);
    leftNumberAxis.setUpperBound(upperBound);
    leftNumberAxis.setTickUnit(new NumberTickUnit(tick));

    NumberAxis rightNumberAxis = new NumberAxis();
    rightNumberAxis.setLabel(messages.getString("label.knots"));
    rightNumberAxis.setLabelPaint(currentSpeedColor);
    rightNumberAxis.setTickLabelPaint(currentSpeedColor);
    lowBound = lowBound / 100.0 / KNOT;
    upperBound = upperBound / 100.0 / KNOT;
    rightNumberAxis.setLowerBound(lowBound);
    rightNumberAxis.setUpperBound(upperBound);
    rightNumberAxis.setTickUnit(new NumberTickUnit(tick / 100.0 / KNOT));
    NumberFormat formatter = new DecimalFormat("#0.00");
    rightNumberAxis.setNumberFormatOverride(formatter);

    List<Date> shortTermTimeList = this.getShortTermTime(currentDirection.getTime().get(0));

    //set thte plot current speed color to be transparent if show current speed is false
    if (!plotCurrentSpeed) {
        currentSpeedColor = new Color(0, 0, 0, 0);
    }

    // plot style
    BasicStroke dottedStroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 2.0f,
            new float[] { 2.0f, 6.0f }, 0.0f);
    plotStyle = currentStyleBuilder.spline(SplineStyle.HYBRID).stroke(dottedStroke)
            .seriesColor(currentSpeedColor).numberAxis(leftNumberAxis).nonNegative(true).build();

    //Draw the current direction even if plotCurrentSpeed is false (but with transparent in such a case)
    //for the purpose to keep the same background grid and tick label on the y-axis 
    //no matter the wave height is shown or not
    plotter.addLineChart(TimeBase.SECOND, currentSpeed, plotStyle);

    plotter.getPlot().setRangeAxis(1, rightNumberAxis);
    plotter.getPlot().setOutlineVisible(true);

    Date minDate = shortTermTimeList.get(0);
    Date maxDate = shortTermTimeList.get(shortTermTimeList.size() - 1);
    plotter.setDomainRange(minDate, maxDate);
    plotter.setDomainDateFormat(timezone, "HH");
    // set domain range after (must) plot all the data
    plotter.addHourBasedDomainGridLines();
    // invisible domain axis
    plotter.getPlot().getDomainAxis().setTickLabelsVisible(false);
    // add markers
    plotter.addDomainMarkers(shortTermTimeList, timezone, locale);

    if (plotCurrentDirection) {
        List<Date> symbolTimes = Utility.filterMinimumHourInterval(currentDirection.getTime(), 2, 1);
        InListFromDateFilter symbolTimesFilter = new InListFromDateFilter(symbolTimes);
        currentDirection.filter(symbolTimesFilter);
        currentSpeed = null;
        if (plotCurrentSpeed) {
            currentSpeed = getOceanForecastDataModel().getPhenomenen(PhenomenonName.CurrentSpeed.toString(),
                    NumberPhenomenon.class);
            currentSpeed.filter(symbolTimesFilter);
            currentSpeed = currentSpeed.scaling(1 / 100.0 / KNOT);
        }

        plotStyle = currentStyleBuilder.seriesColor(currentDirectionColor).build();
        plotter.addArrowDirectionPlot(currentDirection, currentSpeed, 2, plotStyle);
    }
    plotter.getPlot().setRangeZeroBaselineVisible(false);

    return plotter.getPlot();

}

From source file:no.met.jtimeseries.marinogram.MarinogramWindPlot.java

private XYPlot createPlot(TimeZone timezone, boolean plotWindDirection, boolean plotWindSpeed) {
    ChartPlotter plotter = new ChartPlotter();
    // default setting
    plotter.setHeight(this.getHeight());
    plotter.setWidth(this.getWidth());
    plotter.setPlotDefaultProperties("", "");
    Color windSpeedColor = new Color(0, 0, 0);
    Color windDirectionColor = new Color(0, 0, 0);
    // plot style
    PlotStyle.Builder currentStyleBuilder = new PlotStyle.Builder("Wind");
    PlotStyle plotStyle;/*w  w  w.  j  av a  2 s. co  m*/
    NumberPhenomenon windDirection = getLocationForecastDataModel()
            .getPhenomenen(PhenomenonName.WindDirectionDegree.toString(), NumberPhenomenon.class);
    NumberPhenomenon windSpeed = getLocationForecastDataModel()
            .getPhenomenen(PhenomenonName.WindSpeedMPS.toString(), NumberPhenomenon.class);
    if (windSpeed == null || windDirection == null) {
        return null;
    }

    double tick = (windSpeed.getMaxValue() - windSpeed.getMinValue()) / 3;
    tick = Math.ceil(tick);
    double lowBound = Math.floor(windSpeed.getMinValue() / (tick)) * (tick);
    //The minimum scale is 0
    lowBound = lowBound < 0 ? 0 : lowBound;
    lowBound = lowBound - tick / 2;
    double upperBound = lowBound + tick * 6;

    // reference the range axis
    NumberAxis leftNumberAxis = new NumberAxis();
    leftNumberAxis.setLabel(messages.getString("parameter.wind") + " (m/s)");
    leftNumberAxis.setLabelPaint(windSpeedColor);
    leftNumberAxis.setTickLabelPaint(windSpeedColor);
    //int tickUnit = (int) Math.ceil((upperBound - lowBound) / 6);
    leftNumberAxis.setTickUnit(new NumberTickUnit(tick));
    leftNumberAxis.setLowerBound(lowBound);
    leftNumberAxis.setUpperBound(upperBound);

    NumberAxis rightNumberAxis = new NumberAxis();
    rightNumberAxis.setLabel(messages.getString("label.knots"));
    rightNumberAxis.setLabelPaint(windSpeedColor);
    rightNumberAxis.setTickLabelPaint(windSpeedColor);
    lowBound = lowBound / KNOT;
    upperBound = upperBound / KNOT;
    rightNumberAxis.setLowerBound(lowBound);
    rightNumberAxis.setUpperBound(upperBound);
    rightNumberAxis.setTickUnit(new NumberTickUnit(tick / KNOT));
    NumberFormat formatter = new DecimalFormat("#0.0");
    rightNumberAxis.setNumberFormatOverride(formatter);

    List<Date> shortTermTimeList = this.getShortTermTime(windDirection.getTime().get(0));

    // set thte plot current speed color to be transparent if show current
    // speed is false
    if (!plotWindSpeed) {
        windSpeedColor = new Color(0, 0, 0, 0);
    }

    // plot style
    plotStyle = currentStyleBuilder.spline(SplineStyle.HYBRID).stroke(new BasicStroke(2.0f))
            .seriesColor(windSpeedColor).numberAxis(leftNumberAxis).nonNegative(true).build();

    // Draw the current direction even if plotCurrentSpeed is false (but
    // with transparent in such a case)
    // for the purpose to keep the same background grid and tick label on
    // the y-axis
    // no matter the wave height is shown or not
    plotter.addLineChart(TimeBase.SECOND, windSpeed, plotStyle);

    plotter.getPlot().setRangeAxis(1, rightNumberAxis);
    plotter.getPlot().setOutlineVisible(true);

    Date minDate = shortTermTimeList.get(0);
    Date maxDate = shortTermTimeList.get(shortTermTimeList.size() - 1);
    plotter.setDomainRange(minDate, maxDate);
    plotter.setDomainDateFormat(timezone, "HH");
    // set domain range after (must) plot all the data
    plotter.addHourBasedDomainGridLines();
    // invisible domain axis
    plotter.getPlot().getDomainAxis().setTickLabelsVisible(false);
    // add markers
    plotter.addDomainMarkers(shortTermTimeList, timezone, locale);

    if (plotWindDirection) {
        List<Date> symbolTimes = Utility.filterMinimumHourInterval(windDirection.getTime(), 2, 1);
        InListFromDateFilter symbolTimesFilter = new InListFromDateFilter(symbolTimes);
        windDirection.filter(symbolTimesFilter);
        windSpeed = null;
        if (plotWindSpeed) {
            windSpeed = getLocationForecastDataModel().getPhenomenen(PhenomenonName.WindSpeedMPS.toString(),
                    NumberPhenomenon.class);
            windSpeed.filter(symbolTimesFilter);
            windSpeed = windSpeed.scaling(1 / KNOT);
        }

        plotStyle = currentStyleBuilder.seriesColor(windDirectionColor).build();
        // when plot wind direction, the arrow should be rotated 180 degree
        windDirection = windDirection.transform(180);
        plotter.addArrowDirectionPlot(windDirection, windSpeed, 2, plotStyle);
        // transform back after plot
        windDirection = windDirection.transform(180);
    }
    plotter.getPlot().setRangeZeroBaselineVisible(false);

    return plotter.getPlot();

}

From source file:be.nbb.demetra.dfm.output.FactorChart.java

private JFreeChart createMarginViewChart() {
    JFreeChart result = ChartFactory.createXYLineChart("", "", "", Charts.emptyXYDataset(),
            PlotOrientation.VERTICAL, false, false, false);
    result.setPadding(TsCharts.CHART_PADDING);

    XYPlot plot = result.getXYPlot();/*from   w  w  w . ja va2s .  c om*/
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

    LinesThickness linesThickness = LinesThickness.Thin;

    XYLineAndShapeRenderer factor = new LineRenderer(FACTOR_INDEX);
    plot.setRenderer(FACTOR_INDEX, factor);

    XYLineAndShapeRenderer filtered = new LineRenderer(FILTERED_INDEX);
    plot.setRenderer(FILTERED_INDEX, filtered);

    XYDifferenceRenderer difference = new XYDifferenceRenderer();
    difference.setAutoPopulateSeriesPaint(false);
    difference.setAutoPopulateSeriesStroke(false);
    difference.setBaseStroke(TsCharts.getNormalStroke(linesThickness));
    plot.setRenderer(DIFFERENCE_INDEX, difference);

    DateAxis domainAxis = new DateAxis();
    domainAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
    domainAxis.setTickLabelPaint(TsCharts.CHART_TICK_LABEL_COLOR);
    plot.setDomainAxis(domainAxis);

    NumberAxis rangeAxis = new NumberAxis();
    rangeAxis.setAutoRangeIncludesZero(false);
    rangeAxis.setTickLabelPaint(TsCharts.CHART_TICK_LABEL_COLOR);
    plot.setRangeAxis(rangeAxis);

    return result;
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.linecharts.LineChart.java

public JFreeChart createChart() {

    logger.debug("IN");
    CategoryPlot plot = new CategoryPlot();

    NumberAxis rangeAxis = new NumberAxis("Kpi Values");
    rangeAxis.setLabelFont(new Font("Arial", Font.PLAIN, 12));
    Color colorLabel = Color.decode("#000000");
    rangeAxis.setLabelPaint(colorLabel);
    rangeAxis.setTickLabelFont(new Font("Arial", Font.PLAIN, 10));
    rangeAxis.setTickLabelPaint(colorLabel);
    plot.setRangeAxis(rangeAxis);//from w  w  w.j a  v  a 2  s.  c o m

    CategoryAxis domainAxis = new CategoryAxis();
    domainAxis.setLabelFont(new Font("Arial", Font.PLAIN, 10));
    domainAxis.setLabelPaint(colorLabel);
    domainAxis.setTickLabelFont(new Font("Arial", Font.PLAIN, 10));
    domainAxis.setTickLabelPaint(colorLabel);
    plot.setDomainAxis(domainAxis);

    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setRangeGridlinesVisible(true);
    plot.setDomainGridlinesVisible(true);

    //I create a line renderer 
    MyStandardCategoryItemLabelGenerator generator = null;

    LineAndShapeRenderer lineRenderer = new LineAndShapeRenderer();
    lineRenderer.setShapesFilled(true);
    lineRenderer.setBaseItemLabelGenerator(generator);
    lineRenderer.setBaseItemLabelFont(new Font("Arial", Font.PLAIN, 12));
    lineRenderer.setBaseItemLabelPaint(colorLabel);
    lineRenderer.setBaseItemLabelsVisible(true);

    DefaultCategoryDataset datasetLine = (DefaultCategoryDataset) datasetMap.getDatasets().get("line");

    for (Iterator iterator = datasetLine.getRowKeys().iterator(); iterator.hasNext();) {
        String serName = (String) iterator.next();
        String labelName = "";
        int index = -1;
        index = datasetLine.getRowIndex(serName);

        Color color = Color.decode("#990200");
        lineRenderer.setSeriesPaint(index, color);
    }

    plot.setDataset(0, datasetLine);
    plot.setRenderer(0, lineRenderer);

    plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    JFreeChart chart = new JFreeChart(plot);
    logger.debug("Chart created");
    TextTitle title = new TextTitle(name, new Font("Arial", Font.BOLD, 16), Color.decode("#990200"),
            RectangleEdge.TOP, HorizontalAlignment.CENTER, VerticalAlignment.TOP, RectangleInsets.ZERO_INSETS);
    chart.setTitle(title);
    TextTitle subTitle = new TextTitle(subName, new Font("Arial", Font.PLAIN, 12), Color.decode("#000000"),
            RectangleEdge.TOP, HorizontalAlignment.CENTER, VerticalAlignment.TOP, RectangleInsets.ZERO_INSETS);
    chart.addSubtitle(subTitle);
    TextTitle subTitle2 = new TextTitle(subName, new Font("Arial", Font.PLAIN, 8), Color.decode("#FFFFFF"),
            RectangleEdge.TOP, HorizontalAlignment.CENTER, VerticalAlignment.TOP, RectangleInsets.ZERO_INSETS);
    chart.addSubtitle(subTitle2);
    chart.removeLegend();

    chart.setBackgroundPaint(Color.white);
    logger.debug("OUT");
    return chart;
}

From source file:it.eng.spagobi.engines.kpi.bo.charttypes.trendcharts.LineChart.java

public JFreeChart createChart() {

    logger.debug("IN");
    CategoryPlot plot = new CategoryPlot();
    IMessageBuilder msgBuilder = MessageBuilderFactory.getMessageBuilder();
    String rangeAxisName = msgBuilder.getMessage("sbi.kpi.rangeAxisName");
    NumberAxis rangeAxis = new NumberAxis(rangeAxisName);
    rangeAxis.setLabelFont(new Font("Arial", Font.PLAIN, 12));
    Color colorLabel = Color.decode("#000000");
    rangeAxis.setLabelPaint(colorLabel);
    rangeAxis.setTickLabelFont(new Font("Arial", Font.PLAIN, 10));
    rangeAxis.setTickLabelPaint(colorLabel);
    plot.setRangeAxis(rangeAxis);//w w  w .  j av  a2 s  .c om

    CategoryAxis domainAxis = new CategoryAxis();
    domainAxis.setLabelFont(new Font("Arial", Font.PLAIN, 10));
    domainAxis.setLabelPaint(colorLabel);
    domainAxis.setTickLabelFont(new Font("Arial", Font.PLAIN, 10));
    domainAxis.setTickLabelPaint(colorLabel);
    plot.setDomainAxis(domainAxis);

    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setRangeGridlinesVisible(true);
    plot.setDomainGridlinesVisible(true);

    //I create a line renderer 
    MyStandardCategoryItemLabelGenerator generator = null;

    LineAndShapeRenderer lineRenderer = new LineAndShapeRenderer();
    lineRenderer.setShapesFilled(true);
    lineRenderer.setBaseItemLabelGenerator(generator);
    lineRenderer.setBaseItemLabelFont(new Font("Arial", Font.PLAIN, 12));
    lineRenderer.setBaseItemLabelPaint(colorLabel);
    lineRenderer.setBaseItemLabelsVisible(true);

    DefaultCategoryDataset datasetLine = (DefaultCategoryDataset) datasetMap.getDatasets().get("line");

    for (Iterator iterator = datasetLine.getRowKeys().iterator(); iterator.hasNext();) {
        String serName = (String) iterator.next();
        String labelName = "";
        int index = -1;
        index = datasetLine.getRowIndex(serName);

        Color color = Color.decode("#990200");
        lineRenderer.setSeriesPaint(index, color);
    }

    plot.setDataset(0, datasetLine);
    plot.setRenderer(0, lineRenderer);

    plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    JFreeChart chart = new JFreeChart(plot);
    logger.debug("Chart created");
    TextTitle title = new TextTitle(name, new Font("Arial", Font.BOLD, 16), Color.decode("#990200"),
            RectangleEdge.TOP, HorizontalAlignment.CENTER, VerticalAlignment.TOP, RectangleInsets.ZERO_INSETS);
    chart.setTitle(title);
    TextTitle subTitle = new TextTitle(subName, new Font("Arial", Font.PLAIN, 12), Color.decode("#000000"),
            RectangleEdge.TOP, HorizontalAlignment.CENTER, VerticalAlignment.TOP, RectangleInsets.ZERO_INSETS);
    chart.addSubtitle(subTitle);
    TextTitle subTitle2 = new TextTitle(subName, new Font("Arial", Font.PLAIN, 8), Color.decode("#FFFFFF"),
            RectangleEdge.TOP, HorizontalAlignment.CENTER, VerticalAlignment.TOP, RectangleInsets.ZERO_INSETS);
    chart.addSubtitle(subTitle2);
    chart.removeLegend();

    chart.setBackgroundPaint(Color.white);
    logger.debug("OUT");
    return chart;
}

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

/**
 * Permet de paramtrer le graphique une fois cr.
 *///  w  w w .  ja  va 2s  . co  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.n52.io.type.quantity.handler.img.ChartIoHandler.java

public ValueAxis createRangeAxis(DatasetOutput metadata) {
    NumberAxis axis = new NumberAxis(createRangeLabel(metadata));
    axis.setTickLabelFont(LabelConstants.FONT_LABEL);
    axis.setLabelFont(LabelConstants.FONT_LABEL);
    axis.setTickLabelPaint(LabelConstants.COLOR);
    axis.setLabelPaint(LabelConstants.COLOR);
    return axis;//  w ww.j  av a  2s  .  com
}