Java Code Examples for org.jfree.ui.HorizontalAlignment#RIGHT

The following examples show how to use org.jfree.ui.HorizontalAlignment#RIGHT . 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: ColumnArrangementTest.java    From openstock 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() {
    ColumnArrangement c1 = new ColumnArrangement(HorizontalAlignment.LEFT,
            VerticalAlignment.TOP, 1.0, 2.0);
    ColumnArrangement c2 = new ColumnArrangement(HorizontalAlignment.LEFT,
            VerticalAlignment.TOP, 1.0, 2.0);
    assertTrue(c1.equals(c2));
    assertTrue(c2.equals(c1));

    c1 = new ColumnArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.TOP, 1.0, 2.0);
    assertFalse(c1.equals(c2));
    c2 = new ColumnArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.TOP, 1.0, 2.0);
    assertTrue(c1.equals(c2));

    c1 = new ColumnArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.BOTTOM, 1.0, 2.0);
    assertFalse(c1.equals(c2));
    c2 = new ColumnArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.BOTTOM, 1.0, 2.0);
    assertTrue(c1.equals(c2));

    c1 = new ColumnArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.BOTTOM, 1.1, 2.0);
    assertFalse(c1.equals(c2));
    c2 = new ColumnArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.BOTTOM, 1.1, 2.0);
    assertTrue(c1.equals(c2));

    c1 = new ColumnArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.BOTTOM, 1.1, 2.2);
    assertFalse(c1.equals(c2));
    c2 = new ColumnArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.BOTTOM, 1.1, 2.2);
    assertTrue(c1.equals(c2));
}
 
Example 2
Source File: ColumnArrangementTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Confirm that the equals() method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    ColumnArrangement c1 = new ColumnArrangement(HorizontalAlignment.LEFT,
            VerticalAlignment.TOP, 1.0, 2.0);
    ColumnArrangement c2 = new ColumnArrangement(HorizontalAlignment.LEFT,
            VerticalAlignment.TOP, 1.0, 2.0);
    assertTrue(c1.equals(c2));
    assertTrue(c2.equals(c1));

    c1 = new ColumnArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.TOP, 1.0, 2.0);
    assertFalse(c1.equals(c2));
    c2 = new ColumnArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.TOP, 1.0, 2.0);
    assertTrue(c1.equals(c2));

    c1 = new ColumnArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.BOTTOM, 1.0, 2.0);
    assertFalse(c1.equals(c2));
    c2 = new ColumnArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.BOTTOM, 1.0, 2.0);
    assertTrue(c1.equals(c2));

    c1 = new ColumnArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.BOTTOM, 1.1, 2.0);
    assertFalse(c1.equals(c2));
    c2 = new ColumnArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.BOTTOM, 1.1, 2.0);
    assertTrue(c1.equals(c2));

    c1 = new ColumnArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.BOTTOM, 1.1, 2.2);
    assertFalse(c1.equals(c2));
    c2 = new ColumnArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.BOTTOM, 1.1, 2.2);
    assertTrue(c1.equals(c2));
}
 
Example 3
Source File: FlowArrangementTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Confirm that the equals() method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    FlowArrangement f1 = new FlowArrangement(HorizontalAlignment.LEFT,
            VerticalAlignment.TOP, 1.0, 2.0);
    FlowArrangement f2 = new FlowArrangement(HorizontalAlignment.LEFT,
            VerticalAlignment.TOP, 1.0, 2.0);
    assertTrue(f1.equals(f2));
    assertTrue(f2.equals(f1));

    f1 = new FlowArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.TOP, 1.0, 2.0);
    assertFalse(f1.equals(f2));
    f2 = new FlowArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.TOP, 1.0, 2.0);
    assertTrue(f1.equals(f2));

    f1 = new FlowArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.BOTTOM, 1.0, 2.0);
    assertFalse(f1.equals(f2));
    f2 = new FlowArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.BOTTOM, 1.0, 2.0);
    assertTrue(f1.equals(f2));

    f1 = new FlowArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.BOTTOM, 1.1, 2.0);
    assertFalse(f1.equals(f2));
    f2 = new FlowArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.BOTTOM, 1.1, 2.0);
    assertTrue(f1.equals(f2));

    f1 = new FlowArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.BOTTOM, 1.1, 2.2);
    assertFalse(f1.equals(f2));
    f2 = new FlowArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.BOTTOM, 1.1, 2.2);
    assertTrue(f1.equals(f2));

}
 
