Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register
Show
Ignore:
Timestamp:
08/18/08 18:57:52 (5 months ago)
Author:
TorLye
Message:

gmapsimageviewer: Some cleaning up and removal of commented out code.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openmrs-modules/gmapsimageviewer/src/org/openmrs/module/gmapsimageviewer/AnnotatedImage.java

    r5176 r5311  
    88import org.openmrs.module.gmapsimageviewer.obs.handler.AnnotatedImageHandler; 
    99 
     10/** 
     11 * This class represents an image with annotations. 
     12 */ 
    1013public class AnnotatedImage { 
    1114 
    12     private Log log = LogFactory.getLog(AnnotatedImage.class); 
     15       private Log log = LogFactory.getLog(AnnotatedImage.class); 
    1316 
    14     private BufferedImage image; 
     17       private BufferedImage image; 
    1518 
    16     private ImageAnnotation[] annotations = new ImageAnnotation[0]; 
     19       private ImageAnnotation[] annotations = new ImageAnnotation[0]; 
    1720 
    18     private AnnotatedImageHandler handler; 
     21       private AnnotatedImageHandler handler; 
    1922 
    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       
    3033 
    31     public void setAnnotations(ImageAnnotation[] annotations) { 
    32         this.annotations = annotations; 
    33    
     34       public void setAnnotations(ImageAnnotation[] annotations) { 
     35               this.annotations = annotations; 
     36       
    3437 
    35     public ImageAnnotation[] getAnnotations() { 
    36         return annotations; 
    37    
     38       public ImageAnnotation[] getAnnotations() { 
     39               return annotations; 
     40       
    3841 
    39     public BufferedImage getImage() { 
    40         return image; 
    41     } 
    42      
    43     public Pixel getSize() { 
    44         return new Pixel(image.getWidth(), image.getHeight()); 
    45     } 
     42        public BufferedImage getImage() { 
     43                return image; 
     44        } 
    4645 
    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        } 
    7592 
    7693}