本文整理汇总了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;
}