Example 4
Source File: JFreeChart.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a rectangle that is aligned to the frame.
 *
 * @param dimensions  the dimensions for the rectangle.
 * @param frame  the frame to align to.
 * @param hAlign  the horizontal alignment.
 * @param vAlign  the vertical alignment.
 *
 * @return A rectangle.
 */
private Rectangle2D createAlignedRectangle2D(Size2D dimensions,
        Rectangle2D frame, HorizontalAlignment hAlign,
        VerticalAlignment vAlign) {
    double x = Double.NaN;
    double y = Double.NaN;
    if (hAlign == HorizontalAlignment.LEFT) {
        x = frame.getX();
    }
    else if (hAlign == HorizontalAlignment.CENTER) {
        x = frame.getCenterX() - (dimensions.width / 2.0);
    }
    else if (hAlign == HorizontalAlignment.RIGHT) {
        x = frame.getMaxX() - dimensions.width;
    }
    if (vAlign == VerticalAlignment.TOP) {
        y = frame.getY();
    }
    else if (vAlign == VerticalAlignment.CENTER) {
        y = frame.getCenterY() - (dimensions.height / 2.0);
    }
    else if (vAlign == VerticalAlignment.BOTTOM) {
        y = frame.getMaxY() - dimensions.height;
    }

    return new Rectangle2D.Double(x, y, dimensions.width,
            dimensions.height);
}
 
Example 5
Source File: ColumnArrangement.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Arranges the blocks without any constraints.  This puts all blocks
 * into a single column.
 *
 * @param container  the container.
 * @param g2  the graphics device.
 *
 * @return The size after the arrangement.
 */
protected Size2D arrangeNN(BlockContainer container, Graphics2D g2) {
    double y = 0.0;
    double height = 0.0;
    double maxWidth = 0.0;
    List blocks = container.getBlocks();
    int blockCount = blocks.size();
    if (blockCount > 0) {
        Size2D[] sizes = new Size2D[blocks.size()];
        for (int i = 0; i < blocks.size(); i++) {
            Block block = (Block) blocks.get(i);
            sizes[i] = block.arrange(g2, RectangleConstraint.NONE);
            height = height + sizes[i].getHeight();
            maxWidth = Math.max(sizes[i].width, maxWidth);
            block.setBounds(
                new Rectangle2D.Double(
                    0.0, y, sizes[i].width, sizes[i].height
                )
            );
            y = y + sizes[i].height + this.verticalGap;
        }
        if (blockCount > 1) {
            height = height + this.verticalGap * (blockCount - 1);
        }
        if (this.horizontalAlignment != HorizontalAlignment.LEFT) {
            for (int i = 0; i < blocks.size(); i++) {
                //Block b = (Block) blocks.get(i);
                if (this.horizontalAlignment
                        == HorizontalAlignment.CENTER) {
                    //TODO: shift block right by half
                }
                else if (this.horizontalAlignment
                        == HorizontalAlignment.RIGHT) {
                    //TODO: shift block over to right
                }
            }
        }
    }
    return new Size2D(maxWidth, height);
}
 
Example 6
Source File: JFreeChart.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a rectangle that is aligned to the frame.
 *
 * @param dimensions  the dimensions for the rectangle.
 * @param frame  the frame to align to.
 * @param hAlign  the horizontal alignment.
 * @param vAlign  the vertical alignment.
 *
 * @return A rectangle.
 */
private Rectangle2D createAlignedRectangle2D(Size2D dimensions,
        Rectangle2D frame, HorizontalAlignment hAlign,
        VerticalAlignment vAlign) {
    double x = Double.NaN;
    double y = Double.NaN;
    if (hAlign == HorizontalAlignment.LEFT) {
        x = frame.getX();
    }
    else if (hAlign == HorizontalAlignment.CENTER) {
        x = frame.getCenterX() - (dimensions.width / 2.0);
    }
    else if (hAlign == HorizontalAlignment.RIGHT) {
        x = frame.getMaxX() - dimensions.width;
    }
    if (vAlign == VerticalAlignment.TOP) {
        y = frame.getY();
    }
    else if (vAlign == VerticalAlignment.CENTER) {
        y = frame.getCenterY() - (dimensions.height / 2.0);
    }
    else if (vAlign == VerticalAlignment.BOTTOM) {
        y = frame.getMaxY() - dimensions.height;
    }

    return new Rectangle2D.Double(x, y, dimensions.width,
            dimensions.height);
}
 
