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


Java PBounds.getCenterX方法代码示例

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


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

示例1: relocateHandle

import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
 * Force this handle to relocate itself using its locator.
 */
public void relocateHandle() {
    if (locator != null) {
        final PBounds b = getBoundsReference();
        final Point2D aPoint = locator.locatePoint(null);

        if (locator instanceof PNodeLocator) {
            final PNode located = ((PNodeLocator) locator).getNode();
            final PNode parent = getParent();

            located.localToGlobal(aPoint);
            globalToLocal(aPoint);

            if (parent != located && parent instanceof PCamera) {
                ((PCamera) parent).viewToLocal(aPoint);
            }
        }

        final double newCenterX = aPoint.getX();
        final double newCenterY = aPoint.getY();

        if (newCenterX != b.getCenterX() || newCenterY != b.getCenterY()) {
            centerBoundsOnPoint(newCenterX, newCenterY);
        }
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:29,代码来源:PSWTHandle.java

示例2: relocateHandle

import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
 * Force this handle to relocate itself using its locator.
 */
public void relocateHandle() {
    if (locator == null) {
        return;
    }

    final PBounds b = getBoundsReference();
    final Point2D aPoint = locator.locatePoint(null);

    if (locator instanceof PNodeLocator) {
        final PNode located = ((PNodeLocator) locator).getNode();
        final PNode parent = getParent();

        located.localToGlobal(aPoint);
        globalToLocal(aPoint);

        if (parent != located && parent instanceof PCamera) {
            ((PCamera) parent).viewToLocal(aPoint);
        }
    }

    final double newCenterX = aPoint.getX();
    final double newCenterY = aPoint.getY();

    if (newCenterX != b.getCenterX() || newCenterY != b.getCenterY()) {

        centerBoundsOnPoint(newCenterX, newCenterY);
    }

}
 
开发者ID:mleoking,项目名称:PhET,代码行数:33,代码来源:PHandle.java

示例3: fillViewWhiteSpace

import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
 * Instantaneously transforms the provided camera so that it does not
 * contain any extra white space.
 * 
 * @param camera the camera to be transformed
 */
protected void fillViewWhiteSpace(final PCamera camera) {
    final PBounds rootBounds = camera.getRoot().getFullBoundsReference();        

    if (rootBounds.contains(camera.getViewBounds())) {
        return;
    }

    camera.animateViewToPanToBounds(rootBounds, 0);
    camera.animateViewToPanToBounds(focusNode.getGlobalFullBounds(), 0);

    // center content.
    double dx = 0;
    double dy = 0;
    
    PBounds viewBounds = camera.getViewBounds();

    if (viewBounds.getWidth() > rootBounds.getWidth()) {
        // then center along x axis.
        dx = rootBounds.getCenterX() - viewBounds.getCenterX();
    }

    if (viewBounds.getHeight() > rootBounds.getHeight()) {
        // then center along y axis.
        dy = rootBounds.getCenterX() - viewBounds.getCenterX();
    }

    camera.translateView(dx, dy);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:35,代码来源:PNavigationEventHandler.java

示例4: createContentNode

import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
private static PNode createContentNode( String text, Font font, Color foreground, Color disabledForeground, boolean enabled, BufferedImage image, BufferedImage disabledImage, TextPosition textPosition, double imageTextGap ) {
    PNode textNode = createTextNode( text, font, foreground, disabledForeground, enabled );
    PNode imageNode = createImageNode( image, disabledImage, enabled );
    PComposite content = new PComposite();
    content.addChild( textNode );
    content.addChild( imageNode );

    // layout text and image
    double textX, imageX = 0;
    double textY, imageY = 0;
    PBounds tb = textNode.getFullBoundsReference();
    PBounds ib = imageNode.getFullBoundsReference();
    if ( textPosition == TextPosition.ABOVE ) {
        textX = 0;
        imageX = tb.getCenterX() - ( ib.getWidth() / 2 );
        textY = 0;
        imageY = tb.getMaxY() + imageTextGap;
    }
    else if ( textPosition == TextPosition.BELOW ) {
        imageX = 0;
        textX = ib.getCenterX() - ( tb.getWidth() / 2 );
        imageY = 0;
        textY = ib.getMaxY() + imageTextGap;
    }
    else if ( textPosition == TextPosition.LEFT ) {
        textX = 0;
        imageX = tb.getMaxX() + imageTextGap;
        textY = 0;
        imageY = tb.getCenterY() - ( ib.getHeight() / 2 );
    }
    else if ( textPosition == TextPosition.RIGHT ) {
        imageX = 0;
        textX = ib.getMaxX() + imageTextGap;
        imageY = 0;
        textY = ib.getCenterY() - ( tb.getHeight() / 2 );
    }
    else {
        throw new UnsupportedOperationException( "unsupported text position: " + textPosition );
    }
    textNode.setOffset( textX, textY );
    imageNode.setOffset( imageX, imageY );
    return content;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:44,代码来源:HTMLImageButtonNode.java


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