001 package com.croftsoft.core.awt.image; 002 003 import java.awt.Graphics; 004 import java.awt.Graphics2D; 005 import java.awt.GraphicsConfiguration; 006 import java.awt.ImageCapabilities; 007 import java.awt.image.ImageObserver; 008 import java.awt.image.ImageProducer; 009 import java.awt.image.BufferedImage; 010 import java.awt.image.VolatileImage; 011 012 /********************************************************************* 013 * A Null Object implementation of VolatileImage. 014 * 015 * <p> 016 * Use wherever a placeholder VolatileImage or Image is needed. 017 * </p> 018 * 019 * @version 020 * 2002-12-18 021 * @since 022 * 2002-12-18 023 * @author 024 * <a href="https://www.croftsoft.com/">David Wallace Croft</a> 025 *********************************************************************/ 026 027 public final class NullVolatileImage 028 extends VolatileImage 029 ////////////////////////////////////////////////////////////////////// 030 ////////////////////////////////////////////////////////////////////// 031 { 032 033 public static final NullVolatileImage INSTANCE 034 = new NullVolatileImage ( ); 035 036 ////////////////////////////////////////////////////////////////////// 037 ////////////////////////////////////////////////////////////////////// 038 039 public boolean contentsLost ( ) 040 ////////////////////////////////////////////////////////////////////// 041 { 042 return true; 043 } 044 045 public Graphics2D createGraphics ( ) 046 ////////////////////////////////////////////////////////////////////// 047 { 048 return null; 049 } 050 051 public void flush ( ) 052 ////////////////////////////////////////////////////////////////////// 053 { 054 } 055 056 public ImageCapabilities getCapabilities ( ) 057 ////////////////////////////////////////////////////////////////////// 058 { 059 return null; 060 } 061 062 public Graphics getGraphics ( ) 063 ////////////////////////////////////////////////////////////////////// 064 { 065 return null; 066 } 067 068 public int getHeight ( ) 069 ////////////////////////////////////////////////////////////////////// 070 { 071 return 0; 072 } 073 074 public int getHeight ( ImageObserver imageObserver ) 075 ////////////////////////////////////////////////////////////////////// 076 { 077 return 0; 078 } 079 080 public Object getProperty ( 081 String name, 082 ImageObserver imageObserver ) 083 ////////////////////////////////////////////////////////////////////// 084 { 085 return null; 086 } 087 088 public BufferedImage getSnapshot ( ) 089 ////////////////////////////////////////////////////////////////////// 090 { 091 return null; 092 } 093 094 public ImageProducer getSource ( ) 095 ////////////////////////////////////////////////////////////////////// 096 { 097 return null; 098 } 099 100 public int getWidth ( ) 101 ////////////////////////////////////////////////////////////////////// 102 { 103 return 0; 104 } 105 106 public int getWidth ( ImageObserver imageObserver ) 107 ////////////////////////////////////////////////////////////////////// 108 { 109 return 0; 110 } 111 112 public int validate ( GraphicsConfiguration gc ) 113 ////////////////////////////////////////////////////////////////////// 114 { 115 return VolatileImage.IMAGE_INCOMPATIBLE; 116 } 117 118 ////////////////////////////////////////////////////////////////////// 119 ////////////////////////////////////////////////////////////////////// 120 121 private NullVolatileImage ( ) { }; 122 123 ////////////////////////////////////////////////////////////////////// 124 ////////////////////////////////////////////////////////////////////// 125 }