Java 类org.jfree.chart.ui.TextAnchor 实例源码

项目:jfreechart    文件:ShortTextTitle.java   
/**
 * Draws the title using the current font and paint.
 *
 * @param g2  the graphics target.
 * @param area  the title area.
 * @param params  optional parameters (ignored here).
 *
 * @return {@code null}.
 */
@Override
public Object draw(Graphics2D g2, Rectangle2D area, Object params) {
    if (area.isEmpty()) {
        return null;
    }
    area = trimMargin(area);
    drawBorder(g2, area);
    area = trimBorder(area);
    area = trimPadding(area);
    g2.setFont(getFont());
    g2.setPaint(getPaint());
    TextUtils.drawAlignedString(getText(), g2, (float) area.getMinX(),
            (float) area.getMinY(), TextAnchor.TOP_LEFT);
    return null;
}
项目:jfreechart    文件:TextUtils.java   
/**
 * Draws a string such that the specified anchor point is aligned to the
 * given (x, y) location.
 *
 * @param text  the text.
 * @param g2  the graphics device.
 * @param x  the x coordinate (Java 2D).
 * @param y  the y coordinate (Java 2D).
 * @param anchor  the anchor location.
 *
 * @return The text bounds (adjusted for the text position).
 */
public static Rectangle2D drawAlignedString(String text, Graphics2D g2, 
        float x, float y, TextAnchor anchor) {

    Rectangle2D textBounds = new Rectangle2D.Double();
    float[] adjust = deriveTextBoundsAnchorOffsets(g2, text, anchor,
            textBounds);
    // adjust text bounds to match string position
    textBounds.setRect(x + adjust[0], y + adjust[1] + adjust[2],
        textBounds.getWidth(), textBounds.getHeight());
    if (!drawStringsWithFontAttributes) {
        g2.drawString(text, x + adjust[0], y + adjust[1]);
    } else {
        AttributedString as = new AttributedString(text, 
                g2.getFont().getAttributes());
        g2.drawString(as.getIterator(), x + adjust[0], y + adjust[1]);
    }
    return textBounds;
}
项目:jfreechart    文件:TextUtils.java   
/**
 * Draws a string that is aligned by one anchor point and rotated about
 * another anchor point.
 *
 * @param text  the text.
 * @param g2  the graphics device.
 * @param x  the x-coordinate for positioning the text.
 * @param y  the y-coordinate for positioning the text.
 * @param textAnchor  the text anchor.
 * @param angle  the rotation angle.
 * @param rotationX  the x-coordinate for the rotation anchor point.
 * @param rotationY  the y-coordinate for the rotation anchor point.
 */
public static void drawRotatedString(String text, Graphics2D g2, 
        float x, float y, TextAnchor textAnchor, 
        double angle, float rotationX, float rotationY) {

    if (text == null || text.equals("")) {
        return;
    }
    if (angle == 0.0) {
        drawAlignedString(text, g2, x, y, textAnchor);
    } else {
        float[] textAdj = deriveTextBoundsAnchorOffsets(g2, text, 
                textAnchor);
        drawRotatedString(text, g2, x + textAdj[0], y + textAdj[1], angle,
                rotationX, rotationY);
    }
}
项目:jfreechart    文件:TextUtils.java   
/**
 * Draws a string that is aligned by one anchor point and rotated about
 * another anchor point.
 *
 * @param text  the text.
 * @param g2  the graphics device.
 * @param x  the x-coordinate for positioning the text.
 * @param y  the y-coordinate for positioning the text.
 * @param textAnchor  the text anchor.
 * @param angle  the rotation angle (in radians).
 * @param rotationAnchor  the rotation anchor.
 */
