Java Code Examples for java.awt.geom.Rectangle2D#union()

The following examples show how to use java.awt.geom.Rectangle2D#union() . 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: StandardGlyphVector.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public Rectangle2D getVisualBounds() {
    Rectangle2D result = null;
    for (int i = 0; i < glyphs.length; ++i) {
        Rectangle2D glyphVB = getGlyphVisualBounds(i).getBounds2D();
        if (!glyphVB.isEmpty()) {
            if (result == null) {
                result = glyphVB;
            } else {
                Rectangle2D.union(result, glyphVB, result);
            }
        }
    }
    if (result == null) {
        result = new Rectangle2D.Float(0, 0, 0, 0);
    }
    return result;
}
 
Example 2
Source File: StandardGlyphVector.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public Rectangle2D getVisualBounds() {
    Rectangle2D result = null;
    for (int i = 0; i < glyphs.length; ++i) {
        Rectangle2D glyphVB = getGlyphVisualBounds(i).getBounds2D();
        if (!glyphVB.isEmpty()) {
            if (result == null) {
                result = glyphVB;
            } else {
                Rectangle2D.union(result, glyphVB, result);
            }
        }
    }
    if (result == null) {
        result = new Rectangle2D.Float(0, 0, 0, 0);
    }
    return result;
}
 
Example 3
Source File: StandardGlyphVector.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public Rectangle2D getVisualBounds() {
    Rectangle2D result = null;
    for (int i = 0; i < glyphs.length; ++i) {
        Rectangle2D glyphVB = getGlyphVisualBounds(i).getBounds2D();
        if (!glyphVB.isEmpty()) {
            if (result == null) {
                result = glyphVB;
            } else {
                Rectangle2D.union(result, glyphVB, result);
            }
        }
    }
    if (result == null) {
        result = new Rectangle2D.Float(0, 0, 0, 0);
    }
    return result;
}
 
Example 4
Source File: Utils.java    From tabula-java with MIT License 6 votes vote down vote up
public static Rectangle bounds(Collection<? extends Shape> shapes) {
    if (shapes.isEmpty()) {
        throw new IllegalArgumentException("shapes can't be empty");
    }

    Iterator<? extends Shape> iter = shapes.iterator();
    Rectangle rv = new Rectangle();
    rv.setRect(iter.next().getBounds2D());

    while (iter.hasNext()) {
        Rectangle2D.union(iter.next().getBounds2D(), rv, rv);
    }

    return rv;

}
 
Example 5
Source File: StandardGlyphVector.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public Rectangle2D getVisualBounds() {
    Rectangle2D result = null;
    for (int i = 0; i < glyphs.length; ++i) {
        Rectangle2D glyphVB = getGlyphVisualBounds(i).getBounds2D();
        if (!glyphVB.isEmpty()) {
            if (result == null) {
                result = glyphVB;
            } else {
                Rectangle2D.union(result, glyphVB, result);
            }
        }
    }
    if (result == null) {
        result = new Rectangle2D.Float(0, 0, 0, 0);
    }
    return result;
}
 
Example 6
Source File: StandardGlyphVector.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public Rectangle2D getVisualBounds() {
    Rectangle2D result = null;
    for (int i = 0; i < glyphs.length; ++i) {
        Rectangle2D glyphVB = getGlyphVisualBounds(i).getBounds2D();
        if (!glyphVB.isEmpty()) {
            if (result == null) {
                result = glyphVB;
            } else {
                Rectangle2D.union(result, glyphVB, result);
            }
        }
    }
    if (result == null) {
        result = new Rectangle2D.Float(0, 0, 0, 0);
    }
    return result;
}
 
Example 7
Source File: StandardGlyphVector.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
public Rectangle2D getVisualBounds() {
    Rectangle2D result = null;
    for (int i = 0; i < glyphs.length; ++i) {
        Rectangle2D glyphVB = getGlyphVisualBounds(i).getBounds2D();
        if (!glyphVB.isEmpty()) {
            if (result == null) {
                result = glyphVB;
            } else {
                Rectangle2D.union(result, glyphVB, result);
            }
        }
    }
    if (result == null) {
        result = new Rectangle2D.Float(0, 0, 0, 0);
    }
    return result;
}
 
Example 8
Source File: Rectangle.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * @since 1.2
 */
public Rectangle2D createUnion(Rectangle2D r) {
    if (r instanceof Rectangle) {
        return union((Rectangle) r);
    }
    Rectangle2D dest = new Rectangle2D.Double();
    Rectangle2D.union(this, r, dest);
    return dest;
}
 
Example 9
Source File: Rectangle.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * @since 1.2
 */
public Rectangle2D createUnion(Rectangle2D r) {
    if (r instanceof Rectangle) {
        return union((Rectangle) r);
    }
    Rectangle2D dest = new Rectangle2D.Double();
    Rectangle2D.union(this, r, dest);
    return dest;
}
 
Example 10
Source File: Rectangle.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * @since 1.2
 */
public Rectangle2D createUnion(Rectangle2D r) {
    if (r instanceof Rectangle) {
        return union((Rectangle) r);
    }
    Rectangle2D dest = new Rectangle2D.Double();
    Rectangle2D.union(this, r, dest);
    return dest;
}
 