Example 7
Source File: ColumnArrangement.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Arranges the blocks without any constraints.  This puts all blocks
 * into a single column.
 *
 * @param container  the container.
 * @param g2  the graphics device.
 *
 * @return The size after the arrangement.
 */
protected Size2D arrangeNN(BlockContainer container, Graphics2D g2) {
    double y = 0.0;
    double height = 0.0;
    double maxWidth = 0.0;
    List blocks = container.getBlocks();
    int blockCount = blocks.size();
    if (blockCount > 0) {
        Size2D[] sizes = new Size2D[blocks.size()];
        for (int i = 0; i < blocks.size(); i++) {
            Block block = (Block) blocks.get(i);
            sizes[i] = block.arrange(g2, RectangleConstraint.NONE);
            height = height + sizes[i].getHeight();
            maxWidth = Math.max(sizes[i].width, maxWidth);
            block.setBounds(
                new Rectangle2D.Double(
                    0.0, y, sizes[i].width, sizes[i].height
                )
            );
            y = y + sizes[i].height + this.verticalGap;
        }
        if (blockCount > 1) {
            height = height + this.verticalGap * (blockCount - 1);
        }
        if (this.horizontalAlignment != HorizontalAlignment.LEFT) {
            for (int i = 0; i < blocks.size(); i++) {
                //Block b = (Block) blocks.get(i);
                if (this.horizontalAlignment
                        == HorizontalAlignment.CENTER) {
                    //TODO: shift block right by half
                }
                else if (this.horizontalAlignment
                        == HorizontalAlignment.RIGHT) {
                    //TODO: shift block over to right
                }
            }
        }
    }
    return new Size2D(maxWidth, height);
}
 
Example 8
Source File: TextTitle.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Draws a the title horizontally within the specified area.  This method
 * will be called from the {@link #draw(Graphics2D, Rectangle2D) draw}
 * method.
 *
 * @param g2  the graphics device.
 * @param area  the area for the title.
 */
protected void drawHorizontal(Graphics2D g2, Rectangle2D area) {
    Rectangle2D titleArea = (Rectangle2D) area.clone();
    g2.setFont(this.font);
    g2.setPaint(this.paint);
    TextBlockAnchor anchor = null;
    float x = 0.0f;
    HorizontalAlignment horizontalAlignment = getHorizontalAlignment();
    if (horizontalAlignment == HorizontalAlignment.LEFT) {
        x = (float) titleArea.getX();
        anchor = TextBlockAnchor.TOP_LEFT;
    }
    else if (horizontalAlignment == HorizontalAlignment.RIGHT) {
        x = (float) titleArea.getMaxX();
        anchor = TextBlockAnchor.TOP_RIGHT;
    }
    else if (horizontalAlignment == HorizontalAlignment.CENTER) {
        x = (float) titleArea.getCenterX();
        anchor = TextBlockAnchor.TOP_CENTER;
    }
    float y = 0.0f;
    RectangleEdge position = getPosition();
    if (position == RectangleEdge.TOP) {
        y = (float) titleArea.getY();
    }
    else if (position == RectangleEdge.BOTTOM) {
        y = (float) titleArea.getMaxY();
        if (horizontalAlignment == HorizontalAlignment.LEFT) {
            anchor = TextBlockAnchor.BOTTOM_LEFT;
        }
        else if (horizontalAlignment == HorizontalAlignment.CENTER) {
            anchor = TextBlockAnchor.BOTTOM_CENTER;
        }
        else if (horizontalAlignment == HorizontalAlignment.RIGHT) {
            anchor = TextBlockAnchor.BOTTOM_RIGHT;
        }
    }
    this.content.draw(g2, x, y, anchor);
}
 
Example 9
Source File: ColumnArrangementTest.java    From ccu-historian 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() {
    ColumnArrangement c1 = new ColumnArrangement(HorizontalAlignment.LEFT,
            VerticalAlignment.TOP, 1.0, 2.0);
    ColumnArrangement c2 = new ColumnArrangement(HorizontalAlignment.LEFT,
            VerticalAlignment.TOP, 1.0, 2.0);
    assertTrue(c1.equals(c2));
    assertTrue(c2.equals(c1));

    c1 = new ColumnArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.TOP, 1.0, 2.0);
    assertFalse(c1.equals(c2));
    c2 = new ColumnArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.TOP, 1.0, 2.0);
    assertTrue(c1.equals(c2));

    c1 = new ColumnArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.BOTTOM, 1.0, 2.0);
    assertFalse(c1.equals(c2));
    c2 = new ColumnArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.BOTTOM, 1.0, 2.0);
    assertTrue(c1.equals(c2));

    c1 = new ColumnArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.BOTTOM, 1.1, 2.0);
    assertFalse(c1.equals(c2));
    c2 = new ColumnArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.BOTTOM, 1.1, 2.0);
    assertTrue(c1.equals(c2));

    c1 = new ColumnArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.BOTTOM, 1.1, 2.2);
    assertFalse(c1.equals(c2));
    c2 = new ColumnArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.BOTTOM, 1.1, 2.2);
    assertTrue(c1.equals(c2));
}
 