public static void drawRotatedString(String text, Graphics2D g2, 
        float x, float y, TextAnchor textAnchor, 
        double angle, TextAnchor rotationAnchor) {

    if (text == null || text.equals("")) {
        return;
    }
    if (angle == 0.0) {
        drawAlignedString(text, g2, x, y, textAnchor);
    } else {
        float[] textAdj = deriveTextBoundsAnchorOffsets(g2, text, 
                textAnchor);
        float[] rotateAdj = deriveRotationAnchorOffsets(g2, text, 
                rotationAnchor);
        drawRotatedString(text, g2, x + textAdj[0], y + textAdj[1],
                angle, x + textAdj[0] + rotateAdj[0],
                y + textAdj[1] + rotateAdj[1]);
    }
}
项目:jfreechart    文件:TextUtils.java   
/**
 * Returns a shape that represents the bounds of the string after the
 * specified rotation has been applied.
 *
 * @param text  the text ({@code null} permitted).
 * @param g2  the graphics device.
 * @param x  the x coordinate for the anchor point.
 * @param y  the y coordinate for the anchor point.
 * @param textAnchor  the text anchor.
 * @param angle  the angle.
 * @param rotationAnchor  the rotation anchor.
 *
 * @return The bounds (possibly {@code null}).
 */
public static Shape calculateRotatedStringBounds(String text, Graphics2D g2, 
        float x, float y, TextAnchor textAnchor, 
        double angle, TextAnchor rotationAnchor) {

    if (text == null || text.equals("")) {
        return null;
    }
    float[] textAdj = deriveTextBoundsAnchorOffsets(g2, text, textAnchor);
    float[] rotateAdj = deriveRotationAnchorOffsets(g2, text, 
            rotationAnchor);
    Shape result = calculateRotatedStringBounds(text, g2,
            x + textAdj[0], y + textAdj[1], angle,
            x + textAdj[0] + rotateAdj[0], y + textAdj[1] + rotateAdj[1]);
    return result;

}
项目:jfreechart    文件:TextFragment.java   
/**
 * Calculates the vertical offset between the baseline and the specified 
 * text anchor.
 * 
 * @param g2  the graphics device.
 * @param anchor  the anchor.
 * 
 * @return the offset.
 */
public float calculateBaselineOffset(Graphics2D g2, TextAnchor anchor) {
    float result = 0.0f;
    FontMetrics fm = g2.getFontMetrics(this.font);
    LineMetrics lm = fm.getLineMetrics("ABCxyz", g2);
    if (anchor.isTop()) {
        result = lm.getAscent();
    }
    else if (anchor.isHalfAscent()) {
        result = lm.getAscent() / 2.0f;
    }
    else if (anchor.isVerticalCenter()) {
        result = lm.getAscent() / 2.0f - lm.getDescent() / 2.0f;
    }
    else if (anchor.isBottom()) {
        result = -lm.getDescent() - lm.getLeading();
    }
    return result;                                             
}
项目:jfreechart    文件:TextLine.java   
/**
 * Draws the text line.
 * 
 * @param g2  the graphics device.
 * @param anchorX  the x-coordinate for the anchor point.
 * @param anchorY  the y-coordinate for the anchor point.
 * @param anchor  the point on the text line that is aligned to the anchor 
 *                point.
 * @param rotateX  the x-coordinate for the rotation point.
 * @param rotateY  the y-coordinate for the rotation point.
 * @param angle  the rotation angle (in radians).
 */
public void draw(Graphics2D g2, float anchorX, float anchorY, 
        TextAnchor anchor, float rotateX, float rotateY, double angle) {

    Size2D dim = calculateDimensions(g2);
    float xAdj = 0.0f;
    if (anchor.isHorizontalCenter()) {
        xAdj = (float) -dim.getWidth() / 2.0f;
    }
    else if (anchor.isRight()) {
        xAdj = (float) -dim.getWidth();
    }
    float x = anchorX + xAdj;
    final float yOffset = calculateBaselineOffset(g2, anchor);
    final Iterator iterator = this.fragments.iterator();
    while (iterator.hasNext()) {
        final TextFragment fragment = (TextFragment) iterator.next();
        final Size2D d = fragment.calculateDimensions(g2);
        fragment.draw(g2, x, anchorY + yOffset, TextAnchor.BASELINE_LEFT, 
                rotateX, rotateY, angle);
        x = x + (float) d.getWidth();
    }

}
项目:jfreechart    文件:MeterPlot.java   
/**
 * Draws the value label just below the center of the dial.
 *
 * @param g2  the graphics device.
 * @param area  the plot area.
 */
