org.jfree.ui.RectangleAnchor Java Examples

The following examples show how to use org.jfree.ui.RectangleAnchor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DialValueIndicator.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a new instance of <code>DialValueIndicator</code>.
 *
 * @param datasetIndex  the dataset index.
 */
public DialValueIndicator(int datasetIndex) {
    this.datasetIndex = datasetIndex;
    this.angle = -90.0;
    this.radius = 0.3;
    this.frameAnchor = RectangleAnchor.CENTER;
    this.templateValue = new Double(100.0);
    this.maxTemplateValue = null;
    this.formatter = new DecimalFormat("0.0");
    this.font = new Font("Dialog", Font.BOLD, 14);
    this.paint = Color.black;
    this.backgroundPaint = Color.white;
    this.outlineStroke = new BasicStroke(1.0f);
    this.outlinePaint = Color.blue;
    this.insets = new RectangleInsets(4, 4, 4, 4);
    this.valueAnchor = RectangleAnchor.RIGHT;
    this.textAnchor = TextAnchor.CENTER_RIGHT;
}
 
Example #2
Source File: AbstractCategoryItemRenderer.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Calculates the (x, y) coordinates for drawing the label for a marker on
 * the range axis.
 *
 * @param g2  the graphics device.
 * @param orientation  the plot orientation.
 * @param dataArea  the data area.
 * @param markerArea  the rectangle surrounding the marker.
 * @param markerOffset  the marker offset.
 * @param labelOffsetType  the label offset type.
 * @param anchor  the label anchor.
 *
 * @return The coordinates for drawing the marker label.
 */
protected Point2D calculateDomainMarkerTextAnchorPoint(Graphics2D g2,
        PlotOrientation orientation, Rectangle2D dataArea,
        Rectangle2D markerArea, RectangleInsets markerOffset,
        LengthAdjustmentType labelOffsetType, RectangleAnchor anchor) {

    Rectangle2D anchorRect = null;
    if (orientation == PlotOrientation.HORIZONTAL) {
        anchorRect = markerOffset.createAdjustedRectangle(markerArea,
                LengthAdjustmentType.CONTRACT, labelOffsetType);
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        anchorRect = markerOffset.createAdjustedRectangle(markerArea,
                labelOffsetType, LengthAdjustmentType.CONTRACT);
    }
    return RectangleAnchor.coordinates(anchorRect, anchor);

}
 
Example #3
Source File: DialValueIndicator.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a new instance of <code>DialValueIndicator</code>.
 *
 * @param datasetIndex  the dataset index.
 */
public DialValueIndicator(int datasetIndex) {
    this.datasetIndex = datasetIndex;
    this.angle = -90.0;
    this.radius = 0.3;
    this.frameAnchor = RectangleAnchor.CENTER;
    this.templateValue = new Double(100.0);
    this.maxTemplateValue = null;
    this.formatter = new DecimalFormat("0.0");
    this.font = new Font("Dialog", Font.BOLD, 14);
    this.paint = Color.black;
    this.backgroundPaint = Color.white;
    this.outlineStroke = new BasicStroke(1.0f);
    this.outlinePaint = Color.blue;
    this.insets = new RectangleInsets(4, 4, 4, 4);
    this.valueAnchor = RectangleAnchor.RIGHT;
    this.textAnchor = TextAnchor.CENTER_RIGHT;
}
 
Example #4
Source File: CrosshairOverlay.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
private RectangleAnchor flipAnchorH(RectangleAnchor anchor) {
    RectangleAnchor result = anchor;
    if (anchor.equals(RectangleAnchor.TOP_LEFT)) {
        result = RectangleAnchor.TOP_RIGHT;
    }
    else if (anchor.equals(RectangleAnchor.TOP_RIGHT)) {
        result = RectangleAnchor.TOP_LEFT;
    }
    else if (anchor.equals(RectangleAnchor.LEFT)) {
        result = RectangleAnchor.RIGHT;
    }
    else if (anchor.equals(RectangleAnchor.RIGHT)) {
        result = RectangleAnchor.LEFT;
    }
    else if (anchor.equals(RectangleAnchor.BOTTOM_LEFT)) {
        result = RectangleAnchor.BOTTOM_RIGHT;
    }
    else if (anchor.equals(RectangleAnchor.BOTTOM_RIGHT)) {
        result = RectangleAnchor.BOTTOM_LEFT;
    }
    return result;
}
 
