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


Java PBounds.getCenterY方法代码示例

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


在下文中一共展示了PBounds.getCenterY方法的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: createArrowShape

import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
private static GeneralPath createArrowShape( final double scale, final ArrayList<PNode> highlights ) {
    final PBounds highlightBounds = highlights.get( 0 ).getFullBounds();
    Vector2D tickA = new Vector2D( highlightBounds.getX() + 1, highlightBounds.getCenterY() );
    double headWidth = 10.0 / scale;
    return new Arrow( tickA.plus( -5, 0 ).toPoint2D(), tickA.toPoint2D(), headWidth, headWidth, headWidth / 2.0 ).getShape();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:7,代码来源:NumberLineNode.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.getCenterY方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。