Example usage for org.jfree.chart.axis CategoryLabelPositions createDownRotationLabelPositions

List of usage examples for org.jfree.chart.axis CategoryLabelPositions createDownRotationLabelPositions

Introduction

In this page you can find the example usage for org.jfree.chart.axis CategoryLabelPositions createDownRotationLabelPositions.

Prototype

public static CategoryLabelPositions createDownRotationLabelPositions(double angle) 

Source Link

Document

Creates a new instance where the category labels angled downwards by the specified amount.

Usage

From source file:Demo.LineGraph.java

private void InitChart() {
    JFreeChart chart = ChartFactory.createLineChart("Yield", "sample NB", "Probability", dataSet,
            PlotOrientation.VERTICAL, false, false, false);

    CategoryPlot plot = chart.getCategoryPlot();

    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);

    plot.setDomainGridlinesVisible(true);
    plot.setNoDataMessage("no data");

    LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();

    renderer.setBaseItemLabelsVisible(true);
    renderer.setSeriesPaint(0, Color.BLUE);

    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);/*from w w  w .j  a  va2  s  .  com*/

    renderer.setBaseItemLabelsVisible(true);
    renderer.setBasePositiveItemLabelPosition(
            new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));
    renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    renderer.setBaseItemLabelFont(new Font("Times New Romain", 0, 10));
    plot.setRenderer(renderer);

    CategoryAxis axis = plot.getDomainAxis();
    axis.setCategoryLabelPositions(CategoryLabelPositions.createDownRotationLabelPositions(Math.PI / 6.0));

    chartPane = new ChartPanel(chart);
}

From source file:ca.sqlpower.wabit.swingui.chart.ChartSwingUtil.java

/**
 * Creates a JFreeChart based on the current query results produced by the
 * given chart./*from w  w  w .  jav  a 2s  . c  o m*/
 * 
 * @param c
 *            The chart from which to produce a JFreeChart component. Must
 *            not be null.
 * @return A chart based on the data and settings in the given chart, or
 *         null if the given chart is not sufficiently configured (for
 *         example, if its type is not set) or it is currently unable to
 *         produce a result set.
 */
public static JFreeChart createChartFromQuery(Chart c)
        throws SQLException, QueryInitializationException, InterruptedException {
    logger.debug("Creating JFreeChart for Wabit chart " + c);
    ChartType chartType = c.getType();

    if (chartType == null) {
        logger.debug("Returning null (chart's type is not set)");
        return null;
    }

    final JFreeChart chart;
    if (chartType.getDatasetType().equals(DatasetType.CATEGORY)) {

        JFreeChart categoryChart = createCategoryChart(c);
        logger.debug("Made a new category chart: " + categoryChart);

        if (categoryChart != null && categoryChart.getPlot() instanceof CategoryPlot) {

            double rotationRads = Math.toRadians(c.getXAxisLabelRotation());
            CategoryLabelPositions clp;
            if (Math.abs(rotationRads) < 0.05) {
                clp = CategoryLabelPositions.STANDARD;
            } else if (rotationRads < 0) {
                clp = CategoryLabelPositions.createUpRotationLabelPositions(-rotationRads);
            } else {
                clp = CategoryLabelPositions.createDownRotationLabelPositions(rotationRads);
            }

            CategoryAxis domainAxis = categoryChart.getCategoryPlot().getDomainAxis();
            domainAxis.setMaximumCategoryLabelLines(5);
            domainAxis.setCategoryLabelPositions(clp);
        }

        chart = categoryChart;

    } else if (chartType.getDatasetType().equals(DatasetType.XY)) {

        JFreeChart xyChart = createXYChart(c);
        logger.debug("Made a new XY chart: " + xyChart);
        chart = xyChart;

    } else {

        throw new IllegalStateException("Unknown chart dataset type " + chartType.getDatasetType());

    }

    if (chart != null) {
        makeChartNice(chart);
    }

    return chart;
}

From source file:net.sf.jasperreports.engine.fill.DefaultChartTheme.java

/**
 *
 *///from  w w  w . j av a  2  s . c  om