Example #5
Source File: CrosshairOverlay.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
private RectangleAnchor flipAnchorH(RectangleAnchor anchor) {
    RectangleAnchor result = anchor;
    if (anchor.equals(RectangleAnchor.TOP_LEFT)) {
        result = RectangleAnchor.TOP_RIGHT;
    }
    else if (anchor.equals(RectangleAnchor.TOP_RIGHT)) {
        result = RectangleAnchor.TOP_LEFT;
    }
    else if (anchor.equals(RectangleAnchor.LEFT)) {
        result = RectangleAnchor.RIGHT;
    }
    else if (anchor.equals(RectangleAnchor.RIGHT)) {
        result = RectangleAnchor.LEFT;
    }
    else if (anchor.equals(RectangleAnchor.BOTTOM_LEFT)) {
        result = RectangleAnchor.BOTTOM_RIGHT;
    }
    else if (anchor.equals(RectangleAnchor.BOTTOM_RIGHT)) {
        result = RectangleAnchor.BOTTOM_LEFT;
    }
    return result;
}
 
Example #6
Source File: AbstractXYItemRenderer.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Calculates the (x, y) coordinates for drawing a marker label.
 *
 * @param g2  the graphics device.
 * @param orientation  the plot orientation.
 * @param dataArea  the data area.
 * @param markerArea  the rectangle surrounding the marker area.
 * @param markerOffset  the marker label offset.
 * @param labelOffsetType  the label offset type.
 * @param anchor  the label anchor.
 *
 * @return The coordinates for drawing the marker label.
 */
protected Point2D calculateDomainMarkerTextAnchorPoint(Graphics2D g2,
        PlotOrientation orientation, Rectangle2D dataArea,
        Rectangle2D markerArea, RectangleInsets markerOffset,
        LengthAdjustmentType labelOffsetType, RectangleAnchor anchor) {

    Rectangle2D anchorRect = null;
    if (orientation == PlotOrientation.HORIZONTAL) {
        anchorRect = markerOffset.createAdjustedRectangle(markerArea,
                LengthAdjustmentType.CONTRACT, labelOffsetType);
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        anchorRect = markerOffset.createAdjustedRectangle(markerArea,
                labelOffsetType, LengthAdjustmentType.CONTRACT);
    }
    return RectangleAnchor.coordinates(anchorRect, anchor);

}
 
Example #7
Source File: AbstractCategoryItemRenderer.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Calculates the (x, y) coordinates for drawing the label for a marker on
 * the range axis.
 *
 * @param g2  the graphics device.
 * @param orientation  the plot orientation.
 * @param dataArea  the data area.
 * @param markerArea  the rectangle surrounding the marker.
 * @param markerOffset  the marker offset.
 * @param labelOffsetType  the label offset type.
 * @param anchor  the label anchor.
 *
 * @return The coordinates for drawing the marker label.
 */
protected Point2D calculateDomainMarkerTextAnchorPoint(Graphics2D g2,
        PlotOrientation orientation, Rectangle2D dataArea,
        Rectangle2D markerArea, RectangleInsets markerOffset,
        LengthAdjustmentType labelOffsetType, RectangleAnchor anchor) {

    Rectangle2D anchorRect = null;
    if (orientation == PlotOrientation.HORIZONTAL) {
        anchorRect = markerOffset.createAdjustedRectangle(markerArea,
                LengthAdjustmentType.CONTRACT, labelOffsetType);
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        anchorRect = markerOffset.createAdjustedRectangle(markerArea,
                labelOffsetType, LengthAdjustmentType.CONTRACT);
    }
    return RectangleAnchor.coordinates(anchorRect, anchor);

}
 
Example #8
Source File: AbstractCategoryItemRenderer.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Calculates the (x, y) coordinates for drawing a marker label.
 *
 * @param g2  the graphics device.
 * @param orientation  the plot orientation.
 * @param dataArea  the data area.
 * @param markerArea  the rectangle surrounding the marker.
 * @param markerOffset  the marker offset.
 * @param labelOffsetType  the label offset type.
 * @param anchor  the label anchor.
 *
 * @return The coordinates for drawing the marker label.
 */
