private void ensureScale(final float range) { oldRange = range; final double d = (range) / Math.tan(Math.PI / 8); getViewPlatformTransformer().zoomTo(d); }
/** * Center the universe at the given point. */ public void centerAt(final Point3d p) { getViewPlatformTransformer().centerAt(p); }
/** * Rotate the universe, using the given axis of rotation and angle; The center * of rotation is the global center. * * @param axis The axis of rotation (in the image plate coordinate system) * @param angle The angle in radians. */ public void rotateUniverse(final Vector3d axis, final double angle) { viewTransformer.rotate(axis, angle); }
if (c != null && !c.isLocked()) contentTransformer.init(c, e.getX(), e .getY()); else viewTransformer.init(e); if (univ.ui.isPointTool()) { Content sel = c; if (shouldTranslate(mask)) { if (c != null && !c.isLocked()) contentTransformer.translate(e); else viewTransformer.translate(e); e.consume(); (InputEvent.BUTTON1_DOWN_MASK == (mask & InputEvent.BUTTON1_DOWN_MASK))) contentTransformer .rotate(e); else viewTransformer.rotate(e); e.consume(); viewTransformer.zoom(e); e.consume(); viewTransformer.wheel_zoom(e);
case KeyEvent.VK_RIGHT: if (c != null && !c.isLocked()) contentTransformer.translate(2, 0); else viewTransformer.translateXY(2, 0); return; case KeyEvent.VK_LEFT: if (c != null && !c.isLocked()) contentTransformer.translate(-2, 0); else viewTransformer.translateXY(-2, 0); return; case KeyEvent.VK_UP: if (c != null && !c.isLocked()) contentTransformer.translate(0, -2); else viewTransformer.translateXY(0, -2); return; case KeyEvent.VK_DOWN: if (c != null && !c.isLocked()) contentTransformer.translate(0, 2); else viewTransformer.translateXY(0, 2); return; switch (code) { case KeyEvent.VK_UP: viewTransformer.zoom(1); return; case KeyEvent.VK_DOWN: viewTransformer.zoom(-1); return; case KeyEvent.VK_RIGHT: if (c != null && !c.isLocked()) contentTransformer.rotate(5, 0); else viewTransformer.rotateY(-TWO_RAD); return;
/** * Reset the transformations of the view side of the scene graph as if the * Contents of this universe were just displayed. */ public void resetView() { fireTransformationStarted(); // rotate so that y shows downwards final Transform3D t = new Transform3D(); final AxisAngle4d aa = new AxisAngle4d(1, 0, 0, Math.PI); t.set(aa); getRotationTG().setTransform(t); t.setIdentity(); getTranslateTG().setTransform(t); getZoomTG().setTransform(t); recalculateGlobalMinMax(); getViewPlatformTransformer().centerAt(globalCenter); // reset zoom final double d = oldRange / Math.tan(Math.PI / 8); getViewPlatformTransformer().zoomTo(d); fireTransformationUpdated(); fireTransformationFinished(); }
/** * Convenience method which rotates the universe around the x-axis (regarding * the view, not the vworld) the specified amount of degrees (in rad). */ public void rotateX(final double rad) { viewTransformer.rotateX(rad); }
/** * This method should be called during the mouse is dragged, if the mouse * event should result in a rotation. * * @param e */ public void rotate(final MouseEvent e) { final int dx = xLast - e.getX(); final int dy = yLast - e.getY(); rotateXY(dy * ONE_RAD, dx * ONE_RAD); xLast = e.getX(); yLast = e.getY(); }
/** * Convenience method which rotates the universe around the y-axis (regarding * the view, not the vworld) the specified amount of degrees (in rad). */ public void rotateY(final double rad) { viewTransformer.rotateY(rad); fireTransformationUpdated(); }
viewTransformer = new InteractiveViewPlatformTransformer(this, this); contentTransformer = new ContentTransformer(this, this); picker = new Picker(this);
/** * Handle the alt arrow mouse events for zooming here because the * superclass does not do anything: zoom(1) * * @param ke the key event, e.g., arrow up. */ @Override protected void doProcess(KeyEvent ke) { if (ke.isAltDown()) { int code = ke.getKeyCode(); switch (code) { case KeyEvent.VK_UP: viewTransformer.zoomTo(.9); return; case KeyEvent.VK_DOWN: viewTransformer.zoomTo(1.1); return; } } else { super.doProcess(ke); } }
@Override public Boolean call() { // Now adjust universe view if (univ.autoAdjustView) { univ.getViewPlatformTransformer().centerAt(univ.globalCenter); final float range = (float) (univ.globalMax.x - univ.globalMin.x); univ.ensureScale(range); } // Notify listeners univ.waitForNextFrame(); univ.fireTransformationUpdated(); return true; } });
@Override public Content call() { synchronized (lock) { if (!addContentToScene(c)) return null; if (univ.autoAdjustView) { univ.getViewPlatformTransformer().centerAt(univ.globalCenter); final float range = (float) (univ.globalMax.x - univ.globalMin.x); univ.ensureScale(range); } } univ.fireContentAdded(c); univ.addUniverseListener(c); univ.waitForNextFrame(); univ.fireTransformationUpdated(); return c; } });
/** * Select the view at the selected Content. */ public void centerSelected(final Content c) { final Point3d center = new Point3d(); c.getContent().getCenter(center); final Transform3D localToVWorld = new Transform3D(); c.getContent().getLocalToVworld(localToVWorld); localToVWorld.transform(center); getViewPlatformTransformer().centerAt(center); }