Example usage for org.jfree.chart.renderer.category CategoryItemRenderer setSeriesOutlineStroke

List of usage examples for org.jfree.chart.renderer.category CategoryItemRenderer setSeriesOutlineStroke

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.category CategoryItemRenderer setSeriesOutlineStroke.

Prototype

public void setSeriesOutlineStroke(int series, Stroke stroke);

Source Link

Document

Sets the outline stroke used for a series and sends a RendererChangeEvent to all registered listeners.

Usage

From source file:net.sf.fspdfs.chartthemes.simple.SimpleChartTheme.java

protected void handleCategoryPlotSettings(CategoryPlot p, JRChartPlot jrPlot) {
    PlotSettings plotSettings = getPlotSettings();
    Double themeLabelRotation = plotSettings.getLabelRotation();
    // Handle rotation of the category labels.
    CategoryAxis axis = p.getDomainAxis();
    boolean hasRotation = jrPlot.getLabelRotationDouble() != null || themeLabelRotation != null;
    if (hasRotation) {
        double labelRotation = jrPlot.getLabelRotationDouble() != null
                ? jrPlot.getLabelRotationDouble().doubleValue()
                : themeLabelRotation.doubleValue();

        if (labelRotation == 90) {
            axis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90);
        } else if (labelRotation == -90) {
            axis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
        } else if (labelRotation < 0) {
            axis.setCategoryLabelPositions(
                    CategoryLabelPositions.createUpRotationLabelPositions((-labelRotation / 180.0) * Math.PI));
        } else if (labelRotation > 0) {
            axis.setCategoryLabelPositions(
                    CategoryLabelPositions.createDownRotationLabelPositions((labelRotation / 180.0) * Math.PI));
        }/* ww  w  .jav  a  2 s . c o  m*/
    }

    PlotOrientation plotOrientation = jrPlot.getOrientation() != null ? jrPlot.getOrientation()
            : plotSettings.getOrientation();
    if (plotOrientation != null) {
        p.setOrientation(plotOrientation);
    }

    CategoryItemRenderer categoryRenderer = p.getRenderer();
    Paint[] paintSequence = getPaintSequence(plotSettings, jrPlot);
    if (paintSequence != null) {
        for (int i = 0; i < paintSequence.length; i++) {
            categoryRenderer.setSeriesPaint(i, paintSequence[i]);
        }
    }
    Paint[] outlinePaintSequence = getOutlinePaintSequence(plotSettings);
    if (outlinePaintSequence != null) {
        for (int i = 0; i < outlinePaintSequence.length; i++) {
            categoryRenderer.setSeriesOutlinePaint(i, outlinePaintSequence[i]);
        }
    }
    Stroke[] strokeSequence = getStrokeSequence(plotSettings);
    if (strokeSequence != null) {
        for (int i = 0; i < strokeSequence.length; i++) {
            categoryRenderer.setSeriesStroke(i, strokeSequence[i]);
        }
    }
    Stroke[] outlineStrokeSequence = getOutlineStrokeSequence(plotSettings);
    if (outlineStrokeSequence != null) {
        for (int i = 0; i < outlineStrokeSequence.length; i++) {
            categoryRenderer.setSeriesOutlineStroke(i, outlineStrokeSequence[i]);
        }
    }

    Boolean domainGridlineVisible = plotSettings.getDomainGridlineVisible();
    if (domainGridlineVisible == null || domainGridlineVisible.booleanValue()) {
        PaintProvider domainGridlinePaint = plotSettings.getDomainGridlinePaint();
        if (domainGridlinePaint != null) {
            p.setDomainGridlinePaint(domainGridlinePaint.getPaint());
        }
        Stroke domainGridlineStroke = plotSettings.getDomainGridlineStroke();
        if (domainGridlineStroke != null) {
            p.setDomainGridlineStroke(domainGridlineStroke);
        }

    }
    Boolean rangeGridlineVisible = plotSettings.getRangeGridlineVisible();
    if (rangeGridlineVisible == null || rangeGridlineVisible.booleanValue()) {
        PaintProvider rangeGridlinePaint = plotSettings.getRangeGridlinePaint();
        if (rangeGridlinePaint != null) {
            p.setRangeGridlinePaint(rangeGridlinePaint.getPaint());
        }
        Stroke rangeGridlineStroke = plotSettings.getRangeGridlineStroke();
        if (rangeGridlineStroke != null) {
            p.setRangeGridlineStroke(rangeGridlineStroke);
        }
    }
}