protected Point2D calculateRangeMarkerTextAnchorPoint(Graphics2D g2,
        PlotOrientation orientation, Rectangle2D dataArea,
        Rectangle2D markerArea, RectangleInsets markerOffset,
        LengthAdjustmentType labelOffsetType, RectangleAnchor anchor) {

    Rectangle2D anchorRect = null;
    if (orientation == PlotOrientation.HORIZONTAL) {
        anchorRect = markerOffset.createAdjustedRectangle(markerArea,
                labelOffsetType, LengthAdjustmentType.CONTRACT);
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        anchorRect = markerOffset.createAdjustedRectangle(markerArea,
                LengthAdjustmentType.CONTRACT, labelOffsetType);
    }
    return RectangleAnchor.coordinates(anchorRect, anchor);

}
 
Example #9
Source File: DialValueIndicator.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a new instance of <code>DialValueIndicator</code>.
 *
 * @param datasetIndex  the dataset index.
 */
public DialValueIndicator(int datasetIndex) {
    this.datasetIndex = datasetIndex;
    this.angle = -90.0;
    this.radius = 0.3;
    this.frameAnchor = RectangleAnchor.CENTER;
    this.templateValue = new Double(100.0);
    this.maxTemplateValue = null;
    this.formatter = new DecimalFormat("0.0");
    this.font = new Font("Dialog", Font.BOLD, 14);
    this.paint = Color.black;
    this.backgroundPaint = Color.white;
    this.outlineStroke = new BasicStroke(1.0f);
    this.outlinePaint = Color.blue;
    this.insets = new RectangleInsets(4, 4, 4, 4);
    this.valueAnchor = RectangleAnchor.RIGHT;
    this.textAnchor = TextAnchor.CENTER_RIGHT;
}
 
Example #10
Source File: CategoryLabelPositions.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a new instance where the category labels angled upwards by the
 * specified amount.
 *
 * @param angle  the rotation angle (should be &lt; Math.PI / 2.0).
 *
 * @return A category label position specification.
 */
public static CategoryLabelPositions createUpRotationLabelPositions(
        double angle) {
    return new CategoryLabelPositions(
        new CategoryLabelPosition(
            RectangleAnchor.BOTTOM, TextBlockAnchor.BOTTOM_LEFT,
            TextAnchor.BOTTOM_LEFT, -angle,
            CategoryLabelWidthType.RANGE, 0.50f), // TOP
        new CategoryLabelPosition(
            RectangleAnchor.TOP, TextBlockAnchor.TOP_RIGHT,
            TextAnchor.TOP_RIGHT, -angle,
            CategoryLabelWidthType.RANGE, 0.50f), // BOTTOM
        new CategoryLabelPosition(
            RectangleAnchor.RIGHT, TextBlockAnchor.BOTTOM_RIGHT,
            TextAnchor.BOTTOM_RIGHT, -angle,
            CategoryLabelWidthType.RANGE, 0.50f), // LEFT
        new CategoryLabelPosition(
            RectangleAnchor.LEFT, TextBlockAnchor.TOP_LEFT,
            TextAnchor.TOP_LEFT, -angle,
            CategoryLabelWidthType.RANGE, 0.50f) // RIGHT
    );
}
 
Example #11
Source File: AbstractCategoryItemRenderer.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
/**
 * Calculates the (x, y) coordinates for drawing a marker label.
 * 
 * @param g2  the graphics device.
 * @param orientation  the plot orientation.
 * @param dataArea  the data area.
 * @param markerArea  the rectangle surrounding the marker.
 * @param markerOffset  the marker offset.
 * @param labelOffsetType  the label offset type.
 * @param anchor  the label anchor.
 * 
 * @return The coordinates for drawing the marker label.
 */
protected Point2D calculateRangeMarkerTextAnchorPoint(Graphics2D g2, 
                                  PlotOrientation orientation,
                                  Rectangle2D dataArea,
                                  Rectangle2D markerArea,
                                  RectangleInsets markerOffset,
                                  LengthAdjustmentType labelOffsetType,
                                  RectangleAnchor anchor) {
                                                 
    Rectangle2D anchorRect = null;
    if (orientation == PlotOrientation.HORIZONTAL) {
        anchorRect = markerOffset.createAdjustedRectangle(markerArea, 
                labelOffsetType, LengthAdjustmentType.CONTRACT);
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        anchorRect = markerOffset.createAdjustedRectangle(markerArea, 
                LengthAdjustmentType.CONTRACT, labelOffsetType);
    }
    return RectangleAnchor.coordinates(anchorRect, anchor);
    
}
 
