本文整理匯總了Java中java.awt.geom.Rectangle2D.setFrameFromDiagonal方法的典型用法代碼示例。如果您正苦於以下問題:Java Rectangle2D.setFrameFromDiagonal方法的具體用法?Java Rectangle2D.setFrameFromDiagonal怎麽用?Java Rectangle2D.setFrameFromDiagonal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.geom.Rectangle2D
的用法示例。
在下文中一共展示了Rectangle2D.setFrameFromDiagonal方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: pickContainedVertices
import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
/**
* pick the vertices inside the rectangle created from points
* 'down' and 'out'
*/
protected void pickContainedVertices( VisualizationViewer<Room, Exit> vv, Point2D down, Point2D out, boolean clear ) {
Layout<Room, Exit> layout = vv.getGraphLayout();
PickedState<Room> pickedVertexState = vv.getPickedVertexState();
Rectangle2D pickRectangle = new Rectangle2D.Double();
pickRectangle.setFrameFromDiagonal( down, out );
if (pickedVertexState != null) {
if (clear) {
pickedVertexState.clear();
}
GraphElementAccessor<Room, Exit> pickSupport = vv.getPickSupport();
Collection<Room> picked = pickSupport.getVertices( layout, pickRectangle );
for (Room v : picked) {
pickedVertexState.pick( v, true );
}
}
}
示例2: intersectRectShape
import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
Shape intersectRectShape(Rectangle2D r, Shape s,
boolean keep1, boolean keep2) {
if (s instanceof Rectangle2D) {
Rectangle2D r2 = (Rectangle2D) s;
Rectangle2D outrect;
if (!keep1) {
outrect = r;
} else if (!keep2) {
outrect = r2;
} else {
outrect = new Rectangle2D.Float();
}
double x1 = Math.max(r.getX(), r2.getX());
double x2 = Math.min(r.getX() + r.getWidth(),
r2.getX() + r2.getWidth());
double y1 = Math.max(r.getY(), r2.getY());
double y2 = Math.min(r.getY() + r.getHeight(),
r2.getY() + r2.getHeight());
if (((x2 - x1) < 0) || ((y2 - y1) < 0))
// Width or height is negative. No intersection.
outrect.setFrameFromDiagonal(0, 0, 0, 0);
else
outrect.setFrameFromDiagonal(x1, y1, x2, y2);
return outrect;
}
if (r.contains(s.getBounds2D())) {
if (keep2) {
s = cloneShape(s);
}
return s;
}
return intersectByArea(r, s, keep1, keep2);
}