001: /*
002: * Copyright (C) 2004 TiongHiang Lee
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2.1 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: *
018: * Email: thlee@onemindsoft.org
019: */
020:
021: package org.onemind.swingweb.image;
022:
023: import java.awt.Graphics;
024: import java.awt.Image;
025: import java.awt.image.ImageObserver;
026: import java.awt.image.ImageProducer;
027:
028: /**
029: * Swingweb implementation of the images
030: * @author TiongHiang Lee (thlee@onemindsoft.org)
031: *
032: */
033: public abstract class AbstractImage extends Image {
034:
035: /** the width **/
036: private int _width;
037:
038: /** the height **/
039: private int _height;
040:
041: /** the graphics **/
042: private Graphics _graphics;
043:
044: /**
045: * Constructor
046: * @param g the graphics
047: */
048: public AbstractImage(Graphics g) {
049: _graphics = g;
050: }
051:
052: /**
053: * {@inheritDoc}
054: */
055: public Graphics getGraphics() {
056: return _graphics;
057: }
058:
059: /**
060: * {@inheritDoc}
061: */
062: public void flush() {
063: // do nothing
064: }
065:
066: /**
067: * {@inheritDoc}
068: */
069: public ImageProducer getSource() {
070: return new DummyImageProducer(this );
071: }
072:
073: /**
074: * {@inheritDoc}
075: */
076: public Object getProperty(String name, ImageObserver observer) {
077: return null;
078: }
079:
080: /**
081: * Return the height
082: * @return the height.
083: */
084: public final int getHeight(ImageObserver observer) {
085: return _height;
086: }
087:
088: /**
089: * Return the width
090: * @return the width.
091: */
092: public final int getWidth(ImageObserver observer) {
093: return _width;
094: }
095:
096: /**
097: * Set the height
098: * @param height The height to set.
099: */
100: protected final void setHeight(int height) {
101: _height = height;
102: }
103:
104: /**
105: * Set the width
106: * @param width The width to set.
107: */
108: protected final void setWidth(int width) {
109: _width = width;
110: }
111: }
|