本文整理汇总了Java中edu.umd.cs.piccolo.event.PBasicInputEventHandler类的典型用法代码示例。如果您正苦于以下问题:Java PBasicInputEventHandler类的具体用法?Java PBasicInputEventHandler怎么用?Java PBasicInputEventHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PBasicInputEventHandler类属于edu.umd.cs.piccolo.event包,在下文中一共展示了PBasicInputEventHandler类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: main
import edu.umd.cs.piccolo.event.PBasicInputEventHandler; //导入依赖的package包/类
public static void main( String[] args ) {
new JFrame( "Test" ) {{
setContentPane( new PCanvas() {{
setPreferredSize( new Dimension( 800, 600 ) );
setPanEventHandler( null );
for ( int i = 0; i < 1000; i++ ) {
final int finalI = i;
getLayer().addChild( new PPath( new Ellipse2D.Double( 0, 0, 10, 10 ), null ) {{
setPaint( new Color( finalI % 255, 0, 0 ) );
translate( finalI / 10, finalI / 10 );
}} );
}
getLayer().addChild( new PPath( new Ellipse2D.Double( 0, 0, 200, 200 ), null ) {{
setPaint( Color.blue );
addInputEventListener( new PBasicInputEventHandler() {
@Override public void mouseDragged( final PInputEvent event ) {
translate( event.getCanvasDelta().width, event.getCanvasDelta().height );
}
} );
}} );
}} );
pack();
setDefaultCloseOperation( WindowConstants.EXIT_ON_CLOSE );
}}.setVisible( true );
}
开发者ID:mleoking,项目名称:PhET,代码行数:26,代码来源:ComparePiccolo.java
示例2: WorkEnergyRulerNode
import edu.umd.cs.piccolo.event.PBasicInputEventHandler; //导入依赖的package包/类
/**
* Constructor.
*
* @param transform - Model view transform.
* @param rulerModelOrigin - Origin point for the ruler - the ruler will be positioned such that the 0 tick
* mark on the right side is at this location in model space.
*/
public WorkEnergyRulerNode( final Property<Boolean> visibleProperty, ModelViewTransform2D transform, Point2D rulerModelOrigin ) {
visibleProperty.addObserver( new SimpleObserver() {
public void update() {
setVisible( visibleProperty.get() );
}
} );
final RulerNode rulerNode = new RulerNode( Math.abs( transform.modelToViewDifferentialYDouble( 5 ) ),
50, new String[] { "0", "1", "2", "3", "4", "5" }, "m", 4, 18 );
rulerNode.rotate( -Math.PI / 2 );
rulerNode.setOffset( transform.modelToViewXDouble( rulerModelOrigin.getX() ) - rulerNode.getFullBoundsReference().width - WorkEnergyObjectNode.AMOUNT_LINE_EXTENDS_BEYOND_OBJECT,
transform.modelToViewYDouble( rulerModelOrigin.getY() ) + rulerNode.getInsetWidth() );
addChild( rulerNode );
addInputEventListener( new CursorHandler() );
addInputEventListener( new PBasicInputEventHandler() {
@Override
public void mouseDragged( PInputEvent event ) {
PDimension delta = event.getDeltaRelativeTo( getParent() );
translate( delta.width, delta.height );
}
} );
}
开发者ID:mleoking,项目名称:PhET,代码行数:31,代码来源:WorkEnergyRulerNode.java
示例3: RampGraphic
import edu.umd.cs.piccolo.event.PBasicInputEventHandler; //导入依赖的package包/类
public RampGraphic( RampPanel rampPanel, Surface ramp ) {
super( rampPanel, ramp );
arrowGraphic = createArrowGraphic();
addChild( arrowGraphic );
getSurfaceGraphic().addInputEventListener( new PBasicInputEventHandler() {
public void mouseDragged( PInputEvent event ) {
arrowGraphic.setVisible( false );
}
} );
getSurface().addObserver( new SimpleObserver() {
public void update() {
arrowGraphic.setVisible( false );
}
} );
updateArrowGraphic();
}
开发者ID:mleoking,项目名称:PhET,代码行数:19,代码来源:RampGraphic.java
示例4: BodyGraphic
import edu.umd.cs.piccolo.event.PBasicInputEventHandler; //导入依赖的package包/类
public BodyGraphic() {
try {
imageGraphic = new PImage( ImageLoader.loadBufferedImage( "the-ramp/images/tape.gif" ) );
}
catch ( IOException e ) {
e.printStackTrace();
}
addChild( imageGraphic );
addInputEventListener( new PBasicInputEventHandler() {
public void mouseDragged( PInputEvent event ) {
Dimension2D dx = getDelta( event );
translateAll( dx.getWidth(), dx.getHeight() );
}
} );
int crossHairLength = 10;
CrossHairGraphic crossHairGraphic = new CrossHairGraphic( crossHairLength );
addChild( crossHairGraphic );
crossHairGraphic.setOffset( imageGraphic.getWidth() - crossHairLength / 2, imageGraphic.getHeight() - crossHairLength / 2 );
addInputEventListener( new CursorHandler( Cursor.HAND_CURSOR ) );
}
开发者ID:mleoking,项目名称:PhET,代码行数:23,代码来源:MeasuringTape.java
示例5: EndGraphic
import edu.umd.cs.piccolo.event.PBasicInputEventHandler; //导入依赖的package包/类
public EndGraphic() {
Ellipse2D.Double shape = new Ellipse2D.Double( 0, 0, 15, 15 );
phetShapeGraphic = new PPath( shape );
phetShapeGraphic.setPaint( Color.black );
addChild( phetShapeGraphic );
addInputEventListener( new PBasicInputEventHandler() {
public void mouseDragged( PInputEvent event ) {
Dimension2D dx = getDelta( event );
MeasuringTape.this.translateEndPoint( dx.getWidth(), dx.getHeight() );
}
} );
addInputEventListener( new CursorHandler( Cursor.HAND_CURSOR ) );
int crossHairSize = 10;
CrossHairGraphic crossHairGraphic = new CrossHairGraphic( crossHairSize );
crossHairGraphic.setPaint( Color.yellow );
addChild( crossHairGraphic );
crossHairGraphic.setOffset( phetShapeGraphic.getWidth() / 2 - crossHairSize / 2, phetShapeGraphic.getHeight() / 2 - crossHairSize / 2 );
}
开发者ID:mleoking,项目名称:PhET,代码行数:22,代码来源:MeasuringTape.java
示例6: SimSharingTestModule
import edu.umd.cs.piccolo.event.PBasicInputEventHandler; //导入依赖的package包/类
public SimSharingTestModule() {
super( "Test", new ConstantDtClock( 30 ) );
setSimulationPanel( new PhetPCanvas() {{
addScreenChild( new PhetPPath( new Rectangle2D.Double( 0, 0, 100, 100 ), Color.yellow, new BasicStroke( 2 ), Color.blue ) {{
addInputEventListener( new CursorHandler() );
addInputEventListener( new PBasicInputEventHandler() {
@Override public void mouseDragged( PInputEvent event ) {
position.set( position.get().plus( event.getDeltaRelativeTo( getParent() ) ) );
}
} );
position.addObserver( new VoidFunction1<Vector2D>() {
public void apply( Vector2D immutableVector2D ) {
setOffset( immutableVector2D.toPoint2D() );
}
} );
}} );
}} );
}
开发者ID:mleoking,项目名称:PhET,代码行数:19,代码来源:SimSharingTestModule.java
示例7: StoveControlSliderNode
import edu.umd.cs.piccolo.event.PBasicInputEventHandler; //导入依赖的package包/类
public StoveControlSliderNode( final SettableProperty<Double> value ) {
super( UserComponents.stoveSlider, -1, 1, 6, 75, value, new BooleanProperty( true ) );
// Show labels for add, zero, and remove.
addLabel( +1, new PhetPText( StatesOfMatterStrings.STOVE_CONTROL_PANEL_HEAT_LABEL, LABEL_FONT ) );
addLabel( 0.0, new TickMark() );
addLabel( -1, new PhetPText( StatesOfMatterStrings.STOVE_CONTROL_PANEL_COOL_LABEL, LABEL_FONT ) );
// Return to 0 when the user releases the slider.
addInputEventListener( new PBasicInputEventHandler() {
@Override public void mouseReleased( PInputEvent event ) {
value.set( 0.0 );
}
} );
// Show a gradient in the track that goes from orange to light blue to
// indicate the heat/coolness setting.
setTrackFillPaint( new GradientPaint( 0, 0, TOP_SIDE_TRACK_COLOR, 0, (float) trackLength, BOTTOM_SIDE_TRACK_COLOR, false ) );
}
开发者ID:mleoking,项目名称:PhET,代码行数:21,代码来源:StoveControlSliderNode.java
示例8: EvaporationControlNode
import edu.umd.cs.piccolo.event.PBasicInputEventHandler; //导入依赖的package包/类
public EvaporationControlNode( final Evaporator evaporator ) {
super( new HBox(
// Label
new PText( Strings.EVAPORATION ) {{
setFont( new PhetFont( BLLConstants.CONTROL_FONT_SIZE ) );
}},
// Slider
new HSliderNode( UserComponents.evaporationSlider, 0, evaporator.maxEvaporationRate, evaporator.evaporationRate, evaporator.enabled ) {{
// Tick labels
PhetFont tickFont = new PhetFont( BLLConstants.TICK_LABEL_FONT_SIZE );
addLabel( 0, new PhetPText( Strings.NONE, tickFont ) );
addLabel( evaporator.maxEvaporationRate, new PhetPText( Strings.LOTS, tickFont ) );
// Set rate to zero when slider is released.
this.addInputEventListener( new PBasicInputEventHandler() {
@Override public void mouseReleased( PInputEvent event ) {
evaporator.evaporationRate.set( 0.0 );
}
} );
}}
) );
}
开发者ID:mleoking,项目名称:PhET,代码行数:26,代码来源:EvaporationControlNode.java
示例9: CNode
import edu.umd.cs.piccolo.event.PBasicInputEventHandler; //导入依赖的package包/类
public CNode( final CModelElement modelElement ) {
super( modelElement.getSize(), modelElement.getColor() );
_modelElement = modelElement;
_modelElement.addListener( this );
addInputEventListener( new PBasicInputEventHandler() {
public void mouseDragged( PInputEvent event ) {
PDimension delta = event.getDeltaRelativeTo( CNode.this.getParent() );
Point2D p = _modelElement.getPosition();
Point2D pNew = new Point2D.Double( p.getX() + delta.getWidth(), p.getY() + delta.getHeight() );
modelElement.setPosition( pNew );
}
} );
positionChanged();
orientationChanged();
}
开发者ID:mleoking,项目名称:PhET,代码行数:19,代码来源:CNode.java
示例10: circle
import edu.umd.cs.piccolo.event.PBasicInputEventHandler; //导入依赖的package包/类
private PhetPPath circle( final IntegerProperty selectedPage, final int circleDiameter, final int index ) {
return new PhetPPath( new Ellipse2D.Double( 0, 0, circleDiameter, circleDiameter ), new BasicStroke( 2 ), Color.gray ) {{
selectedPage.addObserver( new VoidFunction1<Integer>() {
public void apply( final Integer integer ) {
setPaint( integer == index ? Color.black : BuildAFractionCanvas.TRANSPARENT );
}
} );
addInputEventListener( new CursorHandler() );
addInputEventListener( new PBasicInputEventHandler() {
@Override public void mouseReleased( final PInputEvent event ) {
SimSharingManager.sendButtonPressed( chain( carouselRadioButton, index ) );
selectedPage.set( index );
}
} );
}};
}
开发者ID:mleoking,项目名称:PhET,代码行数:18,代码来源:CarouselDotComponent.java
示例11: text
import edu.umd.cs.piccolo.event.PBasicInputEventHandler; //导入依赖的package包/类
private PhetPText text( final String levelName, final IntegerProperty selectedPage, final int index ) {
return new PhetPText( levelName, SettingsOnOffPanel.FONT ) {{
selectedPage.addObserver( new VoidFunction1<Integer>() {
public void apply( final Integer integer ) {
setTextPaint( integer == index ? Color.black : Color.gray );
}
} );
addInputEventListener( new CursorHandler() );
addInputEventListener( new PBasicInputEventHandler() {
@Override public void mouseReleased( final PInputEvent event ) {
SimSharingManager.sendButtonPressed( chain( carouselRadioButtonLabel, index ) );
selectedPage.set( index );
}
} );
}};
}
开发者ID:mleoking,项目名称:PhET,代码行数:17,代码来源:CarouselDotComponent.java
示例12: onNewBunny
import edu.umd.cs.piccolo.event.PBasicInputEventHandler; //导入依赖的package包/类
/**
* Handles a new bunny
*
* @param bunny The bunny
*/
public void onNewBunny( final Bunny bunny ) {
if ( !bunny.isAlive() ) {
// don't instantiate a dead bunny (loading config, etc)
return;
}
// create a bunny node with the correct visual appearance
BunnyNode bunnyNode = new BunnyNode( model, bunny.getColorPhenotype(), bunny.getTeethPhenotype(), bunny.getTailPhenotype(), this, bunny.getPosition() );
// randomly position the bunny
bunnyNode.setFlipped( !bunny.isMovingRight() );
// add the bunny
addSprite( bunnyNode );
bunny.addListener( bunnyNode );
sprites.add( bunnyNode );
bunnies.add( bunnyNode );
bunnyNode.addInputEventListener( new PBasicInputEventHandler() {
@Override
public void mouseClicked( PInputEvent event ) {
bunny.setSelected( true );
notifyBunnySelected( bunny );
}
} );
}
开发者ID:mleoking,项目名称:PhET,代码行数:31,代码来源:LandscapeNode.java
示例13: RotationRulerNode
import edu.umd.cs.piccolo.event.PBasicInputEventHandler; //导入依赖的package包/类
public RotationRulerNode( double distanceBetweenFirstAndLastTick, double height, String[] majorTickLabels, String units, int numMinorTicksBetweenMajors, int fontSize ) {
super( distanceBetweenFirstAndLastTick, 14 * 3.0 / 200.0, height, majorTickLabels, new PhetFont( 14 ), units, new PhetFont( 14 ), numMinorTicksBetweenMajors, height * 0.4 / 2, height * 0.2 / 2 );
setBackgroundPaint( new Color( 236, 225, 113, 150 ) );
setBackgroundStroke( new BasicStroke( (float) RotationPlayAreaNode.SCALE ) );
setTickStroke( new BasicStroke( (float) RotationPlayAreaNode.SCALE ) );
setUnitsSpacing( 3 * RotationPlayAreaNode.SCALE );
setFontScale( RotationPlayAreaNode.SCALE );
addInputEventListener( new CursorHandler() );
addInputEventListener( new PBasicInputEventHandler() {
public void mouseDragged( PInputEvent event ) {
PDimension delta = event.getDeltaRelativeTo( getParent() );
translate( delta.width,
-delta.height );//Y-axis is inverted
}
} );
}
开发者ID:mleoking,项目名称:PhET,代码行数:18,代码来源:RotationRulerNode.java
示例14: LimbNode
import edu.umd.cs.piccolo.event.PBasicInputEventHandler; //导入依赖的package包/类
public LimbNode( String imageLoc, Point pivot ) {
imageNode = PImageFactory.create( imageLoc );
addChild( imageNode );
highlight = new HighlightNode( imageNode.getImage() );
addChild( highlight );
addInputEventListener( new PBasicInputEventHandler() {
public void mousePressed( PInputEvent event ) {
super.mousePressed( event );
if ( highlight.getVisible() ) {
highlight.setVisible( false );
removeChild( highlight );
}
}
} );
this.pivot = pivot;
addInputEventListener( new RotationHandler( this ) );
addInputEventListener( new CursorHandler() );
}
开发者ID:mleoking,项目名称:PhET,代码行数:19,代码来源:LimbNode.java
示例15: addWiggleMe
import edu.umd.cs.piccolo.event.PBasicInputEventHandler; //导入依赖的package包/类
private void addWiggleMe() {
if ( _wiggleMe == null ) {
// Wiggle Me that points at the eigenstates
String wiggleMeString = BSResources.getString( "wiggleMe.eigenstates" );
_wiggleMe = new DefaultWiggleMe( _canvas, wiggleMeString );
_parentNode.addChild( _wiggleMe );
_wiggleMe.setOffset( 250, -50 );
_wiggleMe.animateTo( 250, 250 );
_wiggleMe.addInputEventListener( new PBasicInputEventHandler() {
// Clicking on the wiggle me makes it go away.
public void mousePressed( PInputEvent event ) {
disableWiggleMe();
}
} );
}
}
开发者ID:mleoking,项目名称:PhET,代码行数:17,代码来源:BSAbstractModule.java
示例16: SpatialSimpleMoleculeGraphic
import edu.umd.cs.piccolo.event.PBasicInputEventHandler; //导入依赖的package包/类
/**
* @param molecule
* @param profile
*/
public SpatialSimpleMoleculeGraphic( SimpleMolecule molecule, EnergyProfile profile ) {
super( molecule, profile );
this.molecule = molecule;
this.profile = profile;
// Catch mouse clicks that select this graphic's molecule
if( molecule instanceof MoleculeA || molecule instanceof MoleculeC ) {
this.addInputEventListener( new PBasicInputEventHandler() {
public void mouseClicked( PInputEvent event ) {
super.mouseClicked( event );
getMolecule().setSelectionStatus( Selectable.SELECTED );
}
} );
}
if( DebugFlags.SHOW_BOUNDING_BOX ) {
boundingBox = new PPath();
boundingBox.setStrokePaint( Color.red );
addChild( boundingBox );
update();
}
}
开发者ID:mleoking,项目名称:PhET,代码行数:28,代码来源:SpatialSimpleMoleculeGraphic.java
示例17: createWiggleMe
import edu.umd.cs.piccolo.event.PBasicInputEventHandler; //导入依赖的package包/类
/**
* Add a wiggle-me that will go away when the user clicks on the red knob
*/
private void createWiggleMe() {
final PhetPCanvas pCanvas = getCanvas();
final MotionHelpBalloon wiggleMe = new MotionHelpBalloon( pCanvas, MRConfig.RESOURCES.getLocalizedString( "messages.invitation" ) );
wiggleMe.setOffset( 0, 0 );
wiggleMe.setBalloonFillPaint( new Color( 255, 255, 100 ) );
wiggleMe.setBalloonVisible( true );
wiggleMe.setBalloonStroke( new BasicStroke( 1 ) );
pCanvas.addWorldChild( wiggleMe );
wiggleMe.setVisible( true );
wiggleMe.animateTo( launcher.getRestingTipLocation().getX() - wiggleMe.getFullBounds().getWidth() - 15,
launcher.getRestingTipLocation().getY() + 85 );
launcherGraphic.addInputEventListener( new PBasicInputEventHandler() {
public void mousePressed( PInputEvent event ) {
super.mousePressed( event );
launcherGraphic.removeInputEventListener( this );
pCanvas.removeWorldChild( wiggleMe );
}
} );
}
开发者ID:mleoking,项目名称:PhET,代码行数:23,代码来源:SimpleModule.java
示例18: WiggleMeInSpace
import edu.umd.cs.piccolo.event.PBasicInputEventHandler; //导入依赖的package包/类
public WiggleMeInSpace( final AbstractEnergySkateParkModule module ) {
this.module = module;
hintNode = new MotionHelpBalloon( module.getDefaultHelpPane(), EnergySkateParkResources.getString( "invitaiton.arrow-keys" ) );
hintNode.setTextColor( Color.white );
hintNode.setShadowTextColor( Color.darkGray );
hintNode.setShadowTextOffset( 1 );
module.getEnergySkateParkModel().addEnergyModelListener( new EnergySkateParkModel.EnergyModelListenerAdapter() {
public void gravityChanged() {
if ( module.getEnergySkateParkModel().getGravity() == 0.0 && !hintDone ) {
startHint();
}
else {
closeHint();
}
}
} );
hintNode.addInputEventListener( new PBasicInputEventHandler() {
public void mousePressed( PInputEvent event ) {
super.mousePressed( event );
hintNode.setVisible( false );
}
} );
}
开发者ID:mleoking,项目名称:PhET,代码行数:24,代码来源:WiggleMeInSpace.java
示例19: TrackButton
import edu.umd.cs.piccolo.event.PBasicInputEventHandler; //导入依赖的package包/类
public TrackButton( final EnergySkateParkBasicsModule module, final String trackName, final Vector2D offset ) {
PImage image = new PImage( createIcon( module, trackName, offset ) );
addChild( image );
final PPath selectedIndicator = new PhetPPath( image.getFullBoundsReference().getBounds2D(), new BasicStroke( 3 ), INVISIBLE_COLOR );
addChild( selectedIndicator );
//When pressed, load the track
addInputEventListener( new CursorHandler() );
addInputEventListener( new PBasicInputEventHandler() {
@Override public void mousePressed( PInputEvent event ) {
SimSharingManager.sendUserMessage( chain( trackButton, trackName ), UserComponentTypes.button, pressed, ParameterSet.parameterSet( EnergySkateParkSimSharing.ParameterKeys.trackName, trackName ) );
module.loadTrack( trackName, offset );
}
} );
//When selected, turn on highlight.
module.currentTrackFileName.addObserver( new VoidFunction1<String>() {
public void apply( String fileName ) {
selectedIndicator.setStrokePaint( fileName.equalsIgnoreCase( trackName ) ? Color.YELLOW : INVISIBLE_COLOR );
}
} );
}
开发者ID:mleoking,项目名称:PhET,代码行数:24,代码来源:TrackButton.java
示例20: ControlPointNode
import edu.umd.cs.piccolo.event.PBasicInputEventHandler; //导入依赖的package包/类
public ControlPointNode( int index_ ) {
this.index = index_;
controlPoint = new PhetPPath( new Color( 255, 50, 50, 128 ), new BasicStroke( 0.01f ), Color.black );
double w = 0.10;
controlPoint.setPathTo( new Ellipse2D.Double( -w / 2, -w / 2, w, w ) );
addChild( controlPoint );
controlPoint.addInputEventListener( new PBasicInputEventHandler() {
public void mouseDragged( PInputEvent event ) {
parametricFunction2D.translateControlPoint( index, event.getDeltaRelativeTo( CubicSpline2DNode.this ).width,
event.getDeltaRelativeTo( CubicSpline2DNode.this ).height );
}
} );
addChild( controlPoint );
update();
}
开发者ID:mleoking,项目名称:PhET,代码行数:20,代码来源:CubicSpline2DNode.java
注:本文中的edu.umd.cs.piccolo.event.PBasicInputEventHandler类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论