• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PCamera类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



PCamera类属于edu.umd.cs.piccolo包,在下文中一共展示了PCamera类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: mapLocation

import edu.umd.cs.piccolo.PCamera; //导入依赖的package包/类
/**
 * Maps the location (upper-left corner) of a PNode on a specified PCanvas to
 * the coordinate system of the parent help pane.
 *
 * @param node
 * @param canvas
 * @return
 */
public Point2D mapLocation( PNode node, PCanvas canvas ) {
    // Determine the node's location in canvas coordinates...
    int x = 0;
    int y = 0;
    {
        // Get the node's full bounds (union of its bounds and all children) in parent node's local coordinates
        Rectangle2D fullBounds = node.getFullBounds();
        // Get the node's global bounds - above the root node's transform, but below the canvas's view transform.
        Rectangle2D globalFullBounds = node.getParent().localToGlobal( fullBounds );

        //TODO: perhaps this code should transform this.globalToLocal(globalFullBounds) to identify the correct location.
        // Apply the canvas' view transform to get bounds in the canvas' coordinate system.
        PCamera camera = canvas.getCamera();
        PAffineTransform transform = camera.getViewTransformReference();
        Rectangle2D bounds = transform.transform( globalFullBounds, null );
        x = (int) bounds.getX();
        y = (int) bounds.getY();
    }

    // Convert the canvas location to a location in the help pane.
    Point2D helpPanePoint = SwingUtilities.convertPoint( canvas, x, y, _helpPane );
    return helpPanePoint;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:32,代码来源:AbstractHelpItem.java


示例2: initialize

import edu.umd.cs.piccolo.PCamera; //导入依赖的package包/类
public void initialize() {
    final PLayer l = new PLayer();
    final PPath n = PPath.createEllipse(0, 0, 100, 80);
    n.setPaint(Color.red);
    n.setStroke(null);
    PBoundsHandle.addBoundsHandlesTo(n);
    l.addChild(n);
    n.translate(200, 200);

    final PCamera c = new PCamera();
    c.setBounds(0, 0, 100, 80);
    c.scaleView(0.1);
    c.addLayer(l);
    PBoundsHandle.addBoundsHandlesTo(c);
    c.setPaint(Color.yellow);

    getCanvas().getLayer().addChild(l);
    getCanvas().getLayer().addChild(c);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:20,代码来源:CameraExample.java


示例3: initialize

import edu.umd.cs.piccolo.PCamera; //导入依赖的package包/类
public void initialize() {
    final PRoot root = getCanvas().getRoot();
    final PLayer layer = getCanvas().getLayer();

    final PNode n = PPath.createRectangle(0, 0, 100, 80);
    final PNode sticky = PPath.createRectangle(0, 0, 50, 50);
    PBoundsHandle.addBoundsHandlesTo(n);
    sticky.setPaint(Color.YELLOW);
    PBoundsHandle.addBoundsHandlesTo(sticky);

    layer.addChild(n);
    getCanvas().getCamera().addChild(sticky);

    final PCamera otherCamera = new PCamera();
    otherCamera.addLayer(layer);
    root.addChild(otherCamera);

    final PCanvas other = new PCanvas();
    other.setCamera(otherCamera);
    final PFrame result = new PFrame("TwoCanvasExample", false, other);
    result.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    result.setLocation(500, 100);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:24,代码来源:TwoCanvasExample.java


示例4: setCamera

import edu.umd.cs.piccolo.PCamera; //导入依赖的package包/类
/**
 * Set the camera associated with this canvas. All input events from this
 * canvas go through this camera. And this is the camera that paints this
 * canvas.
 * 
 * @param newCamera camera to attach to this canvas
 */
public void setCamera(final PCamera newCamera) {
    if (camera != null) {
        camera.setComponent(null);
    }

    camera = newCamera;

    if (camera != null) {
        camera.setComponent(this);

        final Rectangle swtRect = getBounds();

        camera.setBounds(new Rectangle2D.Double(swtRect.x, swtRect.y, swtRect.width, swtRect.height));
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:23,代码来源:PSWTCanvas.java


示例5: relocateHandle

import edu.umd.cs.piccolo.PCamera; //导入依赖的package包/类
/**
 * Force this handle to relocate itself using its locator.
 */
public void relocateHandle() {
    if (locator != null) {
        final PBounds b = getBoundsReference();
        final Point2D aPoint = locator.locatePoint(null);

        if (locator instanceof PNodeLocator) {
            final PNode located = ((PNodeLocator) locator).getNode();
            final PNode parent = getParent();

            located.localToGlobal(aPoint);
            globalToLocal(aPoint);

            if (parent != located && parent instanceof PCamera) {
                ((PCamera) parent).viewToLocal(aPoint);
            }
        }

        final double newCenterX = aPoint.getX();
        final double newCenterY = aPoint.getY();

        if (newCenterX != b.getCenterX() || newCenterY != b.getCenterY()) {
            centerBoundsOnPoint(newCenterX, newCenterY);
        }
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:29,代码来源:PSWTHandle.java


示例6: updateMarquee

import edu.umd.cs.piccolo.PCamera; //导入依赖的package包/类
/** {@inheritDoc} */
protected void updateMarquee(final PInputEvent pie) {
    super.updateMarquee(pie);

    final PBounds b = new PBounds();

    if (marqueeParent instanceof PCamera) {
        b.add(canvasPressPt);
        b.add(pie.getCanvasPosition());
    }
    else {
        b.add(pressPt);
        b.add(pie.getPosition());
    }

    marquee.setPathToRectangle((float) b.x, (float) b.y, (float) b.width, (float) b.height);
    b.reset();
    b.add(pressPt);
    b.add(pie.getPosition());
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:21,代码来源:PSWTSelectionEventHandler.java


示例7: listenForCanvas

import edu.umd.cs.piccolo.PCamera; //导入依赖的package包/类
/**
 * Attaches a listener to the specified node and all its parents to listen
 * for a change in the PSwingCanvas. Only PROPERTY_PARENT listeners are
 * added so this code wouldn't handle if a PLayer were viewed by a different
 * PCamera since that constitutes a child change.
 * 
 * @param node The child node at which to begin a parent-based traversal for
 *            adding listeners.
 */
private void listenForCanvas(final PNode node) {
    // need to get the full tree for this node
    PNode p = node;
    while (p != null) {
        listenToNode(p);

        final PNode parent = p;
        // System.out.println( "parent = " + parent.getClass() );
        if (parent instanceof PLayer) {
            final PLayer player = (PLayer) parent;
            // System.out.println( "Found player: with " +
            // player.getCameraCount() + " cameras" );
            for (int i = 0; i < player.getCameraCount(); i++) {
                final PCamera cam = player.getCamera(i);
                if (cam.getComponent() instanceof PSwingCanvas) {
                    updateCanvas((PSwingCanvas) cam.getComponent());
                    break;
                }
            }
        }
        p = p.getParent();
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:33,代码来源:PSwing.java


示例8: mousePressed

import edu.umd.cs.piccolo.PCamera; //导入依赖的package包/类
/**
 * A callback that is invoked any time the mouse is pressed on the canvas.
 * If the press occurs directly on the canvas, it create a new PStyledText
 * instance and puts it in editing mode. If the click is on a node, it marks
 * changes it to editing mode.
 * 
 * @param event mouse click event that can be queried
 */
public void mousePressed(final PInputEvent event) {
    final PNode pickedNode = event.getPickedNode();

    stopEditing(event);

    if (event.getButton() != MouseEvent.BUTTON1) {
        return;
    }

    if (pickedNode instanceof PStyledText) {
        startEditing(event, (PStyledText) pickedNode);
    }
    else if (pickedNode instanceof PCamera) {
        final PStyledText newText = createText();
        final Insets pInsets = newText.getInsets();
        newText.translate(event.getPosition().getX() - pInsets.left, event.getPosition().getY() - pInsets.top);
        startEditing(event, newText);
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:28,代码来源:PStyledTextEventHandler.java


示例9: isSelectable

import edu.umd.cs.piccolo.PCamera; //导入依赖的package包/类
/**
 * Determine if the specified node can be selected (i.e., if it is a child
 * of the one the list of nodes that can be selected).
 * 
 * @param node node being tested
 * @return true if node can be selected
 */
protected boolean isSelectable(final PNode node) {
    boolean selectable = false;

    final Iterator parentsIt = selectableParents.iterator();
    while (parentsIt.hasNext()) {
        final PNode parent = (PNode) parentsIt.next();
        if (parent.getChildrenReference().contains(node)) {
            selectable = true;
            break;
        }
        else if (parent instanceof PCamera) {
            for (int i = 0; i < ((PCamera) parent).getLayerCount(); i++) {
                final PLayer layer = ((PCamera) parent).getLayer(i);
                if (layer.getChildrenReference().contains(node)) {
                    selectable = true;
                    break;
                }
            }
        }
    }

    return selectable;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:31,代码来源:PSelectionEventHandler.java


示例10: animateCameraViewTransformTo

import edu.umd.cs.piccolo.PCamera; //导入依赖的package包/类
/**
 * Animates the camera's view transform into the provided one over the
 * duration provided.
 * 
 * @param camera camera being animated
 * @param targetTransform the transform to which the camera's transform will
 *            be animated
 * @param duration the number of milliseconds the animation should last
 * 
 * @return an activity object that represents the animation
 */
protected PActivity animateCameraViewTransformTo(final PCamera camera, final AffineTransform targetTransform,
        final int duration) {
    boolean wasOldAnimation = false;

    // first stop any old animations.
    if (navigationActivity != null) {
        navigationActivity.terminate();
        wasOldAnimation = true;
    }

    if (duration == 0) {
        camera.setViewTransform(targetTransform);
        return null;
    }

    final AffineTransform source = camera.getViewTransformReference();

    if (source.equals(targetTransform)) {
        return null;
    }

    navigationActivity = camera.animateViewToTransform(targetTransform, duration);
    navigationActivity.setSlowInSlowOut(!wasOldAnimation);
    return navigationActivity;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:37,代码来源:PNavigationEventHandler.java


示例11: dragActivityStep

import edu.umd.cs.piccolo.PCamera; //导入依赖的package包/类
/**
 * Updates the current zoom periodically, regardless of whether the mouse
 * has moved recently.
 * 
 * @param event contains information about the current state of the mouse
 */
protected void dragActivityStep(final PInputEvent event) {
    final PCamera camera = event.getCamera();
    final double dx = event.getCanvasPosition().getX() - getMousePressedCanvasPoint().getX();
    double scaleDelta = 1.0 + ZOOM_SENSITIVITY * dx;

    final double currentScale = camera.getViewScale();
    final double newScale = currentScale * scaleDelta;

    if (newScale < minScale) {
        scaleDelta = minScale / currentScale;
    }
    if (maxScale > 0 && newScale > maxScale) {
        scaleDelta = maxScale / currentScale;
    }

    camera.scaleViewAboutPoint(scaleDelta, viewZoomPoint.getX(), viewZoomPoint.getY());
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:24,代码来源:PZoomEventHandler.java


示例12: testPick

import edu.umd.cs.piccolo.PCamera; //导入依赖的package包/类
public void testPick() {
    final PCanvas canvas = new PCanvas();
    final PCamera camera = canvas.getCamera();
    final PLayer layer = canvas.getLayer();

    camera.setBounds(0, 0, 100, 100);

    final PNode a = PPath.createRectangle(0, 0, 100, 100);
    final PNode b = PPath.createRectangle(0, 0, 100, 100);
    final PNode c = PPath.createRectangle(0, 0, 100, 100);

    layer.addChild(a);
    layer.addChild(b);
    layer.addChild(c);

    final PPickPath pickPath = camera.pick(50, 50, 2);

    assertTrue(pickPath.getPickedNode() == c);
    assertTrue(pickPath.nextPickedNode() == b);
    assertTrue(pickPath.nextPickedNode() == a);
    assertTrue(pickPath.nextPickedNode() == camera);
    assertTrue(pickPath.nextPickedNode() == null);
    assertTrue(pickPath.nextPickedNode() == null);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:25,代码来源:PPickPathTest.java


示例13: doZoom

import edu.umd.cs.piccolo.PCamera; //导入依赖的package包/类
protected void doZoom(PInputEvent ref, PInputEvent now)
{
    PCamera camera = ((PCanvas) ref.getComponent()).getCamera();
    Point2D zoomPt = ref.getCanvasPosition();

    double dx = ((MouseEvent) ref.getSourceSwingEvent()).getX()
            - ((MouseEvent) now.getSourceSwingEvent()).getX();
    double scaleDelta = (1.0 + (0.001 * dx));
    double currentScale = camera.getViewScale();
    double newScale = currentScale * scaleDelta;

    if (newScale < getMinScale())
        scaleDelta = getMinScale() / currentScale;

    if ((getMaxScale() > 0) && (newScale > getMaxScale()))
        scaleDelta = getMaxScale() / currentScale;

    camera
            .scaleViewAboutPoint(scaleDelta, zoomPt.getX(), zoomPt
                    .getY());
    original = now;
}
 
开发者ID:hypergraphdb,项目名称:viewer,代码行数:23,代码来源:GraphView.java


示例14: isSelectable

import edu.umd.cs.piccolo.PCamera; //导入依赖的package包/类
/**
 * Determine if the specified node is selectable (i.e., if it is a child of
 * the one the list of selectable parents.
 */
protected boolean isSelectable(PNode node) {
	boolean selectable = false;
	for(PNode parent: selectableParents) {
		if (parent.getChildrenReference().contains(node)) {
			selectable = true;
			break;
		} else if (parent instanceof PCamera) {
			for (int i = 0; i < ((PCamera) parent).getLayerCount(); i++) {
				PLayer layer = ((PCamera) parent).getLayer(i);
				if (layer.getChildrenReference().contains(node)) {
					selectable = true;
					break;
				}
			}
		}
	}
	return selectable;
}
 
开发者ID:hypergraphdb,项目名称:viewer,代码行数:23,代码来源:PNodeSelectionHandler.java


示例15: setViewBounds

import edu.umd.cs.piccolo.PCamera; //导入依赖的package包/类
/**
    * Changes the view bounds of a camera with a smooth animation.
    */
protected void setViewBounds(PCamera camera, PBounds b) {
	if (!smoothPanning) {
		camera.setViewBounds(b);
	} else {
 		// The following allows a camera animation to start while another animation
 		// is already running.
 		if (isAnimatingPan()) {
 			currentCameraAnimation.terminate(PActivity.TERMINATE_WITHOUT_FINISHING);
 		}
			currentCameraAnimation = camera.animateViewToCenterBounds(b, true, 150);
			currentCameraAnimation.setSlowInSlowOut(false);
		// Play one step right now, otherwise nothing will happen while dragging the mouse since animations
 		// won't have time to play.
		currentCameraAnimation.setStartTime(System.currentTimeMillis() - currentCameraAnimation.getStepRate());
		currentCameraAnimation.processStep(System.currentTimeMillis());            		
	}
	}
 
开发者ID:jdfekete,项目名称:geneaquilt,代码行数:21,代码来源:SlidingController.java


示例16: mouseWheelRotated

import edu.umd.cs.piccolo.PCamera; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public void mouseWheelRotated(PInputEvent aEvent) {
    PCamera camera = aEvent.getCamera();
    double scaleDelta = (1.0 - (0.1 * aEvent.getWheelRotation()));

    double currentScale = camera.getViewScale();
    double newScale = currentScale * scaleDelta;
    
    if (newScale < getMinScale()) {
        scaleDelta = getMinScale() / currentScale;
    }
    if ((getMaxScale() > 0) && (newScale > getMaxScale())) {
        scaleDelta = getMaxScale() / currentScale;
    }

    camera.scaleViewAboutPoint(
            scaleDelta, 
            aEvent.getPosition().getX(), 
            aEvent.getPosition().getY());
}
 
开发者ID:jdfekete,项目名称:geneaquilt,代码行数:23,代码来源:MouseWheelZoomController.java


示例17: drawSelectedCell

import edu.umd.cs.piccolo.PCamera; //导入依赖的package包/类
/**
	 * Draws a slightly smaller, yellow background version of a cell in the given position
	 * @param cuid
	 * @param x
	 * @param y
	 */
	public void drawSelectedCell(long cuid, int x, int y){		
		if(!draggingCell){
			draggingCell=true;
			CCanvas canvas = CCanvasController.canvasdb.get(cuid);
			PCamera canvasCam =canvas.getContentCamera();		
//			canvasCam.removeChild(canvas.menuBar);
//			canvasCam.removeChild(canvas.topMenuBar);
			CCanvasController.loadCanvasImages(cuid);
			Image img = canvasCam.toImage(imgw-16, imgh-16, Color.YELLOW);	
			CCanvasController.unloadCanvasImages(cuid);
			
			pressedCellMainImage =  new PImage(img);
			
			pressedCellMainImage.setBounds(x-((imgw-24)/2), y-((imgh-24)/2), imgw-24, imgh-24);
			//pressedCellMainImage.setTransparency(CalicoOptions.group.background_transparency);
			CalicoDraw.setNodeTransparency(pressedCellMainImage, CalicoOptions.group.background_transparency);
			//getLayer().addChild(pressedCellMainImage);
			CalicoDraw.addChildToNode(getLayer(), pressedCellMainImage);
			cuidDraggedCanvas=cuid;			
		}
	}
 
开发者ID:uci-sdcl,项目名称:Calico,代码行数:28,代码来源:CGrid.java


示例18: drawSelectedCell

import edu.umd.cs.piccolo.PCamera; //导入依赖的package包/类
/**
		 * Draws a slightly smaller, yellow background version of a cell in the given position
		 * @param cuid
		 * @param x
		 * @param y
		 */
		private void drawSelectedCell(long cuid, int x, int y){		
//			if(!draggingCell){
				draggingCell=true;
				imgw = (int)(CanvasViewScrap.getDefaultWidth()*.5);
				imgh = (int)(CanvasViewScrap.getDefaultHeight()*.5);
				CCanvas canvas = CCanvasController.canvasdb.get(cuid);
				PCamera canvasCam =canvas.getContentCamera();		
//				canvasCam.removeChild(canvas.menuBar);
//				canvasCam.removeChild(canvas.topMenuBar);
				CCanvasController.loadCanvasImages(cuid);
				Image img = canvasCam.toImage(imgw-16, imgh-16, Color.white);
				img.getGraphics().drawRect(1, 1, img.getWidth(null) - 2, img.getHeight(null) - 2);
				CCanvasController.unloadCanvasImages(cuid);
				
				pressedCellMainImage =  new PImage(img);
				
				pressedCellMainImage.setBounds(x-((imgw-24)/2), y-((imgh-24)/2), imgw-24, imgh-24);
				//pressedCellMainImage.setTransparency(CalicoOptions.group.background_transparency);
//				CalicoDraw.setNodeTransparency(pressedCellMainImage, CalicoOptions.group.background_transparency);
				//getLayer().addChild(pressedCellMainImage);
//				CalicoDraw.addChildToNode(CCanvasController.canvasdb.get(canvas_uuid).getCamera(), pressedCellMainImage);
				CalicoDraw.addChildToNode(layer, pressedCellMainImage);
				cuidDraggedCanvas=cuid;			
//			}
		}
 
开发者ID:uci-sdcl,项目名称:Calico,代码行数:32,代码来源:CanvasTitlePanel.java


示例19: VIEWING_SINGLE_CANVAS

import edu.umd.cs.piccolo.PCamera; //导入依赖的package包/类
private static void VIEWING_SINGLE_CANVAS(CalicoPacket p)
	{
		p.rewind();
		p.getInt();
		long cuid = p.getLong();
		
//		CalicoInputManager.unregisterStickyItem(paletteBar);
		if (paletteBar == null)
		{
			paletteBar = new PaletteBar(PalettePlugin.getActivePalette());
			paletteBar.setVisible(false);
		}
		
		if (paletteBar.getParent() != null)
			paletteBar.getParent().removeChild(paletteBar);
		
		PCamera camera = CCanvasController.canvasdb.get(cuid).getCamera();
		camera.addChild(paletteBar);
		
		camera.repaintFrom(paletteBar.getBounds(), paletteBar);
	}
 
开发者ID:uci-sdcl,项目名称:Calico,代码行数:22,代码来源:PalettePlugin.java


示例20: nodeIsOnCanvas

import edu.umd.cs.piccolo.PCamera; //导入依赖的package包/类
private static boolean nodeIsOnCanvas( PNode node, PCanvas canvas ) {
    boolean found = false;
    PCamera camera = canvas.getCamera();
    int layerCount = camera.getLayerCount();
    for ( int i = 0; i < layerCount && found == false; i++ ) {
        found = node.isDescendentOf( camera.getLayer( i ) );
    }
    return found;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:10,代码来源:AbstractHelpItem.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java WSDLConstants类代码示例发布时间:2022-05-23
下一篇:
Java BeanFactoryAccessor类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap