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

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

Introduction

In this page you can find the example usage for org.jfree.chart.axis Axis 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.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 . com

        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.jreserve.dummy.plot.charts.AbstractChart.java

protected void formatAxisColors(Axis axis) {
    Color color = format.getForeColor();
    axis.setAxisLinePaint(color);/*w w w . jav a 2  s  .c  o  m*/
    axis.setTickMarkPaint(color);
    axis.setTickLabelPaint(color);
    axis.setLabelPaint(color);
}

From source file:com.redhat.thermostat.byteman.chart.swing.SwingBarChart.java

private void colorAxis(Axis ax) {
    ax.setAxisLinePaint(toColor(cf.axisLinePaint));
    ax.setTickMarkPaint(toColor(cf.tickMarkPaint));
    ax.setTickLabelPaint(toColor(cf.tickLabelPaint));
}

From source file:ec.util.chart.swing.JTimeSeriesChart.java

private void onColorSchemeSupportChange(Axis axis) {
    axis.setAxisLinePaint(colorSchemeSupport.getAxisColor());
    axis.setTickLabelPaint(colorSchemeSupport.getAxisColor());
    axis.setTickMarkPaint(colorSchemeSupport.getAxisColor());
}

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

protected void setAxisStyles(Axis axis, UIAxis comp) {
    axis.setVisible(comp.isVisible());//from  w ww . ja  v  a 2  s  .  c  o m
    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:net.sf.jasperreports.engine.fill.DefaultChartTheme.java

/**
 * Sets all the axis formatting options.  This includes the colors and fonts to use on
 * the axis as well as the color to use when drawing the axis line.
 *
 * @param axis the axis to format//from w ww  .j a v  a  2s.c  om
 * @param labelFont the font to use for the axis label
 * @param labelColor the color of the axis label
 * @param tickLabelFont the font to use for each tick mark value label
 * @param tickLabelColor the color of each tick mark value label
 * @param tickLabelMask formatting mask for the label.  If the axis is a NumberAxis then
 *                    the mask should be <code>java.text.DecimalFormat</code> mask, and
 *                   if it is a DateAxis then the mask should be a
 *                   <code>java.text.SimpleDateFormat</code> mask.
 * @param verticalTickLabels flag to draw tick labels at 90 degrees
 * @param lineColor color to use when drawing the axis line and any tick marks
 */
protected void configureAxis(Axis axis, JRFont labelFont, Color labelColor, JRFont tickLabelFont,
        Color tickLabelColor, String tickLabelMask, Boolean verticalTickLabels, Color lineColor,
        boolean isRangeAxis, Comparable<?> axisMinValue, Comparable<?> axisMaxValue) {
    axis.setLabelFont(fontUtil.getAwtFont(getFont(labelFont), getLocale()));
    axis.setTickLabelFont(fontUtil.getAwtFont(getFont(tickLabelFont), getLocale()));
    if (labelColor != null) {
        axis.setLabelPaint(labelColor);
    }

    if (tickLabelColor != null) {
        axis.setTickLabelPaint(tickLabelColor);
    }

    if (lineColor != null) {
        axis.setAxisLinePaint(lineColor);
        axis.setTickMarkPaint(lineColor);
    }

    TimeZone timeZone = chartContext.getTimeZone();
    if (axis instanceof DateAxis && timeZone != null) {
        // used when no mask is set
        ((DateAxis) axis).setTimeZone(timeZone);
    }

    // FIXME use locale for formats
    if (tickLabelMask != null) {
        if (axis instanceof NumberAxis) {
            NumberFormat fmt = NumberFormat.getInstance(getLocale());
            if (fmt instanceof DecimalFormat) {
                ((DecimalFormat) fmt).applyPattern(tickLabelMask);
            }
            ((NumberAxis) axis).setNumberFormatOverride(fmt);
        } else if (axis instanceof DateAxis) {
            DateFormat fmt;
            if (tickLabelMask.equals("SHORT") || tickLabelMask.equals("DateFormat.SHORT")) {
                fmt = DateFormat.getDateInstance(DateFormat.SHORT, getLocale());
            } else if (tickLabelMask.equals("MEDIUM") || tickLabelMask.equals("DateFormat.MEDIUM")) {
                fmt = DateFormat.getDateInstance(DateFormat.MEDIUM, getLocale());
            } else if (tickLabelMask.equals("LONG") || tickLabelMask.equals("DateFormat.LONG")) {
                fmt = DateFormat.getDateInstance(DateFormat.LONG, getLocale());
            } else if (tickLabelMask.equals("FULL") || tickLabelMask.equals("DateFormat.FULL")) {
                fmt = DateFormat.getDateInstance(DateFormat.FULL, getLocale());
            } else {
                fmt = new SimpleDateFormat(tickLabelMask, getLocale());
            }

            if (timeZone != null) {
                fmt.setTimeZone(timeZone);
            }

            ((DateAxis) axis).setDateFormatOverride(fmt);
        }
        // ignore mask for other axis types.
    }

    if (verticalTickLabels != null && axis instanceof ValueAxis) {
        ((ValueAxis) axis).setVerticalTickLabels(verticalTickLabels);
    }

    setAxisBounds(axis, isRangeAxis, axisMinValue, axisMaxValue);
}

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

protected void setAxisTickMarks(Axis axis, Paint lineColor, AxisSettings axisSettings) {
    boolean axisTickMarksVisible = axisSettings.getTickMarksVisible() == null
            || axisSettings.getTickMarksVisible().booleanValue();

    axis.setTickMarksVisible(axisTickMarksVisible);

    if (axisTickMarksVisible) {
        Float axisTickMarksInsideLength = axisSettings.getTickMarksInsideLength();
        if (axisTickMarksInsideLength != null)
            axis.setTickMarkInsideLength(axisTickMarksInsideLength.floatValue());

        Float axisTickMarksOutsideLength = axisSettings.getTickMarksOutsideLength();
        if (axisTickMarksOutsideLength != null)
            axis.setTickMarkInsideLength(axisTickMarksOutsideLength.floatValue());

        Paint tickMarkPaint = axisSettings.getTickMarksPaint() != null
                && axisSettings.getTickMarksPaint().getPaint() != null
                        ? axisSettings.getTickMarksPaint().getPaint()
                        : lineColor;//from www  . ja va  2 s.  c o m

        if (tickMarkPaint != null) {
            axis.setTickMarkPaint(tickMarkPaint);
        }
        Stroke tickMarkStroke = axisSettings.getTickMarksStroke();
        if (tickMarkStroke != null)
            axis.setTickMarkStroke(tickMarkStroke);
    }
}

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 .  ja  v a  2s . c o  m*/

    } 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);
            }
        }
    }
}

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

