Changeset 10
- Timestamp:
- 05/01/08 17:02:40 (16 years ago)
- Location:
- trunk/src/org/expeditee
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/gui/Browser.java
r8 r10 1 1 package org.expeditee.gui; 2 2 3 import java.awt.Color; 3 4 import java.awt.Dimension; 4 5 import java.awt.Graphics; … … 15 16 import javax.swing.JFrame; 16 17 18 import org.expeditee.AbsoluteLayout; 17 19 import org.expeditee.actions.Actions; 18 20 import org.expeditee.actions.Misc; … … 30 32 public class Browser extends JFrame implements ComponentListener, 31 33 WindowListener, WindowStateListener { 34 32 35 /** 33 36 * Default version - just to stop eclipse from complaining about it. … … 38 41 39 42 public static Browser _theBrowser; 40 43 41 44 /** 42 45 * Constructs a new Browser object, then launches it … … 51 54 // FrameGraphics.ForceRepaint(); 52 55 } 53 56 54 57 public void setSizes(Dimension size) { 55 58 setSize(size); … … 91 94 UserSettings.InitialHeight)); 92 95 96 //set the layout to absolute layout for widgets 97 this.getContentPane().setLayout(new AbsoluteLayout()); 98 //enable the glasspane-for capturing all mouse events 99 this.setGlassPane(new MouseEventRouter(getJMenuBar(), getContentPane())); 100 this.getGlassPane().setVisible(true); 101 this.getContentPane().setBackground(Color.white); 102 93 103 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 94 104 … … 127 137 DisplayIO.setCurrentFrame(firstFrame); 128 138 129 // Create the action handler for the 130 FrameMouseActions mouse = new FrameMouseActions(); 131 132 this.getContentPane().addMouseListener(mouse); 133 this.getContentPane().addMouseMotionListener(mouse); 134 this.addKeyListener(new FrameKeyboardActions()); 135 this.getContentPane().addMouseWheelListener(mouse); 139 FrameKeyboardActions keyboardListner = new FrameKeyboardActions(); 140 this.getContentPane().addKeyListener(keyboardListner); 141 this.addKeyListener(keyboardListner); 136 142 } 137 143 … … 145 151 } 146 152 147 /*148 * public void loadedMenu(String menu) { if (g == null) return;149 *150 * g.setColor(this.getBackground()); g.fillRect(0, 0, this.getWidth(),151 * this.getHeight()); g.setColor(Color.BLACK); g.drawString("Loading Menu... " +152 * menu, this.getWidth() / 2 - 200, this .getHeight() / 2); }153 */154 155 153 @Override 156 154 public void paint(Graphics g) { 157 155 super.paint(g); 158 156 FrameGraphics.Repaint(); 159 // System.out.print('p');160 157 } 161 158 … … 167 164 setupGraphics(); 168 165 repaint(); 169 // System.out.println("Resize");170 166 } 171 167 … … 218 214 */ 219 215 public void windowStateChanged(WindowEvent e) { 220 // 221 // 216 //FrameGraphics.Repaint(); 217 //System.out.println('C'); 222 218 } 223 219 -
trunk/src/org/expeditee/gui/DisplayIO.java
r7 r10 330 330 FrameIO.ResumeCache(); 331 331 } 332 332 333 // If the frames are the same then the items for the 334 // frame that is just about to hide will still be in view 335 // so only notify items that they are hidden if the 336 // frames differ. 337 if (_CurrentFrames[getCurrentSide()] != null && 338 _CurrentFrames[0] != _CurrentFrames[1]) { 339 for (Item i : _CurrentFrames[getCurrentSide()].getItems()) { 340 i.onParentFameHidden(); 341 } 342 } 333 343 _CurrentFrames[getCurrentSide()] = frame; 344 345 // BROOK 346 for (Item i : _CurrentFrames[getCurrentSide()].getItems()) { 347 i.onParentFameShown(); 348 } 334 349 } else { 350 // Notifying items on the frame being hidden that they 351 // are about to be hidden. 352 // ie. Widgets use this method to remove themselves from 353 //the JPanel 354 if (_CurrentFrames[getCurrentSide()] != null) { 355 for (Item i : _CurrentFrames[getCurrentSide()].getItems()) { 356 i.onParentFameHidden(); 357 } 358 } 359 335 360 _CurrentFrames[getCurrentSide()] = frame; 336 361 frame.setMaxSize(FrameGraphics.getMaxFrameSize()); 362 363 // Notify items on the frame being displayed that they are in view 364 //ie. widgets use this method to add themselves to the content pane 365 for (Item i : _CurrentFrames[getCurrentSide()].getItems()) { 366 i.onParentFameShown(); 367 } 337 368 } 338 369 -
trunk/src/org/expeditee/gui/Frame.java
r7 r10 8 8 import java.awt.image.VolatileImage; 9 9 import java.util.ArrayList; 10 import java.util.Collection; 10 11 import java.util.Collections; 11 12 import java.util.LinkedList; … … 16 17 import org.expeditee.io.Logger; 17 18 import org.expeditee.items.Dot; 19 import org.expeditee.items.InteractiveWidget; 18 20 import org.expeditee.items.Item; 19 21 import org.expeditee.items.ItemUtils; 20 22 import org.expeditee.items.Line; 21 23 import org.expeditee.items.Text; 24 import org.expeditee.items.WidgetCorner; 22 25 23 26 /** … … 86 89 87 90 public static List<Item> FreeItems = new ArrayList<Item>(); 91 92 // for drawing purposes 93 private List<InteractiveWidget> _iWidgets = new ArrayList<InteractiveWidget>(); 88 94 89 95 private int _lineCount = 0; … … 140 146 i.setID(++_lineCount); 141 147 } 148 149 /** 150 * 151 * @return The interactive widgets that are currently ancored in this frame. 152 * Hence it exlcudes free-widgets. 153 */ 154 public List<InteractiveWidget> getInteractiveWidgets() { 155 return Collections.unmodifiableList(this._iWidgets); 156 // return this._iWidgets; // faster 157 } 142 158 143 159 /** … … 163 179 _change = value; 164 180 165 if (_change) 181 if (_change){ 166 182 setBufferValid(false); 167 183 _saved = false; … … 186 202 _sorted = true; 187 203 } 188 204 189 205 List<Item> visibleItems = new ArrayList<Item>(); 190 191 for (Item i: _body) {206 207 for(Item i: _body) { 192 208 if (i.isVisible()) 193 209 visibleItems.add(i); 194 210 } 195 211 196 212 return visibleItems; 197 213 } … … 214 230 } 215 231 216 return bodyTextItems; 217 232 return bodyTextItems; 218 233 } 219 234 … … 289 304 if (autoBulletText.length() > 0) 290 305 frameTitle.stripFirstWord(); 306 } 307 //TODO Widgets... check this out 308 // Brook: Cannot figure what is going on above... widget annot titles should be stripped always 309 if (ItemUtils.isTag(frameTitle, ItemUtils.GetTag(ItemUtils.TAG_IWIDGET))) { 310 frameTitle.stripFirstWord(); 291 311 } 292 312 … … 452 472 if (_frameName != null) { 453 473 id = _frameName.getID(); 454 } else 474 } else{ 455 475 id = -1 * getNextItemID(); 456 476 } … … 575 595 if (item != null) { 576 596 if (_body.contains(item)) { 577 // 578 // 597 //System.out.println("Item (" + item.getClass().getSimpleName() 598 // + ") with ID " + item.getID() + " already in body."); 579 599 return; 580 600 } … … 582 602 if (item instanceof Line) 583 603 _lineCount++; 584 604 585 605 _itemCount = Math.max(_itemCount, item.getID()); 586 606 … … 591 611 592 612 item.setMaxSize(FrameGraphics.getMaxFrameSize()); 613 //add widget items to the list of widgets 614 if (item instanceof WidgetCorner) { 615 InteractiveWidget iw = ((WidgetCorner)item).getWidgetSource(); 616 if (!this._iWidgets.contains(iw)) { // A set would have been best 617 _iWidgets.add(iw); 618 } 619 } 620 621 item.onAddedToFrame(); 622 593 623 change(); 594 624 } … … 608 638 } 609 639 610 public void addAllItems( List<Item> toAdd) {640 public void addAllItems(Collection<Item> toAdd) { 611 641 for (Item i : toAdd) 612 642 addItem(i); 613 643 } 614 644 615 public void removeAllItems( List<Item> toRemove) {645 public void removeAllItems(Collection<Item> toRemove) { 616 646 for (Item i : toRemove) 617 647 removeItem(i); … … 621 651 if (_body.remove(item)) 622 652 change(); 653 654 //Remove widgets from the widget list 655 if (item != null) { 656 item.onRemovedFromFrame(); 657 if (item instanceof WidgetCorner) { 658 _iWidgets.remove(((WidgetCorner)item).getWidgetSource()); 659 } 660 } 661 623 662 } 624 663 … … 951 990 List<Item> copies = ItemUtils.CopyItems(toMergeWith.getItems()); 952 991 copies.remove(toMergeWith.getFrameNameItem()); 953 992 954 993 for (Item i : copies) { 955 994 if (i.getID() >= 0) { -
trunk/src/org/expeditee/gui/FrameGraphics.java
r7 r10 2 2 3 3 import java.awt.Color; 4 import java.awt.Component; 5 import java.awt.Container; 4 6 import java.awt.Dimension; 5 7 import java.awt.Font; … … 7 9 import java.awt.Graphics2D; 8 10 import java.awt.GraphicsEnvironment; 11 import java.awt.Point; 9 12 import java.awt.RenderingHints; 10 13 import java.awt.image.VolatileImage; … … 12 15 import java.util.List; 13 16 17 import javax.swing.JPopupMenu; 18 import javax.swing.SwingUtilities; 19 14 20 import org.expeditee.actions.Misc; 15 21 import org.expeditee.items.Dot; 22 import org.expeditee.items.InteractiveWidget; 16 23 import org.expeditee.items.Item; 17 24 import org.expeditee.items.Line; 18 25 import org.expeditee.items.Picture; 19 26 import org.expeditee.items.Text; 27 import org.expeditee.items.WidgetEdge; 20 28 21 29 public class FrameGraphics { … … 247 255 paintItems.addAll(toPaint.getItems()); 248 256 } 257 // FIRST: Paint widgets swing gui (not expeditee gui) . 258 // Note that these are the ancored widgets 259 for (InteractiveWidget iw : toPaint.getInteractiveWidgets()) { 260 iw.paint(bg); 261 } 262 249 263 PaintPictures(bg, paintItems); 250 264 … … 300 314 PaintLines(bg, Frame.FreeItems); 301 315 } 316 302 317 if (paintOverlay) { 303 318 PaintItem(bg, toPaint.getFrameNameItem()); 304 319 } 320 321 // BROOK: Ensure popups are repainted 322 if (Browser._theBrowser != null) 323 repaintPopups(Browser._theBrowser.getLayeredPane(), bg); 324 305 325 bg.dispose(); 306 326 } … … 388 408 g.drawImage(_MessageBuffer, 0, _MaxSize.height, null); 389 409 g.dispose(); 390 } 410 411 } 412 413 391 414 392 415 private static void paintMessage(Graphics2D g, Color background) { … … 481 504 FrameMouseActions.MouseX, FrameMouseActions.MouseY); 482 505 483 if (toDisconnect != null) { 484 if (Frame.itemAttachedToCursor()) 506 // Brook: Widget Edges do not have such a context 507 if (toDisconnect != null && !(i instanceof WidgetEdge)) { 508 if(Frame.itemAttachedToCursor()) 485 509 return; 486 487 // 510 511 //unhighlight all the other dots 488 512 for (Item conn : toDisconnect.getAllConnected()) { 489 513 conn.showHighlight(false); 490 514 } 491 // 515 //highlight the dot that will be in disconnect mode 492 516 toDisconnect.showDisconnectHighlight(val); 493 517 toDisconnect.setFilledHighlight(true); … … 724 748 _SupressErrors = val; 725 749 } 750 751 752 private static void repaintPopups(Container parent, Graphics g) { 753 for (Component c : parent.getComponents()) { 754 if (c instanceof JPopupMenu && ((JPopupMenu)c).isVisible()) { 755 756 Point p = SwingUtilities.convertPoint(c, c.getLocation(), Browser._theBrowser.getContentPane()); 757 758 g.translate(p.x, p.y); 759 c.paint(g); 760 g.translate(-p.x, -p.y); 761 } else if (c instanceof Container && 762 c != Browser._theBrowser.getContentPane()) { 763 repaintPopups((Container)c, g); 764 } 765 } 766 } 726 767 } -
trunk/src/org/expeditee/gui/FrameIO.java
r8 r10 822 822 Text titleItem = newFrame.getTitle(); 823 823 824 while (titleItem.getBoundsWidth() + titleItem.getX() > newFrame 825 .getFrameNameItem().getX()) { 826 titleItem.setSize(titleItem.getSize() - 1); 824 // BROOK: This had recursion!! Changed to avoid... 825 if ((titleItem.getX() + 1) < newFrame.getFrameNameItem().getX()) { 826 while (titleItem.getBoundsWidth() + titleItem.getX() > newFrame 827 .getFrameNameItem().getX()) { 828 titleItem.setSize(titleItem.getSize() - 1); 829 } 830 } else { 831 System.out.println("Bad title x position: " + titleItem.getX()); 827 832 } 828 833 … … 965 970 if (!FrameIO.DoesFramesetExist(framesetName)) 966 971 return false; 967 972 968 973 for (String path : UserSettings.FrameDirs) { 969 974 String source = path + framesetName.toLowerCase() + File.separator; -
trunk/src/org/expeditee/gui/FrameMouseActions.java
r7 r10 20 20 import org.expeditee.items.Constraint; 21 21 import org.expeditee.items.Dot; 22 import org.expeditee.items.InteractiveWidgetNotAvailableException; 22 23 import org.expeditee.items.Item; 23 24 import org.expeditee.items.ItemUtils; … … 25 26 import org.expeditee.items.Picture; 26 27 import org.expeditee.items.Text; 28 import org.expeditee.items.WidgetCorner; 29 import org.expeditee.items.WidgetEdge; 27 30 import org.expeditee.stats.SessionStats; 28 31 29 32 public class FrameMouseActions implements MouseListener, MouseMotionListener, 30 33 MouseWheelListener { 34 35 36 private FrameMouseActions() {} 37 38 private static FrameMouseActions _instance = null; 39 40 public static FrameMouseActions getInstance() { 41 if (_instance == null) _instance = new FrameMouseActions(); 42 return _instance; 43 } 31 44 32 45 // TODO say where/how used … … 185 198 public void mouseClicked(MouseEvent e) { 186 199 } 187 200 188 201 /** 189 202 * Each Item on the Frame is checked to determine if the mouse x,y … … 193 206 */ 194 207 public void mousePressed(MouseEvent e) { 208 ProccessMousePressedEvent(e, e.getModifiersEx()); 209 } 210 211 public void ProccessMousePressedEvent(MouseEvent e, int modifiersEx) { 212 195 213 _mouseDown += e.getButton(); 196 214 _lastMouseClickDate = new Date(); … … 238 256 239 257 // check for delete command 240 if (isDelete( e)) {258 if (isDelete(modifiersEx)) { 241 259 _isDelete = true; 242 260 // _lastRanged = null; … … 244 262 _wasDouble = false; 245 263 // check for attributes command 246 } else if (isGetAttributes( e)) {264 } else if (isGetAttributes(modifiersEx)) { 247 265 _isAttribute = true; 248 266 _wasDouble = false; 249 } else if (isTwoClickNoOp( e)) {267 } else if (isTwoClickNoOp(modifiersEx)) { 250 268 _isAttribute = false; 251 269 _wasDouble = false; … … 442 460 } 443 461 444 // if the user has cropped an ima ge, either the above happend or this is462 // if the user has cropped an imate, either the above happend or this is 445 463 // a no-op 446 464 if (_lastCropped != null && _lastCropped.getCroppedSize() > 0) { … … 560 578 if (clicked == null) 561 579 return false; 580 581 // Brook: widgets do not merge 582 if (clicked instanceof WidgetCorner) return false; 583 584 // Brook: widgets do not merge 585 if (clicked instanceof WidgetEdge) return false; 562 586 563 587 // System.out.println(Frame.FreeItems.size()); … … 623 647 } 624 648 625 // TODO remove rectangle constraints?626 if (clicked instanceof Line ) {649 // BROOK: WIDGET RECTANGLES DONT ALLOW DISCONNECTION 650 if (clicked instanceof Line && !(clicked instanceof WidgetEdge)) { 627 651 // Check if within 20% of the end of the line 628 652 Line l = (Line) clicked; … … 683 707 } 684 708 } 685 709 686 710 pickup(clicked); 687 711 return; … … 1320 1344 1321 1345 DisplayIO.Back(); 1322 1346 1323 1347 // repaint things if necessary 1324 1348 if (Frame.itemAttachedToCursor()) … … 1513 1537 List<Item> toUndo = new LinkedList<Item>(); 1514 1538 List<Item> seen = new LinkedList<Item>(); 1515 1539 1516 1540 // disconnect any connected items 1517 1541 for (Item i : itemList) { … … 1580 1604 1581 1605 private static List<Item> deleteDot(Dot dot) { 1582 // create a backup copy of the dot 1583 List<Item> copy = copy(dot.getConnected()); 1584 // remove lines that are connected to anchored dots 1585 // note: the line is kept so that it can be properly restored 1586 for (Item ic : copy) { 1587 if (ic instanceof Line) { 1588 Line line = (Line) ic; 1589 if (!copy.contains(line.getStartItem())) 1590 line.getStartItem().removeLine(line); 1591 if (!copy.contains(line.getEndItem())) 1592 line.getEndItem().removeLine(line); 1593 } 1594 } 1595 1596 // remove all lines being deleted 1597 for (Item ic : dot.getConnected()) { 1598 if (ic instanceof Line && ((Line) ic).getOppositeEnd(dot) != null) { 1599 Line line = (Line) ic; 1600 1601 Item d = line.getOppositeEnd(dot); 1602 d.removeLine(line); 1603 1604 // if the dot was only part of one line, it can be 1605 // removed 1606 if (d.getLines().size() == 0) { 1607 if (d.getParent() != null) 1608 d.getParent().removeItem(d); 1609 if (!copy.contains(d)) 1610 copy.add(d); 1611 } 1612 1613 if (dot.getParent() != null) 1614 dot.getParent().removeItem(ic); 1615 } 1616 } 1617 return copy; 1606 1607 if (dot instanceof WidgetCorner) { // Brook 1608 1609 WidgetCorner wc = (WidgetCorner)dot; 1610 List<Item> wccopy; 1611 1612 try { 1613 wccopy = wc.getWidgetSource().copy().getItems(); 1614 } catch (InteractiveWidgetNotAvailableException e) { 1615 e.printStackTrace(); 1616 return new LinkedList<Item>(); 1617 } 1618 1619 if (dot.getParent() != null) { 1620 dot.getParent().removeAllItems(wc.getWidgetSource().getItems()); 1621 } 1622 return wccopy; 1623 } else { 1624 1625 // create a backup copy of the dot 1626 List<Item> copy = copy(dot.getConnected()); 1627 // remove lines that are connected to anchored dots 1628 // note: the line is kept so that it can be properly restored 1629 for (Item ic : copy) { 1630 if (ic instanceof Line) { 1631 Line line = (Line) ic; 1632 if (!copy.contains(line.getStartItem())) 1633 line.getStartItem().removeLine(line); 1634 if (!copy.contains(line.getEndItem())) 1635 line.getEndItem().removeLine(line); 1636 } 1637 } 1638 1639 // remove all lines being deleted 1640 for (Item ic : dot.getConnected()) { 1641 if (ic instanceof Line && ((Line) ic).getOppositeEnd(dot) != null) { 1642 Line line = (Line) ic; 1643 1644 Item d = line.getOppositeEnd(dot); 1645 d.removeLine(line); 1646 1647 // if the dot was only part of one line, it can be 1648 // removed 1649 if (d.getLines().size() == 0) { 1650 if (d.getParent() != null) 1651 d.getParent().removeItem(d); 1652 if (!copy.contains(d)) 1653 copy.add(d); 1654 } 1655 1656 if (dot.getParent() != null) 1657 dot.getParent().removeItem(ic); 1658 } 1659 } 1660 return copy; 1661 } 1618 1662 } 1619 1663 … … 1763 1807 */ 1764 1808 public static void pickup(Item toGrab) { 1809 1810 // Brook: If the widget corner is being picked up. Instead refer to picking 1811 // up the edge for fixed-sized widgets so it is not so confusing 1812 if (toGrab instanceof WidgetCorner) { 1813 WidgetCorner wc = (WidgetCorner) toGrab; 1814 if (wc.getWidgetSource().isFixedSize()) { 1815 toGrab = toGrab.getConnected().get(1); 1816 } 1817 } 1818 1765 1819 pickup(toGrab.getConnected()); 1766 1820 } … … 1974 2028 } 1975 2029 1976 public static boolean isDelete(MouseEvent e) { 1977 if (e == null) 1978 return false; 2030 public static boolean isDelete(int modifiersEx) { 2031 1979 2032 int onMask = MouseEvent.BUTTON3_DOWN_MASK 1980 2033 | MouseEvent.BUTTON2_DOWN_MASK; 1981 return (e.getModifiersEx() & onMask) == onMask; 1982 } 1983 1984 public static boolean isGetAttributes(MouseEvent e) { 1985 if (e == null) 1986 return false; 2034 return (modifiersEx & onMask) == onMask; 2035 } 2036 2037 public static boolean isGetAttributes(int modifiersEx) { 1987 2038 int onMask = MouseEvent.BUTTON3_DOWN_MASK 1988 2039 | MouseEvent.BUTTON1_DOWN_MASK; 1989 return (e.getModifiersEx() & onMask) == onMask; 1990 } 1991 1992 public static boolean isTwoClickNoOp(MouseEvent e) { 1993 if (e == null) 1994 return false; 2040 return (modifiersEx & onMask) == onMask; 2041 } 2042 2043 public static boolean isTwoClickNoOp(int modifiersEx) { 1995 2044 int onMask = MouseEvent.BUTTON2_DOWN_MASK 1996 2045 | MouseEvent.BUTTON1_DOWN_MASK; 1997 return ( e.getModifiersEx()& onMask) == onMask;2046 return (modifiersEx & onMask) == onMask; 1998 2047 } 1999 2048 2000 2049 public static boolean wasDeleteClicked() { 2001 return isDelete(_lastMouseClick); 2050 if (_lastMouseClick == null) return false; 2051 return isDelete(_lastMouseClick.getModifiersEx()); 2002 2052 } 2003 2053 -
trunk/src/org/expeditee/gui/FrameUtils.java
r7 r10 11 11 import org.expeditee.io.Logger; 12 12 import org.expeditee.items.Dot; 13 import org.expeditee.items.InteractiveWidget; 14 import org.expeditee.items.InteractiveWidgetNotAvailableException; 13 15 import org.expeditee.items.Item; 14 16 import org.expeditee.items.ItemUtils; … … 16 18 import org.expeditee.items.Picture; 17 19 import org.expeditee.items.Text; 20 import org.expeditee.items.WidgetCorner; 21 import org.expeditee.items.WidgetEdge; 18 22 19 23 public class FrameUtils { … … 447 451 frame.removeItem(txt); 448 452 frame.addItem(pic); 453 454 return true; 455 } 456 457 /** 458 * Creates an interactive widget and adds it to a frame. 459 * If txt has no parent the parent will be set to frame. 460 * 461 * @param frame 462 * Frame to add widget to. Must not be null. 463 * 464 * @param txt 465 * Text to create the widget from. Must not be null. 466 * 467 * @return True if created/added. False if coul not create. 468 * 469 * @author Brook Novak 470 */ 471 private static boolean createWidget(Frame frame, Text txt) { 472 473 if (frame == null) throw new NullPointerException("frame"); 474 if (txt == null) throw new NullPointerException("txt"); 475 476 // Safety 477 if (txt.getParent() == null) txt.setParent(frame); 478 479 InteractiveWidget iw = null; 480 481 try { 482 483 iw = InteractiveWidget.CreateWidget(txt); 484 485 } catch (InteractiveWidgetNotAvailableException e) { 486 e.printStackTrace(); 487 FrameGraphics.ErrorMessage("Cannot create iWidget: " + e.getMessage()); 488 489 } catch (IllegalArgumentException e) { 490 e.printStackTrace(); 491 FrameGraphics.ErrorMessage("Cannot create iWidget: " + e.getMessage()); 492 } 493 494 if (iw == null) return false; 495 496 frame.removeItem(txt); 497 498 frame.addAllItems(iw.getItems()); 449 499 450 500 return true; … … 628 678 ItemUtils.EnclosedCheck(toParse.getItems()); 629 679 630 ArrayList<Item> items = new ArrayList<Item>(); 631 items.addAll(toParse.getItems()); 680 List<Item> items = toParse.getItems(); 632 681 633 682 // if XRayMode is on, replace pictures with their underlying text 634 683 if (FrameGraphics.isXRayMode()) { 684 685 // BROOK: Must handle these a little different 686 //List<InteractiveWidget> widgets = toParse.getInteractiveWidgets(); 687 ArrayList<InteractiveWidget> widgets = new ArrayList<InteractiveWidget>(); 688 /* 635 689 for (Item i : items) { 636 690 if (i instanceof Picture) { 637 691 toParse.removeItem(i); 638 692 toParse.addItem(((Picture) i).getText()); 639 } 640 } 641 693 } else if (i instanceof WidgetCorner) { 694 toParse.removeItem(i); 695 } else if (i instanceof WidgetEdge) { 696 toParse.removeItem(i); 697 } 698 }*/ 699 for (Item i : items) { 700 if (i instanceof Picture) { 701 toParse.removeItem(i); 702 toParse.addItem(((Picture) i).getText()); 703 } else if (i instanceof WidgetCorner) { 704 toParse.removeItem(i); 705 InteractiveWidget iw = ((WidgetCorner)i).getWidgetSource(); 706 if (!widgets.contains(iw)) { // hmmm I should be using a set... meh 707 widgets.add(iw); 708 } 709 } else if (i instanceof WidgetEdge) toParse.removeItem(i); 710 } 711 712 713 for (InteractiveWidget iw : widgets) { 714 toParse.addItem(iw.getSource()); 715 } 716 642 717 // update the list of items 643 718 items.clear(); … … 691 766 } 692 767 693 // check for Images 768 // check for Images and widgets 694 769 if (!FrameGraphics.isXRayMode()) { 695 770 if (ItemUtils.isTag(i, ItemUtils.TAG_IMAGE)) … … 699 774 && ItemUtils.isTag(i, ItemUtils.TAG_FRAME_IMAGE)) 700 775 createFramePicture(toParse, (Text) i); 776 // Check for interactive widgets 777 else if (ItemUtils.isTag(i, ItemUtils.TAG_IWIDGET)) { 778 createWidget(toParse, (Text) i); 779 } 701 780 } 702 781 -
trunk/src/org/expeditee/io/ExpWriter.java
r4 r10 13 13 import org.expeditee.items.Constraint; 14 14 import org.expeditee.items.Dot; 15 import org.expeditee.items.InteractiveWidget; 15 16 import org.expeditee.items.Item; 16 17 import org.expeditee.items.Line; 17 18 import org.expeditee.items.Picture; 18 19 import org.expeditee.items.Text; 20 import org.expeditee.items.WidgetCorner; 21 import org.expeditee.items.WidgetEdge; 19 22 import org.expeditee.stats.SessionStats; 20 23 … … 145 148 // write out each Item in the Frame. 146 149 List<Item> items = frame.getItems(); 150 151 // iWidgets are handled specially since 8 items are written as one 152 List<InteractiveWidget> seenWidgets = new LinkedList<InteractiveWidget>(); 147 153 148 154 // do not write items with ID -1, also skip any lines 149 155 for (Item i : items) { 150 if (i.getID() >= 0 && !(i instanceof Line)) 156 157 // Ensure only one of the WidgetCorners represent a single widget 158 if (i instanceof WidgetCorner) { 159 InteractiveWidget iw = ((WidgetCorner)i).getWidgetSource(); 160 if (seenWidgets.contains(iw)) continue; 161 seenWidgets.add(iw); 162 } 163 164 if (i.getID() >= 0 && !(i instanceof Line)) { 151 165 writeItem(i); 152 } 153 166 } 167 } 168 154 169 // write any lines or constraints 155 170 writeTerminator(); … … 210 225 if (item instanceof Picture) 211 226 item = ((Picture) item).getText(); 212 227 else if (item instanceof WidgetCorner) 228 item = ((WidgetCorner) item).getWidgetSource().getSource(); 229 213 230 if (item.getLines().size() > 0) 214 231 writePoint(item); … … 242 259 if (lines != null && lines.size() > 0) { 243 260 for (Line line : lines) { 261 262 // Brook: widget edges are not saved 263 if (line instanceof WidgetEdge) { 264 seen.add(line); 265 continue; 266 } 244 267 245 268 // only output new lines that have not yet been output -
trunk/src/org/expeditee/items/Item.java
r7 r10 40 40 public static int PERMISSION_TDFC = 3; 41 41 public static int PERMISSION_FULL = 4; 42 42 43 43 public static final int NEAR_DISTANCE = 15; 44 44 … … 1414 1414 return _visible; 1415 1415 } 1416 1417 1418 1419 // BROOK: Overrideable 1420 public void onRemovedFromFrame() {} 1421 public void onAddedToFrame() {} 1422 public void onParentFameHidden() {} // because of caching 1423 public void onParentFameShown() {} // because of caching 1416 1424 } -
trunk/src/org/expeditee/items/ItemUtils.java
r7 r10 63 63 64 64 public static final int TAG_MAX = 15; 65 66 // Brook: Im claiming this number! 67 public static final int TAG_IWIDGET = 16; 68 65 69 66 70 /** … … 276 280 case TAG_POINTTYPE: 277 281 return "@pointtype:"; 282 case TAG_IWIDGET: 283 return "@iw"; 278 284 default: 279 285 return null; … … 418 424 List<Item> seen = new ArrayList<Item>(); 419 425 426 // Widgets are super special 427 List<InteractiveWidget> widgets = new ArrayList<InteractiveWidget>(); 428 420 429 for (Item i : toCopy) { 430 431 // BROOK 432 if (i instanceof WidgetCorner) { // dont add these 433 434 if (!widgets.contains(((WidgetCorner)i).getWidgetSource())) 435 widgets.add(((WidgetCorner)i).getWidgetSource()); 436 437 // BROOK 438 } else if (i instanceof WidgetEdge) { // dont add these 439 421 440 // lines are recreated later 422 if (i instanceof Line) {441 } else if (i instanceof Line) { 423 442 Line line = (Line) i; 424 443 lines.add(line); … … 529 548 } 530 549 550 // BROOK 551 for (InteractiveWidget iw : widgets) { 552 try { 553 554 InteractiveWidget icopy = iw.copy(); 555 copies.addAll(icopy.getItems()); 556 557 } catch (InteractiveWidgetNotAvailableException e) { 558 e.printStackTrace(); 559 } 560 } 561 531 562 return copies; 532 563 }
Note:
See TracChangeset
for help on using the changeset viewer.