当前位置: 首页>>代码示例>>Java>>正文


Java PBounds.add方法代码示例

本文整理汇总了Java中org.piccolo2d.util.PBounds.add方法的典型用法代码示例。如果您正苦于以下问题:Java PBounds.add方法的具体用法?Java PBounds.add怎么用?Java PBounds.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.piccolo2d.util.PBounds的用法示例。


在下文中一共展示了PBounds.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateMarquee

import org.piccolo2d.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());
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:21,代码来源:PSWTSelectionEventHandler.java

示例2: getViewPosition

import org.piccolo2d.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;
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:29,代码来源:PDefaultScrollDirector.java

示例3: getViewSize

import org.piccolo2d.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;
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:31,代码来源:PDefaultScrollDirector.java

示例4: getViewPosition

import org.piccolo2d.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;

}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:46,代码来源:PrintExample.java

示例5: getViewPosition

import org.piccolo2d.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;

}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:47,代码来源:ScrollingExample.java

示例6: shouldRevalidateScrollPane

import org.piccolo2d.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;
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:46,代码来源:PDefaultScrollDirector.java

示例7: getUnionOfLayerFullBounds

import org.piccolo2d.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;
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:19,代码来源:PCamera.java

示例8: costOfNoBoundsCache

import org.piccolo2d.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");

}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:40,代码来源:PerformanceTests.java

示例9: setViewPosition

import org.piccolo2d.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;
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:59,代码来源:PrintExample.java

示例10: setViewPosition

import org.piccolo2d.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;
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:58,代码来源:ScrollingExample.java

示例11: cacheViewBounds

import org.piccolo2d.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;
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:47,代码来源:PCacheCamera.java

示例12: updateMarquee

import org.piccolo2d.util.PBounds; //导入方法依赖的package包/类
/**
 * Updates the marquee rectangle as the result of a drag.
 * 
 * @param pie event responsible for the change in the marquee
 */
protected void updateMarquee(final PInputEvent 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.globalToLocal(b);
    marquee.reset();
    marquee.append(b, false);
    marquee.closePath();
    b.reset();
    b.add(presspt);
    b.add(pie.getPosition());

    allItems.clear();
    final PNodeFilter filter = createNodeFilter(b);
    final Iterator parentsIt = selectableParents.iterator();
    while (parentsIt.hasNext()) {
        final PNode parent = (PNode) parentsIt.next();

        Collection items;
        if (parent instanceof PCamera) {
            items = new ArrayList();
            for (int i = 0; i < ((PCamera) parent).getLayerCount(); i++) {
                ((PCamera) parent).getLayer(i).getAllNodes(filter, items);
            }
        }
        else {
            items = parent.getAllNodes(filter, null);
        }

        final Iterator itemsIt = items.iterator();
        while (itemsIt.hasNext()) {
            allItems.put(itemsIt.next(), Boolean.TRUE);
        }
    }
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:49,代码来源:PSelectionEventHandler.java

示例13: setViewPosition

import org.piccolo2d.util.PBounds; //导入方法依赖的package包/类
/**
 * Set the view position in a manner consistent with standardized scrolling.
 * 
 * @param x The new x position
 * @param y The new y position
 */
public void setViewPosition(final double x, final double y) {
    // Bail out if scrollInProgress because we can end up with an infinite
    // loop since the scrollbars depend on the camera location
    if (camera == null || 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 bounds
    final PBounds viewBounds = camera.getBoundsReference();
    layerBounds.add(viewBounds);

    // Now find the new view position in view coordinates
    final Point2D newPoint = new Point2D.Double(layerBounds.getX() + x, layerBounds.getY() + y);

    // 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;
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:48,代码来源:PDefaultScrollDirector.java

示例14: testAdding1PointToEmptyYieldsEmpty

import org.piccolo2d.util.PBounds; //导入方法依赖的package包/类
public void testAdding1PointToEmptyYieldsEmpty() {
    final PBounds b = new PBounds();
    b.add(-10, -10);
    PiccoloAsserts.assertEquals(new PDimension(0, 0), b.getSize(), 0.00001);
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:6,代码来源:PBoundsTest.java

示例15: testAdding2PointsToEmptyYieldsNotEmpty

import org.piccolo2d.util.PBounds; //导入方法依赖的package包/类
public void testAdding2PointsToEmptyYieldsNotEmpty() {
    final PBounds b = new PBounds();
    b.add(-10, -10);
    b.add(0, 0);
    PiccoloAsserts.assertEquals(new PDimension(10, 10), b.getSize(), 0.00001);
}
 
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:7,代码来源:PBoundsTest.java


注:本文中的org.piccolo2d.util.PBounds.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。