protected void setAxisTickMarks(Axis axis, Paint lineColor, AxisSettings axisSettings) {
    boolean axisTickMarksVisible = axisSettings.getTickMarksVisible() == null
            || axisSettings.getTickMarksVisible();

    axis.setTickMarksVisible(axisTickMarksVisible);

    if (axisTickMarksVisible) {
        Float axisTickMarksInsideLength = axisSettings.getTickMarksInsideLength();
        if (axisTickMarksInsideLength != null)
            axis.setTickMarkInsideLength(axisTickMarksInsideLength);

        Float axisTickMarksOutsideLength = axisSettings.getTickMarksOutsideLength();
        if (axisTickMarksOutsideLength != null)
            axis.setTickMarkInsideLength(axisTickMarksOutsideLength);

        Paint tickMarkPaint = axisSettings.getTickMarksPaint() != null
                && axisSettings.getTickMarksPaint().getPaint() != null
                        ? axisSettings.getTickMarksPaint().getPaint()
                        : lineColor;/*from ww w.ja v  a  2  s .c o  m*/

        if (tickMarkPaint != null) {
            axis.setTickMarkPaint(tickMarkPaint);
        }
        Stroke tickMarkStroke = axisSettings.getTickMarksStroke();
        if (tickMarkStroke != null)
            axis.setTickMarkStroke(tickMarkStroke);
    }
}

From source file:net.sf.fspdfs.chartthemes.spring.GenericChartTheme.java

protected void setAxisTickMarks(Axis axis, Paint lineColor) {
    Boolean defaultAxisTickMarksVisible = (Boolean) getDefaultValue(defaultAxisPropertiesMap,
            ChartThemesConstants.AXIS_TICK_MARKS_VISIBLE);
    if (defaultAxisTickMarksVisible != null && defaultAxisTickMarksVisible.booleanValue()) {
        Float defaultAxisTickMarksInsideLength = (Float) getDefaultValue(defaultAxisPropertiesMap,
                ChartThemesConstants.AXIS_TICK_MARKS_INSIDE_LENGTH);
        if (defaultAxisTickMarksInsideLength != null)
            axis.setTickMarkInsideLength(defaultAxisTickMarksInsideLength.floatValue());

        Float defaultAxisTickMarksOutsideLength = (Float) getDefaultValue(defaultAxisPropertiesMap,
                ChartThemesConstants.AXIS_TICK_MARKS_OUTSIDE_LENGTH);
        if (defaultAxisTickMarksOutsideLength != null)
            axis.setTickMarkInsideLength(defaultAxisTickMarksOutsideLength.floatValue());

        Paint tickMarkPaint = getDefaultValue(defaultAxisPropertiesMap,
                ChartThemesConstants.AXIS_TICK_MARKS_PAINT) != null
                        ? (Paint) getDefaultValue(defaultAxisPropertiesMap,
                                ChartThemesConstants.AXIS_TICK_MARKS_PAINT)
                        : lineColor;//ww  w.  j  a  v a2s .  c om

        if (tickMarkPaint != null) {
            axis.setTickMarkPaint(tickMarkPaint);
        }
        Stroke defaultTickMarkStroke = (Stroke) getDefaultValue(defaultAxisPropertiesMap,
                ChartThemesConstants.AXIS_TICK_MARKS_STROKE);
        if (defaultTickMarkStroke != null)
            axis.setTickMarkStroke(defaultTickMarkStroke);
    }
}