001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: /**
018: * @author Alexey A. Petrenko
019: * @version $Revision$
020: */package java.awt.image;
021:
022: import java.awt.Graphics;
023: import java.awt.Graphics2D;
024: import java.awt.GraphicsConfiguration;
025: import java.awt.Image;
026: import java.awt.ImageCapabilities;
027: import java.awt.Transparency;
028:
029: /**
030: * Volatile image implementation
031: */
032: public abstract class VolatileImage extends Image
033: // Volatile image implements Transparency since 1.5
034: implements Transparency {
035: /***************************************************************************
036: *
037: * Constants
038: *
039: ***************************************************************************/
040:
041: public static final int IMAGE_INCOMPATIBLE = 2;
042:
043: public static final int IMAGE_OK = 0;
044:
045: public static final int IMAGE_RESTORED = 1;
046:
047: protected int transparency = OPAQUE;
048:
049: /***************************************************************************
050: *
051: * Constructors
052: *
053: ***************************************************************************/
054:
055: public VolatileImage() {
056: super ();
057: }
058:
059: /***************************************************************************
060: *
061: * Abstract methods
062: *
063: ***************************************************************************/
064:
065: public abstract boolean contentsLost();
066:
067: public abstract Graphics2D createGraphics();
068:
069: public abstract ImageCapabilities getCapabilities();
070:
071: public abstract int getHeight();
072:
073: public abstract BufferedImage getSnapshot();
074:
075: public abstract int getWidth();
076:
077: public abstract int validate(GraphicsConfiguration gc);
078:
079: /***************************************************************************
080: *
081: * Public methods
082: *
083: ***************************************************************************/
084:
085: @Override
086: public void flush() {
087: }
088:
089: @Override
090: public Graphics getGraphics() {
091: return createGraphics();
092: }
093:
094: @Override
095: public ImageProducer getSource() {
096: return getSnapshot().getSource();
097: }
098:
099: public int getTransparency() {
100: return transparency;
101: }
102: }
|