protected void drawValueLabel(Graphics2D g2, Rectangle2D area) {
    g2.setFont(this.valueFont);
    g2.setPaint(this.valuePaint);
    String valueStr = "No value";
    if (this.dataset != null) {
        Number n = this.dataset.getValue();
        if (n != null) {
            valueStr = this.tickLabelFormat.format(n.doubleValue()) + " "
                     + this.units;
        }
    }
    float x = (float) area.getCenterX();
    float y = (float) area.getCenterY() + DEFAULT_CIRCLE_SIZE;
    TextUtils.drawAlignedString(valueStr, g2, x, y,
            TextAnchor.TOP_CENTER);
}
项目:jfreechart    文件:DialValueIndicator.java   
/**
 * Creates a new instance of {@code DialValueIndicator}.
 *
 * @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;
}
项目:jfreechart    文件:CategoryLabelPositions.java   
/**
 * Creates a new instance where the category labels angled upwards by the
 * specified amount.
 *
 * @param angle  the rotation angle (should be < 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
    );
}
项目:jfreechart    文件:CategoryLabelPositions.java   
/**
 * Creates a new instance where the category labels angled downwards by the
 * specified amount.
 *
 * @param angle  the rotation angle (should be < 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
    );
}
项目:jfreechart    文件:CategoryLabelPosition.java   
/**
 * 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} not
 *                        permitted).
 * @param labelAnchor  the label anchor ({@code null} not permitted).
 * @param rotationAnchor  the rotation anchor ({@code null} not
 *                        permitted).
 * @param angle  the rotation angle ({@code null} not permitted).
 * @param widthType  the width type ({@code null} 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) {

    Args.nullNotPermitted(categoryAnchor, "categoryAnchor");
    Args.nullNotPermitted(labelAnchor, "labelAnchor");
    Args.nullNotPermitted(rotationAnchor, "rotationAnchor");
    Args.nullNotPermitted(widthType, "widthType");

    this.categoryAnchor = categoryAnchor;
    this.labelAnchor = labelAnchor;
    this.rotationAnchor = rotationAnchor;
    this.angle = angle;
    this.widthType = widthType;
    this.widthRatio = widthRatio;

}
项目:jfreechart    文件:MarkerTest.java   
/**
 * Some checks for the getLabelTextAnchor() and setLabelTextAnchor()
 * methods.
 */
@Test
public void testGetSetLabelTextAnchor() {
    // 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(TextAnchor.CENTER, m.getLabelTextAnchor());
    m.setLabelTextAnchor(TextAnchor.BASELINE_LEFT);
    assertEquals(TextAnchor.BASELINE_LEFT, m.getLabelTextAnchor());
    assertEquals(m, this.lastEvent.getMarker());

    // check null argument...
    try {
        m.setLabelTextAnchor(null);
        fail("Expected an IllegalArgumentException for null.");
    }
    catch (IllegalArgumentException e) {
        assertTrue(true);
    }
}
项目:jfreechart    文件:CategoryTickTest.java   
/**
 * Two objects that are equal are required to return the same hashCode.
 */
@Test
public void testHashCode() {
    Comparable c1 = "C1";
    TextBlock tb1 = new TextBlock();
    tb1.addLine(new TextLine("Block 1"));
    tb1.addLine(new TextLine("Block 2"));
    TextBlockAnchor tba1 = TextBlockAnchor.CENTER;
    TextAnchor ta1 = TextAnchor.CENTER;

    CategoryTick t1 = new CategoryTick(c1, tb1, tba1, ta1, 1.0f);
    CategoryTick t2 = new CategoryTick(c1, tb1, tba1, ta1, 1.0f);
    assertTrue(t1.equals(t2));
    int h1 = t1.hashCode();
    int h2 = t2.hashCode();
    assertEquals(h1, h2);
}
项目:jfreechart    文件:CrosshairOverlay.java   
/**
 * 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 textAlignPtForLabelAnchorV(RectangleAnchor anchor) {
    TextAnchor result = TextAnchor.CENTER;
    if (anchor.equals(RectangleAnchor.TOP_LEFT)) {
        result = TextAnchor.TOP_RIGHT;
    }
    else if (anchor.equals(RectangleAnchor.TOP)) {
        result = TextAnchor.TOP_CENTER;
    }
    else if (anchor.equals(RectangleAnchor.TOP_RIGHT)) {
        result = TextAnchor.TOP_LEFT;
    }
    else if (anchor.equals(RectangleAnchor.LEFT)) {
        result = TextAnchor.HALF_ASCENT_RIGHT;
    }
    else if (anchor.equals(RectangleAnchor.RIGHT)) {
        result = TextAnchor.HALF_ASCENT_LEFT;
    }
    else if (anchor.equals(RectangleAnchor.BOTTOM_LEFT)) {
        result = TextAnchor.BOTTOM_RIGHT;
    }
    else if (anchor.equals(RectangleAnchor.BOTTOM)) {
        result = TextAnchor.BOTTOM_CENTER;
    }
    else if (anchor.equals(RectangleAnchor.BOTTOM_RIGHT)) {
        result = TextAnchor.BOTTOM_LEFT;
    }
    return result;
}
项目:jfreechart    文件:CrosshairOverlay.java   
/**
 * 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;
}
项目:jfreechart    文件:StackedXYBarRenderer.java   
/**
 * Creates a new renderer.
 *
 * @param margin  the percentual amount of the bars that are cut away.
 */
