本文整理汇总了Java中edu.umd.cs.piccolo.PNode.toImage方法的典型用法代码示例。如果您正苦于以下问题:Java PNode.toImage方法的具体用法?Java PNode.toImage怎么用?Java PNode.toImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.umd.cs.piccolo.PNode
的用法示例。
在下文中一共展示了PNode.toImage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createImage
import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public static Image createImage() {
PNode parentNode = new PNode();
CalipersNode calipersNode = new CalipersNode( CALIPERS_CLOSED_SIZE );
calipersNode.open( 20 );
parentNode.addChild( calipersNode );
PNode handleNode = new HandleNode( HANDLE_SIZE );
parentNode.addChild( handleNode );
//TODO these 2 lines of code are duplicated from the constructor
calipersNode.setOffset( 0, 0 );
handleNode.setOffset( -handleNode.getFullBoundsReference().getWidth(), calipersNode.getFullBoundsReference().getMaxY() );
return parentNode.toImage();
}
示例2: createIcon
import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
/**
* Creates an icon to represent this node.
* The icon consists of a column of 3 vectors, left aligned.
* Vectors near the top are longer than vectors near the bottom.
*
* @return Icon
*/
public static Icon createIcon() {
PNode parentNode = new PNode();
VelocityVectorNode vectorNode;
final double ySpacing = 4;
vectorNode = new VelocityVectorNode( 30, 0, 1 );
vectorNode.setOffset( 0, 0 );
parentNode.addChild( vectorNode );
vectorNode = new VelocityVectorNode( 20, 0, 1 );
vectorNode.setOffset( 0, ySpacing );
parentNode.addChild( vectorNode );
vectorNode = new VelocityVectorNode( 10, 0, 1 );
vectorNode.setOffset( 0, 2 * ySpacing );
parentNode.addChild( vectorNode );
Image image = parentNode.toImage();
return new ImageIcon( image );
}
示例3: HoseIcon
import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
private JLabel HoseIcon( final WaterTowerModule module ) {
final int width = 60;
final int height = 14;
PNode node = new PNode() {{
final PhetPPath hosePart = new PhetPPath( new RoundRectangle2D.Double( 0, 0, width, height, 10, 10 ), Color.green, new BasicStroke( 1 ), Color.darkGray ) {{
//workaround the "edges get cut off in toImage" problem
setBounds( -1, -1, width + 2, height + 2 );
}};
addChild( hosePart );
addChild( new PImage( BufferedImageUtils.multiScaleToHeight( getRotatedImage( Images.NOZZLE, Math.PI / 2 ), (int) ( hosePart.getFullBounds().getHeight() + 4 ) ) ) {{
setOffset( hosePart.getFullBounds().getMaxX() - getFullBounds().getWidth() + 15, hosePart.getFullBounds().getCenterY() - getFullBounds().getHeight() / 2 );
}} );
}};
final ImageIcon imageIcon = new ImageIcon( node.toImage() );
//restore
// module.model.hose.enabled.set( enabled );
return new JLabel( imageIcon ) {{
addMouseListener( new MouseAdapter() {
@Override public void mousePressed( final MouseEvent e ) {
SimSharingManager.sendUserMessage( hoseCheckBoxIcon, icon, pressed, parameterSet( isSelected, !module.model.hose.enabled.get() ) );
module.model.hose.enabled.toggle();
}
} );
}};
}
示例4: createIcon
import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public static Icon createIcon( double width ) {
PNode parentNode = new PadBoundsNode();
LineFormsModel model = new SlopeInterceptModel();
model.interactiveLine.set( Line.createSlopeIntercept( 1, 2, 0 ) ); // bigger values will make slope tool look smaller in icon
// slope tool
SlopeToolNode slopeToolNode = new SlopeToolNode( model.interactiveLine, model.mvt );
parentNode.addChild( slopeToolNode );
// dashed line where the line would be, tweaked visually
PPath lineNode = new PPath( new Line2D.Double( slopeToolNode.getFullBoundsReference().getMinX() + ( 0.4 * slopeToolNode.getFullBoundsReference().getWidth() ), slopeToolNode.getFullBoundsReference().getMaxY(),
slopeToolNode.getFullBoundsReference().getMaxX(), slopeToolNode.getFullBoundsReference().getMinY() + ( 0.5 * slopeToolNode.getFullBoundsReference().getHeight() ) ) );
lineNode.setStroke( new BasicStroke( 1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 6, 6 }, 0 ) );
parentNode.addChild( lineNode );
// scale and convert to image
parentNode.scale( width / parentNode.getFullBoundsReference().getWidth() );
return new ImageIcon( parentNode.toImage() );
}
示例5: createImage
import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
private static Image createImage( EnergyProfile profile ) {
setMoleculeImages( profile );
Font font = new PhetFont( Font.BOLD, 18 );
PText plusA = new PText( "+" );
plusA.setTextPaint( Color.black );
plusA.setFont( font );
PNode pNode = new PNode();
pNode.addChild( aNode );
pNode.addChild( plusA );
pNode.addChild( bcNode );
plusA.setOffset( aNode.getFullBounds().getWidth() + 3,
( aNode.getFullBounds().getHeight() - plusA.getFullBounds().getHeight() ) / 2 );
bcNode.setOffset( plusA.getOffset().getX() + plusA.getFullBounds().getWidth() + 3,
( aNode.getFullBounds().getHeight() - bcNode.getFullBounds().getHeight() ) / 2 );
return pNode.toImage();
}
示例6: BufferedPNode
import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
/**
* Constructor.
*
* @param canvas the canvas, from which we get the transform using to draw rescaled node
* @param managedNode the node that we'll be buffering
*/
public BufferedPNode( final PhetPCanvas canvas, final PNode managedNode ) {
super();
this.managedNode = managedNode;
rescaledNode = new RescaledNode( canvas, managedNode.toImage() );
buffered = true;
addChild( managedNode );
managedNode.addPropertyChangeListener( new PropertyChangeListener() {
public void propertyChange( PropertyChangeEvent event ) {
// if the managed node's children change, we need a new scaling node
if ( event.getPropertyName() == PNode.PROPERTY_CHILDREN ) {//todo: should this use .equals comparison?
rescaledNode = new RescaledNode( canvas, managedNode.toImage() );
update();
}
}
} );
update();
}
示例7: addAlpha
import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
private void addAlpha( PNode nucleus, double radius, double pixelsPerFm ) {
PNode alphaParticle = new AlphaParticleNode();
alphaParticle.scale( pixelsPerFm );
PImage alphaParticleImage = new PImage( alphaParticle.toImage() );
setParticlePosition( radius, alphaParticleImage, pixelsPerFm );
nucleus.addChild( alphaParticleImage );
}
示例8: addNeutron
import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
private void addNeutron( PNode nucleus, double radius, double pixelsPerFm ) {
PNode neutron = new StandaloneNeutronNode();
neutron.scale( pixelsPerFm );
PImage neutronImage = new PImage( neutron.toImage() );
setParticlePosition( radius, neutronImage, pixelsPerFm );
nucleus.addChild( neutronImage );
}
示例9: addProton
import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
private void addProton( PNode nucleus, double radius, double pixelsPerFm ) {
PNode proton = new StandaloneProtonNode();
proton.scale( pixelsPerFm );
PImage protonImage = new PImage( proton.toImage() );
setParticlePosition( radius, protonImage, pixelsPerFm );
nucleus.addChild( protonImage );
}
示例10: NuclearReactorLegendPanel
import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public NuclearReactorLegendPanel() {
// Add the border around the legend.
BevelBorder baseBorder = (BevelBorder)BorderFactory.createRaisedBevelBorder();
TitledBorder titledBorder = BorderFactory.createTitledBorder( baseBorder,
NuclearPhysicsStrings.LEGEND_BORDER_LABEL,
TitledBorder.LEFT,
TitledBorder.TOP,
new PhetFont( Font.BOLD, 14 ),
Color.GRAY );
setBorder( titledBorder );
// Set the layout.
setLayout( new GridLayout(0, 2) );
// Add the images and labels for the simple portion of the legend.
PNode neutron = new StandaloneNeutronNode();
neutron.scale( PARTICLE_SCALE_FACTOR );
addLegendItem( neutron.toImage(), NuclearPhysicsStrings.NEUTRON_LEGEND_LABEL );
// Add the Uranium 235 nucleus to the legend.
// Add the Uranium 235 nucleus to the legend.
PNode labeledU235Nucleus = new LabeledNucleusImageNode("uranium-nucleus-small.png",
NuclearPhysicsStrings.URANIUM_235_ISOTOPE_NUMBER,
NuclearPhysicsStrings.URANIUM_235_CHEMICAL_SYMBOL,
NuclearPhysicsConstants.URANIUM_235_LABEL_COLOR );
Image u235Image = labeledU235Nucleus.toImage();
ImageIcon icon = new ImageIcon(u235Image);
add(new JLabel(icon));
add(new JLabel( NuclearPhysicsStrings.URANIUM_235_LEGEND_LABEL ) );
}
示例11: createImage
import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
/**
* Creates the image used to represent an alpha particle.
* @return Image
*/
public static final Image createImage() {
if ( IMAGE == null ) {
PNode parent = new PNode();
ProtonNode p1 = new ProtonNode();
ProtonNode p2 = new ProtonNode();
NeutronNode n1 = new NeutronNode();
NeutronNode n2 = new NeutronNode();
parent.addChild( p2 );
parent.addChild( n2 );
parent.addChild( p1 );
parent.addChild( n1 );
final double xOffset = ( 1 - OVERLAP ) * p1.getFullBounds().getWidth();
final double yOffset = ( 1 - OVERLAP ) * p1.getFullBounds().getHeight();
p1.setOffset( 0, 0 );
p2.setOffset( xOffset, yOffset );
n1.setOffset( xOffset, 0 );
n2.setOffset( 0, yOffset );
IMAGE = parent.toImage();
}
return IMAGE;
}
示例12: PhotonNode
import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
/**
* Use this constructor if you want to customize the sizes of the halo, orb and sparkle.
* @param wavelength
* @param haloDiameter
* @param orbDiameter
* @param sparkleDiameter
*/
public PhotonNode( double wavelength, double haloDiameter, double orbDiameter, double sparkleDiameter ) {
// assemble the components of the node
PNode parentNode = new PNode();
parentNode.addChild( new CircleNode( getHaloPaint( wavelength, haloDiameter ), haloDiameter ) );
parentNode.addChild( new CircleNode( getOrbPaint( wavelength, orbDiameter ), orbDiameter ) );
parentNode.addChild( new SparkleNode( getSparkleColor( wavelength, sparkleDiameter ), sparkleDiameter, SPARKLE_ANGLE ) );
// convert to image, center
PImage imageNode = new PImage( parentNode.toImage() );
addChild( imageNode );
imageNode.setOffset( -imageNode.getFullBoundsReference().getWidth() / 2,
-imageNode.getFullBoundsReference().getHeight() / 2 );
}
示例13: Molecule
import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
protected Molecule( PNode node, Element... elements ) {
this( node.toImage(), elements );
}
示例14: createIcon
import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public static Icon createIcon( Color color ) {
PNode node = new DipoleNode( new Property<Vector2D>( new Vector2D( 0.5, 0 ) ), color ) {
};
return new ImageIcon( node.toImage() );
}
示例15: ChainReactionLegendPanel
import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public ChainReactionLegendPanel() {
// Add the border around the legend.
BevelBorder baseBorder = (BevelBorder)BorderFactory.createRaisedBevelBorder();
TitledBorder titledBorder = BorderFactory.createTitledBorder( baseBorder,
NuclearPhysicsStrings.LEGEND_BORDER_LABEL,
TitledBorder.LEFT,
TitledBorder.TOP,
new PhetFont( Font.BOLD, 14 ),
Color.GRAY );
setBorder( titledBorder );
// Set the layout.
setLayout( new GridLayout(0, 2) );
// Add the images and labels for the simple portion of the legend.
PNode neutron = new StandaloneNeutronNode();
neutron.scale( PARTICLE_SCALE_FACTOR );
addLegendItem( neutron.toImage(), NuclearPhysicsStrings.NEUTRON_LEGEND_LABEL );
PNode proton = new StandaloneProtonNode();
proton.scale( PARTICLE_SCALE_FACTOR );
addLegendItem( proton.toImage(), NuclearPhysicsStrings.PROTON_LEGEND_LABEL );
// Add the Uranium 235 nucleus to the legend.
PNode labeledU235Nucleus = new LabeledNucleusImageNode("uranium-nucleus-small.png",
NuclearPhysicsStrings.URANIUM_235_ISOTOPE_NUMBER,
NuclearPhysicsStrings.URANIUM_235_CHEMICAL_SYMBOL,
NuclearPhysicsConstants.URANIUM_235_LABEL_COLOR );
Image u235Image = labeledU235Nucleus.toImage();
ImageIcon icon = new ImageIcon(u235Image);
add(new JLabel(icon));
add(new JLabel( NuclearPhysicsStrings.URANIUM_235_LEGEND_LABEL ) );
// Add the Uranium 238 nucleus to the legend.
PNode labeledU238Nucleus = new LabeledNucleusImageNode("uranium-nucleus-small.png",
NuclearPhysicsStrings.URANIUM_238_ISOTOPE_NUMBER,
NuclearPhysicsStrings.URANIUM_238_CHEMICAL_SYMBOL,
NuclearPhysicsConstants.URANIUM_238_LABEL_COLOR );
Image u238Image = labeledU238Nucleus.toImage();
icon = new ImageIcon(u238Image);
add(new JLabel(icon));
add(new JLabel( NuclearPhysicsStrings.URANIUM_238_LEGEND_LABEL ) );
// Add the Uranium 238 nucleus to the legend.
PNode labeledU239Nucleus = new LabeledNucleusImageNode("uranium-nucleus-small.png",
NuclearPhysicsStrings.URANIUM_239_ISOTOPE_NUMBER,
NuclearPhysicsStrings.URANIUM_239_CHEMICAL_SYMBOL,
NuclearPhysicsConstants.URANIUM_239_LABEL_COLOR );
Image u239Image = labeledU239Nucleus.toImage();
icon = new ImageIcon(u239Image);
add(new JLabel(icon));
add(new JLabel( NuclearPhysicsStrings.URANIUM_239_LEGEND_LABEL ) );
// Add the daughter nuclei to the legend.
addLegendItem( "daughter-nuclei-small.png", NuclearPhysicsStrings.DAUGHTER_NUCLEI_LABEL, 75 );
}