[919] | 1 | /**
|
---|
| 2 | * Item.java
|
---|
| 3 | * Copyright (C) 2010 New Zealand Digital Library, http://expeditee.org
|
---|
| 4 | *
|
---|
| 5 | * This program is free software: you can redistribute it and/or modify
|
---|
| 6 | * it under the terms of the GNU General Public License as published by
|
---|
| 7 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 8 | * (at your option) any later version.
|
---|
| 9 | *
|
---|
| 10 | * This program is distributed in the hope that it will be useful,
|
---|
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 13 | * GNU General Public License for more details.
|
---|
| 14 | *
|
---|
| 15 | * You should have received a copy of the GNU General Public License
|
---|
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 17 | */
|
---|
| 18 |
|
---|
[4] | 19 | package org.expeditee.items;
|
---|
| 20 |
|
---|
| 21 | import java.util.ArrayList;
|
---|
[72] | 22 | import java.util.Collection;
|
---|
[4] | 23 | import java.util.ConcurrentModificationException;
|
---|
[1408] | 24 | import java.util.HashMap;
|
---|
[108] | 25 | import java.util.HashSet;
|
---|
[72] | 26 | import java.util.LinkedHashSet;
|
---|
[4] | 27 | import java.util.LinkedList;
|
---|
| 28 | import java.util.List;
|
---|
[1408] | 29 | import java.util.Map;
|
---|
| 30 | import java.util.Set;
|
---|
[4] | 31 |
|
---|
| 32 | import org.expeditee.actions.Actions;
|
---|
[410] | 33 | import org.expeditee.actions.IncorrectUseOfStatementException;
|
---|
[472] | 34 | import org.expeditee.actions.Javascript;
|
---|
[176] | 35 | import org.expeditee.actions.Misc;
|
---|
[4] | 36 | import org.expeditee.actions.Simple;
|
---|
[1102] | 37 | import org.expeditee.core.Anchoring;
|
---|
| 38 | import org.expeditee.core.Colour;
|
---|
| 39 | import org.expeditee.core.Cursor;
|
---|
| 40 | import org.expeditee.core.Dimension;
|
---|
| 41 | import org.expeditee.core.Fill;
|
---|
[1477] | 42 | import org.expeditee.core.Font;
|
---|
[1102] | 43 | import org.expeditee.core.GradientFill;
|
---|
| 44 | import org.expeditee.core.Point;
|
---|
| 45 | import org.expeditee.core.Stroke;
|
---|
| 46 | import org.expeditee.core.bounds.AxisAlignedBoxBounds;
|
---|
| 47 | import org.expeditee.core.bounds.Bounds;
|
---|
| 48 | import org.expeditee.core.bounds.EllipticalBounds;
|
---|
| 49 | import org.expeditee.core.bounds.PolygonBounds;
|
---|
[1427] | 50 | import org.expeditee.encryption.core.EncryptedImage;
|
---|
[1509] | 51 | import org.expeditee.encryption.io.EncryptedExpWriter;
|
---|
[1477] | 52 | import org.expeditee.encryption.items.KeyType;
|
---|
[1509] | 53 | import org.expeditee.encryption.items.UserAppliedEncryptionPermission;
|
---|
[1408] | 54 | import org.expeditee.encryption.items.surrogates.EncryptionDetail;
|
---|
[1415] | 55 | import org.expeditee.encryption.items.surrogates.EncryptionDetail.Type;
|
---|
[1431] | 56 | import org.expeditee.encryption.items.surrogates.Label.LabelInfo;
|
---|
| 57 | import org.expeditee.encryption.items.surrogates.Label.LabelResult;
|
---|
[1415] | 58 | import org.expeditee.encryption.items.surrogates.Label;
|
---|
[1102] | 59 | import org.expeditee.gio.EcosystemManager;
|
---|
| 60 | import org.expeditee.gio.GraphicsManager;
|
---|
| 61 | import org.expeditee.gio.gesture.StandardGestureActions;
|
---|
[376] | 62 | import org.expeditee.gui.AttributeValuePair;
|
---|
[1102] | 63 | import org.expeditee.gui.DisplayController;
|
---|
[4] | 64 | import org.expeditee.gui.Frame;
|
---|
| 65 | import org.expeditee.gui.FrameIO;
|
---|
| 66 | import org.expeditee.gui.FrameUtils;
|
---|
[156] | 67 | import org.expeditee.gui.FreeItems;
|
---|
[121] | 68 | import org.expeditee.gui.MessageBay;
|
---|
[116] | 69 | import org.expeditee.gui.Overlay;
|
---|
| 70 | import org.expeditee.gui.Vector;
|
---|
[4] | 71 | import org.expeditee.io.Conversion;
|
---|
[1408] | 72 | import org.expeditee.io.DefaultFrameWriter;
|
---|
[570] | 73 | import org.expeditee.settings.UserSettings;
|
---|
[1200] | 74 | import org.expeditee.settings.legacy.LegacyFeatures;
|
---|
[4] | 75 | import org.expeditee.simple.Context;
|
---|
| 76 | import org.expeditee.stats.AgentStats;
|
---|
[419] | 77 | import org.expeditee.stats.Formatter;
|
---|
[472] | 78 | import org.mozilla.javascript.Scriptable;
|
---|
| 79 | import org.mozilla.javascript.ScriptableObject;
|
---|
[4] | 80 |
|
---|
| 81 | /**
|
---|
| 82 | * Represents everything that can be drawn on the screen (text, lines, dots,
|
---|
| 83 | * images). Each specific type is a subclass of Item.
|
---|
| 84 | *
|
---|
| 85 | * @author jdm18
|
---|
| 86 | *
|
---|
| 87 | */
|
---|
[50] | 88 | public abstract class Item implements Comparable<Item>, Runnable {
|
---|
[4] | 89 |
|
---|
[1102] | 90 | public enum HighlightMode {
|
---|
| 91 | None, // The item has no highlighting
|
---|
| 92 | Enclosed, // The item is part of the current enclosure
|
---|
| 93 | Connected, // The item is connected to the current item
|
---|
| 94 | Disconnect, // The item is a free item
|
---|
| 95 | Normal // The item is the current item
|
---|
| 96 | }
|
---|
| 97 |
|
---|
| 98 | /** Which edge of the window things are anchored to. */
|
---|
| 99 | public enum AnchorEdgeType {
|
---|
| 100 | None, Left, Right, Top, Bottom
|
---|
| 101 | }
|
---|
| 102 |
|
---|
| 103 | public static final float SIZE_NOT_APPLICABLE = Float.NaN;
|
---|
| 104 |
|
---|
[108] | 105 | public static final Float DEFAULT_THICKNESS = 2f;
|
---|
| 106 |
|
---|
[143] | 107 | public static final Float MINIMUM_THICKNESS = 0f;
|
---|
[108] | 108 |
|
---|
[143] | 109 | public static final Float MINIMUM_PAINT_THICKNESS = 1f;
|
---|
| 110 |
|
---|
[1102] | 111 | protected static final Stroke.JOIN DEFAULT_JOIN = Stroke.JOIN.ROUND;
|
---|
[107] | 112 |
|
---|
[1102] | 113 | protected static final Stroke.CAP DEFAULT_CAP = Stroke.CAP.BUTT;
|
---|
[108] | 114 |
|
---|
[1102] | 115 | protected static final Stroke DOT_STROKE = new Stroke(DEFAULT_THICKNESS, DEFAULT_CAP, DEFAULT_JOIN);
|
---|
[427] | 116 |
|
---|
[1102] | 117 | protected static final Stroke HIGHLIGHT_STROKE = new Stroke(MINIMUM_THICKNESS, DEFAULT_CAP, DEFAULT_JOIN);
|
---|
| 118 |
|
---|
[78] | 119 | public static final int LEFT_MARGIN = 13;
|
---|
[50] | 120 |
|
---|
[7] | 121 | public static final int NEAR_DISTANCE = 15;
|
---|
[50] | 122 |
|
---|
[4] | 123 | public static final int DEFAULT_HIGHLIGHT_THICKNESS = 2;
|
---|
| 124 |
|
---|
[1102] | 125 | /** The default colour to draw highlighting in */
|
---|
| 126 | public static final Colour DEFAULT_HIGHLIGHT = Colour.RED;
|
---|
[4] | 127 |
|
---|
[1102] | 128 | public static final Colour DEPRESSED_HIGHLIGHT = Colour.GREEN;
|
---|
[50] | 129 |
|
---|
[1102] | 130 | public static final Colour ALTERNATE_HIGHLIGHT = Colour.BLUE;
|
---|
[4] | 131 |
|
---|
[1102] | 132 | public static final Colour LINK_COLOR = Colour.BLACK;
|
---|
[4] | 133 |
|
---|
[1102] | 134 | public static final Colour ACTION_COLOR = Colour.BLACK;
|
---|
[4] | 135 |
|
---|
[1102] | 136 | public static final Colour LINK_ACTION_COLOR = Colour.RED;
|
---|
[4] | 137 |
|
---|
[1102] | 138 | public static final Colour DEFAULT_FOREGROUND = Colour.BLACK;
|
---|
[4] | 139 |
|
---|
[1102] | 140 | public static final Colour DEFAULT_BACKGROUND = Colour.WHITE;
|
---|
[4] | 141 |
|
---|
[1102] | 142 | public static final Colour TRANSPARENT = new Colour(0, 0, 0, 0);
|
---|
[80] | 143 |
|
---|
[1102] | 144 | /** The number of pixels highlighting should extend around Items. */
|
---|
[4] | 145 | public static final int XGRAVITY = 3;
|
---|
| 146 |
|
---|
[72] | 147 | public static final int MARGIN_RIGHT = 2;
|
---|
[4] | 148 |
|
---|
[72] | 149 | public static final int MARGIN_LEFT = 15;
|
---|
[4] | 150 |
|
---|
[1102] | 151 | protected static final double DEFAULT_ARROWHEAD_RATIO = 0.3; // used to be 0.5
|
---|
[50] | 152 |
|
---|
[1102] | 153 | public static final double DEFAULT_ARROWHEAD_NIB_PERC = 0.75;
|
---|
[475] | 154 |
|
---|
[1102] | 155 | public static final Colour GREEN = Colour.GREEN.darker();
|
---|
[7] | 156 |
|
---|
[1102] | 157 | //public static final int UNCHANGED_CURSOR = -100;
|
---|
[7] | 158 |
|
---|
[1102] | 159 | public static final Cursor.CursorType DEFAULT_CURSOR = Cursor.CursorType.DEFAULT;
|
---|
[7] | 160 |
|
---|
[1102] | 161 | public static final Cursor.CursorType HIDDEN_CURSOR = Cursor.CursorType.CUSTOM;
|
---|
[7] | 162 |
|
---|
[1102] | 163 | public static final Cursor.CursorType TEXT_CURSOR = Cursor.CursorType.TEXT;
|
---|
[7] | 164 |
|
---|
[1102] | 165 | public static final Cursor.CursorType CROP_CURSOR = Cursor.CursorType.CROSSHAIR;
|
---|
[1415] | 166 |
|
---|
[1102] | 167 | /** The default value for integer attributes */
|
---|
[80] | 168 | public static final int DEFAULT_INTEGER = -1;
|
---|
[1415] | 169 |
|
---|
[1102] | 170 | private static final int BRIGHTNESS = 185;
|
---|
[1415] | 171 |
|
---|
[1102] | 172 | /** Contains all dots (including this one) that form an enclosure if this dot is part of an enclosing shape. */
|
---|
| 173 | private Collection<Item> _enclosure = null;
|
---|
| 174 |
|
---|
| 175 | /** The area which this item covers (including its gravity). */
|
---|
| 176 | private Bounds _bounds = null;
|
---|
[656] | 177 |
|
---|
[1102] | 178 | /** The area this item covered before it was invalidated. */
|
---|
| 179 | private Bounds _oldBounds = null;
|
---|
[7] | 180 |
|
---|
[1102] | 181 | protected boolean _connectedToAnnotation = false;
|
---|
[720] | 182 |
|
---|
[1102] | 183 | protected boolean _save = true;
|
---|
[7] | 184 |
|
---|
[1102] | 185 | /** The angle of change for gradient colour fills (in radians). */
|
---|
| 186 | private double _gradientAngle = 0.0;
|
---|
| 187 |
|
---|
| 188 | private Tooltip _tooltip = new Tooltip();
|
---|
[7] | 189 |
|
---|
[1102] | 190 | protected Anchoring _anchoring = new Anchoring();
|
---|
[7] | 191 |
|
---|
[1102] | 192 | /** The highlight mode for this item. */
|
---|
| 193 | protected HighlightMode _highlightMode = HighlightMode.None;
|
---|
[7] | 194 |
|
---|
[4] | 195 | private Point _offset = new Point(0, 0);
|
---|
| 196 |
|
---|
[108] | 197 | protected float _x;
|
---|
| 198 | protected float _y;
|
---|
[4] | 199 |
|
---|
| 200 | private int _id;
|
---|
| 201 |
|
---|
[286] | 202 | private Item _editTarget = this;
|
---|
| 203 |
|
---|
[4] | 204 | private String _creationDate = null;
|
---|
| 205 |
|
---|
[1102] | 206 | /** Whether or not this item should display a mark indicating it has a link. */
|
---|
[4] | 207 | private boolean _linkMark = true;
|
---|
| 208 |
|
---|
[1102] | 209 | /** Whether or not this item should display a mark indicating it has an action. */
|
---|
[4] | 210 | private boolean _actionMark = true;
|
---|
| 211 |
|
---|
[1102] | 212 | /** TODO: Appears unused? cts16 */
|
---|
[4] | 213 | private boolean _highlight = true;
|
---|
| 214 |
|
---|
[147] | 215 | // private int _maxWidth = -1;
|
---|
[4] | 216 |
|
---|
| 217 | private String _owner = null;
|
---|
| 218 |
|
---|
| 219 | private String _link = null;
|
---|
[676] | 220 |
|
---|
| 221 | private boolean _linkHistory = true;
|
---|
[4] | 222 |
|
---|
[74] | 223 | private StringBuffer _tag = new StringBuffer();
|
---|
[4] | 224 |
|
---|
| 225 | private List<String> _actionCursorEnter = null;
|
---|
| 226 |
|
---|
| 227 | private List<String> _actionCursorLeave = null;
|
---|
| 228 |
|
---|
| 229 | private List<String> _actionEnterFrame = null;
|
---|
| 230 |
|
---|
| 231 | private List<String> _actionLeaveFrame = null;
|
---|
| 232 |
|
---|
[1402] | 233 | private PermissionTriple _permissionTriple = null;
|
---|
[737] | 234 |
|
---|
| 235 | private UserAppliedPermission _overlayPermission = null;
|
---|
[116] | 236 |
|
---|
[1102] | 237 | /** The primary fill colour of this item. A fill colour of null represents transparent. */
|
---|
| 238 | private Colour _fillColour = null;
|
---|
[116] | 239 |
|
---|
[1102] | 240 | /** The secondary fill colour if this item has a gradient fill. Null represents no gradient. */
|
---|
| 241 | private Colour _gradientColour = null;
|
---|
[7] | 242 |
|
---|
[1102] | 243 | /** The primary draw colour of this item. Null represents the default colour. */
|
---|
| 244 | private Colour _foregroundColour = null;
|
---|
[50] | 245 |
|
---|
[1102] | 246 | /** The colour to draw highlights on this item. */
|
---|
| 247 | protected Colour _highlightColour = DEFAULT_HIGHLIGHT;
|
---|
[145] | 248 |
|
---|
[1102] | 249 | /** The background colour for this item. */
|
---|
| 250 | private Colour _backgroundColour = null;
|
---|
[4] | 251 |
|
---|
[1102] | 252 | private Colour _colorBorder = null;
|
---|
[4] | 253 |
|
---|
[1102] | 254 | private Colour _colorTopShadow = null;
|
---|
[4] | 255 |
|
---|
[1102] | 256 | private Colour _colorBottomShadow = null;
|
---|
[214] | 257 |
|
---|
[1102] | 258 | /** The shape representing the circle drawn next to link/action items. */
|
---|
| 259 | private static EllipticalBounds _linkCircle = null;
|
---|
[4] | 260 |
|
---|
[1102] | 261 | /** The shape representing the cross drawn next to invalid links. */
|
---|
| 262 | private static PolygonBounds _linkCircleCross = null;
|
---|
[4] | 263 |
|
---|
| 264 | private Frame _parent = null;
|
---|
[741] | 265 | private Frame _oldParent = null;
|
---|
[4] | 266 |
|
---|
| 267 | protected int _highlightThickness = 2;
|
---|
| 268 |
|
---|
[376] | 269 | protected int _vectorHighlightThickness = 1;
|
---|
| 270 |
|
---|
[4] | 271 | // arrowhead parameters
|
---|
[475] | 272 | private float _arrowheadLength = 0;
|
---|
| 273 | private double _arrowheadRatio = DEFAULT_ARROWHEAD_RATIO;
|
---|
| 274 | private double _arrowheadNibPerc = DEFAULT_ARROWHEAD_NIB_PERC;
|
---|
| 275 |
|
---|
[1102] | 276 | private PolygonBounds _arrowhead = null;
|
---|
[4] | 277 |
|
---|
| 278 | // the list of lines that this point is part of.
|
---|
| 279 | private List<Line> _lines = new ArrayList<Line>();
|
---|
| 280 |
|
---|
| 281 | private int[] _linePattern = null;
|
---|
| 282 |
|
---|
| 283 | private boolean _floating = false;
|
---|
| 284 |
|
---|
| 285 | // list of points constrained with this point
|
---|
[50] | 286 | private List<Constraint> _constraints = new ArrayList<Constraint>();
|
---|
[4] | 287 |
|
---|
[74] | 288 | private List<String> _actions = null;
|
---|
[1200] | 289 |
|
---|
[176] | 290 | private String _formula = null;
|
---|
[74] | 291 |
|
---|
[7] | 292 | private String _link_frameset = null;
|
---|
[4] | 293 |
|
---|
[7] | 294 | private String _link_template = null;
|
---|
[4] | 295 |
|
---|
[7] | 296 | private String _fillPattern = null;
|
---|
[50] | 297 |
|
---|
[7] | 298 | private boolean _visible = true;
|
---|
[50] | 299 |
|
---|
| 300 | private float _thickness = -1.0F;
|
---|
| 301 |
|
---|
[1102] | 302 | protected Collection<XRayable> _enclosures = new HashSet<XRayable>();
|
---|
| 303 |
|
---|
| 304 | private boolean _deleted = false;
|
---|
| 305 |
|
---|
| 306 | private Overlay _overlay = null;
|
---|
| 307 |
|
---|
| 308 | protected AttributeValuePair _attributeValuePair = null;
|
---|
| 309 |
|
---|
| 310 | private Float _autoStamp = null;
|
---|
| 311 |
|
---|
| 312 | private Item _magnetizedItemLeft = null;
|
---|
| 313 |
|
---|
| 314 | private Item _magnetizedItemRight = null;
|
---|
| 315 |
|
---|
| 316 | private Item _magnetizedItemTop = null;
|
---|
| 317 |
|
---|
| 318 | private Item _magnetizedItemBottom = null;
|
---|
[1398] | 319 |
|
---|
| 320 | private String _encryptionLabel = null;
|
---|
[1102] | 321 |
|
---|
| 322 | protected DotType _type = DotType.square;
|
---|
| 323 |
|
---|
| 324 | protected boolean _filled = true;
|
---|
[1200] | 325 |
|
---|
[1388] | 326 | private Data _data = new Data();
|
---|
[1415] | 327 |
|
---|
| 328 | // Used via reflection by AttributeUtils to determine if the boolean value is different from default.
|
---|
| 329 | public static final boolean acceptsKeyboardEnterDefault = false;
|
---|
| 330 | private boolean _acceptsKeyboardEnter = acceptsKeyboardEnterDefault;
|
---|
[1102] | 331 |
|
---|
[1408] | 332 | private Item surrogateFor = null;
|
---|
[1413] | 333 | private Set<Item> surrogateItems = new HashSet<Item>();
|
---|
[1414] | 334 | private static Map<String, EncryptionDetail> primaryPropertyEncryptionDefault = new HashMap<String, EncryptionDetail>();
|
---|
[1413] | 335 | private static Map<String, Boolean> surrogatePropertyInheritanceDefault = new HashMap<String, Boolean>();
|
---|
[1414] | 336 | protected Map<String, EncryptionDetail> primaryPropertyEncryption = new HashMap<String, EncryptionDetail>(primaryPropertyEncryptionDefault);
|
---|
[1413] | 337 | protected Map<String, Boolean> surrogatePropertyInheritance = new HashMap<String, Boolean>(surrogatePropertyInheritanceDefault);
|
---|
[1477] | 338 |
|
---|
| 339 | private KeyType keyType = KeyType.NotAKey;
|
---|
[1408] | 340 |
|
---|
[1413] | 341 | {
|
---|
[1415] | 342 | EncryptionDetail unencryptedOnSave = new EncryptionDetail(EncryptionDetail.Type.UnencryptedOnSave);
|
---|
[1418] | 343 | for (String tag: DefaultFrameWriter.getItemTags().keySet()) {
|
---|
| 344 | if (tag == "T" || tag == "S") {
|
---|
| 345 | surrogatePropertyInheritanceDefault.put(tag, false);
|
---|
[1413] | 346 | } else {
|
---|
[1418] | 347 | surrogatePropertyInheritanceDefault.put(tag, true);
|
---|
[1413] | 348 | }
|
---|
[1415] | 349 | primaryPropertyEncryptionDefault.put(tag, unencryptedOnSave);
|
---|
[1413] | 350 | }
|
---|
| 351 | }
|
---|
| 352 |
|
---|
[1102] | 353 | /** Just calls source.duplicateOnto(dest). */
|
---|
| 354 | public static void DuplicateItem(Item source, Item dest)
|
---|
| 355 | {
|
---|
| 356 | if (source == null) return;
|
---|
| 357 |
|
---|
| 358 | source.duplicateOnto(dest);
|
---|
| 359 | }
|
---|
| 360 |
|
---|
| 361 | /** Sets the properties of dest so that they match this item's properties. */
|
---|
| 362 | public void duplicateOnto(Item dest)
|
---|
| 363 | {
|
---|
| 364 | if (dest == null) return;
|
---|
| 365 |
|
---|
| 366 | dest.setX(this.getX());
|
---|
| 367 | dest.setY(this.getY());
|
---|
| 368 |
|
---|
| 369 | dest.setActions(this.getAction());
|
---|
| 370 | dest.setActionCursorEnter(this.getActionCursorEnter());
|
---|
| 371 | dest.setActionCursorLeave(this.getActionCursorLeave());
|
---|
| 372 | dest.setActionEnterFrame(this.getActionEnterFrame());
|
---|
| 373 | dest.setActionLeaveFrame(this.getActionLeaveFrame());
|
---|
| 374 | dest.setActionMark(this.getActionMark());
|
---|
| 375 |
|
---|
| 376 | dest.setBackgroundColor(this.getBackgroundColor());
|
---|
| 377 | dest.setBottomShadowColor(this.getBottomShadowColor());
|
---|
| 378 | dest.setColor(this.getColor());
|
---|
| 379 | dest.setBorderColor(this.getBorderColor());
|
---|
| 380 |
|
---|
| 381 | dest.setTooltips(this.getTooltip());
|
---|
| 382 | dest.setData(this.getData());
|
---|
| 383 | dest.setTag(this.getTag());
|
---|
| 384 | dest.setFillColor(this.getFillColor());
|
---|
| 385 | dest.setGradientColor(this.getGradientColor());
|
---|
| 386 | dest.setGradientAngle(this.getGradientAngle());
|
---|
| 387 | dest.setFillPattern(this.getFillPattern());
|
---|
| 388 |
|
---|
| 389 | dest.setHighlight(this.getHighlight());
|
---|
| 390 | dest.setLink(this.getLink());
|
---|
| 391 | dest.setLinkFrameset(this.getLinkFrameset());
|
---|
| 392 | dest.setLinkMark(this.getLinkMark());
|
---|
| 393 | dest.setLinkTemplate(this.getLinkTemplate());
|
---|
| 394 |
|
---|
[1415] | 395 | // dest.setWidth(this.getWidth());
|
---|
[1102] | 396 |
|
---|
| 397 | dest.setOffset(this.getOffset());
|
---|
| 398 | // dest.setOwner(this.getOwner());
|
---|
| 399 | dest.setThickness(this.getThickness());
|
---|
| 400 | dest.setSize(this.getSize());
|
---|
| 401 | dest.setTopShadowColor(this.getTopShadowColor());
|
---|
| 402 | dest.setLinePattern(this.getLinePattern());
|
---|
| 403 |
|
---|
| 404 | dest.setFloating(this.isFloating());
|
---|
| 405 | dest.setArrow(this.getArrowheadLength(), this.getArrowheadRatio(), this.getArrowheadNibPerc());
|
---|
| 406 | dest.setDotType(this.getDotType());
|
---|
| 407 | dest.setFilled(this.getFilled());
|
---|
| 408 | /*
|
---|
| 409 | * Calling the methods will move the item... This messes things up when
|
---|
| 410 | * the user uses backspace to delete a text line end
|
---|
| 411 | */
|
---|
| 412 | // dest._anchorLeft = this._anchorLeft;
|
---|
| 413 | // dest._anchorRight = this._anchorRight;
|
---|
| 414 | // dest._anchorTop = this._anchorTop;
|
---|
| 415 | // dest._anchorBottom = this._anchorBottom;
|
---|
| 416 | dest.setFormula(this.getFormula());
|
---|
| 417 | dest._overlay = this._overlay;
|
---|
| 418 | dest._highlightMode = this._highlightMode;// SelectedMode.None;
|
---|
| 419 | // dest._highlightColor = this._highlightColor;
|
---|
| 420 | // dest.setHighlight(this.getHighlight());
|
---|
| 421 |
|
---|
| 422 | dest._visible = this._visible;
|
---|
| 423 |
|
---|
| 424 | Frame parent = DisplayController.getCurrentFrame();
|
---|
| 425 | if (parent == null) parent = this.getParentOrCurrentFrame();
|
---|
| 426 | dest.setParent(parent);
|
---|
| 427 |
|
---|
| 428 | /*
|
---|
| 429 | * TODO MIKE says maybe we could tighten up and only give items ID's if
|
---|
| 430 | * their current ID is negative?
|
---|
| 431 | */
|
---|
| 432 | if (parent != null) {
|
---|
| 433 | dest.setID(parent.getNextItemID());
|
---|
| 434 | }
|
---|
[1212] | 435 |
|
---|
[1415] | 436 | String currentUser = UserSettings.UserName.get();
|
---|
| 437 | // if (parent != null && !currentUser.equals(parent.getOwner())) {
|
---|
| 438 | // //dest.setOwner(currentUser);
|
---|
| 439 | // } else {
|
---|
| 440 | // System.err.println("I have duplicated a item and made it owned by "
|
---|
| 441 | // + "current user, whereas the old code would not have "
|
---|
| 442 | // + "changed ownership at this time.");
|
---|
| 443 | // System.err.println("Item: " + dest + ", Class: " + dest.getClass());
|
---|
| 444 | // System.err.println("Current owner: " + dest.getOwner());
|
---|
| 445 | // System.err.println("Current user: " + currentUser);
|
---|
| 446 | // }
|
---|
| 447 | dest.setOwner(currentUser);
|
---|
[1102] | 448 | }
|
---|
| 449 |
|
---|
| 450 | public void setDotType(DotType type) {
|
---|
| 451 | invalidateAll();
|
---|
| 452 | _type = type;
|
---|
| 453 | invalidateAll();
|
---|
[1413] | 454 | if (isSurrogate()) {
|
---|
| 455 | surrogatePropertyInheritance.put(DefaultFrameWriter.DOT_TYPE_STR, false);
|
---|
[1414] | 456 | Item primary = getPrimary();
|
---|
[1413] | 457 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.DOT_TYPE_STR)) {
|
---|
[1415] | 458 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 459 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.DOT_TYPE_STR, inheritanceCheckOnSave);
|
---|
[1413] | 460 | }
|
---|
| 461 | }
|
---|
[1102] | 462 | }
|
---|
| 463 |
|
---|
| 464 | public DotType getDotType() {
|
---|
[1413] | 465 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.DOT_TYPE_STR)) {
|
---|
[1414] | 466 | return this.getPrimary().getDotType();
|
---|
[1410] | 467 | } else {
|
---|
| 468 | return _type;
|
---|
| 469 | }
|
---|
[1102] | 470 | }
|
---|
| 471 |
|
---|
| 472 |
|
---|
[1413] | 473 | public void setFilled(boolean filled) {
|
---|
[1102] | 474 | invalidateAll();
|
---|
| 475 | _filled = filled;
|
---|
| 476 | invalidateAll();
|
---|
[1413] | 477 |
|
---|
| 478 | if (isSurrogate()) {
|
---|
| 479 | surrogatePropertyInheritance.put(DefaultFrameWriter.FILLED_STR, false);
|
---|
[1414] | 480 | Item primary = getPrimary();
|
---|
[1413] | 481 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.DOT_TYPE_STR)) {
|
---|
[1415] | 482 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 483 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.FILLED_STR, inheritanceCheckOnSave);
|
---|
[1413] | 484 | }
|
---|
| 485 | }
|
---|
[1102] | 486 | }
|
---|
| 487 |
|
---|
| 488 | public boolean getFilled() {
|
---|
[1413] | 489 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.FILLED_STR)) {
|
---|
[1414] | 490 | return this.getPrimary().getFilled();
|
---|
[1410] | 491 | } else {
|
---|
| 492 | return _filled;
|
---|
| 493 | }
|
---|
[1102] | 494 | }
|
---|
| 495 |
|
---|
| 496 | /**
|
---|
| 497 | * Sets the angle of colour change for gradient colour fills.
|
---|
| 498 | *
|
---|
| 499 | * @param gradientAngle The new angle of colour change.
|
---|
| 500 | */
|
---|
[1413] | 501 | public void setGradientAngle(double gradientAngle) {
|
---|
[1102] | 502 | _gradientAngle = gradientAngle;
|
---|
| 503 |
|
---|
| 504 | for (Line line : _lines) {
|
---|
| 505 | Item other = line.getOppositeEnd(this);
|
---|
| 506 | if (other.getGradientAngle() != gradientAngle) other.setGradientAngle(gradientAngle);
|
---|
| 507 | }
|
---|
| 508 |
|
---|
| 509 | invalidateCommonTrait(ItemAppearence.GradientColor);
|
---|
| 510 | invalidateFill();
|
---|
[1413] | 511 |
|
---|
| 512 | if (isSurrogate()) {
|
---|
| 513 | surrogatePropertyInheritance.put(DefaultFrameWriter.GRADIENT_ANGLE_STR, false);
|
---|
[1414] | 514 | Item primary = getPrimary();
|
---|
[1413] | 515 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.DOT_TYPE_STR)) {
|
---|
[1415] | 516 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 517 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.GRADIENT_ANGLE_STR, inheritanceCheckOnSave);
|
---|
[1413] | 518 | }
|
---|
| 519 | }
|
---|
[1102] | 520 | }
|
---|
| 521 |
|
---|
| 522 | /**
|
---|
| 523 | * Gets the angle of colour change for gradient fills.
|
---|
| 524 | *
|
---|
| 525 | * @return The angle of colour change.
|
---|
| 526 | */
|
---|
| 527 | public double getGradientAngle() {
|
---|
[1413] | 528 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.GRADIENT_ANGLE_STR)) {
|
---|
[1414] | 529 | return this.getPrimary().getGradientAngle();
|
---|
[1410] | 530 | } else {
|
---|
| 531 | return _gradientAngle;
|
---|
| 532 | }
|
---|
[1102] | 533 | }
|
---|
| 534 |
|
---|
| 535 | /**
|
---|
| 536 | * Gets the gravity for this item. Gravity is the distance from the item at which mouse interaction
|
---|
| 537 | * applies to the item (like a small buffer zone so you don't need to click exactly on the item).
|
---|
| 538 | *
|
---|
| 539 | * @return The gravity distance for this item.
|
---|
| 540 | */
|
---|
| 541 | public int getGravity()
|
---|
| 542 | {
|
---|
| 543 | if (isVectorItem()) return 2;
|
---|
| 544 |
|
---|
| 545 | return UserSettings.Gravity.get();
|
---|
| 546 | }
|
---|
| 547 |
|
---|
| 548 | /**
|
---|
| 549 | * Whether or not line highlights should be shown.
|
---|
| 550 | * TODO: Not really an item method is it? Goes straight to user settings. Refactor. cts16
|
---|
| 551 | *
|
---|
| 552 | * @return <code>true</code> if line highlighting should be shown, <code>false</code> otherwise.
|
---|
| 553 | */
|
---|
| 554 | public static boolean shouldShowLineHighlight()
|
---|
| 555 | {
|
---|
| 556 | return UserSettings.LineHighlight.get();
|
---|
| 557 | }
|
---|
| 558 |
|
---|
| 559 | /**
|
---|
| 560 | * Sets the highlight mode for this item.
|
---|
| 561 | *
|
---|
| 562 | * @param mode The new highlight mode.
|
---|
| 563 | */
|
---|
| 564 | public void setHighlightMode(HighlightMode mode)
|
---|
| 565 | {
|
---|
| 566 | if (hasPermission(UserAppliedPermission.followLinks) || getEditTarget().hasPermission(UserAppliedPermission.followLinks)) {
|
---|
| 567 | if (_highlightMode != mode) {
|
---|
| 568 | _highlightMode = mode;
|
---|
| 569 | this.invalidateCommonTrait(ItemAppearence.HighlightModeChanged);
|
---|
| 570 | }
|
---|
| 571 | }
|
---|
| 572 | }
|
---|
| 573 |
|
---|
| 574 | public void setOverlayPermission(UserAppliedPermission overlayPermission)
|
---|
| 575 | {
|
---|
| 576 | _overlayPermission = overlayPermission;
|
---|
| 577 | }
|
---|
| 578 |
|
---|
[1407] | 579 | public void setPermission(PermissionTriple permissionPair) {
|
---|
| 580 | List<String> groupMembers = getParent() != null ? getParent().getGroupMembers() : new ArrayList<String>();
|
---|
[1402] | 581 | _permissionTriple = permissionPair;
|
---|
[1407] | 582 | if (_permissionTriple.getPermission(_owner, groupMembers) == UserAppliedPermission.denied) {
|
---|
[1200] | 583 | this.getParent().moveItemToBodyHiddenDueToPermission(this);
|
---|
| 584 | }
|
---|
[1413] | 585 |
|
---|
| 586 | if (isSurrogate()) {
|
---|
| 587 | surrogatePropertyInheritance.put(DefaultFrameWriter.PERMISSION_STR, false);
|
---|
[1414] | 588 | Item primary = getPrimary();
|
---|
[1413] | 589 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.DOT_TYPE_STR)) {
|
---|
[1415] | 590 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 591 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.PERMISSION_STR, inheritanceCheckOnSave);
|
---|
[1413] | 592 | }
|
---|
| 593 | }
|
---|
[1102] | 594 | }
|
---|
| 595 |
|
---|
[1402] | 596 | public PermissionTriple getPermission() {
|
---|
[1413] | 597 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.PERMISSION_STR)) {
|
---|
[1414] | 598 | return this.getPrimary().getPermission();
|
---|
[1410] | 599 | } else {
|
---|
| 600 | return _permissionTriple;
|
---|
| 601 | }
|
---|
[1102] | 602 | }
|
---|
| 603 |
|
---|
| 604 | public UserAppliedPermission getUserAppliedPermission() {
|
---|
[1407] | 605 | List<String> groupMembers = getParent() != null ? getParent().getGroupMembers() : new ArrayList<String>();
|
---|
[1102] | 606 | String owner = _owner != null ? _owner : _parent != null ? _parent.getOwner() : null;
|
---|
[1407] | 607 | if(_permissionTriple != null) return _permissionTriple.getPermission(owner, groupMembers);
|
---|
[1102] | 608 | if(_overlayPermission != null) return _overlayPermission;
|
---|
| 609 | if(_parent != null) return _parent.getUserAppliedPermission();
|
---|
| 610 | return UserAppliedPermission.full;
|
---|
| 611 | }
|
---|
| 612 |
|
---|
| 613 | public boolean hasPermission(UserAppliedPermission permission) {
|
---|
| 614 | return getUserAppliedPermission().ordinal() >= permission.ordinal();
|
---|
| 615 | }
|
---|
| 616 |
|
---|
[7] | 617 | protected Item() {
|
---|
[419] | 618 | _creationDate = Formatter.getLongDateTime();
|
---|
[7] | 619 | }
|
---|
[4] | 620 |
|
---|
[7] | 621 | /**
|
---|
| 622 | * Adds an action to this Item.
|
---|
| 623 | *
|
---|
| 624 | * @param action
|
---|
[1102] | 625 | * The name of the action to add to this Item.
|
---|
[7] | 626 | */
|
---|
[1102] | 627 | public void addAction(String action)
|
---|
| 628 | {
|
---|
| 629 | if (action == null || action.equals("")) return;
|
---|
[4] | 630 |
|
---|
[116] | 631 | if (_actions == null) {
|
---|
[7] | 632 | _actions = new LinkedList<String>();
|
---|
[108] | 633 | }
|
---|
[1102] | 634 |
|
---|
[7] | 635 | _actions.add(action);
|
---|
[1102] | 636 |
|
---|
[130] | 637 | if (_actions.size() == 1) {
|
---|
[1102] | 638 | invalidateBounds();
|
---|
[130] | 639 | invalidateCommonTrait(ItemAppearence.LinkChanged);
|
---|
| 640 | }
|
---|
[7] | 641 | }
|
---|
[4] | 642 |
|
---|
[1102] | 643 | public void addAllConnected(Collection<Item> connected)
|
---|
| 644 | {
|
---|
| 645 | if (!connected.contains(this)) connected.add(this);
|
---|
[4] | 646 |
|
---|
[108] | 647 | for (Item item : getConnected()) {
|
---|
[1102] | 648 | if (!connected.contains(item)) {
|
---|
[108] | 649 | item.addAllConnected(connected);
|
---|
[1102] | 650 | }
|
---|
[7] | 651 | }
|
---|
| 652 | }
|
---|
[4] | 653 |
|
---|
[7] | 654 | /**
|
---|
| 655 | * Adds the given Constraint to this Dot
|
---|
| 656 | *
|
---|
| 657 | * @param c
|
---|
| 658 | * The Constraint to set this Dot as a member of.
|
---|
| 659 | */
|
---|
[1102] | 660 | public void addConstraint(Constraint c)
|
---|
| 661 | {
|
---|
[7] | 662 | // do not add duplicate constraint
|
---|
| 663 | if (_constraints.contains(c))
|
---|
| 664 | return;
|
---|
[4] | 665 |
|
---|
[7] | 666 | _constraints.add(c);
|
---|
| 667 | }
|
---|
[4] | 668 |
|
---|
[7] | 669 | /**
|
---|
| 670 | * Adds a given line to the list of lines that this Point is an end for.
|
---|
| 671 | *
|
---|
| 672 | * @param line
|
---|
| 673 | * The Line that this Point is an end of.
|
---|
| 674 | */
|
---|
[1102] | 675 | public void addLine(Line line)
|
---|
| 676 | {
|
---|
[7] | 677 | if (_lines.contains(line)) {
|
---|
| 678 | return;
|
---|
| 679 | }
|
---|
[4] | 680 |
|
---|
[7] | 681 | _lines.add(line);
|
---|
[4] | 682 | }
|
---|
| 683 |
|
---|
| 684 | /**
|
---|
| 685 | * Items are sorted by their Y coordinate on the screen.
|
---|
| 686 | *
|
---|
| 687 | * @param i
|
---|
| 688 | * The Item to compare this Item to
|
---|
| 689 | * @return a negative integer, zero, or a positive integer as this object is
|
---|
| 690 | * less than, equal to, or greater than the specified object.
|
---|
| 691 | */
|
---|
[1102] | 692 | public int compareTo(Item i)
|
---|
| 693 | {
|
---|
[4] | 694 | return getY() - i.getY();
|
---|
| 695 | }
|
---|
| 696 |
|
---|
[7] | 697 | /**
|
---|
| 698 | * Every Item has an area around it defined by a Shape (typically a
|
---|
| 699 | * rectangle), this method returns true if the given x,y pair lies within
|
---|
| 700 | * the area and false otherwise.
|
---|
| 701 | *
|
---|
[1102] | 702 | * @param p
|
---|
| 703 | * The coordinate to check
|
---|
[7] | 704 | * @return True if the Shape around this Item contains the given x,y pair,
|
---|
| 705 | * false otherwise.
|
---|
| 706 | */
|
---|
[1102] | 707 | public boolean contains(Point p)
|
---|
| 708 | {
|
---|
| 709 | return getBounds().contains(p);
|
---|
[4] | 710 | }
|
---|
| 711 |
|
---|
[7] | 712 | /**
|
---|
| 713 | * Returns a deep copy of this Item, note: it is up to the receiver to
|
---|
| 714 | * change the Item ID etc as necessary.
|
---|
| 715 | *
|
---|
| 716 | * @return A deep copy of this Item.
|
---|
| 717 | */
|
---|
| 718 | public abstract Item copy();
|
---|
| 719 |
|
---|
[1102] | 720 | public void delete()
|
---|
| 721 | {
|
---|
[108] | 722 | _deleted = true;
|
---|
[4] | 723 | }
|
---|
| 724 |
|
---|
[108] | 725 | @Override
|
---|
[1102] | 726 | public boolean equals(Object o)
|
---|
| 727 | {
|
---|
[108] | 728 | if (o == null)
|
---|
| 729 | return false;
|
---|
| 730 | if (getClass().equals(o.getClass())) {
|
---|
[4] | 731 | Item i = (Item) o;
|
---|
| 732 | return i.getID() == getID()
|
---|
| 733 | && ((i.getParent() == _parent) || (i.getParent() != null && i
|
---|
| 734 | .getParent().equals(_parent)));
|
---|
| 735 | } else
|
---|
| 736 | return false;
|
---|
| 737 | }
|
---|
| 738 |
|
---|
| 739 | /**
|
---|
[105] | 740 | * Returns a list of any action code that is currently associated with this
|
---|
| 741 | * Item
|
---|
[4] | 742 | *
|
---|
[7] | 743 | * @return A List of action code associated with this Item, or null if none
|
---|
| 744 | * has been assigned.
|
---|
[4] | 745 | */
|
---|
[1388] | 746 | public List<String> getAction() {
|
---|
[1413] | 747 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.ACTION_STR)) {
|
---|
[1414] | 748 | return this.getPrimary().getAction();
|
---|
[1410] | 749 | } else {
|
---|
| 750 | return _actions;
|
---|
| 751 | }
|
---|
[4] | 752 | }
|
---|
| 753 |
|
---|
[1388] | 754 | public List<String> getData() {
|
---|
[1413] | 755 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.DATA_STR)) {
|
---|
[1414] | 756 | return this.getPrimary().getData();
|
---|
[1410] | 757 | } else {
|
---|
[1413] | 758 | return _data.getData();
|
---|
[1410] | 759 | }
|
---|
[74] | 760 | }
|
---|
| 761 |
|
---|
[1388] | 762 | public List<String> getActionCursorEnter() {
|
---|
[1413] | 763 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.ACTION_CURSOR_ENTER_STR)) {
|
---|
[1414] | 764 | return this.getPrimary().getActionCursorEnter();
|
---|
[1410] | 765 | } else {
|
---|
[1413] | 766 | return _actionCursorEnter;
|
---|
[1410] | 767 | }
|
---|
[4] | 768 | }
|
---|
| 769 |
|
---|
[1388] | 770 | public List<String> getActionCursorLeave() {
|
---|
[1413] | 771 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.ACTION_CURSOR_LEAVE_STR)) {
|
---|
[1414] | 772 | return this.getPrimary().getActionCursorLeave();
|
---|
[1410] | 773 | } else {
|
---|
[1413] | 774 | return _actionCursorLeave;
|
---|
[1410] | 775 | }
|
---|
[7] | 776 | }
|
---|
[4] | 777 |
|
---|
[1388] | 778 | public List<String> getActionEnterFrame() {
|
---|
[1413] | 779 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.ACTION_ENTER_FRAME_STR)) {
|
---|
[1414] | 780 | return this.getPrimary().getActionEnterFrame();
|
---|
[1410] | 781 | } else {
|
---|
[1413] | 782 | return _actionEnterFrame;
|
---|
[1410] | 783 | }
|
---|
[4] | 784 | }
|
---|
| 785 |
|
---|
[1388] | 786 | public List<String> getActionLeaveFrame() {
|
---|
[1413] | 787 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.ACTION_LEAVE_FRAME_STR)) {
|
---|
[1414] | 788 | return this.getPrimary().getActionLeaveFrame();
|
---|
[1410] | 789 | } else {
|
---|
[1413] | 790 | return _actionLeaveFrame;
|
---|
[1410] | 791 | }
|
---|
[1388] | 792 | }
|
---|
[4] | 793 |
|
---|
[1388] | 794 | public boolean getActionMark() {
|
---|
[1413] | 795 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.ACTION_MARK_STR)) {
|
---|
[1414] | 796 | return this.getPrimary().getActionMark();
|
---|
[1410] | 797 | } else {
|
---|
[1413] | 798 | return _actionMark;
|
---|
[1410] | 799 | }
|
---|
[4] | 800 | }
|
---|
| 801 |
|
---|
[72] | 802 | /**
|
---|
| 803 | * Gets all the items connected to this item. Uses a recursive approach to
|
---|
| 804 | * search connected points.
|
---|
| 805 | *
|
---|
| 806 | * @return
|
---|
| 807 | */
|
---|
[1102] | 808 | public Collection<Item> getAllConnected()
|
---|
| 809 | {
|
---|
[72] | 810 | Collection<Item> list = new LinkedHashSet<Item>();
|
---|
[7] | 811 | addAllConnected(list);
|
---|
| 812 | return list;
|
---|
[4] | 813 | }
|
---|
| 814 |
|
---|
[1102] | 815 | /* public Area getArea() {
|
---|
[7] | 816 | return new Area(getPolygon());
|
---|
[1102] | 817 | }*/
|
---|
[7] | 818 |
|
---|
[1410] | 819 | public String getArrow() {
|
---|
[1413] | 820 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.ARROW_STR)) {
|
---|
[1414] | 821 | return this.getPrimary().getArrow();
|
---|
[1410] | 822 | } else {
|
---|
| 823 | if (!hasVisibleArrow())
|
---|
| 824 | return null;
|
---|
[7] | 825 |
|
---|
[1410] | 826 | String ratio = "" + getArrowheadRatio();
|
---|
| 827 | if (ratio.length() - ratio.indexOf(".") > 2)
|
---|
| 828 | ratio = ratio.substring(0, ratio.indexOf(".") + 3);
|
---|
[7] | 829 |
|
---|
[1410] | 830 | return getArrowheadLength() + " " + ratio + " " + getArrowheadNibPerc();
|
---|
| 831 | }
|
---|
[7] | 832 | }
|
---|
| 833 |
|
---|
[1102] | 834 | public PolygonBounds getArrowhead()
|
---|
| 835 | {
|
---|
[7] | 836 | return _arrowhead;
|
---|
| 837 | }
|
---|
| 838 |
|
---|
[1102] | 839 | public float getArrowheadLength()
|
---|
| 840 | {
|
---|
[7] | 841 | return _arrowheadLength;
|
---|
| 842 | }
|
---|
| 843 |
|
---|
[1102] | 844 | public double getArrowheadRatio()
|
---|
| 845 | {
|
---|
[7] | 846 | return _arrowheadRatio;
|
---|
| 847 | }
|
---|
| 848 |
|
---|
[1102] | 849 | public double getArrowheadNibPerc()
|
---|
| 850 | {
|
---|
[475] | 851 | return _arrowheadNibPerc;
|
---|
| 852 | }
|
---|
| 853 |
|
---|
[1410] | 854 | public Colour getBackgroundColor() {
|
---|
[1413] | 855 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.BACKGROUND_COLOR_STR)) {
|
---|
[1414] | 856 | return this.getPrimary().getBackgroundColor();
|
---|
[1410] | 857 | } else {
|
---|
[1413] | 858 | return _backgroundColour;
|
---|
[1410] | 859 | }
|
---|
[7] | 860 | }
|
---|
| 861 |
|
---|
[1410] | 862 | public Colour getBorderColor() {
|
---|
[1413] | 863 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.BORDER_COLOR_STR)) {
|
---|
[1414] | 864 | return this.getPrimary().getBorderColor();
|
---|
[1410] | 865 | } else {
|
---|
[1413] | 866 | return _colorBorder;
|
---|
[1410] | 867 | }
|
---|
[214] | 868 | }
|
---|
| 869 |
|
---|
[4] | 870 | /**
|
---|
[7] | 871 | * Returns the Color being used to shade the bottom half of this Item's
|
---|
| 872 | * border. This can be NULL if no Color is being used
|
---|
| 873 | *
|
---|
| 874 | * @return The Color displayed on the bottom\right half of this Item's
|
---|
| 875 | * border.
|
---|
[4] | 876 | */
|
---|
[1102] | 877 | public Colour getBottomShadowColor()
|
---|
| 878 | {
|
---|
[7] | 879 | return _colorBottomShadow;
|
---|
[4] | 880 | }
|
---|
| 881 |
|
---|
| 882 | /**
|
---|
[7] | 883 | * Returns the height (in pixels) of this Item's surrounding area.
|
---|
[4] | 884 | *
|
---|
[7] | 885 | * @return The height (in pixels) of this Item's surrounding area as
|
---|
| 886 | * returned by getArea().
|
---|
[4] | 887 | */
|
---|
[1102] | 888 | public int getBoundsHeight()
|
---|
| 889 | {
|
---|
| 890 | return AxisAlignedBoxBounds.getEnclosing(getBounds()).getHeight();
|
---|
[4] | 891 | }
|
---|
| 892 |
|
---|
| 893 | /**
|
---|
[7] | 894 | * Returns the width (in pixels) of this Item's surrounding area.
|
---|
[4] | 895 | *
|
---|
[7] | 896 | * @return The width (in pixels) of this Item's surrounding area as returned
|
---|
| 897 | * by getArea().
|
---|
[4] | 898 | */
|
---|
[1102] | 899 | public int getBoundsWidth()
|
---|
| 900 | {
|
---|
| 901 | return AxisAlignedBoxBounds.getEnclosing(getBounds()).getWidth();
|
---|
[4] | 902 | }
|
---|
| 903 |
|
---|
[1102] | 904 | // TODO: Remove magic constants. cts16
|
---|
| 905 | public EllipticalBounds getLinkBounds()
|
---|
| 906 | {
|
---|
| 907 | if (_linkCircle == null) {
|
---|
| 908 | _linkCircle = new EllipticalBounds(new Point(6, 3), 7);
|
---|
[7] | 909 | }
|
---|
| 910 |
|
---|
[1102] | 911 | return _linkCircle;
|
---|
[4] | 912 | }
|
---|
| 913 |
|
---|
[1102] | 914 | protected PolygonBounds getCircleCross()
|
---|
| 915 | {
|
---|
[7] | 916 |
|
---|
[1102] | 917 | if (_linkCircleCross == null) {
|
---|
| 918 | _linkCircleCross = new PolygonBounds();
|
---|
[7] | 919 |
|
---|
[1102] | 920 | EllipticalBounds poly = getLinkBounds();
|
---|
| 921 | int x1 = poly.getMinX();
|
---|
| 922 | int x2 = poly.getMaxX();
|
---|
| 923 | int y1 = poly.getMinY();
|
---|
| 924 | int y2 = poly.getMaxY();
|
---|
| 925 | int midX = (x2 + x1) / 2;
|
---|
| 926 | int midY = (y2 + y1) / 2;
|
---|
[7] | 927 |
|
---|
[1102] | 928 | _linkCircleCross.addPoint(new Point(x1, y1));
|
---|
| 929 | _linkCircleCross.addPoint(new Point(x2, y2));
|
---|
| 930 | _linkCircleCross.addPoint(new Point(midX, midY));
|
---|
| 931 | _linkCircleCross.addPoint(new Point(x1, y2));
|
---|
| 932 | _linkCircleCross.addPoint(new Point(x2, y1));
|
---|
| 933 | _linkCircleCross.addPoint(new Point(midX, midY));
|
---|
[7] | 934 | }
|
---|
| 935 |
|
---|
[1102] | 936 | return _linkCircleCross;
|
---|
[4] | 937 | }
|
---|
| 938 |
|
---|
[1410] | 939 | public Colour getColor() {
|
---|
[1413] | 940 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.COLOR_STR)) {
|
---|
[1414] | 941 | return this.getPrimary().getColor();
|
---|
[1410] | 942 | } else {
|
---|
[1413] | 943 | return _foregroundColour;
|
---|
[1410] | 944 | }
|
---|
[4] | 945 | }
|
---|
| 946 |
|
---|
[1102] | 947 | public Collection<Item> getConnected()
|
---|
| 948 | {
|
---|
[7] | 949 | List<Item> conn = new LinkedList<Item>();
|
---|
| 950 | conn.add(this);
|
---|
[108] | 951 | conn.addAll(getEnclosures());
|
---|
[7] | 952 | conn.addAll(getLines());
|
---|
| 953 | return conn;
|
---|
| 954 | }
|
---|
| 955 |
|
---|
[1410] | 956 | public String getConstraintIDs() {
|
---|
[1413] | 957 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.CONSTRAINT_IDS_STR)) {
|
---|
[1414] | 958 | return this.getPrimary().getConstraintIDs();
|
---|
[1410] | 959 | } else {
|
---|
| 960 | if (_constraints == null || _constraints.size() == 0)
|
---|
| 961 | return null;
|
---|
[4] | 962 |
|
---|
[1410] | 963 | String cons = "";
|
---|
[4] | 964 |
|
---|
[1410] | 965 | for (Constraint c : _constraints)
|
---|
| 966 | cons += c.getID() + " ";
|
---|
[4] | 967 |
|
---|
[1410] | 968 | return cons.trim();
|
---|
| 969 | }
|
---|
[4] | 970 | }
|
---|
| 971 |
|
---|
[7] | 972 | /*
|
---|
| 973 | * public void setLinkValid(boolean val) { _isValidLink = val; }
|
---|
| 974 | */
|
---|
[4] | 975 |
|
---|
| 976 | /**
|
---|
[7] | 977 | * Returns a List of any Constraints that this Dot is a memeber of.
|
---|
[4] | 978 | *
|
---|
[7] | 979 | * @return a List of Constraints that this Dot is a member of.
|
---|
[4] | 980 | */
|
---|
[1102] | 981 | public List<Constraint> getConstraints()
|
---|
| 982 | {
|
---|
[7] | 983 | return _constraints;
|
---|
| 984 | }
|
---|
[4] | 985 |
|
---|
[1102] | 986 | public String getTag()
|
---|
| 987 | {
|
---|
[74] | 988 | if (_tag != null && _tag.length() > 0)
|
---|
| 989 | return _tag.toString();
|
---|
[7] | 990 | return null;
|
---|
[4] | 991 | }
|
---|
| 992 |
|
---|
[1410] | 993 | public String getDateCreated() {
|
---|
[1413] | 994 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.DATE_CREATED_STR)) {
|
---|
[1414] | 995 | return this.getPrimary().getDateCreated();
|
---|
[1410] | 996 | } else {
|
---|
[1413] | 997 | return _creationDate;
|
---|
[1410] | 998 | }
|
---|
[4] | 999 | }
|
---|
| 1000 |
|
---|
[1410] | 1001 | public Colour getFillColor() {
|
---|
[1413] | 1002 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.FILL_COLOR_STR)) {
|
---|
[1414] | 1003 | return this.getPrimary().getFillColor();
|
---|
[1410] | 1004 | } else {
|
---|
[1413] | 1005 | return _fillColour;
|
---|
[1410] | 1006 | }
|
---|
[4] | 1007 | }
|
---|
| 1008 |
|
---|
[1410] | 1009 | public String getFillPattern() {
|
---|
[1413] | 1010 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.FILL_PATTERN_STR)) {
|
---|
[1414] | 1011 | return this.getPrimary().getFillPattern();
|
---|
[1410] | 1012 | } else {
|
---|
[1413] | 1013 | return _fillPattern;
|
---|
[1410] | 1014 | }
|
---|
[4] | 1015 | }
|
---|
| 1016 |
|
---|
[1102] | 1017 | public String getFirstAction()
|
---|
| 1018 | {
|
---|
[74] | 1019 | if (_actions == null || _actions.size() == 0)
|
---|
[7] | 1020 | return null;
|
---|
[74] | 1021 | return _actions.get(0);
|
---|
[4] | 1022 | }
|
---|
| 1023 |
|
---|
[1102] | 1024 | /**
|
---|
| 1025 | * Gets the value of <code>_highlight</code> for this item.
|
---|
| 1026 | * TODO: Appears unused? cts16.
|
---|
| 1027 | *
|
---|
| 1028 | * @return The value of <code>_highlight</code>.
|
---|
| 1029 | */
|
---|
[1410] | 1030 | public boolean getHighlight() {
|
---|
[1413] | 1031 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.HIGHLIGHT_STR)) {
|
---|
[1414] | 1032 | return this.getPrimary().getHighlight();
|
---|
[1410] | 1033 | } else {
|
---|
[1413] | 1034 | return _highlight;
|
---|
[1410] | 1035 | }
|
---|
[4] | 1036 | }
|
---|
| 1037 |
|
---|
[1102] | 1038 | public Colour getHighlightColor()
|
---|
| 1039 | {
|
---|
| 1040 | if (_highlightColour.equals(getPaintColor())) return getAlternateHighlightColor();
|
---|
| 1041 |
|
---|
[376] | 1042 | return getDefaultHighlightColor();
|
---|
[4] | 1043 | }
|
---|
| 1044 |
|
---|
| 1045 | /**
|
---|
[7] | 1046 | * Returns the ID of this Item, which must be unique for the Frame.
|
---|
[4] | 1047 | *
|
---|
[7] | 1048 | * @return The ID of this Item.
|
---|
[1102] | 1049 | *
|
---|
| 1050 | * TODO: What does it mean to have a negative ID# (as used in TDFC)? cts16
|
---|
[4] | 1051 | */
|
---|
[1430] | 1052 | public int getID() {
|
---|
[7] | 1053 | return _id;
|
---|
[4] | 1054 | }
|
---|
| 1055 |
|
---|
| 1056 | /**
|
---|
[7] | 1057 | * Returns the list of IDs of the Lines that this Dot is an end of.
|
---|
[4] | 1058 | *
|
---|
[7] | 1059 | * @return The list of Line IDs that this point is part of.
|
---|
[4] | 1060 | */
|
---|
[1410] | 1061 | public String getLineIDs() {
|
---|
[1413] | 1062 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.LINE_IDS_STR)) {
|
---|
[1414] | 1063 | return this.getPrimary().getLineIDs();
|
---|
[1410] | 1064 | } else {
|
---|
| 1065 | String lineID = null;
|
---|
[4] | 1066 |
|
---|
[1410] | 1067 | if (_lines.size() > 0) {
|
---|
| 1068 | lineID = "" + _lines.get(0).getID();
|
---|
[4] | 1069 |
|
---|
[1410] | 1070 | for (int i = 1; i < _lines.size(); i++)
|
---|
| 1071 | lineID += " " + _lines.get(i).getID();
|
---|
| 1072 | }
|
---|
| 1073 |
|
---|
| 1074 | return lineID;
|
---|
[4] | 1075 | }
|
---|
| 1076 | }
|
---|
| 1077 |
|
---|
[1410] | 1078 | public int[] getLinePattern() {
|
---|
[1413] | 1079 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.LINE_PATTERN_STR)) {
|
---|
[1414] | 1080 | return this.getPrimary().getLinePattern();
|
---|
[1410] | 1081 | } else {
|
---|
[1413] | 1082 | return _linePattern;
|
---|
[1410] | 1083 | }
|
---|
[4] | 1084 | }
|
---|
| 1085 |
|
---|
| 1086 | /**
|
---|
[7] | 1087 | * Returns a list of Lines where this Dot is an end.
|
---|
[4] | 1088 | *
|
---|
[7] | 1089 | * @return A list of the Lines that this Dot is an end for or null if no
|
---|
| 1090 | * Lines have been added.
|
---|
[4] | 1091 | */
|
---|
[1102] | 1092 | public List<Line> getLines()
|
---|
| 1093 | {
|
---|
[7] | 1094 | return _lines;
|
---|
[4] | 1095 | }
|
---|
| 1096 |
|
---|
| 1097 | /**
|
---|
| 1098 | * Returns the name of a Frame that this Item links to, or null if this Item
|
---|
| 1099 | * has no link.
|
---|
| 1100 | *
|
---|
| 1101 | * @return The name of a Frame that this Item links to (if any) or null if
|
---|
| 1102 | * this Item does not link to anything.
|
---|
| 1103 | */
|
---|
[1410] | 1104 | public String getLink() {
|
---|
[1413] | 1105 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.LINK_STR)) {
|
---|
[1414] | 1106 | return this.getPrimary().getLink();
|
---|
[1410] | 1107 | } else {
|
---|
[1413] | 1108 | return _link;
|
---|
[1410] | 1109 | }
|
---|
[4] | 1110 | }
|
---|
[181] | 1111 |
|
---|
[1410] | 1112 | public String getFormula() {
|
---|
[1413] | 1113 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.FORMULA_STR)) {
|
---|
[1414] | 1114 | return this.getPrimary().getFormula();
|
---|
[1410] | 1115 | } else {
|
---|
[1413] | 1116 | return _formula;
|
---|
[1410] | 1117 | }
|
---|
[176] | 1118 | }
|
---|
[181] | 1119 |
|
---|
[1102] | 1120 | public boolean hasFormula()
|
---|
| 1121 | {
|
---|
[176] | 1122 | return _formula != null;
|
---|
| 1123 | }
|
---|
[410] | 1124 |
|
---|
[1102] | 1125 | public boolean hasAttributeValuePair()
|
---|
| 1126 | {
|
---|
[376] | 1127 | return _attributeValuePair != null && _attributeValuePair.hasPair();
|
---|
| 1128 | }
|
---|
[181] | 1129 |
|
---|
[1413] | 1130 | public void setFormula(String formula) {
|
---|
[176] | 1131 | _formula = formula;
|
---|
[1413] | 1132 |
|
---|
| 1133 | if (isSurrogate()) {
|
---|
| 1134 | surrogatePropertyInheritance.put(DefaultFrameWriter.FORMULA_STR, false);
|
---|
[1414] | 1135 | Item primary = getPrimary();
|
---|
[1413] | 1136 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.FORMULA_STR)) {
|
---|
[1415] | 1137 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 1138 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.FORMULA_STR, inheritanceCheckOnSave);
|
---|
[1413] | 1139 | }
|
---|
| 1140 | }
|
---|
[176] | 1141 | }
|
---|
[181] | 1142 |
|
---|
[1102] | 1143 | public boolean calculate(String formula)
|
---|
| 1144 | {
|
---|
[176] | 1145 | setFormula(formula);
|
---|
[291] | 1146 | return true;
|
---|
[176] | 1147 | }
|
---|
[4] | 1148 |
|
---|
[1410] | 1149 | public String getLinkFrameset() {
|
---|
[1413] | 1150 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.LINK_FRAMESET_STR)) {
|
---|
[1414] | 1151 | return this.getPrimary().getLinkFrameset();
|
---|
[1410] | 1152 | } else {
|
---|
[1413] | 1153 | return _link_frameset;
|
---|
[1410] | 1154 | }
|
---|
[4] | 1155 | }
|
---|
| 1156 |
|
---|
[1410] | 1157 | public boolean getLinkMark() {
|
---|
[1413] | 1158 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.LINK_MARK_STR)) {
|
---|
[1414] | 1159 | return this.getPrimary().getLinkMark();
|
---|
[1410] | 1160 | } else {
|
---|
[1413] | 1161 | return _linkMark;
|
---|
[1410] | 1162 | }
|
---|
[4] | 1163 | }
|
---|
| 1164 |
|
---|
[1410] | 1165 | public String getLinkTemplate() {
|
---|
[1413] | 1166 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.LINK_TEMPLATE_STR)) {
|
---|
[1414] | 1167 | return this.getPrimary().getLinkTemplate();
|
---|
[1410] | 1168 | } else {
|
---|
[1413] | 1169 | return _link_template;
|
---|
[1410] | 1170 | }
|
---|
[4] | 1171 | }
|
---|
| 1172 |
|
---|
[1102] | 1173 | public Point getOffset()
|
---|
| 1174 | {
|
---|
[7] | 1175 | return _offset;
|
---|
[4] | 1176 | }
|
---|
| 1177 |
|
---|
[1410] | 1178 | public String getOwner() {
|
---|
[1413] | 1179 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.OWNER_STR)) {
|
---|
[1414] | 1180 | return this.getPrimary().getOwner();
|
---|
[1410] | 1181 | } else {
|
---|
[1413] | 1182 | return _owner;
|
---|
[1410] | 1183 | }
|
---|
[4] | 1184 | }
|
---|
[50] | 1185 |
|
---|
[1102] | 1186 | public Colour getPaintBackgroundColor()
|
---|
| 1187 | {
|
---|
| 1188 | Colour colorBackground = getBackgroundColor();
|
---|
[108] | 1189 | if (colorBackground == null) {
|
---|
[7] | 1190 | if (getParent() != null && getParent().getBackgroundColor() != null)
|
---|
| 1191 | return getParent().getBackgroundColor();
|
---|
[4] | 1192 |
|
---|
[7] | 1193 | return DEFAULT_BACKGROUND;
|
---|
| 1194 | }
|
---|
| 1195 |
|
---|
[108] | 1196 | return colorBackground;
|
---|
[4] | 1197 | }
|
---|
| 1198 |
|
---|
| 1199 | /**
|
---|
[7] | 1200 | * Returns the foreground Color of this Item.
|
---|
[4] | 1201 | *
|
---|
[7] | 1202 | * @return The Color of this item (foreground)
|
---|
[4] | 1203 | */
|
---|
[1102] | 1204 | public final Colour getPaintColor()
|
---|
| 1205 | {
|
---|
[80] | 1206 | // If color is null then get the paint foregroundColor for the frame the
|
---|
| 1207 | // item is on which is a color adjusted to suit the background
|
---|
[1102] | 1208 | Colour color = getColor();
|
---|
[108] | 1209 |
|
---|
| 1210 | if (color == null) {
|
---|
[7] | 1211 | if (getParent() != null)
|
---|
| 1212 | return getParent().getPaintForegroundColor();
|
---|
| 1213 |
|
---|
[1102] | 1214 | Frame current = DisplayController.getCurrentFrame();
|
---|
[242] | 1215 | if (current == null) {
|
---|
[7] | 1216 | return DEFAULT_FOREGROUND;
|
---|
[220] | 1217 | }
|
---|
[80] | 1218 | return current.getPaintForegroundColor();
|
---|
[4] | 1219 | }
|
---|
| 1220 |
|
---|
[108] | 1221 | return color;
|
---|
[4] | 1222 | }
|
---|
| 1223 |
|
---|
[1102] | 1224 | public final Colour getPaintBorderColor()
|
---|
| 1225 | {
|
---|
[242] | 1226 | // If color is null then get the paint foregroundColor for the frame the
|
---|
| 1227 | // item is on which is a color adjusted to suit the background
|
---|
[1102] | 1228 | Colour color = getBorderColor();
|
---|
[242] | 1229 |
|
---|
| 1230 | if (color == null) {
|
---|
| 1231 | if (getParent() != null)
|
---|
| 1232 | return getParent().getPaintForegroundColor();
|
---|
| 1233 |
|
---|
[1102] | 1234 | Frame current = DisplayController.getCurrentFrame();
|
---|
[242] | 1235 | if (current == null) {
|
---|
| 1236 | return DEFAULT_FOREGROUND;
|
---|
| 1237 | }
|
---|
| 1238 | return current.getPaintForegroundColor();
|
---|
| 1239 | }
|
---|
| 1240 |
|
---|
| 1241 | return color;
|
---|
| 1242 | }
|
---|
| 1243 |
|
---|
[1102] | 1244 | protected Colour getPaintHighlightColor()
|
---|
| 1245 | {
|
---|
| 1246 | Colour highlightColor = getDefaultHighlightColor();
|
---|
[242] | 1247 | if (hasVisibleBorder()) {
|
---|
| 1248 | if (getPaintBorderColor().equals(highlightColor)) {
|
---|
[376] | 1249 | highlightColor = getDefaultHighlightColor();
|
---|
[242] | 1250 | }
|
---|
| 1251 | } else if (getPaintBackgroundColor().equals(highlightColor)) {
|
---|
[376] | 1252 | highlightColor = getDefaultHighlightColor();
|
---|
[242] | 1253 | }
|
---|
[1102] | 1254 |
|
---|
| 1255 | if (getParent() != null && getParent().getPaintBackgroundColor().equals(highlightColor)) {
|
---|
[131] | 1256 | highlightColor = getParent().getPaintForegroundColor();
|
---|
[1102] | 1257 | }
|
---|
[7] | 1258 |
|
---|
[214] | 1259 | if (hasVisibleBorder()) {
|
---|
[1102] | 1260 | if (highlightColor.equals(getBorderColor()) && getThickness() == getHighlightThickness()) {
|
---|
| 1261 | highlightColor = highlightColor.clone();
|
---|
| 1262 | highlightColor.setAlpha(Colour.FromComponent255(150));
|
---|
[214] | 1263 | }
|
---|
| 1264 | }
|
---|
| 1265 |
|
---|
[131] | 1266 | return highlightColor;
|
---|
[4] | 1267 | }
|
---|
| 1268 |
|
---|
[1102] | 1269 | protected Colour getDefaultHighlightColor()
|
---|
| 1270 | {
|
---|
| 1271 | if (isVectorItem() && !this.contains(EcosystemManager.getInputManager().getCursorPosition())) {
|
---|
| 1272 | return Colour.FromRGB255(255, BRIGHTNESS, BRIGHTNESS);
|
---|
[376] | 1273 | }
|
---|
[1102] | 1274 | return _highlightColour;
|
---|
[376] | 1275 | }
|
---|
| 1276 |
|
---|
[1102] | 1277 | protected Colour getAlternateHighlightColor()
|
---|
| 1278 | {
|
---|
| 1279 | if (isVectorItem() && !this.contains(EcosystemManager.getInputManager().getCursorPosition())) {
|
---|
| 1280 | return Colour.FromRGB255(BRIGHTNESS, BRIGHTNESS, 255);
|
---|
[376] | 1281 | }
|
---|
| 1282 | return ALTERNATE_HIGHLIGHT;
|
---|
| 1283 | }
|
---|
| 1284 |
|
---|
[1102] | 1285 | protected int getHighlightThickness()
|
---|
| 1286 | {
|
---|
| 1287 | if (isVectorItem()) return _vectorHighlightThickness;
|
---|
| 1288 |
|
---|
[376] | 1289 | return _highlightThickness;
|
---|
| 1290 | }
|
---|
| 1291 |
|
---|
[1102] | 1292 | public final Frame getParent()
|
---|
| 1293 | {
|
---|
[7] | 1294 | return _parent;
|
---|
| 1295 | }
|
---|
| 1296 |
|
---|
[1102] | 1297 | /** Gets the position of this item. */
|
---|
[1410] | 1298 | public final Point getPosition() {
|
---|
[1413] | 1299 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.POSITION_STR)) {
|
---|
[1414] | 1300 | return this.getPrimary().getPosition();
|
---|
[1410] | 1301 | } else {
|
---|
| 1302 | return new Point(getX(), getY());
|
---|
| 1303 | }
|
---|
[4] | 1304 | }
|
---|
| 1305 |
|
---|
| 1306 | /**
|
---|
[7] | 1307 | * Returns the size of this Item. For Text this is the Font size, for Lines
|
---|
| 1308 | * and Dots this is the thickness.
|
---|
[4] | 1309 | *
|
---|
[7] | 1310 | * @return The size of this Item.
|
---|
[4] | 1311 | */
|
---|
[1102] | 1312 | public float getSize()
|
---|
| 1313 | {
|
---|
| 1314 | return SIZE_NOT_APPLICABLE;
|
---|
[4] | 1315 | }
|
---|
| 1316 |
|
---|
| 1317 | /**
|
---|
[7] | 1318 | * Returns the Color being used to shade the top half of this Item's border.
|
---|
| 1319 | * This can be NULL if no Color is being used
|
---|
[4] | 1320 | *
|
---|
[7] | 1321 | * @return The Color displayed on the top\left half of this Item's border.
|
---|
[4] | 1322 | */
|
---|
[1102] | 1323 | public Colour getTopShadowColor()
|
---|
| 1324 | {
|
---|
[7] | 1325 | return _colorTopShadow;
|
---|
| 1326 | }
|
---|
[4] | 1327 |
|
---|
[1410] | 1328 | public String getTypeAndID() {
|
---|
[1413] | 1329 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.TYPE_AND_ID_STR)) {
|
---|
[1414] | 1330 | return this.getPrimary().getTypeAndID();
|
---|
[1410] | 1331 | } else {
|
---|
| 1332 | return "T " + getID();
|
---|
| 1333 | }
|
---|
[4] | 1334 | }
|
---|
| 1335 |
|
---|
[1410] | 1336 | public Integer getWidthToSave() {
|
---|
[1413] | 1337 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.WIDTH_TO_SAVE_STR)) {
|
---|
[1414] | 1338 | return this.getPrimary().getWidthToSave();
|
---|
[1410] | 1339 | } else {
|
---|
| 1340 | return getWidth();
|
---|
| 1341 | }
|
---|
[7] | 1342 | }
|
---|
[1200] | 1343 |
|
---|
| 1344 | public Integer getMinWidthToSave() {
|
---|
[1413] | 1345 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.MIN_WIDTH_TO_SAVE_STR)) {
|
---|
[1414] | 1346 | return this.getPrimary().getMinWidthToSave();
|
---|
[1410] | 1347 | } else {
|
---|
| 1348 | return getMinWidth();
|
---|
| 1349 | }
|
---|
[1200] | 1350 | }
|
---|
[410] | 1351 |
|
---|
[1102] | 1352 | public Integer getWidth()
|
---|
| 1353 | {
|
---|
[400] | 1354 | return null;
|
---|
| 1355 | }
|
---|
[1200] | 1356 |
|
---|
| 1357 | public Integer getMinWidth() {
|
---|
| 1358 | return null;
|
---|
| 1359 | }
|
---|
[4] | 1360 |
|
---|
[1102] | 1361 | public int getHeight()
|
---|
| 1362 | {
|
---|
[1412] | 1363 | return 0;
|
---|
[282] | 1364 | }
|
---|
| 1365 |
|
---|
[4] | 1366 | /**
|
---|
[7] | 1367 | * Returns the X coordinate of this Item on the screen
|
---|
[4] | 1368 | *
|
---|
[7] | 1369 | * @return The X coordinate of this Item on the screen
|
---|
[4] | 1370 | */
|
---|
[1410] | 1371 | public int getX() {
|
---|
[1413] | 1372 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.POSITION_STR)) {
|
---|
[1414] | 1373 | return this.getPrimary().getX();
|
---|
[1410] | 1374 | } else {
|
---|
| 1375 | return Math.round(_x);
|
---|
| 1376 | }
|
---|
[4] | 1377 | }
|
---|
| 1378 |
|
---|
| 1379 | /**
|
---|
[7] | 1380 | * Returns the Y coordinate of this Item on the screen
|
---|
[4] | 1381 | *
|
---|
[7] | 1382 | * @return The Y coordinate of this Item on the screen
|
---|
[4] | 1383 | */
|
---|
[1410] | 1384 | public int getY() {
|
---|
[1413] | 1385 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.POSITION_STR)) {
|
---|
[1414] | 1386 | return this.getPrimary().getY();
|
---|
[1410] | 1387 | } else {
|
---|
| 1388 | return Math.round(_y);
|
---|
| 1389 | }
|
---|
[4] | 1390 | }
|
---|
| 1391 |
|
---|
[1102] | 1392 | public boolean hasVisibleArrow()
|
---|
| 1393 | {
|
---|
[472] | 1394 | return isLineEnd() && getArrowheadRatio() != 0 && getArrowheadLength() != 0;
|
---|
[7] | 1395 | }
|
---|
| 1396 |
|
---|
[4] | 1397 | /**
|
---|
| 1398 | * Checks if the given Shape intersects with the Shape around this Item.
|
---|
| 1399 | *
|
---|
| 1400 | * @param s
|
---|
| 1401 | * The Shape to check.
|
---|
| 1402 | * @return True if the two Shapes overlap, False otherwise.
|
---|
| 1403 | */
|
---|
[1102] | 1404 | public boolean intersects(PolygonBounds otherBounds)
|
---|
| 1405 | {
|
---|
| 1406 | if (otherBounds == null) return false;
|
---|
| 1407 |
|
---|
| 1408 | Bounds thisBounds = getBounds();
|
---|
| 1409 |
|
---|
[181] | 1410 | // Need to do this check for circles
|
---|
[1102] | 1411 | if (otherBounds.equals(thisBounds)) return true;
|
---|
[50] | 1412 |
|
---|
[1415] | 1413 | boolean intersects = otherBounds.intersects(thisBounds);
|
---|
| 1414 |
|
---|
| 1415 | /*if (intersects) {
|
---|
| 1416 | System.err.println("Found intersection between this item (" + this + ") with bounds: " + thisBounds + "...and...");
|
---|
| 1417 | System.err.println("item with bounds: " + otherBounds.toString());
|
---|
| 1418 | }*/
|
---|
| 1419 | return intersects;
|
---|
[181] | 1420 |
|
---|
| 1421 | // Need to check the second equality so that we dont pick up circles
|
---|
| 1422 | // inside other circles
|
---|
[1102] | 1423 | //return !a.isEmpty() && !a.equals(new Area(p));
|
---|
[4] | 1424 | }
|
---|
| 1425 |
|
---|
| 1426 | /**
|
---|
[7] | 1427 | * Note: Pictures always return False, as they should be drawn even when no
|
---|
| 1428 | * other annotation Items are.
|
---|
[4] | 1429 | *
|
---|
[7] | 1430 | * @return True if this Item is an annotation, False otherwise.
|
---|
[4] | 1431 | */
|
---|
[1102] | 1432 | public boolean isAnnotation()
|
---|
| 1433 | {
|
---|
[72] | 1434 | return false;
|
---|
| 1435 | }
|
---|
[7] | 1436 |
|
---|
[1102] | 1437 | public boolean isFloating()
|
---|
| 1438 | {
|
---|
[7] | 1439 | return _floating;
|
---|
[4] | 1440 | }
|
---|
| 1441 |
|
---|
[1102] | 1442 | public boolean isFrameName()
|
---|
| 1443 | {
|
---|
[80] | 1444 | if (this.getParent() == null || this.getParent().getNameItem() != this)
|
---|
[7] | 1445 | return false;
|
---|
| 1446 | return true;
|
---|
[4] | 1447 | }
|
---|
| 1448 |
|
---|
[1102] | 1449 | public boolean isFrameTitle()
|
---|
| 1450 | {
|
---|
[80] | 1451 | if (this.getParent() == null || this.getParent().getTitleItem() != this)
|
---|
[7] | 1452 | return false;
|
---|
| 1453 | return true;
|
---|
[4] | 1454 | }
|
---|
| 1455 |
|
---|
| 1456 | /**
|
---|
| 1457 | * Returns True if this Item is currently highlighted.
|
---|
| 1458 | *
|
---|
| 1459 | * @return True if this Item is currently highlighted on the screen, False
|
---|
| 1460 | * otherwise.
|
---|
| 1461 | */
|
---|
[1102] | 1462 | public boolean isHighlighted()
|
---|
| 1463 | {
|
---|
[108] | 1464 | if (isFloating())
|
---|
| 1465 | return false;
|
---|
[1102] | 1466 | return _highlightMode != HighlightMode.None;
|
---|
[4] | 1467 | }
|
---|
| 1468 |
|
---|
| 1469 | /**
|
---|
[7] | 1470 | * Tests if the item link is a valid framename, that is, the String must
|
---|
| 1471 | * begin with a character, end with a number with 0 or more letters and
|
---|
| 1472 | * numbers in between. If there is a dot in the framename all the chars
|
---|
| 1473 | * after it must be digits.
|
---|
[4] | 1474 | *
|
---|
[7] | 1475 | * @return True if the given framename is proper, false otherwise.
|
---|
[4] | 1476 | */
|
---|
[1102] | 1477 | public boolean isLinkValid()
|
---|
| 1478 | {
|
---|
[7] | 1479 | if (FrameIO.isPositiveInteger(getLink()))
|
---|
| 1480 | return true;
|
---|
[4] | 1481 |
|
---|
[7] | 1482 | if (FrameIO.isValidFrameName(getLink()))
|
---|
| 1483 | return true;
|
---|
| 1484 | return false;
|
---|
| 1485 | }
|
---|
[4] | 1486 |
|
---|
[1102] | 1487 | /**
|
---|
| 1488 | * Checks if the given point is 'near' to the item. Here 'near' means within a certain distance
|
---|
| 1489 | * of the axis-aligned box bounding the item's polygon.
|
---|
| 1490 | *
|
---|
| 1491 | * @param x
|
---|
| 1492 | * The x-coordinate of the point to check.
|
---|
| 1493 | *
|
---|
| 1494 | * @param y
|
---|
| 1495 | * The y-coordinate of the point to check.
|
---|
| 1496 | *
|
---|
| 1497 | * @return
|
---|
| 1498 | * True if the given point is 'near' to the item, false otherwise.
|
---|
| 1499 | */
|
---|
| 1500 | public boolean isNear(int x, int y)
|
---|
| 1501 | {
|
---|
| 1502 | AxisAlignedBoxBounds box = ItemUtils.expandRectangle(getBoundingBox(), NEAR_DISTANCE * 2);
|
---|
| 1503 |
|
---|
| 1504 | return box.contains(x, y);
|
---|
[7] | 1505 | }
|
---|
[4] | 1506 |
|
---|
[1102] | 1507 | public boolean isOldTag()
|
---|
| 1508 | {
|
---|
[7] | 1509 | if (this instanceof Text)
|
---|
[80] | 1510 | if (((Text) this).getTextList().get(0).toLowerCase().equals("@old"))
|
---|
[7] | 1511 | return true;
|
---|
| 1512 | return false;
|
---|
[4] | 1513 | }
|
---|
| 1514 |
|
---|
| 1515 | /**
|
---|
| 1516 | * Merges this Item with the given Item. The merger Item should be left
|
---|
| 1517 | * unchanged after this method. The merger may or may not be the same class
|
---|
| 1518 | * as this Item, exact behaviour depends on the subclass, No-op is allowed.
|
---|
| 1519 | *
|
---|
| 1520 | * @param merger
|
---|
| 1521 | * The Item to merge with
|
---|
| 1522 | * @return any Item that should remain on the cursor
|
---|
| 1523 | */
|
---|
| 1524 | public abstract Item merge(Item merger, int mouseX, int mouseY);
|
---|
| 1525 |
|
---|
| 1526 | /**
|
---|
[7] | 1527 | * Displays this item directly on the screen. Note: All Items are
|
---|
| 1528 | * responsible for their own drawing, buffering, etc.
|
---|
[4] | 1529 | *
|
---|
[7] | 1530 | * @param g
|
---|
| 1531 | * The Graphics to draw this Item on.
|
---|
[4] | 1532 | */
|
---|
[1102] | 1533 | public abstract void paint();
|
---|
[656] | 1534 |
|
---|
[1102] | 1535 | public void setTooltips(final List<String> tooltips)
|
---|
| 1536 | {
|
---|
| 1537 | if (tooltips == null || tooltips.size() == 0) {
|
---|
| 1538 | _tooltip = new Tooltip();
|
---|
| 1539 | } else {
|
---|
| 1540 | for (final String content: tooltips) _tooltip.addTooltip(content, this);
|
---|
| 1541 | }
|
---|
[707] | 1542 | }
|
---|
| 1543 |
|
---|
[1413] | 1544 | public void setTooltip(final String tooltip) {
|
---|
[707] | 1545 | if(tooltip != null && tooltip.trim().length() > 0) {
|
---|
[977] | 1546 | _tooltip.addTooltip(tooltip, this);
|
---|
[707] | 1547 | }
|
---|
[1413] | 1548 |
|
---|
| 1549 | if (isSurrogate()) {
|
---|
| 1550 | surrogatePropertyInheritance.put(DefaultFrameWriter.TOOLTIP_STR, false);
|
---|
[1414] | 1551 | Item primary = getPrimary();
|
---|
[1413] | 1552 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.TOOLTIP_STR)) {
|
---|
[1415] | 1553 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 1554 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.TOOLTIP_STR, inheritanceCheckOnSave);
|
---|
[1413] | 1555 | }
|
---|
| 1556 | }
|
---|
[656] | 1557 | }
|
---|
| 1558 |
|
---|
[1410] | 1559 | public List<String> getTooltip() {
|
---|
[1413] | 1560 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.TOOLTIP_STR)) {
|
---|
[1414] | 1561 | return this.getPrimary().getTooltip();
|
---|
[1410] | 1562 | } else {
|
---|
| 1563 | return _tooltip.asStringList();
|
---|
| 1564 | }
|
---|
[656] | 1565 | }
|
---|
| 1566 |
|
---|
[1102] | 1567 | public Collection<Text> getTooltipItems()
|
---|
| 1568 | {
|
---|
[940] | 1569 | return _tooltip.getTooltips();
|
---|
[664] | 1570 | }
|
---|
[940] | 1571 |
|
---|
[1102] | 1572 | public void clearTooltips()
|
---|
| 1573 | {
|
---|
[940] | 1574 | final Frame frame = this.getParent();
|
---|
[1102] | 1575 | if(_tooltip != null) {
|
---|
[954] | 1576 | for(final Text tooltip: _tooltip.getTooltips()) frame.removeItem(tooltip);
|
---|
[1102] | 1577 | }
|
---|
[940] | 1578 | }
|
---|
[664] | 1579 |
|
---|
[1102] | 1580 | public void paintTooltip()
|
---|
| 1581 | {
|
---|
| 1582 | final Bounds bounds = AxisAlignedBoxBounds.getEnclosing(this.getBoundingBox());
|
---|
[1258] | 1583 | Dimension frameSize = DisplayController.getFramePaintAreaSize();
|
---|
[1102] | 1584 |
|
---|
| 1585 | int x = bounds.getMaxX();
|
---|
| 1586 |
|
---|
| 1587 | // If the tooltip goes off the right side of the window, move it left so it's completely on
|
---|
| 1588 | if(x + _tooltip.getWidth() > frameSize.getWidth()) {
|
---|
| 1589 | x = frameSize.getWidth() - _tooltip.getWidth();
|
---|
[664] | 1590 | }
|
---|
[1102] | 1591 |
|
---|
| 1592 | int y = bounds.getMaxY();
|
---|
| 1593 |
|
---|
| 1594 | if(y + _tooltip.getCollectiveHeight() > frameSize.getHeight()) {
|
---|
| 1595 | y = (bounds.getMinY() + bounds.getMaxY()) / 2 - _tooltip.getCollectiveHeight();
|
---|
[656] | 1596 | }
|
---|
[1102] | 1597 |
|
---|
[940] | 1598 | for(final Text tooltip : _tooltip.getTooltips()) {
|
---|
| 1599 | this.getParent().addItem(tooltip);
|
---|
| 1600 | tooltip.setPosition(x, y);
|
---|
[1102] | 1601 | tooltip.paint();
|
---|
[940] | 1602 | y += tooltip.getHeight();
|
---|
[656] | 1603 | }
|
---|
| 1604 | }
|
---|
| 1605 |
|
---|
[1102] | 1606 | public void paintFill() {
|
---|
| 1607 | Colour fillColor = getFillColor();
|
---|
[108] | 1608 | if (fillColor != null && getEnclosingDots() != null) {
|
---|
[1102] | 1609 | Fill fill = getFill();
|
---|
| 1610 | EcosystemManager.getGraphicsManager().drawPolygon(getEnclosedShape(), null, null, 0.0f, fill, null, null);
|
---|
[147] | 1611 | }
|
---|
| 1612 | }
|
---|
| 1613 |
|
---|
[1102] | 1614 | protected Fill getFill() {
|
---|
| 1615 | Fill fill;
|
---|
| 1616 | Colour fillColour = getFillColor();
|
---|
[147] | 1617 | if (isFloating()) {
|
---|
| 1618 | // TODO experiment with adding alpha when picking up filled
|
---|
| 1619 | // items... Slows things down quite alot!!
|
---|
[1102] | 1620 | // TODO: Does nothing as it stands... cts16
|
---|
| 1621 | fillColour = new Colour(fillColour.getRed(), fillColour.getGreen(),
|
---|
| 1622 | fillColour.getBlue(), fillColour.getAlpha());
|
---|
[147] | 1623 | }
|
---|
[1102] | 1624 | Colour gradientColor = getGradientColor();
|
---|
| 1625 | PolygonBounds poly = getEnclosedShape();
|
---|
| 1626 | if (gradientColor != null && poly != null) {
|
---|
[348] | 1627 | /*
|
---|
| 1628 | * It is slow when painting gradients... modify so this is only done
|
---|
| 1629 | * once unless it is resized...
|
---|
| 1630 | */
|
---|
[1102] | 1631 | AxisAlignedBoxBounds b = AxisAlignedBoxBounds.getEnclosing(poly);
|
---|
| 1632 | double rads = getGradientAngle();
|
---|
| 1633 | double cos = Math.cos(rads);
|
---|
| 1634 | double sin = Math.sin(rads);
|
---|
[348] | 1635 |
|
---|
[1102] | 1636 | Point fromPoint = new Point((int) (b.getMinX() + b.getWidth() * (0.2 * cos + 0.5)), (int) (b.getMinY() + b.getHeight() * (0.2 * sin + 0.5)));
|
---|
| 1637 | Point toPoint = new Point((int) (b.getMinX() + b.getWidth() * (-0.8 * cos + 0.5)), (int) (b.getMinY() + b.getHeight() * (-0.8 * sin + 0.5)));
|
---|
| 1638 |
|
---|
| 1639 | fill = new GradientFill(fillColour, fromPoint, gradientColor, toPoint);
|
---|
| 1640 | } else {
|
---|
| 1641 | fill = new Fill(fillColour);
|
---|
[72] | 1642 | }
|
---|
[1102] | 1643 |
|
---|
| 1644 | return fill;
|
---|
[72] | 1645 | }
|
---|
[4] | 1646 |
|
---|
| 1647 | /**
|
---|
[7] | 1648 | * This method performs all the actions in an items list. If it contains a
|
---|
[1102] | 1649 | * link as well the link is used as the source frame for all actions.
|
---|
[4] | 1650 | */
|
---|
[7] | 1651 | public void performActions() {
|
---|
| 1652 | Frame sourceFrame = null;
|
---|
[156] | 1653 | Item sourceItem = FreeItems.getItemAttachedToCursor();
|
---|
[278] | 1654 |
|
---|
[181] | 1655 | if (sourceItem == null) {
|
---|
[156] | 1656 | sourceItem = this;
|
---|
[282] | 1657 | } else {
|
---|
| 1658 | for (Item i : sourceItem.getAllConnected()) {
|
---|
| 1659 | if (i instanceof Text) {
|
---|
[278] | 1660 | sourceItem = i;
|
---|
| 1661 | break;
|
---|
| 1662 | }
|
---|
| 1663 | }
|
---|
[156] | 1664 | }
|
---|
[181] | 1665 |
|
---|
[214] | 1666 | // TODO decide whether to have items or
|
---|
[7] | 1667 | // if a link exists make it the source frame for this action
|
---|
| 1668 | if (getLink() != null) {
|
---|
[71] | 1669 | sourceFrame = FrameUtils.getFrame(getAbsoluteLink());
|
---|
[7] | 1670 | }
|
---|
| 1671 | // if no link exists or the link is bad then use the
|
---|
| 1672 | // currently displayed frame as the source frame for the
|
---|
| 1673 | // action
|
---|
| 1674 | if (sourceFrame == null) {
|
---|
[214] | 1675 | // For actions like format they rely on this being set to the
|
---|
| 1676 | // current frame incase the item being activated is on an overlay
|
---|
[1102] | 1677 | sourceFrame = DisplayController.getCurrentFrame();
|
---|
[7] | 1678 | }
|
---|
[4] | 1679 |
|
---|
[7] | 1680 | for (String s : getAction()) {
|
---|
[1200] | 1681 | Object returnValue;
|
---|
| 1682 | if (LegacyFeatures.UseLegacyActionArgumentMapping.get()) {
|
---|
| 1683 | returnValue = Actions.LegacyPerformActionCatchErrors(sourceFrame, sourceItem, s);
|
---|
| 1684 | } else {
|
---|
| 1685 | returnValue = Actions.PerformActionCatchErrors(sourceFrame, sourceItem, s, this);
|
---|
| 1686 | }
|
---|
| 1687 |
|
---|
[181] | 1688 | if (returnValue != null) {
|
---|
| 1689 | FreeItems.getInstance().clear();
|
---|
| 1690 | if (returnValue instanceof Item) {
|
---|
[278] | 1691 | Misc.attachToCursor(((Item) returnValue).getAllConnected());
|
---|
[284] | 1692 | } else if (returnValue instanceof Collection) {
|
---|
| 1693 | try {
|
---|
| 1694 | Misc.attachToCursor((Collection) returnValue);
|
---|
| 1695 | } catch (Exception e) {
|
---|
| 1696 | e.printStackTrace();
|
---|
| 1697 | }
|
---|
[181] | 1698 | } else {
|
---|
| 1699 | Misc.attachStatsToCursor(returnValue.toString());
|
---|
| 1700 | }
|
---|
| 1701 | }
|
---|
[4] | 1702 | }
|
---|
| 1703 | }
|
---|
| 1704 |
|
---|
[50] | 1705 | /**
|
---|
| 1706 | * Removes all constraints that this item has.
|
---|
| 1707 | *
|
---|
| 1708 | */
|
---|
[7] | 1709 | public void removeAllConstraints() {
|
---|
[50] | 1710 | while (_constraints.size() > 0) {
|
---|
| 1711 | Constraint c = _constraints.get(0);
|
---|
| 1712 | c.getEnd().removeConstraint(c);
|
---|
| 1713 | c.getStart().removeConstraint(c);
|
---|
| 1714 | }
|
---|
[4] | 1715 | }
|
---|
| 1716 |
|
---|
| 1717 | /**
|
---|
[7] | 1718 | * Clears the list of Lines that this Dot is an end of. Note: This only
|
---|
| 1719 | * clears this Dot's list and does not have any affect on the Lines or other
|
---|
| 1720 | * Dots.
|
---|
[4] | 1721 | */
|
---|
[7] | 1722 | public void removeAllLines() {
|
---|
[121] | 1723 | for (Line l : _lines) {
|
---|
| 1724 | l.invalidateAll();
|
---|
| 1725 | }
|
---|
[7] | 1726 | _lines.clear();
|
---|
[4] | 1727 | }
|
---|
| 1728 |
|
---|
| 1729 | /**
|
---|
[812] | 1730 | * Removes the given Constraint from the list of constraints that this Dot
|
---|
[7] | 1731 | * is a part of.
|
---|
[4] | 1732 | *
|
---|
[7] | 1733 | * @param c
|
---|
| 1734 | * The Constraint that this Dot is no longer a part of.
|
---|
[4] | 1735 | */
|
---|
[7] | 1736 | public void removeConstraint(Constraint c) {
|
---|
| 1737 | _constraints.remove(c);
|
---|
[4] | 1738 | }
|
---|
| 1739 |
|
---|
| 1740 | /**
|
---|
[7] | 1741 | * Removes the given Line from the list of lines that this Dot is an end
|
---|
| 1742 | * for.
|
---|
[4] | 1743 | *
|
---|
[7] | 1744 | * @param line
|
---|
| 1745 | * The Line that this Dot is no longer an end of.
|
---|
[4] | 1746 | */
|
---|
[7] | 1747 | public void removeLine(Line line) {
|
---|
[124] | 1748 | if (_lines.remove(line))
|
---|
[121] | 1749 | line.invalidateAll();
|
---|
[4] | 1750 | }
|
---|
| 1751 |
|
---|
[7] | 1752 | public void run() {
|
---|
| 1753 | try {
|
---|
[472] | 1754 |
|
---|
| 1755 | List<String> action = this.getAction();
|
---|
| 1756 | if (action != null) {
|
---|
| 1757 | String action_name = action.get(0);
|
---|
| 1758 | if (action_name.equalsIgnoreCase("RunJavascriptFrame")){
|
---|
| 1759 | // Associate a new Context with this thread
|
---|
| 1760 | org.mozilla.javascript.Context javascript_context = org.mozilla.javascript.Context.enter();
|
---|
| 1761 | try {
|
---|
| 1762 | Scriptable javascript_scope = javascript_context.initStandardObjects();
|
---|
| 1763 | Context simple_context = new Context();
|
---|
| 1764 |
|
---|
| 1765 |
|
---|
| 1766 | //Object jsDisplayIO = org.mozilla.javascript.Context.javaToJS(org.expeditee.gui.DisplayIO, javascript_scope);
|
---|
| 1767 | //ScriptableObject.putProperty(javascript_scope, "displayIO", jsDisplayIO);
|
---|
| 1768 |
|
---|
| 1769 |
|
---|
| 1770 | Object jsSimpleContext = org.mozilla.javascript.Context.javaToJS(simple_context, javascript_scope);
|
---|
| 1771 | ScriptableObject.putProperty(javascript_scope, "simpleContext", jsSimpleContext);
|
---|
| 1772 |
|
---|
| 1773 | Object jsErr = org.mozilla.javascript.Context.javaToJS(System.err, javascript_scope);
|
---|
| 1774 | ScriptableObject.putProperty(javascript_scope, "err", jsErr);
|
---|
| 1775 |
|
---|
| 1776 | Object jsOut = org.mozilla.javascript.Context.javaToJS(System.out, javascript_scope);
|
---|
| 1777 | ScriptableObject.putProperty(javascript_scope, "out", jsOut);
|
---|
| 1778 |
|
---|
| 1779 | Javascript.ProgramStarted();
|
---|
| 1780 | Javascript.RunFrameAndReportError(this, javascript_context,javascript_scope);
|
---|
| 1781 | MessageBay.displayMessage(AgentStats.getStats(), GREEN);
|
---|
| 1782 | }
|
---|
| 1783 | finally {
|
---|
| 1784 | org.mozilla.javascript.Context.exit();
|
---|
| 1785 | }
|
---|
| 1786 | }
|
---|
| 1787 | }
|
---|
| 1788 | else {
|
---|
| 1789 |
|
---|
| 1790 | // assume it is a simple program that is to be run
|
---|
| 1791 | Simple.ProgramStarted();
|
---|
| 1792 | Context simple_context = new Context();
|
---|
| 1793 | Simple.RunFrameAndReportError(this, simple_context);
|
---|
| 1794 | MessageBay.displayMessage(AgentStats.getStats(), GREEN);
|
---|
| 1795 | }
|
---|
[7] | 1796 | } catch (ConcurrentModificationException ce) {
|
---|
| 1797 | ce.printStackTrace();
|
---|
[410] | 1798 | } catch (IncorrectUseOfStatementException ise) {
|
---|
| 1799 | MessageBay.linkedErrorMessage(ise.getMessage());
|
---|
| 1800 | MessageBay.displayMessage("See SIMPLE doc for ["
|
---|
[427] | 1801 | + ise.getStatement() + "] statement", ise.getStatement()
|
---|
[1102] | 1802 | + "1", Colour.CYAN.darker(), true, null);
|
---|
[7] | 1803 | } catch (Exception e) {
|
---|
[121] | 1804 | MessageBay.linkedErrorMessage(e.getMessage());
|
---|
[7] | 1805 | }
|
---|
[410] | 1806 | Simple.ProgramFinished();
|
---|
[181] | 1807 | // Need to repaint any highlights etc
|
---|
[1102] | 1808 | DisplayController.requestRefresh(true);
|
---|
[4] | 1809 | }
|
---|
| 1810 |
|
---|
| 1811 | /**
|
---|
[7] | 1812 | * Check if it has a relative link if so make it absolute.
|
---|
[4] | 1813 | *
|
---|
| 1814 | */
|
---|
[7] | 1815 | public void setAbsoluteLink() {
|
---|
[86] | 1816 | String link = getLink();
|
---|
| 1817 | if (link == null)
|
---|
[7] | 1818 | return;
|
---|
| 1819 | // Check if all the characters are digits and hence it is a relative
|
---|
| 1820 | // link
|
---|
[116] | 1821 | if (!FrameIO.isPositiveInteger(link))
|
---|
[108] | 1822 | return;
|
---|
[4] | 1823 |
|
---|
[7] | 1824 | // Make it an absolute link
|
---|
| 1825 | String framesetName;
|
---|
[4] | 1826 |
|
---|
[7] | 1827 | if (_parent == null)
|
---|
[1102] | 1828 | framesetName = DisplayController.getCurrentFrame().getFramesetName();
|
---|
[7] | 1829 | else
|
---|
[24] | 1830 | framesetName = _parent.getFramesetName();
|
---|
[4] | 1831 |
|
---|
[86] | 1832 | setLink(framesetName + link);
|
---|
[4] | 1833 | }
|
---|
| 1834 |
|
---|
[7] | 1835 | /**
|
---|
[116] | 1836 | * Sets any action code that should be associated with this Item Each entry
|
---|
| 1837 | * in the list is one line of code
|
---|
[7] | 1838 | *
|
---|
| 1839 | * @param actions
|
---|
| 1840 | * The lines of code to associate with this Item
|
---|
| 1841 | */
|
---|
[1413] | 1842 | public void setActions(List<String> actions) {
|
---|
[130] | 1843 | if (actions == null || actions.size() == 0) {
|
---|
| 1844 | invalidateCommonTrait(ItemAppearence.LinkChanged);
|
---|
| 1845 | _actions = null;
|
---|
[1102] | 1846 | } else {
|
---|
[130] | 1847 | _actions = new LinkedList<String>(actions);
|
---|
[1102] | 1848 | }
|
---|
| 1849 |
|
---|
| 1850 | // Want to resize the highlight box for text items if actions have been added
|
---|
| 1851 | invalidateBounds();
|
---|
[130] | 1852 | invalidateCommonTrait(ItemAppearence.LinkChanged);
|
---|
[1413] | 1853 |
|
---|
| 1854 | if (isSurrogate()) {
|
---|
| 1855 | surrogatePropertyInheritance.put(DefaultFrameWriter.ACTION_STR, false);
|
---|
[1414] | 1856 | Item primary = getPrimary();
|
---|
[1413] | 1857 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.ACTION_STR)) {
|
---|
[1415] | 1858 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 1859 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.ACTION_STR, inheritanceCheckOnSave);
|
---|
[1413] | 1860 | }
|
---|
| 1861 | }
|
---|
[4] | 1862 | }
|
---|
| 1863 |
|
---|
[74] | 1864 | public void setData(List<String> data) {
|
---|
[1388] | 1865 | _data.setData(data);
|
---|
[74] | 1866 | }
|
---|
[242] | 1867 |
|
---|
[212] | 1868 | public void setData(String data) {
|
---|
[1388] | 1869 | _data.setData(data);
|
---|
[212] | 1870 | }
|
---|
[242] | 1871 |
|
---|
[212] | 1872 | public void addToData(String dataItem) {
|
---|
[1388] | 1873 | _data.addToData(dataItem);
|
---|
[1413] | 1874 |
|
---|
| 1875 | if (isSurrogate()) {
|
---|
| 1876 | surrogatePropertyInheritance.put(DefaultFrameWriter.DATA_STR, false);
|
---|
[1414] | 1877 | Item primary = getPrimary();
|
---|
[1413] | 1878 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.DATA_STR)) {
|
---|
[1415] | 1879 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 1880 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.DATA_STR, inheritanceCheckOnSave);
|
---|
[1413] | 1881 | }
|
---|
| 1882 | }
|
---|
[212] | 1883 | }
|
---|
[1212] | 1884 |
|
---|
[1388] | 1885 | public boolean hasData(String dataItem) {
|
---|
| 1886 | return _data.hasData(dataItem);
|
---|
[1212] | 1887 | }
|
---|
[74] | 1888 |
|
---|
[7] | 1889 | public void setActionCursorEnter(List<String> enter) {
|
---|
| 1890 | _actionCursorEnter = enter;
|
---|
[1413] | 1891 |
|
---|
| 1892 | if (isSurrogate()) {
|
---|
| 1893 | surrogatePropertyInheritance.put(DefaultFrameWriter.ACTION_CURSOR_ENTER_STR, false);
|
---|
[1414] | 1894 | Item primary = getPrimary();
|
---|
[1413] | 1895 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.ACTION_CURSOR_ENTER_STR)) {
|
---|
[1415] | 1896 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 1897 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.ACTION_CURSOR_ENTER_STR, inheritanceCheckOnSave);
|
---|
[1413] | 1898 | }
|
---|
| 1899 | }
|
---|
[4] | 1900 | }
|
---|
| 1901 |
|
---|
[7] | 1902 | public void setActionCursorLeave(List<String> leave) {
|
---|
| 1903 | _actionCursorLeave = leave;
|
---|
[1413] | 1904 |
|
---|
| 1905 | if (isSurrogate()) {
|
---|
| 1906 | surrogatePropertyInheritance.put(DefaultFrameWriter.ACTION_CURSOR_LEAVE_STR, false);
|
---|
[1414] | 1907 | Item primary = getPrimary();
|
---|
[1413] | 1908 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.ACTION_CURSOR_LEAVE_STR)) {
|
---|
[1415] | 1909 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 1910 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.ACTION_CURSOR_LEAVE_STR, inheritanceCheckOnSave);
|
---|
[1413] | 1911 | }
|
---|
| 1912 | }
|
---|
[4] | 1913 | }
|
---|
| 1914 |
|
---|
[7] | 1915 | public void setActionEnterFrame(List<String> enter) {
|
---|
| 1916 | _actionEnterFrame = enter;
|
---|
[1413] | 1917 |
|
---|
| 1918 | if (isSurrogate()) {
|
---|
| 1919 | surrogatePropertyInheritance.put(DefaultFrameWriter.ACTION_ENTER_FRAME_STR, false);
|
---|
[1414] | 1920 | Item primary = getPrimary();
|
---|
[1413] | 1921 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.ACTION_ENTER_FRAME_STR)) {
|
---|
[1415] | 1922 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 1923 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.ACTION_ENTER_FRAME_STR, inheritanceCheckOnSave);
|
---|
[1413] | 1924 | }
|
---|
| 1925 | }
|
---|
[4] | 1926 | }
|
---|
| 1927 |
|
---|
[7] | 1928 | public void setActionLeaveFrame(List<String> leave) {
|
---|
| 1929 | _actionLeaveFrame = leave;
|
---|
[1413] | 1930 |
|
---|
| 1931 | if (isSurrogate()) {
|
---|
| 1932 | surrogatePropertyInheritance.put(DefaultFrameWriter.ACTION_LEAVE_FRAME_STR, false);
|
---|
[1414] | 1933 | Item primary = getPrimary();
|
---|
[1413] | 1934 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.ACTION_LEAVE_FRAME_STR)) {
|
---|
[1415] | 1935 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 1936 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.ACTION_LEAVE_FRAME_STR, inheritanceCheckOnSave);
|
---|
[1413] | 1937 | }
|
---|
| 1938 | }
|
---|
[4] | 1939 | }
|
---|
| 1940 |
|
---|
[1413] | 1941 | public void setActionMark(boolean val) {
|
---|
[1102] | 1942 | if (!val) invalidateCommonTrait(ItemAppearence.LinkChanged);
|
---|
| 1943 | invalidateBounds();
|
---|
[7] | 1944 | _actionMark = val;
|
---|
[1102] | 1945 | if (val) invalidateCommonTrait(ItemAppearence.LinkChanged);
|
---|
[1413] | 1946 |
|
---|
| 1947 | if (isSurrogate()) {
|
---|
| 1948 | surrogatePropertyInheritance.put(DefaultFrameWriter.ACTION_MARK_STR, false);
|
---|
[1414] | 1949 | Item primary = getPrimary();
|
---|
[1413] | 1950 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.ACTION_MARK_STR)) {
|
---|
[1415] | 1951 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 1952 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.ACTION_MARK_STR, inheritanceCheckOnSave);
|
---|
[1413] | 1953 | }
|
---|
| 1954 | }
|
---|
[4] | 1955 | }
|
---|
| 1956 |
|
---|
| 1957 | /**
|
---|
| 1958 | * Sets whether this Item is an Annotation.
|
---|
| 1959 | *
|
---|
| 1960 | * @param val
|
---|
| 1961 | * True if this Item is an Annotation, False otherwise.
|
---|
| 1962 | */
|
---|
| 1963 | public abstract void setAnnotation(boolean val);
|
---|
| 1964 |
|
---|
| 1965 | /**
|
---|
[7] | 1966 | * Used to set this Line as an Arrow. If length and ratio are 0, no arrow is
|
---|
| 1967 | * shown.
|
---|
[4] | 1968 | *
|
---|
[7] | 1969 | * @param length
|
---|
| 1970 | * The how far down the shaft of the line the arrowhead should
|
---|
| 1971 | * come.
|
---|
| 1972 | * @param ratio
|
---|
| 1973 | * The ratio of the arrow's length to its width.
|
---|
[4] | 1974 | */
|
---|
[475] | 1975 | public void setArrow(float length, double ratio, double nib_perc) {
|
---|
[7] | 1976 | _arrowheadLength = length;
|
---|
| 1977 | _arrowheadRatio = ratio;
|
---|
[475] | 1978 | _arrowheadNibPerc = nib_perc;
|
---|
[7] | 1979 | updateArrowPolygon();
|
---|
[1413] | 1980 |
|
---|
| 1981 | if (isSurrogate()) {
|
---|
| 1982 | surrogatePropertyInheritance.put(DefaultFrameWriter.ARROW_STR, false);
|
---|
[1414] | 1983 | Item primary = getPrimary();
|
---|
[1413] | 1984 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.ARROW_STR)) {
|
---|
[1415] | 1985 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 1986 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.ARROW_STR, inheritanceCheckOnSave);
|
---|
[1413] | 1987 | }
|
---|
| 1988 | }
|
---|
[4] | 1989 | }
|
---|
| 1990 |
|
---|
[475] | 1991 | public void setArrow(float length, double ratio) {
|
---|
| 1992 | setArrow(length,ratio,DEFAULT_ARROWHEAD_NIB_PERC);
|
---|
| 1993 | }
|
---|
| 1994 |
|
---|
[1102] | 1995 | public void setArrowhead(PolygonBounds arrow) {
|
---|
[7] | 1996 | _arrowhead = arrow;
|
---|
[4] | 1997 | }
|
---|
| 1998 |
|
---|
[108] | 1999 | public void setArrowheadLength(float length) {
|
---|
[7] | 2000 | _arrowheadLength = length;
|
---|
| 2001 | updateArrowPolygon();
|
---|
[4] | 2002 | }
|
---|
| 2003 |
|
---|
[7] | 2004 | public void setArrowheadRatio(double ratio) {
|
---|
| 2005 | _arrowheadRatio = ratio;
|
---|
| 2006 | updateArrowPolygon();
|
---|
[4] | 2007 | }
|
---|
[475] | 2008 |
|
---|
| 2009 | public void setArrowheadNibPerc(double perc) {
|
---|
| 2010 | _arrowheadNibPerc = perc;
|
---|
| 2011 | updateArrowPolygon();
|
---|
| 2012 | }
|
---|
[4] | 2013 |
|
---|
[1102] | 2014 | public void setBackgroundColor(Colour c) {
|
---|
| 2015 | if (c != _backgroundColour) {
|
---|
| 2016 | _backgroundColour = c;
|
---|
[121] | 2017 | invalidateCommonTrait(ItemAppearence.BackgroundColorChanged);
|
---|
| 2018 | }
|
---|
[1413] | 2019 |
|
---|
| 2020 | if (isSurrogate()) {
|
---|
| 2021 | surrogatePropertyInheritance.put(DefaultFrameWriter.BACKGROUND_COLOR_STR, false);
|
---|
[1414] | 2022 | Item primary = getPrimary();
|
---|
[1413] | 2023 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.BACKGROUND_COLOR_STR)) {
|
---|
[1415] | 2024 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 2025 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.BACKGROUND_COLOR_STR, inheritanceCheckOnSave);
|
---|
[1413] | 2026 | }
|
---|
| 2027 | }
|
---|
[4] | 2028 | }
|
---|
| 2029 |
|
---|
[1102] | 2030 | public void setBorderColor(Colour c) {
|
---|
[214] | 2031 | if (c != _colorBorder) {
|
---|
| 2032 | _colorBorder = c;
|
---|
| 2033 | invalidateCommonTrait(ItemAppearence.BorderColorChanged);
|
---|
| 2034 | }
|
---|
[1413] | 2035 |
|
---|
| 2036 | if (isSurrogate()) {
|
---|
| 2037 | surrogatePropertyInheritance.put(DefaultFrameWriter.BORDER_COLOR_STR, false);
|
---|
[1414] | 2038 | Item primary = getPrimary();
|
---|
[1413] | 2039 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.BORDER_COLOR_STR)) {
|
---|
[1415] | 2040 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 2041 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.BORDER_COLOR_STR, inheritanceCheckOnSave);
|
---|
[1413] | 2042 | }
|
---|
| 2043 | }
|
---|
[214] | 2044 | }
|
---|
| 2045 |
|
---|
[7] | 2046 | /**
|
---|
| 2047 | * Sets the Color to use on the bottom and right sections of this Item's
|
---|
| 2048 | * border. If top is NULL, then the Item's background Color will be used.
|
---|
| 2049 | *
|
---|
| 2050 | * @param top
|
---|
| 2051 | * The Color to display in the bottom and right sections of this
|
---|
| 2052 | * Item's border.
|
---|
| 2053 | */
|
---|
[1102] | 2054 | public void setBottomShadowColor(Colour bottom) {
|
---|
[7] | 2055 | _colorBottomShadow = bottom;
|
---|
[4] | 2056 | }
|
---|
| 2057 |
|
---|
[7] | 2058 | /**
|
---|
| 2059 | * Sets the foreground Color of this Item to the given Color.
|
---|
| 2060 | *
|
---|
| 2061 | * @param c
|
---|
| 2062 | */
|
---|
[1102] | 2063 | public void setColor(Colour c) {
|
---|
| 2064 | if (c != _foregroundColour) {
|
---|
| 2065 | _foregroundColour = c;
|
---|
[121] | 2066 | invalidateCommonTrait(ItemAppearence.ForegroundColorChanged);
|
---|
[124] | 2067 | if (hasVector()) {
|
---|
[130] | 2068 | // TODO make this more efficient so it only repaints the items
|
---|
| 2069 | // for this vector
|
---|
[1102] | 2070 | StandardGestureActions.Refresh();
|
---|
[124] | 2071 | }
|
---|
[121] | 2072 | }
|
---|
[4] | 2073 | }
|
---|
| 2074 |
|
---|
[7] | 2075 | public void setConstraintIDs(String IDs) {
|
---|
[1413] | 2076 | if (isSurrogate()) {
|
---|
| 2077 | surrogatePropertyInheritance.put(DefaultFrameWriter.CONSTRAINT_IDS_STR, false);
|
---|
[1414] | 2078 | Item primary = getPrimary();
|
---|
[1413] | 2079 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.CONSTRAINT_IDS_STR)) {
|
---|
[1415] | 2080 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 2081 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.CONSTRAINT_IDS_STR, inheritanceCheckOnSave);
|
---|
[1413] | 2082 | }
|
---|
| 2083 | }
|
---|
[4] | 2084 | }
|
---|
| 2085 |
|
---|
[7] | 2086 | public void setConstraints(List<Constraint> constraints) {
|
---|
| 2087 | _constraints = constraints;
|
---|
[4] | 2088 | }
|
---|
| 2089 |
|
---|
[74] | 2090 | public void setTag(String newData) {
|
---|
[7] | 2091 | if (newData != null)
|
---|
[74] | 2092 | _tag = new StringBuffer(newData);
|
---|
[7] | 2093 | else
|
---|
[74] | 2094 | _tag = null;
|
---|
[4] | 2095 | }
|
---|
| 2096 |
|
---|
[7] | 2097 | /**
|
---|
| 2098 | * Sets the created date of this Frame to the given String.
|
---|
| 2099 | *
|
---|
| 2100 | * @param date
|
---|
| 2101 | * The date to use for this Frame.
|
---|
| 2102 | */
|
---|
| 2103 | public void setDateCreated(String date) {
|
---|
| 2104 | _creationDate = date;
|
---|
[1413] | 2105 |
|
---|
| 2106 | if (isSurrogate()) {
|
---|
| 2107 | surrogatePropertyInheritance.put(DefaultFrameWriter.DATE_CREATED_STR, false);
|
---|
[1414] | 2108 | Item primary = getPrimary();
|
---|
[1413] | 2109 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.DATE_CREATED_STR)) {
|
---|
[1415] | 2110 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 2111 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.DATE_CREATED_STR, inheritanceCheckOnSave);
|
---|
[1413] | 2112 | }
|
---|
| 2113 | }
|
---|
[4] | 2114 | }
|
---|
| 2115 |
|
---|
[1102] | 2116 | public void setFillColor(Colour c) {
|
---|
[121] | 2117 |
|
---|
[1102] | 2118 | _fillColour = c;
|
---|
[4] | 2119 |
|
---|
[7] | 2120 | for (Line line : _lines) {
|
---|
| 2121 | Item other = line.getOppositeEnd(this);
|
---|
[282] | 2122 | if (other.getFillColor() != c) {
|
---|
[7] | 2123 | other.setFillColor(c);
|
---|
[247] | 2124 | }
|
---|
[7] | 2125 | }
|
---|
[124] | 2126 |
|
---|
[121] | 2127 | invalidateCommonTrait(ItemAppearence.FillColor);
|
---|
| 2128 | invalidateFill();
|
---|
[1413] | 2129 |
|
---|
| 2130 | if (isSurrogate()) {
|
---|
| 2131 | surrogatePropertyInheritance.put(DefaultFrameWriter.FILL_COLOR_STR, false);
|
---|
[1414] | 2132 | Item primary = getPrimary();
|
---|
[1413] | 2133 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.FILL_COLOR_STR)) {
|
---|
[1415] | 2134 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 2135 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.FILL_COLOR_STR, inheritanceCheckOnSave);
|
---|
[1413] | 2136 | }
|
---|
| 2137 | }
|
---|
[4] | 2138 | }
|
---|
| 2139 |
|
---|
[1413] | 2140 | public void setGradientColor(Colour c) {
|
---|
[1102] | 2141 | _gradientColour = c;
|
---|
[145] | 2142 |
|
---|
| 2143 | for (Line line : _lines) {
|
---|
| 2144 | Item other = line.getOppositeEnd(this);
|
---|
| 2145 | if (other.getGradientColor() != c)
|
---|
| 2146 | other.setGradientColor(c);
|
---|
| 2147 | }
|
---|
| 2148 |
|
---|
| 2149 | invalidateCommonTrait(ItemAppearence.GradientColor);
|
---|
| 2150 | invalidateFill();
|
---|
[1413] | 2151 |
|
---|
| 2152 | if (isSurrogate()) {
|
---|
| 2153 | surrogatePropertyInheritance.put(DefaultFrameWriter.GRADIENT_COLOR_STR, false);
|
---|
[1414] | 2154 | Item primary = getPrimary();
|
---|
[1413] | 2155 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.GRADIENT_COLOR_STR)) {
|
---|
[1415] | 2156 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 2157 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.GRADIENT_COLOR_STR, inheritanceCheckOnSave);
|
---|
[1413] | 2158 | }
|
---|
| 2159 | }
|
---|
[145] | 2160 | }
|
---|
| 2161 |
|
---|
[1102] | 2162 | public Colour getGradientColor() {
|
---|
[1413] | 2163 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.GRADIENT_COLOR_STR)) {
|
---|
[1414] | 2164 | return this.getPrimary().getGradientColor();
|
---|
[1410] | 2165 | } else {
|
---|
| 2166 | return _gradientColour;
|
---|
| 2167 | }
|
---|
[145] | 2168 | }
|
---|
| 2169 |
|
---|
[7] | 2170 | public void setFillPattern(String patternLink) {
|
---|
| 2171 | _fillPattern = patternLink;
|
---|
[121] | 2172 | invalidateCommonTrait(ItemAppearence.FillPattern);
|
---|
| 2173 | invalidateFill();
|
---|
[1413] | 2174 |
|
---|
| 2175 | if (isSurrogate()) {
|
---|
| 2176 | surrogatePropertyInheritance.put(DefaultFrameWriter.FILL_PATTERN_STR, false);
|
---|
[1414] | 2177 | Item primary = getPrimary();
|
---|
[1413] | 2178 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.FILL_PATTERN_STR)) {
|
---|
[1415] | 2179 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 2180 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.FILL_PATTERN_STR, inheritanceCheckOnSave);
|
---|
[1413] | 2181 | }
|
---|
| 2182 | }
|
---|
[4] | 2183 | }
|
---|
| 2184 |
|
---|
[7] | 2185 | public void setFloating(boolean val) {
|
---|
| 2186 | _floating = val;
|
---|
[4] | 2187 | }
|
---|
| 2188 |
|
---|
[1102] | 2189 | /**
|
---|
| 2190 | * Sets the value <code>_highlight</code> for this item.
|
---|
| 2191 | * TODO: Appears unused? cts16
|
---|
| 2192 | *
|
---|
| 2193 | * @param val The new value for <code>_highlight</code>.
|
---|
| 2194 | */
|
---|
[7] | 2195 | public void setHighlight(boolean val) {
|
---|
| 2196 | _highlight = val;
|
---|
[1413] | 2197 |
|
---|
| 2198 | if (isSurrogate()) {
|
---|
| 2199 | surrogatePropertyInheritance.put(DefaultFrameWriter.HIGHLIGHT_STR, false);
|
---|
[1414] | 2200 | Item primary = getPrimary();
|
---|
[1413] | 2201 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.HIGHLIGHT_STR)) {
|
---|
[1415] | 2202 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 2203 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.HIGHLIGHT_STR, inheritanceCheckOnSave);
|
---|
[1413] | 2204 | }
|
---|
| 2205 | }
|
---|
[4] | 2206 | }
|
---|
| 2207 |
|
---|
[7] | 2208 | /**
|
---|
| 2209 | * Sets the ID of this Item to the given Integer. Note: Items with ID's < 0
|
---|
| 2210 | * are not saved
|
---|
| 2211 | *
|
---|
| 2212 | * @param newID
|
---|
| 2213 | * The new ID to assign this Item.
|
---|
| 2214 | */
|
---|
| 2215 | public void setID(int newID) {
|
---|
| 2216 | _id = newID;
|
---|
[1413] | 2217 |
|
---|
| 2218 | if (isSurrogate()) {
|
---|
| 2219 | surrogatePropertyInheritance.put(DefaultFrameWriter.TYPE_AND_ID_STR, false);
|
---|
[1414] | 2220 | Item primary = getPrimary();
|
---|
[1413] | 2221 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.TYPE_AND_ID_STR)) {
|
---|
[1415] | 2222 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 2223 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.TYPE_AND_ID_STR, inheritanceCheckOnSave);
|
---|
[1413] | 2224 | }
|
---|
| 2225 | }
|
---|
[4] | 2226 | }
|
---|
[1430] | 2227 |
|
---|
| 2228 | /**
|
---|
| 2229 | * Function called when a user attempts to set the ID of a Item. Simply provides
|
---|
| 2230 | * feedback to the user telling them that they are not allowed to do this. This
|
---|
| 2231 | * function is provided so that users are able to get the ID of a item when
|
---|
| 2232 | * extracting properties. See {@link org.expeditee.gui.AttributeUtils}.
|
---|
| 2233 | *
|
---|
| 2234 | * @param newID The requested new ID that will be ignored.
|
---|
| 2235 | */
|
---|
| 2236 | public void setIDFail(int newID) {
|
---|
| 2237 | MessageBay.displayMessage("A user cannot change the ID of an item.");
|
---|
| 2238 | }
|
---|
[4] | 2239 |
|
---|
[7] | 2240 | /**
|
---|
| 2241 | * Sets the list of lines that this point is part of (may be set to null).
|
---|
| 2242 | *
|
---|
| 2243 | * @param lineID
|
---|
| 2244 | * A String of line ID numbers separated by spaces.
|
---|
| 2245 | */
|
---|
| 2246 | public void setLineIDs(String lineID) {
|
---|
[1413] | 2247 | if (isSurrogate()) {
|
---|
| 2248 | surrogatePropertyInheritance.put(DefaultFrameWriter.LINE_IDS_STR, false);
|
---|
[1414] | 2249 | Item primary = getPrimary();
|
---|
[1413] | 2250 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.LINE_IDS_STR)) {
|
---|
[1415] | 2251 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 2252 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.LINE_IDS_STR, inheritanceCheckOnSave);
|
---|
[1413] | 2253 | }
|
---|
| 2254 | }
|
---|
[4] | 2255 | }
|
---|
| 2256 |
|
---|
[7] | 2257 | public void setLinePattern(int[] pattern) {
|
---|
| 2258 | _linePattern = pattern;
|
---|
[4] | 2259 |
|
---|
[7] | 2260 | for (Line line : getLines())
|
---|
| 2261 | line.setLinePattern(pattern);
|
---|
[1413] | 2262 |
|
---|
| 2263 | if (isSurrogate()) {
|
---|
| 2264 | surrogatePropertyInheritance.put(DefaultFrameWriter.LINE_PATTERN_STR, false);
|
---|
[1414] | 2265 | Item primary = getPrimary();
|
---|
[1413] | 2266 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.LINE_PATTERN_STR)) {
|
---|
[1415] | 2267 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 2268 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.LINE_PATTERN_STR, inheritanceCheckOnSave);
|
---|
[1413] | 2269 | }
|
---|
| 2270 | }
|
---|
[4] | 2271 | }
|
---|
| 2272 |
|
---|
[7] | 2273 | public void setLines(List<Line> lines) {
|
---|
| 2274 | _lines = lines;
|
---|
[4] | 2275 |
|
---|
[7] | 2276 | for (Line line : lines)
|
---|
| 2277 | line.setLinePattern(getLinePattern());
|
---|
[124] | 2278 |
|
---|
[4] | 2279 | }
|
---|
| 2280 |
|
---|
[7] | 2281 | /**
|
---|
| 2282 | * Links this item to the given Frame, this may be set to null to remove a
|
---|
| 2283 | * link.
|
---|
| 2284 | *
|
---|
| 2285 | * @param frameName
|
---|
| 2286 | * The name of the Frame to link this item to.
|
---|
| 2287 | */
|
---|
[1413] | 2288 | public void setLink(String frameName) {
|
---|
[1102] | 2289 | if (frameName == null) invalidateCommonTrait(ItemAppearence.LinkChanged);
|
---|
[130] | 2290 |
|
---|
[1102] | 2291 | // If a link is being removed or set then need to reset _bounds so the
|
---|
[130] | 2292 | // highlighting is drawn with the correct width
|
---|
[1102] | 2293 | if (frameName == null || getLink() == null) invalidateBounds();
|
---|
[130] | 2294 |
|
---|
[1102] | 2295 | if (FrameIO.isValidLink(frameName)) {
|
---|
[72] | 2296 | _link = frameName;
|
---|
[1102] | 2297 | } else {
|
---|
| 2298 | MessageBay.errorMessage("[" + frameName + "] is not a valid frame name");
|
---|
| 2299 | }
|
---|
[72] | 2300 | // TODO make this throw exceptions etc...
|
---|
[124] | 2301 |
|
---|
[130] | 2302 | invalidateCommonTrait(ItemAppearence.LinkChanged);
|
---|
[1413] | 2303 |
|
---|
| 2304 | if (isSurrogate()) {
|
---|
| 2305 | surrogatePropertyInheritance.put(DefaultFrameWriter.LINK_STR, false);
|
---|
[1414] | 2306 | Item primary = getPrimary();
|
---|
[1413] | 2307 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.LINK_STR)) {
|
---|
[1415] | 2308 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 2309 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.LINK_STR, inheritanceCheckOnSave);
|
---|
[1413] | 2310 | }
|
---|
| 2311 | }
|
---|
[4] | 2312 | }
|
---|
[676] | 2313 |
|
---|
| 2314 | public void setLinkHistory(boolean value) {
|
---|
| 2315 | _linkHistory = value;
|
---|
[1413] | 2316 |
|
---|
| 2317 | if (isSurrogate()) {
|
---|
| 2318 | surrogatePropertyInheritance.put(DefaultFrameWriter.LINK_HISTORY_STR, false);
|
---|
[1414] | 2319 | Item primary = getPrimary();
|
---|
[1413] | 2320 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.LINK_HISTORY_STR)) {
|
---|
[1415] | 2321 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 2322 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.LINK_HISTORY_STR, inheritanceCheckOnSave);
|
---|
[1413] | 2323 | }
|
---|
| 2324 | }
|
---|
[676] | 2325 | }
|
---|
| 2326 |
|
---|
| 2327 | public boolean getLinkHistory() {
|
---|
[1413] | 2328 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.LINK_HISTORY_STR)) {
|
---|
[1414] | 2329 | return this.getPrimary().getLinkHistory();
|
---|
[1410] | 2330 | } else {
|
---|
| 2331 | return _linkHistory;
|
---|
| 2332 | }
|
---|
[676] | 2333 | }
|
---|
[4] | 2334 |
|
---|
[1102] | 2335 | public void setLinkFrameset(String frameset)
|
---|
| 2336 | {
|
---|
| 2337 | if (frameset == null || FrameIO.isValidFramesetName(frameset)) {
|
---|
[72] | 2338 | _link_frameset = frameset;
|
---|
[1102] | 2339 | } else {
|
---|
| 2340 | MessageBay.errorMessage("[" + frameset + "] is not a valid frameset name");
|
---|
| 2341 | }
|
---|
[72] | 2342 | // TODO make this throw exceptions etc...
|
---|
[1413] | 2343 |
|
---|
| 2344 | if (isSurrogate()) {
|
---|
| 2345 | surrogatePropertyInheritance.put(DefaultFrameWriter.LINK_FRAMESET_STR, false);
|
---|
[1414] | 2346 | Item primary = getPrimary();
|
---|
[1413] | 2347 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.LINK_FRAMESET_STR)) {
|
---|
[1415] | 2348 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 2349 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.LINK_FRAMESET_STR, inheritanceCheckOnSave);
|
---|
[1413] | 2350 | }
|
---|
| 2351 | }
|
---|
[4] | 2352 | }
|
---|
| 2353 |
|
---|
[1413] | 2354 | public void setLinkMark(boolean val) {
|
---|
[1102] | 2355 | if (!val) invalidateCommonTrait(ItemAppearence.LinkChanged);
|
---|
| 2356 | invalidateBounds();
|
---|
[7] | 2357 | _linkMark = val;
|
---|
[1102] | 2358 | if (val) invalidateCommonTrait(ItemAppearence.LinkChanged);
|
---|
[1413] | 2359 |
|
---|
| 2360 | if (isSurrogate()) {
|
---|
| 2361 | surrogatePropertyInheritance.put(DefaultFrameWriter.LINK_MARK_STR, false);
|
---|
[1414] | 2362 | Item primary = getPrimary();
|
---|
[1413] | 2363 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.LINK_MARK_STR)) {
|
---|
[1415] | 2364 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 2365 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.LINK_MARK_STR, inheritanceCheckOnSave);
|
---|
[1413] | 2366 | }
|
---|
| 2367 | }
|
---|
[4] | 2368 | }
|
---|
| 2369 |
|
---|
[1413] | 2370 | public void setLinkTemplate(String template) {
|
---|
[1102] | 2371 | if (FrameIO.isValidLink(template)) {
|
---|
[72] | 2372 | _link_template = template;
|
---|
[1102] | 2373 | } else {
|
---|
| 2374 | MessageBay.errorMessage("[" + template + "] is not a valid frame name");
|
---|
| 2375 | }
|
---|
[72] | 2376 | // TODO make this throw exceptions etc...
|
---|
[1413] | 2377 |
|
---|
| 2378 | if (isSurrogate()) {
|
---|
| 2379 | surrogatePropertyInheritance.put(DefaultFrameWriter.LINK_TEMPLATE_STR, false);
|
---|
[1414] | 2380 | Item primary = getPrimary();
|
---|
[1413] | 2381 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.LINK_TEMPLATE_STR)) {
|
---|
[1415] | 2382 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 2383 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.LINK_TEMPLATE_STR, inheritanceCheckOnSave);
|
---|
[1413] | 2384 | }
|
---|
| 2385 | }
|
---|
[4] | 2386 | }
|
---|
| 2387 |
|
---|
[147] | 2388 | // /**
|
---|
| 2389 | // * Sets the maximum coordinates on the screen that this item may occupy.
|
---|
| 2390 | // * This is used by Text items to compute word-wrapping lengths.
|
---|
| 2391 | // *
|
---|
| 2392 | // * @param d
|
---|
| 2393 | // * The Maximum size of the Frame containing this Item.
|
---|
| 2394 | // */
|
---|
| 2395 | // public void setMaxWidth(int width) {
|
---|
| 2396 | // if (width > 0) {
|
---|
| 2397 | // _maxWidth = width;
|
---|
| 2398 | // updatePolygon();
|
---|
| 2399 | // }
|
---|
| 2400 | // }
|
---|
[4] | 2401 |
|
---|
[7] | 2402 | public void setOffset(int x, int y) {
|
---|
[1102] | 2403 | _offset.set(x, y);
|
---|
[4] | 2404 | }
|
---|
| 2405 |
|
---|
[7] | 2406 | public void setOffset(Point p) {
|
---|
[1102] | 2407 | _offset.set(p);
|
---|
[4] | 2408 | }
|
---|
| 2409 |
|
---|
[7] | 2410 | public void setOwner(String own) {
|
---|
| 2411 | _owner = own;
|
---|
[1413] | 2412 |
|
---|
| 2413 | if (isSurrogate()) {
|
---|
| 2414 | surrogatePropertyInheritance.put(DefaultFrameWriter.OWNER_STR, false);
|
---|
[1414] | 2415 | Item primary = getPrimary();
|
---|
[1413] | 2416 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.OWNER_STR)) {
|
---|
[1415] | 2417 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 2418 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.OWNER_STR, inheritanceCheckOnSave);
|
---|
[1413] | 2419 | }
|
---|
| 2420 | }
|
---|
[4] | 2421 | }
|
---|
| 2422 |
|
---|
[7] | 2423 | public void setParent(Frame frame) {
|
---|
[741] | 2424 | _oldParent = _parent;
|
---|
[7] | 2425 | _parent = frame;
|
---|
[1212] | 2426 |
|
---|
| 2427 | if (_parent == null) { return; }
|
---|
[427] | 2428 |
|
---|
[1212] | 2429 | final String currentUser = UserSettings.UserName.get();
|
---|
| 2430 | final String existingOwner = _parent.getOwner();
|
---|
| 2431 | if (currentUser != null && (existingOwner == null || currentUser.compareTo(existingOwner) != 0)) {
|
---|
| 2432 | setOwner(currentUser);
|
---|
[427] | 2433 | }
|
---|
[4] | 2434 | }
|
---|
| 2435 |
|
---|
[7] | 2436 | /**
|
---|
[121] | 2437 | * Invalidates this, connected lines and fill
|
---|
[124] | 2438 | *
|
---|
[121] | 2439 | * @param trait
|
---|
| 2440 | */
|
---|
| 2441 | private void invalidateCommonTraitForAll(ItemAppearence trait) {
|
---|
| 2442 | invalidateCommonTrait(trait);
|
---|
[282] | 2443 | if (isLineEnd()) {
|
---|
| 2444 | boolean hasLinePattern = getLines().get(0).getLinePattern() != null;
|
---|
| 2445 | if (hasLinePattern) {
|
---|
| 2446 | for (Item i : getAllConnected()) {
|
---|
| 2447 | if (i instanceof Line) {
|
---|
[284] | 2448 | ((Line) i).invalidateCommonTrait(trait);
|
---|
[282] | 2449 | }
|
---|
| 2450 | }
|
---|
| 2451 | } else {
|
---|
| 2452 | for (Line line : getLines()) {
|
---|
| 2453 | line.invalidateCommonTrait(trait);
|
---|
| 2454 | }
|
---|
| 2455 | }
|
---|
| 2456 | }
|
---|
[1102] | 2457 | if (_fillColour != null) {
|
---|
[121] | 2458 | invalidateFill(); // only invalidates if has fill
|
---|
| 2459 | }
|
---|
[124] | 2460 | for (XRayable x : getEnclosures()) {
|
---|
[121] | 2461 | x.invalidateCommonTrait(trait);
|
---|
| 2462 | }
|
---|
| 2463 |
|
---|
| 2464 | }
|
---|
[124] | 2465 |
|
---|
[812] | 2466 | protected void anchorConstraints()
|
---|
| 2467 | {
|
---|
| 2468 | // update the position of any dots that are constrained by this one
|
---|
| 2469 | for (Constraint c : _constraints) {
|
---|
| 2470 | Item other = c.getOppositeEnd(this);
|
---|
| 2471 |
|
---|
| 2472 | // only set position if the other dot is still fixed to the
|
---|
| 2473 | // frame
|
---|
| 2474 | if (/* this.isFloating() && */!other.isFloating()) {
|
---|
| 2475 | if (c.getType() == Constraint.HORIZONTAL) {
|
---|
| 2476 | if (isAnchoredY()) {
|
---|
| 2477 | // Make the 'other' item have the same anchor top/bottom values as this
|
---|
[1102] | 2478 | other._anchoring.setYAnchor(this._anchoring);
|
---|
[812] | 2479 | }
|
---|
| 2480 | } else if (c.getType() == Constraint.VERTICAL) {
|
---|
| 2481 | if (isAnchoredX()) {
|
---|
| 2482 | // Make the 'other' item have the same anchor left/right values as this
|
---|
[1102] | 2483 | other._anchoring.setXAnchor(this._anchoring);
|
---|
[812] | 2484 | }
|
---|
| 2485 | } else if (c.isDiagonal()) {
|
---|
| 2486 |
|
---|
| 2487 | System.err.println("Warning: anchorConstraints() not implement for Diagonal setting");
|
---|
| 2488 | }
|
---|
| 2489 | }
|
---|
| 2490 | }
|
---|
| 2491 | }
|
---|
| 2492 |
|
---|
[121] | 2493 | /**
|
---|
[7] | 2494 | * Sets the position of this item on the screen
|
---|
| 2495 | *
|
---|
| 2496 | * @param x
|
---|
| 2497 | * The new X coordinate
|
---|
| 2498 | * @param y
|
---|
| 2499 | * The new Y coordinate
|
---|
| 2500 | */
|
---|
[1413] | 2501 | public void setPosition(float x, float y) {
|
---|
[97] | 2502 | float deltaX = x - _x;
|
---|
| 2503 | float deltaY = y - _y;
|
---|
[124] | 2504 |
|
---|
[1102] | 2505 | if (deltaX == 0 && deltaY == 0) return;
|
---|
[124] | 2506 |
|
---|
[121] | 2507 | invalidateCommonTraitForAll(ItemAppearence.PreMoved);
|
---|
[97] | 2508 |
|
---|
[7] | 2509 | _x = x;
|
---|
| 2510 | _y = y;
|
---|
[4] | 2511 |
|
---|
[108] | 2512 | for (Item i : getEnclosures()) {
|
---|
[1102] | 2513 | i.invalidateBounds();
|
---|
[108] | 2514 | }
|
---|
[1102] | 2515 | invalidateBounds();
|
---|
[4] | 2516 |
|
---|
[7] | 2517 | // update the position of any dots that are constrained by this one
|
---|
[50] | 2518 | for (Constraint c : _constraints) {
|
---|
| 2519 | Item other = c.getOppositeEnd(this);
|
---|
[4] | 2520 |
|
---|
[50] | 2521 | // only set position if the other dot is still fixed to the
|
---|
| 2522 | // frame
|
---|
[95] | 2523 | if (/* this.isFloating() && */!other.isFloating()) {
|
---|
[70] | 2524 | if (c.getType() == Constraint.HORIZONTAL) {
|
---|
[97] | 2525 | if (other._y != y) {
|
---|
[70] | 2526 | other.setY(y);
|
---|
[97] | 2527 | }
|
---|
| 2528 | } else if (c.getType() == Constraint.VERTICAL) {
|
---|
| 2529 | if (other._x != x) {
|
---|
[70] | 2530 | other.setX(x);
|
---|
[97] | 2531 | }
|
---|
| 2532 | } else if (c.isDiagonal()) {
|
---|
[105] | 2533 | if (Math.abs(other._x - x) != Math.abs(other._y - y)) {
|
---|
| 2534 |
|
---|
[97] | 2535 | float m1 = c.getGradient();
|
---|
| 2536 | float c1 = y - m1 * x;
|
---|
| 2537 | // Now work out the equation for the second line
|
---|
| 2538 | // Get the first line the other end is attached to that
|
---|
| 2539 | // is not the diagonal line
|
---|
| 2540 | List<Line> lines = other.getLines();
|
---|
| 2541 | // If there is only one line...
|
---|
| 2542 | if (lines.size() == 1) {
|
---|
[105] | 2543 | if (m1 != 0) {
|
---|
| 2544 | if (Math.abs(deltaX) > Math.abs(deltaY)) {
|
---|
[97] | 2545 | other.setX((other._y - c1) / m1);
|
---|
[105] | 2546 | } else {
|
---|
[97] | 2547 | other.setY(m1 * other._x + c1);
|
---|
| 2548 | }
|
---|
| 2549 | }
|
---|
| 2550 | } else if (lines.size() > 1) {
|
---|
| 2551 | Line otherLine = lines.get(0);
|
---|
| 2552 | Item end = otherLine.getOppositeEnd(other);
|
---|
| 2553 | if (end.equals(this)) {
|
---|
| 2554 | otherLine = lines.get(1);
|
---|
| 2555 | end = otherLine.getOppositeEnd(other);
|
---|
| 2556 | assert (!end.equals(this));
|
---|
| 2557 | }
|
---|
| 2558 |
|
---|
| 2559 | float xDiff = end._x - other._x;
|
---|
| 2560 | float yDiff = end._y - other._y;
|
---|
| 2561 | if (xDiff == 0) {
|
---|
| 2562 | other.setY(m1 * other._x + c1);
|
---|
| 2563 | } else if (Math.abs(xDiff) == Math.abs(yDiff)
|
---|
[105] | 2564 | && !this.isFloating() && deltaX == 0
|
---|
| 2565 | && deltaY == 0) {
|
---|
[97] | 2566 | if (deltaX == 0) {
|
---|
[105] | 2567 | _x = (_y - other._y) * m1 + other._x;
|
---|
[97] | 2568 | } else {
|
---|
[105] | 2569 | _y = (_x - other._x) * m1 + other._y;
|
---|
[97] | 2570 | }
|
---|
| 2571 | } else {
|
---|
| 2572 | float m2 = yDiff / xDiff;
|
---|
| 2573 | float c2 = end._y - m2 * end._x;
|
---|
| 2574 | float mDiff = m1 - m2;
|
---|
| 2575 | if (Math.abs(mDiff) < 0.000001) {
|
---|
| 2576 | assert (false);
|
---|
| 2577 | // TODO how do I handle this case!!
|
---|
| 2578 | } else {
|
---|
| 2579 | float newX = (c2 - c1) / mDiff;
|
---|
| 2580 | float newY = m1 * newX + c1;
|
---|
| 2581 | if (other._x != newX
|
---|
| 2582 | /* && other._y != newY */) {
|
---|
| 2583 | other.setPosition(newX, newY);
|
---|
| 2584 | }
|
---|
| 2585 | }
|
---|
| 2586 | }
|
---|
| 2587 | }
|
---|
| 2588 | // Do simultaneous equations to get the new postion for
|
---|
| 2589 | // the other end of the diagonal line
|
---|
| 2590 | }
|
---|
[70] | 2591 | }
|
---|
[7] | 2592 | }
|
---|
| 2593 | }
|
---|
| 2594 |
|
---|
[121] | 2595 | for (Line line : getLines()) {
|
---|
[1102] | 2596 | line.invalidateBounds();
|
---|
[121] | 2597 | }
|
---|
[124] | 2598 |
|
---|
[284] | 2599 | // for (Item item : getAllConnected()) {
|
---|
| 2600 | // item.updatePolygon();
|
---|
| 2601 | // }
|
---|
| 2602 |
|
---|
[121] | 2603 | invalidateCommonTraitForAll(ItemAppearence.PostMoved);
|
---|
[124] | 2604 |
|
---|
[1413] | 2605 | if (isSurrogate()) {
|
---|
| 2606 | surrogatePropertyInheritance.put(DefaultFrameWriter.POSITION_STR, false);
|
---|
[1414] | 2607 | Item primary = getPrimary();
|
---|
[1413] | 2608 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.POSITION_STR)) {
|
---|
[1415] | 2609 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 2610 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.POSITION_STR, inheritanceCheckOnSave);
|
---|
[1413] | 2611 | }
|
---|
| 2612 | }
|
---|
[4] | 2613 | }
|
---|
| 2614 |
|
---|
[7] | 2615 | public void setPosition(Point position) {
|
---|
[1143] | 2616 | setPosition(position.getX(), position.getY());
|
---|
[4] | 2617 | }
|
---|
| 2618 |
|
---|
[7] | 2619 | public void setRelativeLink() {
|
---|
[86] | 2620 | String link = getLink();
|
---|
| 2621 | if (link == null)
|
---|
[7] | 2622 | return;
|
---|
| 2623 | assert (_parent != null);
|
---|
[116] | 2624 |
|
---|
| 2625 | if (FrameIO.isPositiveInteger(link))
|
---|
[108] | 2626 | return;
|
---|
[116] | 2627 |
|
---|
[7] | 2628 | // Check if the link is for the current frameset
|
---|
| 2629 | if (_parent.getFramesetName().equalsIgnoreCase(
|
---|
[97] | 2630 | Conversion.getFramesetName(link))) {
|
---|
[86] | 2631 | setLink("" + Conversion.getFrameNumber(link));
|
---|
[7] | 2632 | }
|
---|
[4] | 2633 | }
|
---|
| 2634 |
|
---|
| 2635 | /**
|
---|
[7] | 2636 | * Sets the size of this Item. For Text this is the Font size. For Lines and
|
---|
| 2637 | * Dots this is the thickness.
|
---|
[4] | 2638 | */
|
---|
[108] | 2639 | public void setSize(float size) {
|
---|
[50] | 2640 | }
|
---|
[4] | 2641 |
|
---|
[115] | 2642 | /**
|
---|
| 2643 | * Sets the thickness of the item.
|
---|
[116] | 2644 | *
|
---|
[115] | 2645 | * @param thick
|
---|
| 2646 | */
|
---|
[311] | 2647 | public final void setThickness(float thick) {
|
---|
[115] | 2648 | setThickness(thick, true);
|
---|
[1413] | 2649 |
|
---|
| 2650 | if (isSurrogate()) {
|
---|
| 2651 | surrogatePropertyInheritance.put(DefaultFrameWriter.THICKNESS_STR, false);
|
---|
[1414] | 2652 | Item primary = getPrimary();
|
---|
[1413] | 2653 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.THICKNESS_STR)) {
|
---|
[1415] | 2654 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 2655 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.THICKNESS_STR, inheritanceCheckOnSave);
|
---|
[1413] | 2656 | }
|
---|
| 2657 | }
|
---|
[115] | 2658 | }
|
---|
[116] | 2659 |
|
---|
[115] | 2660 | /**
|
---|
| 2661 | * Sets the thickness of this item.
|
---|
[116] | 2662 | *
|
---|
| 2663 | * @param thick
|
---|
| 2664 | * the new thickness for the item
|
---|
| 2665 | * @param setConnectedThickness
|
---|
| 2666 | * true if all items connected to this item should also have
|
---|
| 2667 | * their thickness set
|
---|
[115] | 2668 | */
|
---|
[1102] | 2669 | public void setThickness(float thick, boolean setConnectedThickness)
|
---|
| 2670 | {
|
---|
| 2671 | if (thick == _thickness) return;
|
---|
| 2672 |
|
---|
[121] | 2673 | boolean bigger = thick > _thickness;
|
---|
[124] | 2674 |
|
---|
[130] | 2675 | if (!bigger) {
|
---|
| 2676 | if (setConnectedThickness) {
|
---|
| 2677 | // TODO is there a more efficient way of doing this?
|
---|
[1102] | 2678 | for (Item i : getConnected()) i.invalidateCommonTrait(ItemAppearence.Thickness);
|
---|
[130] | 2679 | } else {
|
---|
| 2680 | invalidateCommonTrait(ItemAppearence.Thickness);
|
---|
| 2681 | }
|
---|
| 2682 | }
|
---|
[124] | 2683 |
|
---|
[50] | 2684 | _thickness = thick;
|
---|
| 2685 | // update the size of any lines
|
---|
[362] | 2686 | /*
|
---|
| 2687 | * TODO: Revise the way line thickness is set to make it more efficient
|
---|
| 2688 | * etc...
|
---|
| 2689 | */
|
---|
[1102] | 2690 | for (Line line : getLines()) line.setThickness(thick, setConnectedThickness);
|
---|
[121] | 2691 |
|
---|
[1102] | 2692 | if (setConnectedThickness) invalidateBounds();
|
---|
[130] | 2693 |
|
---|
| 2694 | if (bigger) {
|
---|
| 2695 | if (setConnectedThickness) {
|
---|
[1102] | 2696 | for (Item i : getConnected()) i.invalidateCommonTrait(ItemAppearence.Thickness);
|
---|
[130] | 2697 | } else {
|
---|
| 2698 | invalidateCommonTrait(ItemAppearence.Thickness);
|
---|
| 2699 | }
|
---|
| 2700 | }
|
---|
[4] | 2701 | }
|
---|
| 2702 |
|
---|
| 2703 | /**
|
---|
[50] | 2704 | * Returns the thickness (in pixels) of this Dot.
|
---|
| 2705 | *
|
---|
| 2706 | * @return The 'thickness' of this Dot. (returns -1 if the thickness is not
|
---|
| 2707 | * set).
|
---|
| 2708 | */
|
---|
[1410] | 2709 | public float getThickness() {
|
---|
[1413] | 2710 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.THICKNESS_STR)) {
|
---|
[1414] | 2711 | return this.getPrimary().getThickness();
|
---|
[1410] | 2712 | } else {
|
---|
| 2713 | return _thickness;
|
---|
| 2714 | }
|
---|
[50] | 2715 | }
|
---|
| 2716 |
|
---|
| 2717 | /**
|
---|
[7] | 2718 | * Sets the Color to use on the top and left sections of this Item's border.
|
---|
| 2719 | * If top is NULL, then the Item's background Color will be used.
|
---|
[4] | 2720 | *
|
---|
[7] | 2721 | * @param top
|
---|
| 2722 | * The Color to display in the top and left sections of this
|
---|
| 2723 | * Item's border.
|
---|
[4] | 2724 | */
|
---|
[1102] | 2725 | public void setTopShadowColor(Colour top) {
|
---|
[7] | 2726 | _colorTopShadow = top;
|
---|
[4] | 2727 | }
|
---|
| 2728 |
|
---|
[1102] | 2729 | public void setWidth(Integer width) throws UnsupportedOperationException
|
---|
| 2730 | {
|
---|
| 2731 | throw new UnsupportedOperationException("Item type does not support width attribute!");
|
---|
[4] | 2732 | }
|
---|
[1200] | 2733 |
|
---|
| 2734 | public void setMinWidth(final Integer width) throws UnsupportedOperationException {
|
---|
| 2735 | throw new UnsupportedOperationException("Item type does not support minwidth attribute.");
|
---|
| 2736 | }
|
---|
[1369] | 2737 |
|
---|
| 2738 | public void setMaxWidth(Integer width) throws UnsupportedOperationException {
|
---|
| 2739 | throw new UnsupportedOperationException("Item type does not support maxwidth attribute");
|
---|
| 2740 | }
|
---|
[282] | 2741 |
|
---|
[1511] | 2742 | public void setRightMargin(int rightEdgeToFitTo, boolean fixWidth)
|
---|
[1102] | 2743 | {
|
---|
[1511] | 2744 | int itemXLeft = getX();
|
---|
| 2745 | int adjustedRightEdgeToFitTo = rightEdgeToFitTo - Item.MARGIN_LEFT;
|
---|
[1244] | 2746 |
|
---|
[1511] | 2747 | if (itemXLeft < adjustedRightEdgeToFitTo) {
|
---|
| 2748 | int newWidth = adjustedRightEdgeToFitTo - itemXLeft;
|
---|
| 2749 |
|
---|
| 2750 | if (!fixWidth) {
|
---|
| 2751 | newWidth *= -1;
|
---|
| 2752 | }
|
---|
| 2753 |
|
---|
| 2754 | setWidth(newWidth);
|
---|
| 2755 | } else if (fixWidth) {
|
---|
| 2756 | System.err.println(
|
---|
| 2757 | "Item::setRightMargin() called to set right margin outside of writable area but with fixWidth set to true.");
|
---|
| 2758 | System.err.println(this);
|
---|
[400] | 2759 | }
|
---|
[247] | 2760 | }
|
---|
[4] | 2761 |
|
---|
[7] | 2762 | /**
|
---|
| 2763 | * Sets the position of this Item on the X axis
|
---|
| 2764 | *
|
---|
| 2765 | * @param newX
|
---|
| 2766 | * The position on the X axis to assign to this Item
|
---|
| 2767 | */
|
---|
[97] | 2768 | public void setX(float newX) {
|
---|
[7] | 2769 | setPosition(newX, getY());
|
---|
[1413] | 2770 |
|
---|
[1417] | 2771 | // if (isSurrogate()) {
|
---|
| 2772 | // surrogatePropertyInheritance.put(DefaultFrameWriter.POSITION_STR, false);
|
---|
| 2773 | // Item primary = getPrimary();
|
---|
| 2774 | // if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.POSITION_STR)) {
|
---|
| 2775 | // EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 2776 | // primary.primaryPropertyEncryption.put(DefaultFrameWriter.POSITION_STR, inheritanceCheckOnSave);
|
---|
| 2777 | // }
|
---|
| 2778 | // }
|
---|
[4] | 2779 | }
|
---|
| 2780 |
|
---|
| 2781 | /**
|
---|
[7] | 2782 | * Sets the position of this Item on the Y axis
|
---|
[4] | 2783 | *
|
---|
[7] | 2784 | * @param newY
|
---|
| 2785 | * The position on the Y axis to assign to this Item
|
---|
[4] | 2786 | */
|
---|
[97] | 2787 | public void setY(float newY) {
|
---|
[7] | 2788 | setPosition(getX(), newY);
|
---|
[1413] | 2789 |
|
---|
[1417] | 2790 | // if (isSurrogate()) {
|
---|
| 2791 | // surrogatePropertyInheritance.put(DefaultFrameWriter.POSITION_STR, false);
|
---|
| 2792 | // Item primary = getPrimary();
|
---|
| 2793 | // if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.POSITION_STR)) {
|
---|
| 2794 | // EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 2795 | // primary.primaryPropertyEncryption.put(DefaultFrameWriter.POSITION_STR, inheritanceCheckOnSave);
|
---|
| 2796 | // }
|
---|
| 2797 | // }
|
---|
[4] | 2798 | }
|
---|
| 2799 |
|
---|
[7] | 2800 | /**
|
---|
| 2801 | * Paints any highlighting of this Item. This may include changing the
|
---|
| 2802 | * thickness (lines) or painting a box around the item (Text, Images). If
|
---|
| 2803 | * val is True then the Graphics Color is changed to the highlight Color, if
|
---|
| 2804 | * False then the Graphics Color is left unchanged (for clearing of
|
---|
| 2805 | * highlighting).
|
---|
| 2806 | *
|
---|
| 2807 | * @param val
|
---|
| 2808 | * True if this Item should be highlighted, false if the
|
---|
[21] | 2809 | * highlighting is being cleared.
|
---|
[7] | 2810 | * @return The desired mouse cursor when this Item is highlighted (negative
|
---|
| 2811 | * means no change)
|
---|
| 2812 | */
|
---|
[1102] | 2813 |
|
---|
| 2814 | /**
|
---|
| 2815 | *
|
---|
| 2816 | *
|
---|
| 2817 | * @return
|
---|
| 2818 | */
|
---|
| 2819 | public void setHighlightColorToDefault() {
|
---|
| 2820 | setHighlightColor(DEFAULT_HIGHLIGHT);
|
---|
[4] | 2821 | }
|
---|
| 2822 |
|
---|
[1102] | 2823 | public void setHighlightColor(Colour c) {
|
---|
| 2824 | if (c == null) return;
|
---|
| 2825 |
|
---|
[286] | 2826 | if (!this.isVisible() && this.hasVector()) {
|
---|
| 2827 | for (Item i : this.getParentOrCurrentFrame().getVectorItems()) {
|
---|
| 2828 | if (i.getEditTarget() == this) {
|
---|
| 2829 | i.setHighlightColor(c);
|
---|
| 2830 | }
|
---|
| 2831 | }
|
---|
| 2832 | }
|
---|
[124] | 2833 |
|
---|
[21] | 2834 | _highlightThickness = DEFAULT_HIGHLIGHT_THICKNESS;
|
---|
[124] | 2835 |
|
---|
[1102] | 2836 | Colour selColor = (c != null) ? c : DEFAULT_HIGHLIGHT;
|
---|
| 2837 | if (_highlightColour != c) {
|
---|
| 2838 | _highlightColour = selColor;
|
---|
[121] | 2839 | this.invalidateCommonTrait(ItemAppearence.HighlightColorChanged);
|
---|
| 2840 | }
|
---|
[4] | 2841 |
|
---|
| 2842 | }
|
---|
[50] | 2843 |
|
---|
[7] | 2844 | private void updateArrowPolygon() {
|
---|
[475] | 2845 | if (getArrowheadLength() < 0 || getArrowheadRatio() < 0 || getArrowheadNibPerc() < 0)
|
---|
[7] | 2846 | _arrowhead = null;
|
---|
| 2847 | else {
|
---|
[475] | 2848 | _arrowhead = Line.createArrowheadPolygon(getX(),getY(),getArrowheadLength(),getArrowheadRatio(),getArrowheadNibPerc());
|
---|
[4] | 2849 | }
|
---|
| 2850 | }
|
---|
[50] | 2851 |
|
---|
[1102] | 2852 | /** Returns a Bounds which represents the area covered by the item (including its gravity). */
|
---|
| 2853 | public abstract Bounds updateBounds();
|
---|
[4] | 2854 |
|
---|
[108] | 2855 | public void setHidden(boolean state) {
|
---|
| 2856 | this._visible = !state;
|
---|
| 2857 | }
|
---|
| 2858 |
|
---|
[7] | 2859 | public void setVisible(boolean state) {
|
---|
| 2860 | this._visible = state;
|
---|
[4] | 2861 | }
|
---|
| 2862 |
|
---|
[7] | 2863 | public boolean isVisible() {
|
---|
[108] | 2864 | return _visible && !_deleted;
|
---|
[4] | 2865 | }
|
---|
[70] | 2866 |
|
---|
[55] | 2867 | /**
|
---|
[70] | 2868 | * Raised whenever the item is removed, added, no longer in view (That is,
|
---|
| 2869 | * when it is not on any of the current frames, of overlays of the current
|
---|
| 2870 | * frames) or has become visible. That is, when it is either on a current
|
---|
[115] | 2871 | * frame, or an overlay of a current frame.
|
---|
[70] | 2872 | *
|
---|
| 2873 | * @param e
|
---|
| 2874 | * The event
|
---|
[55] | 2875 | */
|
---|
[70] | 2876 | public void onParentStateChanged(ItemParentStateChangedEvent e) {
|
---|
| 2877 | }
|
---|
[181] | 2878 |
|
---|
[1102] | 2879 | /**
|
---|
| 2880 | * Sets the highlight mode and colour at the same time.
|
---|
| 2881 | *
|
---|
| 2882 | * @param mode The new highlight mode.
|
---|
| 2883 | * @param colour The new highlight colour.
|
---|
| 2884 | */
|
---|
| 2885 | public void setHighlightModeAndColour(HighlightMode mode, Colour colour)
|
---|
| 2886 | {
|
---|
| 2887 | setHighlightMode(mode);
|
---|
| 2888 | setHighlightColor(colour);
|
---|
[21] | 2889 | }
|
---|
| 2890 |
|
---|
[115] | 2891 | public HighlightMode getHighlightMode() {
|
---|
[1102] | 2892 | return _highlightMode;
|
---|
[21] | 2893 | }
|
---|
[50] | 2894 |
|
---|
| 2895 | public void anchor() {
|
---|
[67] | 2896 | Frame current = getParentOrCurrentFrame();
|
---|
[741] | 2897 | // only set the id if we've moved to a different frame, or if the frame already has an item with that id
|
---|
| 2898 | if(!current.equals(_oldParent) || current.getItemWithID(getID()) != null) {
|
---|
| 2899 | setID(current.getNextItemID());
|
---|
| 2900 | } else {
|
---|
| 2901 | // System.out.println(this + " - Kept old ID of " + _id);
|
---|
| 2902 | }
|
---|
[50] | 2903 | setOffset(0, 0);
|
---|
| 2904 | setParent(current);
|
---|
| 2905 |
|
---|
[242] | 2906 | current.addItem(this, false);
|
---|
[1415] | 2907 | current.invalidateSorted();
|
---|
[50] | 2908 | setRelativeLink();
|
---|
| 2909 | setFloating(false);
|
---|
[97] | 2910 |
|
---|
| 2911 | // // If its an unconstrained line end check if we should add a
|
---|
| 2912 | // constraint
|
---|
| 2913 | // if (isLineEnd() && getLines().size() <= 2
|
---|
| 2914 | // && getConstraints().size() <= 1) {
|
---|
| 2915 | // Constraint existingConstraint = null;
|
---|
| 2916 | // List<Constraint> constraints = getConstraints();
|
---|
| 2917 | // // Get the existing constraint
|
---|
| 2918 | // if (constraints.size() > 0) {
|
---|
| 2919 | // existingConstraint = constraints.get(0);
|
---|
| 2920 | // }
|
---|
| 2921 | // for (Line line : getLines()) {
|
---|
| 2922 | // Integer constraintType = line.getPossibleConstraint();
|
---|
| 2923 | // if (constraintType != null) {
|
---|
| 2924 | // Item oppositeEnd = line.getOppositeEnd(this);
|
---|
| 2925 | // if (existingConstraint == null
|
---|
| 2926 | // || !existingConstraint.contains(oppositeEnd)) {
|
---|
| 2927 | // new Constraint(this, oppositeEnd,
|
---|
| 2928 | // getParentOrCurrentFrame().getNextItemID(),
|
---|
| 2929 | // constraintType);
|
---|
| 2930 | // }
|
---|
| 2931 | // }
|
---|
| 2932 | // }
|
---|
| 2933 | // }
|
---|
[50] | 2934 | }
|
---|
| 2935 |
|
---|
| 2936 | /**
|
---|
| 2937 | * Gets the parent frame if it is set or the current frame if this item does
|
---|
| 2938 | * not have a parent set.
|
---|
| 2939 | *
|
---|
| 2940 | * @return
|
---|
| 2941 | */
|
---|
[67] | 2942 | public Frame getParentOrCurrentFrame() {
|
---|
[50] | 2943 | // if the item is from an overlay the parent will NOT be null
|
---|
| 2944 | if (getParent() == null) {
|
---|
[1102] | 2945 | return DisplayController.getCurrentFrame();
|
---|
[50] | 2946 | }
|
---|
| 2947 | return getParent();
|
---|
| 2948 | }
|
---|
| 2949 |
|
---|
| 2950 | /**
|
---|
| 2951 | * Sets the list of Dots (including this one) that form a closed shape.
|
---|
| 2952 | * Passing null sets this dot back to its normal (non-enclosed) state.
|
---|
| 2953 | *
|
---|
| 2954 | * @param enclosed
|
---|
| 2955 | * The List of Dots including this one that form a closed shape,
|
---|
| 2956 | * or null.
|
---|
| 2957 | */
|
---|
[72] | 2958 | public void setEnclosedList(Collection<Item> enclosed) {
|
---|
[124] | 2959 |
|
---|
[121] | 2960 | boolean changed = (_enclosure == null && enclosed != null);
|
---|
[124] | 2961 |
|
---|
[121] | 2962 | if (_enclosure != null && enclosed == null) {
|
---|
| 2963 | invalidateFill();
|
---|
| 2964 | }
|
---|
[124] | 2965 |
|
---|
[50] | 2966 | _enclosure = enclosed;
|
---|
[124] | 2967 |
|
---|
[121] | 2968 | if (changed) {
|
---|
[124] | 2969 | invalidateFill();
|
---|
| 2970 | ;
|
---|
[121] | 2971 | }
|
---|
[50] | 2972 | }
|
---|
| 2973 |
|
---|
| 2974 | /**
|
---|
| 2975 | * Returns the polygon that represents the shape created by all the Dots in
|
---|
| 2976 | * this Dot's enclosed list. If the list is null, then null is returned.
|
---|
| 2977 | *
|
---|
| 2978 | * @return A Polygon the same shape and position as created by the Dots in
|
---|
| 2979 | * the enclosed list.
|
---|
| 2980 | */
|
---|
[1102] | 2981 | public PolygonBounds getEnclosedShape()
|
---|
| 2982 | {
|
---|
| 2983 | if (_enclosure == null) return null;
|
---|
[50] | 2984 |
|
---|
[1102] | 2985 | PolygonBounds poly = new PolygonBounds();
|
---|
[50] | 2986 | for (Item d : _enclosure) {
|
---|
[1102] | 2987 | poly.addPoint(new Point(d.getX(), d.getY()));
|
---|
[50] | 2988 | }
|
---|
| 2989 |
|
---|
| 2990 | return poly;
|
---|
| 2991 | }
|
---|
| 2992 |
|
---|
| 2993 | /**
|
---|
| 2994 | * Returns the list of Dots that, along with this Dot, form an enclosed
|
---|
| 2995 | * polygon. If this Dot is not part of an enclosure null may be returned.
|
---|
| 2996 | *
|
---|
| 2997 | * @return The List of Dots that form an enclosed shape with this Dot, or
|
---|
| 2998 | * null if this Dot is not part of an enclosure.
|
---|
| 2999 | */
|
---|
[72] | 3000 | public Collection<Item> getEnclosingDots() {
|
---|
[50] | 3001 | return _enclosure;
|
---|
| 3002 | }
|
---|
| 3003 |
|
---|
| 3004 | /**
|
---|
| 3005 | * Returns whether this Dot has an assigned enclosure list of other Dots.
|
---|
| 3006 | * The result is the same as getEnclosedShape() != null.
|
---|
| 3007 | *
|
---|
| 3008 | * @return True if this Dot has an enclosure list of other Dots, false
|
---|
| 3009 | * otherwise.
|
---|
| 3010 | */
|
---|
| 3011 | public boolean isEnclosed() {
|
---|
| 3012 | return _enclosure != null;
|
---|
| 3013 | }
|
---|
| 3014 |
|
---|
[108] | 3015 | /**
|
---|
| 3016 | * True if this item is the end of a line.
|
---|
| 3017 | *
|
---|
| 3018 | * @return
|
---|
| 3019 | */
|
---|
[50] | 3020 | public boolean isLineEnd() {
|
---|
[108] | 3021 | // TODO this will need to be redone when enclosure class is added...
|
---|
[812] | 3022 | // At the moment enclosures are only circles...we don't want circle
|
---|
| 3023 | // centres to be lineEnds
|
---|
[50] | 3024 | return _lines.size() > 0;
|
---|
| 3025 | }
|
---|
[116] | 3026 |
|
---|
| 3027 | public boolean hasEnclosures() {
|
---|
[108] | 3028 | return _enclosures.size() > 0;
|
---|
| 3029 | }
|
---|
[50] | 3030 |
|
---|
| 3031 | /**
|
---|
| 3032 | * Method that is called to notify an item that is on the end of a line that
|
---|
| 3033 | * its line has changed color.
|
---|
| 3034 | *
|
---|
| 3035 | * @param c
|
---|
| 3036 | * the new color for the line
|
---|
| 3037 | */
|
---|
[1102] | 3038 | protected void lineColorChanged(Colour c) {
|
---|
[50] | 3039 | for (Line l : getLines()) {
|
---|
| 3040 | if (l.getColor() != c)
|
---|
| 3041 | l.setColor(c);
|
---|
| 3042 | }
|
---|
| 3043 | }
|
---|
[70] | 3044 |
|
---|
[58] | 3045 | /**
|
---|
| 3046 | * Checks if this item is off the left or top of the screen
|
---|
[70] | 3047 | *
|
---|
[58] | 3048 | * @return
|
---|
| 3049 | */
|
---|
[86] | 3050 | public boolean offScreenTopOrLeft() {
|
---|
[1102] | 3051 | Bounds bounds = getBoundingBox();
|
---|
| 3052 |
|
---|
[70] | 3053 | // Check that the bottom right corner of this item is on the screen
|
---|
[1102] | 3054 | if (bounds.getMaxX() >= 0 && bounds.getMaxY() >= 0) {
|
---|
[58] | 3055 | return false;
|
---|
[1102] | 3056 | }
|
---|
| 3057 |
|
---|
[70] | 3058 | // Check if all the items it is connected to are offscreen
|
---|
| 3059 | for (Item i : getAllConnected()) {
|
---|
[1102] | 3060 | bounds = i.getBoundingBox();
|
---|
[70] | 3061 | // Check that the bottom right corner of this item is on the screen
|
---|
[1102] | 3062 | if (bounds.getMaxX() >= 0 && bounds.getMaxY() >= 0) {
|
---|
[58] | 3063 | return false;
|
---|
| 3064 | }
|
---|
| 3065 | }
|
---|
[1102] | 3066 |
|
---|
[58] | 3067 | return true;
|
---|
| 3068 | }
|
---|
[72] | 3069 |
|
---|
| 3070 | public void setConnectedToAnnotation(boolean val) {
|
---|
| 3071 | _connectedToAnnotation = val;
|
---|
| 3072 | }
|
---|
| 3073 |
|
---|
| 3074 | public boolean isConnectedToAnnotation() {
|
---|
| 3075 | return _connectedToAnnotation;
|
---|
| 3076 | }
|
---|
[74] | 3077 |
|
---|
[133] | 3078 | public boolean hasAction() {
|
---|
[154] | 3079 | List<String> actions = getAction();
|
---|
| 3080 | return actions != null && actions.size() > 0;
|
---|
[133] | 3081 | }
|
---|
[137] | 3082 |
|
---|
[1102] | 3083 | public void setAction(String action)
|
---|
| 3084 | {
|
---|
| 3085 | // Want to resize the highlight box for text items if actions are been added
|
---|
[130] | 3086 | if (action == null || action.length() == 0) {
|
---|
[121] | 3087 | invalidateCommonTrait(ItemAppearence.LinkChanged);
|
---|
[108] | 3088 | }
|
---|
[1102] | 3089 |
|
---|
[131] | 3090 | if (_actions == null || _actions.size() == 0) {
|
---|
[1102] | 3091 | invalidateBounds();
|
---|
[130] | 3092 | _actions = new LinkedList<String>();
|
---|
[131] | 3093 | } else {
|
---|
[130] | 3094 | _actions.clear();
|
---|
| 3095 | }
|
---|
[1102] | 3096 |
|
---|
| 3097 | if (action != null && action.length() > 0) _actions.add(action);
|
---|
| 3098 |
|
---|
[130] | 3099 | invalidateCommonTrait(ItemAppearence.LinkChanged);
|
---|
[74] | 3100 | }
|
---|
[80] | 3101 |
|
---|
[78] | 3102 | protected int getLinkYOffset() {
|
---|
| 3103 | return 0;
|
---|
| 3104 | }
|
---|
[124] | 3105 |
|
---|
[1102] | 3106 | protected AxisAlignedBoxBounds getLinkDrawArea() {
|
---|
[184] | 3107 | return getLinkDrawArea(getX() - LEFT_MARGIN, getY() + getLinkYOffset());
|
---|
[121] | 3108 | }
|
---|
[214] | 3109 |
|
---|
[184] | 3110 | /**
|
---|
[214] | 3111 | * TODO: Revise - it would be good to have a member that defines the link
|
---|
| 3112 | * dimensions.
|
---|
[184] | 3113 | *
|
---|
| 3114 | * @param x
|
---|
[214] | 3115 | * Left of graphic (i.e not centered)
|
---|
[184] | 3116 | * @param y
|
---|
[214] | 3117 | * Above graphic (i.e not centered)
|
---|
[184] | 3118 | *
|
---|
[214] | 3119 | * @return The drawing area of the link at the given coordinates.
|
---|
[184] | 3120 | */
|
---|
[1102] | 3121 | public AxisAlignedBoxBounds getLinkDrawArea(int x, int y) {
|
---|
| 3122 | return new AxisAlignedBoxBounds(x + 2, y - 1, 8, 8);
|
---|
[184] | 3123 | }
|
---|
[78] | 3124 |
|
---|
| 3125 | /**
|
---|
[80] | 3126 | * Paint the link symbol for the item if it is a
|
---|
| 3127 | *
|
---|
[78] | 3128 | * @param g
|
---|
| 3129 | */
|
---|
[1102] | 3130 | protected void paintLink() {
|
---|
| 3131 | paintLinkGraphic(getX() - LEFT_MARGIN, getY() + getLinkYOffset());
|
---|
[1477] | 3132 | paintKeyGraphic(getX() - LEFT_MARGIN, getY() + getLinkYOffset());
|
---|
| 3133 | paintPadlockGraphic(getX() - LEFT_MARGIN, getY() + getLinkYOffset());
|
---|
[184] | 3134 | }
|
---|
| 3135 |
|
---|
| 3136 | /**
|
---|
| 3137 | * Paint the link symbol for the item at a given position.
|
---|
| 3138 | *
|
---|
[214] | 3139 | * @see #paintLink
|
---|
| 3140 | *
|
---|
[184] | 3141 | * @param g
|
---|
[214] | 3142 | * The graphics to paint with
|
---|
[184] | 3143 | *
|
---|
| 3144 | * @param x
|
---|
[214] | 3145 | * The x position of the link. Left of graphic (i.e not centered)
|
---|
[184] | 3146 | *
|
---|
| 3147 | * @param y
|
---|
[214] | 3148 | * The y position of the link. Above of graphic (i.e not
|
---|
| 3149 | * centered)
|
---|
[184] | 3150 | */
|
---|
[1102] | 3151 | public void paintLinkGraphic(int x, int y) {
|
---|
[214] | 3152 |
|
---|
[1102] | 3153 | boolean hasLink = hasLink();
|
---|
[133] | 3154 | boolean hasAction = hasAction();
|
---|
[214] | 3155 |
|
---|
[133] | 3156 | if (hasLink || hasAction) {
|
---|
[1102] | 3157 | GraphicsManager g = EcosystemManager.getGraphicsManager();
|
---|
| 3158 | Fill fill = new Fill();
|
---|
| 3159 | Colour colour = null;
|
---|
| 3160 | Point offset = new Point(x, y);
|
---|
| 3161 |
|
---|
[133] | 3162 | if (hasLink && hasAction) {
|
---|
[1102] | 3163 | colour = LINK_ACTION_COLOR;
|
---|
[133] | 3164 | } else if (hasLink) {
|
---|
[1102] | 3165 | colour = LINK_COLOR;
|
---|
[133] | 3166 | } else if (hasAction) {
|
---|
[1102] | 3167 | colour = ACTION_COLOR;
|
---|
[78] | 3168 | }
|
---|
[1102] | 3169 | fill.setColour(colour);
|
---|
[80] | 3170 |
|
---|
[1102] | 3171 | // Small circles look rubbish without AA. cts16
|
---|
| 3172 | g.setAntialiasing(true);
|
---|
| 3173 |
|
---|
| 3174 | if (hasLink && getLinkMark()) {
|
---|
| 3175 | g.drawOval(offset, getLinkBounds().getDiameters(), 0.0f, null, colour, HIGHLIGHT_STROKE);
|
---|
| 3176 |
|
---|
[78] | 3177 | // if the link is not valid, cross out the circle
|
---|
[1102] | 3178 | if (!isLinkValid()) {
|
---|
| 3179 | g.drawPolygon(getCircleCross(), offset, null, 0.0f, null, colour, HIGHLIGHT_STROKE);
|
---|
| 3180 | }
|
---|
[78] | 3181 | }
|
---|
[80] | 3182 |
|
---|
[1102] | 3183 | if (hasAction && getActionMark()) {
|
---|
| 3184 | g.drawOval(offset, getLinkBounds().getDiameters(), 0.0f, fill, colour, HIGHLIGHT_STROKE);
|
---|
[80] | 3185 |
|
---|
[78] | 3186 | // if the link is not valid, cross out the circle
|
---|
| 3187 | if (!isLinkValid() && getLink() != null) {
|
---|
[1102] | 3188 | g.drawPolygon(getCircleCross(), offset, null, 0.0f, null, getParent().getPaintBackgroundColor(), HIGHLIGHT_STROKE);
|
---|
[78] | 3189 | }
|
---|
| 3190 | }
|
---|
[1102] | 3191 |
|
---|
| 3192 | g.setAntialiasing(false);
|
---|
[78] | 3193 | }
|
---|
| 3194 | }
|
---|
[80] | 3195 |
|
---|
[1477] | 3196 | protected void paintKeyGraphic(int x, int y) {
|
---|
| 3197 | Colour fontColour = null;
|
---|
| 3198 | switch (this.keyType()) {
|
---|
| 3199 | case PartialKey:
|
---|
| 3200 | fontColour = Colour.LIGHT_GRAY;
|
---|
| 3201 | break;
|
---|
| 3202 | case FullKey:
|
---|
| 3203 | fontColour = Colour.BLACK;
|
---|
| 3204 | break;
|
---|
| 3205 | default:
|
---|
| 3206 | return;
|
---|
| 3207 | }
|
---|
| 3208 |
|
---|
| 3209 | GraphicsManager g = EcosystemManager.getGraphicsManager();
|
---|
| 3210 | g.setAntialiasing(true);
|
---|
| 3211 | Font font = new Font();
|
---|
| 3212 | g.drawString("\uD83D\uDD11", new Point(x,y), font, fontColour);
|
---|
| 3213 | g.setAntialiasing(false);
|
---|
| 3214 | }
|
---|
| 3215 |
|
---|
| 3216 | protected void paintPadlockGraphic(int x, int y) {
|
---|
| 3217 | String encryptionLabel = this.getEncryptionLabel();
|
---|
| 3218 | if (encryptionLabel != null && encryptionLabel.length() > 0) {
|
---|
| 3219 | GraphicsManager g = EcosystemManager.getGraphicsManager();
|
---|
| 3220 | g.setAntialiasing(true);
|
---|
| 3221 | Font font = new Font();
|
---|
| 3222 | g.drawString("\uD83D\uDD12", new Point(x,y), font, Colour.BLACK);
|
---|
| 3223 | g.setAntialiasing(false);
|
---|
| 3224 | }
|
---|
| 3225 | }
|
---|
| 3226 |
|
---|
| 3227 | public KeyType keyType() {
|
---|
| 3228 | return keyType;
|
---|
| 3229 | }
|
---|
| 3230 |
|
---|
| 3231 | public void setKeyType(String s) {
|
---|
| 3232 | try {
|
---|
| 3233 | keyType = KeyType.valueOf(s);
|
---|
| 3234 | } catch (IllegalArgumentException e) {
|
---|
| 3235 | keyType = KeyType.NotAKey;
|
---|
| 3236 | }
|
---|
| 3237 | }
|
---|
| 3238 |
|
---|
[78] | 3239 | /**
|
---|
| 3240 | * Gets the distance between the start of the text and the left border of
|
---|
| 3241 | * the item. This distance changes depending on whether or not the item is
|
---|
| 3242 | * linked or has an associated action.
|
---|
| 3243 | *
|
---|
| 3244 | * @return the gap size in pixels
|
---|
| 3245 | */
|
---|
| 3246 | protected int getLeftMargin() {
|
---|
| 3247 | return ((getLinkMark() && getLink() != null)
|
---|
| 3248 | || (getActionMark() && getAction() != null) ? MARGIN_LEFT
|
---|
| 3249 | - MARGIN_RIGHT : MARGIN_RIGHT);
|
---|
| 3250 | }
|
---|
[80] | 3251 |
|
---|
| 3252 | public String getName() {
|
---|
[199] | 3253 | return getText();
|
---|
[80] | 3254 | }
|
---|
| 3255 |
|
---|
| 3256 | final public String getAbsoluteLinkTemplate() {
|
---|
| 3257 | return getAbsoluteLink(getLinkTemplate());
|
---|
| 3258 | }
|
---|
| 3259 |
|
---|
| 3260 | final public String getAbsoluteLinkFrameset() {
|
---|
| 3261 | return getAbsoluteLink(getLinkFrameset());
|
---|
| 3262 | }
|
---|
| 3263 |
|
---|
| 3264 | final public String getAbsoluteLink() {
|
---|
| 3265 | return getAbsoluteLink(getLink());
|
---|
| 3266 | }
|
---|
| 3267 |
|
---|
| 3268 | /**
|
---|
| 3269 | * @param link
|
---|
| 3270 | * @return
|
---|
| 3271 | */
|
---|
| 3272 | private String getAbsoluteLink(String link) {
|
---|
| 3273 | if (link == null)
|
---|
| 3274 | return null;
|
---|
| 3275 | // assert (_parent!= null);
|
---|
[108] | 3276 | Frame parent = getParentOrCurrentFrame();
|
---|
[80] | 3277 | if (_parent == null) {
|
---|
| 3278 | // if parent is null it is an item on the message box
|
---|
| 3279 | // so it must already be absolute
|
---|
[116] | 3280 | // assert (!FrameIO.isPositiveInteger(link));
|
---|
| 3281 | // return link;
|
---|
| 3282 |
|
---|
[80] | 3283 | }
|
---|
| 3284 |
|
---|
| 3285 | // if its a relative link then return absolute
|
---|
| 3286 | if (FrameIO.isPositiveInteger(link)) {
|
---|
[108] | 3287 | return parent.getFramesetName() + link;
|
---|
[80] | 3288 | }
|
---|
| 3289 | return link;
|
---|
| 3290 | }
|
---|
[242] | 3291 |
|
---|
[220] | 3292 | public static String convertToAbsoluteLink(String link) {
|
---|
| 3293 | if (link == null)
|
---|
| 3294 | return null;
|
---|
| 3295 | // assert (_parent!= null);
|
---|
[1102] | 3296 | Frame parent = DisplayController.getCurrentFrame();
|
---|
[242] | 3297 | assert (parent != null);
|
---|
[105] | 3298 |
|
---|
[220] | 3299 | // if its a relative link then return absolute
|
---|
| 3300 | if (FrameIO.isPositiveInteger(link)) {
|
---|
| 3301 | return parent.getFramesetName() + link;
|
---|
| 3302 | }
|
---|
| 3303 | return link;
|
---|
| 3304 | }
|
---|
| 3305 |
|
---|
[105] | 3306 | /**
|
---|
| 3307 | * Sets the x and y values of this item ignoring constraints.
|
---|
| 3308 | *
|
---|
| 3309 | * @param x
|
---|
| 3310 | * new x position
|
---|
| 3311 | * @param y
|
---|
| 3312 | * new y position
|
---|
| 3313 | */
|
---|
[108] | 3314 | public void setXY(float x, float y) {
|
---|
[105] | 3315 | _x = x;
|
---|
| 3316 | _y = y;
|
---|
| 3317 | }
|
---|
| 3318 |
|
---|
| 3319 | /**
|
---|
| 3320 | * Recursive function for getting the path around a shape. This is used to
|
---|
| 3321 | * get the path that is painted on the screen.
|
---|
| 3322 | *
|
---|
| 3323 | * @param visited
|
---|
| 3324 | * @param points
|
---|
| 3325 | * @param addToEnd
|
---|
| 3326 | * @param toExplore
|
---|
| 3327 | */
|
---|
| 3328 | public void appendPath(Collection<Line> visited, LinkedList<Point> points,
|
---|
| 3329 | boolean addToEnd, Collection<Line> toExplore) {
|
---|
| 3330 |
|
---|
| 3331 | if (addToEnd) {
|
---|
| 3332 | // put the start item points into our list
|
---|
| 3333 | points.addLast(getPosition());
|
---|
| 3334 | } else {
|
---|
| 3335 | points.addFirst(getPosition());
|
---|
| 3336 | }
|
---|
| 3337 |
|
---|
| 3338 | // Find the line that has not been added yet
|
---|
| 3339 | LinkedList<Line> lines = new LinkedList<Line>();
|
---|
| 3340 | lines.addAll(getLines());
|
---|
| 3341 |
|
---|
| 3342 | while (!lines.isEmpty()) {
|
---|
| 3343 | Line l = lines.remove();
|
---|
[1102] | 3344 | // if we haven't visited the line yet visit it
|
---|
[105] | 3345 | if (!visited.contains(l)) {
|
---|
| 3346 | visited.add(l);
|
---|
| 3347 | Item otherEnd = l.getOppositeEnd(this);
|
---|
[1102] | 3348 | // Add all the unexplored lines to our list
|
---|
[105] | 3349 | while (!lines.isEmpty()) {
|
---|
| 3350 | l = lines.remove();
|
---|
| 3351 | // Get the paths for the rest of the lines to be explored
|
---|
| 3352 | // later
|
---|
| 3353 | if (!toExplore.contains(l) && !visited.contains(l)) {
|
---|
| 3354 | toExplore.add(l);
|
---|
| 3355 | }
|
---|
| 3356 | }
|
---|
| 3357 | otherEnd.appendPath(visited, points, addToEnd, toExplore);
|
---|
| 3358 | }
|
---|
| 3359 | }
|
---|
| 3360 | }
|
---|
| 3361 |
|
---|
| 3362 | /**
|
---|
[108] | 3363 | * Gets the size of the enclosure that this item is part of. Used to
|
---|
| 3364 | * determine the paint order of items, with smaller items being painted
|
---|
| 3365 | * first.
|
---|
| 3366 | *
|
---|
| 3367 | * @return the area of the box surrounding the enclosed shape that this item
|
---|
| 3368 | * is part of
|
---|
[105] | 3369 | */
|
---|
[1102] | 3370 | public double getEnclosedArea()
|
---|
| 3371 | {
|
---|
| 3372 | AxisAlignedBoxBounds box = getEnclosedBox();
|
---|
| 3373 | if (box == null) return 0.0;
|
---|
[108] | 3374 | return box.getWidth() * box.getHeight();
|
---|
[105] | 3375 | }
|
---|
[133] | 3376 |
|
---|
[1102] | 3377 | /**
|
---|
| 3378 | * Gets the box encompassing all points that form an enclosure with this item.
|
---|
| 3379 | *
|
---|
| 3380 | * @return An axis-aligned box around all enclosure points.
|
---|
| 3381 | */
|
---|
| 3382 | public AxisAlignedBoxBounds getEnclosedBox()
|
---|
| 3383 | {
|
---|
| 3384 | if (_enclosure == null) return null;
|
---|
| 3385 |
|
---|
| 3386 | return AxisAlignedBoxBounds.getEnclosing(getEnclosedShape());
|
---|
[242] | 3387 | }
|
---|
| 3388 |
|
---|
[1102] | 3389 | public int getEnclosureID()
|
---|
| 3390 | {
|
---|
[133] | 3391 | return _enclosure == null ? 0 : _enclosure.hashCode();
|
---|
[131] | 3392 | }
|
---|
[108] | 3393 |
|
---|
| 3394 | /**
|
---|
[1102] | 3395 | * Returns the Bounds that surrounds this Item representing this Item's
|
---|
[108] | 3396 | * 'gravity'.
|
---|
| 3397 | *
|
---|
[1102] | 3398 | * @return The Bounds surrounding this Item, which represents
|
---|
[108] | 3399 | * this Items 'gravity'.
|
---|
| 3400 | */
|
---|
[1102] | 3401 | public final Bounds getBounds()
|
---|
| 3402 | {
|
---|
| 3403 | if (_bounds == null) _bounds = updateBounds();
|
---|
| 3404 |
|
---|
| 3405 | // DEBUG
|
---|
| 3406 | if (_bounds == null) {
|
---|
| 3407 | //System.out.println("updateBounds failed!");
|
---|
| 3408 | }
|
---|
[108] | 3409 |
|
---|
[1102] | 3410 | return _bounds;
|
---|
[108] | 3411 | }
|
---|
[1102] | 3412 |
|
---|
| 3413 | public final Bounds getOldBounds()
|
---|
| 3414 | {
|
---|
| 3415 | return _oldBounds;
|
---|
| 3416 | }
|
---|
| 3417 |
|
---|
| 3418 | public final void invalidateBounds()
|
---|
| 3419 | {
|
---|
| 3420 | if (_bounds != null) _oldBounds = _bounds;
|
---|
| 3421 | _bounds = null;
|
---|
[1466] | 3422 | for (Item surrogate: this.getSurrogates()) {
|
---|
| 3423 | surrogate.invalidateBounds();
|
---|
| 3424 | }
|
---|
[1102] | 3425 | }
|
---|
| 3426 |
|
---|
| 3427 | public final AxisAlignedBoxBounds getBoundingBox()
|
---|
| 3428 | {
|
---|
| 3429 | return AxisAlignedBoxBounds.getEnclosing(getBounds());
|
---|
| 3430 | }
|
---|
[108] | 3431 |
|
---|
| 3432 | /**
|
---|
| 3433 | * Shifts the position of the item along the line between this items
|
---|
| 3434 | * location and a specified point.
|
---|
| 3435 | *
|
---|
| 3436 | * @param origin
|
---|
| 3437 | * @param ratio
|
---|
| 3438 | */
|
---|
[1102] | 3439 | public void translate(Point origin, double ratio) {
|
---|
[124] | 3440 |
|
---|
[121] | 3441 | invalidateCommonTraitForAll(ItemAppearence.PreMoved);
|
---|
[124] | 3442 |
|
---|
[1143] | 3443 | _x = (float) (origin.getX() + ratio * (_x - origin.getX()));
|
---|
| 3444 | _y = (float) (origin.getY() + ratio * (_y - origin.getY()));
|
---|
[1102] | 3445 | invalidateBounds();
|
---|
[108] | 3446 | for (Line line : getLines())
|
---|
[1102] | 3447 | line.invalidateBounds();
|
---|
[124] | 3448 |
|
---|
[121] | 3449 | invalidateCommonTraitForAll(ItemAppearence.PostMoved);
|
---|
[124] | 3450 |
|
---|
[108] | 3451 | }
|
---|
| 3452 |
|
---|
| 3453 | private static int[] LinePatterns = new int[] { 0, 10, 20 };
|
---|
| 3454 |
|
---|
| 3455 | /**
|
---|
| 3456 | * The rotates through a wheel of dashed lines.
|
---|
| 3457 | *
|
---|
| 3458 | * @param amount
|
---|
| 3459 | * number of rotations around the wheel to toggle by.
|
---|
| 3460 | */
|
---|
| 3461 | public void toggleDashed(int amount) {
|
---|
| 3462 | // find the index of the current line pattern
|
---|
| 3463 | int[] currentPattern = getLinePattern();
|
---|
| 3464 |
|
---|
| 3465 | // Find the current pattern and move to the next pattern in the wheel
|
---|
| 3466 | for (int i = 0; i < LinePatterns.length; i++) {
|
---|
| 3467 | if (currentPattern == null || currentPattern[0] == LinePatterns[i]) {
|
---|
| 3468 | i += LinePatterns.length + amount;
|
---|
| 3469 | i %= LinePatterns.length;
|
---|
| 3470 |
|
---|
| 3471 | // if we are at the start of the wheel make it 'null' (solid
|
---|
| 3472 | // line)
|
---|
| 3473 | if (i == 0) {
|
---|
| 3474 | setLinePattern(null);
|
---|
| 3475 | } else {
|
---|
| 3476 | setLinePattern(new int[] { LinePatterns[i], LinePatterns[i] });
|
---|
| 3477 | }
|
---|
[124] | 3478 |
|
---|
[121] | 3479 | invalidateCommonTrait(ItemAppearence.ToggleDashed);
|
---|
[108] | 3480 | return;
|
---|
| 3481 | }
|
---|
| 3482 | }
|
---|
[124] | 3483 |
|
---|
[108] | 3484 | }
|
---|
| 3485 |
|
---|
| 3486 | /**
|
---|
| 3487 | * For now there can only be one enclosure per item
|
---|
[116] | 3488 | *
|
---|
[108] | 3489 | * @param enclosure
|
---|
| 3490 | */
|
---|
| 3491 | public void addEnclosure(XRayable enclosure) {
|
---|
| 3492 | _enclosures.clear();
|
---|
| 3493 | _enclosures.add(enclosure);
|
---|
| 3494 | }
|
---|
| 3495 |
|
---|
[247] | 3496 | /**
|
---|
| 3497 | * Gets any XRayable items that have this item as a source.
|
---|
| 3498 | *
|
---|
| 3499 | * @return the collection of items that are linked to this item as source.
|
---|
[812] | 3500 | * Guaranteed not to be null.
|
---|
[247] | 3501 | */
|
---|
[108] | 3502 | public Collection<? extends XRayable> getEnclosures() {
|
---|
| 3503 | return _enclosures;
|
---|
| 3504 | }
|
---|
| 3505 |
|
---|
| 3506 | public void removeEnclosure(Item i) {
|
---|
| 3507 | _enclosures.remove(i);
|
---|
| 3508 |
|
---|
| 3509 | }
|
---|
| 3510 |
|
---|
| 3511 | public boolean isDeleted() {
|
---|
| 3512 | return _deleted;
|
---|
| 3513 | }
|
---|
[124] | 3514 |
|
---|
[121] | 3515 | /**
|
---|
[124] | 3516 | * @return The full canvas that this item draws to. Must include
|
---|
| 3517 | * highlighting bounds
|
---|
[121] | 3518 | */
|
---|
[1102] | 3519 | public AxisAlignedBoxBounds getDrawingArea() {
|
---|
[124] | 3520 |
|
---|
[1190] | 3521 | final AxisAlignedBoxBounds boundingBox = getBoundingBox();
|
---|
[1102] | 3522 | return ItemUtils.expandRectangle(
|
---|
[1190] | 3523 | boundingBox,
|
---|
[1102] | 3524 | (int) Math.ceil(Math.max(_highlightThickness, getThickness())) + 1 // + 1 to make sure
|
---|
| 3525 | );
|
---|
[121] | 3526 | }
|
---|
[124] | 3527 |
|
---|
[121] | 3528 | /**
|
---|
| 3529 | *
|
---|
| 3530 | * @param area
|
---|
| 3531 | * @return True if area intersects with this items drawing area.
|
---|
| 3532 | */
|
---|
[1102] | 3533 | public final boolean isInDrawingArea(AxisAlignedBoxBounds area)
|
---|
| 3534 | {
|
---|
| 3535 | AxisAlignedBoxBounds drawingArea = getDrawingArea();
|
---|
| 3536 |
|
---|
| 3537 | if (drawingArea == null) return false;
|
---|
| 3538 |
|
---|
| 3539 | return drawingArea.intersects(area);
|
---|
[121] | 3540 | }
|
---|
[124] | 3541 |
|
---|
[121] | 3542 | /**
|
---|
[1102] | 3543 | * Completely invalidates the item - so that it should be redrawn. Note:
|
---|
| 3544 | * This is handled internally, it should be rare to invoke this externally
|
---|
[121] | 3545 | */
|
---|
[1102] | 3546 | public final void invalidateAll()
|
---|
| 3547 | {
|
---|
[121] | 3548 | invalidate(getDrawingArea());
|
---|
| 3549 | }
|
---|
[124] | 3550 |
|
---|
[121] | 3551 | /**
|
---|
[124] | 3552 | * Invalidates areas on the parent frame. Purpose: to be called on specific
|
---|
| 3553 | * areas of the item that needs redrawing.
|
---|
| 3554 | *
|
---|
[121] | 3555 | * @param damagedAreas
|
---|
| 3556 | */
|
---|
[1102] | 3557 | protected final void invalidate(Bounds[] damagedAreas)
|
---|
| 3558 | {
|
---|
| 3559 | if (damagedAreas != null) for (Bounds b : damagedAreas) invalidate(b);
|
---|
[121] | 3560 | }
|
---|
[124] | 3561 |
|
---|
[121] | 3562 | /**
|
---|
[124] | 3563 | * Invalidates areas on the parent frame. Purpose: to be called on specific
|
---|
| 3564 | * areas of the item that needs redrawing.
|
---|
| 3565 | *
|
---|
[121] | 3566 | * @param damagedAreas
|
---|
| 3567 | */
|
---|
[1102] | 3568 | protected final void invalidate(Bounds damagedArea)
|
---|
| 3569 | {
|
---|
| 3570 | if (damagedArea != null) DisplayController.invalidateItem(this, damagedArea);
|
---|
[121] | 3571 | }
|
---|
[124] | 3572 |
|
---|
[121] | 3573 | /**
|
---|
| 3574 | * Used to invalidate visual traits commonly shared by all items.
|
---|
[124] | 3575 | *
|
---|
[121] | 3576 | * @param trait
|
---|
| 3577 | */
|
---|
[1102] | 3578 | public final void invalidateCommonTrait(ItemAppearence trait)
|
---|
| 3579 | {
|
---|
[121] | 3580 | invalidate(getDamagedArea(trait));
|
---|
[124] | 3581 |
|
---|
[1102] | 3582 | if (_fillColour != null && (trait == ItemAppearence.Added || trait == ItemAppearence.Removed)) {
|
---|
[121] | 3583 | invalidateFill();
|
---|
| 3584 | }
|
---|
| 3585 | }
|
---|
[124] | 3586 |
|
---|
[121] | 3587 | /**
|
---|
| 3588 | * Invalidates fill if has one, even if no color is set.
|
---|
| 3589 | */
|
---|
[1102] | 3590 | public void invalidateFill()
|
---|
| 3591 | {
|
---|
[121] | 3592 | if (isLineEnd() && _enclosure != null) {
|
---|
[1102] | 3593 | invalidate(getEnclosedBox());
|
---|
[121] | 3594 | }
|
---|
| 3595 | }
|
---|
[124] | 3596 |
|
---|
[121] | 3597 | /**
|
---|
[124] | 3598 | * Default implementation always uses drawing area except for links, where
|
---|
| 3599 | * the link drawing area is used. Override to make item drawing more
|
---|
| 3600 | * efficient - defining only parts of the item that needs redrawing.
|
---|
[121] | 3601 | *
|
---|
| 3602 | * @see Item.getDrawingArea
|
---|
| 3603 | *
|
---|
[124] | 3604 | * @param trait
|
---|
| 3605 | * The visual trait that has changed.
|
---|
[121] | 3606 | *
|
---|
| 3607 | * @return The damaged area according to the visual trait that has changed.
|
---|
| 3608 | */
|
---|
[1102] | 3609 | protected AxisAlignedBoxBounds getDamagedArea(ItemAppearence trait)
|
---|
| 3610 | {
|
---|
[124] | 3611 | if (trait == ItemAppearence.LinkChanged)
|
---|
[1102] | 3612 | return getLinkDrawArea(); // Invalidate area where link is drawn
|
---|
[124] | 3613 |
|
---|
[121] | 3614 | return getDrawingArea();
|
---|
| 3615 | }
|
---|
| 3616 |
|
---|
[116] | 3617 | public boolean hasVector() {
|
---|
| 3618 | return _overlay instanceof Vector;
|
---|
| 3619 | }
|
---|
[124] | 3620 |
|
---|
[116] | 3621 | public boolean hasOverlay() {
|
---|
| 3622 | return _overlay != null;
|
---|
| 3623 | }
|
---|
| 3624 |
|
---|
| 3625 | public Vector getVector() {
|
---|
| 3626 | if (_overlay instanceof Vector)
|
---|
| 3627 | return (Vector) _overlay;
|
---|
| 3628 | return null;
|
---|
| 3629 | }
|
---|
| 3630 |
|
---|
| 3631 | public void setOverlay(Overlay overlay) {
|
---|
| 3632 | _overlay = overlay;
|
---|
| 3633 | }
|
---|
[121] | 3634 |
|
---|
[143] | 3635 | public boolean dontSave() {
|
---|
[427] | 3636 | /*
|
---|
| 3637 | * TODO Mike says: checkout if the ID check is still needed- When will
|
---|
| 3638 | * ID still be -1 when saving a frame? assert (i != null);
|
---|
| 3639 | */
|
---|
[632] | 3640 | // make it save stuff that's off the screen so stuff isn't deleted by panning - jts21
|
---|
| 3641 | return !_save || !isVisible() || getID() < 0; // || offScreenTopOrLeft();
|
---|
[143] | 3642 | }
|
---|
[147] | 3643 |
|
---|
[1413] | 3644 | public void setAnchorLeft(Integer anchor) {
|
---|
[1102] | 3645 | this._anchoring.setLeftAnchor(anchor);
|
---|
[720] | 3646 | if (anchor != null) {
|
---|
[812] | 3647 | anchorConstraints();
|
---|
[720] | 3648 | setX(anchor);
|
---|
| 3649 | }
|
---|
[1413] | 3650 |
|
---|
| 3651 | if (isSurrogate()) {
|
---|
| 3652 | surrogatePropertyInheritance.put(DefaultFrameWriter.ANCHOR_LEFT_STR, false);
|
---|
[1414] | 3653 | Item primary = getPrimary();
|
---|
[1413] | 3654 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.ANCHOR_LEFT_STR)) {
|
---|
[1415] | 3655 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 3656 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.ANCHOR_LEFT_STR, inheritanceCheckOnSave);
|
---|
[1413] | 3657 | }
|
---|
| 3658 | }
|
---|
[720] | 3659 | }
|
---|
| 3660 |
|
---|
[1413] | 3661 | public void setAnchorRight(Integer anchor) {
|
---|
[1102] | 3662 | this._anchoring.setRightAnchor(anchor);
|
---|
[812] | 3663 | if (anchor != null) {
|
---|
| 3664 | anchorConstraints();
|
---|
[1511] | 3665 | int width = Math.abs(getBoundsWidth());
|
---|
| 3666 | //System.err.println("Item::setAnchorRight::Text Content= " + getText() + "; width=" + width);
|
---|
| 3667 | setX(DisplayController.getFramePaintArea().getMaxX() - anchor - width);
|
---|
[812] | 3668 | }
|
---|
[1413] | 3669 |
|
---|
| 3670 | if (isSurrogate()) {
|
---|
| 3671 | surrogatePropertyInheritance.put(DefaultFrameWriter.ANCHOR_RIGHT_STR, false);
|
---|
[1414] | 3672 | Item primary = getPrimary();
|
---|
[1413] | 3673 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.ANCHOR_RIGHT_STR)) {
|
---|
[1415] | 3674 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 3675 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.ANCHOR_RIGHT_STR, inheritanceCheckOnSave);
|
---|
[1413] | 3676 | }
|
---|
| 3677 | }
|
---|
[147] | 3678 | }
|
---|
| 3679 |
|
---|
[1413] | 3680 | public void setAnchorTop(Integer anchor) {
|
---|
[1102] | 3681 | this._anchoring.setTopAnchor(anchor);
|
---|
[812] | 3682 | if (anchor != null) {
|
---|
| 3683 | anchorConstraints();
|
---|
[720] | 3684 | setY(anchor);
|
---|
[812] | 3685 | }
|
---|
[1413] | 3686 |
|
---|
| 3687 | if (isSurrogate()) {
|
---|
| 3688 | surrogatePropertyInheritance.put(DefaultFrameWriter.ANCHOR_TOP_STR, false);
|
---|
[1414] | 3689 | Item primary = getPrimary();
|
---|
[1413] | 3690 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.ANCHOR_TOP_STR)) {
|
---|
[1415] | 3691 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 3692 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.ANCHOR_TOP_STR, inheritanceCheckOnSave);
|
---|
[1413] | 3693 | }
|
---|
| 3694 | }
|
---|
[147] | 3695 | }
|
---|
| 3696 |
|
---|
[720] | 3697 |
|
---|
[1413] | 3698 | public void setAnchorBottom(Integer anchor) {
|
---|
[1102] | 3699 | this._anchoring.setBottomAnchor(anchor);
|
---|
[812] | 3700 | if (anchor != null) {
|
---|
| 3701 | anchorConstraints();
|
---|
[1102] | 3702 | setY(DisplayController.getFramePaintArea().getMaxY() - anchor);
|
---|
[812] | 3703 | }
|
---|
[1413] | 3704 |
|
---|
| 3705 | if (isSurrogate()) {
|
---|
| 3706 | surrogatePropertyInheritance.put(DefaultFrameWriter.ANCHOR_BOTTOM_STR, false);
|
---|
[1414] | 3707 | Item primary = getPrimary();
|
---|
[1413] | 3708 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.ANCHOR_BOTTOM_STR)) {
|
---|
[1415] | 3709 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 3710 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.ANCHOR_BOTTOM_STR, inheritanceCheckOnSave);
|
---|
[1413] | 3711 | }
|
---|
| 3712 | }
|
---|
[147] | 3713 | }
|
---|
| 3714 |
|
---|
[1102] | 3715 | public boolean isAnchored()
|
---|
| 3716 | {
|
---|
| 3717 | return _anchoring.isAnchored();
|
---|
[774] | 3718 | }
|
---|
| 3719 |
|
---|
[805] | 3720 | public boolean isAnchoredX() {
|
---|
[1102] | 3721 | return _anchoring.isXAnchored();
|
---|
[805] | 3722 | }
|
---|
| 3723 |
|
---|
| 3724 | public boolean isAnchoredY() {
|
---|
[1102] | 3725 | return _anchoring.isYAnchored();
|
---|
[805] | 3726 | }
|
---|
| 3727 |
|
---|
[1102] | 3728 | public Integer getAnchorLeft() {
|
---|
[1413] | 3729 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.ANCHOR_LEFT_STR)) {
|
---|
[1414] | 3730 | return this.getPrimary().getAnchorLeft();
|
---|
[1410] | 3731 | } else {
|
---|
| 3732 | return _anchoring.getLeftAnchor();
|
---|
| 3733 | }
|
---|
[720] | 3734 | }
|
---|
| 3735 |
|
---|
[1102] | 3736 | public Integer getAnchorRight() {
|
---|
[1413] | 3737 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.ANCHOR_RIGHT_STR)) {
|
---|
[1414] | 3738 | return this.getPrimary().getAnchorRight();
|
---|
[1410] | 3739 | } else {
|
---|
| 3740 | return _anchoring.getRightAnchor();
|
---|
| 3741 | }
|
---|
[720] | 3742 | }
|
---|
| 3743 |
|
---|
[1102] | 3744 | public Integer getAnchorTop() {
|
---|
[1413] | 3745 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.ANCHOR_TOP_STR)) {
|
---|
[1414] | 3746 | return this.getPrimary().getAnchorTop();
|
---|
[1410] | 3747 | } else {
|
---|
| 3748 | return _anchoring.getTopAnchor();
|
---|
| 3749 | }
|
---|
[720] | 3750 | }
|
---|
| 3751 |
|
---|
[1102] | 3752 | public Integer getAnchorBottom() {
|
---|
[1413] | 3753 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.ANCHOR_BOTTOM_STR)) {
|
---|
[1414] | 3754 | return this.getPrimary().getAnchorBottom();
|
---|
[1410] | 3755 | } else {
|
---|
| 3756 | return _anchoring.getBottomAnchor();
|
---|
| 3757 | }
|
---|
[147] | 3758 | }
|
---|
[181] | 3759 |
|
---|
[156] | 3760 | public String getText() {
|
---|
[1413] | 3761 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.TEXT_STR)) {
|
---|
[1414] | 3762 | return this.getPrimary().getText();
|
---|
[1410] | 3763 | } else {
|
---|
| 3764 | return "@" + getClass().getSimpleName() + ":" + getID();
|
---|
| 3765 | }
|
---|
[156] | 3766 | }
|
---|
[181] | 3767 |
|
---|
[176] | 3768 | public void setText(String text) {
|
---|
| 3769 | }
|
---|
[214] | 3770 |
|
---|
[190] | 3771 | public boolean recalculateWhenChanged() {
|
---|
| 3772 | return false;
|
---|
| 3773 | }
|
---|
[196] | 3774 |
|
---|
[294] | 3775 | public boolean update() {
|
---|
| 3776 | return calculate(getText());
|
---|
[196] | 3777 | }
|
---|
[214] | 3778 |
|
---|
| 3779 | public Collection<Item> getEnclosedItems() {
|
---|
| 3780 | return FrameUtils.getItemsEnclosedBy(this.getParentOrCurrentFrame(),
|
---|
| 3781 | this.getEnclosedShape());
|
---|
| 3782 | }
|
---|
| 3783 |
|
---|
| 3784 | public Collection<Text> getEnclosedNonAnnotationText() {
|
---|
| 3785 | Collection<Text> items = new LinkedHashSet<Text>();
|
---|
| 3786 | for (Item t : getEnclosedItems()) {
|
---|
| 3787 | if (t instanceof Text && !t.isAnnotation())
|
---|
| 3788 | items.add((Text) t);
|
---|
| 3789 | }
|
---|
| 3790 |
|
---|
| 3791 | return items;
|
---|
| 3792 | }
|
---|
| 3793 |
|
---|
| 3794 | public void dispose() {
|
---|
| 3795 | setParent(null);
|
---|
| 3796 | }
|
---|
| 3797 |
|
---|
| 3798 | /**
|
---|
| 3799 | * @return
|
---|
| 3800 | */
|
---|
| 3801 | protected boolean hasVisibleBorder() {
|
---|
[427] | 3802 | return getThickness() > 0 && !isLineEnd() && getBorderColor() != null;
|
---|
[214] | 3803 | }
|
---|
[238] | 3804 |
|
---|
| 3805 | public Frame getChild() {
|
---|
| 3806 | String childName = getAbsoluteLink();
|
---|
| 3807 | if (childName != null) {
|
---|
| 3808 | return FrameIO.LoadFrame(childName);
|
---|
| 3809 | }
|
---|
| 3810 | return null;
|
---|
| 3811 | }
|
---|
[282] | 3812 |
|
---|
| 3813 | public boolean hasLink() {
|
---|
| 3814 | return _link != null;
|
---|
| 3815 | }
|
---|
| 3816 |
|
---|
[812] | 3817 | protected void anchorConnectedOLD(AnchorEdgeType anchorEdgeType, Float delta) {
|
---|
[282] | 3818 | // Check for a more efficient way to do this!!
|
---|
| 3819 | // Invalidate all the items
|
---|
| 3820 | for (Item i : this.getAllConnected()) {
|
---|
| 3821 | i.invalidateAll();
|
---|
| 3822 | }
|
---|
| 3823 | // Move the items
|
---|
| 3824 | for (Item i : this.getAllConnected()) {
|
---|
| 3825 | if (i.isLineEnd()) {
|
---|
[720] | 3826 | if (delta != null) {
|
---|
| 3827 | if ((anchorEdgeType == AnchorEdgeType.Left) || (anchorEdgeType == AnchorEdgeType.Right)) {
|
---|
| 3828 | // 'delta' encodes a horizontal (x) move
|
---|
| 3829 | if (anchorEdgeType == AnchorEdgeType.Left) {
|
---|
| 3830 | i.setAnchorLeft(null);
|
---|
| 3831 | }
|
---|
| 3832 | else {
|
---|
| 3833 | // must be Right
|
---|
| 3834 | i.setAnchorRight(null);
|
---|
| 3835 | }
|
---|
| 3836 |
|
---|
| 3837 | i.setXY(i.getX() + delta, i.getY());
|
---|
| 3838 | }
|
---|
| 3839 | if ((anchorEdgeType == AnchorEdgeType.Top) || (anchorEdgeType == AnchorEdgeType.Bottom)) {
|
---|
| 3840 | // 'delta; encodes a vertical (y) move
|
---|
| 3841 | if (anchorEdgeType == AnchorEdgeType.Top) {
|
---|
| 3842 | i.setAnchorTop(null);
|
---|
| 3843 | }
|
---|
| 3844 | else {
|
---|
| 3845 | // must be Bottom
|
---|
| 3846 | i.setAnchorBottom(null);
|
---|
| 3847 | }
|
---|
| 3848 | i.setXY(i.getX(), i.getY() + delta);
|
---|
| 3849 | }
|
---|
| 3850 |
|
---|
[282] | 3851 | }
|
---|
[720] | 3852 | }
|
---|
| 3853 | }
|
---|
| 3854 | // Invalidate them again!!
|
---|
| 3855 | for (Item i : this.getAllConnected()) {
|
---|
[1102] | 3856 | i.invalidateBounds();
|
---|
[720] | 3857 | i.invalidateAll();
|
---|
| 3858 | }
|
---|
| 3859 | }
|
---|
| 3860 |
|
---|
| 3861 | protected void anchorConnected(AnchorEdgeType anchorEdgeType, Float delta) {
|
---|
[812] | 3862 |
|
---|
[720] | 3863 | // Check for a more efficient way to do this!!
|
---|
| 3864 | // Invalidate all the items
|
---|
| 3865 | for (Item i : this.getAllConnected()) {
|
---|
| 3866 | i.invalidateAll();
|
---|
| 3867 | }
|
---|
| 3868 |
|
---|
| 3869 | // Move the items
|
---|
| 3870 | for (Item i : this.getAllConnected()) {
|
---|
| 3871 | if (i.isLineEnd()) {
|
---|
| 3872 | if (delta != null) {
|
---|
| 3873 | if ((anchorEdgeType == AnchorEdgeType.Left) || (anchorEdgeType == AnchorEdgeType.Right)) {
|
---|
| 3874 | // 'delta' encodes a horizontal (x) move
|
---|
| 3875 | if (anchorEdgeType == AnchorEdgeType.Left) {
|
---|
| 3876 | // Processing a Left anchor
|
---|
| 3877 | // => Anything connected that is *not* anchored to the right should be moved by 'delta'
|
---|
| 3878 | if (i.getAnchorRight()==null) {
|
---|
| 3879 | i.setXY(i.getX() + delta, i.getY());
|
---|
| 3880 | }
|
---|
| 3881 | }
|
---|
| 3882 | else {
|
---|
| 3883 | // Processing a Right anchor
|
---|
| 3884 | // => Anything connected that is *not* anchored to the left should be moved by 'delta'
|
---|
| 3885 | if (i.getAnchorLeft()==null) {
|
---|
| 3886 | i.setXY(i.getX() + delta, i.getY());
|
---|
| 3887 | }
|
---|
| 3888 | }
|
---|
| 3889 |
|
---|
| 3890 | }
|
---|
| 3891 | if ((anchorEdgeType == AnchorEdgeType.Top) || (anchorEdgeType == AnchorEdgeType.Bottom)) {
|
---|
| 3892 | // 'delta; encodes a vertical (y) move
|
---|
| 3893 | if (anchorEdgeType == AnchorEdgeType.Top) {
|
---|
| 3894 | // Processing a Top anchor
|
---|
| 3895 | // => Anything connected that is *not* anchored to the bottom should be moved by 'delta'
|
---|
| 3896 | if (i.getAnchorBottom()==null) {
|
---|
| 3897 | i.setXY(i.getX(), i.getY() + delta);
|
---|
| 3898 | }
|
---|
| 3899 | }
|
---|
| 3900 | else {
|
---|
| 3901 | // Processing a Bottom anchor
|
---|
| 3902 | // => Anything connected that is *not* anchored to the top should be moved by 'delta'
|
---|
| 3903 | if (i.getAnchorTop()==null) {
|
---|
[798] | 3904 | // must be Bottom
|
---|
| 3905 | //i.setAnchorBottom(null);
|
---|
| 3906 | i.setXY(i.getX(), i.getY() + delta);
|
---|
[720] | 3907 | }
|
---|
| 3908 | }
|
---|
| 3909 | }
|
---|
[282] | 3910 | }
|
---|
| 3911 | }
|
---|
| 3912 | }
|
---|
[720] | 3913 |
|
---|
[812] | 3914 | anchorConstraints();
|
---|
| 3915 |
|
---|
[282] | 3916 | // Invalidate them again!!
|
---|
| 3917 | for (Item i : this.getAllConnected()) {
|
---|
[1102] | 3918 | i.invalidateBounds();
|
---|
[282] | 3919 | i.invalidateAll();
|
---|
| 3920 | }
|
---|
| 3921 | }
|
---|
[286] | 3922 | /**
|
---|
[427] | 3923 | * Sets the item to pickup when the user attempts to pick this item up.
|
---|
[286] | 3924 | * EditTarget has a value of 'this' by default but may be set to other
|
---|
| 3925 | * values if this item is on a vector.
|
---|
| 3926 | *
|
---|
| 3927 | * @param target
|
---|
| 3928 | * the item to be copied or picked up when the user attempts to
|
---|
| 3929 | * edit this item.
|
---|
| 3930 | */
|
---|
| 3931 | public void setEditTarget(Item target) {
|
---|
| 3932 | _editTarget = target;
|
---|
| 3933 | }
|
---|
| 3934 |
|
---|
[427] | 3935 | /**
|
---|
| 3936 | * Gets the item to pickup when the user attempts to pick this item up.
|
---|
| 3937 | * EditTarget has a value of 'this' by default but may be set to other
|
---|
| 3938 | * values if this item is on a vector.
|
---|
| 3939 | */
|
---|
[286] | 3940 | public Item getEditTarget() {
|
---|
| 3941 | return _editTarget;
|
---|
| 3942 | }
|
---|
[311] | 3943 |
|
---|
| 3944 | public void scale(Float scale, int originX, int originY) {
|
---|
[851] | 3945 | setXY((getX() - originX) * scale + originX, (getY() - originY) * scale + originY);
|
---|
[311] | 3946 | setArrowheadLength(getArrowheadLength() * scale);
|
---|
| 3947 |
|
---|
| 3948 | float thickness = getThickness();
|
---|
| 3949 | if (thickness > 0)
|
---|
| 3950 | setThickness(thickness * scale, false);
|
---|
| 3951 |
|
---|
| 3952 | // DONT PUT SIZE IN HERE CAUSE IT STUFFS UP CIRCLES
|
---|
| 3953 |
|
---|
[1102] | 3954 | invalidateBounds();
|
---|
[311] | 3955 | }
|
---|
[376] | 3956 |
|
---|
| 3957 | protected boolean isVectorItem() {
|
---|
| 3958 | return _editTarget != this;
|
---|
| 3959 | }
|
---|
| 3960 |
|
---|
| 3961 | public AttributeValuePair getAttributeValuePair() {
|
---|
[410] | 3962 | if (_attributeValuePair == null) {
|
---|
[376] | 3963 | _attributeValuePair = new AttributeValuePair(getText());
|
---|
| 3964 | }
|
---|
| 3965 | return _attributeValuePair;
|
---|
| 3966 | }
|
---|
| 3967 |
|
---|
[410] | 3968 | /*
|
---|
| 3969 | * private static Set<Object> _locks = new HashSet<Object>();
|
---|
| 3970 | *
|
---|
| 3971 | * public static void lock(Object itemToLock) { _locks.add(itemToLock); }
|
---|
| 3972 | *
|
---|
| 3973 | * public static void unlock(Object itemToUnlock) {
|
---|
| 3974 | * _locks.remove(itemToUnlock); }
|
---|
| 3975 | *
|
---|
| 3976 | * public static boolean isLocked(Object item) { return
|
---|
| 3977 | * _locks.contains(item); }
|
---|
| 3978 | */
|
---|
[376] | 3979 |
|
---|
[427] | 3980 | public void setSave(boolean state) {
|
---|
| 3981 | _save = state;
|
---|
| 3982 | }
|
---|
| 3983 |
|
---|
| 3984 | public boolean getSave() {
|
---|
| 3985 | return _save;
|
---|
| 3986 | }
|
---|
| 3987 |
|
---|
| 3988 | public void setAutoStamp(Float rate) {
|
---|
| 3989 | _autoStamp = rate;
|
---|
| 3990 | }
|
---|
| 3991 |
|
---|
| 3992 | public Float getAutoStamp() {
|
---|
| 3993 | return _autoStamp;
|
---|
| 3994 | }
|
---|
| 3995 |
|
---|
| 3996 | public boolean isAutoStamp() {
|
---|
| 3997 | return _autoStamp != null && _autoStamp >= 0.0;
|
---|
| 3998 | }
|
---|
[906] | 3999 |
|
---|
| 4000 | public int getMagnetizedItemLeft() {
|
---|
[1413] | 4001 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.MAGNETIZED_ITEM_LEFT_STR)) {
|
---|
[1414] | 4002 | return this.getPrimary().getMagnetizedItemLeft();
|
---|
[1410] | 4003 | } else {
|
---|
| 4004 | if(_magnetizedItemLeft != null) return _magnetizedItemLeft.getID();
|
---|
| 4005 | else return -1;
|
---|
| 4006 | }
|
---|
[906] | 4007 | }
|
---|
| 4008 |
|
---|
| 4009 | public void setMagnetizedItemLeft(final Item item) {
|
---|
| 4010 | _magnetizedItemLeft = item;
|
---|
| 4011 | }
|
---|
| 4012 |
|
---|
| 4013 | public void setMagnetizedItemLeft(final int id) {
|
---|
| 4014 | setMagnetizedItemLeft(this.getParent().getItemWithID(id));
|
---|
[1413] | 4015 |
|
---|
| 4016 | if (isSurrogate()) {
|
---|
| 4017 | surrogatePropertyInheritance.put(DefaultFrameWriter.MAGNETIZED_ITEM_LEFT_STR, false);
|
---|
[1414] | 4018 | Item primary = getPrimary();
|
---|
[1413] | 4019 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.MAGNETIZED_ITEM_LEFT_STR)) {
|
---|
[1415] | 4020 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 4021 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.MAGNETIZED_ITEM_LEFT_STR, inheritanceCheckOnSave);
|
---|
[1413] | 4022 | }
|
---|
| 4023 | }
|
---|
[906] | 4024 | }
|
---|
| 4025 |
|
---|
| 4026 | public int getMagnetizedItemRight() {
|
---|
[1413] | 4027 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.MAGNETIZED_ITEM_RIGHT_STR)) {
|
---|
[1414] | 4028 | return this.getPrimary().getMagnetizedItemRight();
|
---|
[1410] | 4029 | } else {
|
---|
| 4030 | if(_magnetizedItemRight != null) return _magnetizedItemRight.getID();
|
---|
| 4031 | else return -1;
|
---|
| 4032 | }
|
---|
[906] | 4033 | }
|
---|
| 4034 |
|
---|
| 4035 | public void setMagnetizedItemRight(final Item item) {
|
---|
| 4036 | _magnetizedItemRight = item;
|
---|
| 4037 | }
|
---|
| 4038 |
|
---|
| 4039 | public void setMagnetizedItemRight(final int id) {
|
---|
| 4040 | setMagnetizedItemRight(this.getParent().getItemWithID(id));
|
---|
[1413] | 4041 |
|
---|
| 4042 | if (isSurrogate()) {
|
---|
| 4043 | surrogatePropertyInheritance.put(DefaultFrameWriter.MAGNETIZED_ITEM_RIGHT_STR, false);
|
---|
[1414] | 4044 | Item primary = getPrimary();
|
---|
[1413] | 4045 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.MAGNETIZED_ITEM_RIGHT_STR)) {
|
---|
[1415] | 4046 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 4047 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.MAGNETIZED_ITEM_RIGHT_STR, inheritanceCheckOnSave);
|
---|
[1413] | 4048 | }
|
---|
| 4049 | }
|
---|
[906] | 4050 | }
|
---|
| 4051 |
|
---|
| 4052 | public int getMagnetizedItemTop() {
|
---|
[1413] | 4053 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.MAGNETIZED_ITEM_TOP_STR)) {
|
---|
[1414] | 4054 | return this.getPrimary().getMagnetizedItemTop();
|
---|
[1410] | 4055 | } else {
|
---|
| 4056 | if(_magnetizedItemTop != null) return _magnetizedItemTop.getID();
|
---|
| 4057 | else return -1;
|
---|
| 4058 | }
|
---|
[906] | 4059 | }
|
---|
| 4060 |
|
---|
| 4061 | public void setMagnetizedItemTop(final Item item) {
|
---|
| 4062 | _magnetizedItemTop = item;
|
---|
| 4063 | }
|
---|
| 4064 |
|
---|
| 4065 | public void setMagnetizedItemTop(final int id) {
|
---|
| 4066 | setMagnetizedItemTop(this.getParent().getItemWithID(id));
|
---|
[1413] | 4067 |
|
---|
| 4068 | if (isSurrogate()) {
|
---|
| 4069 | surrogatePropertyInheritance.put(DefaultFrameWriter.MAGNETIZED_ITEM_TOP_STR, false);
|
---|
[1414] | 4070 | Item primary = getPrimary();
|
---|
[1413] | 4071 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.MAGNETIZED_ITEM_TOP_STR)) {
|
---|
[1415] | 4072 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 4073 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.MAGNETIZED_ITEM_TOP_STR, inheritanceCheckOnSave);
|
---|
[1413] | 4074 | }
|
---|
| 4075 | }
|
---|
[906] | 4076 | }
|
---|
| 4077 |
|
---|
| 4078 | public int getMagnetizedItemBottom() {
|
---|
[1413] | 4079 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.MAGNETIZED_ITEM_BOTTOM_STR)) {
|
---|
[1414] | 4080 | return this.getPrimary().getMagnetizedItemBottom();
|
---|
[1410] | 4081 | } else {
|
---|
| 4082 | if(_magnetizedItemBottom != null) return _magnetizedItemBottom.getID();
|
---|
| 4083 | else return -1;
|
---|
| 4084 | }
|
---|
[906] | 4085 | }
|
---|
| 4086 |
|
---|
| 4087 | public void setMagnetizedItemBottom(final Item item) {
|
---|
| 4088 | _magnetizedItemBottom = item;
|
---|
| 4089 | }
|
---|
| 4090 |
|
---|
| 4091 | public void setMagnetizedItemBottom(final int id) {
|
---|
| 4092 | setMagnetizedItemBottom(this.getParent().getItemWithID(id));
|
---|
[1413] | 4093 |
|
---|
| 4094 | if (isSurrogate()) {
|
---|
| 4095 | surrogatePropertyInheritance.put(DefaultFrameWriter.MAGNETIZED_ITEM_BOTTOM_STR, false);
|
---|
[1414] | 4096 | Item primary = getPrimary();
|
---|
[1413] | 4097 | if (subjectToInheritanceCheckOnSave(DefaultFrameWriter.MAGNETIZED_ITEM_BOTTOM_STR)) {
|
---|
[1415] | 4098 | EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);
|
---|
| 4099 | primary.primaryPropertyEncryption.put(DefaultFrameWriter.MAGNETIZED_ITEM_BOTTOM_STR, inheritanceCheckOnSave);
|
---|
[1413] | 4100 | }
|
---|
| 4101 | }
|
---|
[906] | 4102 | }
|
---|
[1398] | 4103 |
|
---|
| 4104 | public String getEncryptionLabel() {
|
---|
[1413] | 4105 | if (isSurrogate() && surrogatePropertyInheritance.get(DefaultFrameWriter.ENCRYPTION_LABEL_STR)) {
|
---|
[1414] | 4106 | return this.getPrimary().getEncryptionLabel();
|
---|
[1410] | 4107 | } else {
|
---|
| 4108 | return _encryptionLabel;
|
---|
| 4109 | }
|
---|
[1398] | 4110 | }
|
---|
[1509] | 4111 |
|
---|
[1398] | 4112 | public void setEncryptionLabel(String label) {
|
---|
[1509] | 4113 | if (label == null) {
|
---|
| 4114 | _encryptionLabel = null;
|
---|
| 4115 | return;
|
---|
| 4116 | }
|
---|
| 4117 |
|
---|
[1505] | 4118 | if (this.getParent().getFrameEncryptionLabel() == null) {
|
---|
[1415] | 4119 | MessageBay.displayMessage("Items can only be entrypted if the frame they are on is.");
|
---|
| 4120 | return;
|
---|
| 4121 | }
|
---|
[1509] | 4122 |
|
---|
[1431] | 4123 | LabelInfo labelResult = Label.getLabel(label);
|
---|
| 4124 | if (!labelResult.is(LabelResult.SuccessResolveLabelToKey)) {
|
---|
[1415] | 4125 | MessageBay.displayMessage(labelResult.toString());
|
---|
| 4126 | return;
|
---|
| 4127 | }
|
---|
| 4128 |
|
---|
[1509] | 4129 | String errorMessage = "You do not have sufficient permissions to set the encryption label to " + label;
|
---|
| 4130 | UserAppliedEncryptionPermission p = getParent().getEncryptionPermission().getPermission(getParent().getOwner(), getParent().getGroupMembers());
|
---|
| 4131 | String homogeneousEncryptionLabel = getParent().getHomogeneousEncryptionLabel();
|
---|
| 4132 | if (homogeneousEncryptionLabel == null) { homogeneousEncryptionLabel = getParent().getFrameEncryptionLabel(); }
|
---|
| 4133 | if (homogeneousEncryptionLabel == null) { homogeneousEncryptionLabel = EncryptedExpWriter.getLabelNone(); }
|
---|
| 4134 | List<String> hetrogeneousFrameOwnerLabels = getParent().getHetrogeneousFrameOwnerLabels();
|
---|
[1427] | 4135 |
|
---|
[1509] | 4136 | switch(p) {
|
---|
| 4137 | case none:
|
---|
| 4138 | MessageBay.errorMessage(errorMessage);
|
---|
| 4139 | return;
|
---|
| 4140 | case homogeneous:
|
---|
| 4141 | if (!homogeneousEncryptionLabel.equals(label)) {
|
---|
| 4142 | MessageBay.errorMessage(errorMessage);
|
---|
| 4143 | return;
|
---|
[1427] | 4144 | }
|
---|
[1509] | 4145 | break;
|
---|
| 4146 | case hetrogeneous_owner:
|
---|
| 4147 | if (!homogeneousEncryptionLabel.equals(label) && !hetrogeneousFrameOwnerLabels.contains(label)) {
|
---|
| 4148 | MessageBay.errorMessage(errorMessage);
|
---|
| 4149 | return;
|
---|
| 4150 | }
|
---|
| 4151 | break;
|
---|
| 4152 | case hetrogeneous: break;
|
---|
[1427] | 4153 | }
|
---|
| 4154 |
|
---|
[1509] | 4155 | this.getSurrogates().clear();
|
---|
| 4156 | this._encryptionLabel = label;
|
---|
| 4157 |
|
---|
| 4158 | //Setup surrogate items.
|
---|
| 4159 | generateSurrogate(labelResult);
|
---|
[1398] | 4160 | }
|
---|
[1415] | 4161 |
|
---|
| 4162 | public void setEncryptionLabelOnLoad(String label) {
|
---|
| 4163 | this._encryptionLabel = label;
|
---|
| 4164 | }
|
---|
[1102] | 4165 |
|
---|
| 4166 | /**
|
---|
| 4167 | * Replaces the given dot item with a text item displaying the given character.
|
---|
| 4168 | *
|
---|
| 4169 | * @param dot
|
---|
| 4170 | * The Dot item to replace.
|
---|
| 4171 | *
|
---|
| 4172 | * @param ch
|
---|
| 4173 | * The character to display as the text for the created Text item.
|
---|
| 4174 | *
|
---|
| 4175 | * @return
|
---|
| 4176 | * The created Text item.
|
---|
| 4177 | */
|
---|
| 4178 | public static Text replaceDot(Item dot, char ch) {
|
---|
| 4179 | // TODO: Should this make sure 'dot' is actually a Dot and not some other item? cts16
|
---|
| 4180 | Text text = Text.createText(ch);
|
---|
| 4181 | Item.DuplicateItem(dot, text);
|
---|
| 4182 | FrameUtils.setLastEdited(text);
|
---|
| 4183 |
|
---|
| 4184 | // Copy the lines list so it can be modified
|
---|
| 4185 | List<Line> lines = new LinkedList<Line>(dot.getLines());
|
---|
| 4186 | for (Line line : lines)
|
---|
| 4187 | line.replaceLineEnd(dot, text);
|
---|
| 4188 | Frame current = dot.getParentOrCurrentFrame();
|
---|
| 4189 | current.removeItem(dot);
|
---|
[1415] | 4190 | ItemUtils.EnclosedCheck(current.getSortedItems());
|
---|
[1102] | 4191 | return text;
|
---|
| 4192 | // TODO: Should this add the newly-created Text item to the frame? cts16
|
---|
| 4193 | }
|
---|
| 4194 |
|
---|
| 4195 | /**
|
---|
| 4196 | * Replaces the given text item with a dot
|
---|
| 4197 | */
|
---|
| 4198 | public static Item replaceText(Item text) {
|
---|
| 4199 | Item dot = new Dot(text.getX(), text.getY(), text.getID());
|
---|
| 4200 | Item.DuplicateItem(text, dot);
|
---|
| 4201 |
|
---|
| 4202 | List<Line> lines = new LinkedList<Line>();
|
---|
| 4203 | lines.addAll(text.getLines());
|
---|
| 4204 | if (lines.size() > 0)
|
---|
| 4205 | dot.setColor(lines.get(0).getColor());
|
---|
| 4206 | for (Line line : lines) {
|
---|
| 4207 | line.replaceLineEnd(text, dot);
|
---|
| 4208 | }
|
---|
| 4209 | text.delete();
|
---|
| 4210 | Frame current = text.getParentOrCurrentFrame();
|
---|
| 4211 | current.addItem(dot);
|
---|
| 4212 | DisplayController.setCursor(Item.DEFAULT_CURSOR);
|
---|
[1415] | 4213 | ItemUtils.EnclosedCheck(current.getSortedItems());
|
---|
[1102] | 4214 | return dot;
|
---|
| 4215 | }
|
---|
[1408] | 4216 |
|
---|
[1413] | 4217 | public Set<Item> getSurrogates() {
|
---|
[1408] | 4218 | return surrogateItems;
|
---|
| 4219 | }
|
---|
| 4220 |
|
---|
[1414] | 4221 | private void setAsSurrogateFor(Item primary) {
|
---|
| 4222 | this.surrogateFor = primary;
|
---|
[1408] | 4223 | }
|
---|
| 4224 |
|
---|
[1413] | 4225 | public void addToSurrogates(Item surrogate) {
|
---|
[1466] | 4226 | if (this.getEncryptionLabel() == null) {
|
---|
| 4227 | MessageBay.displayMessage("Only Items with encryption labels can have surrogates.");
|
---|
| 4228 | return;
|
---|
| 4229 | }
|
---|
| 4230 |
|
---|
[1430] | 4231 | this.getParent().removeItem(surrogate);
|
---|
[1408] | 4232 | this.surrogateItems.add(surrogate);
|
---|
[1413] | 4233 | surrogate.setAsSurrogateFor(this);
|
---|
[1415] | 4234 | this.getParent().addItem(surrogate);
|
---|
[1414] | 4235 |
|
---|
[1415] | 4236 | EncryptionDetail reencryptOnSave = new EncryptionDetail(EncryptionDetail.Type.ReencryptOnSave);
|
---|
| 4237 | EncryptionDetail unencryptedOnSave = new EncryptionDetail(EncryptionDetail.Type.UnencryptedOnSave);
|
---|
| 4238 |
|
---|
[1418] | 4239 | for (Character tag: DefaultFrameWriter.getItemCharTags().keySet()) {
|
---|
[1414] | 4240 | if (tag == 'T') {
|
---|
[1415] | 4241 | primaryPropertyEncryption.put(tag + "", reencryptOnSave.clone());
|
---|
[1414] | 4242 | } else {
|
---|
[1415] | 4243 | primaryPropertyEncryption.put(tag + "", unencryptedOnSave.clone());
|
---|
[1414] | 4244 | }
|
---|
| 4245 |
|
---|
| 4246 | if (tag == 'T' || tag == 'S') {
|
---|
| 4247 | surrogate.surrogatePropertyInheritance.put(tag + "", false);
|
---|
| 4248 | } else {
|
---|
| 4249 | surrogate.surrogatePropertyInheritance.put(tag + "", true);
|
---|
| 4250 | }
|
---|
| 4251 | }
|
---|
| 4252 |
|
---|
[1418] | 4253 | for (String tag: DefaultFrameWriter.getItemStrTags().keySet()) {
|
---|
[1430] | 4254 | primaryPropertyEncryption.put(tag, unencryptedOnSave.clone());
|
---|
[1414] | 4255 | surrogate.surrogatePropertyInheritance.put(tag + "", true);
|
---|
| 4256 | }
|
---|
[1408] | 4257 | }
|
---|
| 4258 |
|
---|
| 4259 | public boolean isSurrogate() {
|
---|
| 4260 | return this.surrogateFor != null;
|
---|
| 4261 | }
|
---|
| 4262 |
|
---|
[1414] | 4263 | public Item getPrimary() {
|
---|
[1408] | 4264 | return this.surrogateFor;
|
---|
| 4265 | }
|
---|
| 4266 |
|
---|
| 4267 | public EncryptionDetail getEncryptionDetailForTag(String tag) {
|
---|
[1414] | 4268 | EncryptionDetail encryptionDetail = primaryPropertyEncryption.get(tag);
|
---|
[1408] | 4269 |
|
---|
| 4270 | if (encryptionDetail == null) {
|
---|
[1415] | 4271 | EncryptionDetail unencryptedOnSave = new EncryptionDetail(EncryptionDetail.Type.UnencryptedOnSave);
|
---|
| 4272 | return unencryptedOnSave;
|
---|
[1408] | 4273 | } else {
|
---|
| 4274 | return encryptionDetail;
|
---|
| 4275 | }
|
---|
| 4276 | }
|
---|
| 4277 |
|
---|
| 4278 | public void setEncryptionDetailForTag(String tag, EncryptionDetail encryptionDetail) {
|
---|
[1414] | 4279 | primaryPropertyEncryption.put(tag, encryptionDetail);
|
---|
[1408] | 4280 | }
|
---|
[1413] | 4281 |
|
---|
| 4282 | public boolean isTagInherited(String tag) {
|
---|
| 4283 | return surrogatePropertyInheritance.get(tag);
|
---|
| 4284 | }
|
---|
| 4285 |
|
---|
[1415] | 4286 | public void setTagNotInherited(String tag) {
|
---|
| 4287 | surrogatePropertyInheritance.put(tag, false);
|
---|
| 4288 | }
|
---|
| 4289 |
|
---|
| 4290 | public boolean hasAccessToItemAsPrimary() {
|
---|
| 4291 | String label = this.getEncryptionLabel();
|
---|
| 4292 | if (this.isSurrogate() || label == null || label.length() == 0) {
|
---|
| 4293 | return true;
|
---|
| 4294 | }
|
---|
| 4295 |
|
---|
[1431] | 4296 | return Label.getLabel(label).is(LabelResult.SuccessResolveLabelToKey);
|
---|
[1415] | 4297 | }
|
---|
| 4298 |
|
---|
[1413] | 4299 |
|
---|
| 4300 | /**
|
---|
[1415] | 4301 | * If when setting a property, we find that the primary has a undeciphered value, when we must continue using that undeciphered value
|
---|
[1413] | 4302 | * when eventually saving.
|
---|
| 4303 | * @return
|
---|
| 4304 | */
|
---|
| 4305 | protected boolean subjectToInheritanceCheckOnSave(String tag) {
|
---|
[1430] | 4306 | if (tag.equals(DefaultFrameWriter.TYPE_AND_ID_STR)) {
|
---|
| 4307 | return false;
|
---|
| 4308 | }
|
---|
[1415] | 4309 | Item primary = getPrimary();
|
---|
| 4310 | if (primary == null) return false;
|
---|
| 4311 | EncryptionDetail primaryItemTagEncryptionDetail = primary.primaryPropertyEncryption.get(tag);
|
---|
| 4312 | Type primaryItemTagEncryptionDetailType = primaryItemTagEncryptionDetail.getEncryptionDetailType();
|
---|
| 4313 | return primaryItemTagEncryptionDetailType != EncryptionDetail.Type.UseUndecipheredValueOnSave;
|
---|
[1413] | 4314 | }
|
---|
[1415] | 4315 |
|
---|
| 4316 | public boolean acceptsKeyboardEnter() {
|
---|
| 4317 | return _acceptsKeyboardEnter;
|
---|
| 4318 | }
|
---|
| 4319 |
|
---|
| 4320 | public void setAcceptsEnter(boolean value) {
|
---|
| 4321 | if (this.getText() != null && this.getText().equals("Beep")) {
|
---|
| 4322 | System.err.println();
|
---|
| 4323 | }
|
---|
| 4324 | _acceptsKeyboardEnter = value;
|
---|
| 4325 | }
|
---|
[1509] | 4326 |
|
---|
| 4327 | private void generateSurrogate(LabelInfo labelResult) {
|
---|
| 4328 | Item copy = this.copy();
|
---|
| 4329 | if (copy.isAnnotation()) {
|
---|
| 4330 | if (ItemUtils.startsWithTag(copy, ItemUtils.TAG_IMAGE, true)) {
|
---|
| 4331 | String text = copy.getText();
|
---|
| 4332 | String size = "";
|
---|
| 4333 |
|
---|
| 4334 | // remove @i tag
|
---|
| 4335 | text = text.replaceFirst("@i:", "");
|
---|
| 4336 | text = text.replaceAll("\n", "");
|
---|
| 4337 | text = text.trim();
|
---|
| 4338 |
|
---|
| 4339 | int dotPos = text.indexOf('.');
|
---|
| 4340 | if (dotPos >= 0) {
|
---|
| 4341 | int endOfFileNamePos = text.indexOf(' ', dotPos);
|
---|
| 4342 | if (endOfFileNamePos >= 0) {
|
---|
| 4343 | size = text.substring(endOfFileNamePos).trim();
|
---|
| 4344 | }
|
---|
| 4345 | }
|
---|
| 4346 |
|
---|
| 4347 | String copyText = ItemUtils.GetTag(ItemUtils.TAG_IMAGE) + ": " + Picture.REDACTED_IMAGE_NAME + " " + size;
|
---|
| 4348 | copy.setText(copyText.trim());
|
---|
| 4349 | copy.setVisible(true);
|
---|
| 4350 | }
|
---|
| 4351 | } else if (copy instanceof Text) {
|
---|
| 4352 | copy.setText("Encrypted");
|
---|
| 4353 | }
|
---|
| 4354 |
|
---|
| 4355 | // Encrypt XRayables representative files and update pointer.
|
---|
| 4356 | Collection<? extends XRayable> xrayables = this.getEnclosures();
|
---|
| 4357 | for (XRayable xray: xrayables) {
|
---|
| 4358 | if (xray instanceof Picture) {
|
---|
| 4359 | EncryptedImage.encryptImage((Picture) xray, labelResult.key);
|
---|
| 4360 | Text source = xray._source;
|
---|
| 4361 | String oldName = xray.getName();
|
---|
| 4362 | String newName = oldName.substring(0, oldName.lastIndexOf('.')) + EncryptedImage.EXPEDITEE_ENCRYPTED_IMAGE_EXTENSION;
|
---|
| 4363 | source.setText(source.getText().replace(oldName, newName));
|
---|
| 4364 | }
|
---|
| 4365 | }
|
---|
| 4366 |
|
---|
| 4367 | this.addToSurrogates(copy);
|
---|
| 4368 | }
|
---|
[4] | 4369 | }
|
---|