1 18 package org.apache.batik.ext.awt.image.rendered; 19 20 21 import java.awt.Rectangle ; 22 import java.awt.image.Raster ; 23 import java.awt.image.WritableRaster ; 24 31 public class TranslateRed extends AbstractRed { 32 33 protected int deltaX; 34 protected int deltaY; 35 36 41 public TranslateRed(CachableRed cr, int xloc, int yloc) { 42 super(cr, new Rectangle (xloc, yloc, 43 cr.getWidth(), cr.getHeight()), 44 cr.getColorModel(), cr.getSampleModel(), 45 cr.getTileGridXOffset()+xloc-cr.getMinX(), 46 cr.getTileGridYOffset()+yloc-cr.getMinY(), 47 null); 48 deltaX = xloc-cr.getMinX(); 49 deltaY = yloc-cr.getMinY(); 50 } 51 52 55 public int getDeltaX() { return deltaX; } 56 57 60 public int getDeltaY() { return deltaY; } 61 62 65 public CachableRed getSource() { 66 return (CachableRed)getSources().get(0); 67 } 68 69 public Object getProperty(String name) { 70 return getSource().getProperty(name); 71 } 72 73 public String [] getPropertyNames() { 74 return getSource().getPropertyNames(); 75 } 76 77 public Raster getTile(int tileX, int tileY) { 78 Raster r = getSource().getTile(tileX, tileY); 79 80 return r.createTranslatedChild(r.getMinX()+deltaX, 81 r.getMinY()+deltaY); 82 } 83 84 public Raster getData() { 85 Raster r = getSource().getData(); 86 return r.createTranslatedChild(r.getMinX()+deltaX, 87 r.getMinY()+deltaY); 88 } 89 90 public Raster getData(Rectangle rect) { 91 Rectangle r = (Rectangle )rect.clone(); 92 r.translate(-deltaX, -deltaY); 93 Raster ret = getSource().getData(r); 94 return ret.createTranslatedChild(ret.getMinX()+deltaX, 95 ret.getMinY()+deltaY); 96 } 97 98 public WritableRaster copyData(WritableRaster wr) { 99 WritableRaster wr2 = wr.createWritableTranslatedChild 100 (wr.getMinX()-deltaX, wr.getMinY()-deltaY); 101 102 getSource().copyData(wr2); 103 104 return wr; 105 } 106 } 107 | Popular Tags |