Example #12
Source File: LegendGraphic.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new legend graphic.
 * 
 * @param shape  the shape (<code>null</code> not permitted).
 * @param fillPaint  the fill paint (<code>null</code> not permitted).
 */
public LegendGraphic(Shape shape, Paint fillPaint) {
    if (shape == null) {
        throw new IllegalArgumentException("Null 'shape' argument.");
    }
    if (fillPaint == null) {
        throw new IllegalArgumentException("Null 'fillPaint' argument.");
    }
    this.shapeVisible = true;
    this.shape = shape;
    this.shapeAnchor = RectangleAnchor.CENTER;
    this.shapeLocation = RectangleAnchor.CENTER;
    this.shapeFilled = true;
    this.fillPaint = fillPaint;
    this.fillPaintTransformer = new StandardGradientPaintTransformer();
    setPadding(2.0, 2.0, 2.0, 2.0);
}
 
Example #13
Source File: AbstractCategoryItemRenderer.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Calculates the (x, y) coordinates for drawing a marker label.
 *
 * @param g2  the graphics device.
 * @param orientation  the plot orientation.
 * @param dataArea  the data area.
 * @param markerArea  the rectangle surrounding the marker.
 * @param markerOffset  the marker offset.
 * @param labelOffsetType  the label offset type.
 * @param anchor  the label anchor.
 *
 * @return The coordinates for drawing the marker label.
 */
protected Point2D calculateRangeMarkerTextAnchorPoint(Graphics2D g2,
        PlotOrientation orientation, Rectangle2D dataArea,
        Rectangle2D markerArea, RectangleInsets markerOffset,
        LengthAdjustmentType labelOffsetType, RectangleAnchor anchor) {

    Rectangle2D anchorRect = null;
    if (orientation == PlotOrientation.HORIZONTAL) {
        anchorRect = markerOffset.createAdjustedRectangle(markerArea,
                labelOffsetType, LengthAdjustmentType.CONTRACT);
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        anchorRect = markerOffset.createAdjustedRectangle(markerArea,
                LengthAdjustmentType.CONTRACT, labelOffsetType);
    }
    return RectangleAnchor.coordinates(anchorRect, anchor);

}
 
Example #14
Source File: Crosshair.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a new crosshair value with the specified value and line style.
 *
 * @param value  the value.
 * @param paint  the line paint (<code>null</code> not permitted).
 * @param stroke  the line stroke (<code>null</code> not permitted).
 */
public Crosshair(double value, Paint paint, Stroke stroke) {
    ParamChecks.nullNotPermitted(paint, "paint");
    ParamChecks.nullNotPermitted(stroke, "stroke");
    this.visible = true;
    this.value = value;
    this.paint = paint;
    this.stroke = stroke;
    this.labelVisible = false;
    this.labelGenerator = new StandardCrosshairLabelGenerator();
    this.labelAnchor = RectangleAnchor.BOTTOM_LEFT;
    this.labelXOffset = 3.0;
    this.labelYOffset = 3.0;
    this.labelFont = new Font("Tahoma", Font.PLAIN, 12);
    this.labelPaint = Color.black;
    this.labelBackgroundPaint = new Color(0, 0, 255, 63);
    this.labelOutlineVisible = true;
    this.labelOutlinePaint = Color.black;
    this.labelOutlineStroke = new BasicStroke(0.5f);
    this.pcs = new PropertyChangeSupport(this);
}
 
Example #15
Source File: LegendTitle.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a new legend title with the specified arrangement.
 *
 * @param source  the source.
 * @param hLayout  the horizontal item arrangement (<code>null</code> not
 *                 permitted).
 * @param vLayout  the vertical item arrangement (<code>null</code> not
 *                 permitted).
 */
public LegendTitle(LegendItemSource source,
                   Arrangement hLayout, Arrangement vLayout) {
    this.sources = new LegendItemSource[] {source};
    this.items = new BlockContainer(hLayout);
    this.hLayout = hLayout;
    this.vLayout = vLayout;
    this.backgroundPaint = null;
    this.legendItemGraphicEdge = RectangleEdge.LEFT;
    this.legendItemGraphicAnchor = RectangleAnchor.CENTER;
    this.legendItemGraphicLocation = RectangleAnchor.CENTER;
    this.legendItemGraphicPadding = new RectangleInsets(2.0, 2.0, 2.0, 2.0);
    this.itemFont = DEFAULT_ITEM_FONT;
    this.itemPaint = DEFAULT_ITEM_PAINT;
    this.itemLabelPadding = new RectangleInsets(2.0, 2.0, 2.0, 2.0);
    this.sortOrder = SortOrder.ASCENDING;
}
 