protected void configurePlot(Plot plot) {
    plot.setOutlinePaint(null);

    if (getPlot().getOwnBackcolor() == null)// in a way, plot backcolor inheritence from chart is useless
    {
        plot.setBackgroundPaint(null);
    } else {
        plot.setBackgroundPaint(getPlot().getBackcolor());
    }

    float backgroundAlpha = getPlot().getBackgroundAlphaFloat() == null ? 1f
            : getPlot().getBackgroundAlphaFloat();
    float foregroundAlpha = getPlot().getForegroundAlphaFloat() == null ? 1f
            : getPlot().getForegroundAlphaFloat();
    plot.setBackgroundAlpha(backgroundAlpha);
    plot.setForegroundAlpha(foregroundAlpha);

    if (plot instanceof CategoryPlot) {
        // Handle rotation of the category labels.
        CategoryAxis axis = ((CategoryPlot) plot).getDomainAxis();
        // it's OK to use deprecated method here; avoiding it means attempting cast operations  
        double labelRotation = getLabelRotation();
        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));
        }
    }

    // Set any color series
    SortedSet<JRSeriesColor> seriesColors = getPlot().getSeriesColors();
    if (seriesColors != null && seriesColors.size() > 0) {
        if (seriesColors.size() == 1) {
            // Add the single color to the beginning of the color cycle, using all the default
            // colors.  To replace the defaults you have to specify at least two colors.
            Paint[] colors = new Paint[DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE.length + 1];
            colors[0] = seriesColors.first().getColor();
            System.arraycopy(DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE, 0, colors, 1,
                    DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE.length);
            plot.setDrawingSupplier(
                    new DefaultDrawingSupplier(colors, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE,
                            DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE,
                            DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE,
                            DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE));
        } else if (seriesColors.size() > 1) {
            // Set up a custom drawing supplier that cycles through the user's colors
            // instead of the default colors.
            Color[] colors = new Color[seriesColors.size()];
            JRSeriesColor[] colorSequence = new JRSeriesColor[seriesColors.size()];
            seriesColors.toArray(colorSequence);
            for (int i = 0; i < colorSequence.length; i++) {
                colors[i] = colorSequence[i].getColor();
            }

            plot.setDrawingSupplier(
                    new DefaultDrawingSupplier(colors, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE,
                            DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE,
                            DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE,
                            DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE));
        }
    }
}

From source file:org.operamasks.faces.render.graph.ChartRenderer.java

private void setCategoryAxisStyles(CategoryAxis axis, UIAxis comp) {
    Double lowerMargin = comp.getLowerMargin();
    Double upperMargin = comp.getUpperMargin();
    if (lowerMargin != null)
        axis.setLowerMargin(lowerMargin);
    if (upperMargin != null)
        axis.setUpperMargin(upperMargin);

    Double labelAngle = comp.getLabelAngle();
    if (labelAngle != null) {
        CategoryLabelPositions clp;//from   w w w .j av  a2s.co m
        double angle = Math.PI * labelAngle / 180.0;
        if (angle >= 0) {
            clp = CategoryLabelPositions.createDownRotationLabelPositions(angle);
        } else {
            clp = CategoryLabelPositions.createUpRotationLabelPositions(-angle);
        }
        axis.setCategoryLabelPositions(clp);
    }
}

From source file:org.pentaho.platform.uifoundation.chart.CategoryDatasetChartDefinition.java

public void setCategoryLabelRotation(final Node rotationDirection, final Node rotationAngle) {
    // down is the default
    String direction = "down"; //$NON-NLS-1$
    if (rotationDirection != null) {
        direction = rotationDirection.getText();
    }/*from   ww w.  jav  a  2  s  . co  m*/

    if (rotationAngle != null) {
        if ("up".equalsIgnoreCase(direction)) { //$NON-NLS-1$
            setCategoryLabelPositions(CategoryLabelPositions
                    .createUpRotationLabelPositions(Double.parseDouble(rotationAngle.getText())));
        } else {
            setCategoryLabelPositions(CategoryLabelPositions
                    .createDownRotationLabelPositions(Double.parseDouble(rotationAngle.getText())));
        }
    }
}

From source file:edu.jhuapl.graphs.controller.GraphController.java