public StackedXYBarRenderer(double margin) {
    super(margin);
    this.renderAsPercentages = false;

    // set the default item label positions, which will only be used if
    // the user requests visible item labels...
    ItemLabelPosition p = new ItemLabelPosition(ItemLabelAnchor.CENTER,
            TextAnchor.CENTER);
    setDefaultPositiveItemLabelPosition(p);
    setDefaultNegativeItemLabelPosition(p);
    setPositiveItemLabelPositionFallback(null);
    setNegativeItemLabelPositionFallback(null);
}
项目:jfreechart    文件:StackedBarRenderer.java   
/**
 * Creates a new renderer.
 *
 * @param renderAsPercentages  a flag that controls whether the data values
 *                             are rendered as percentages.
 */
public StackedBarRenderer(boolean renderAsPercentages) {
    super();
    this.renderAsPercentages = renderAsPercentages;

    // set the default item label positions, which will only be used if
    // the user requests visible item labels...
    ItemLabelPosition p = new ItemLabelPosition(ItemLabelAnchor.CENTER,
            TextAnchor.CENTER);
    setDefaultPositiveItemLabelPosition(p);
    setDefaultNegativeItemLabelPosition(p);
    setPositiveItemLabelPositionFallback(null);
    setNegativeItemLabelPositionFallback(null);
}
项目:jfreechart    文件:TextUtils.java   
/**
 * A utility method for drawing rotated text.
 * <P>
 * A common rotation is -Math.PI/2 which draws text 'vertically' (with the
 * top of the characters on the left).
 *
 * @param text  the text.
 * @param g2  the graphics device.
 * @param textX  the x-coordinate for the text (before rotation).
 * @param textY  the y-coordinate for the text (before rotation).
 * @param angle  the angle of the (clockwise) rotation (in radians).
 * @param rotateX  the point about which the text is rotated.
 * @param rotateY  the point about which the text is rotated.
 */
public static void drawRotatedString(String text, Graphics2D g2,
        float textX, float textY, 
        double angle, float rotateX, float rotateY) {

    if ((text == null) || (text.equals(""))) {
        return;
    }
    if (angle == 0.0) {
        drawAlignedString(text, g2, textX, textY, TextAnchor.BASELINE_LEFT);
        return;
    }

    AffineTransform saved = g2.getTransform();
    AffineTransform rotate = AffineTransform.getRotateInstance(
            angle, rotateX, rotateY);
    g2.transform(rotate);

    if (useDrawRotatedStringWorkaround) {
        // workaround for JDC bug ID 4312117 and others...
        TextLayout tl = new TextLayout(text, g2.getFont(),
                g2.getFontRenderContext());
        tl.draw(g2, textX, textY);
    }
    else {
        if (!drawStringsWithFontAttributes) {
            g2.drawString(text, textX, textY);
        } else {
            AttributedString as = new AttributedString(text, 
                    g2.getFont().getAttributes());
            g2.drawString(as.getIterator(), textX, textY);
        }
    }
    g2.setTransform(saved);

}
项目:jfreechart    文件:TextBlock.java   
/**
 * Draws the text block, aligning it with the specified anchor point and 
 * rotating it about the specified rotation point.
 * 
 * @param g2  the graphics device.
 * @param anchorX  the x-coordinate for the anchor point.
 * @param anchorY  the y-coordinate for the anchor point.
 * @param anchor  the point on the text block that is aligned to the 
 *                anchor point.
 * @param rotateX  the x-coordinate for the rotation point.
 * @param rotateY  the x-coordinate for the rotation point.
 * @param angle  the rotation (in radians).
 */
