Java Code Examples for org.jfree.ui.RectangleInsets#calculateRightOutset()

The following examples show how to use org.jfree.ui.RectangleInsets#calculateRightOutset() . 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: 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 2
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 drawVertical(Graphics2D g2, Rectangle2D chartArea) {

    double startX;
    double topSpace = 0.0;
    double bottomSpace = 0.0;
    double leftSpace = 0.0;
    double rightSpace = 0.0;

    double w = getWidth();
    double h = getHeight();

    RectangleInsets padding = getPadding();
    if (padding != null) {
        topSpace = padding.calculateTopOutset(h);
        bottomSpace = padding.calculateBottomOutset(h);
        leftSpace = padding.calculateLeftOutset(w);
        rightSpace = padding.calculateRightOutset(w);
    }

    if (getPosition() == RectangleEdge.LEFT) {
        startX = chartArea.getX() + leftSpace;
    }
    else {
        startX = chartArea.getMaxX() - rightSpace - w;
    }

    // what is our alignment?
    VerticalAlignment alignment = getVerticalAlignment();
    double startY = 0.0;
    if (alignment == VerticalAlignment.CENTER) {
        startY = chartArea.getMinY() + topSpace
                 + chartArea.getHeight() / 2.0 - h / 2.0;
    }
    else if (alignment == VerticalAlignment.TOP) {
        startY = chartArea.getMinY() + topSpace;
    }
    else if (alignment == VerticalAlignment.BOTTOM) {
        startY = chartArea.getMaxY() - bottomSpace - h;
    }

    g2.drawImage(this.image, (int) startX, (int) startY, (int) w, (int) h,
            null);

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

}
 
Example 3
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 4
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 drawVertical(Graphics2D g2, Rectangle2D chartArea) {

    double startX;
    double topSpace = 0.0;
    double bottomSpace = 0.0;
    double leftSpace = 0.0;
    double rightSpace = 0.0;

    double w = getWidth();
    double h = getHeight();

    RectangleInsets padding = getPadding();
    if (padding != null) {
        topSpace = padding.calculateTopOutset(h);
        bottomSpace = padding.calculateBottomOutset(h);
        leftSpace = padding.calculateLeftOutset(w);
        rightSpace = padding.calculateRightOutset(w);
    }

    if (getPosition() == RectangleEdge.LEFT) {
        startX = chartArea.getX() + leftSpace;
    }
    else {
        startX = chartArea.getMaxX() - rightSpace - w;
    }

    // what is our alignment?
    VerticalAlignment alignment = getVerticalAlignment();
    double startY = 0.0;
    if (alignment == VerticalAlignment.CENTER) {
        startY = chartArea.getMinY() + topSpace
                 + chartArea.getHeight() / 2.0 - h / 2.0;
    }
    else if (alignment == VerticalAlignment.TOP) {
        startY = chartArea.getMinY() + topSpace;
    }
    else if (alignment == VerticalAlignment.BOTTOM) {
        startY = chartArea.getMaxY() - bottomSpace - h;
    }

    g2.drawImage(this.image, (int) startX, (int) startY, (int) w, (int) h,
            null);

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

}
 
Example 5
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 6
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 drawVertical(Graphics2D g2, Rectangle2D chartArea) {

    double startX;
    double topSpace = 0.0;
    double bottomSpace = 0.0;
    double leftSpace = 0.0;
    double rightSpace = 0.0;

    double w = getWidth();
    double h = getHeight();

    RectangleInsets padding = getPadding();
    if (padding != null) {
        topSpace = padding.calculateTopOutset(h);
        bottomSpace = padding.calculateBottomOutset(h);
        leftSpace = padding.calculateLeftOutset(w);
        rightSpace = padding.calculateRightOutset(w);
    }

    if (getPosition() == RectangleEdge.LEFT) {
        startX = chartArea.getX() + leftSpace;
    }
    else {
        startX = chartArea.getMaxX() - rightSpace - w;
    }

    // what is our alignment?
    VerticalAlignment alignment = getVerticalAlignment();
    double startY = 0.0;
    if (alignment == VerticalAlignment.CENTER) {
        startY = chartArea.getMinY() + topSpace
                 + chartArea.getHeight() / 2.0 - h / 2.0;
    }
    else if (alignment == VerticalAlignment.TOP) {
        startY = chartArea.getMinY() + topSpace;
    }
    else if (alignment == VerticalAlignment.BOTTOM) {
        startY = chartArea.getMaxY() - bottomSpace - h;
    }

    g2.drawImage(this.image, (int) startX, (int) startY, (int) w, (int) h,
            null);

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

}
 
