本文整理汇总了Java中edu.umd.cs.piccolo.util.PBounds.add方法的典型用法代码示例。如果您正苦于以下问题:Java PBounds.add方法的具体用法?Java PBounds.add怎么用?Java PBounds.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.umd.cs.piccolo.util.PBounds
的用法示例。
在下文中一共展示了PBounds.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: stackableNodeDropped
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
public void stackableNodeDropped( final StackableNode stackableNode ) {
PBounds bounds = skateboard.getGlobalFullBounds();
bounds.add( skateboard.getGlobalFullBounds().getCenterX(), rootNode.globalToLocal( new Point2D.Double( STAGE_SIZE.width / 2, 0 ) ).getY() );
if ( stackableNode.getGlobalFullBounds().getMinY() < skateboard.getGlobalFullBounds().getMaxY() &&
//Limit stack size to 3 things
stack.get().length() < 3 ) {
stackableNode.onSkateboard.set( true );
stack.set( stack.get().snoc( stackableNode ) );
normalizeStack();
}
else {
stackableNode.animateHome();
}
dragging.set( false );
}
示例2: updateMarquee
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/** {@inheritDoc} */
protected void updateMarquee(final PInputEvent pie) {
super.updateMarquee(pie);
final PBounds b = new PBounds();
if (marqueeParent instanceof PCamera) {
b.add(canvasPressPt);
b.add(pie.getCanvasPosition());
}
else {
b.add(pressPt);
b.add(pie.getPosition());
}
marquee.setPathToRectangle((float) b.x, (float) b.y, (float) b.width, (float) b.height);
b.reset();
b.add(pressPt);
b.add(pie.getPosition());
}
示例3: getViewPosition
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
* Get the View position given the specified camera bounds.
*
* @param viewBounds The bounds for which the view position will be computed
* @return The view position
*/
public Point getViewPosition(final Rectangle2D viewBounds) {
final Point pos = new Point();
if (camera != null) {
// First we compute the union of all the layers
final PBounds layerBounds = new PBounds();
final List layers = camera.getLayersReference();
for (final Iterator i = layers.iterator(); i.hasNext();) {
final PLayer layer = (PLayer) i.next();
layerBounds.add(layer.getFullBoundsReference());
}
// Then we put the bounds into camera coordinates and
// union the camera bounds
camera.viewToLocal(layerBounds);
layerBounds.add(viewBounds);
pos.setLocation((int) (viewBounds.getX() - layerBounds.getX() + 0.5), (int) (viewBounds.getY()
- layerBounds.getY() + 0.5));
}
return pos;
}
示例4: getViewSize
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
* Get the size of the view based on the specified camera bounds.
*
* @param viewBounds The view bounds for which the view size will be
* computed
* @return The view size
*/
public Dimension getViewSize(final Rectangle2D viewBounds) {
final Dimension size = new Dimension();
if (camera != null) {
// First we compute the union of all the layers
final PBounds bounds = new PBounds();
final List layers = camera.getLayersReference();
for (final Iterator i = layers.iterator(); i.hasNext();) {
final PLayer layer = (PLayer) i.next();
bounds.add(layer.getFullBoundsReference());
}
// Then we put the bounds into camera coordinates and
// union the camera bounds
if (!bounds.isEmpty()) {
camera.viewToLocal(bounds);
}
bounds.add(viewBounds);
size.setSize((int) (bounds.getWidth() + 0.5), (int) (bounds.getHeight() + 0.5));
}
return size;
}
示例5: getLayoutBounds
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
public PBounds getLayoutBounds() {
PBounds bounds = null;
for ( LayoutElement element : elements ) {
if ( bounds == null ) {
bounds = element.getLayoutBounds();
}
else {
bounds.add( element.getLayoutBounds() );
}
}
return bounds;
}
示例6: getPositionBounds
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
* @return Where the molecule is right now
*/
public PBounds getPositionBounds() {
PBounds bounds = null;
for ( Atom2D atom : getAtoms() ) {
PBounds atomBounds = atom.getPositionBounds();
if ( bounds == null ) {
bounds = atomBounds;
}
else {
bounds.add( atomBounds );
}
}
return bounds;
}
示例7: getDestinationBounds
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
* @return Where the molecule will end up
*/
public PBounds getDestinationBounds() {
PBounds bounds = null;
for ( Atom2D atom : getAtoms() ) {
PBounds atomBounds = atom.getDestinationBounds();
if ( bounds == null ) {
bounds = atomBounds;
}
else {
bounds.add( atomBounds );
}
}
return bounds;
}
示例8: getViewPosition
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
* Get the View position given the specified camera bounds - modified
* such that:
*
* Rather than finding the distance from the upper left corner of the
* window to the upper left corner of the document - we instead find the
* distance from the lower right corner of the window to the upper left
* corner of the document THEN we subtract that value from total
* document width so that the position is inverted
*
* @param viewBounds The bounds for which the view position will be
* computed
* @return The view position
*/
public Point getViewPosition(final Rectangle2D viewBounds) {
final Point pos = new Point();
if (camera != null) {
// First we compute the union of all the layers
final PBounds layerBounds = new PBounds();
final java.util.List layers = camera.getLayersReference();
for (final Iterator i = layers.iterator(); i.hasNext();) {
final PLayer layer = (PLayer) i.next();
layerBounds.add(layer.getFullBoundsReference());
}
// Then we put the bounds into camera coordinates and
// union the camera bounds
camera.viewToLocal(layerBounds);
layerBounds.add(viewBounds);
// Rather than finding the distance from the upper left corner
// of the window to the upper left corner of the document -
// we instead find the distance from the lower right corner
// of the window to the upper left corner of the document
// THEN we measure the offset from the lower right corner
// of the document
pos.setLocation((int) (layerBounds.getWidth()
- (viewBounds.getX() + viewBounds.getWidth() - layerBounds.getX()) + 0.5), (int) (layerBounds
.getHeight()
- (viewBounds.getY() + viewBounds.getHeight() - layerBounds.getY()) + 0.5));
}
return pos;
}
示例9: getViewPosition
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
* Get the View position given the specified camera bounds - modified
* such that:
*
* Rather than finding the distance from the upper left corner of the
* window to the upper left corner of the document - we instead find the
* distance from the lower right corner of the window to the upper left
* corner of the document THEN we subtract that value from total
* document width so that the position is inverted
*
* @param viewBounds The bounds for which the view position will be
* computed
* @return The view position
*/
public Point getViewPosition(final Rectangle2D viewBounds) {
final Point pos = new Point();
if (camera == null)
return pos;
// First we compute the union of all the layers
final PBounds layerBounds = new PBounds();
final java.util.List layers = camera.getLayersReference();
for (final Iterator i = layers.iterator(); i.hasNext();) {
final PLayer layer = (PLayer) i.next();
layerBounds.add(layer.getFullBoundsReference());
}
// Then we put the bounds into camera coordinates and
// union the camera bounds
camera.viewToLocal(layerBounds);
layerBounds.add(viewBounds);
// Rather than finding the distance from the upper left corner
// of the window to the upper left corner of the document -
// we instead find the distance from the lower right corner
// of the window to the upper left corner of the document
// THEN we measure the offset from the lower right corner
// of the document
pos.setLocation((int) (layerBounds.getWidth()
- (viewBounds.getX() + viewBounds.getWidth() - layerBounds.getX()) + 0.5), (int) (layerBounds
.getHeight()
- (viewBounds.getY() + viewBounds.getHeight() - layerBounds.getY()) + 0.5));
return pos;
}
示例10: shouldRevalidateScrollPane
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
* Should the ScrollPane be revalidated. This occurs when either the scroll
* bars are showing and should be remove or are not showing and should be
* added.
*
* @return Whether the scroll pane should be revalidated
*/
public boolean shouldRevalidateScrollPane() {
if (camera != null) {
if (scrollPane.getHorizontalScrollBarPolicy() != ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED
&& scrollPane.getVerticalScrollBarPolicy() != ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED) {
return false;
}
// Get the union of all the layers' bounds
final PBounds layerBounds = new PBounds();
final List layers = camera.getLayersReference();
for (final Iterator i = layers.iterator(); i.hasNext();) {
final PLayer layer = (PLayer) i.next();
layerBounds.add(layer.getFullBoundsReference());
}
// Put into camera coordinates
camera.viewToLocal(layerBounds);
// And union with the camera bounds
final PBounds cameraBounds = camera.getBoundsReference();
layerBounds.add(cameraBounds);
// Truncate these to ints before comparing since
// that's what the ScrollPane uses
final int layerWidth = (int) (layerBounds.getWidth() + 0.5);
final int layerHeight = (int) (layerBounds.getHeight() + 0.5);
final int cameraWidth = (int) (cameraBounds.getWidth() + 0.5);
final int cameraHeight = (int) (cameraBounds.getHeight() + 0.5);
if (scrollPane.getHorizontalScrollBar().isShowing() && layerWidth <= cameraWidth
|| !scrollPane.getHorizontalScrollBar().isShowing() && layerWidth > cameraWidth
|| scrollPane.getVerticalScrollBar().isShowing() && layerHeight <= cameraHeight
|| !scrollPane.getVerticalScrollBar().isShowing() && layerHeight > cameraHeight) {
return true;
}
}
return false;
}
示例11: getUnionOfLayerFullBounds
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
* Return the union of the full bounds of each layer in the list of layers
* viewed by this camera, or empty bounds if the list of layers viewed by
* this camera is empty.
*
* @return the union of the full bounds of each layer in the list of layers
* viewed by this camera, or empty bounds if the list of layers viewed
* by this camera is empty
*/
public PBounds getUnionOfLayerFullBounds() {
final PBounds result = new PBounds();
final int size = layers.size();
for (int i = 0; i < size; i++) {
final PLayer each = (PLayer) layers.get(i);
result.add(each.getFullBoundsReference());
}
return result;
}
示例12: costOfNoBoundsCache
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
public void costOfNoBoundsCache() {
final PNode[] nodes = new PNode[NUMBER_NODES];
final PBounds[] bounds = new PBounds[NUMBER_NODES];
final PBounds pickRect = new PBounds(0, 0, 1, 1);
final Random r = new Random();
for (int i = 0; i < NUMBER_NODES; i++) {
nodes[i] = new PNode();
nodes[i].translate(1000 * r.nextFloat(), 1000 * r.nextFloat());
nodes[i].scale(1000 * r.nextFloat());
bounds[i] = new PBounds(1000 * r.nextFloat(), 1000 * r.nextFloat(), 100, 80);
}
log.startTest();
for (int i = 0; i < NUMBER_NODES; i++) {
bounds[i].intersects(pickRect);
}
log.endTest("Do intersects test for " + NUMBER_NODES + " bounds");
log.startTest();
for (int i = 0; i < NUMBER_NODES; i++) {
nodes[i].localToParent(bounds[i]);
}
log.endTest("Transform " + NUMBER_NODES + " bounds from local to parent");
log.startTest();
for (int i = 0; i < NUMBER_NODES; i++) {
pickRect.add(bounds[i]);
}
log.endTest("Sum " + NUMBER_NODES + " bounds");
final PBounds b = new PBounds(r.nextDouble(), r.nextDouble(), r.nextDouble(), r.nextDouble());
log.startTest();
for (int i = 0; i < NUMBER_NODES * 10; i++) {
b.clone();
}
log.endTest("Clone " + NUMBER_NODES * 10 + " PBounds");
}
示例13: setViewPosition
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
* We do the same thing we did in getViewPosition above to flip the
* document-window position relationship
*
* @param x The new x position
* @param y The new y position
*/
public void setViewPosition(final double x, final double y) {
if (camera == null)
return;
// If a scroll is in progress - we ignore new scrolls - if we
// didn't, since the scrollbars depend on the camera location
// we can end up with an infinite loop
if (scrollInProgress)
return;
scrollInProgress = true;
// Get the union of all the layers' bounds
final PBounds layerBounds = new PBounds();
final List layers = camera.getLayersReference();
for (final Iterator i = layers.iterator(); i.hasNext();) {
final PLayer layer = (PLayer) i.next();
layerBounds.add(layer.getFullBoundsReference());
}
final PAffineTransform at = camera.getViewTransform();
at.transform(layerBounds, layerBounds);
// Union the camera view bounds
final PBounds viewBounds = camera.getBoundsReference();
layerBounds.add(viewBounds);
// Now find the new view position in view coordinates -
// This is basically the distance from the lower right
// corner of the window to the upper left corner of the
// document
// We then measure the offset from the lower right corner
// of the document
final Point2D newPoint = new Point2D.Double(layerBounds.getX() + layerBounds.getWidth()
- (x + viewBounds.getWidth()), layerBounds.getY() + layerBounds.getHeight()
- (y + viewBounds.getHeight()));
// Now transform the new view position into global coords
camera.localToView(newPoint);
// Compute the new matrix values to put the camera at the
// correct location
final double newX = -(at.getScaleX() * newPoint.getX() + at.getShearX() * newPoint.getY());
final double newY = -(at.getShearY() * newPoint.getX() + at.getScaleY() * newPoint.getY());
at.setTransform(at.getScaleX(), at.getShearY(), at.getShearX(), at.getScaleY(), newX, newY);
// Now actually set the camera's transform
camera.setViewTransform(at);
scrollInProgress = false;
}
示例14: setViewPosition
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
* We do the same thing we did in getViewPosition above to flip the
* document-window position relationship
*
* @param x The new x position
* @param y The new y position
*/
public void setViewPosition(final double x, final double y) {
if (camera == null)
return;
// If a scroll is in progress - we ignore new scrolls - if we
// didn't, since the scrollbars depend on the camera
// location we can end up with an infinite loop
if (scrollInProgress)
return;
scrollInProgress = true;
// Get the union of all the layers' bounds
final PBounds layerBounds = new PBounds();
final java.util.List layers = camera.getLayersReference();
for (final Iterator i = layers.iterator(); i.hasNext();) {
final PLayer layer = (PLayer) i.next();
layerBounds.add(layer.getFullBoundsReference());
}
final PAffineTransform at = camera.getViewTransform();
at.transform(layerBounds, layerBounds);
// Union the camera view bounds
final PBounds viewBounds = camera.getBoundsReference();
layerBounds.add(viewBounds);
// Now find the new view position in view coordinates -
// This is basically the distance from the lower right
// corner of the window to the upper left corner of the
// document. We then measure the offset from the lower right corner
// of the document
final Point2D newPoint = new Point2D.Double(layerBounds.getX() + layerBounds.getWidth()
- (x + viewBounds.getWidth()), layerBounds.getY() + layerBounds.getHeight()
- (y + viewBounds.getHeight()));
// Now transform the new view position into global coords
camera.localToView(newPoint);
// Compute the new matrix values to put the camera at the
// correct location
final double newX = -(at.getScaleX() * newPoint.getX() + at.getShearX() * newPoint.getY());
final double newY = -(at.getShearY() * newPoint.getX() + at.getScaleY() * newPoint.getY());
at.setTransform(at.getScaleX(), at.getShearY(), at.getShearX(), at.getScaleY(), newX, newY);
// Now actually set the camera's transform
camera.setViewTransform(at);
scrollInProgress = false;
}
示例15: cacheViewBounds
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
* Caches the information necessary to animate from the current view bounds
* to the specified centerBounds.
*/
private AffineTransform cacheViewBounds(final Rectangle2D centerBounds, final boolean scaleToFit) {
final PBounds viewBounds = getViewBounds();
// Initialize the image to the union of the current and destination
// bounds
final PBounds imageBounds = new PBounds(viewBounds);
imageBounds.add(centerBounds);
animateViewToCenterBounds(imageBounds, scaleToFit, 0);
imageAnimateBounds = getViewBounds();
// Now create the actual cache image that we will use to animate fast
final BufferedImage buffer = getPaintBuffer();
Paint fPaint = Color.white;
if (getPaint() != null) {
fPaint = getPaint();
}
toImage(buffer, fPaint);
// Do this after the painting above!
imageAnimate = true;
// Return the bounds to the previous viewbounds
animateViewToCenterBounds(viewBounds, scaleToFit, 0);
// The code below is just copied from animateViewToCenterBounds to
// create the correct transform to center the specified bounds
final PDimension delta = viewBounds.deltaRequiredToCenter(centerBounds);
final PAffineTransform newTransform = getViewTransform();
newTransform.translate(delta.width, delta.height);
if (scaleToFit) {
final double s = Math.min(viewBounds.getWidth() / centerBounds.getWidth(), viewBounds.getHeight()
/ centerBounds.getHeight());
newTransform.scaleAboutPoint(s, centerBounds.getCenterX(), centerBounds.getCenterY());
}
return newTransform;
}