public void setTimeSeriesGraphMetaData(GraphDataInterface graphData, Double yAxisMin, Double yAxisMax,
        double maxCount, Map<String, Object> graphMetaData) {
    String graphTitle = graphData.getGraphTitle() != null ? graphData.getGraphTitle() : "";
    String xAxisLabel = graphData.getXAxisLabel() != null ? graphData.getXAxisLabel() : "";
    String yAxisLabel = graphData.getYAxisLabel() != null ? graphData.getYAxisLabel() : "";
    int graphWidth = graphData.getGraphWidth();
    int graphHeight = graphData.getGraphHeight();
    boolean percentBased = graphData.percentBased();
    int maxLabeledCategoryTicks = graphData.getMaxLabeledCategoryTicks();

    graphMetaData.put(GraphSource.GRAPH_TYPE, GraphSource.GRAPH_TYPE_LINE);
    graphMetaData.put(GraphSource.BACKGROUND_COLOR, Color.WHITE);
    graphMetaData.put(GraphSource.GRAPH_TITLE, graphTitle);
    graphMetaData.put(GraphSource.GRAPH_FONT, graphFont);
    graphMetaData.put(GraphSource.GRAPH_MINOR_TICKS, 0);
    graphMetaData.put(GraphSource.GRAPH_LEGEND, graphData.showLegend());
    graphMetaData.put(GraphSource.LEGEND_FONT, legendFont);

    SparselyLabeledCategoryAxis domainAxis;

    if (graphWidth >= 500 && graphHeight >= 300) {
        // this is a larger graph so we can add some additional properties to pretty it up
        graphMetaData.put(GraphSource.GRAPH_BORDER, true);
        graphMetaData.put(GraphSource.AXIS_OFFSET, 5.0);
        graphMetaData.put(GraphSource.GRAPH_RANGE_GRIDLINE_PAINT, Color.lightGray);

        if (yAxisLabel == null && percentBased) {
            yAxisLabel = getTranslation("Percent");
        } else if (yAxisLabel == null) {
            yAxisLabel = getTranslation("Counts");
        }//from www  .  ja v a 2 s .  c  o  m

        if (xAxisLabel == null) {
            xAxisLabel = getTranslation("Date");
        }

        domainAxis = new SparselyLabeledCategoryAxis(maxLabeledCategoryTicks, Color.lightGray);
    } else {
        yAxisLabel = "";
        xAxisLabel = "";
        domainAxis = new SparselyLabeledCategoryAxis(maxLabeledCategoryTicks);
    }

    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createDownRotationLabelPositions(45));
    domainAxis.setMaximumCategoryLabelWidthRatio(maxCategoryLabelWidthRatio);
    graphMetaData.put(JFreeChartCategoryGraphSource.DOMAIN_AXIS, domainAxis);

    graphMetaData.put(GraphSource.GRAPH_RANGE_INTEGER_TICK, !percentBased);
    graphMetaData.put(GraphSource.GRAPH_RANGE_MINOR_TICK_VISIBLE, false);

    if (yAxisMin != null && yAxisMax != null) {
        graphMetaData.put(GraphSource.GRAPH_RANGE_LOWER_BOUND, yAxisMin);
        graphMetaData.put(GraphSource.GRAPH_RANGE_UPPER_BOUND, yAxisMax);
    } else {
        graphMetaData.put(GraphSource.GRAPH_RANGE_LOWER_BOUND, 0.0);

        if (maxCount == 0) {
            // if there is no data, set the upper bound to 1.0, otherwise we
            // get a weird looking y-axis
            graphMetaData.put(GraphSource.GRAPH_RANGE_UPPER_BOUND, 1.0);
        }
        // if the maxCount is less than 1, Y-Axis labels are not displayed.
        // Found during testing % data that may be 1%
        else if (maxCount < 1) {
            graphMetaData.put(GraphSource.GRAPH_RANGE_INTEGER_TICK, false);
            graphMetaData.put(GraphSource.GRAPH_RANGE_UPPER_BOUND, maxCount * 1.05);
        } else {
            graphMetaData.put(GraphSource.GRAPH_RANGE_UPPER_BOUND, maxCount * 1.05);
        }
    }

    graphMetaData.put(GraphSource.GRAPH_Y_LABEL, yAxisLabel);
    graphMetaData.put(GraphSource.GRAPH_Y_AXIS_FONT, rangeAxisFont);
    graphMetaData.put(GraphSource.GRAPH_Y_AXIS_LABEL_FONT, rangeAxisLabelFont);
    graphMetaData.put(GraphSource.GRAPH_X_LABEL, xAxisLabel);
    graphMetaData.put(GraphSource.GRAPH_X_AXIS_FONT, domainAxisFont);
    graphMetaData.put(GraphSource.GRAPH_X_AXIS_LABEL_FONT, domainAxisLabelFont);
}

From source file:edu.jhuapl.graphs.controller.GraphController.java

