| 20 | | public AnnotatedImage(BufferedImage image) { |
|---|
| 21 | | setImage(image); |
|---|
| 22 | | if (image == null) |
|---|
| 23 | | log.info("gmapsimageviewer: Created new AnnotatedImage " |
|---|
| 24 | | + "containing a null image"); |
|---|
| 25 | | else |
|---|
| 26 | | log.info("gmapsimageviewer: Created new AnnotatedImage " |
|---|
| 27 | | + "containing a " + image.getWidth() + "x" |
|---|
| 28 | | + image.getHeight() + " image"); |
|---|
| 29 | | } |
|---|
| | 23 | public AnnotatedImage(BufferedImage image) { |
|---|
| | 24 | setImage(image); |
|---|
| | 25 | if (image == null) |
|---|
| | 26 | log.info("gmapsimageviewer: Created new AnnotatedImage " |
|---|
| | 27 | + "containing a null image"); |
|---|
| | 28 | else |
|---|
| | 29 | log.info("gmapsimageviewer: Created new AnnotatedImage " |
|---|
| | 30 | + "containing a " + image.getWidth() + "x" |
|---|
| | 31 | + image.getHeight() + " image"); |
|---|
| | 32 | } |
|---|
| 47 | | public void setImage(BufferedImage image) { |
|---|
| 48 | | this.image = image; |
|---|
| 49 | | } |
|---|
| 50 | | |
|---|
| 51 | | public void setHandler(AnnotatedImageHandler handler) { |
|---|
| 52 | | this.handler = handler; |
|---|
| 53 | | } |
|---|
| 54 | | |
|---|
| 55 | | public void saveAnnotation(Obs obs, ImageAnnotation annotation) { |
|---|
| 56 | | Pixel location = annotation.getLocation(); |
|---|
| 57 | | if(location.x < 0) |
|---|
| 58 | | location.x = 0; |
|---|
| 59 | | if(location.y < 0) |
|---|
| 60 | | location.y = 0; |
|---|
| 61 | | if(location.x >= getSize().x) |
|---|
| 62 | | location.x = getSize().x-1; |
|---|
| 63 | | if(location.y >= getSize().y) |
|---|
| 64 | | location.y = getSize().y-1; |
|---|
| 65 | | annotation.setLocation(location); |
|---|
| 66 | | |
|---|
| 67 | | handler.saveAnnotation(obs, annotation, false); |
|---|
| 68 | | handler.loadMetadata(obs, this); |
|---|
| 69 | | } |
|---|
| 70 | | |
|---|
| 71 | | public void removeAnnotation(Obs obs, ImageAnnotation annotation) { |
|---|
| 72 | | handler.saveAnnotation(obs, annotation, true); |
|---|
| 73 | | handler.loadMetadata(obs, this); |
|---|
| 74 | | } |
|---|
| | 46 | public Pixel getSize() { |
|---|
| | 47 | return new Pixel(image.getWidth(), image.getHeight()); |
|---|
| | 48 | } |
|---|
| | 49 | |
|---|
| | 50 | public void setImage(BufferedImage image) { |
|---|
| | 51 | this.image = image; |
|---|
| | 52 | } |
|---|
| | 53 | |
|---|
| | 54 | public void setHandler(AnnotatedImageHandler handler) { |
|---|
| | 55 | this.handler = handler; |
|---|
| | 56 | } |
|---|
| | 57 | |
|---|
| | 58 | /** |
|---|
| | 59 | * Saves an annotation. Changes in annotations are write-through, they are |
|---|
| | 60 | * transferred to the storage layer immediately. |
|---|
| | 61 | * |
|---|
| | 62 | * @param obs |
|---|
| | 63 | * @param annotation |
|---|
| | 64 | */ |
|---|
| | 65 | public void saveAnnotation(Obs obs, ImageAnnotation annotation) { |
|---|
| | 66 | Pixel location = annotation.getLocation(); |
|---|
| | 67 | if (location.x < 0) |
|---|
| | 68 | location.x = 0; |
|---|
| | 69 | if (location.y < 0) |
|---|
| | 70 | location.y = 0; |
|---|
| | 71 | if (location.x >= getSize().x) |
|---|
| | 72 | location.x = getSize().x - 1; |
|---|
| | 73 | if (location.y >= getSize().y) |
|---|
| | 74 | location.y = getSize().y - 1; |
|---|
| | 75 | annotation.setLocation(location); |
|---|
| | 76 | |
|---|
| | 77 | handler.saveAnnotation(obs, annotation, false); |
|---|
| | 78 | handler.loadMetadata(obs, this); |
|---|
| | 79 | } |
|---|
| | 80 | |
|---|
| | 81 | /** |
|---|
| | 82 | * Deletes an annotation. Changes in annotations are write-through, they are |
|---|
| | 83 | * transferred to the storage layer immediately. |
|---|
| | 84 | * |
|---|
| | 85 | * @param obs |
|---|
| | 86 | * @param annotation |
|---|
| | 87 | */ |
|---|
| | 88 | public void removeAnnotation(Obs obs, ImageAnnotation annotation) { |
|---|
| | 89 | handler.saveAnnotation(obs, annotation, true); |
|---|
| | 90 | handler.loadMetadata(obs, this); |
|---|
| | 91 | } |
|---|