Changeset 78 for trunk/src/org/expeditee/gui/Frame.java
- Timestamp:
- 05/26/08 09:11:05 (16 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 8 8 testdummyaudio 9 9 tests_apollos 10 *.txt
-
- Property svn:ignore
-
trunk/src/org/expeditee/gui/Frame.java
r74 r78 62 62 private Color _background; 63 63 64 private Color _foreground ;64 private Color _foreground = Item.DEFAULT_FOREGROUND; 65 65 66 66 public String path; … … 97 97 private List<Overlay> _overlays = new ArrayList<Overlay>(); 98 98 99 private VolatileImage _buffer = null; 99 private List<Vector> _vectors = new ArrayList<Vector>(); 100 101 private Image _buffer = null; 100 102 101 103 private boolean _validBuffer = true; … … 108 110 } 109 111 110 public VolatileImage getBuffer() {112 public Image getBuffer() { 111 113 return _buffer; 112 114 } 113 115 114 public void setBuffer( VolatileImage newBuffer) {116 public void setBuffer(Image newBuffer) { 115 117 _buffer = newBuffer; 116 118 } 117 119 118 120 public boolean isBufferValid() { 119 if (_buffer == null || _buffer.contentsLost()) 121 if (_buffer == null 122 || (_buffer instanceof VolatileImage && ((VolatileImage) _buffer) 123 .contentsLost())) 120 124 return false; 121 125 … … 243 247 * @return the last non annotation text item. 244 248 */ 245 public TextgetLastNonAnnotationTextItem() {249 public Item getLastNonAnnotationTextItem() { 246 250 List<Item> items = getItems(); 247 251 … … 251 255 252 256 if (it instanceof Text && !it.isAnnotation()) { 253 return ( Text) it;257 return (Item) it; 254 258 } 255 259 } … … 332 336 } 333 337 334 public TextgetFrameNameItem() {338 public Item getFrameNameItem() { 335 339 return _frameName; 336 340 } … … 364 368 } 365 369 366 public TextgetStatsTextItem(String itemText) {370 public Item getStatsTextItem(String itemText) { 367 371 Text t = getStatTemplate(); 368 372 // We dont want the stats to wrap at all … … 769 773 770 774 public Color getPaintBackgroundColor() { 771 if (_background == null) 772 return DisplayIO.DEFAULT_BACKGROUND; 775 // If null... return white 776 if (_background == null) { 777 return Item.DEFAULT_BACKGROUND; 778 } 773 779 774 780 return _background; … … 895 901 896 902 /** 903 * Adds the given Vector to the list of vector Frames being drawn with this 904 * Frame. 905 * 906 * @param vector 907 * The Vector to add 908 * 909 * @throws NullPointerException 910 * If overlay is null. 911 */ 912 public void addVector(Vector vector) { 913 if (vector == null) 914 throw new NullPointerException("Frame.addVector"); 915 // make sure we dont add this frame as an overlay of itself 916 if (vector.Frame == this) 917 return; 918 919 // if (_vectors.contains(vector)) 920 // return; 921 922 _vectors.add(vector); 923 924 // TODO add the code below 925 // Items must be notified that they have been added to this frame via 926 // the vector... 927 // List<Item> items = new LinkedList<Item>(); 928 // FrameGraphics.AddAllOverlayItems(items, vector.Frame, 929 // new LinkedList<Frame>()); 930 // 931 // for (Item i : items) { 932 // i.onParentStateChanged(new ItemParentStateChangedEvent(this, 933 // ItemParentStateChangedEvent.EVENT_TYPE_ADDED_VIA_VECTOR, 934 // overlay.Level)); 935 // } 936 } 937 938 /** 897 939 * Adds the given Frame to the list of overlays Frames being drawn with this 898 940 * Frame. … … 957 999 958 1000 /** 1001 * Removes the given vector from the list of vector being drawn with this 1002 * Frame. 1003 * 1004 * @param vector 1005 * The overlay to remove 1006 * 1007 * @throws NullPointerException 1008 * If overlay is null. 1009 */ 1010 public void removeVector(Vector vector) { 1011 if (vector == null) 1012 throw new NullPointerException("Frame.removeVector"); 1013 1014 this._vectors.remove(vector); 1015 1016 // TODO figure out what the code below needs to be changed to 1017 // Items must be notified that they have been removed from this frame 1018 // via the overlay... 1019 // List<Item> items = new LinkedList<Item>(); 1020 // FrameGraphics.AddAllOverlayItems(items, vector.Frame, 1021 // new LinkedList<Frame>()); 1022 // for (Item i : items) { 1023 // i.onParentStateChanged(new ItemParentStateChangedEvent(this, 1024 // ItemParentStateChangedEvent.EVENT_TYPE_REMOVED_VIA_OVERLAY, 1025 // vector.Level)); 1026 // } 1027 } 1028 1029 /** 959 1030 * Removes the given Frame from the list of overlayed Frames being drawn 960 1031 * with this Frame. … … 983 1054 } 984 1055 1056 public List<Vector> getVectors() { 1057 List<Vector> l = new LinkedList<Vector>(); 1058 l.addAll(_vectors); 1059 return l; 1060 } 1061 985 1062 public List<Overlay> getOverlays() { 986 1063 List<Overlay> l = new LinkedList<Overlay>(); … … 997 1074 getOverlaysDeep(l, this, new LinkedList<Frame>()); 998 1075 return l; 1076 } 1077 1078 /** 1079 * @return All vectosr seen by this frame (including its vector's vectors). 1080 */ 1081 public List<Vector> getVectorsDeep() { 1082 List<Vector> l = new LinkedList<Vector>(); 1083 getVectorsDeep(l, this, new LinkedList<Frame>()); 1084 return l; 1085 } 1086 1087 private boolean getVectorsDeep(List<Vector> vectors, Frame vector, 1088 List<Frame> seenVectors) { 1089 1090 if (seenVectors.contains(vector)) 1091 return false; 1092 1093 seenVectors.add(vector); 1094 1095 for (Vector o : vector.getVectors()) { 1096 if (getVectorsDeep(vectors, o.Frame, seenVectors)) { 1097 vectors.add(o); 1098 } 1099 } 1100 1101 return true; 999 1102 } 1000 1103 … … 1037 1140 } 1038 1141 1142 public void clearVectors() { 1143 while (!_vectors.isEmpty()) { 1144 removeVector(_vectors.get(0)); // centralise removing 1145 } 1146 } 1147 1039 1148 public void clearOverlays() { 1040 1149 while (!_overlays.isEmpty()) { 1041 1150 removeOverlay(_overlays.get(0)); // centralise removing 1151 } 1152 } 1153 1154 public void addAllVectors(List<Vector> vectors) { 1155 for (Vector v : vectors) { 1156 addVector(v); // centralise adding 1042 1157 } 1043 1158 } … … 1167 1282 getNextItemID()); 1168 1283 1169 Texttemplate = getTemplate(UserSettings.LineTemplate,1284 Item template = getTemplate(UserSettings.LineTemplate, 1170 1285 ItemUtils.TAG_LINE_TEMPLATE); 1171 1286 float thickness = template.getThickness(); … … 1236 1351 } 1237 1352 1238 public TextaddText(int x, int y, String text, String action, String link) {1239 Textt = addText(x, y, text, action);1353 public Item addText(int x, int y, String text, String action, String link) { 1354 Item t = addText(x, y, text, action); 1240 1355 t.setLink(link); 1241 1356 return t;
Note:
See TracChangeset
for help on using the changeset viewer.