Example 10
Source File: FlowArrangementTest.java    From ccu-historian 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() {
    FlowArrangement f1 = new FlowArrangement(HorizontalAlignment.LEFT,
            VerticalAlignment.TOP, 1.0, 2.0);
    FlowArrangement f2 = new FlowArrangement(HorizontalAlignment.LEFT,
            VerticalAlignment.TOP, 1.0, 2.0);
    assertTrue(f1.equals(f2));
    assertTrue(f2.equals(f1));

    f1 = new FlowArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.TOP, 1.0, 2.0);
    assertFalse(f1.equals(f2));
    f2 = new FlowArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.TOP, 1.0, 2.0);
    assertTrue(f1.equals(f2));

    f1 = new FlowArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.BOTTOM, 1.0, 2.0);
    assertFalse(f1.equals(f2));
    f2 = new FlowArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.BOTTOM, 1.0, 2.0);
    assertTrue(f1.equals(f2));

    f1 = new FlowArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.BOTTOM, 1.1, 2.0);
    assertFalse(f1.equals(f2));
    f2 = new FlowArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.BOTTOM, 1.1, 2.0);
    assertTrue(f1.equals(f2));

    f1 = new FlowArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.BOTTOM, 1.1, 2.2);
    assertFalse(f1.equals(f2));
    f2 = new FlowArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.BOTTOM, 1.1, 2.2);
    assertTrue(f1.equals(f2));

}
 
Example 11
Source File: JFreeChart.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a rectangle that is aligned to the frame.
 *
 * @param dimensions  the dimensions for the rectangle.
 * @param frame  the frame to align to.
 * @param hAlign  the horizontal alignment.
 * @param vAlign  the vertical alignment.
 *
 * @return A rectangle.
 */
private Rectangle2D createAlignedRectangle2D(Size2D dimensions,
        Rectangle2D frame, HorizontalAlignment hAlign,
        VerticalAlignment vAlign) {
    double x = Double.NaN;
    double y = Double.NaN;
    if (hAlign == HorizontalAlignment.LEFT) {
        x = frame.getX();
    }
    else if (hAlign == HorizontalAlignment.CENTER) {
        x = frame.getCenterX() - (dimensions.width / 2.0);
    }
    else if (hAlign == HorizontalAlignment.RIGHT) {
        x = frame.getMaxX() - dimensions.width;
    }
    if (vAlign == VerticalAlignment.TOP) {
        y = frame.getY();
    }
    else if (vAlign == VerticalAlignment.CENTER) {
        y = frame.getCenterY() - (dimensions.height / 2.0);
    }
    else if (vAlign == VerticalAlignment.BOTTOM) {
        y = frame.getMaxY() - dimensions.height;
    }

    return new Rectangle2D.Double(x, y, dimensions.width,
            dimensions.height);
}
 
Example 12
Source File: ColumnArrangement.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Arranges the blocks without any constraints.  This puts all blocks
 * into a single column.
 *
 * @param container  the container.
 * @param g2  the graphics device.
 *
 * @return The size after the arrangement.
 */
