|
| 1 | +package sysmlinjava.analysis.animatedareadisplay; |
| 2 | + |
| 3 | +import java.io.Serializable; |
| 4 | +import sysmlinjava.analysis.common.XYData; |
| 5 | + |
| 6 | +/** |
| 7 | + * Representation of an image object in an area display. Contains the parameters |
| 8 | + * needed to display the object as an image in the display from a specified |
| 9 | + * image file and at a specified position, size, roation, and z-order in the |
| 10 | + * area display. |
| 11 | + * |
| 12 | + * @author ModelerOne |
| 13 | + * |
| 14 | + */ |
| 15 | +public class AAImage extends AAObject implements Serializable |
| 16 | +{ |
| 17 | + /** Serializable ID*/private static final long serialVersionUID = -7826688565768235972L; |
| 18 | + /** |
| 19 | + * String for default image file URL used only if null URL is provided in |
| 20 | + * constructor |
| 21 | + */ |
| 22 | + public static final String defaultImageFileURL = "file:defaultImage.png"; |
| 23 | + |
| 24 | + /** |
| 25 | + * URL of the file that contains the image to be displayed in the area display. |
| 26 | + * If the URL is for a file on the local file system, be sure to use an absolute |
| 27 | + * path to the file. The file will be loaded from the "working" directory of the |
| 28 | + * TaskMaster, so use of a relative path to the image file is likely to fail to |
| 29 | + * locate it properly. |
| 30 | + */ |
| 31 | + public String imageFileURL; |
| 32 | + /** |
| 33 | + * Width (pixels) to resize the image to for the display. Null or zero for no |
| 34 | + * resize |
| 35 | + */ |
| 36 | + public Integer resizeWidth; |
| 37 | + /** |
| 38 | + * Height (pixels) to resize the image to for the display. Null or zero for no |
| 39 | + * resize |
| 40 | + */ |
| 41 | + public Integer resizeHeight; |
| 42 | + /** |
| 43 | + * Degrees (clockwise) to rotate the image to for the display. Null or zero for |
| 44 | + * no resize |
| 45 | + */ |
| 46 | + public Integer rotateDegrees; |
| 47 | + /** |
| 48 | + * X,Y position in the display of the center of the image |
| 49 | + */ |
| 50 | + public XYData position; |
| 51 | + /** |
| 52 | + * Order of the image in the layers of objects in the area display. Lower number |
| 53 | + * is closer to viewer. |
| 54 | + */ |
| 55 | + public Integer zOrder; |
| 56 | + |
| 57 | + /** |
| 58 | + * Constructor for all attributes |
| 59 | + * |
| 60 | + * @param uid unique identifier |
| 61 | + * @param action the action to be performed in the display of the text |
| 62 | + * @param imageFileURL URL for the file that contains the image to be |
| 63 | + * displayed. |
| 64 | + * @param resizeWidth width (pixels) to resize the image to for the display. |
| 65 | + * Null or zero for no resize |
| 66 | + * @param resizeHeight height (pixels) to resize the image to for the display. |
| 67 | + * Null or zero for no resize |
| 68 | + * @param rotateDegrees degrees (clockwise) to rotate the image to for the |
| 69 | + * display. Null or zero for no resize |
| 70 | + * @param position X,Y position in the display of the center of the image |
| 71 | + * @param zOrder order of the image in the layers of objects in the area |
| 72 | + * display. Lower number is closer to viewer. |
| 73 | + */ |
| 74 | + public AAImage(String uid, Action action, String imageFileURL, Integer resizeWidth, Integer resizeHeight, Integer rotateDegrees, XYData position, Integer zOrder) |
| 75 | + { |
| 76 | + super(uid, action); |
| 77 | + switch (action) |
| 78 | + { |
| 79 | + case create: |
| 80 | + this.position = position != null ? position : new XYData(0, 0); |
| 81 | + this.imageFileURL = imageFileURL != null ? imageFileURL : defaultImageFileURL; |
| 82 | + this.resizeWidth = resizeWidth != null ? resizeWidth : 0; |
| 83 | + this.resizeHeight = resizeHeight != null ? resizeHeight : 0; |
| 84 | + this.rotateDegrees = rotateDegrees != null ? rotateDegrees : 0; |
| 85 | + this.zOrder = zOrder != null ? zOrder : 0; |
| 86 | + break; |
| 87 | + case update: |
| 88 | + this.imageFileURL = imageFileURL; |
| 89 | + this.resizeWidth = resizeWidth; |
| 90 | + this.resizeHeight = resizeHeight; |
| 91 | + this.rotateDegrees = rotateDegrees; |
| 92 | + this.position = position; |
| 93 | + this.zOrder = zOrder; |
| 94 | + break; |
| 95 | + case delete: |
| 96 | + break; |
| 97 | + default: |
| 98 | + break; |
| 99 | + } |
| 100 | + } |
| 101 | + |
| 102 | + /** |
| 103 | + * Updates/changes the image display as specified by parameter values, with |
| 104 | + * value {@code null} indicating no change |
| 105 | + * |
| 106 | + * @param action the action to be performed in the display of the text |
| 107 | + * @param imageFileURL URL for the file that contains the image to be |
| 108 | + * displayed. |
| 109 | + * @param resizeWidth width (pixels) to resize the image to for the display. |
| 110 | + * Null or zero for no resize |
| 111 | + * @param resizeHeight height (pixels) to resize the image to for the display. |
| 112 | + * Null or zero for no resize |
| 113 | + * @param rotateDegrees degrees (clockwise) to rotate the image to for the |
| 114 | + * display. Null or zero for no resize |
| 115 | + * @param position X,Y position in the display of the center of the image |
| 116 | + * @param zOrder order of the image in the layers of objects in the area |
| 117 | + * display. Lower number is closer to viewer. |
| 118 | + */ |
| 119 | + public void update(Action action, String imageFileURL, Integer resizeWidth, Integer resizeHeight, Integer rotateDegrees, XYData position, Integer zOrder) |
| 120 | + { |
| 121 | + this.action = action != null ? action : Action.none; |
| 122 | + this.imageFileURL = imageFileURL; |
| 123 | + this.resizeWidth = imageFileURL != null ? (resizeWidth != null ? resizeWidth : 0) : null; |
| 124 | + this.resizeHeight = imageFileURL != null ? (resizeHeight != null ? resizeHeight : 0) : null; |
| 125 | + this.rotateDegrees = rotateDegrees; |
| 126 | + this.position = position; |
| 127 | + this.zOrder = zOrder; |
| 128 | + } |
| 129 | + |
| 130 | + @Override |
| 131 | + public String toString() |
| 132 | + { |
| 133 | + return String.format("AAImage [uid=%s, action=%s, imageFileURL=%s, resizeWidth=%s, resizeHeight=%s, rotateDegrees=%s, position=%s, zOrder=%s]", uid, action, imageFileURL, resizeWidth, resizeHeight, rotateDegrees, position, zOrder); |
| 134 | + } |
| 135 | +} |
0 commit comments