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

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

Introduction

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

Prototype

public void setLabel(String label) 

Source Link

Document

Sets the label for the axis 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());
        }/* ww w.  jav  a2 s. c o m*/

        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:daylightchart.options.chart.AxisOptions.java

/**
 * Sets the properties of the specified axis to match the properties
 * defined on this panel./*from  w w w .j a  v  a 2 s.c o m*/
 *
 * @param axis
 *        the axis.
 */
void setAxisProperties(final Axis axis) {
    axis.setLabel(label);
    if (labelFont != null) {
        axis.setLabelFont(labelFont);
    }
    if (labelPaint != null) {
        axis.setLabelPaint(labelPaint);
    }
    if (labelInsets != null) {
        axis.setLabelInsets(labelInsets);
    }
    //
    axis.setTickMarksVisible(tickMarksVisible);
    axis.setTickLabelsVisible(tickLabelsVisible);
    if (tickLabelFont != null) {
        axis.setTickLabelFont(tickLabelFont);
    }
    if (tickLabelPaint != null) {
        axis.setTickLabelPaint(tickLabelPaint);
    }
    if (tickLabelInsets != null) {
        axis.setTickLabelInsets(tickLabelInsets);
    }
}

From source file:com.bdaum.zoom.report.internal.wizards.ReportComponent.java

private static void applyAxisProperties(Axis axis, String prefix, Map<String, Object> properties) {
    axis.setLabel((String) properties.get(prefix + AXISLABEL));
    Font font = (Font) properties.get(prefix + AXISLABELFONT);
    if (font != null)
        axis.setLabelFont(font);//from ww  w. ja v  a 2 s  .  c o  m
    Paint paint = (Paint) properties.get(prefix + AXISLABELPAINT);
    if (paint != null)
        axis.setLabelPaint(paint);
    Boolean visible = (Boolean) properties.get(prefix + TICKMARKSVISIBLE);
    if (visible != null)
        axis.setTickMarksVisible(visible);
    visible = (Boolean) properties.get(prefix + TICKLABELSVISIBLE);
    if (visible != null)
        axis.setTickLabelsVisible(visible);
    font = (Font) properties.get(prefix + TICKLABELFONT);
    if (font != null)
        axis.setTickLabelFont(font);
    paint = (Paint) properties.get(prefix + TICKLABELPAINT);
    if (paint != null)
        axis.setTickLabelPaint(paint);
}

From source file:net.sourceforge.processdash.ev.ui.chart.EVXYChartPanel.java

protected void adjustAxis(Axis a, boolean chromeless, String label) {
    boolean showAxisTickLabels = !chromeless && chartContainsData;

    a.setTickLabelsVisible(showAxisTickLabels);
    a.setTickMarksVisible(showAxisTickLabels);
    a.setLabel(chromeless ? null : label);
}

From source file:com.rcp.wbw.demo.editor.SWTAxisEditor.java

/**
 * Sets the properties of the specified axis to match
 * the properties defined on this panel.
 * //from  ww  w  .jav  a 2 s .  c o  m
 * @param axis
 *            the axis.
 */
public void setAxisProperties(Axis axis) {
    axis.setLabel(getLabel());
    axis.setLabelFont(getLabelFont());
    axis.setLabelPaint(getLabelPaint());
    axis.setTickMarksVisible(this.showTickMarksCheckBox.getSelection());
    axis.setTickLabelsVisible(this.showTickLabelsCheckBox.getSelection());
    axis.setTickLabelFont(getTickLabelFont());
    axis.setTickLabelPaint(getTickLabelPaint());
}

From source file:ch.zhaw.simulation.diagram.charteditor.DefaultAxisEditor.java

/**
 * Sets the properties of the specified axis to match the properties defined
 * on this panel./*from   w w  w  . j a va  2s .  c  o m*/
 * 
 * @param axis
 *            the axis.
 */
public void setAxisProperties(Axis axis) {
    axis.setLabel(getLabel());
    axis.setLabelFont(getLabelFont());
    axis.setLabelPaint(getLabelPaint());
    axis.setTickMarksVisible(isTickMarksVisible());
    axis.setTickLabelsVisible(isTickLabelsVisible());
    axis.setTickLabelFont(getTickLabelFont());
    axis.setTickLabelPaint(getTickLabelPaint());
    axis.setTickLabelInsets(getTickLabelInsets());
    axis.setLabelInsets(getLabelInsets());
}

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);/*from   w  ww  .  jav a2 s.  co 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:org.operamasks.faces.render.graph.ChartRenderer.java

protected void setAxisStyles(Axis axis, UIAxis comp) {
    axis.setVisible(comp.isVisible());/*from   ww  w  . j av  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:com.appnativa.rare.ui.chart.jfreechart.ChartHandler.java

@Override
public void setRangeLabel(iPlatformComponent chartPanel, ChartDefinition cd) {
    Axis a = getAxis(cd, true);

    if (a != null) {
        a.setLabel(cd.getRangeAxis().getLabel());
    }//from   ww  w.  ja  v  a 2  s. c  o m
}

From source file:com.appnativa.rare.ui.chart.jfreechart.ChartHandler.java

@Override
public void setDomainLabel(iPlatformComponent chartPanel, ChartDefinition cd) {
    Axis a = getAxis(cd, false);

    if (a != null) {
        a.setLabel(cd.getDomainAxis().getLabel());
    }/*from  w w  w . j  a v  a2 s.c o  m*/
}