Example usage for org.jfree.chart.plot Marker getLabelOffset

List of usage examples for org.jfree.chart.plot Marker getLabelOffset

Introduction

In this page you can find the example usage for org.jfree.chart.plot Marker getLabelOffset.

Prototype

public RectangleInsets getLabelOffset() 

Source Link

Document

Returns the label offset.

Usage

From source file:net.sf.jasperreports.customizers.marker.AbstractMarkerCustomizer.java

protected void configureMarker(Marker marker) {
    String label = getProperty(PROPERTY_LABEL);
    if (label != null && label.length() > 0) {
        marker.setLabel(label);/* w ww  . j  a  v  a2  s .  c  o m*/
    }

    RectangleAnchorEnum labelAnchor = RectangleAnchorEnum.getByName(getProperty(PROPERTY_LABEL_ANCHOR));
    if (labelAnchor != null) {
        marker.setLabelAnchor(labelAnchor.getRectangleAnchor());
    }

    Double offsetTop = getDoubleProperty(PROPERTY_LABEL_OFFSET_TOP);
    Double offsetLeft = getDoubleProperty(PROPERTY_LABEL_OFFSET_LEFT);
    Double offsetBottom = getDoubleProperty(PROPERTY_LABEL_OFFSET_BOTTOM);
    Double offsetRight = getDoubleProperty(PROPERTY_LABEL_OFFSET_RIGHT);
    if (offsetTop != null || offsetLeft != null || offsetBottom != null || offsetRight != null) {
        RectangleInsets currentOffset = marker.getLabelOffset();
        marker.setLabelOffset(new RectangleInsets(offsetTop == null ? currentOffset.getTop() : offsetTop,
                offsetLeft == null ? currentOffset.getLeft() : offsetLeft,
                offsetBottom == null ? currentOffset.getBottom() : offsetBottom,
                offsetRight == null ? currentOffset.getRight() : offsetRight));
    }

    TextAnchorEnum labelTextAnchor = TextAnchorEnum.getByName(getProperty(PROPERTY_LABEL_TEXT_ANCHOR));
    if (labelTextAnchor != null) {
        marker.setLabelTextAnchor(labelTextAnchor.getTextAnchor());
    }

    Color color = JRColorUtil.getColor(getProperty(PROPERTY_COLOR), null);
    if (color != null) {
        marker.setPaint(color);
    }

    Float alpha = getFloatProperty(PROPERTY_ALPHA);
    if (alpha != null) {
        marker.setAlpha(alpha);
    }
}