1 18 package org.apache.batik.ext.awt.image.renderable; 19 20 import java.awt.RenderingHints ; 21 import java.awt.Shape ; 22 import java.awt.geom.Rectangle2D ; 23 import java.awt.image.RenderedImage ; 24 import java.awt.image.renderable.RenderContext ; 25 import java.util.Map ; 26 import java.util.Vector ; 27 28 38 39 public class DeferRable implements Filter { 40 Filter src; 41 Rectangle2D bounds; 42 Map props; 43 46 public DeferRable() { 47 } 48 49 52 public synchronized Filter getSource() { 53 while (src == null) { 54 try { 55 wait(); 57 } 58 catch(InterruptedException ie) { 59 } 61 } 62 return src; 63 } 64 65 74 public synchronized void setSource(Filter src) { 75 if (this.src != null) return; 77 this.src = src; 78 this.bounds = src.getBounds2D(); 79 notifyAll(); 80 } 81 82 public synchronized void setBounds(Rectangle2D bounds) { 83 if (this.bounds != null) return; 84 this.bounds = bounds; 85 notifyAll(); 86 } 87 88 public synchronized void setProperties(Map props) { 89 this.props = props; 90 notifyAll(); 91 } 92 93 public long getTimeStamp() { 94 return getSource().getTimeStamp(); 95 } 96 97 public Vector getSources() { 98 return getSource().getSources(); 99 } 100 101 104 public boolean isDynamic() { 105 return getSource().isDynamic(); 106 } 107 108 112 public Rectangle2D getBounds2D() { 113 synchronized(this) { 114 while ((src == null) && (bounds == null)) { 115 try { 116 wait(); 118 } 119 catch(InterruptedException ie) { 120 } 122 } 123 } 124 if (src != null) 125 return src.getBounds2D(); 126 return bounds; 127 } 128 129 public float getMinX() { 130 return (float)getBounds2D().getX(); 131 } 132 public float getMinY() { 133 return (float)getBounds2D().getY(); 134 } 135 public float getWidth() { 136 return (float)getBounds2D().getWidth(); 137 } 138 public float getHeight() { 139 return (float)getBounds2D().getHeight(); 140 } 141 142 145 public Object getProperty(String name) { 146 synchronized (this) { 147 while ((src == null) && (props == null)) { 148 try { 149 wait(); 151 } catch(InterruptedException ie) { } 152 } 153 } 154 if (src != null) 155 return src.getProperty(name); 156 return props.get(name); 157 } 158 159 162 public String [] getPropertyNames() { 163 synchronized (this) { 164 while ((src == null) && (props == null)) { 165 try { 166 wait(); 168 } catch(InterruptedException ie) { } 169 } 170 } 171 if (src != null) 172 return src.getPropertyNames(); 173 174 String [] ret = new String [props.size()]; 175 props.keySet().toArray(ret); 176 return ret; 177 } 178 179 182 public RenderedImage createDefaultRendering() { 183 return getSource().createDefaultRendering(); 184 } 185 186 189 public RenderedImage createScaledRendering(int w, int h, 190 RenderingHints hints) { 191 return getSource().createScaledRendering(w, h, hints); 192 } 193 194 197 public RenderedImage createRendering(RenderContext rc) { 198 return getSource().createRendering(rc); 199 } 200 201 204 public Shape getDependencyRegion(int srcIndex, 205 Rectangle2D outputRgn) { 206 return getSource().getDependencyRegion(srcIndex, outputRgn); 207 } 208 209 212 public Shape getDirtyRegion(int srcIndex, 213 Rectangle2D inputRgn) { 214 return getSource().getDirtyRegion(srcIndex, inputRgn); 215 } 216 } 217 | Popular Tags |