本文整理汇总了Java中edu.umd.cs.piccolo.util.PBounds.getMaxY方法的典型用法代码示例。如果您正苦于以下问题:Java PBounds.getMaxY方法的具体用法?Java PBounds.getMaxY怎么用?Java PBounds.getMaxY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.umd.cs.piccolo.util.PBounds
的用法示例。
在下文中一共展示了PBounds.getMaxY方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: step
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
public void step( MovingImageNode node, PBounds bounds ) {
double y = node.getYOffset() + node.getMotionDelta();
if ( y > bounds.getMaxY() ) {
y = bounds.getMinY() - node.getFullBoundsReference().getHeight();
}
node.setOffset( node.getXOffset(), y );
}
示例2: updateUI
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
private void updateUI() {
// set selection state of each button
for ( ButtonNode button : buttons ) {
button.setSelection( _selectedModel );
}
// position the selection indicator behind the selected button's image
PBounds sbb = getSelectedButton().getFullBounds();
PBounds sib = _selectionIndicator.getFullBounds();
double x = sbb.getX() - ( ( sib.getWidth() - sbb.getWidth() ) / 2 );
double y = sbb.getMaxY() - sib.getHeight() + ( ( sib.getHeight() - getSelectedButton().getImageHeight() ) / 2 );
_selectionIndicator.setOffset( x, y );
}
示例3: separateMoleculeDestinations
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
* Update atom destinations so that separate molecules will be separated visually
* <p/>
* Returns all of the molecules that were pushed in this action
*/
private Set<Molecule> separateMoleculeDestinations() {
int maxIterations = 500;
double pushAmount = 10; // how much to push two molecules away
Set<Molecule> pushedMolecules = new HashSet<Molecule>();
boolean foundOverlap = true;
while ( foundOverlap && maxIterations-- >= 0 ) {
foundOverlap = false;
for ( Molecule a : molecules ) {
PBounds aBounds = padMoleculeBounds( a.getDestinationBounds() );
// push it away from the outsides
if ( aBounds.getMinX() < getAvailablePlayAreaBounds().getMinX() ) {
a.shiftDestination( new Vector2D( getAvailablePlayAreaBounds().getMinX() - aBounds.getMinX(), 0 ) );
aBounds = padMoleculeBounds( a.getDestinationBounds() );
}
if ( aBounds.getMaxX() > getAvailablePlayAreaBounds().getMaxX() ) {
a.shiftDestination( new Vector2D( getAvailablePlayAreaBounds().getMaxX() - aBounds.getMaxX(), 0 ) );
aBounds = padMoleculeBounds( a.getDestinationBounds() );
}
if ( aBounds.getMinY() < getAvailablePlayAreaBounds().getMinY() ) {
a.shiftDestination( new Vector2D( 0, getAvailablePlayAreaBounds().getMinY() - aBounds.getMinY() ) );
aBounds = padMoleculeBounds( a.getDestinationBounds() );
}
if ( aBounds.getMaxY() > getAvailablePlayAreaBounds().getMaxY() ) {
a.shiftDestination( new Vector2D( 0, getAvailablePlayAreaBounds().getMaxY() - aBounds.getMaxY() ) );
}
// then separate it from other molecules
for ( Molecule b : molecules ) {
if ( a.getMoleculeId() >= b.getMoleculeId() ) {
// this removes the case where a == b, and will make sure we don't run the following code twice for (a,b) and (b,a)
continue;
}
PBounds bBounds = padMoleculeBounds( b.getDestinationBounds() );
if ( aBounds.intersects( bBounds ) ) {
foundOverlap = true;
// try adding both. set should remove duplicates
pushedMolecules.add( a );
pushedMolecules.add( b );
// get perturbed centers. this is so that if two molecules have the exact same centers, we will push them away
Vector2D aCenter = new Vector2D( aBounds.getCenter2D() ).plus( Math.random() - 0.5, Math.random() - 0.5 );
Vector2D bCenter = new Vector2D( bBounds.getCenter2D() ).plus( Math.random() - 0.5, Math.random() - 0.5 );
// delta from center of A to center of B, scaled to half of our push amount.
Vector2D delta = bCenter.minus( aCenter ).normalized().times( pushAmount );
// how hard B should be pushed (A will be pushed (1-pushRatio)). Heuristic, power is to make the ratio not too skewed
// this is done so that heavier molecules will be pushed less, while lighter ones will be pushed more
double pushPower = 1;
double pushRatio = Math.pow( a.getApproximateMolecularWeight(), pushPower ) / ( Math.pow( a.getApproximateMolecularWeight(), pushPower ) + Math.pow( b.getApproximateMolecularWeight(), pushPower ) );
// push B by the pushRatio
b.shiftDestination( delta.times( pushRatio ) );
// push A the opposite way, by (1 - pushRatio)
Vector2D delta1 = delta.times( -1 * ( 1 - pushRatio ) );
a.shiftDestination( delta1 );
aBounds = padMoleculeBounds( a.getDestinationBounds() );
}
}
}
}
return pushedMolecules;
}
示例4: VoltmeterBodyNode
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
* Constructor
*
* @param voltmeter the voltmeter model
* @param mvt model-view transform
*/
public VoltmeterBodyNode( final Voltmeter voltmeter, final CLModelViewTransform3D mvt ) {
// body of the meter
PImage imageNode = new PImage( BODY_IMAGE );
addChild( imageNode );
// close button
PImage closeButtonNode = new PImage( CLImages.CLOSE_BUTTON );
closeButtonNode.addInputEventListener( new CursorHandler() );
closeButtonNode.addInputEventListener( new PBasicInputEventHandler() {
@Override
public void mouseReleased( PInputEvent event ) {
voltmeter.visibleProperty.set( false );
}
} );
addChild( closeButtonNode );
double xOffset = imageNode.getFullBoundsReference().getMaxX() + 2;
double yOffset = imageNode.getFullBoundsReference().getMinY();
closeButtonNode.setOffset( xOffset, yOffset );
// display background, assumes display is horizontally centered in the meter
double x = DISPLAY_X_MARGIN_TO_IMAGE_WIDTH_RATIO * imageNode.getFullBoundsReference().getWidth();
double y = DISPLAY_Y_MARGIN_TO_IMAGE_HEIGHT_RATIO * imageNode.getFullBoundsReference().getHeight();
double w = imageNode.getFullBoundsReference().getWidth() - ( 2 * x );
double h = ( DISPLAY_HEIGHT_TO_IMAGE_HEIGHT_RATION * imageNode.getFullBoundsReference().getHeight() ) - ( 2 * y );
displayBackgroundNode = new PPath( new Rectangle2D.Double( x, y, w, h ) );
displayBackgroundNode.setStroke( null );
displayBackgroundNode.setPaint( DISPLAY_BACKGROUND_COLOR );
addChild( displayBackgroundNode );
// digital display
displayNode = new DoubleDisplayNode( voltmeter.getValue(), "", DISPLAY_VALUE_FORMAT, CLStrings.VOLTS, CLStrings.PATTERN_LABEL_VALUE_UNITS, CLStrings.VOLTS_UNKNOWN );
displayNode.setFont( DISPLAY_FONT );
displayNode.setHTMLColor( DISPLAY_TEXT_COLOR );
addChild( displayNode );
// offsets for connection points of wires that attach probes to body
PBounds imageBounds = imageNode.getFullBoundsReference();
positiveConnectionOffset = new Point2D.Double( imageBounds.getWidth() / 4, imageBounds.getMaxY() ); // bottom left
negativeConnectionOffset = new Point2D.Double( 3 * imageBounds.getWidth() / 4, imageBounds.getMaxY() ); // bottom right
// interactivity
addInputEventListener( new CursorHandler() );
addInputEventListener( new WorldLocationDragHandler( voltmeter.bodyLocationProperty, this, mvt ) );
// observers
{
// update display when value changes
voltmeter.addValueObserver( new SimpleObserver() {
public void update() {
displayNode.setValue( voltmeter.getValue() );
updateLayout();
}
} );
// update location
voltmeter.bodyLocationProperty.addObserver( new SimpleObserver() {
public void update() {
setOffset( mvt.modelToView( voltmeter.bodyLocationProperty.get() ) );
}
} );
}
}
示例5: isPointOutsideRadiusBounds
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
private static boolean isPointOutsideRadiusBounds( Vector2D point, double radius, PBounds bounds ) {
return point.x - radius < bounds.getMinX()
|| point.x + radius > bounds.getMaxX()
|| point.y - radius < bounds.getMinY()
|| point.y + radius > bounds.getMaxY();
}
示例6: BeakerNode
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
public BeakerNode( PDimension vesselSize, AqueousSolution solution ) {
VesselNode vesselNode = new VesselNode( vesselSize, MAX_VOLUME );
double probeHeight = vesselSize.getHeight() + 55;
probeNode = new PHProbeNode( probeHeight, solution );
SolutionNode solutionNode = new SolutionNode( vesselSize );
moleculeCountsNode = new MoleculeCountsNode( solution );
PDimension labelSize = new PDimension( 0.9 * vesselSize.getWidth(), 0.1 * vesselSize.getHeight() );
beakerLabelNode = new BeakerLabelNode( labelSize, solution );
// clipping path for "dot" views
PBounds containerBounds = new PBounds( 0, 0, vesselSize.getWidth(), vesselSize.getHeight() );
PClip dotsClippingPath = new PClip();
dotsClippingPath.setPathTo( new Rectangle2D.Double( containerBounds.getX(), containerBounds.getY(), containerBounds.getWidth(), containerBounds.getHeight() ) );
dotsClippingPath.setStroke( null );
dotsNode = new RatioDotsNode( solution, containerBounds );
dotsClippingPath.addChild( dotsNode ); // clip to solution bounds
// rendering order
addChild( solutionNode );
addChild( probeNode );
addChild( dotsClippingPath );
addChild( vesselNode );
addChild( moleculeCountsNode );
addChild( beakerLabelNode );
// layout
vesselNode.setOffset( 0, 0 );
solutionNode.setOffset( vesselNode.getOffset() );
// molecule counts inside the vessel
double xOffset = vesselNode.getXOffset() - PNodeLayoutUtils.getOriginXOffset( moleculeCountsNode ) + 25;
double yOffset = vesselNode.getYOffset() - PNodeLayoutUtils.getOriginYOffset( moleculeCountsNode ) + 20;
moleculeCountsNode.setOffset( xOffset, yOffset );
// label at bottom of vessel
PBounds vfb = vesselNode.getFullBoundsReference();
xOffset = vfb.getMinX() + ( vfb.getWidth() - beakerLabelNode.getFullBoundsReference().getWidth() ) / 2;
yOffset = vfb.getMaxY() - beakerLabelNode.getFullBoundsReference().getHeight() - 20;
beakerLabelNode.setOffset( xOffset, yOffset );
// probe at right side of vessel, tip of probe at bottom of vessel
xOffset = vfb.getMaxX() - probeNode.getFullBoundsReference().getWidth() - 100;
yOffset = vfb.getMaxY() - probeNode.getFullBoundsReference().getHeight();
probeNode.setOffset( xOffset, yOffset );
}
示例7: GameScoreboardNode
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
* Constructor
*
* @param maxLevel the maximum level, used to adjust the layout to accommodate the maximum width
* @param maxScore the maximum score, used to adjust the layout to accommodate the maximum width
* @param pointsFormat points are displayed in this format
*/
public GameScoreboardNode( int maxLevel, double maxScore, NumberFormat pointsFormat ) {
this.pointsFormat = pointsFormat;
this.confirmNewGame = false; // #3434, default is no confirmation
this.listeners = new EventListenerList();
// Level
levelNode = new PText();
levelNode.setFont( FONT );
setLevel( maxLevel ); // start with this, so we have a reasonable size for layout
// Score
scoreNode = new PText();
scoreNode.setFont( FONT );
setScore( maxScore ); // start with this, so we have a reasonable size for layout
// timer
timerIcon = new PImage( STOPWATCH_ICON );
timerValue = new PText();
timerValue.setFont( FONT );
setTime( 0 ); // start with this, so we have a reasonable size for layout
// New Game button
newGameButton = new HTMLImageButtonNode( BUTTON_NEW_GAME, BUTTON_FONT, BUTTON_COLOR ) {{
setUserComponent( GameSimSharing.UserComponents.newGameButton );
}};
newGameButton.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent e ) {
handleNewGame();
}
} );
// rendering order
addChild( levelNode );
addChild( scoreNode );
addChild( timerIcon );
addChild( timerValue );
addChild( newGameButton );
// layout, everything in a row, vertically centered, offsets were set by eyeballing them
final double maxChildHeight = getMaxChildHeight();
// level
double x = X_MARGIN;
double y = Y_MARGIN + ( ( maxChildHeight - levelNode.getFullBoundsReference().getHeight() ) / 2 );
levelNode.setOffset( x, y );
// score
x = levelNode.getFullBoundsReference().getMaxX() + 80;
y = Y_MARGIN + ( ( maxChildHeight - scoreNode.getFullBoundsReference().getHeight() ) / 2 );
scoreNode.setOffset( x, y );
// timer
x = scoreNode.getFullBoundsReference().getMaxX() + 60;
y = Y_MARGIN + ( ( maxChildHeight - timerIcon.getFullBoundsReference().getHeight() ) / 2 );
timerIcon.setOffset( x, y );
x = timerIcon.getFullBoundsReference().getMaxX() + 5;
y = Y_MARGIN + ( ( maxChildHeight - timerValue.getFullBoundsReference().getHeight() ) / 2 );
timerValue.setOffset( x, y );
// New Game button
x = timerValue.getFullBoundsReference().getMaxX() + 20;
y = Y_MARGIN + ( ( maxChildHeight - newGameButton.getFullBoundsReference().getHeight() ) / 2 );
newGameButton.setOffset( x, y );
// background, added last since it's sized to fit the child nodes above
PBounds b = getFullBoundsReference();
backgroundShape = new Rectangle2D.Double( 0, 0, b.getMaxX() + X_MARGIN, b.getMaxY() + Y_MARGIN );
backgroundNode = new PPath( backgroundShape );
backgroundNode.setPaint( BACKGROUND_FILL_COLOR );
backgroundNode.setStroke( BACKGROUND_STROKE );
backgroundNode.setStrokePaint( BACKGROUND_STROKE_COLOR );
addChild( backgroundNode );
backgroundNode.moveToBack();
}
示例8: 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;
}