Example usage for org.jfree.chart.axis Axis setTickMarkOutsideLength

List of usage examples for org.jfree.chart.axis Axis setTickMarkOutsideLength

Introduction

In this page you can find the example usage for org.jfree.chart.axis Axis setTickMarkOutsideLength.

Prototype

public void setTickMarkOutsideLength(float length) 

Source Link

Document

Sets the outside length of the tick marks and sends an AxisChangeEvent to all registered listeners.

Usage

From source file:org.openfaces.component.chart.impl.helpers.AxisUtil.java

public static void setupAxisPresentation(String label, Axis axis, FakeAxisStyle axisStyle) {
    StyleObjectModel model = axisStyle.getStyleObjectModel();
    StyleBorderModel border = model.getBorder();
    if (border != null) {
        if (border.getColor() != null) {
            axis.setAxisLinePaint(border.getColor());
        }//from w w w . j  a va  2  s  .  c  om

        if (!border.isNone()) {
            axis.setAxisLineVisible(true);
            axis.setAxisLineStroke(PropertiesConverter.toStroke(border));
            axis.setTickMarkPaint(border.getColor());
            axis.setTickMarksVisible(true);
            if (!axis.isTickMarksVisible())
                axis.setTickMarksVisible(false);
        }

        if (border.getStyle().equalsIgnoreCase("none")) {
            axis.setAxisLineVisible(false);
            axis.setTickMarksVisible(false);
            if (axis.isTickMarksVisible())
                axis.setTickMarksVisible(true);
        }

    }

    axis.setTickLabelsVisible(axisStyle.isTickLabelsVisible());

    if (axisStyle.isLabelVisible() && label != null) {
        axis.setLabel(label);
        axis.setLabelPaint(model.getColor());
        axis.setLabelFont(CSSUtil.getFont(model));
    }

    if (axisStyle.isTickLabelsVisible()) {
        axis.setTickLabelsVisible(true);
        axis.setTickLabelPaint(model.getColor());
        axis.setTickLabelFont(CSSUtil.getFont(model));
    } else {
        axis.setTickLabelsVisible(false);
    }

    Double tickInterval = axisStyle.getTickInterval();
    if (tickInterval != null && tickInterval != 0 && axis instanceof NumberAxis) {
        NumberAxis numberAxis = (NumberAxis) axis;
        if (tickInterval > 0) {
            NumberTickUnit tickUnit = new NumberTickUnit(tickInterval);
            numberAxis.setTickUnit(tickUnit);
        } else if (tickInterval == -1) {
            TickUnitSource tickUnits = NumberAxis.createIntegerTickUnits();
            numberAxis.setStandardTickUnits(tickUnits);
        } else {
            throw new FacesException("tickInterval must be a positive number for a fixed tick interval, "
                    + "or -1 for automatic integer tick selection: " + tickInterval);
        }

        numberAxis.setMinorTickMarksVisible(true);
        numberAxis.setMinorTickCount(2);
        numberAxis.setMinorTickMarkOutsideLength(3);
        numberAxis.setMinorTickMarkInsideLength(3);
        numberAxis.setTickMarkInsideLength(5);
        numberAxis.setTickMarkOutsideLength(5);
    }

    axis.setTickMarkInsideLength(axisStyle.getTickInsideLength());
    axis.setTickMarkOutsideLength(axisStyle.getTickOutsideLength());
    if (axisStyle.getMinorTicksVisible()) {
        axis.setMinorTickMarksVisible(true);
        if (axis instanceof ValueAxis)
            ((ValueAxis) axis).setMinorTickCount(axisStyle.getMinorTickCount() + 1);
        axis.setMinorTickMarkInsideLength(axisStyle.getMinorTickInsideLength());
        axis.setMinorTickMarkOutsideLength(axisStyle.getMinorTickOutsideLength());
    } else {
        axis.setMinorTickMarksVisible(false);
    }
}

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

protected void setAxisStyles(Axis axis, UIAxis comp) {
    axis.setVisible(comp.isVisible());//from   w  ww . j av a 2  s .  c om
    axis.setAxisLineVisible(comp.isDrawLine());
    axis.setTickLabelsVisible(comp.isDrawTickLabels());
    axis.setTickMarksVisible(comp.isDrawTickMarks());

    String label = comp.getLabel();
    Font labelFont = comp.getLabelFont();
    Paint labelColor = comp.getLabelColor();
    Paint lineColor = comp.getLineColor();
    Font tickLabelFont = comp.getTickLabelFont();
    Paint tickLabelColor = comp.getTickLabelColor();
    Paint tickMarkColor = comp.getTickMarkColor();

    if (label != null)
        axis.setLabel(label);
    if (labelFont != null)
        axis.setLabelFont(labelFont);
    if (labelColor != null)
        axis.setLabelPaint(labelColor);
    if (lineColor != null)
        axis.setAxisLinePaint(lineColor);
    if (tickLabelFont != null)
        axis.setTickLabelFont(tickLabelFont);
    if (tickLabelColor != null)
        axis.setTickLabelPaint(tickLabelColor);
    if (tickMarkColor != null)
        axis.setTickMarkPaint(tickMarkColor);
    axis.setTickMarkInsideLength(comp.getTickMarkInsideLength());
    axis.setTickMarkOutsideLength(comp.getTickMarkOutsideLength());

    if (axis instanceof CategoryAxis) {
        setCategoryAxisStyles((CategoryAxis) axis, comp);
    } else if (axis instanceof DateAxis) {
        setDateAxisStyles((DateAxis) axis, comp);
    } else if (axis instanceof NumberAxis) {
        setNumberAxisStyles((NumberAxis) axis, comp);
    }
}

