- Timestamp:
- 08/27/08 09:18:49 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/items/widgets/InteractiveWidget.java
r279 r282 19 19 import javax.swing.SwingUtilities; 20 20 21 import org.expeditee.gui.AttributeUtils; 21 22 import org.expeditee.gui.Browser; 22 23 import org.expeditee.gui.DisplayIO; … … 133 134 text = text.trim(); 134 135 136 // Check starts with the widget tag and seporator 137 if (!text.startsWith(TAG + ":")) 138 throw new IllegalArgumentException("Source text must begin with \"" 139 + TAG + ":\""); 140 141 text = text.substring(TAG.length() + 1).trim(); 142 135 143 int index = 0; 136 if (text.length() > TAG.length() + 1) {137 index = text.indexOf(':' , TAG.length() + 1); // used for144 if (text.length() > 0) { 145 index = text.indexOf(':'); // used for 138 146 // signifying start 139 // of 140 } 141 142 // arguments 147 // of arguments 148 } 149 143 150 if (index == 0) 144 151 throw new IllegalArgumentException("Source text must begin with \"" … … 148 155 0, index).split(" "); 149 156 150 // Check starts with the widget tag and seporator151 if (tokens.length == 0 || !tokens[0].equals(TAG + ":"))152 throw new IllegalArgumentException("Source text must begin with \""153 + TAG + ":\"");154 155 157 float width = -1, height = -1; 156 158 157 if (tokens.length < 2)159 if (tokens.length < 1) 158 160 throw new IllegalArgumentException( 159 161 "Missing widget class name in source text"); … … 161 163 try { 162 164 163 if (tokens.length >= 3) { // parse optional width164 width = Integer.parseInt(tokens[ 2]);165 if (tokens.length >= 2) { // parse optional width 166 width = Integer.parseInt(tokens[1]); 165 167 width = (width <= 0) ? width = -1 : width; 166 168 } 167 169 168 if (tokens.length >= 4) { // parse optional height169 height = Integer.parseInt(tokens[ 3]);170 if (tokens.length >= 3) { // parse optional height 171 height = Integer.parseInt(tokens[2]); 170 172 height = (height <= 0) ? height = -1 : height; 171 173 } … … 176 178 } 177 179 178 if (tokens.length > 4)180 if (tokens.length > 3) 179 181 throw new IllegalArgumentException( 180 182 "to many arguments given before \":\" in source text"); 181 183 182 String classname = tokens[ 1];184 String classname = tokens[0]; 183 185 if (classname.charAt(0) == '$') 184 186 classname = "org.expeditee.items.widgets." + classname.substring(1); … … 704 706 705 707 public void setPosition(int x, int y) { 706 if (x == getX() && y == getY()) return; 708 if (x == getX() && y == getY()) 709 return; 707 710 708 711 boolean vfloating[] = new boolean[] { _d1.isFloating(), … … 925 928 .getCurrentMouseEvent()) 926 929 return; // already dealt with this event 927 930 928 931 _lastParentStateChangedEvent = e; 929 _lastParentStateChangedMouseEvent = MouseEventRouter.getCurrentMouseEvent(); 932 _lastParentStateChangedMouseEvent = MouseEventRouter 933 .getCurrentMouseEvent(); 930 934 931 935 switch (e.getEventType()) { … … 1072 1076 /** 1073 1077 * 1074 * @return 1075 * The current bounds for this widget. Never null. 1078 * @return The current bounds for this widget. Never null. 1076 1079 */ 1077 1080 public Rectangle getBounds() { … … 1155 1158 if (_textRepresentation.getLink() != null 1156 1159 || _textRepresentation.hasAction()) { 1157 // System.out.println("Painted link");1160 // System.out.println("Painted link"); 1158 1161 _textRepresentation.paintLinkGraphic(g, getLinkX(), getLinkY()); 1159 1162 … … 1493 1496 1494 1497 if (newData != null) { 1495 if (data != null) data.add(newData); 1498 if (data != null) 1499 data.add(newData); 1496 1500 else { 1497 1501 data = new LinkedList<String>(); 1498 1502 data.add(newData); 1499 1503 getCurrentRepresentation().setData(data); 1500 1501 } 1502 } 1504 1505 } 1506 } 1503 1507 } 1504 1508 … … 1507 1511 * 1508 1512 * @param link 1509 * 1510 * 1513 * The new frame link. Can be null (for no link) 1514 * 1511 1515 */ 1512 1516 public void setLink(String link) { … … 1518 1522 invalidateLink(); 1519 1523 } 1520 1521 public void setBackgroundColor(Color c) {1524 1525 public void setBackgroundColor(Color c) { 1522 1526 getSource().setBackgroundColor(c); 1523 1527 } 1524 1525 /** 1526 * @return 1527 * The link for this widget. Null if none. 1528 1529 /** 1530 * @return The link for this widget. Null if none. 1528 1531 */ 1529 1532 public String getLink() { 1530 1533 return _textRepresentation.getLink(); 1531 1534 } 1532 1533 1534 /**1535 * <b>Note:</b> That if the widget has no parent (e.g. the widget is a free-item) then1536 * the absolute link returned will be for the frameset of thecurrent frame.1537 * 1538 * @return 1539 * The absolute link for this item. Null if there is no link, or if1540 * there is no parent for this widget and the current frame isunavailable.1541 * 1535 1536 /** 1537 * <b>Note:</b> That if the widget has no parent (e.g. the widget is a 1538 * free-item) then the absolute link returned will be for the frameset of 1539 * the current frame. 1540 * 1541 * @return The absolute link for this item. Null if there is no link, or if 1542 * there is no parent for this widget and the current frame is 1543 * unavailable. 1544 * 1542 1545 */ 1543 1546 public String getAbsoluteLink() { 1544 1545 // Note: 1547 1548 // Note: cannot return the source absolute link since it does not have 1546 1549 // a parent ... thus must manually format link 1547 1550 1548 1551 String link = getLink(); 1549 1550 if (link == null || link.length() == 0) return null; 1551 1552 if (FrameIO.isPositiveInteger(link)) { // relative - convert to absolute 1553 1552 1553 if (link == null || link.length() == 0) 1554 return null; 1555 1556 if (FrameIO.isPositiveInteger(link)) { // relative - convert to 1557 // absolute 1558 1554 1559 // Get the frameset of this item 1555 1560 Frame parent = getParentFrame(); 1556 if (parent == null) parent = DisplayIO.getCurrentFrame(); 1557 if (parent == null) return null; 1558 1561 if (parent == null) 1562 parent = DisplayIO.getCurrentFrame(); 1563 if (parent == null) 1564 return null; 1565 1559 1566 String framesetName = parent.getFramesetName(); 1560 1561 if (framesetName == null) return null; 1562 1567 1568 if (framesetName == null) 1569 return null; 1570 1563 1571 return framesetName + link; 1564 1572 1565 1573 } else if (FrameIO.isValidFrameName(link)) { // already absolute 1566 1574 return link; 1567 1575 } 1568 1576 1569 1577 return null; 1570 1578 } … … 1600 1608 _textRepresentation.setColor(c); 1601 1609 } 1602 1610 1603 1611 public void setSourceBorderColor(Color c) { 1604 1612 _textRepresentation.setBorderColor(c); 1605 1613 } 1606 1614 1607 1615 public void setSourceFillColor(Color c) { 1608 1616 _textRepresentation.setFillColor(c); 1609 1617 } 1610 1618 1611 1619 public void setSourceThickness(float newThickness, boolean setConnected) { 1612 1620 _textRepresentation.setThickness(newThickness, setConnected); … … 1616 1624 _textRepresentation.setData(data); 1617 1625 } 1618 1626 1619 1627 protected Point getOrigin() { 1620 1628 return _d1.getPosition(); // BROOK: This flips around ... the origin can be any point 1621 1629 } 1622 1630 1623 1631 protected Item getFirstCorner() { 1624 1632 return _d1;
Note:
See TracChangeset
for help on using the changeset viewer.