protected Size2D arrangeNN(BlockContainer container, Graphics2D g2) {
    double y = 0.0;
    double height = 0.0;
    double maxWidth = 0.0;
    List blocks = container.getBlocks();
    int blockCount = blocks.size();
    if (blockCount > 0) {
        Size2D[] sizes = new Size2D[blocks.size()];
        for (int i = 0; i < blocks.size(); i++) {
            Block block = (Block) blocks.get(i);
            sizes[i] = block.arrange(g2, RectangleConstraint.NONE);
            height = height + sizes[i].getHeight();
            maxWidth = Math.max(sizes[i].width, maxWidth);
            block.setBounds(
                new Rectangle2D.Double(
                    0.0, y, sizes[i].width, sizes[i].height
                )
            );
            y = y + sizes[i].height + this.verticalGap;
        }
        if (blockCount > 1) {
            height = height + this.verticalGap * (blockCount - 1);
        }
        if (this.horizontalAlignment != HorizontalAlignment.LEFT) {
            for (int i = 0; i < blocks.size(); i++) {
                //Block b = (Block) blocks.get(i);
                if (this.horizontalAlignment
                        == HorizontalAlignment.CENTER) {
                    //TODO: shift block right by half
                }
                else if (this.horizontalAlignment
                        == HorizontalAlignment.RIGHT) {
                    //TODO: shift block over to right
                }
            }
        }
    }
    return new Size2D(maxWidth, height);
}
 
Example 13
Source File: TextTitle.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Draws a the title horizontally within the specified area.  This method
 * will be called from the {@link #draw(Graphics2D, Rectangle2D) draw}
 * method.
 *
 * @param g2  the graphics device.
 * @param area  the area for the title.
 */
protected void drawHorizontal(Graphics2D g2, Rectangle2D area) {
    Rectangle2D titleArea = (Rectangle2D) area.clone();
    g2.setFont(this.font);
    g2.setPaint(this.paint);
    TextBlockAnchor anchor = null;
    float x = 0.0f;
    HorizontalAlignment horizontalAlignment = getHorizontalAlignment();
    if (horizontalAlignment == HorizontalAlignment.LEFT) {
        x = (float) titleArea.getX();
        anchor = TextBlockAnchor.TOP_LEFT;
    }
    else if (horizontalAlignment == HorizontalAlignment.RIGHT) {
        x = (float) titleArea.getMaxX();
        anchor = TextBlockAnchor.TOP_RIGHT;
    }
    else if (horizontalAlignment == HorizontalAlignment.CENTER) {
        x = (float) titleArea.getCenterX();
        anchor = TextBlockAnchor.TOP_CENTER;
    }
    float y = 0.0f;
    RectangleEdge position = getPosition();
    if (position == RectangleEdge.TOP) {
        y = (float) titleArea.getY();
    }
    else if (position == RectangleEdge.BOTTOM) {
        y = (float) titleArea.getMaxY();
        if (horizontalAlignment == HorizontalAlignment.LEFT) {
            anchor = TextBlockAnchor.BOTTOM_LEFT;
        }
        else if (horizontalAlignment == HorizontalAlignment.CENTER) {
            anchor = TextBlockAnchor.BOTTOM_CENTER;
        }
        else if (horizontalAlignment == HorizontalAlignment.RIGHT) {
            anchor = TextBlockAnchor.BOTTOM_RIGHT;
        }
    }
    this.content.draw(g2, x, y, anchor);
}
 
Example 14
Source File: FlowArrangementTest.java    From openstock 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() {
    FlowArrangement f1 = new FlowArrangement(HorizontalAlignment.LEFT,
            VerticalAlignment.TOP, 1.0, 2.0);
    FlowArrangement f2 = new FlowArrangement(HorizontalAlignment.LEFT,
            VerticalAlignment.TOP, 1.0, 2.0);
    assertTrue(f1.equals(f2));
    assertTrue(f2.equals(f1));

    f1 = new FlowArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.TOP, 1.0, 2.0);
    assertFalse(f1.equals(f2));
    f2 = new FlowArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.TOP, 1.0, 2.0);
    assertTrue(f1.equals(f2));

    f1 = new FlowArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.BOTTOM, 1.0, 2.0);
    assertFalse(f1.equals(f2));
    f2 = new FlowArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.BOTTOM, 1.0, 2.0);
    assertTrue(f1.equals(f2));

    f1 = new FlowArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.BOTTOM, 1.1, 2.0);
    assertFalse(f1.equals(f2));
    f2 = new FlowArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.BOTTOM, 1.1, 2.0);
    assertTrue(f1.equals(f2));

    f1 = new FlowArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.BOTTOM, 1.1, 2.2);
    assertFalse(f1.equals(f2));
    f2 = new FlowArrangement(HorizontalAlignment.RIGHT,
            VerticalAlignment.BOTTOM, 1.1, 2.2);
    assertTrue(f1.equals(f2));

}
 
