1 27 package org.htmlparser.lexerapplications.thumbelina; 28 29 import java.awt.Image ; 30 import java.awt.Point ; 31 import java.awt.Rectangle ; 32 import java.net.URL ; 33 34 38 public class Picture extends Rectangle 39 { 40 43 public static final Point ORIGIN = new Point (0, 0); 44 45 48 protected URL mURL; 49 50 53 protected Image mImage; 54 55 63 protected Point mOrigin; 64 65 68 public Picture () 69 { 70 setURL (null); 71 setImage (null); 72 setOrigin (ORIGIN); 73 } 74 75 82 public Picture (final int x, final int y, final int width, final int height) 83 { 84 super (x, y, width, height); 85 setURL (null); 86 setImage (null); 87 setOrigin (new Point (x, y)); 88 } 89 90 94 public Picture (final Rectangle r) 95 { 96 super (r); 97 setURL (null); 98 setImage (null); 99 setOrigin (new Point (r.x, r.y)); 100 } 101 102 106 public Picture (final Picture picture) 107 { 108 super (picture); 109 setURL (picture.getURL ()); 110 setImage (picture.getImage ()); 111 setOrigin (picture.getOrigin ()); 112 } 113 114 118 public URL getURL () 119 { 120 return (mURL); 121 } 122 123 127 public void setURL (final URL url) 128 { 129 mURL = url; 130 } 131 132 135 public Image getImage () 136 { 137 return (mImage); 138 } 139 140 143 public void setImage (final Image image) 144 { 145 mImage = image; 146 if (null != image) 147 { 148 width = image.getWidth (null); 149 height = image.getHeight (null); 150 } 151 } 152 153 156 public Point getOrigin () 157 { 158 return (mOrigin); 159 } 160 161 164 public void setOrigin (final Point origin) 165 { 166 mOrigin = origin; 167 } 168 169 174 public boolean same (final Picture picture) 175 { 176 return (mImage == picture.mImage); 177 } 178 179 182 public void reset () 183 { 184 setBounds (mOrigin.x, mOrigin.y, 185 mImage.getWidth (null), mImage.getHeight (null)); 186 } 187 188 192 public String toString () 193 { 194 StringBuffer ret; 195 196 ret = new StringBuffer (); 197 ret.append (getURL ().toString ()); 198 ret.append ("[x="); 199 ret.append (Integer.toString (x)); 200 ret.append (",y="); 201 ret.append (Integer.toString (y)); 202 ret.append (",width="); 203 ret.append (Integer.toString (width)); 204 ret.append (",height="); 205 ret.append (Integer.toString (height)); 206 ret.append ("]"); 207 208 return (ret.toString ()); 209 } 210 } 211 212 229 | Popular Tags |