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


Java PNode.setTransparency方法代码示例

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


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

示例1: LactoseTransportCanvas

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public LactoseTransportCanvas(LacOperonModel model) {
	
	super(model);
	
       // Add the cell membrane to the canvas.
       Rectangle2D cellMembraneRect = model.getCellMembraneRect();
   	Rectangle2D transformedCellMembraneRect = getMvt().createTransformedShape(cellMembraneRect).getBounds2D();
   	GradientPaint paint = new GradientPaint(0f, (float)transformedCellMembraneRect.getCenterY(), Color.WHITE,
   			0f, (float)transformedCellMembraneRect.getBounds2D().getMaxY(), new Color(255, 100, 100), true);
   	PNode cellMembrane = new PhetPPath(transformedCellMembraneRect, paint, new BasicStroke(2f), Color.BLACK);
   	cellMembrane.setTransparency(0.7f);
       PText cellMembraneLabel = new PText(GeneNetworkStrings.CELL_MEMBRANE_LABEL);
       cellMembraneLabel.setFont(new PhetFont(18, true));
       cellMembraneLabel.setOffset(getMvt().modelToViewXDouble(model.getInteriorMotionBounds().getMinX()), 
       		transformedCellMembraneRect.getCenterY() - cellMembraneLabel.getFullBoundsReference().height / 2); 
       cellMembrane.addChild(cellMembraneLabel);
       setCellMembraneNode(cellMembrane);
       
       // Add the DNA strand to the canvas.
       setDnaStrand(new DnaStrandNode(model.getDnaStrand(), getMvt(), getBackground()));

       // Add the tool box.
       setToolBox(new DnaSegmentToolboxWithLacYNode(this, model, getMvt()));
       
       // Add the lactose injector.
       LactoseInjectorNode lactoseInjector = new LactoseInjectorNode(model, getMvt(), 0);
       lactoseInjector.setOffset(50,
       		cellMembrane.getFullBoundsReference().getMinY() - lactoseInjector.getFullBoundsReference().height / 2 - 4);
       setLactoseInjector(lactoseInjector);
       
       // Add the legend.
       setLegend(new MacroMoleculeLegend(model, this, true));
       
       // Add the lactose meter.
       LactoseMeter lactoseMeter = new LactoseMeter(model);
       lactoseMeter.setOffset(-200, 250);
       setLactoseMeter(lactoseMeter);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:39,代码来源:LactoseTransportCanvas.java

示例2: update

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
private void update() {

        final double plateCharge = getPlateCharge();
        final int numberOfCharges = getNumberOfCharges( plateCharge, maxPlateCharge );

        // remove existing charges
        parentNode.removeAllChildren();

        // compute grid dimensions
        if ( numberOfCharges > 0 ) {

            final double zMargin = mvt.viewToModelDelta( new PositiveChargeNode().getFullBoundsReference().getWidth(), 0 ).getX();

            final double gridWidth = getContactWidth(); // contact between plate and dielectric
            final double gridDepth = getCapacitor().getPlateDepth() - ( 2 * zMargin );

            // grid dimensions
            Dimension gridSize = gridSizeStrategy.getGridSize( numberOfCharges, gridWidth, gridDepth );
            final int rows = gridSize.height;
            final int columns = gridSize.width;

            // distance between cells
            final double dx = gridWidth / columns;
            final double dz = gridDepth / rows;

            // offset to move us to the center of cells
            final double xOffset = dx / 2;
            final double zOffset = dz / 2;

            // populate the grid
            for ( int row = 0; row < rows; row++ ) {
                for ( int column = 0; column < columns; column++ ) {
                    // add a charge
                    PNode chargeNode = isPositivelyCharged() ? new PositiveChargeNode() : new NegativeChargeNode();
                    chargeNode.setTransparency( transparency );
                    parentNode.addChild( chargeNode );

                    // position the charge in cell in the grid
                    double x = getContactXOrigin() + xOffset + ( column * dx );
                    double y = 0;
                    double z = -( gridDepth / 2 ) + ( zMargin / 2 ) + zOffset + ( row * dz );
                    if ( numberOfCharges == 1 ) {
                        z -= dz / 6; //#2935, so that single charge is not obscured by wire connected to center of top plate
                    }
                    chargeNode.setOffset( mvt.modelToView( x, y, z ) );
                }
            }

            // debug output
            if ( DEBUG_OUTPUT_ENABLED ) {
                System.out.println( getClass().getName() + " " + numberOfCharges + " charges computed, " + ( rows * columns ) + " charges displayed" );
            }
        }
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:55,代码来源:PlateChargeNode.java

示例3: nodeDemo

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public void nodeDemo() {
    final PLayer layer = getCanvas().getLayer();
    final PNode aNode = PPath.createRectangle(0, 0, 100, 80);

    // A node needs to be a descendent of the root to be displayed on the
    // screen.
    layer.addChild(aNode);

    // The default color for a node is blue, but you can change that with
    // the setPaint method.
    aNode.setPaint(Color.red);

    // A node can have children nodes added to it.
    aNode.addChild(PPath.createRectangle(0, 0, 100, 80));

    // The base bounds of a node is easy to change. Note that changing the
    // base
    // bounds of a node will not change it's children.
    aNode.setBounds(-10, -10, 200, 110);

    // Each node has a transform that can be used to transform the node, and
    // all its children on the screen.
    aNode.translate(100, 100);
    aNode.scale(1.5);
    aNode.rotate(45);

    // The transparency of any node can be set, this transparency will be
    // applied to any of the nodes children as well.
    aNode.setTransparency(0.75f);

    // Its easy to copy nodes.
    final PNode aCopy = (PNode) aNode.clone();

    // Make is so that the copies children are not pickable. For this
    // example
    // that means you will not be able to grab the child and remove it from
    // its parent.
    aNode.setChildrenPickable(false);

    // Change the look of the copy
    aNode.setPaint(Color.GREEN);
    aNode.setTransparency(1.0f);

    // Let's add the copy to the root, and translate it so that it does not
    // cover the original node.
    layer.addChild(aCopy);
    aCopy.setOffset(0, 0);
    aCopy.rotate(-45);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:50,代码来源:NodeExample.java

示例4: nodeDemo

import edu.umd.cs.piccolo.PNode; //导入方法依赖的package包/类
public void nodeDemo() {
    final PLayer layer = getCanvas().getLayer();
    final PNode aNode = PPath.createRectangle(0, 0, 100, 80);

    // A node needs to be a descendent of the root to be displayed on the
    // screen.
    layer.addChild(aNode);

    // The default color for a node is blue, but you can change that with
    // the setPaint method.
    aNode.setPaint(Color.red);

    // A node can have children nodes added to it.
    aNode.addChild(PPath.createRectangle(0, 0, 100, 80));

    // The base bounds of a node is easy to change. Note that changing the
    // base bounds of a node will not change it's children.
    aNode.setBounds(-10, -10, 200, 110);

    // Each node has a transform that can be used to transform the node, and
    // all its children on the screen.
    aNode.translate(100, 100);
    aNode.scale(1.5);
    aNode.rotate(45);

    // The transparency of any node can be set, this transparency will be
    // applied to any of the nodes children as well.
    aNode.setTransparency(0.75f);

    // Its easy to copy nodes.
    final PNode aCopy = (PNode) aNode.clone();

    // Make is so that the copies children are not pickable. For this
    // example that means you will not be able to grab the child and remove
    // it from its parent.
    aNode.setChildrenPickable(false);

    // Change the look of the copy
    aNode.setPaint(Color.GREEN);
    aNode.setTransparency(1.0f);

    // Let's add the copy to the root, and translate it so that it does not
    // cover the original node.
    layer.addChild(aCopy);
    aCopy.setOffset(0, 0);
    aCopy.rotate(-45);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:48,代码来源:BirdsEyeViewExample.java


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