Changeset 115 for trunk/src/org/expeditee/gui/FrameGraphics.java
- Timestamp:
- 07/02/08 12:38:54 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/gui/FrameGraphics.java
r108 r115 12 12 import java.awt.Point; 13 13 import java.awt.RenderingHints; 14 import java.awt.geom.Point2D;15 14 import java.awt.image.BufferedImage; 16 15 import java.awt.image.VolatileImage; … … 19 18 import java.util.Comparator; 20 19 import java.util.HashSet; 21 import java.util.Iterator;22 20 import java.util.LinkedList; 23 21 import java.util.List; … … 32 30 import org.expeditee.items.ItemUtils; 33 31 import org.expeditee.items.Line; 34 import org.expeditee.items.Picture;35 32 import org.expeditee.items.Text; 36 33 import org.expeditee.items.WidgetEdge; … … 71 68 public static final Color ERROR_COLOR = Color.red; 72 69 73 private static int _Mode = MODE_NORMAL; 70 // Start in XRay mode so that errors arnt thrown when parsing the profile 71 // frame if it has images on it 72 private static int _Mode = MODE_XRAY; 74 73 75 74 // if true, error messages are not shown to the user … … 96 95 _Mode = MODE_AUDIENCE; 97 96 ItemUtils.UpdateConnectedToAnnotations(current.getItems()); 98 for (Overlay o : current.getOverlays Deep()) {97 for (Overlay o : current.getOverlays()) { 99 98 ItemUtils.UpdateConnectedToAnnotations(o.Frame.getItems()); 100 99 } … … 213 212 if (!isAudienceMode() 214 213 || (isAudienceMode() && !i.isConnectedToAnnotation() && !i 215 .isAnnotation()) || i == FrameUtils. LastEdited) {214 .isAnnotation()) || i == FrameUtils.getLastEdited()) { 216 215 217 216 Graphics2D tg = (Graphics2D) g.create(); … … 219 218 tg.dispose(); 220 219 } 221 }222 223 public static void AddAllOverlayItems(List<Item> items, Frame overlay,224 List<Frame> seenOverlays) {225 if (seenOverlays.contains(overlay))226 return;227 228 seenOverlays.add(overlay);229 230 for (Overlay o : overlay.getOverlays())231 AddAllOverlayItems(items, o.Frame, seenOverlays);232 233 items.addAll(overlay.getVisibleItems());234 220 } 235 221 … … 250 236 * scaled. 251 237 */ 252 public static void AddAllVectorItems(List<Item> items, Frame vector, 253 Collection<Frame> seenVectors, Point2D.Float origin, Float scale, 254 Color defaultForeground, Color defaultBackground) { 255 256 // Check all the vector items and add the items on the vectors 257 if (seenVectors.contains(vector)) 258 return; 259 seenVectors.add(vector); 260 261 float originX = origin == null ? 0 : origin.x; 262 float originY = origin == null ? 0 : origin.y; 263 264 for (Vector o : vector.getVectors()) 265 AddAllVectorItems(items, o.Frame, new HashSet<Frame>(seenVectors), 266 new Point2D.Float(originX + o.Origin.x * scale, originY 267 + o.Origin.y * scale), o.Scale * scale, 268 o.Foreground, o.Background); 269 // if its the original frame then were done 270 if (origin == null) { 271 ItemUtils.EnclosedCheck(items); 272 return; 273 } 274 // Put copies of the items shifted to the origin of the VectorTag 275 float dx = origin.x; 276 float dy = origin.y; 277 List<Item> copies = ItemUtils 278 .CopyItems(vector.getVisibleItems(), false); 279 // FrameMouseActions 280 while (!copies.isEmpty()) { 281 Iterator<Item> iterator = copies.iterator(); 282 Item item = iterator.next(); 283 // Dont paint annotation items for @v 284 if (!item.isVisible() || item.isAnnotation()) { 285 iterator.remove(); 286 continue; 287 } 288 item.setLinkMark(false); 289 item.setActionMark(false); 290 if (!(item instanceof Line)) { 291 item.setThickness(item.getThickness() * scale); 292 Collection<Item> connected = item.getAllConnected(); 293 for (Item i : connected) { 294 if (!(i instanceof Line)) { 295 i.setXY(i.getX() * scale + dx, i.getY() * scale + dy); 296 i.setArrowheadLength(i.getArrowheadLength() * scale); 297 if (i.getColor() == null) { 298 i.setColor(defaultForeground); 299 } 300 if (i.getBackgroundColor() == null) { 301 i.setBackgroundColor(defaultBackground); 302 } 303 if (i.getFillColor() == null) { 304 i.setFillColor(defaultBackground); 305 } 306 if (i instanceof Text) 307 i.setSize(i.getSize() * scale); 308 else if (i instanceof Picture) { 309 Picture p = (Picture) i; 310 p.setScale(p.getScale() * scale); 311 } 312 } 313 } 314 items.addAll(connected); 315 copies.removeAll(connected); 316 } else { 317 items.add(item); 318 } 319 } 320 } 238 // public static void AddAllVectorItems(List<Item> items, Vector vector, 239 // Collection<Frame> seenVectors) { 240 // // Check all the vector items and add the items on the vectors 241 // if (seenVectors.contains(vector)) 242 // return; 243 // seenVectors.add(vector); 244 // 245 // float originX = origin == null ? 0 : origin.x; 246 // float originY = origin == null ? 0 : origin.y; 247 // 248 // for (Vector o : vector.getVectors()) 249 // AddAllVectorItems(items, o.Frame, new HashSet<Frame>(seenVectors), 250 // new Point2D.Float(originX + o.Origin.x * scale, originY 251 // + o.Origin.y * scale), o.Scale * scale, 252 // o.Foreground, o.Background); 253 // // if its the original frame then were done 254 // if (origin == null) { 255 // ItemUtils.EnclosedCheck(items); 256 // return; 257 // } 258 // // Put copies of the items shifted to the origin of the VectorTag 259 // items.addAll(ItemUtils 260 // .CopyItems(vector.getNonAnnotationItems(), vector)); 261 // 262 // } 321 263 322 264 /** … … 375 317 // rubber-banding on older machines 376 318 if (UserSettings.AntiAlias) 377 ((Graphics2D) bg).setRenderingHint( 378 RenderingHints.KEY_ANTIALIASING, 319 bg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, 379 320 RenderingHints.VALUE_ANTIALIAS_ON); 380 321 // If we are doing @f etc... then have a clear background if its the … … 396 337 List<InteractiveWidget> paintWidgets; 397 338 398 AddAllVectorItems(paintItems, toPaint, new LinkedList<Frame>(),399 null, 1F, null, null);400 401 339 if (isActualFrame) { 402 340 // Add all the items for this frame and any other from other 403 341 // frames 404 AddAllOverlayItems(paintItems, toPaint, new LinkedList<Frame>());342 paintItems.addAll(toPaint.getAllItems()); 405 343 406 344 paintWidgets = new LinkedList<InteractiveWidget>(); 407 345 AddAllOverlayWidgets(paintWidgets, toPaint, 408 346 new LinkedList<Frame>()); 409 410 347 } else { 411 348 paintItems.addAll(toPaint.getVisibleItems()); 349 paintItems.addAll(toPaint.getVectorItems()); 412 350 paintWidgets = toPaint.getInteractiveWidgets(); 413 351 } … … 736 674 // Brook: Widget Edges do not have such a context 737 675 if (toDisconnect != null && !(i instanceof WidgetEdge)) { 738 Item. SelectedMode newMode = toDisconnect.getSelectedMode();676 Item.HighlightMode newMode = toDisconnect.getHighlightMode(); 739 677 if (Frame.itemAttachedToCursor()) 740 newMode = Item. SelectedMode.Normal;678 newMode = Item.HighlightMode.Normal; 741 679 // unhighlight all the other dots 742 680 for (Item conn : toDisconnect.getAllConnected()) { 743 conn.set SelectedMode(Item.SelectedMode.None);681 conn.setHighlightMode(Item.HighlightMode.None); 744 682 } 745 l.set SelectedMode(newMode);683 l.setHighlightMode(newMode); 746 684 // highlight the dot that will be in disconnect mode 747 toDisconnect.set SelectedMode(newMode);685 toDisconnect.setHighlightMode(newMode); 748 686 i = toDisconnect; 749 687 } else { 750 688 Collection<Item> connected = i.getAllConnected(); 751 689 for (Item conn : connected) { 752 conn.set SelectedMode(Item.SelectedMode.Connected);690 conn.setHighlightMode(Item.HighlightMode.Connected); 753 691 } 754 692 } 755 693 } else if (i instanceof Circle) { 756 i.set SelectedMode(Item.SelectedMode.Connected);694 i.setHighlightMode(Item.HighlightMode.Connected); 757 695 } else { 758 696 // FrameGraphics.ChangeSelectionMode(i, … … 760 698 // For polygons need to make sure all other endpoints are 761 699 // unHighlighted 762 ChangeSelectionMode(i, Item.SelectedMode.Normal,763 Item. SelectedMode.None);700 changeHighlightMode(i, Item.HighlightMode.Normal, 701 Item.HighlightMode.None); 764 702 } 765 703 Repaint(); … … 767 705 } 768 706 769 public static void ChangeSelectionMode(Item item, Item.SelectedMode newMode) {770 ChangeSelectionMode(item, newMode, newMode);771 } 772 773 public static void ChangeSelectionMode(Item item,774 Item. SelectedMode newMode, Item.SelectedMode connectedNewMode) {707 public static void changeHighlightMode(Item item, Item.HighlightMode newMode) { 708 changeHighlightMode(item, newMode, newMode); 709 } 710 711 public static void changeHighlightMode(Item item, 712 Item.HighlightMode newMode, Item.HighlightMode connectedNewMode) { 775 713 if (item == null) 776 714 return; 715 // Mike: TODO comment on why the line below is used!! 716 // I forgot already!!Opps 777 717 boolean freeItem = Frame.FreeItems.contains(item); 778 718 for (Item i : item.getAllConnected()) { 779 // Mike: TODO comment on what the line below does!! 780 // I forgot already!!Opps 781 if (freeItem || !Frame.FreeItems.contains(i)) { 782 i.setSelectedMode(connectedNewMode); 783 } 784 } 785 if (newMode != connectedNewMode) 786 item.setSelectedMode(newMode); 719 if (/* freeItem || */!Frame.FreeItems.contains(i)) { 720 i.setHighlightMode(connectedNewMode); 721 } 722 } 723 if (!freeItem && newMode != connectedNewMode) 724 item.setHighlightMode(newMode); 787 725 Repaint(); 788 726 } … … 959 897 Paint(left, right, Item.DEFAULT_BACKGROUND); 960 898 } 961 962 899 isPainting = false; 963 900 }
Note:
See TracChangeset
for help on using the changeset viewer.