Example 11
Source File: ScreenshotUtil.java    From haxademic with MIT License 5 votes vote down vote up
public static Rectangle2D getFullScreenBounds() {
	// NOTE! main monitor must be top left, otherwise, override x+y position  
	Rectangle2D result = new Rectangle2D.Double();
	GraphicsEnvironment localGE = GraphicsEnvironment.getLocalGraphicsEnvironment();
	for (GraphicsDevice gd : localGE.getScreenDevices()) {
		for (GraphicsConfiguration graphicsConfiguration : gd.getConfigurations()) {
			Rectangle2D.union(result, graphicsConfiguration.getBounds(), result);
		}
	}
	return result;
}
 
Example 12
Source File: Rectangle.java    From jdk-1.7-annotated with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * @since 1.2
 */
public Rectangle2D createUnion(Rectangle2D r) {
    if (r instanceof Rectangle) {
        return union((Rectangle) r);
    }
    Rectangle2D dest = new Rectangle2D.Double();
    Rectangle2D.union(this, r, dest);
    return dest;
}
 
Example 13
Source File: Rectangle.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * @since 1.2
 */
public Rectangle2D createUnion(Rectangle2D r) {
    if (r instanceof Rectangle) {
        return union((Rectangle) r);
    }
    Rectangle2D dest = new Rectangle2D.Double();
    Rectangle2D.union(this, r, dest);
    return dest;
}
 
Example 14
Source File: ScreenUtilities.java    From Dayon with GNU General Public License v3.0 5 votes vote down vote up
private static Rectangle getCombinedScreenSize() {
    Rectangle fullSize = new Rectangle();
    GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
    for (GraphicsDevice gd : environment.getScreenDevices()) {
        for (GraphicsConfiguration graphicsConfiguration : gd.getConfigurations()) {
            Rectangle2D.union(fullSize, graphicsConfiguration.getBounds(), fullSize);
        }
    }
    return fullSize.getBounds();
}
 
Example 15
Source File: Rectangle.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * @since 1.2
 */
public Rectangle2D createUnion(Rectangle2D r) {
    if (r instanceof Rectangle) {
        return union((Rectangle) r);
    }
    Rectangle2D dest = new Rectangle2D.Double();
    Rectangle2D.union(this, r, dest);
    return dest;
}
 
Example 16
Source File: Rectangle.java    From HtmlUnit-Android with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * @since 1.2
 */
public Rectangle2D createUnion(Rectangle2D r) {
    if (r instanceof Rectangle) {
        return union((Rectangle) r);
    }
    Rectangle2D dest = new Rectangle2D.Double();
    Rectangle2D.union(this, r, dest);
    return dest;
}
 
Example 17
Source File: Rectangle.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * @since 1.2
 */
public Rectangle2D createUnion(Rectangle2D r) {
    if (r instanceof Rectangle) {
        return union((Rectangle) r);
    }
    Rectangle2D dest = new Rectangle2D.Double();
    Rectangle2D.union(this, r, dest);
    return dest;
}
 
Example 18
Source File: Rectangle.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 * @since 1.2
 */
public Rectangle2D createUnion(Rectangle2D r) {
    if (r instanceof Rectangle) {
        return union((Rectangle) r);
    }
    Rectangle2D dest = new Rectangle2D.Double();
    Rectangle2D.union(this, r, dest);
    return dest;
}
 
Example 19
Source File: Rectangle.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * @since 1.2
 */
public Rectangle2D createUnion(Rectangle2D r) {
    if (r instanceof Rectangle) {
        return union((Rectangle) r);
    }
    Rectangle2D dest = new Rectangle2D.Double();
    Rectangle2D.union(this, r, dest);
    return dest;
}
 
Example 20
Source File: SlantedSymbol.java    From audiveris with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected MyParams getParams (MusicFont font)
{
    MyParams p = new MyParams();

    p.layouts = new SmartLayout[codes.length];

    // Union of all rectangles
    Rectangle2D rect = null;

    // Current abscissa
    float x = 0;

    for (int i = 0; i < codes.length; i++) {
        int code = codes[i];
        TextLayout layout = font.layout(code);
        Rectangle2D r = layout.getBounds();

        // Abscissa reduction because of slanted characters
        // Its value depends on whether we have a 'f' or not
        float dx;
        int c = code - MusicFont.CODE_OFFSET;

        if ((c == 102) || // F
                (c == 196) || // FF
                (c == 236) || // FFF
                (c == 83) || // SF
                (c == 90)) { // FZ
            dx = (float) r.getHeight() * 0.215f; // Measured
        } else {
            dx = (float) r.getHeight() * 0.075f; // Measured
        }

        p.layouts[i] = new SmartLayout(layout, dx);

        if (i > 0) {
            x -= dx;
        }

        if (i == 0) {
            rect = layout.getPixelBounds(null, x, 0);
        } else {
            Rectangle2D.union(rect, layout.getPixelBounds(null, x, 0), rect);
        }

        x += (r.getWidth() - dx);
    }

    p.rect = new Rectangle(
            (int) Math.floor(rect.getX()),
            (int) Math.floor(rect.getY()),
            (int) Math.ceil(rect.getWidth()),
            (int) Math.ceil(rect.getHeight()));

    return p;
}