public void draw(Graphics2D g2, float anchorX, float anchorY, 
        TextBlockAnchor anchor, float rotateX, float rotateY, double angle) {

    Size2D d = calculateDimensions(g2);
    float[] offsets = calculateOffsets(anchor, d.getWidth(), 
            d.getHeight());
    Iterator iterator = this.lines.iterator();
    float yCursor = 0.0f;
    while (iterator.hasNext()) {
        TextLine line = (TextLine) iterator.next();
        Size2D dimension = line.calculateDimensions(g2);
        float lineOffset = 0.0f;
        if (this.lineAlignment == HorizontalAlignment.CENTER) {
            lineOffset = (float) (d.getWidth() - dimension.getWidth()) 
                / 2.0f;   
        }
        else if (this.lineAlignment == HorizontalAlignment.RIGHT) {
            lineOffset = (float) (d.getWidth() - dimension.getWidth());   
        }
        line.draw(g2, anchorX + offsets[0] + lineOffset, 
                anchorY + offsets[1] + yCursor, TextAnchor.TOP_LEFT, 
                rotateX, rotateY, angle);
        yCursor = yCursor + (float) dimension.getHeight();
    }

}
项目:jfreechart    文件:TextLine.java   
/**
 * Calculate the offsets required to translate from the specified anchor 
 * position to the left baseline position.
 * 
 * @param g2  the graphics device.
 * @param anchor  the anchor position.
 * 
 * @return The offsets.
 */
private float calculateBaselineOffset(Graphics2D g2, TextAnchor anchor) {
    float result = 0.0f;
    Iterator iterator = this.fragments.iterator();
    while (iterator.hasNext()) {
        TextFragment fragment = (TextFragment) iterator.next();
        result = Math.max(result, 
                fragment.calculateBaselineOffset(g2, anchor));
    }
    return result;
}
项目:jfreechart    文件:DialTextAnnotation.java   
/**
 * Creates a new instance of {@code DialTextAnnotation}.
 *
 * @param label  the label ({@code null} not permitted).
 */
public DialTextAnnotation(String label) {
    Args.nullNotPermitted(label, "label");
    this.angle = -90.0;
    this.radius = 0.3;
    this.font = new Font("Dialog", Font.BOLD, 14);
    this.paint = Color.BLACK;
    this.label = label;
    this.anchor = TextAnchor.TOP_CENTER;
}
项目:jfreechart    文件:Marker.java   
/**
 * 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) {

    Args.nullNotPermitted(paint, "paint");
    Args.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();
}
项目:jfreechart    文件:PolarPlot.java   
/**
 * Generates a list of tick values for the angular tick marks.
 *
 * @return A list of {@link NumberTick} instances.
 *
 * @since 1.0.10
 */
protected List refreshAngleTicks() {
    List ticks = new ArrayList();
    for (double currentTickVal = 0.0; currentTickVal < 360.0;
            currentTickVal += this.angleTickUnit.getSize()) {

        TextAnchor ta = calculateTextAnchor(currentTickVal);
        NumberTick tick = new NumberTick(new Double(currentTickVal),
            this.angleTickUnit.valueToString(currentTickVal),
            ta, TextAnchor.CENTER, 0.0);
        ticks.add(tick);
    }
    return ticks;
}
项目:jfreechart    文件:Axis.java   
protected TextAnchor labelAnchorH(AxisLabelLocation location) {
    if (location.equals(AxisLabelLocation.HIGH_END)) {
        return TextAnchor.CENTER_RIGHT;
    }
    if (location.equals(AxisLabelLocation.MIDDLE)) {
        return TextAnchor.CENTER;
    }
    if (location.equals(AxisLabelLocation.LOW_END)) {
        return TextAnchor.CENTER_LEFT;
    }
    throw new RuntimeException("Unexpected AxisLabelLocation: " + location);
}
项目:jfreechart    文件:Axis.java   
protected TextAnchor labelAnchorV(AxisLabelLocation location) {
    if (location.equals(AxisLabelLocation.HIGH_END)) {
        return TextAnchor.CENTER_RIGHT;
    }
    if (location.equals(AxisLabelLocation.MIDDLE)) {
        return TextAnchor.CENTER;
    }
    if (location.equals(AxisLabelLocation.LOW_END)) {
        return TextAnchor.CENTER_LEFT;
    }
    throw new RuntimeException("Unexpected AxisLabelLocation: " + location);
}
项目:jfreechart    文件:Tick.java   
/**
 * Creates a new tick.
 *
 * @param text  the formatted version of the tick value.
 * @param textAnchor  the text anchor ({@code null} not permitted).
 * @param rotationAnchor  the rotation anchor ({@code null} not
 *                        permitted).
 * @param angle  the angle.
 */