Example 7
Source File: ImageTitle.java    From ECG-Viewer with GNU General Public License v2.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 8
Source File: ImageTitle.java    From ECG-Viewer with GNU General Public License v2.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 drawVertical(Graphics2D g2, Rectangle2D chartArea) {

    double startX;
    double topSpace = 0.0;
    double bottomSpace = 0.0;
    double leftSpace = 0.0;
    double rightSpace = 0.0;

    double w = getWidth();
    double h = getHeight();

    RectangleInsets padding = getPadding();
    if (padding != null) {
        topSpace = padding.calculateTopOutset(h);
        bottomSpace = padding.calculateBottomOutset(h);
        leftSpace = padding.calculateLeftOutset(w);
        rightSpace = padding.calculateRightOutset(w);
    }

    if (getPosition() == RectangleEdge.LEFT) {
        startX = chartArea.getX() + leftSpace;
    }
    else {
        startX = chartArea.getMaxX() - rightSpace - w;
    }

    // what is our alignment?
    VerticalAlignment alignment = getVerticalAlignment();
    double startY = 0.0;
    if (alignment == VerticalAlignment.CENTER) {
        startY = chartArea.getMinY() + topSpace
                 + chartArea.getHeight() / 2.0 - h / 2.0;
    }
    else if (alignment == VerticalAlignment.TOP) {
        startY = chartArea.getMinY() + topSpace;
    }
    else if (alignment == VerticalAlignment.BOTTOM) {
        startY = chartArea.getMaxY() - bottomSpace - h;
    }

    g2.drawImage(this.image, (int) startX, (int) startY, (int) w, (int) h,
            null);

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

}
 
Example 9
Source File: ImageTitle.java    From opensim-gui 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 = 0.0;
    double topSpace = 0.0;
    double bottomSpace = 0.0;
    double leftSpace = 0.0;
    double rightSpace = 0.0;

    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 10
Source File: ImageTitle.java    From opensim-gui 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 drawVertical(Graphics2D g2, Rectangle2D chartArea) {

    double startX = 0.0;
    double topSpace = 0.0;
    double bottomSpace = 0.0;
    double leftSpace = 0.0;
    double rightSpace = 0.0;

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

    if (getPosition() == RectangleEdge.LEFT) {
        startX = chartArea.getX() + leftSpace;
    }
    else {
        startX = chartArea.getMaxX() - rightSpace - w;
    }

    // what is our alignment?
    VerticalAlignment alignment = getVerticalAlignment();
    double startY = 0.0;
    if (alignment == VerticalAlignment.CENTER) {
        startY = chartArea.getMinY() + topSpace 
                 + chartArea.getHeight() / 2.0 - h / 2.0;
    }
    else if (alignment == VerticalAlignment.TOP) {
        startY = chartArea.getMinY() + topSpace;
    }
    else if (alignment == VerticalAlignment.BOTTOM) {
        startY = chartArea.getMaxY() - bottomSpace - h;
    }

    g2.drawImage(this.image, (int) startX, (int) startY, (int) w, (int) h, 
            null);

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

}
 
Example 11
Source File: ImageTitle.java    From buffer_bci 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 12
Source File: ImageTitle.java    From buffer_bci 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 drawVertical(Graphics2D g2, Rectangle2D chartArea) {

    double startX;
    double topSpace = 0.0;
    double bottomSpace = 0.0;
    double leftSpace = 0.0;
    double rightSpace = 0.0;

    double w = getWidth();
    double h = getHeight();

    RectangleInsets padding = getPadding();
    if (padding != null) {
        topSpace = padding.calculateTopOutset(h);
        bottomSpace = padding.calculateBottomOutset(h);
        leftSpace = padding.calculateLeftOutset(w);
        rightSpace = padding.calculateRightOutset(w);
    }

    if (getPosition() == RectangleEdge.LEFT) {
        startX = chartArea.getX() + leftSpace;
    }
    else {
        startX = chartArea.getMaxX() - rightSpace - w;
    }

    // what is our alignment?
    VerticalAlignment alignment = getVerticalAlignment();
    double startY = 0.0;
    if (alignment == VerticalAlignment.CENTER) {
        startY = chartArea.getMinY() + topSpace
                 + chartArea.getHeight() / 2.0 - h / 2.0;
    }
    else if (alignment == VerticalAlignment.TOP) {
        startY = chartArea.getMinY() + topSpace;
    }
    else if (alignment == VerticalAlignment.BOTTOM) {
        startY = chartArea.getMaxY() - bottomSpace - h;
    }

    g2.drawImage(this.image, (int) startX, (int) startY, (int) w, (int) h,
            null);

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

}
 
Example 13
Source File: ImageTitle.java    From buffer_bci 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 14
Source File: ImageTitle.java    From buffer_bci 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 drawVertical(Graphics2D g2, Rectangle2D chartArea) {

    double startX;
    double topSpace = 0.0;
    double bottomSpace = 0.0;
    double leftSpace = 0.0;
    double rightSpace = 0.0;

    double w = getWidth();
    double h = getHeight();

    RectangleInsets padding = getPadding();
    if (padding != null) {
        topSpace = padding.calculateTopOutset(h);
        bottomSpace = padding.calculateBottomOutset(h);
        leftSpace = padding.calculateLeftOutset(w);
        rightSpace = padding.calculateRightOutset(w);
    }

    if (getPosition() == RectangleEdge.LEFT) {
        startX = chartArea.getX() + leftSpace;
    }
    else {
        startX = chartArea.getMaxX() - rightSpace - w;
    }

    // what is our alignment?
    VerticalAlignment alignment = getVerticalAlignment();
    double startY = 0.0;
    if (alignment == VerticalAlignment.CENTER) {
        startY = chartArea.getMinY() + topSpace
                 + chartArea.getHeight() / 2.0 - h / 2.0;
    }
    else if (alignment == VerticalAlignment.TOP) {
        startY = chartArea.getMinY() + topSpace;
    }
    else if (alignment == VerticalAlignment.BOTTOM) {
        startY = chartArea.getMaxY() - bottomSpace - h;
    }

    g2.drawImage(this.image, (int) startX, (int) startY, (int) w, (int) h,
            null);

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

}