Example #16
Source File: CategoryLabelPositions.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a new instance where the category labels angled upwards by the
 * specified amount.
 *
 * @param angle  the rotation angle (should be &lt; Math.PI / 2.0).
 *
 * @return A category label position specification.
 */
public static CategoryLabelPositions createUpRotationLabelPositions(
        double angle) {
    return new CategoryLabelPositions(
        new CategoryLabelPosition(
            RectangleAnchor.BOTTOM, TextBlockAnchor.BOTTOM_LEFT,
            TextAnchor.BOTTOM_LEFT, -angle,
            CategoryLabelWidthType.RANGE, 0.50f), // TOP
        new CategoryLabelPosition(
            RectangleAnchor.TOP, TextBlockAnchor.TOP_RIGHT,
            TextAnchor.TOP_RIGHT, -angle,
            CategoryLabelWidthType.RANGE, 0.50f), // BOTTOM
        new CategoryLabelPosition(
            RectangleAnchor.RIGHT, TextBlockAnchor.BOTTOM_RIGHT,
            TextAnchor.BOTTOM_RIGHT, -angle,
            CategoryLabelWidthType.RANGE, 0.50f), // LEFT
        new CategoryLabelPosition(
            RectangleAnchor.LEFT, TextBlockAnchor.TOP_LEFT,
            TextAnchor.TOP_LEFT, -angle,
            CategoryLabelWidthType.RANGE, 0.50f) // RIGHT
    );
}
 
Example #17
Source File: MarkerTest.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Some checks for the getLabelAnchor() and setLabelAnchor() methods.
 */
@Test
public void testGetSetLabelAnchor() {
    // we use ValueMarker for the tests, because we need a concrete
    // subclass...
    ValueMarker m = new ValueMarker(1.1);
    m.addChangeListener(this);
    this.lastEvent = null;
    assertEquals(RectangleAnchor.TOP_LEFT, m.getLabelAnchor());
    m.setLabelAnchor(RectangleAnchor.TOP);
    assertEquals(RectangleAnchor.TOP, m.getLabelAnchor());
    assertEquals(m, this.lastEvent.getMarker());

    // check null argument...
    try {
        m.setLabelAnchor(null);
        fail("Expected an IllegalArgumentException for null.");
    }
    catch (IllegalArgumentException e) {
        assertTrue(true);
    }
}
 
Example #18
Source File: DialValueIndicator.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a new instance of <code>DialValueIndicator</code>.
 *
 * @param datasetIndex  the dataset index.
 */
public DialValueIndicator(int datasetIndex) {
    this.datasetIndex = datasetIndex;
    this.angle = -90.0;
    this.radius = 0.3;
    this.frameAnchor = RectangleAnchor.CENTER;
    this.templateValue = new Double(100.0);
    this.maxTemplateValue = null;
    this.formatter = new DecimalFormat("0.0");
    this.font = new Font("Dialog", Font.BOLD, 14);
    this.paint = Color.black;
    this.backgroundPaint = Color.white;
    this.outlineStroke = new BasicStroke(1.0f);
    this.outlinePaint = Color.blue;
    this.insets = new RectangleInsets(4, 4, 4, 4);
    this.valueAnchor = RectangleAnchor.RIGHT;
    this.textAnchor = TextAnchor.CENTER_RIGHT;
}
 
Example #19
Source File: Crosshair.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a new crosshair value with the specified value and line style.
 *
 * @param value  the value.
 * @param paint  the line paint (<code>null</code> not permitted).
 * @param stroke  the line stroke (<code>null</code> not permitted).
 */
public Crosshair(double value, Paint paint, Stroke stroke) {
    ParamChecks.nullNotPermitted(paint, "paint");
    ParamChecks.nullNotPermitted(stroke, "stroke");
    this.visible = true;
    this.value = value;
    this.paint = paint;
    this.stroke = stroke;
    this.labelVisible = false;
    this.labelGenerator = new StandardCrosshairLabelGenerator();
    this.labelAnchor = RectangleAnchor.BOTTOM_LEFT;
    this.labelXOffset = 3.0;
    this.labelYOffset = 3.0;
    this.labelFont = new Font("Tahoma", Font.PLAIN, 12);
    this.labelPaint = Color.black;
    this.labelBackgroundPaint = new Color(0, 0, 255, 63);
    this.labelOutlineVisible = true;
    this.labelOutlinePaint = Color.black;
    this.labelOutlineStroke = new BasicStroke(0.5f);
    this.pcs = new PropertyChangeSupport(this);
}
 
