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