performed javacscript:fix and worked on documentation
[taxeditor.git] / taxeditor-editor / src / main / java / eu / etaxonomy / taxeditor / editor / name / EditorAnnotation.java
index b24902eeb07c84b32407ef3ae65ec5a1099bf7fe..3d7db78a14e714df254fccac798fa5b83b7b8100 100644 (file)
-package eu.etaxonomy.taxeditor.editor.name;\r
-\r
-import org.apache.log4j.Logger;\r
-import org.eclipse.core.resources.IMarker;\r
-import org.eclipse.jface.text.Position;\r
-import org.eclipse.jface.text.source.Annotation;\r
-import org.eclipse.jface.text.source.IAnnotationPresentation;\r
-import org.eclipse.swt.graphics.GC;\r
-import org.eclipse.swt.graphics.Image;\r
-import org.eclipse.swt.graphics.Point;\r
-import org.eclipse.swt.graphics.RGB;\r
-import org.eclipse.swt.graphics.Rectangle;\r
-import org.eclipse.swt.widgets.Canvas;\r
-\r
-import eu.etaxonomy.taxeditor.model.ImageResources;\r
-\r
-public class EditorAnnotation extends Annotation implements IAnnotationPresentation {\r
-       private static final Logger logger = Logger\r
-                       .getLogger(EditorAnnotation.class);\r
-    private IMarker marker;\r
-    private String text;\r
-    private int line;\r
-    private Position position;\r
-\r
-    // error identifiers, images and colors\r
-    public static String ERROR_TYPE = "editor.error.type";\r
-    public static Image ERROR_IMAGE = ImageResources.getImage(ImageResources.ERROR_ANNOTATION_ICON);\r
-    public static final RGB ERROR_RGB = new RGB(255, 0, 0);    \r
-    \r
-    public static String WARNING_TYPE = "editor.warning.type";\r
-    public static Image WARNING_IMAGE = ImageResources.getImage(ImageResources.WARNING_ANNOTATION_ICON);\r
-    public static final RGB WARNING_RGB = new RGB(244, 200, 45); \r
-    \r
-    public EditorAnnotation(IMarker marker) {\r
-        this.marker = marker;\r
-    }\r
-\r
-    public EditorAnnotation(int line, String text) {\r
-       this(ERROR_TYPE, line, text);\r
-    }\r
-\r
-    public EditorAnnotation(String type, int line, String text) {\r
-       super(type, false, text);\r
-        this.marker = null;\r
-        this.line = line;\r
-        this.text = text;\r
-    }\r
-    \r
-    public IMarker getMarker() {\r
-        return marker;\r
-    }\r
-\r
-    public int getLine() {\r
-        return line;\r
-    }\r
-\r
-    public String getText() {\r
-       if (ERROR_TYPE.equals(getType())) {\r
-               return "Error: " + text;\r
-       }\r
-       if (WARNING_TYPE.equals(getType())) {\r
-               return "Warning: " + text;\r
-       }\r
-       return super.getText();\r
-    }\r
-\r
-       /**\r
-        * @return\r
-        */\r
-       private Image getImage() {\r
-       if (ERROR_TYPE.equals(getType())) {\r
-               return ERROR_IMAGE;\r
-       }\r
-       if (WARNING_TYPE.equals(getType())) {\r
-               return WARNING_IMAGE;\r
-       }\r
-               logger.warn("No image for type " + getType());\r
-               return null;\r
-       }\r
-    \r
-    public int getLayer() {\r
-        return 3;\r
-    }\r
-\r
-\r
-    public Position getPosition() {\r
-        return position;\r
-    }\r
-\r
-    public void setPosition(Position position) {\r
-        this.position = position;\r
-    }\r
-\r
-       \r
-       public void paint(GC gc, Canvas canvas, Rectangle bounds) {\r
-               Point canvasSize= canvas.getSize();\r
-\r
-               int x= 0;\r
-               int y= bounds.y;\r
-               int w= canvasSize.x;\r
-               int h= bounds.height;\r
-\r
-               if (y + h > canvasSize.y)\r
-                       h= canvasSize.y - y;\r
-\r
-               if (y < 0) {\r
-                       h= h + y;\r
-                       y= 0;\r
-               }\r
-\r
-               if (h <= 0)\r
-                       return;\r
-\r
-               Image image = getImage();\r
-               \r
-               if (image == null) {\r
-                       return;\r
-               }\r
-               \r
-               Rectangle r = image.getBounds();\r
-               \r
-               int destX = x + w - r.width;\r
-               int destY = y + h - r.height;\r
-               \r
-               gc.drawImage(image, 0, 0, r.width, r.height, destX, destY, r.width, r.height);\r
-       }\r
-}
\ No newline at end of file
+package eu.etaxonomy.taxeditor.editor.name;
+
+import org.apache.log4j.Logger;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.jface.text.source.IAnnotationPresentation;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+
+import eu.etaxonomy.taxeditor.model.ImageResources;
+
+/**
+ * <p>EditorAnnotation class.</p>
+ *
+ * @author n.hoffmann
+ * @version $Id: $
+ */
+public class EditorAnnotation extends Annotation implements IAnnotationPresentation {
+       private static final Logger logger = Logger
+                       .getLogger(EditorAnnotation.class);
+    private IMarker marker;
+    private String text;
+    private int line;
+    private Position position;
+
+    // error identifiers, images and colors
+    /** Constant <code>ERROR_TYPE="editor.error.type"</code> */
+    public static String ERROR_TYPE = "editor.error.type";
+    /** Constant <code>ERROR_IMAGE</code> */
+    public static Image ERROR_IMAGE = ImageResources.getImage(ImageResources.ERROR_ANNOTATION_ICON);
+    /** Constant <code>ERROR_RGB</code> */
+    public static final RGB ERROR_RGB = new RGB(255, 0, 0);    
+    
+    /** Constant <code>WARNING_TYPE="editor.warning.type"</code> */
+    public static String WARNING_TYPE = "editor.warning.type";
+    /** Constant <code>WARNING_IMAGE</code> */
+    public static Image WARNING_IMAGE = ImageResources.getImage(ImageResources.WARNING_ANNOTATION_ICON);
+    /** Constant <code>WARNING_RGB</code> */
+    public static final RGB WARNING_RGB = new RGB(244, 200, 45); 
+    
+    /**
+     * <p>Constructor for EditorAnnotation.</p>
+     *
+     * @param marker a org.eclipse.core.resources.IMarker object.
+     */
+    public EditorAnnotation(IMarker marker) {
+        this.marker = marker;
+    }
+
+    /**
+     * <p>Constructor for EditorAnnotation.</p>
+     *
+     * @param line a int.
+     * @param text a {@link java.lang.String} object.
+     */
+    public EditorAnnotation(int line, String text) {
+       this(ERROR_TYPE, line, text);
+    }
+
+    /**
+     * <p>Constructor for EditorAnnotation.</p>
+     *
+     * @param type a {@link java.lang.String} object.
+     * @param line a int.
+     * @param text a {@link java.lang.String} object.
+     */
+    public EditorAnnotation(String type, int line, String text) {
+       super(type, false, text);
+        this.marker = null;
+        this.line = line;
+        this.text = text;
+    }
+    
+    /**
+     * <p>Getter for the field <code>marker</code>.</p>
+     *
+     * @return a org.eclipse.core.resources.IMarker object.
+     */
+    public IMarker getMarker() {
+        return marker;
+    }
+
+    /**
+     * <p>Getter for the field <code>line</code>.</p>
+     *
+     * @return a int.
+     */
+    public int getLine() {
+        return line;
+    }
+
+    /**
+     * <p>Getter for the field <code>text</code>.</p>
+     *
+     * @return a {@link java.lang.String} object.
+     */
+    public String getText() {
+       if (ERROR_TYPE.equals(getType())) {
+               return "Error: " + text;
+       }
+       if (WARNING_TYPE.equals(getType())) {
+               return "Warning: " + text;
+       }
+       return super.getText();
+    }
+
+       /**
+        * @return
+        */
+       private Image getImage() {
+       if (ERROR_TYPE.equals(getType())) {
+               return ERROR_IMAGE;
+       }
+       if (WARNING_TYPE.equals(getType())) {
+               return WARNING_IMAGE;
+       }
+               logger.warn("No image for type " + getType());
+               return null;
+       }
+    
+    /**
+     * <p>getLayer</p>
+     *
+     * @return a int.
+     */
+    public int getLayer() {
+        return 3;
+    }
+
+
+    /**
+     * <p>Getter for the field <code>position</code>.</p>
+     *
+     * @return a {@link org.eclipse.jface.text.Position} object.
+     */
+    public Position getPosition() {
+        return position;
+    }
+
+    /**
+     * <p>Setter for the field <code>position</code>.</p>
+     *
+     * @param position a {@link org.eclipse.jface.text.Position} object.
+     */
+    public void setPosition(Position position) {
+        this.position = position;
+    }
+
+       
+       /** {@inheritDoc} */
+       public void paint(GC gc, Canvas canvas, Rectangle bounds) {
+               Point canvasSize= canvas.getSize();
+
+               int x= 0;
+               int y= bounds.y;
+               int w= canvasSize.x;
+               int h= bounds.height;
+
+               if (y + h > canvasSize.y)
+                       h= canvasSize.y - y;
+
+               if (y < 0) {
+                       h= h + y;
+                       y= 0;
+               }
+
+               if (h <= 0)
+                       return;
+
+               Image image = getImage();
+               
+               if (image == null) {
+                       return;
+               }
+               
+               Rectangle r = image.getBounds();
+               
+               int destX = x + w - r.width;
+               int destY = y + h - r.height;
+               
+               gc.drawImage(image, 0, 0, r.width, r.height, destX, destY, r.width, r.height);
+       }
+}