public void setViewport(Viewport _viewport) { if (_viewport != null) { // disconnect from old viewport _viewport.setContainer(null); } mViewport = _viewport; if (mViewport != null) { // connect to new Satellite mViewport.setContainer(this); // resize to show entire view of satellite Dimension size = mViewport.getPreferredSize(); setViewportSize(size); // resize the window to fit the image setSize( size.width + getInsets().left + getInsets().right + 2 * INSET, size.height + getInsets().top + getInsets().bottom + 2 * INSET); } }
public void dispose() { super.dispose(); if (mViewport != null) { mViewport.terminate(); mViewport = null; } setUniverse(null); if (mBackBufferGfx != null) { mBackBufferGfx.dispose(); } Logger.log("FramedViewportContainer terminated"); }
public void setViewportSize(Dimension _size) { mViewportSize = new Dimension(_size); int w = mViewportSize.width + 2 * INSET; int h = mViewportSize.height + 2 * INSET; // create an off screen buffer for drawing if (mBackBufferGfx != null) { mBackBufferGfx.dispose(); // free old one } mBackBufferImg = createImage(w, h); Logger.log("Create off-screen buffer of " + w + "x" + h + " (" + mBackBufferImg + ")"); mBackBufferGfx = mBackBufferImg.getGraphics(); // Determine the graphics context for the viewport mDrawGfx = mBackBufferGfx.create(INSET, INSET, mViewportSize.width, mViewportSize.height); mViewport.setActualSize(mViewportSize); Logger.log("Viewport resized"); }
public void doTimer(TimerTrigger tt) { mViewport.paint(mDrawGfx); repaint(); }