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); }
@Override public void paint(Graphics2D g2d, int viewWidth, int viewHeight) { if (!visible) { return; } g2d.setClip(x, y, w, h); if (bkgColor != null) { g2d.setColor(bkgColor); g2d.fillRect(x, y, w, h); } standardStroke = g2d.getStroke(); // be sure to call the translate instruction before getting the standard transform // as the latter's matrix is preconcatenated to the translation matrix of glyphs // that use AffineTransforms for translation standardTransform = g2d.getTransform(); drawnGlyphs = cameraSpace.getDrawnGlyphs(camIndex); synchronized (drawnGlyphs) { drawnGlyphs.clear(); uncoef = (camera.focal + camera.altitude) / camera.focal; // compute region seen from this view through camera viewWC = camera.vx - (w / 2) * uncoef; viewNC = camera.vy + (h / 2) * uncoef; viewEC = camera.vx + (w / 2) * uncoef; viewSC = camera.vy - (h / 2) * uncoef; gll = cameraSpace.getDrawingList(); for (int i = 0; i < gll.length; i++) { if (gll[i] != null) { synchronized (gll[i]) { if (gll[i].visibleInViewport(viewWC, viewNC, viewEC, viewSC, camera)) { // if glyph is at least partially visible in the reg. seen from this view, display gll[i].project(camera, size); // an invisible glyph should still be projected if (gll[i].isVisible()) { // as it can be sensitive gll[i].draw(g2d, w, h, camIndex, standardStroke, standardTransform, x, y); } } } } } } // paint region observed through observedRegionCamera observedRegion = observedRegionView.getVisibleRegion(observedRegionCamera, observedRegion); g2d.setColor(observedRegionColor); orcoef = (float) (camera.focal / (camera.focal + camera.altitude)); if (acST != null) { g2d.setComposite(acST); g2d.fillRect( (int) (x + w / 2 + Math.round((observedRegion[0] - camera.vx) * orcoef)), (int) (y + h / 2 - Math.round((observedRegion[1] - camera.vy) * orcoef)), (int) Math.round((observedRegion[2] - observedRegion[0]) * orcoef), (int) Math.round((observedRegion[1] - observedRegion[3]) * orcoef)); g2d.setComposite(Translucent.acO); } g2d.drawRect( (int) (x + w / 2 + Math.round((observedRegion[0] - camera.vx) * orcoef)), (int) (y + h / 2 - Math.round((observedRegion[1] - camera.vy) * orcoef)), (int) Math.round((observedRegion[2] - observedRegion[0]) * orcoef), (int) Math.round((observedRegion[1] - observedRegion[3]) * orcoef)); // reset Graphics2D g2d.setClip(0, 0, viewWidth, viewHeight); if (borderColor != null) { g2d.setColor(borderColor); g2d.drawRect(x, y, w, h); } }