From source file:net.sf.jasperreports.chartthemes.simple.SimpleChartTheme.java

protected void handleCategoryPlotSettings(CategoryPlot p, JRChartPlot jrPlot) {
    PlotSettings plotSettings = getPlotSettings();
    Double themeLabelRotation = plotSettings.getLabelRotation();
    // Handle rotation of the category labels.
    CategoryAxis axis = p.getDomainAxis();
    boolean hasRotation = jrPlot.getLabelRotationDouble() != null || themeLabelRotation != null;
    if (hasRotation) {
        double labelRotation = jrPlot.getLabelRotationDouble() != null ? jrPlot.getLabelRotationDouble()
                : themeLabelRotation;//from ww w .  ja va  2 s  . c  om

        if (labelRotation == 90) {
            axis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90);
        } else if (labelRotation == -90) {
            axis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
        } else if (labelRotation < 0) {
            axis.setCategoryLabelPositions(
                    CategoryLabelPositions.createUpRotationLabelPositions((-labelRotation / 180.0) * Math.PI));
        } else if (labelRotation > 0) {
            axis.setCategoryLabelPositions(
                    CategoryLabelPositions.createDownRotationLabelPositions((labelRotation / 180.0) * Math.PI));
        }
    }

    PlotOrientation plotOrientation = jrPlot.getOrientationValue() != null
            ? jrPlot.getOrientationValue().getOrientation()
            : plotSettings.getOrientation();
    if (plotOrientation != null) {
        p.setOrientation(plotOrientation);
    }

    CategoryItemRenderer categoryRenderer = p.getRenderer();
    Paint[] paintSequence = getPaintSequence(plotSettings, jrPlot);
    if (paintSequence != null) {
        for (int i = 0; i < paintSequence.length; i++) {
            categoryRenderer.setSeriesPaint(i, paintSequence[i]);
        }
    }
    Paint[] outlinePaintSequence = getOutlinePaintSequence(plotSettings);
    if (outlinePaintSequence != null) {
        for (int i = 0; i < outlinePaintSequence.length; i++) {
            categoryRenderer.setSeriesOutlinePaint(i, outlinePaintSequence[i]);
        }
    }
    Stroke[] strokeSequence = getStrokeSequence(plotSettings);
    if (strokeSequence != null) {
        for (int i = 0; i < strokeSequence.length; i++) {
            categoryRenderer.setSeriesStroke(i, strokeSequence[i]);
        }
    }
    Stroke[] outlineStrokeSequence = getOutlineStrokeSequence(plotSettings);
    if (outlineStrokeSequence != null) {
        for (int i = 0; i < outlineStrokeSequence.length; i++) {
            categoryRenderer.setSeriesOutlineStroke(i, outlineStrokeSequence[i]);
        }
    }

    Boolean domainGridlineVisible = plotSettings.getDomainGridlineVisible();
    if (domainGridlineVisible == null || domainGridlineVisible) {
        PaintProvider domainGridlinePaint = plotSettings.getDomainGridlinePaint();
        if (domainGridlinePaint != null) {
            p.setDomainGridlinePaint(domainGridlinePaint.getPaint());
        }
        Stroke domainGridlineStroke = plotSettings.getDomainGridlineStroke();
        if (domainGridlineStroke != null) {
            p.setDomainGridlineStroke(domainGridlineStroke);
        }

    }
    Boolean rangeGridlineVisible = plotSettings.getRangeGridlineVisible();
    if (rangeGridlineVisible == null || rangeGridlineVisible) {
        PaintProvider rangeGridlinePaint = plotSettings.getRangeGridlinePaint();
        if (rangeGridlinePaint != null) {
            p.setRangeGridlinePaint(rangeGridlinePaint.getPaint());
        }
        Stroke rangeGridlineStroke = plotSettings.getRangeGridlineStroke();
        if (rangeGridlineStroke != null) {
            p.setRangeGridlineStroke(rangeGridlineStroke);
        }
    }
}