public Tick(String text, TextAnchor textAnchor, TextAnchor rotationAnchor,
            double angle) {
    Args.nullNotPermitted(textAnchor, "textAnchor");
    Args.nullNotPermitted(rotationAnchor, "rotationAnchor");
    this.text = text;
    this.textAnchor = textAnchor;
    this.rotationAnchor = rotationAnchor;
    this.angle = angle;
}
项目:jfreechart    文件:CategoryTick.java   
/**
 * Creates a new tick.
 *
 * @param category  the category.
 * @param label  the label.
 * @param labelAnchor  the label anchor.
 * @param rotationAnchor  the rotation anchor.
 * @param angle  the rotation angle (in radians).
 */
public CategoryTick(Comparable category,
                    TextBlock label,
                    TextBlockAnchor labelAnchor,
                    TextAnchor rotationAnchor,
                    double angle) {

    super("", TextAnchor.CENTER, rotationAnchor, angle);
    this.category = category;
    this.label = label;
    this.labelAnchor = labelAnchor;

}
项目:jfreechart    文件:AttrStringUtils.java   
private static boolean isHorizontalLeft(TextAnchor anchor) {
    return anchor.equals(TextAnchor.TOP_LEFT) 
            || anchor.equals(TextAnchor.CENTER_LEFT) 
            || anchor.equals(TextAnchor.HALF_ASCENT_LEFT) 
            || anchor.equals(TextAnchor.BASELINE_LEFT) 
            || anchor.equals(TextAnchor.BOTTOM_LEFT);
}
项目:jfreechart    文件:AttrStringUtils.java   
private static boolean isHorizontalCenter(TextAnchor anchor) {
    return anchor.equals(TextAnchor.TOP_CENTER) 
            || anchor.equals(TextAnchor.CENTER) 
            || anchor.equals(TextAnchor.HALF_ASCENT_CENTER) 
            || anchor.equals(TextAnchor.BASELINE_CENTER) 
            || anchor.equals(TextAnchor.BOTTOM_CENTER);
}
项目:jfreechart    文件:AttrStringUtils.java   
private static boolean isHorizontalRight(TextAnchor anchor) {
    return anchor.equals(TextAnchor.TOP_RIGHT) 
            || anchor.equals(TextAnchor.CENTER_RIGHT) 
            || anchor.equals(TextAnchor.HALF_ASCENT_RIGHT) 
            || anchor.equals(TextAnchor.BASELINE_RIGHT)
            || anchor.equals(TextAnchor.BOTTOM_RIGHT);
}
项目:jfreechart    文件:AbstractRendererTest.java   
@Test
public void testEquals_ObjectList3() {
    BarRenderer r1 = new BarRenderer();
    r1.setSeriesPositiveItemLabelPosition(0, 
            new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER));
    BarRenderer r2 = new BarRenderer();
    r2.setSeriesPositiveItemLabelPosition(0, 
            new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER));
    assertEquals(r1, r2);
    r2.setSeriesPositiveItemLabelPosition(1, 
            new ItemLabelPosition(ItemLabelAnchor.INSIDE1, TextAnchor.CENTER));
    assertNotEquals(r1, r2);
}
项目:jfreechart    文件:AbstractRendererTest.java   
@Test
public void testEquals_ObjectList4() {
    BarRenderer r1 = new BarRenderer();
    r1.setSeriesNegativeItemLabelPosition(0, 
            new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER));
    BarRenderer r2 = new BarRenderer();
    r2.setSeriesNegativeItemLabelPosition(0, 
            new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER));
    assertEquals(r1, r2);
    r2.setSeriesNegativeItemLabelPosition(1, 
            new ItemLabelPosition(ItemLabelAnchor.INSIDE1, TextAnchor.CENTER));
    assertNotEquals(r1, r2);
}
项目:jfreechart    文件:CategoryTickTest.java   
/**
 * Confirm that cloning works.
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    CategoryTick t1 = new CategoryTick("C1", new TextBlock(), 
            TextBlockAnchor.CENTER, TextAnchor.CENTER, 1.5f);
    CategoryTick t2 = (CategoryTick) t1.clone();
    assertTrue(t1 != t2);
    assertTrue(t1.getClass() == t2.getClass());
    assertTrue(t1.equals(t2));
}
项目:jfreechart    文件:CategoryTickTest.java   
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization() {
    CategoryTick t1 = new CategoryTick("C1", new TextBlock(),
            TextBlockAnchor.CENTER, TextAnchor.CENTER, 1.5f);
    CategoryTick t2 = (CategoryTick) TestUtils.serialised(t1);
    assertEquals(t1, t2);
}
项目:jfreechart    文件:DateTickTest.java   
/**
 * Two objects that are equal are required to return the same hashCode.
 */
