1 18 package org.apache.batik.ext.awt.image.rendered; 19 20 import java.awt.Rectangle ; 21 import java.awt.Shape ; 22 import java.awt.image.BufferedImage ; 23 import java.awt.image.ColorModel ; 24 import java.awt.image.Raster ; 25 import java.awt.image.RenderedImage ; 26 import java.awt.image.SampleModel ; 27 import java.awt.image.WritableRaster ; 28 import java.util.Vector ; 29 30 31 39 public class RenderedImageCachableRed implements CachableRed { 40 41 public static CachableRed wrap(RenderedImage ri) { 42 if (ri instanceof CachableRed) 43 return (CachableRed) ri; 44 if (ri instanceof BufferedImage ) 45 return new BufferedImageCachableRed((BufferedImage )ri); 46 return new RenderedImageCachableRed(ri); 47 } 48 49 private RenderedImage src; 50 private Vector srcs = new Vector (0); 51 52 public RenderedImageCachableRed(RenderedImage src) { 53 if(src == null){ 54 throw new IllegalArgumentException (); 55 } 56 this.src = src; 57 } 58 59 public Vector getSources() { 60 return srcs; } 62 63 public Rectangle getBounds() { 64 return new Rectangle (getMinX(), 65 getMinY(), 66 getWidth(), 67 getHeight()); 68 } 69 70 public int getMinX() { 71 return src.getMinX(); 72 } 73 public int getMinY() { 74 return src.getMinY(); 75 } 76 77 public int getWidth() { 78 return src.getWidth(); 79 } 80 public int getHeight() { 81 return src.getHeight(); 82 } 83 84 public ColorModel getColorModel() { 85 return src.getColorModel(); 86 } 87 88 public SampleModel getSampleModel() { 89 return src.getSampleModel(); 90 } 91 92 public int getMinTileX() { 93 return src.getMinTileX(); 94 } 95 public int getMinTileY() { 96 return src.getMinTileY(); 97 } 98 99 public int getNumXTiles() { 100 return src.getNumXTiles(); 101 } 102 public int getNumYTiles() { 103 return src.getNumYTiles(); 104 } 105 106 public int getTileGridXOffset() { 107 return src.getTileGridXOffset(); 108 } 109 110 public int getTileGridYOffset() { 111 return src.getTileGridYOffset(); 112 } 113 114 public int getTileWidth() { 115 return src.getTileWidth(); 116 } 117 public int getTileHeight() { 118 return src.getTileHeight(); 119 } 120 121 public Object getProperty(String name) { 122 return src.getProperty(name); 123 } 124 125 public String [] getPropertyNames() { 126 return src.getPropertyNames(); 127 } 128 129 public Raster getTile(int tileX, int tileY) { 130 return src.getTile(tileX, tileY); 131 } 132 133 public WritableRaster copyData(WritableRaster raster) { 134 return src.copyData(raster); 135 } 136 137 public Raster getData() { 138 return src.getData(); 139 } 140 141 public Raster getData(Rectangle rect) { 142 return src.getData(rect); 143 } 144 145 public Shape getDependencyRegion(int srcIndex, Rectangle outputRgn) { 146 throw new IndexOutOfBoundsException 147 ("Nonexistant source requested."); 148 } 149 150 public Shape getDirtyRegion(int srcIndex, Rectangle inputRgn) { 151 throw new IndexOutOfBoundsException 152 ("Nonexistant source requested."); 153 } 154 } 155 | Popular Tags |