本文整理匯總了Java中java.awt.geom.Rectangle2D.union方法的典型用法代碼示例。如果您正苦於以下問題:Java Rectangle2D.union方法的具體用法?Java Rectangle2D.union怎麽用?Java Rectangle2D.union使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.geom.Rectangle2D
的用法示例。
在下文中一共展示了Rectangle2D.union方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getVisualBounds
import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
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;
}
示例2: bounds
import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
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;
}
示例3: createUnion
import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
/**
* {@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;
}
示例4: updateCachedPreferredSize
import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
/**
* Taken from <code>com.jgraph.example.fastgraph.FastGraphUI</code>.
* Updates the <code>preferredSize</code> instance variable, which is
* returned from <code>getPreferredSize()</code>. Ignores edges for
* performance
*/
@Override
protected void updateCachedPreferredSize() {
CellView[] views = this.graphLayoutCache.getRoots();
Rectangle2D size = null;
if (views != null && views.length > 0) {
for (int i = 0; i < views.length; i++) {
if (views[i] != null && !(views[i] instanceof JEdgeView)) {
Rectangle2D r = views[i].getBounds();
if (r != null) {
if (size == null) {
size =
new Rectangle2D.Double(r.getX(), r.getY(),
r.getWidth(), r.getHeight());
} else {
Rectangle2D.union(size, r, size);
}
}
}
}
}
if (size == null) {
size = new Rectangle2D.Double();
}
Point2D psize =
new Point2D.Double(size.getX() + size.getWidth(), size.getY()
+ size.getHeight());
Dimension d = getJGraph().getMinimumSize();
Point2D min =
(d != null) ? getJGraph().toScreen(new Point(d.width, d.height))
: new Point(0, 0);
Point2D scaled = getJGraph().toScreen(psize);
this.preferredSize =
new Dimension((int) Math.max(min.getX(), scaled.getX()),
(int) Math.max(min.getY(), scaled.getY()));
Insets in = this.graph.getInsets();
if (in != null) {
this.preferredSize.setSize(this.preferredSize.getWidth() + in.left
+ in.right, this.preferredSize.getHeight() + in.top + in.bottom);
}
this.validCachedPreferredSize = true;
}