@Test
public void testHashCode() {
    Date d1 = new Date(0L);
    String l1 = "Label 1";
    TextAnchor ta1 = TextAnchor.CENTER;

    DateTick t1 = new DateTick(d1, l1, ta1, ta1, Math.PI / 2.0);
    DateTick t2 = new DateTick(d1, l1, ta1, ta1, Math.PI / 2.0);
    assertTrue(t1.equals(t2));
    int h1 = t1.hashCode();
    int h2 = t2.hashCode();
    assertEquals(h1, h2);
}
项目:jfreechart    文件:DateTickTest.java   
/**
 * Confirm that cloning works.
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    DateTick t1 = new DateTick(new Date(0L), "Label", TextAnchor.CENTER,
            TextAnchor.CENTER, 10.0);
    DateTick t2 = (DateTick) t1.clone();
    assertTrue(t1 != t2);
    assertTrue(t1.getClass() == t2.getClass());
    assertTrue(t1.equals(t2));
}
项目:jfreechart    文件:DateTickTest.java   
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization() {
    DateTick t1 = new DateTick(new Date(0L), "Label", TextAnchor.CENTER,
            TextAnchor.CENTER, 10.0);
    DateTick t2 = (DateTick) TestUtils.serialised(t1);
    assertEquals(t1, t2);
}
项目:jfreechart    文件:TextAnnotationTest.java   
/**
  * Some tests to ensure that change events are generated as expected.
  */
 @Test
 public void testChangeEvents() {
     TextAnnotation a = new CategoryTextAnnotation("Test", "A", 1.0);
     a.addChangeListener(this);
     this.lastEvent = null;
     a.setText("B");
     assertNotNull(this.lastEvent);
             this.lastEvent = null;
     a.setText("B");
     assertNotNull(this.lastEvent);

     this.lastEvent = null;
     a.setFont(new Font("SansSerif", Font.PLAIN, 12));
     assertNotNull(this.lastEvent);

     this.lastEvent = null;
     a.setPaint(Color.BLUE);
     assertNotNull(this.lastEvent);

     this.lastEvent = null;
     a.setTextAnchor(TextAnchor.CENTER_LEFT);
     assertNotNull(this.lastEvent);

     this.lastEvent = null;
     a.setRotationAnchor(TextAnchor.CENTER_LEFT);
     assertNotNull(this.lastEvent);

     this.lastEvent = null;
     a.setRotationAngle(123.4);
     assertNotNull(this.lastEvent);
}
项目:SPIM_Registration    文件:MouseListenerValue.java   
protected ValueMarker makeMarker( final double value )
{
    final ValueMarker valueMarker = new ValueMarker( value );
    valueMarker.setStroke( new BasicStroke ( 2f ) );
    valueMarker.setPaint( new Color( 0f/255f, 0f/255f, 255f/255f ) );
    valueMarker.setLabel( " Distance=" + value );
    valueMarker.setLabelPaint( Color.BLUE );
    valueMarker.setLabelAnchor( RectangleAnchor.TOP );
    valueMarker.setLabelTextAnchor( TextAnchor.TOP_LEFT );

    return valueMarker;
}