Example #20
Source File: CategoryLabelPositions.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a new instance where the category labels angled downwards by the
 * specified amount.
 *
 * @param angle  the rotation angle (should be &lt; Math.PI / 2.0).
 *
 * @return A category label position specification.
 */
public static CategoryLabelPositions createDownRotationLabelPositions(
        double angle) {
    return new CategoryLabelPositions(
        new CategoryLabelPosition(
            RectangleAnchor.BOTTOM, TextBlockAnchor.BOTTOM_RIGHT,
            TextAnchor.BOTTOM_RIGHT, angle,
            CategoryLabelWidthType.RANGE, 0.50f), // TOP
        new CategoryLabelPosition(
            RectangleAnchor.TOP, TextBlockAnchor.TOP_LEFT,
            TextAnchor.TOP_LEFT, angle,
            CategoryLabelWidthType.RANGE, 0.50f), // BOTTOM
        new CategoryLabelPosition(
            RectangleAnchor.RIGHT, TextBlockAnchor.TOP_RIGHT,
            TextAnchor.TOP_RIGHT, angle,
            CategoryLabelWidthType.RANGE, 0.50f), // LEFT
        new CategoryLabelPosition(
            RectangleAnchor.LEFT, TextBlockAnchor.BOTTOM_LEFT,
            TextAnchor.BOTTOM_LEFT, angle,
            CategoryLabelWidthType.RANGE, 0.50f) // RIGHT
    );
}
 
Example #21
Source File: DialValueIndicator.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new instance of <code>DialValueIndicator</code>.
 *
 * @param datasetIndex  the dataset index.
 */
public DialValueIndicator(int datasetIndex) {
    this.datasetIndex = datasetIndex;
    this.angle = -90.0;
    this.radius = 0.3;
    this.frameAnchor = RectangleAnchor.CENTER;
    this.templateValue = new Double(100.0);
    this.maxTemplateValue = null;
    this.formatter = new DecimalFormat("0.0");
    this.font = new Font("Dialog", Font.BOLD, 14);
    this.paint = Color.black;
    this.backgroundPaint = Color.white;
    this.outlineStroke = new BasicStroke(1.0f);
    this.outlinePaint = Color.blue;
    this.insets = new RectangleInsets(4, 4, 4, 4);
    this.valueAnchor = RectangleAnchor.RIGHT;
    this.textAnchor = TextAnchor.CENTER_RIGHT;
}
 
Example #22
Source File: Marker.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Constructs a new marker.
 *
 * @param paint  the paint ({@code null} not permitted).
 * @param stroke  the stroke ({@code null} not permitted).
 * @param outlinePaint  the outline paint ({@code null} permitted).
 * @param outlineStroke  the outline stroke ({@code null} permitted).
 * @param alpha  the alpha transparency (must be in the range 0.0f to
 *     1.0f).
 *
 * @throws IllegalArgumentException if {@code paint} or
 *     {@code stroke} is {@code null}, or {@code alpha} is
 *     not in the specified range.
 */
protected Marker(Paint paint, Stroke stroke, Paint outlinePaint, 
        Stroke outlineStroke, float alpha) {

    ParamChecks.nullNotPermitted(paint, "paint");
    ParamChecks.nullNotPermitted(stroke, "stroke");
    if (alpha < 0.0f || alpha > 1.0f) {
        throw new IllegalArgumentException(
                "The 'alpha' value must be in the range 0.0f to 1.0f");
    }

    this.paint = paint;
    this.stroke = stroke;
    this.outlinePaint = outlinePaint;
    this.outlineStroke = outlineStroke;
    this.alpha = alpha;

    this.labelFont = new Font("SansSerif", Font.PLAIN, 9);
    this.labelPaint = Color.black;
    this.labelBackgroundColor = new Color(100, 100, 100, 100);
    this.labelAnchor = RectangleAnchor.TOP_LEFT;
    this.labelOffset = new RectangleInsets(3.0, 3.0, 3.0, 3.0);
    this.labelOffsetType = LengthAdjustmentType.CONTRACT;
    this.labelTextAnchor = TextAnchor.CENTER;

    this.listenerList = new EventListenerList();
}
 
