home *** CD-ROM | disk | FTP | other *** search
- package com.sfs.vrml;
-
- import java.awt.Canvas;
- import java.awt.Component;
- import java.awt.Dimension;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.util.Observable;
- import java.util.Observer;
-
- public abstract class Portal extends Canvas implements Observer {
- private Scene _scn;
- private Image _im;
- private Graphics _gr;
- private Dimension _dim;
-
- public Portal(Scene var1) {
- if (var1 == null) {
- throw new NullPointerException("null scene");
- } else {
- this._scn = var1;
- this._scn.addObserver(this);
- }
- }
-
- public void paint(Graphics var1) {
- this.update(var1);
- }
-
- public void update(Observable var1, Object var2) {
- if (var1 == this._scn) {
- ((Component)this).repaint();
- }
-
- }
-
- protected Scene getScene() {
- return this._scn;
- }
-
- public void update(Graphics var1) {
- Dimension var2 = ((Component)this).size();
- if (this._im == null || this._gr == null || this._dim == null || this._dim.height != var2.height || this._dim.width != var2.width) {
- this._dim = var2;
- this._im = ((Component)this).createImage(this._dim.width, this._dim.height);
- this._gr = this._im.getGraphics();
- }
-
- this._gr.setColor(((Component)this).getBackground());
- this._gr.fillRect(0, 0, this._dim.width, this._dim.height);
- this._gr.setColor(((Component)this).getForeground());
- this.paintScene(this._gr);
- var1.drawImage(this._im, 0, 0, this);
- }
-
- protected abstract void paintScene(Graphics var1);
- }
-