当前位置: 首页>>代码示例>>Java>>正文


Java PNode.addPropertyChangeListener方法代码示例

本文整理汇总了Java中edu.umd.cs.piccolo.PNode.addPropertyChangeListener方法的典型用法代码示例。如果您正苦于以下问题:Java PNode.addPropertyChangeListener方法的具体用法?Java PNode.addPropertyChangeListener怎么用?Java PNode.addPropertyChangeListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.umd.cs.piccolo.PNode的用法示例。


在下文中一共展示了PNode.addPropertyChangeListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ProbeWireNode

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
/**
 * Constructor.
 *
 * @param bodyNode
 * @param probeNode
 * @param bodyControlPointOffset  cubic control point for the end of the wire that connects to the body
 * @param probeControlPointOffset cubic control point for the end of the wire that connects to the probe
 * @param bodyConnectionOffset    wire connection point on the body, relative to the body's origin
 * @param probeConnectionOffset   wire connection point on the probe, relative to the probe's origin
 * @param color                   wire color
 */
public ProbeWireNode( PNode bodyNode, PNode probeNode, Point2D bodyControlPointOffset, Point2D probeControlPointOffset, Point2D bodyConnectionOffset, Point2D probeConnectionOffset, Color color ) {
    setPickable( false );
    setStroke( WIRE_STROKE );
    setStrokePaint( color );

    this.bodyNode = bodyNode;
    this.probeNode = probeNode;
    this.bodyControlPointOffset = bodyControlPointOffset;
    this.probeControlPointOffset = probeControlPointOffset;
    this.bodyConnectionOffset = bodyConnectionOffset;
    this.probeConnectionOffset = probeConnectionOffset;

    // update wire when body or probe moves
    {
        PropertyChangeListener fullBoundsListener = new PropertyChangeListener() {
            public void propertyChange( PropertyChangeEvent event ) {
                if ( event.getPropertyName().equals( PNode.PROPERTY_FULL_BOUNDS ) ) {
                    update();
                }
            }
        };
        bodyNode.addPropertyChangeListener( fullBoundsListener );
        probeNode.addPropertyChangeListener( fullBoundsListener );
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:37,代码来源:ProbeWireNode.java

示例2: BackgroundScreenNode

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public BackgroundScreenNode( EnergySkateParkSimulationPanel simulationPanel, BufferedImage backgroundImage, PNode floorGraphic ) {
    this.canvas = simulationPanel;
    this.backgroundImage = backgroundImage;
    this.floorGraphic = floorGraphic;

    floorGraphic.addPropertyChangeListener( PNode.PROPERTY_VISIBLE, new PropertyChangeListener() {
        public void propertyChange( PropertyChangeEvent evt ) {
            update();
        }
    } );
    simulationPanel.addListener( new EnergySkateParkSimulationPanel.Adapter() {
        public void zoomChanged() {
            update();
        }
    } );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:17,代码来源:BackgroundScreenNode.java

示例3: 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();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:27,代码来源:BufferedPNode.java

示例4: ControlPanelNode

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public ControlPanelNode( final PNode content, Color backgroundColor, BasicStroke borderStroke, Color borderColor, final int inset, final int arc, boolean transparifySwing ) {
    //Make sure the background resizes when the content resizes
    background = new PhetPPath( backgroundColor, borderStroke, borderColor ) {{
        final PropertyChangeListener updateSize = new PropertyChangeListener() {
            public void propertyChange( PropertyChangeEvent evt ) {
                final PBounds layoutSize = getControlPanelBounds( content );
                //Set the size of the border, subtracting out any local offset of the content node
                setPathTo( new RoundRectangle2D.Double( 0, 0, layoutSize.width + inset * 2, layoutSize.height + inset * 2, arc, arc ) );
            }
        };
        content.addPropertyChangeListener( PROPERTY_FULL_BOUNDS, updateSize );
        updateSize.propertyChange( null );
    }};
    // Create a node that puts the contents at the inset location
    // regardless of its initial offset.
    PNode insetContentNode = new ZeroOffsetNode( content ) {{
        setOffset( inset, inset );
    }};
    addChild( background );
    background.addChild( insetContentNode );
    if ( transparifySwing ) {
        transparifySwing( this );
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:25,代码来源:ControlPanelNode.java

示例5: NoBoundsWhenInvisible

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public NoBoundsWhenInvisible( PNode child ) {
    this.child = child;
    addChild( child );

    //When the child's visibility changes, recompute the bounds since they will probably change
    child.addPropertyChangeListener( PROPERTY_VISIBLE, new PropertyChangeListener() {
        public void propertyChange( PropertyChangeEvent evt ) {
            invalidateFullBounds();
        }
    } );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:12,代码来源:NoBoundsWhenInvisible.java

示例6: BarChartNodeAxisTitleLabelNode

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public BarChartNodeAxisTitleLabelNode( EatingAndExerciseCanvas canvas, StackedBarChartNode stackedBarChart, PNode parent ) {
    this.canvas = canvas;
    this.stackedBarChart = stackedBarChart;
    this.parent = parent;
    EatingAndExercisePText text = new EatingAndExercisePText( stackedBarChart.getTitle() );
    text.setFont( new PhetFont( 20, true ) );

    canvas.addComponentListener( new ComponentAdapter() {
        public void componentResized( ComponentEvent e ) {
            updateLayout();
            updateLayout();
        }
    } );

    parent.addPropertyChangeListener( PNode.PROPERTY_FULL_BOUNDS, new PropertyChangeListener() {
        public void propertyChange( PropertyChangeEvent evt ) {
            updateLayout();
            updateLayout();
        }
    } );

    updateLayout();
    updateLayout();

    backgroundCoverup = new PhetPPath( text.getFullBounds(), EatingAndExerciseConstants.BACKGROUND );
    addChild( backgroundCoverup );
    addChild( text );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:29,代码来源:BarChartNodeAxisTitleLabelNode.java

示例7: WireNode

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public WireNode( final PNode bodyNode, final PNode probeNode ) {
    setStroke( new BasicStroke( 8, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND, 1f ) );
    setStrokePaint( Color.GRAY );

    // Update when bounds of the body or probe change
    final PropertyChangeListener listener = new PropertyChangeListener() {
        public void propertyChange( PropertyChangeEvent evt ) {

            // connect to left center of body
            final double bodyConnectionX = bodyNode.getFullBoundsReference().getMinX();
            final double bodyConnectionY = bodyNode.getFullBounds().getCenterY();

            // connect to bottom center of probe
            final double probeConnectionX = probeNode.getFullBoundsReference().getCenterX();
            final double probeConnectionY = probeNode.getFullBoundsReference().getMaxY();

            // cubic curve
            final double controlPointOffset = 60;
            setPathTo( new CubicCurve2D.Double( bodyConnectionX, bodyConnectionY,
                                                bodyConnectionX - controlPointOffset, bodyConnectionY,
                                                probeConnectionX, probeConnectionY + controlPointOffset,
                                                probeConnectionX, probeConnectionY ) );
        }
    };
    probeNode.addPropertyChangeListener( PNode.PROPERTY_FULL_BOUNDS, listener );
    bodyNode.addPropertyChangeListener( PNode.PROPERTY_FULL_BOUNDS, listener );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:28,代码来源:ATDetectorNode.java

示例8: ConcentrationMeterNode

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public ConcentrationMeterNode( ConcentrationMeter meter, ConcentrationSolution solution, Dropper dropper,
                               PNode solutionNode, PNode stockSolutionNode, PNode solventFluidNode, PNode drainFluidNode ) {

    this.meter = meter;
    this.solution = solution;
    this.dropper = dropper;

    // nodes
    bodyNode = new BodyNode( meter );
    probeNode = new ProbeNode( meter, solutionNode, solventFluidNode, drainFluidNode, stockSolutionNode );
    PNode wireNode = new WireNode( probeNode, bodyNode );

    // rendering order
    addChild( wireNode );
    addChild( bodyNode );
    addChild( probeNode );

    //NOTE: layout is handled by child nodes observing model elements.

    // Update the meter value based on model changes
    RichSimpleObserver valueUpdater = new RichSimpleObserver() {
        public void update() {
            updateValue();
        }
    };
    valueUpdater.observe( meter.probe.location, solution.solute, solution.concentration );

    // Update the meter value based on changes to fluid shapes
    PropertyChangeListener boundsListener = new PropertyChangeListener() {
        public void propertyChange( PropertyChangeEvent evt ) {
            updateValue();
        }
    };
    solutionNode.addPropertyChangeListener( PNode.PROPERTY_FULL_BOUNDS, boundsListener );
    solventFluidNode.addPropertyChangeListener( PNode.PROPERTY_FULL_BOUNDS, boundsListener );
    drainFluidNode.addPropertyChangeListener( PNode.PROPERTY_FULL_BOUNDS, boundsListener );
    stockSolutionNode.addPropertyChangeListener( PNode.PROPERTY_FULL_BOUNDS, boundsListener );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:39,代码来源:ConcentrationMeterNode.java

示例9: WireNode

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public WireNode( final PNode probeNode, final PNode bodyNode ) {

            setStroke( new BasicStroke( 8, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND, 1f ) );
            setStrokePaint( Color.GRAY );

            final PropertyChangeListener updateCurve = new PropertyChangeListener() {
                public void propertyChange( PropertyChangeEvent evt ) {

                    // Connect bottom-center of body to right-center of probe.
                    Vector2D bodyConnectionPoint = new Vector2D( bodyNode.getFullBoundsReference().getCenterX(), bodyNode.getFullBoundsReference().getMaxY() - 10 );
                    Vector2D probeConnectionPoint = new Vector2D( probeNode.getFullBoundsReference().getMaxX(), probeNode.getFullBoundsReference().getCenterY() );

                    // control points
                    Vector2D c1Offset = new Vector2D( 0, BODY_CTRL_Y.evaluate( bodyNode.getFullBoundsReference().getCenterX() - probeNode.getFullBoundsReference().getX() ) );
                    Vector2D c2Offset = new Vector2D( 50, 0 );
                    Vector2D c1 = new Vector2D( bodyConnectionPoint.getX() + c1Offset.getX(), bodyConnectionPoint.getY() + c1Offset.getY() );
                    Vector2D c2 = new Vector2D( probeConnectionPoint.getX() + c2Offset.getX(), probeConnectionPoint.getY() + c2Offset.getY() );

                    // cubic curve
                    setPathTo( new CubicCurve2D.Double( bodyConnectionPoint.getX(), bodyConnectionPoint.getY(),
                                                        c1.getX(), c1.getY(),
                                                        c2.getX(), c2.getY(),
                                                        probeConnectionPoint.getX(), probeConnectionPoint.getY() ) );
                }
            };

            // Update when bounds of the body or probe changes.
            probeNode.addPropertyChangeListener( PNode.PROPERTY_FULL_BOUNDS, updateCurve );
            bodyNode.addPropertyChangeListener( PNode.PROPERTY_FULL_BOUNDS, updateCurve );
        }
 
开发者ID:mleoking,项目名称:PhET,代码行数:31,代码来源:ConcentrationMeterNode.java

示例10: propertyChange

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public void propertyChange( PropertyChangeEvent evt ) {
    PNode parent = jFreeChartNode.getParent();
    while ( parent != null ) {
        parent.removePropertyChangeListener( PNode.PROPERTY_TRANSFORM, updater );
        parent.removePropertyChangeListener( PNode.PROPERTY_PARENT, updateParent );
        parent.addPropertyChangeListener( PNode.PROPERTY_TRANSFORM, updater );
        parent.addPropertyChangeListener( PNode.PROPERTY_PARENT, updateParent );
        parent = parent.getParent();
        update();
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:12,代码来源:JFreeChartCursorNode.java

示例11: updateWatchList

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
private void updateWatchList() {
    clearWatchList();
    PNode node = _pswing;
    while ( node != null ) {
        node.addPropertyChangeListener( this );
        _watchList.add( node );
        node = node.getParent();
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:10,代码来源:AbstractHelpItem.java

示例12: Piccolo3DCanvas

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
/**
 * @param node The node to wrap within the canvas
 */
public Piccolo3DCanvas( PNode node ) {
    this.node = node;

    // make it see-through by default
    setOpaque( false );

    // disable the normal event handlers
    removeInputEventListener( getZoomEventHandler() );
    removeInputEventListener( getPanEventHandler() );

    // don't compromise quality by default, as this is a drop in the bucket now
    setAnimatingRenderQuality( PPaintContext.HIGH_QUALITY_RENDERING );
    setInteractingRenderQuality( PPaintContext.HIGH_QUALITY_RENDERING );

    // wrap it to maintain component bounds
    getLayer().addChild( new ZeroOffsetNode( node ) );

    // if our node changes bounds, update the underlying canvas size (so we can forward those events)
    node.addPropertyChangeListener( PNode.PROPERTY_FULL_BOUNDS, new PropertyChangeListener() {
        public void propertyChange( PropertyChangeEvent evt ) {
            updateSize();
        }
    } );

    updateSize();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:30,代码来源:Piccolo3DCanvas.java

示例13: ConnectorNode

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public ConnectorNode( PNode src, PNode dst ) {
    this.source = src;
    this.destination = dst;
    PropertyChangeListener changeHandler = new PropertyChangeListener() {
        public void propertyChange( PropertyChangeEvent evt ) {
            update();
        }
    };
    src.addPropertyChangeListener( PNode.PROPERTY_FULL_BOUNDS, changeHandler );
    dst.addPropertyChangeListener( PNode.PROPERTY_FULL_BOUNDS, changeHandler );
    update();
    setStrokePaint( Color.black );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:14,代码来源:ConnectorNode.java

示例14: BoundNode

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public BoundNode( PNode src, double insetX, double insetY ) {
    this.src = src;
    this.insetX = insetX;
    this.insetY = insetY;
    PropertyChangeListener listener = new PropertyChangeListener() {
        public void propertyChange( PropertyChangeEvent evt ) {
            update();
        }
    };
    src.addPropertyChangeListener( listener );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:12,代码来源:BoundNode.java

示例15: listenToNode

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
/**
 * Attach a property change listener to the specified node, if one has not
 * already been attached.
 * 
 * @param node the node to listen to for parent/pcamera/pcanvas changes
 */
private void listenToNode(final PNode node) {
    if (!isListeningTo(node)) {
        listeningTo.add(node);
        node.addPropertyChangeListener(PNode.PROPERTY_PARENT, parentListener);
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:13,代码来源:PSwing.java


注:本文中的edu.umd.cs.piccolo.PNode.addPropertyChangeListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。