Example #23
Source File: CrosshairOverlay.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the text anchor that is used to align a label to its anchor
 * point.
 *
 * @param anchor  the anchor.
 *
 * @return The text alignment point.
 */
private TextAnchor textAlignPtForLabelAnchorH(RectangleAnchor anchor) {
    TextAnchor result = TextAnchor.CENTER;
    if (anchor.equals(RectangleAnchor.TOP_LEFT)) {
        result = TextAnchor.BOTTOM_LEFT;
    }
    else if (anchor.equals(RectangleAnchor.TOP)) {
        result = TextAnchor.BOTTOM_CENTER;
    }
    else if (anchor.equals(RectangleAnchor.TOP_RIGHT)) {
        result = TextAnchor.BOTTOM_RIGHT;
    }
    else if (anchor.equals(RectangleAnchor.LEFT)) {
        result = TextAnchor.HALF_ASCENT_LEFT;
    }
    else if (anchor.equals(RectangleAnchor.RIGHT)) {
        result = TextAnchor.HALF_ASCENT_RIGHT;
    }
    else if (anchor.equals(RectangleAnchor.BOTTOM_LEFT)) {
        result = TextAnchor.TOP_LEFT;
    }
    else if (anchor.equals(RectangleAnchor.BOTTOM)) {
        result = TextAnchor.TOP_CENTER;
    }
    else if (anchor.equals(RectangleAnchor.BOTTOM_RIGHT)) {
        result = TextAnchor.TOP_RIGHT;
    }
    return result;
}
 
Example #24
Source File: CategoryLabelPosition.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new position record.  The item label anchor is a point 
 * relative to the data item (dot, bar or other visual item) on a chart.  
 * The item label is aligned by aligning the text anchor with the item 
 * label anchor.
 * 
 * @param categoryAnchor  the category anchor (<code>null</code> not 
 *                        permitted).
 * @param labelAnchor  the label anchor (<code>null</code> not permitted).
 * @param rotationAnchor  the rotation anchor (<code>null</code> not 
 *                        permitted).
 * @param angle  the rotation angle (<code>null</code> not permitted).
 * @param widthType  the width type (<code>null</code> not permitted).
 * @param widthRatio  the maximum label width as a percentage (of the 
 *                    category space or the range space).
 */
public CategoryLabelPosition(RectangleAnchor categoryAnchor, 
                             TextBlockAnchor labelAnchor,
                             TextAnchor rotationAnchor,
                             double angle,
                             CategoryLabelWidthType widthType,
                             float widthRatio) {
    
    if (categoryAnchor == null) {
        throw new IllegalArgumentException(
            "Null 'categoryAnchor' argument."
        );
    }
    if (labelAnchor == null) {
        throw new IllegalArgumentException(
            "Null 'labelAnchor' argument."
        );
    }
    if (rotationAnchor == null) {
        throw new IllegalArgumentException(
            "Null 'rotationAnchor' argument."
        );
    }
    if (widthType == null) {
        throw new IllegalArgumentException("Null 'widthType' argument.");   
    }
    
    this.categoryAnchor = categoryAnchor;
    this.labelAnchor = labelAnchor;
    this.rotationAnchor = rotationAnchor;
    this.angle = angle;
    this.widthType = widthType;
    this.widthRatio = widthRatio;

}
 
Example #25
Source File: LegendGraphic.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new legend graphic.
 *
 * @param shape  the shape (<code>null</code> not permitted).
 * @param fillPaint  the fill paint (<code>null</code> not permitted).
 */
public LegendGraphic(Shape shape, Paint fillPaint) {
    ParamChecks.nullNotPermitted(shape, "shape");
    ParamChecks.nullNotPermitted(fillPaint, "fillPaint");
    this.shapeVisible = true;
    this.shape = shape;
    this.shapeAnchor = RectangleAnchor.CENTER;
    this.shapeLocation = RectangleAnchor.CENTER;
    this.shapeFilled = true;
    this.fillPaint = fillPaint;
    this.fillPaintTransformer = new StandardGradientPaintTransformer();
    setPadding(2.0, 2.0, 2.0, 2.0);
}
 