From source file:com.xpn.xwiki.plugin.charts.ChartCustomizer.java

public static void customizeAxis(Axis axis, ChartParams params, String prefix) {

    if (params.get(prefix + ChartParams.AXIS_VISIBLE_SUFIX) != null
            && params.getBoolean(prefix + ChartParams.AXIS_VISIBLE_SUFIX).booleanValue() == false) {
        axis.setVisible(false);/*  ww  w  .  j a va2  s. c om*/

    } else {
        if (params.get(prefix + ChartParams.AXIS_LINE_VISIBLE_SUFFIX) != null) {
            if (params.getBoolean(prefix + ChartParams.AXIS_LINE_VISIBLE_SUFFIX).booleanValue()) {
                axis.setAxisLineVisible(true);

                if (params.get(prefix + ChartParams.AXIS_LINE_COLOR_SUFFIX) != null) {
                    axis.setAxisLinePaint(params.getColor(prefix + ChartParams.AXIS_LINE_COLOR_SUFFIX));
                }

                if (params.get(prefix + ChartParams.AXIS_LINE_STROKE_SUFFIX) != null) {
                    axis.setAxisLineStroke(params.getStroke(prefix + ChartParams.AXIS_LINE_STROKE_SUFFIX));
                }
            } else {
                axis.setAxisLineVisible(false);
            }
        }

        if (params.get(prefix + ChartParams.AXIS_LABEL_SUFFIX) != null) {
            axis.setLabel(params.getString(prefix + ChartParams.AXIS_LABEL_SUFFIX));

            if (params.get(prefix + ChartParams.AXIS_LABEL_FONT_SUFFIX) != null) {
                axis.setLabelFont(params.getFont(prefix + ChartParams.AXIS_LABEL_FONT_SUFFIX));
            }

            if (params.get(prefix + ChartParams.AXIS_LABEL_COLOR_SUFFIX) != null) {
                axis.setLabelPaint(params.getColor(prefix + ChartParams.AXIS_LABEL_COLOR_SUFFIX));
            }

            if (params.get(prefix + ChartParams.AXIS_LABEL_INSERTS_SUFFIX) != null) {
                axis.setLabelInsets(params.getRectangleInsets(prefix + ChartParams.AXIS_LABEL_INSERTS_SUFFIX));
            }
        }

        if (params.get(prefix + ChartParams.AXIS_TICK_LABEL_VISIBLE_SUFFIX) != null) {
            if (params.getBoolean(prefix + ChartParams.AXIS_TICK_LABEL_VISIBLE_SUFFIX).booleanValue()) {
                axis.setTickLabelsVisible(true);

                if (params.get(prefix + ChartParams.AXIS_TICK_LABEL_FONT_SUFFIX) != null) {
                    axis.setTickLabelFont(params.getFont(prefix + ChartParams.AXIS_TICK_LABEL_FONT_SUFFIX));
                }

                if (params.get(prefix + ChartParams.AXIS_TICK_LABEL_COLOR_SUFFIX) != null) {
                    axis.setTickLabelPaint(params.getColor(prefix + ChartParams.AXIS_TICK_LABEL_COLOR_SUFFIX));
                }

                if (params.get(prefix + ChartParams.AXIS_TICK_LABEL_INSERTS_SUFFIX) != null) {
                    axis.setTickLabelInsets(
                            params.getRectangleInsets(prefix + ChartParams.AXIS_TICK_LABEL_INSERTS_SUFFIX));
                }

            } else {
                axis.setTickLabelsVisible(false);
            }
        }

        if (params.get(prefix + ChartParams.AXIS_TICK_MARK_VISIBLE_SUFFIX) != null) {
            if (params.getBoolean(prefix + ChartParams.AXIS_TICK_MARK_VISIBLE_SUFFIX).booleanValue()) {
                axis.setTickMarksVisible(true);

                if (params.get(prefix + ChartParams.AXIS_TICK_MARK_INSIDE_LENGTH_SUFFIX) != null) {
                    axis.setTickMarkInsideLength(params
                            .getFloat(prefix + ChartParams.AXIS_TICK_MARK_INSIDE_LENGTH_SUFFIX).floatValue());
                }

                if (params.get(prefix + ChartParams.AXIS_TICK_MARK_OUTSIDE_LENGTH_SUFFIX) != null) {
                    axis.setTickMarkOutsideLength(params
                            .getFloat(prefix + ChartParams.AXIS_TICK_MARK_OUTSIDE_LENGTH_SUFFIX).floatValue());
                }

                if (params.get(prefix + ChartParams.AXIS_TICK_MARK_COLOR_SUFFIX) != null) {
                    axis.setTickMarkPaint(params.getColor(prefix + ChartParams.AXIS_TICK_MARK_COLOR_SUFFIX));
                }

                if (params.get(prefix + ChartParams.AXIS_TICK_MARK_COLOR_SUFFIX) != null) {
                    axis.setTickMarkStroke(params.getStroke(prefix + ChartParams.AXIS_TICK_MARK_STROKE_SUFFIX));
                }

            } else {
                axis.setTickMarksVisible(false);
            }
        }
    }
}