/* * Panel3D.java */ import java.awt.*; /* 3D Panel */ public class Panel3D extends Panel implements Setting { int mode = -1; // -1: concave, 1: convex, 0: flat. int rinsets = 1; /** Initialize a Blank Concave 3D Panel */ public Panel3D() { setLayout(flow); setBackground(gray); } /** Initalize a Blank 3D Panel with mode setting */ public Panel3D(int _mode) { this(); mode = _mode;} /** Initalize a Blank 3D Panel with mode setting */ public Panel3D(int _mode, int _rinsets) { this(_mode); rinsets = _rinsets;} /** Insets setting */ public Insets insets() { int ofs = rinsets*depth; return new Insets(ofs, ofs, ofs, ofs); } public void repaint() { Graphics g = getGraphics(); if ( g == null ) return; paintAll(g); g.dispose(); } /* Draw 3D Rect Utility Method */ public void Draw3DRect(Graphics g, int depth, Color color) { Canvas3D.Draw3DRect(g, 0, 0, size().width, size().height, depth, color);} /** Call update when respont to a exposure */ public void paint(Graphics g) { update(g);} /** Respond to a repaint request */ public void update(Graphics g) { if ( g == null ) return; validate(); int w = size().width-d2; int h = size().height-d2; if ( mode < 0 ) { Draw3DRect(g, -depth, null); g.clipRect(depth, depth, w, h); } else if ( mode > 0 ) { Draw3DRect(g, depth, null); g.clipRect(depth, depth, w, h); } } /** Notify Parent Object */ public void Notify(Event ev, Object arg) { Component p = getParent(); while ( (p != null) && !p.action(ev, arg) ) p = p.getParent(); } }