Changeset 1102 for trunk/src/org/expeditee/items/ItemUtils.java
- Timestamp:
- 05/10/18 16:04:51 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/items/ItemUtils.java
r922 r1102 19 19 package org.expeditee.items; 20 20 21 import java.awt.Color;22 import java.awt.Rectangle;23 import java.awt.image.ImageObserver;24 21 import java.io.File; 25 22 import java.io.UnsupportedEncodingException; … … 34 31 import java.util.Map; 35 32 36 import org.expeditee.gui.DisplayIO; 33 import org.expeditee.core.Colour; 34 import org.expeditee.core.bounds.AxisAlignedBoxBounds; 35 import org.expeditee.gui.DisplayController; 36 import org.expeditee.gui.DisplayController.TwinFramesSide; 37 37 import org.expeditee.gui.Frame; 38 38 import org.expeditee.gui.FrameUtils; … … 40 40 import org.expeditee.gui.Vector; 41 41 import org.expeditee.items.Item.HighlightMode; 42 import org.expeditee.items.widgets. InteractiveWidget;42 import org.expeditee.items.widgets.Widget; 43 43 import org.expeditee.items.widgets.InteractiveWidgetInitialisationFailedException; 44 44 import org.expeditee.items.widgets.InteractiveWidgetNotAvailableException; … … 360 360 * 361 361 * @param source 362 * The Text file containing the Picture info mation362 * The Text file containing the Picture information 363 363 * @return The Picture object representing the file, or Null if the file is 364 364 * not found. 365 365 */ 366 public static Picture CreatePicture(Text source, ImageObserver observer,boolean tryRemote) {366 public static Picture CreatePicture(Text source, boolean tryRemote) { 367 367 String text = source.getText(); 368 368 String path = ""; … … 424 424 // call CreatePicture again, but with tryRemote set to false so we won't get into an infinite loop 425 425 // if something goes wrong with finding the downloaded image 426 return CreatePicture(source, observer,false);426 return CreatePicture(source, false); 427 427 } 428 428 return null; … … 434 434 435 435 try { 436 Picture pic = new Picture(source, fileName, path, size , observer);436 Picture pic = new Picture(source, fileName, path, size); 437 437 438 438 return pic; … … 444 444 } 445 445 446 public static Picture CreatePicture(Text source , ImageObserver observer) {447 return CreatePicture(source, observer,true);446 public static Picture CreatePicture(Text source) { 447 return CreatePicture(source, true); 448 448 } 449 449 … … 483 483 484 484 // Widgets are super special 485 List< InteractiveWidget> widgets = new ArrayList<InteractiveWidget>();485 List<Widget> widgets = new ArrayList<Widget>(); 486 486 487 487 for (Item i : toCopy) { … … 596 596 Item start = lineEndMap.get(c.getStart()); 597 597 Item end = lineEndMap.get(c.getEnd()); 598 int id = Display IO.getCurrentFrame().getNextItemID();598 int id = DisplayController.getCurrentFrame().getNextItemID(); 599 599 if (start != null && end != null) { 600 600 new Constraint(start, end, id, c.getType()); … … 603 603 604 604 // BROOK 605 for ( InteractiveWidget iw : widgets) {605 for (Widget iw : widgets) { 606 606 try { 607 607 608 InteractiveWidget icopy = iw.copy();608 Widget icopy = iw.copy(); 609 609 copies.addAll(icopy.getItems()); 610 610 … … 680 680 Item copy = origEnd.copy(); 681 681 origEnd.setHighlightMode(HighlightMode.None); 682 origEnd.setHighlightColorToDefault(); 682 683 copy.removeAllLines(); 683 684 copy.removeAllConstraints(); … … 688 689 689 690 // create a new line 690 Frame currentFrame = Display IO.getCurrentFrame();691 Frame currentFrame = DisplayController.getCurrentFrame(); 691 692 Line line = new Line(origEnd, copy, currentFrame.getNextItemID()); 692 693 // if the previous line was constrained then make the new line … … 694 695 // TODO add later a diagonal constraint if getLines() == 3 or 4 695 696 Collection<Constraint> constraints = origEnd.getConstraints(); 696 if (constrain && constraints.size() > 0 697 && origEnd.getLines().size() == 2) { 697 if (constrain && constraints.size() > 0 && origEnd.getLines().size() == 2) { 698 698 Integer type = null; 699 699 for (Constraint c : constraints) { … … 710 710 } 711 711 if (type != null) { 712 new Constraint(origEnd, copy, currentFrame.getNextItemID(), 713 type); 712 new Constraint(origEnd, copy, currentFrame.getNextItemID(), type); 714 713 } 715 714 } … … 726 725 727 726 public static void New() { 728 EnclosedCheck(Display IO.getCurrentFrame().getItems());727 EnclosedCheck(DisplayController.getCurrentFrame().getItems()); 729 728 } 730 729 731 730 public static void Old() { 732 OldEnclosedCheck(Display IO.getCurrentFrame().getItems());731 OldEnclosedCheck(DisplayController.getCurrentFrame().getItems()); 733 732 } 734 733 … … 902 901 */ 903 902 public static boolean isVisible(Item i) { 904 if (Display IO.isTwinFramesOn()) {905 if (!isVisible(Display IO.getFrames()[0], i)) {906 return isVisible(Display IO.getFrames()[1], i);903 if (DisplayController.isTwinFramesOn()) { 904 if (!isVisible(DisplayController.getFrameOnSide(TwinFramesSide.LEFT), i)) { 905 return isVisible(DisplayController.getFrameOnSide(TwinFramesSide.RIGHT), i); 907 906 } else { 908 907 return true; 909 908 } 910 909 } else { 911 return isVisible(Display IO.getCurrentFrame(), i);910 return isVisible(DisplayController.getCurrentFrame(), i); 912 911 } 913 912 } … … 923 922 * @return True if visible/free from given frame. 924 923 */ 925 public static boolean isVisible(Frame fromFrame, Item i) {926 if (fromFrame == null)927 924 public static boolean isVisible(Frame fromFrame, Item i) 925 { 926 if (fromFrame == null) return false; 928 927 929 928 Frame parent = i.getParent(); 930 929 931 if (parent == fromFrame) 930 if (parent == fromFrame) { 932 931 return true; 932 } else if (parent == null) { 933 return FreeItems.getInstance().contains(i) || FreeItems.getCursor().contains(i); 934 } 933 935 934 else if (parent == null)935 return FreeItems.getInstance().contains(i)936 || FreeItems.getCursor().contains(i);937 938 936 return fromFrame.getAllItems().contains(i) && i.isVisible(); 939 937 } 940 938 941 public static Rectangle expandRectangle(Rectangle r, int n) { 942 return new Rectangle(r.x - (n >> 1), r.y - (n >> 1), r.width + n, 943 r.height + n); 939 public static AxisAlignedBoxBounds expandRectangle(AxisAlignedBoxBounds r, int n) 940 { 941 if (r == null) return null; 942 943 return new AxisAlignedBoxBounds(r.getMinX() - (n >> 1), r.getMinY() - (n >> 1), r.getWidth() + n, r.getHeight() + n); 944 944 } 945 945 … … 973 973 int originX = v.Origin.x; 974 974 int originY = v.Origin.y; 975 Colo r defaultForeground = v.Foreground;976 Colo r defaultBackground = v.Background;975 Colour defaultForeground = v.Foreground; 976 Colour defaultBackground = v.Background; 977 977 UserAppliedPermission permission = v.permission; 978 978 // TODO should this be checking if the frame has the … … 1014 1014 * @return List of (unique)widgets in items. Never null. 1015 1015 */ 1016 public static List< InteractiveWidget> extractWidgets(List<Item> items) {1016 public static List<Widget> extractWidgets(List<Item> items) { 1017 1017 assert (items != null); 1018 1018 1019 List< InteractiveWidget> iWidgets = new LinkedList<InteractiveWidget>();1019 List<Widget> iWidgets = new LinkedList<Widget>(); 1020 1020 1021 1021 for (Item i : items) { … … 1053 1053 * @param frame 1054 1054 */ 1055 public static void Justify(Frame frame) { 1055 public static void Justify(Frame frame) 1056 { 1057 if (frame == null) return; 1056 1058 EnclosedCheck(frame.getItems()); 1057 1059 Justify(frame.getItems());
Note:
See TracChangeset
for help on using the changeset viewer.