public void mouseWheelMoved( ViewPanel v, short wheelDirection, int jpx, int jpy, MouseWheelEvent e) { Camera c = application.vsm.getActiveCamera(); double a = (c.focal + Math.abs(c.altitude)) / c.focal; if (wheelDirection == WHEEL_UP) { c.altitudeOffset(-a * 5); application.vsm.repaint(); } else { // wheelDirection == WHEEL_DOWN c.altitudeOffset(a * 5); application.vsm.repaint(); } }
/** * Builds a new portal displaying what is seen through a camera and the region seen through * another camera. * * @param x top-left horizontal coordinate of portal, in parent's JPanel coordinates * @param y top-left vertical coordinate of portal, in parent's JPanel coordinates * @param w portal width * @param h portal height * @param pc camera associated with the portal (provinding the overview) * @param orc camera observing a region; this region is displayed as an overlay in the portal */ public OverviewPortal(int x, int y, int w, int h, Camera pc, Camera orc) { super(x, y, w, h, pc); this.observedRegionCamera = orc; this.observedRegionView = orc.getOwningView(); observedRegion = new double[4]; borderTimer = new Timer(); borderTimer.scheduleAtFixedRate(new BorderTimer(this), 40, 40); }
public void initTest(String vt) { eh = new TestDefaultHandler.EventHandlerTestDTH(this); vs = vsm.addVirtualSpace("src"); cam = vs.addCamera(); List<Camera> cameras = new ArrayList<Camera>(); cameras.add(cam); cam.setZoomFloor(-90); testView = vsm.addFrameView(cameras, "Test", vt, 800, 600, true); testView.setBackgroundColor(Color.LIGHT_GRAY); testView.setListener(eh); final Glyph circle = new VCircle(100, 0, 0, 40, Color.WHITE); cam.setAltitude(50); vs.addGlyph(circle); vsm.repaint(); AnimationManager am = vsm.getAnimationManager(); for (int i = 0; i < 4; ++i) { Animation anim = am.getAnimationFactory() .createAnimation( 3000, 1.0, Animation.RepeatBehavior.LOOP, circle, Animation.Dimension.POSITION, new DefaultTimingHandler() { public void timingEvent( float fraction, Object subject, Animation.Dimension dim) { Glyph g = (Glyph) subject; g.moveTo(100 - (double) 600 * fraction, 0); } }, new SplineInterpolator(0.7f, 0.1f, 0.3f, 0.9f)); am.startAnimation(anim, false); } Animation anim = am.getAnimationFactory() .createAnimation( 8000, 1.0, Animation.RepeatBehavior.LOOP, circle, Animation.Dimension.FILLCOLOR, new DefaultTimingHandler() { public void timingEvent(float fraction, Object subject, Animation.Dimension dim) { Glyph g = (Glyph) subject; g.setColor(new Color(0, 0, Float.valueOf(255 * fraction).intValue())); } }); am.startAnimation(anim, false); Animation animSize = am.getAnimationFactory() .createAnimation( 4000, 1.0, Animation.RepeatBehavior.LOOP, circle, Animation.Dimension.SIZE, new DefaultTimingHandler() { public void timingEvent(float fraction, Object subject, Animation.Dimension dim) { Glyph g = (Glyph) subject; g.sizeTo(40 + 60 * fraction); } }); am.startAnimation(animSize, false); }