本文整理汇总了Java中edu.umd.cs.piccolo.PNode.getXOffset方法的典型用法代码示例。如果您正苦于以下问题:Java PNode.getXOffset方法的具体用法?Java PNode.getXOffset怎么用?Java PNode.getXOffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.umd.cs.piccolo.PNode
的用法示例。
在下文中一共展示了PNode.getXOffset方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getConnectionPoint
import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
private Point2D getConnectionPoint( PNode node, Point2D connectionOffset ) {
// create a transform that matches the node's rotation
AffineTransform t = AffineTransform.getRotateInstance( node.getRotation(), node.getXOffset(), node.getYOffset() );
// rotate the connection point to match the node's rotation
double x = node.getXOffset() + connectionOffset.getX();
double y = node.getYOffset() + connectionOffset.getY();
return t.transform( new Point2D.Double( x, y ), null );
}
示例2: updateLayout
import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
private void updateLayout() {
for ( String substanceName : stacks.keySet() ){
ArrayList<SubstanceImageNode> stack = stacks.get( substanceName );
PNode controlNode = valueNodes.get( substanceName );
for ( int i = 0; i < stack.size(); i++ ) {
SubstanceImageNode node = stack.get( i );
double x = controlNode.getXOffset() - ( node.getFullBoundsReference().getWidth() / 2 );
double y = getBoxHeight() - node.getFullBoundsReference().getHeight() - Y_MARGIN - ( i * Y_SPACING );
node.setOffset( x, y );
}
}
}
示例3: updateNode
import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
private void updateNode() {
// all dynamic stuff is above the beam, and is children of atomPilesParentNode
atomPilesParentNode.removeAllChildren();
// left pile of atoms, centered on left-half of beam
PNode leftPileNode = createAtomPile( leftNumberOfAtoms, element );
leftPileNode.setOffset( -( 0.25 * BEAM_LENGTH ) - ( leftPileNode.getFullBoundsReference().getWidth() / 2 ), 0 );
atomPilesParentNode.addChild( leftPileNode );
// right pile of atoms, centered on right-half of beam
PNode rightPileNode = createAtomPile( rightNumberOfAtoms, element );
rightPileNode.setOffset( ( 0.25 * BEAM_LENGTH ) - ( rightPileNode.getFullBoundsReference().getWidth() / 2 ), 0 );
atomPilesParentNode.addChild( rightPileNode );
// left count, centered above left pile
CountNode leftCountNode = new CountNode( leftNumberOfAtoms );
atomPilesParentNode.addChild( leftCountNode );
double x = leftPileNode.getXOffset() + ( leftPileNode.getFullBoundsReference().getWidth() / 2 ) - ( leftCountNode.getFullBoundsReference().getWidth() / 2 );
double y = leftPileNode.getFullBoundsReference().getMinY() - leftCountNode.getFullBoundsReference().getHeight() - 2;
leftCountNode.setOffset( x, y );
// right count, centered above right pile
CountNode rightCountNode = new CountNode( rightNumberOfAtoms );
atomPilesParentNode.addChild( rightCountNode );
x = rightPileNode.getXOffset() + ( rightPileNode.getFullBoundsReference().getWidth() / 2 ) - ( rightCountNode.getFullBoundsReference().getWidth() / 2 );
y = rightPileNode.getFullBoundsReference().getMinY() - rightCountNode.getFullBoundsReference().getHeight() - 2;
rightCountNode.setOffset( x, y );
// rotate beam and piles on fulcrum
double maxAngle = ( Math.PI / 2 ) - Math.acos( FULCRUM_SIZE.getHeight() / ( BEAM_LENGTH / 2 ) );
final double difference = rightNumberOfAtoms - leftNumberOfAtoms;
double angle = 0;
if ( Math.abs( difference ) >= NUMBER_OF_TILT_ANGLES ) {
// max tilt
int sign = (int)( Math.abs( difference ) / difference );
angle = sign * maxAngle;
}
else {
// partial tilt
angle = difference * ( maxAngle / NUMBER_OF_TILT_ANGLES );
}
beamNode.setRotation( angle );
atomPilesParentNode.setRotation( angle );
}
示例4: updateLayout
import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
protected void updateLayout() {
Dimension2D worldSize = getWorldSize();
if ( worldSize.getWidth() <= 0 || worldSize.getHeight() <= 0 ) {
// canvas hasn't been sized, blow off layout
return;
}
else if ( AABSConstants.DEBUG_CANVAS_UPDATE_LAYOUT ) {
System.out.println( getClass().getName() + ".updateLayout worldSize=" + worldSize );
}
// start at (0,0), we'll adjust this globally with centerRootNode
double xOffset, yOffset = 0;
// solution controls in upper left
xOffset = -PNodeLayoutUtils.getOriginXOffset( solutionControlsNode );
yOffset = -PNodeLayoutUtils.getOriginYOffset( solutionControlsNode );
solutionControlsNode.setOffset( xOffset, yOffset );
// beaker below solution controls
xOffset = solutionControlsNode.getFullBoundsReference().getMinX() - PNodeLayoutUtils.getOriginXOffset( beakerNode );
yOffset = solutionControlsNode.getFullBoundsReference().getMaxY() - PNodeLayoutUtils.getOriginYOffset( beakerNode ) + 20;
beakerNode.setOffset( xOffset, yOffset );
// beaker controls attached to right edge of beaker
xOffset = beakerNode.getXOffset() + SolutionsDefaults.BEAKER_SIZE.getWidth() - 1;
yOffset = beakerNode.getYOffset() + ( 0.1 * SolutionsDefaults.BEAKER_SIZE.getHeight() );
beakerControlsNode.setOffset( xOffset, yOffset );
// graph to the right of beaker
xOffset = beakerNode.getFullBoundsReference().getMaxX() + 215;
yOffset = 0;
graphMaximizeControlNode.setOffset( xOffset, yOffset );
// reaction equations, below graph
xOffset = graphMaximizeControlNode.getXOffset();
yOffset = graphMaximizeControlNode.getFullBoundsReference().getMaxY() + 5;
reactionEquationsMaximizeControlNode.setOffset( xOffset, yOffset );
// equilibrium expressions, below reaction equations
xOffset = reactionEquationsMaximizeControlNode.getXOffset();
yOffset = reactionEquationsMaximizeControlNode.getFullBoundsReference().getMaxY() + 5;
equilibriumExpressionsMaximizeControlNode.setOffset( xOffset, yOffset );
// Reset All button at bottom center
PNode resetAllButton = getResetAllButton();
xOffset = beakerNode.getFullBoundsReference().getMaxX() + 10;
yOffset = beakerNode.getFullBoundsReference().getMaxY() - resetAllButton.getFullBoundsReference().getHeight();
resetAllButton.setOffset( xOffset , yOffset );
// misc controls above reset button
xOffset = resetAllButton.getXOffset();
yOffset = resetAllButton.getFullBoundsReference().getY() - legendControlNode.getFullBoundsReference().getHeight() - 5;
legendControlNode.setOffset( xOffset, yOffset );
centerRootNode();
}
示例5: FaceNode
import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public FaceNode( final double headDiameter, Paint headPaint, final Stroke headStroke, final Paint headStrokePaint, Paint eyePaint, Paint mouthPaint ) {
super();
final double eyeDiameter = 0.15f * headDiameter;
final double mouthRadius = headDiameter / 4d;
final Stroke mouthStroke = new BasicStroke( Math.max( 1f, (float) ( headDiameter / 25 ) ), BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND );
CircleNode headNode = new CircleNode( headDiameter, headPaint ) {{
setStroke( headStroke );
setStrokePaint( headStrokePaint );
}};
PNode leftEyeNode = new CircleNode( eyeDiameter, eyePaint );
PNode rightEyeNode = new CircleNode( eyeDiameter, eyePaint );
smileNode = new SmileNode( mouthRadius, mouthPaint, mouthStroke );
frownNode = new FrownNode( mouthRadius, mouthPaint, mouthStroke );
// rendering order
addChild( headNode );
addChild( leftEyeNode );
addChild( rightEyeNode );
addChild( smileNode );
addChild( frownNode );
// layout
double x = 0;
double y = 0;
headNode.setOffset( x, y );
x = ( 0.3 * headDiameter ) - ( leftEyeNode.getWidth() / 2 );
y = ( 0.4 * headDiameter ) - ( leftEyeNode.getHeight() / 2 );
leftEyeNode.setOffset( x, y );
x = headDiameter - leftEyeNode.getXOffset() - rightEyeNode.getWidth();
y = leftEyeNode.getYOffset();
rightEyeNode.setOffset( x, y );
x = 0.5 * headDiameter;
y = 0.55 * headDiameter;
smileNode.setOffset( x, y );
x = smileNode.getXOffset();
y = 0.65 * headDiameter;
frownNode.setOffset( x, y );
// default state
smile();
}
示例6: getOriginXOffset
import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public static double getOriginXOffset( PNode node ) {
return node.getFullBoundsReference().getX() - node.getXOffset();
}