diff options
Diffstat (limited to 'NET/worlds/console/RenderCanvas.java')
| -rw-r--r-- | NET/worlds/console/RenderCanvas.java | 396 |
1 files changed, 396 insertions, 0 deletions
diff --git a/NET/worlds/console/RenderCanvas.java b/NET/worlds/console/RenderCanvas.java new file mode 100644 index 0000000..5d23a21 --- /dev/null +++ b/NET/worlds/console/RenderCanvas.java @@ -0,0 +1,396 @@ +/* */ package NET.worlds.console; +/* */ +/* */ import NET.worlds.scape.Camera; +/* */ import NET.worlds.scape.EventQueue; +/* */ import NET.worlds.scape.FrameEvent; +/* */ import NET.worlds.scape.LibraryDropTarget; +/* */ import NET.worlds.scape.Pilot; +/* */ import NET.worlds.scape.ToolTipManager; +/* */ import java.awt.Canvas; +/* */ import java.awt.Container; +/* */ import java.awt.Dimension; +/* */ import java.awt.Graphics; +/* */ import java.awt.IllegalComponentStateException; +/* */ import java.awt.Point; +/* */ import java.util.Enumeration; +/* */ import java.util.Vector; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public class RenderCanvas +/* */ extends Canvas +/* */ implements FramePart, LibraryDropTarget +/* */ { +/* */ private static final long serialVersionUID = -811200590685352009L; +/* */ DefaultConsole universeConsole; +/* */ private Window w; +/* */ private Dimension dim; +/* */ private Camera camera; +/* */ private int xRenderExtent; +/* */ private int yRenderExtent; +/* */ +/* */ public RenderCanvas(Dimension d) +/* */ { +/* 83 */ this(null, d); +/* */ } +/* */ +/* */ public RenderCanvas(DefaultConsole dc, Dimension d) { +/* 87 */ this.universeConsole = dc; +/* 88 */ this.dim = d; +/* */ +/* 90 */ this.overlays = new Vector(); +/* */ } +/* */ +/* */ +/* */ +/* */ public void drive() +/* */ { +/* 97 */ if ((this.w != null) && (Pilot.getActiveRoom() != null)) +/* 98 */ this.w.setDeltaMode(true); +/* */ } +/* */ +/* */ public boolean getDeltaMode() { +/* 102 */ if (this.w == null) { +/* 103 */ return false; +/* */ } +/* 105 */ return this.w.getDeltaMode(); +/* */ } +/* */ +/* */ +/* */ +/* */ public void activate(Console c, Container f, Console prev) {} +/* */ +/* */ +/* */ +/* */ public void deactivate() {} +/* */ +/* */ +/* */ public void setCamera(Camera cam) +/* */ { +/* 119 */ this.camera = cam; +/* 120 */ if (cam != null) { +/* 121 */ cam.setCanvas(this); +/* */ } +/* */ } +/* */ +/* */ public Camera getCamera() { +/* 126 */ return this.camera; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public Window getWindow() +/* */ { +/* 135 */ return this.w; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public void update(Graphics g) {} +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public void paint(Graphics g) {} +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public void setBounds(int x, int y, int width, int height) +/* */ { +/* 178 */ super.setBounds(x, y, width, height); +/* */ +/* */ +/* */ +/* 182 */ this.mayNeedToResize = true; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ public Dimension getMinimumSize() +/* */ { +/* 190 */ return this.dim; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ public Dimension getPreferredSize() +/* */ { +/* 198 */ return this.dim; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public void addOverlay(RenderCanvasOverlay overlay) +/* */ { +/* 208 */ assert (this.overlays != null); +/* 209 */ this.overlays.addElement(overlay); +/* 210 */ this.mayNeedToResize = true; +/* */ } +/* */ +/* */ public void removeOverlay(RenderCanvasOverlay overlay) { +/* 214 */ assert (this.overlays != null); +/* 215 */ this.overlays.removeElement(overlay); +/* 216 */ this.mayNeedToResize = true; +/* */ } +/* */ +/* */ private void computeOverlayDimensions() { +/* */ int minYPer; +/* 221 */ int minXPer = minYPer = 100; +/* 222 */ this.fullScreenOverlay = false; +/* */ +/* 224 */ Dimension size = getSize(); +/* */ +/* 226 */ if (this.overlays != null) { +/* 227 */ Enumeration<RenderCanvasOverlay> e = this.overlays.elements(); +/* 228 */ while (e.hasMoreElements()) { +/* 229 */ RenderCanvasOverlay o = (RenderCanvasOverlay)e.nextElement(); +/* */ +/* */ +/* */ +/* 233 */ o.canvasResized(size.width, size.height); +/* */ +/* 235 */ if (o.isFullscreen()) +/* */ { +/* */ +/* */ +/* 239 */ this.fullScreenOverlay = true; +/* 240 */ minXPer = minYPer = 0; +/* */ } +/* */ +/* 243 */ int ox = 100 - o.getXPercent(); +/* 244 */ int oy = 100 - o.getYPercent(); +/* */ +/* 246 */ if (ox < minXPer) +/* 247 */ minXPer = ox; +/* 248 */ if (oy < minYPer) { +/* 249 */ minYPer = oy; +/* */ } +/* */ } +/* */ } +/* */ +/* 254 */ if ((minXPer == 0) && (minYPer == 0)) +/* */ { +/* 256 */ this.xRenderExtent = (this.yRenderExtent = 0); +/* 257 */ } else if (minXPer == 0) +/* */ { +/* 259 */ this.xRenderExtent = size.width; +/* 260 */ this.yRenderExtent = ((int)(size.height * minYPer * 0.01D)); +/* 261 */ } else if (minYPer == 0) +/* */ { +/* 263 */ this.xRenderExtent = ((int)(size.width * minXPer * 0.01D)); +/* 264 */ this.yRenderExtent = size.height; +/* */ } +/* */ else { +/* 267 */ this.xRenderExtent = size.width; +/* 268 */ this.yRenderExtent = size.height; +/* */ } +/* */ } +/* */ +/* */ +/* 273 */ private boolean fullScreenOverlay = false; +/* */ +/* */ +/* */ private boolean mayNeedToResize; +/* */ +/* */ +/* */ private Vector<RenderCanvasOverlay> overlays; +/* */ +/* */ +/* */ public boolean handle(FrameEvent f) +/* */ { +/* 284 */ if (this.camera == null) { +/* 285 */ return true; +/* */ } +/* 287 */ if (!checkForWindow(true)) { +/* 288 */ return true; +/* */ } +/* 290 */ EventQueue.pollForEvents(this.camera); +/* */ +/* */ +/* 293 */ if (this.w == null) { +/* 294 */ return true; +/* */ } +/* 296 */ if (this.mayNeedToResize) { +/* 297 */ computeOverlayDimensions(); +/* */ +/* */ +/* 300 */ this.w.maybeResize(this.xRenderExtent, this.yRenderExtent); +/* */ +/* 302 */ if (Window.usingMicrosoftVMHacks()) +/* */ { +/* */ +/* 305 */ Point pt = getLocationOnScreen(); +/* 306 */ Dimension dim = getSize(); +/* 307 */ this.w.reShape(pt.x, pt.y, dim.width, dim.height); +/* */ } +/* */ +/* 310 */ this.mayNeedToResize = false; +/* */ } +/* */ +/* 313 */ if (this.camera != null) +/* 314 */ doRender(); +/* 315 */ return true; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public boolean checkForWindow(boolean interceptEvents) +/* */ { +/* 329 */ if (this.w == null) { +/* 330 */ String title = Console.getFrame().getTitle(); +/* 331 */ if (title == null) +/* 332 */ return false; +/* */ try { +/* 334 */ this.w = new Window(title, getLocationOnScreen(), getSize(), this.camera, +/* 335 */ interceptEvents); +/* */ } catch (IllegalComponentStateException e) { +/* 337 */ return false; +/* */ } catch (WindowNotFoundException e) { +/* 339 */ return false; +/* */ } +/* */ +/* 342 */ this.mayNeedToResize = false; +/* */ } +/* */ +/* 345 */ return true; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ private synchronized void doRender() +/* */ { +/* 353 */ if ((this.universeConsole != null) && (this.universeConsole.isUniverseMode())) { +/* 354 */ ToolTipManager.toolTipManager().killToolTip(); +/* 355 */ if (this.w != null) +/* 356 */ this.w.hideNativeWindow(); +/* 357 */ return; +/* */ } +/* */ +/* 360 */ ToolTipManager.toolTipManager().heartbeat(); +/* */ +/* 362 */ this.w.showNativeWindow(); +/* */ +/* */ +/* 365 */ if (this.fullScreenOverlay) { +/* 366 */ ToolTipManager.toolTipManager().killToolTip(); +/* 367 */ return; +/* */ } +/* */ +/* 370 */ this.camera.renderToCanvas(); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public void removeNotify() +/* */ { +/* 384 */ if (this.w != null) { +/* 385 */ this.w.dispose(); +/* 386 */ this.w = null; +/* */ } +/* 388 */ super.removeNotify(); +/* */ } +/* */ } + + +/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\console\RenderCanvas.class + * Java compiler version: 6 (50.0) + * JD-Core Version: 0.7.1 + */
\ No newline at end of file |