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


Java PBounds.setRect方法代码示例

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


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

示例1: computeFullBounds

import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
 * Change the full bounds computation to take into account that we are
 * expanding the children's bounds Do this instead of overriding
 * getBoundsReference() since the node is not volatile
 */
public PBounds computeFullBounds(final PBounds dstBounds) {
    final PBounds result = getUnionOfChildrenBounds(dstBounds);

    cachedChildBounds.setRect(result);
    result.setRect(result.getX() - INDENT, result.getY() - INDENT, result.getWidth() + 2 * INDENT, result
            .getHeight()
            + 2 * INDENT);
    localToParent(result);
    return result;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:16,代码来源:GroupExample.java

示例2: getBoundsReference

import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
 * Since our bounds are volatile, we can override this method to indicate
 * that we are expanding our bounds beyond our children
 */
public PBounds getBoundsReference() {
    final PBounds bds = super.getBoundsReference();
    getUnionOfChildrenBounds(bds);

    cachedChildBounds.setRect(bds);
    final double scaledIndent = INDENT / renderCamera.getViewScale();
    bds.setRect(bds.getX() - scaledIndent, bds.getY() - scaledIndent, bds.getWidth() + 2 * scaledIndent, bds
            .getHeight()
            + 2 * scaledIndent);

    return bds;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:17,代码来源:GroupExample.java

示例3: getBoundsReference

import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/** {@inheritDoc} */
public PBounds getBoundsReference() {
    final PBounds targetBounds = target.getFullBounds();
    camera.viewToLocal(targetBounds);
    camera.globalToLocal(targetBounds);
    final PBounds bounds = super.getBoundsReference();
    bounds.setRect(targetBounds);
    return super.getBoundsReference();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:10,代码来源:PSWTStickyHandleManager.java

示例4: getBoundsReference

import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
 * The sticky handle manager's bounds as computed by examining its target
 * through its camera.
 * 
 * @return the sticky handle manager's bounds as computed by examining its
 *         target through its camera
 */
public PBounds getBoundsReference() {
    final PBounds targetBounds = target.getFullBounds();
    camera.viewToLocal(targetBounds);
    camera.globalToLocal(targetBounds);
    final PBounds bounds = super.getBoundsReference();
    bounds.setRect(targetBounds);
    return super.getBoundsReference();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:16,代码来源:PStickyHandleManager.java

示例5: applyViewConstraints

import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
 * Transforms the view so that it conforms to the given constraint.
 */
protected void applyViewConstraints() {
    if (VIEW_CONSTRAINT_NONE == viewConstraint) {
        return;
    }
    final PBounds viewBounds = getViewBounds();
    final PBounds layerBounds = (PBounds) globalToLocal(getUnionOfLayerFullBounds());

    if (VIEW_CONSTRAINT_CENTER == viewConstraint) {
        layerBounds.setRect(layerBounds.getCenterX(), layerBounds.getCenterY(), 0, 0);            
    }
    PDimension constraintDelta = viewBounds.deltaRequiredToContain(layerBounds);
    viewTransform.translate(-constraintDelta.width, -constraintDelta.height);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:17,代码来源:PCamera.java

示例6: dragHandle

import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
 * Is invoked when the handle is being dragged.
 * 
 * @param aLocalDimension dimension representing the magnitude of the handle
 *            drag
 * @param aEvent event responsible for the call
 */
public void dragHandle(final PDimension aLocalDimension, final PInputEvent aEvent) {
    final PBoundsLocator l = (PBoundsLocator) getLocator();

    final PNode n = l.getNode();
    final PBounds b = n.getBounds();

    final PNode parent = getParent();
    if (parent != n && parent instanceof PCamera) {
        ((PCamera) parent).localToView(aLocalDimension);
    }

    localToGlobal(aLocalDimension);
    n.globalToLocal(aLocalDimension);

    final double dx = aLocalDimension.getWidth();
    final double dy = aLocalDimension.getHeight();

    switch (l.getSide()) {
        case SwingConstants.NORTH:
            b.setRect(b.x, b.y + dy, b.width, b.height - dy);
            break;

        case SwingConstants.SOUTH:
            b.setRect(b.x, b.y, b.width, b.height + dy);
            break;

        case SwingConstants.EAST:
            b.setRect(b.x, b.y, b.width + dx, b.height);
            break;

        case SwingConstants.WEST:
            b.setRect(b.x + dx, b.y, b.width - dx, b.height);
            break;

        case SwingConstants.NORTH_WEST:
            b.setRect(b.x + dx, b.y + dy, b.width - dx, b.height - dy);
            break;

        case SwingConstants.SOUTH_WEST:
            b.setRect(b.x + dx, b.y, b.width - dx, b.height + dy);
            break;

        case SwingConstants.NORTH_EAST:
            b.setRect(b.x, b.y + dy, b.width + dx, b.height - dy);
            break;

        case SwingConstants.SOUTH_EAST:
            b.setRect(b.x, b.y, b.width + dx, b.height + dy);
            break;
        default:
            throw new RuntimeException("Invalid side returned from PBoundsLocator");
    }

    boolean flipX = false;
    boolean flipY = false;

    if (b.width < 0) {
        flipX = true;
        b.width = -b.width;
        b.x -= b.width;
    }

    if (b.height < 0) {
        flipY = true;
        b.height = -b.height;
        b.y -= b.height;
    }

    if (flipX || flipY) {
        flipSiblingBoundsHandles(flipX, flipY);
    }

    n.setBounds(b);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:82,代码来源:PBoundsHandle.java


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