Example 15
Source File: ImageTitle.java    From ccu-historian with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Draws the title on a Java 2D graphics device (such as the screen or a
 * printer).
 *
 * @param g2  the graphics device.
 * @param chartArea  the area within which the title (and plot) should be
 *                   drawn.
 *
 * @return The size of the area used by the title.
 */
protected Size2D drawHorizontal(Graphics2D g2, Rectangle2D chartArea) {
    double startY;
    double topSpace;
    double bottomSpace;
    double leftSpace;
    double rightSpace;

    double w = getWidth();
    double h = getHeight();
    RectangleInsets padding = getPadding();
    topSpace = padding.calculateTopOutset(h);
    bottomSpace = padding.calculateBottomOutset(h);
    leftSpace = padding.calculateLeftOutset(w);
    rightSpace = padding.calculateRightOutset(w);

    if (getPosition() == RectangleEdge.TOP) {
        startY = chartArea.getY() + topSpace;
    }
    else {
        startY = chartArea.getY() + chartArea.getHeight() - bottomSpace - h;
    }

    // what is our alignment?
    HorizontalAlignment horizontalAlignment = getHorizontalAlignment();
    double startX = 0.0;
    if (horizontalAlignment == HorizontalAlignment.CENTER) {
        startX = chartArea.getX() + leftSpace + chartArea.getWidth() / 2.0
                 - w / 2.0;
    }
    else if (horizontalAlignment == HorizontalAlignment.LEFT) {
        startX = chartArea.getX() + leftSpace;
    }
    else if (horizontalAlignment == HorizontalAlignment.RIGHT) {
        startX = chartArea.getX() + chartArea.getWidth() - rightSpace - w;
    }
    g2.drawImage(this.image, (int) startX, (int) startY, (int) w, (int) h,
            null);

    return new Size2D(chartArea.getWidth() + leftSpace + rightSpace,
        h + topSpace + bottomSpace);

}
 
Example 16
Source File: ImageTitle.java    From SIMVA-SoS with Apache License 2.0 4 votes vote down vote up
/**
 * Draws the title on a Java 2D graphics device (such as the screen or a
 * printer).
 *
 * @param g2  the graphics device.
 * @param chartArea  the area within which the title (and plot) should be
 *                   drawn.
 *
 * @return The size of the area used by the title.
 */
protected Size2D drawHorizontal(Graphics2D g2, Rectangle2D chartArea) {
    double startY;
    double topSpace;
    double bottomSpace;
    double leftSpace;
    double rightSpace;

    double w = getWidth();
    double h = getHeight();
    RectangleInsets padding = getPadding();
    topSpace = padding.calculateTopOutset(h);
    bottomSpace = padding.calculateBottomOutset(h);
    leftSpace = padding.calculateLeftOutset(w);
    rightSpace = padding.calculateRightOutset(w);

    if (getPosition() == RectangleEdge.TOP) {
        startY = chartArea.getY() + topSpace;
    }
    else {
        startY = chartArea.getY() + chartArea.getHeight() - bottomSpace - h;
    }

    // what is our alignment?
    HorizontalAlignment horizontalAlignment = getHorizontalAlignment();
    double startX = 0.0;
    if (horizontalAlignment == HorizontalAlignment.CENTER) {
        startX = chartArea.getX() + leftSpace + chartArea.getWidth() / 2.0
                 - w / 2.0;
    }
    else if (horizontalAlignment == HorizontalAlignment.LEFT) {
        startX = chartArea.getX() + leftSpace;
    }
    else if (horizontalAlignment == HorizontalAlignment.RIGHT) {
        startX = chartArea.getX() + chartArea.getWidth() - rightSpace - w;
    }
    g2.drawImage(this.image, (int) startX, (int) startY, (int) w, (int) h,
            null);

    return new Size2D(chartArea.getWidth() + leftSpace + rightSpace,
        h + topSpace + bottomSpace);

}
 