public void setBarGraphMetaData(GraphDataInterface graphData, boolean stackGraph,
        Map<String, Object> graphMetaData) {
    String graphTitle = graphData.getGraphTitle() != null ? graphData.getGraphTitle() : "";
    String xAxisLabel = graphData.getXAxisLabel() != null ? graphData.getXAxisLabel() : "";
    String yAxisLabel = graphData.getYAxisLabel() != null ? graphData.getYAxisLabel() : "";
    int graphWidth = graphData.getGraphWidth();
    int graphHeight = graphData.getGraphHeight();
    boolean percentBased = graphData.percentBased();
    boolean plotHorizontal = graphData.plotHorizontal();
    int maxLabeledCategoryTicks = graphData.getMaxLabeledCategoryTicks();

    if (stackGraph) {
        graphMetaData.put(GraphSource.GRAPH_TYPE, GraphSource.GRAPH_TYPE_STACKED_BAR);
    } else {/*from  w w  w.j av  a 2 s  .c o  m*/
        graphMetaData.put(GraphSource.GRAPH_TYPE, GraphSource.GRAPH_TYPE_BAR);
    }

    if (plotHorizontal) {
        graphMetaData.put(JFreeChartBarGraphSource.PLOT_ORIENTATION, PlotOrientation.HORIZONTAL);
    }

    graphMetaData.put(GraphSource.GRAPH_LABEL_BACKGROUND_COLOR, Color.WHITE);
    graphMetaData.put(GraphSource.BACKGROUND_COLOR, Color.WHITE);
    graphMetaData.put(GraphSource.GRAPH_TITLE, graphTitle);
    graphMetaData.put(GraphSource.GRAPH_FONT, graphFont);
    graphMetaData.put(GraphSource.GRAPH_BORDER, false);
    graphMetaData.put(GraphSource.GRAPH_LEGEND, graphData.showLegend());
    graphMetaData.put(GraphSource.LEGEND_FONT, legendFont);

    SparselyLabeledCategoryAxis domainAxis;

    if (graphWidth >= 500 && graphHeight >= 300) {
        // this is a larger graph so we can add some additional properties to pretty it up
        graphMetaData.put(GraphSource.GRAPH_BORDER, true);
        graphMetaData.put(GraphSource.AXIS_OFFSET, 5.0);
        graphMetaData.put(GraphSource.GRAPH_RANGE_GRIDLINE_PAINT, Color.lightGray);

        domainAxis = new SparselyLabeledCategoryAxis(maxLabeledCategoryTicks, Color.lightGray);
    } else {
        domainAxis = new SparselyLabeledCategoryAxis(maxLabeledCategoryTicks);
    }

    if (!plotHorizontal) {
        // don't rotate labels if this is a horizontal graph
        domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createDownRotationLabelPositions(45));
    }

    domainAxis.setMaximumCategoryLabelWidthRatio(maxCategoryLabelWidthRatio);
    graphMetaData.put(JFreeChartCategoryGraphSource.DOMAIN_AXIS, domainAxis);

    graphMetaData.put(GraphSource.GRAPH_RANGE_AXIS_LOCATION, AxisLocation.BOTTOM_OR_LEFT);
    graphMetaData.put(GraphSource.GRAPH_RANGE_INTEGER_TICK, !percentBased);
    graphMetaData.put(GraphSource.GRAPH_RANGE_MINOR_TICK_VISIBLE, false);
    graphMetaData.put(GraphSource.GRAPH_Y_LABEL, yAxisLabel);
    graphMetaData.put(GraphSource.GRAPH_Y_AXIS_FONT, rangeAxisFont);
    graphMetaData.put(GraphSource.GRAPH_Y_AXIS_LABEL_FONT, rangeAxisLabelFont);
    graphMetaData.put(GraphSource.GRAPH_X_LABEL, xAxisLabel);
    graphMetaData.put(GraphSource.GRAPH_X_AXIS_FONT, domainAxisFont);
    graphMetaData.put(GraphSource.GRAPH_X_AXIS_LABEL_FONT, domainAxisLabelFont);
}

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));
        }//from  w  ww  . j  a va2 s. c  om
    }

    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.fspdfs.chartthemes.spring.GenericChartTheme.java

protected void handleCategoryPlotSettings(CategoryPlot p, JRChartPlot jrPlot) {
    Double defaultPlotLabelRotation = (Double) getDefaultValue(defaultPlotPropertiesMap,
            ChartThemesConstants.PLOT_LABEL_ROTATION);
    PlotOrientation defaultPlotOrientation = (PlotOrientation) getDefaultValue(defaultPlotPropertiesMap,
            ChartThemesConstants.PLOT_ORIENTATION);
    // Handle rotation of the category labels.
    CategoryAxis axis = p.getDomainAxis();
    boolean hasRotation = jrPlot.getLabelRotationDouble() != null || defaultPlotLabelRotation != null;
    if (hasRotation) {
        double labelRotation = jrPlot.getLabelRotationDouble() != null
                ? jrPlot.getLabelRotationDouble().doubleValue()
                : defaultPlotLabelRotation.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));
        }//from   ww w . j  a  v a2 s .  com
    }

    if (defaultPlotOrientation != null) {
        p.setOrientation(defaultPlotOrientation);
    }
}

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  v  a  2s . 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);
        }
    }
}