本文整理汇总了Java中edu.umd.cs.piccolo.util.PBounds.getHeight方法的典型用法代码示例。如果您正苦于以下问题:Java PBounds.getHeight方法的具体用法?Java PBounds.getHeight怎么用?Java PBounds.getHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.umd.cs.piccolo.util.PBounds
的用法示例。
在下文中一共展示了PBounds.getHeight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fullPaint
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
* Overrides the camera's full paint method to do the fast rendering when
* possible.
*
* @param paintContext Paint Contex in which the painting is done
*/
public void fullPaint(final PPaintContext paintContext) {
if (imageAnimate) {
final PBounds fRef = getFullBoundsReference();
final PBounds viewBounds = getViewBounds();
final double scale = getFullBoundsReference().getWidth() / imageAnimateBounds.getWidth();
final double xOffset = (viewBounds.getX() - imageAnimateBounds.getX()) * scale;
final double yOffset = (viewBounds.getY() - imageAnimateBounds.getY()) * scale;
final double scaleW = viewBounds.getWidth() * scale;
final double scaleH = viewBounds.getHeight() * scale;
paintContext.getGraphics().drawImage(paintBuffer, 0, 0, (int) Math.ceil(fRef.getWidth()),
(int) Math.ceil(fRef.getHeight()), (int) Math.floor(xOffset), (int) Math.floor(yOffset),
(int) Math.ceil(xOffset + scaleW), (int) Math.ceil(yOffset + scaleH), null);
}
else {
super.fullPaint(paintContext);
}
}
示例2: updateLayout
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
private void updateLayout() {
final double horizMargin = 15;
final double vertMargin = 15;
PBounds chartBounds = _chartWrapper.getFullBoundsReference();
PBounds closeButtonBounds = _closeButtonNode.getFullBoundsReference();
final double maxWidth = chartBounds.getWidth();
double maxHeight = closeButtonBounds.getHeight() + vertMargin;
double x = 0;
double y = 0;
// chart: close button sits on chart
x = 0;
y = 0;
_chartWrapper.setOffset( x, y );
// close button: right edge, vertically centered
x = maxWidth - horizMargin - closeButtonBounds.getWidth();
y = ( maxHeight - closeButtonBounds.getHeight() ) / 2;
_closeButtonNode.setOffset( x, y );
}
示例3: handleReturnBeadButton
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
* When the "Return Bead" button is clicked,
* move the bead to the button's position and hide the button.
*/
private void handleReturnBeadButton() {
// Determine the button's coordinates
PBounds b = _returnBeadButtonWrapper.getFullBoundsReference();
double x = b.getX() + ( b.getWidth() / 2 );
double y = b.getY() + ( b.getHeight() / 2 );
OTModelViewTransform modelViewTransform = _model.getModelViewTransform();
Point2D p = modelViewTransform.viewToModel( x, y );
// Move the bead to the button's position
Bead bead = _model.getBead();
bead.setMotionEnabled( false );
bead.setPosition( p );
bead.setMotionEnabled( true );
// Hide the button
_returnBeadButtonWrapper.setVisible( false );
_returnBeadButtonWrapper.setPickable( false );
_returnBeadButtonWrapper.setChildrenPickable( false );
}
示例4: updateLayout
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
private void updateLayout() {
// scale the html, if necessary
PBounds bb = backgroundNode.getFullBoundsReference();
PBounds hb = htmlNode.getFullBoundsReference();
double scaleX = Math.min( 1.0, ( bb.getWidth() - 2 * MARGIN ) / hb.getWidth() );
double scaleY = Math.min( 1.0, ( bb.getHeight() - 2 * MARGIN ) / hb.getHeight() );
double scale = Math.min( scaleX, scaleY );
htmlNode.scale( scale );
// center html in background
hb = htmlNode.getFullBoundsReference();
double xOffset = ( bb.getWidth() - hb.getWidth() ) / 2;
double yOffset = ( bb.getHeight() - hb.getHeight() ) / 2;
htmlNode.setOffset( xOffset, yOffset );
}
示例5: updateBackgroundNodeShapes
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
private void updateBackgroundNodeShapes() {
PBounds b = toolTipTextNode.getFullBoundsReference();
final double w = b.getWidth() + ( 2 * _margin );
final double h = b.getHeight() + ( 2 * _margin );
_backgroundNode.setPathTo( new Rectangle2D.Double( 0, 0, w, h ) );
_backgroundShadowNode.setPathTo( new Rectangle2D.Double( 0, 0, w, h ) );
}
示例6: update
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
private void update() {
PBounds b = _foregroundNode.getFullBoundsReference();
double x = b.getMinX() - _insets.left;
double y = b.getMinY() - _insets.top;
double w = b.getWidth() + _insets.left + _insets.right;
double h = b.getHeight() + _insets.top + _insets.bottom;
_rectangle.setRect( x, y, w, h );
_pathNode.setPathTo( _rectangle );
}
示例7: scaleLabel
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
* Scale the label to fit optimally within the bounds.
*
* @param labelNode
* @param fullBoundsReference
*/
private void scaleLabel(HTMLNode labelNode, PBounds bounds) {
labelNode.setScale(1);
double maxBoundsConsumption = 0.90;
double widthScale = bounds.getWidth() * maxBoundsConsumption / labelNode.getWidth();
double heightScale = bounds.getHeight() * maxBoundsConsumption / labelNode.getHeight();
// Scale by the smaller of the two possible scaling values so that the
// label fits within the bounds.
labelNode.setScale(Math.min(widthScale, heightScale));
}
示例8: setScale
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
@Override
public void setScale( double scale ) {
PBounds boundsBefore = getFullBounds();
super.setScale( scale );
PBounds boundsAfter = getFullBounds();
double xOffset = getXOffset() - ( ( boundsAfter.getWidth() - boundsBefore.getWidth() ) / 2 );
double yOffset = getYOffset() + ( ( boundsAfter.getHeight() - boundsBefore.getHeight() ) / 2 );
setOffset( xOffset, yOffset );
}
示例9: centerNode
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
protected void centerNode( PNode node ) {
if ( node != null ) {
Dimension2D worldSize = getWorldSize();
PBounds b = node.getFullBoundsReference();
double xOffset = ( ( worldSize.getWidth() - b.getWidth() ) / 2 ) - PNodeLayoutUtils.getOriginXOffset( node );
double yOffset = ( ( worldSize.getHeight() - b.getHeight() ) / 2 ) - PNodeLayoutUtils.getOriginYOffset( node );
node.setOffset( xOffset, yOffset );
}
}
示例10: updateCharges
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
protected void updateCharges() {
Bead bead = getBead();
final double electricFieldX = bead.getElectricFieldX();
final double scale = getChargeScale( electricFieldX );
// if the scale is zero, hide the charges so we don't attempt to apply a zero scale
_positiveNode.setVisible( scale > 0 );
_negativeNode.setVisible( scale > 0 );
// position and scale the charges
if ( scale > 0 ) {
double x, y;
PBounds positiveBounds = _positiveNode.getFullBoundsReference();
PBounds negativeBounds = _negativeNode.getFullBoundsReference();
// positive charge
_positiveNode.setScale( scale );
if ( electricFieldX > 0 ) {
x = _viewBeadRadius - positiveBounds.getWidth() - _viewMargin;
}
else {
x = -_viewBeadRadius + _viewMargin;
}
y = -positiveBounds.getHeight() / 2;
_positiveNode.setOffset( x, y );
// negative charge
_negativeNode.setScale( scale );
if ( electricFieldX > 0 ) {
x = -_viewBeadRadius + _viewMargin;
}
else {
x = _viewBeadRadius - negativeBounds.getWidth() - _viewMargin;
}
y = -negativeBounds.getHeight() / 2;
_negativeNode.setOffset( x, y );
}
}
示例11: 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 );
}
示例12: setScale
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
/**
* Terms scale about their center.
*/
public void setScale( double scale ) {
PBounds boundsBefore = getFullBounds();
super.setScale( scale );
PBounds boundsAfter = getFullBounds();
double xOffset = getXOffset() - ( ( boundsAfter.getWidth() - boundsBefore.getWidth() ) / 2 );
double yOffset = getYOffset() - ( ( boundsAfter.getHeight() - boundsBefore.getHeight() ) / 2 );
setOffset( xOffset, yOffset );
}
示例13: isBufferSmallerThanBounds
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
private boolean isBufferSmallerThanBounds(final PBounds bounds) {
return paintBuffer.getWidth() < bounds.getWidth() || paintBuffer.getHeight() < bounds.getHeight();
}
示例14: rebuildHUD
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
public synchronized void rebuildHUD() {
/*
* Here, we basically take our integral component coordinates and find out where (after our projection
* transformation) we should actually place the component. Usually it ends up with fractional coordinates.
* Since we want to keep the HUD node's offset as an integral number so that the HUD pixels map exactly to
* the screen pixels, we need to essentially compute the rectangle with integral coordinates that contains
* all of our non-integral transformed component (IE, offsetX, offsetY, hudWidth, hudHeight). We then
* position the HUD at those coordinates, and pass in the scale and slight offset so that our Graphics2D
* calls paint it at the precise sub-pixel location.
*/
// these are our stage bounds, relative to the SwingJMENode's location
PBounds localBounds = new PBounds( position.get().getX(), position.get().getY(), size.width, size.height );
// here we calculate our actual JME bounds
Rectangle2D transformedBounds = canvasTransform.getTransformedBounds( localBounds );
// for rendering the image, we need to know how much to scale it by
final double scaleX = transformedBounds.getWidth() / localBounds.getWidth();
final double scaleY = transformedBounds.getHeight() / localBounds.getHeight();
// find the largest integer offsets that allow us to cover the entire renderable area
final int offsetX = (int) Math.floor( transformedBounds.getMinX() ); // int truncation isn't good for the negatives here
final int offsetY = (int) Math.floor( transformedBounds.getMinY() );
// get how much we need to offset our rendered image by for sub-pixel accuracy (since we translate by offsetX/Y, we need to render at the difference)
final double imageOffsetX = transformedBounds.getMinX() - offsetX;
final double imageOffsetY = Math.ceil( transformedBounds.getMaxY() ) - transformedBounds.getMaxY(); // reversed Y handling
// how large our HUD node needs to be as a raster to render all of our content
final int hudWidth = ( (int) Math.ceil( transformedBounds.getMaxX() ) ) - offsetX;
final int hudHeight = ( (int) Math.ceil( transformedBounds.getMaxY() ) ) - offsetY;
// debugging for the translation image-offset issues
// if ( this instanceof PiccoloJMENode ) {
// PiccoloJMENode pthis = (PiccoloJMENode) this;
// PNode node = pthis.getNode();
// if ( node != null && node.getClass().getName().equals( "edu.colorado.phet.moleculeshapes.control.MoleculeShapesControlPanel" ) ) {
// System.out.println( "----" );
// System.out.println( "hash: " + node.hashCode() );
// System.out.println( "canvas: " + module.getCanvasSize() );
// System.out.println( "position: " + position.get() );
// System.out.println( "localBounds: " + localBounds );
// System.out.println( "transformedBounds: " + transformedBounds );
// System.out.println( "scales: " + scaleX + ", " + scaleY );
// System.out.println( "offsets: " + offsetX + ", " + offsetY );
// System.out.println( "image offsets: " + imageOffsetX + ", " + imageOffsetY );
// System.out.println( "hud dimension: " + hudWidth + ", " + hudHeight );
// System.out.println( "----" );
// }
// }
// create the new HUD node within the EDT
final HUDNode newHudNode = new HUDNode( component, hudWidth, hudHeight, new AffineTransform() {{
translate( imageOffsetX, imageOffsetY );
scale( scaleX, scaleY );
}}, inputHandler, tab, antialiased );
newHudNode.setLocalTranslation( offsetX, offsetY, 0 );
// do the rest of the work in the JME thread
JMEUtils.invoke( new Runnable() {
public void run() {
// ditch the old HUD node
if ( hudNode != null ) {
detachChild( hudNode );
hudNode.dispose();
}
// hook up new HUD node.
hudNode = newHudNode;
attachChild( newHudNode );
if ( ignoreInput ) {
hudNode.ignoreInput();
}
}
} );
}
示例15: getRandomPoint
import edu.umd.cs.piccolo.util.PBounds; //导入方法依赖的package包/类
private void getRandomPoint( PBounds bounds, Point2D pOutput ) {
double x = bounds.getX() + ( _randomCoordinate.nextDouble() * bounds.getWidth() );
double y = bounds.getY() + ( _randomCoordinate.nextDouble() * bounds.getHeight() );
pOutput.setLocation( x, y );
}