Example 17
Source File: ImageTitle.java    From openstock with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Draws the title on a Java 2D graphics device (such as the screen or a
 * printer).
 *
 * @param g2  the graphics device.
 * @param chartArea  the area within which the title (and plot) should be
 *                   drawn.
 *
 * @return The size of the area used by the title.
 */
protected Size2D drawHorizontal(Graphics2D g2, Rectangle2D chartArea) {
    double startY;
    double topSpace;
    double bottomSpace;
    double leftSpace;
    double rightSpace;

    double w = getWidth();
    double h = getHeight();
    RectangleInsets padding = getPadding();
    topSpace = padding.calculateTopOutset(h);
    bottomSpace = padding.calculateBottomOutset(h);
    leftSpace = padding.calculateLeftOutset(w);
    rightSpace = padding.calculateRightOutset(w);

    if (getPosition() == RectangleEdge.TOP) {
        startY = chartArea.getY() + topSpace;
    }
    else {
        startY = chartArea.getY() + chartArea.getHeight() - bottomSpace - h;
    }

    // what is our alignment?
    HorizontalAlignment horizontalAlignment = getHorizontalAlignment();
    double startX = 0.0;
    if (horizontalAlignment == HorizontalAlignment.CENTER) {
        startX = chartArea.getX() + leftSpace + chartArea.getWidth() / 2.0
                 - w / 2.0;
    }
    else if (horizontalAlignment == HorizontalAlignment.LEFT) {
        startX = chartArea.getX() + leftSpace;
    }
    else if (horizontalAlignment == HorizontalAlignment.RIGHT) {
        startX = chartArea.getX() + chartArea.getWidth() - rightSpace - w;
    }
    g2.drawImage(this.image, (int) startX, (int) startY, (int) w, (int) h,
            null);

    return new Size2D(chartArea.getWidth() + leftSpace + rightSpace,
        h + topSpace + bottomSpace);

}
 
Example 18
Source File: DateTitle.java    From SIMVA-SoS with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new chart title that displays the current date.
 * <p>
 * The date style should be one of:  {@code SHORT},
 * {@code MEDIUM}, {@code LONG} or {@code FULL} (defined
 * in {@code java.util.DateFormat}).
 * <P>
 * For the locale, you can use {@code Locale.getDefault()} for the
 * default locale.
 *
 * @param style  the date style.
 * @param locale  the locale.
 * @param font  the font.
 * @param paint  the text color.
 */
public DateTitle(int style, Locale locale, Font font, Paint paint) {
    this(style, locale, font, paint, RectangleEdge.BOTTOM,
            HorizontalAlignment.RIGHT, VerticalAlignment.CENTER,
            Title.DEFAULT_PADDING);
}
 
Example 19
Source File: DateTitle.java    From ccu-historian with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Creates a new chart title that displays the current date.
 * <p>
 * The date style should be one of:  {@code SHORT},
 * {@code MEDIUM}, {@code LONG} or {@code FULL} (defined
 * in {@code java.util.DateFormat}).
 * <P>
 * For the locale, you can use {@code Locale.getDefault()} for the
 * default locale.
 *
 * @param style  the date style.
 * @param locale  the locale.
 * @param font  the font.
 * @param paint  the text color.
 */
public DateTitle(int style, Locale locale, Font font, Paint paint) {
    this(style, locale, font, paint, RectangleEdge.BOTTOM,
            HorizontalAlignment.RIGHT, VerticalAlignment.CENTER,
            Title.DEFAULT_PADDING);
}
 
Example 20
Source File: DateTitle.java    From openstock with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Creates a new chart title that displays the current date.
 * <p>
 * The date style should be one of:  {@code SHORT},
 * {@code MEDIUM}, {@code LONG} or {@code FULL} (defined
 * in {@code java.util.DateFormat}).
 * <P>
 * For the locale, you can use {@code Locale.getDefault()} for the
 * default locale.
 *
 * @param style  the date style.
 * @param locale  the locale.
 * @param font  the font.
 * @param paint  the text color.
 */
public DateTitle(int style, Locale locale, Font font, Paint paint) {
    this(style, locale, font, paint, RectangleEdge.BOTTOM,
            HorizontalAlignment.RIGHT, VerticalAlignment.CENTER,
            Title.DEFAULT_PADDING);
}