本文整理汇总了Java中org.piccolo2d.PCamera类的典型用法代码示例。如果您正苦于以下问题:Java PCamera类的具体用法?Java PCamera怎么用?Java PCamera使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PCamera类属于org.piccolo2d包,在下文中一共展示了PCamera类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: initialize
import org.piccolo2d.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:piccolo2d,项目名称:piccolo2d.java,代码行数:20,代码来源:CameraExample.java
示例2: initialize
import org.piccolo2d.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:piccolo2d,项目名称:piccolo2d.java,代码行数:24,代码来源:TwoCanvasExample.java
示例3: initialize
import org.piccolo2d.PCamera; //导入依赖的package包/类
public void initialize() {
final PSwingCanvas canvas = (PSwingCanvas) getCanvas();
final PLayer layer = canvas.getLayer();
final PCamera camera = canvas.getCamera();
PNode parent = new PNode();
parent.setPaint(Color.orange);
parent.setBounds(0, 0, 200, 200);
JButton button = new JButton("Drink Me");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(PSwingScaleExample.this, "Thank You");
}
});
final PSwing ps = new PSwing(button);
centerFullBoundsIn(ps, parent.getGlobalFullBounds());
parent.addChild(ps);
parent.scale(0.001);
layer.addChild(parent);
camera.animateViewToCenterBounds(ps.getGlobalFullBounds(), true, 0);
}
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:25,代码来源:PSwingScaleExample.java
示例4: setCamera
import org.piccolo2d.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:piccolo2d,项目名称:piccolo2d.java,代码行数:23,代码来源:PSWTCanvas.java
示例5: relocateHandle
import org.piccolo2d.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:piccolo2d,项目名称:piccolo2d.java,代码行数:29,代码来源:PSWTHandle.java
示例6: updateMarquee
import org.piccolo2d.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:piccolo2d,项目名称:piccolo2d.java,代码行数:21,代码来源:PSWTSelectionEventHandler.java
示例7: listenForCanvas
import org.piccolo2d.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:piccolo2d,项目名称:piccolo2d.java,代码行数:33,代码来源:PSwing.java
示例8: mousePressed
import org.piccolo2d.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:piccolo2d,项目名称:piccolo2d.java,代码行数:28,代码来源:PStyledTextEventHandler.java
示例9: isSelectable
import org.piccolo2d.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:piccolo2d,项目名称:piccolo2d.java,代码行数:31,代码来源:PSelectionEventHandler.java
示例10: animateCameraViewTransformTo
import org.piccolo2d.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:piccolo2d,项目名称:piccolo2d.java,代码行数:37,代码来源:PNavigationEventHandler.java
示例11: dragActivityStep
import org.piccolo2d.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:piccolo2d,项目名称:piccolo2d.java,代码行数:24,代码来源:PZoomEventHandler.java
示例12: testPick
import org.piccolo2d.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:piccolo2d,项目名称:piccolo2d.java,代码行数:25,代码来源:PPickPathTest.java
示例13: initialize
import org.piccolo2d.PCamera; //导入依赖的package包/类
public void initialize() {
PPath eacha = PPath.createRectangle(50, 50, 300, 300);
eacha.setPaint(Color.red);
getCanvas().getLayer().addChild(eacha);
eacha = PPath.createRectangle(-50, -50, 100, 100);
eacha.setPaint(Color.green);
getCanvas().getLayer().addChild(eacha);
eacha = PPath.createRectangle(350, 350, 100, 100);
eacha.setPaint(Color.green);
getCanvas().getLayer().addChild(eacha);
getCanvas().getCamera().addInputEventListener(new PBasicInputEventHandler() {
public void mousePressed(final PInputEvent event) {
if (!(event.getPickedNode() instanceof PCamera)) {
event.setHandled(true);
getCanvas().getCamera().animateViewToPanToBounds(event.getPickedNode().getGlobalFullBounds(), 500);
}
}
});
final PLayer layer = getCanvas().getLayer();
final Random random = new Random();
for (int i = 0; i < 1000; i++) {
final PPath each = PPath.createRectangle(0, 0, 100, 80);
each.scale(random.nextFloat() * 2);
each.offset(random.nextFloat() * 10000, random.nextFloat() * 10000);
each.setPaint(new Color(random.nextFloat(), random.nextFloat(), random.nextFloat()));
each.setStroke(new BasicStroke(1 + 10 * random.nextFloat()));
each.setStrokePaint(new Color(random.nextFloat(), random.nextFloat(), random.nextFloat()));
layer.addChild(each);
}
getCanvas().removeInputEventListener(getCanvas().getZoomEventHandler());
}
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:39,代码来源:PanToExample.java
示例14: initialize
import org.piccolo2d.PCamera; //导入依赖的package包/类
public void initialize() {
final PCanvas c = getCanvas();
final PLayer l = c.getLayer();
final PCamera cam = c.getCamera();
cam.scaleView(2.0);
final PPath path = PPath.createRectangle(0, 0, 100, 100);
l.addChild(path);
path.translate(100, 10);
path.scale(0.2);
cam.animateViewToCenterBounds(path.getGlobalFullBounds(), true, 1000);
}
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:14,代码来源:CenterExample.java
示例15: createBasicSceneGraph
import org.piccolo2d.PCamera; //导入依赖的package包/类
/**
* Builds the basic scene graph associated with this canvas. Developers may
* override this method to install their own layers, and cameras.
*
* @return PCamera viewing the freshly created scene
*/
public PCamera createBasicSceneGraph() {
final PRoot r = new PSWTRoot(this);
final PLayer l = new PLayer();
final PCamera c = new PCamera();
r.addChild(c);
r.addChild(l);
c.addLayer(l);
return c;
}
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:18,代码来源:PSWTCanvas.java
示例16: addStickyBoundsHandlesTo
import org.piccolo2d.PCamera; //导入依赖的package包/类
/**
* Adds sticky bounds handles to all corners and edges of the provided node
* and for display on the provided camera.
*
* @param node to decorate with bounds handles.
* @param camera camera onto which the handles should be stuck
*/
public static void addStickyBoundsHandlesTo(final PNode node, final PCamera camera) {
camera.addChild(new PSWTBoundsHandle(PBoundsLocator.createEastLocator(node)));
camera.addChild(new PSWTBoundsHandle(PBoundsLocator.createWestLocator(node)));
camera.addChild(new PSWTBoundsHandle(PBoundsLocator.createNorthLocator(node)));
camera.addChild(new PSWTBoundsHandle(PBoundsLocator.createSouthLocator(node)));
camera.addChild(new PSWTBoundsHandle(PBoundsLocator.createNorthEastLocator(node)));
camera.addChild(new PSWTBoundsHandle(PBoundsLocator.createNorthWestLocator(node)));
camera.addChild(new PSWTBoundsHandle(PBoundsLocator.createSouthEastLocator(node)));
camera.addChild(new PSWTBoundsHandle(PBoundsLocator.createSouthWestLocator(node)));
}
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:18,代码来源:PSWTBoundsHandle.java
示例17: testAddStickyBoundsHandlesToNodeAddsHandles
import org.piccolo2d.PCamera; //导入依赖的package包/类
public void testAddStickyBoundsHandlesToNodeAddsHandles() {
PCamera camera = new PCamera();
PSWTBoundsHandle.addStickyBoundsHandlesTo(node, camera);
assertEquals(0, node.getChildrenCount());
assertEquals(8, camera.getChildrenCount());
for (int i = 0; i < 8; i++) {
PNode child = camera.getChild(i);
assertTrue(child instanceof PSWTBoundsHandle);
}
}
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:12,代码来源:PSWTBoundsHandleTest.java
示例18: relocateHandle
import org.piccolo2d.PCamera; //导入依赖的package包/类
/**
* Force this handle to relocate itself using its locator.
*/
public void relocateHandle() {
if (locator == null) {
return;
}
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:piccolo2d,项目名称:piccolo2d.java,代码行数:33,代码来源:PHandle.java
示例19: addStickyBoundsHandlesTo
import org.piccolo2d.PCamera; //导入依赖的package包/类
/**
* Adds stick handles (always visible regardless of scale since they are
* attached to the camera) to the node provided.
*
* @param node node being extended with bounds handles
* @param camera camera onto which handles will appear
*/
public static void addStickyBoundsHandlesTo(final PNode node, final PCamera camera) {
camera.addChild(new PBoundsHandle(PBoundsLocator.createEastLocator(node)));
camera.addChild(new PBoundsHandle(PBoundsLocator.createWestLocator(node)));
camera.addChild(new PBoundsHandle(PBoundsLocator.createNorthLocator(node)));
camera.addChild(new PBoundsHandle(PBoundsLocator.createSouthLocator(node)));
camera.addChild(new PBoundsHandle(PBoundsLocator.createNorthEastLocator(node)));
camera.addChild(new PBoundsHandle(PBoundsLocator.createNorthWestLocator(node)));
camera.addChild(new PBoundsHandle(PBoundsLocator.createSouthEastLocator(node)));
camera.addChild(new PBoundsHandle(PBoundsLocator.createSouthWestLocator(node)));
}
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:18,代码来源:PBoundsHandle.java
示例20: cameraToLocal
import org.piccolo2d.PCamera; //导入依赖的package包/类
/**
* Transforms the given point from camera coordinates to the node's local
* system.
*
* @param camera camera from which coordinates are measured
* @param pt point to transform (will be modified)
* @param node node from which local coordinates are measured
*/
private void cameraToLocal(final PCamera camera, final Point2D pt, final PNode node) {
if (node != null) {
if (descendsFromLayer(node)) {
final AffineTransform inverse = invertTransform(camera.getViewTransform());
inverse.transform(pt, pt);
}
node.globalToLocal(pt);
}
}
开发者ID:piccolo2d,项目名称:piccolo2d.java,代码行数:19,代码来源:PSwingEventHandler.java
注:本文中的org.piccolo2d.PCamera类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论