Example #26
Source File: XYTitleAnnotation.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new annotation to be displayed at the specified (x, y)
 * location.
 *
 * @param x  the x-coordinate (in data space).
 * @param y  the y-coordinate (in data space).
 * @param title  the title (<code>null</code> not permitted).
 * @param anchor  the title anchor (<code>null</code> not permitted).
 */
public XYTitleAnnotation(double x, double y, Title title,
        RectangleAnchor anchor) {
    super();
    ParamChecks.nullNotPermitted(title, "title");
    ParamChecks.nullNotPermitted(anchor, "anchor");
    this.coordinateType = XYCoordinateType.RELATIVE;
    this.x = x;
    this.y = y;
    this.maxWidth = 0.0;
    this.maxHeight = 0.0;
    this.title = title;
    this.anchor = anchor;
}
 
Example #27
Source File: LabelBlock.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new label block.
 *
 * @param text  the text for the label (<code>null</code> not permitted).
 * @param font  the font (<code>null</code> not permitted).
 * @param paint the paint (<code>null</code> not permitted).
 */
public LabelBlock(String text, Font font, Paint paint) {
    this.text = text;
    this.paint = paint;
    this.label = TextUtilities.createTextBlock(text, font, this.paint);
    this.font = font;
    this.toolTipText = null;
    this.urlText = null;
    this.contentAlignmentPoint = TextBlockAnchor.CENTER;
    this.textAnchor = RectangleAnchor.CENTER;
}
 
Example #28
Source File: XYBlockRenderer.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the anchor point used to align a block at its (x, y) location and
 * sends a {@link RendererChangeEvent} to all registered listeners.
 *
 * @param anchor  the anchor.
 *
 * @see #getBlockAnchor()
 */
public void setBlockAnchor(RectangleAnchor anchor) {
    ParamChecks.nullNotPermitted(anchor, "anchor");
    if (this.blockAnchor.equals(anchor)) {
        return;  // no change
    }
    this.blockAnchor = anchor;
    updateOffsets();
    fireChangeEvent();
}
 
Example #29
Source File: XYBlockRenderer.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Updates the offsets to take into account the block width, height and
 * anchor.
 */
private void updateOffsets() {
    if (this.blockAnchor.equals(RectangleAnchor.BOTTOM_LEFT)) {
        this.xOffset = 0.0;
        this.yOffset = 0.0;
    }
    else if (this.blockAnchor.equals(RectangleAnchor.BOTTOM)) {
        this.xOffset = -this.blockWidth / 2.0;
        this.yOffset = 0.0;
    }
    else if (this.blockAnchor.equals(RectangleAnchor.BOTTOM_RIGHT)) {
        this.xOffset = -this.blockWidth;
        this.yOffset = 0.0;
    }
    else if (this.blockAnchor.equals(RectangleAnchor.LEFT)) {
        this.xOffset = 0.0;
        this.yOffset = -this.blockHeight / 2.0;
    }
    else if (this.blockAnchor.equals(RectangleAnchor.CENTER)) {
        this.xOffset = -this.blockWidth / 2.0;
        this.yOffset = -this.blockHeight / 2.0;
    }
    else if (this.blockAnchor.equals(RectangleAnchor.RIGHT)) {
        this.xOffset = -this.blockWidth;
        this.yOffset = -this.blockHeight / 2.0;
    }
    else if (this.blockAnchor.equals(RectangleAnchor.TOP_LEFT)) {
        this.xOffset = 0.0;
        this.yOffset = -this.blockHeight;
    }
    else if (this.blockAnchor.equals(RectangleAnchor.TOP)) {
        this.xOffset = -this.blockWidth / 2.0;
        this.yOffset = -this.blockHeight;
    }
    else if (this.blockAnchor.equals(RectangleAnchor.TOP_RIGHT)) {
        this.xOffset = -this.blockWidth;
        this.yOffset = -this.blockHeight;
    }
}
 
Example #30
Source File: XYImageAnnotationTest.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    Image image = JFreeChart.INFO.getLogo();
    XYImageAnnotation a1 = new XYImageAnnotation(10.0, 20.0, image);
    XYImageAnnotation a2 = new XYImageAnnotation(10.0, 20.0, image);
    assertTrue(a1.equals(a2));

    a1 = new XYImageAnnotation(10.0, 20.0, image, RectangleAnchor.LEFT);
    assertFalse(a1.equals(a2));
    a2 = new XYImageAnnotation(10.0, 20.0, image, RectangleAnchor.LEFT);
    assertTrue(a1.equals(a2));
}