Changeset 376 for trunk/src/org/expeditee/gui/FrameUtils.java
- Timestamp:
- 11/02/08 13:05:01 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/gui/FrameUtils.java
r373 r376 240 240 } 241 241 242 if (above != curr.getNameItem() && above != curr.getTitleItem()) 242 // Need to do things differently for FORMAT than for DROPPING 243 if (moveAll && above != curr.getNameItem() 244 && above != curr.getTitleItem()) { 243 245 x = above.getX(); 246 from.setY((int) above.getPolygon().getBounds().getMaxY() 247 + space 248 + ((int) (from.getY() - from.getPolygon().getBounds() 249 .getMinY()))); 250 from.setX(x); 251 } else { 252 x = from.getX(); 253 } 244 254 245 255 space += adjust; 246 247 from.setY((int) above.getPolygon().getBounds().getMaxY() 248 + space 249 + ((int) (from.getY() - from.getPolygon().getBounds() 250 .getMinY()))); 251 252 if (moveAll) 253 from.setX(x); 254 } 255 256 } 256 257 for (int i = 1; i < toAlign.size(); i++) { 257 258 Item current = toAlign.get(i); … … 580 581 // check for all tags setting user values 581 582 for (Text item : profile.getBodyTextItems(false)) { 582 583 AttributeValuePair avp = new AttributeValuePair(item.getText()); 584 String attributeFullCase = avp.getAttributeOrValue(); 585 586 if (attributeFullCase == null) 587 continue; 588 String attribute = attributeFullCase.toLowerCase(); 589 590 if (attribute.equals("homeframe")) { 591 String first = getLink(item, UserSettings.HomeFrame); 592 // do not use non-existant frames as the first frame 593 if (FrameIO.isValidFrameName(first)) { 594 UserSettings.HomeFrame = first; 595 } 596 // warn the user 597 else { 598 // MessageBay.warningMessage("Home frame: " + first 599 // + " is not a valid frame."); 600 UserSettings.HomeFrame = profile.getName(); 601 } 602 } else if (attribute.equals("username")) { 603 UserSettings.UserName = avp.getValue(); 604 } else if (attribute.equals("spellchecker")) { 605 606 try { 607 JSpellChecker.create(); 608 } catch (FileNotFoundException e) { 609 MessageBay.errorMessage("Could not find dictionary: " 610 + e.getMessage()); 611 } catch (IOException e) { 612 // TODO Auto-generated catch block 613 e.printStackTrace(); 614 } 615 } else if (attribute.equals("defaultframe")) 616 UserSettings.DefaultFrame = getLink(item, 617 UserSettings.DefaultFrame); 618 else if (attribute.equals("mailsettings")) 619 MailSession.init(item.getChild()); 620 else if (attribute.equals("networksettings")) 621 FrameShare.init(item.getChild()); 622 else if (attribute.equals("greenstonesettings")) { 623 SearchGreenstone.init(item.getChild()); 624 } else if (attribute.equals("reminders")) 625 Reminders.init(item.getChild()); 626 else if (attribute.equals("antialias")) 627 UserSettings.AntiAlias = avp.getBooleanValue(); 628 else if (attribute.equals("gravity")) 629 UserSettings.Gravity = avp.getIntegerValue(); 630 else if (attribute.equals("showlinehighlight")) 631 UserSettings.LineHighlight = avp.getBooleanValue(); 632 else if (attribute.equals("linestraightenthreshold")) 633 UserSettings.LineStraightenThreshold = avp.getIntegerValue(); 634 else if (attribute.equals("noopthreshold")) 635 UserSettings.NoOpThreshold = avp.getIntegerValue(); 636 else if (attribute.equals("formatspacingmin")) { 637 FrameUtils.MINIMUM_SPACING_RATIO = avp.getDoubleValue(); 638 } else if (attribute.equals("formatspacingmax")) { 639 FrameUtils.MAXIMUM_SPACING_RATIO = avp.getDoubleValue(); 640 } else if (attribute.equals("initialwidth")) { 641 UserSettings.InitialWidth = avp.getIntegerValue(); 642 } else if (attribute.equals("initialheight")) { 643 UserSettings.InitialHeight = avp.getIntegerValue(); 644 } else if (attribute.equals("titleposition")) { 645 UserSettings.TitlePosition = avp.getIntegerValue(); 646 } else if (attribute.equals("logging")) { 647 UserSettings.Logging = avp.getBooleanValue(); 648 } else if (attribute.equals("itemtemplate")) { 649 UserSettings.ItemTemplate = ((Text) item).getTemplateForm(); 650 } else if (attribute.equals("annotationtemplate")) { 651 UserSettings.AnnotationTemplate = ((Text) item) 652 .getTemplateForm(); 653 } else if (attribute.equals("statstemplate")) { 654 UserSettings.StatTemplate = ((Text) item).getTemplateForm(); 655 } else if (attribute.equals("commenttemplate")) { 656 UserSettings.CodeCommentTemplate = ((Text) item) 657 .getTemplateForm(); 658 } else if (attribute.equals("dottemplate")) { 659 UserSettings.DotTemplate = ((Text) item).getTemplateForm(); 660 } else if (attribute.equals("framesetdir")) { 661 String dir = getDir(avp.getValue()); 662 if (dir != null) { 663 UserSettings.FrameDirs.add(dir); 664 } 665 } else if (attribute.equals("logdir")) { 666 org.expeditee.gui.FrameIO.LOGS_DIR = getDir(avp.getValue()); 667 } else if (attribute.equals("imagedir")) { 668 String dir = getDir(avp.getValue()); 669 if (dir != null) 670 UserSettings.ImageDirs.add(0, dir); 671 } else if (attribute.equals("threading")) { 672 UserSettings.Threading = avp.getBooleanValue(); 673 } else if (attribute.equals("colorwheel")) { 674 Item.COLOR_WHEEL = getColorWheel(item); 675 } else if (attribute.equals("fillcolorwheel")) { 676 Item.FILL_COLOR_WHEEL = getColorWheel(item); 677 } else if (attribute.equals("backgroundcolorwheel")) { 678 Frame.COLOR_WHEEL = getColorWheel(item); 679 } else if (attribute.equals("framesetdirs")) { 680 UserSettings.FrameDirs.addAll(getDirs(item)); 681 } else if (attribute.equals("imagedirs")) { 682 UserSettings.ImageDirs.addAll(getDirs(item)); 683 } else if (attribute.equals("style")) { 684 UserSettings.Style = getStyle(item.getChild()); 685 } else { 686 errors.add(attributeFullCase + " is not a profile frame tag"); 583 try { 584 585 AttributeValuePair avp = new AttributeValuePair(item.getText()); 586 String attributeFullCase = avp.getAttributeOrValue(); 587 588 if (attributeFullCase == null) 589 continue; 590 String attribute = attributeFullCase.toLowerCase(); 591 592 if (attribute.equals("homeframe")) { 593 String first = getLink(item, UserSettings.HomeFrame); 594 // do not use non-existant frames as the first frame 595 if (FrameIO.isValidFrameName(first)) { 596 UserSettings.HomeFrame = first; 597 } 598 // warn the user 599 else { 600 // MessageBay.warningMessage("Home frame: " + first 601 // + " is not a valid frame."); 602 UserSettings.HomeFrame = profile.getName(); 603 } 604 } else if (attribute.equals("username")) { 605 UserSettings.UserName = avp.getValue(); 606 } else if (attribute.equals("spellchecker")) { 607 608 try { 609 JSpellChecker.create(); 610 } catch (FileNotFoundException e) { 611 MessageBay.errorMessage("Could not find dictionary: " 612 + e.getMessage()); 613 } catch (IOException e) { 614 // TODO Auto-generated catch block 615 e.printStackTrace(); 616 } 617 } else if (attribute.equals("defaultframe")) 618 UserSettings.DefaultFrame = getLink(item, 619 UserSettings.DefaultFrame); 620 else if (attribute.equals("mailsettings")) 621 MailSession.init(item.getChild()); 622 else if (attribute.equals("networksettings")) 623 FrameShare.init(item.getChild()); 624 else if (attribute.equals("spelling")) 625 JSpellChecker.create(item.getChild()); 626 else if (attribute.equals("greenstonesettings")) { 627 SearchGreenstone.init(item.getChild()); 628 } else if (attribute.equals("reminders")) 629 Reminders.init(item.getChild()); 630 else if (attribute.equals("antialias")) 631 UserSettings.AntiAlias = avp.getBooleanValue(); 632 else if (attribute.equals("gravity")) 633 UserSettings.Gravity = avp.getIntegerValue(); 634 else if (attribute.equals("showlinehighlight")) 635 UserSettings.LineHighlight = avp.getBooleanValue(); 636 else if (attribute.equals("linestraightenthreshold")) 637 UserSettings.LineStraightenThreshold = avp 638 .getIntegerValue(); 639 else if (attribute.equals("noopthreshold")) 640 UserSettings.NoOpThreshold = avp.getIntegerValue(); 641 else if (attribute.equals("formatspacingmin")) { 642 FrameUtils.MINIMUM_SPACING_RATIO = avp.getDoubleValue(); 643 } else if (attribute.equals("formatspacingmax")) { 644 FrameUtils.MAXIMUM_SPACING_RATIO = avp.getDoubleValue(); 645 } else if (attribute.equals("initialwidth")) { 646 UserSettings.InitialWidth = avp.getIntegerValue(); 647 } else if (attribute.equals("initialheight")) { 648 UserSettings.InitialHeight = avp.getIntegerValue(); 649 } else if (attribute.equals("titleposition")) { 650 UserSettings.TitlePosition = avp.getIntegerValue(); 651 } else if (attribute.equals("logging")) { 652 UserSettings.Logging = avp.getBooleanValue(); 653 } else if (attribute.equals("itemtemplate")) { 654 UserSettings.ItemTemplate = ((Text) item).getTemplateForm(); 655 } else if (attribute.equals("annotationtemplate")) { 656 UserSettings.AnnotationTemplate = ((Text) item) 657 .getTemplateForm(); 658 } else if (attribute.equals("statstemplate")) { 659 UserSettings.StatTemplate = ((Text) item).getTemplateForm(); 660 } else if (attribute.equals("commenttemplate")) { 661 UserSettings.CodeCommentTemplate = ((Text) item) 662 .getTemplateForm(); 663 } else if (attribute.equals("dottemplate")) { 664 UserSettings.DotTemplate = ((Text) item).getTemplateForm(); 665 } else if (attribute.equals("framesetdir")) { 666 String dir = getDir(avp.getValue()); 667 if (dir != null) { 668 UserSettings.FrameDirs.add(dir); 669 } 670 } else if (attribute.equals("logdir")) { 671 org.expeditee.gui.FrameIO.LOGS_DIR = getDir(avp.getValue()); 672 } else if (attribute.equals("imagedir")) { 673 String dir = getDir(avp.getValue()); 674 if (dir != null) 675 UserSettings.ImageDirs.add(0, dir); 676 } else if (attribute.equals("threading")) { 677 UserSettings.Threading = avp.getBooleanValue(); 678 } else if (attribute.equals("colorwheel")) { 679 Item.COLOR_WHEEL = getColorWheel(item); 680 } else if (attribute.equals("fillcolorwheel")) { 681 Item.FILL_COLOR_WHEEL = getColorWheel(item); 682 } else if (attribute.equals("backgroundcolorwheel")) { 683 Frame.COLOR_WHEEL = getColorWheel(item); 684 } else if (attribute.equals("framesetdirs")) { 685 UserSettings.FrameDirs.addAll(getDirs(item)); 686 } else if (attribute.equals("imagedirs")) { 687 UserSettings.ImageDirs.addAll(getDirs(item)); 688 } else if (attribute.equals("style")) { 689 UserSettings.Style = getStyle(item.getChild()); 690 } else { 691 errors.add(attributeFullCase 692 + " is not a profile frame tag"); 693 } 694 } catch (Exception e) { 695 e.printStackTrace(); 696 errors.add("Error parsing [" + item.getText() + "] on " 697 + profile.getName()); 687 698 } 688 699 } … … 692 703 693 704 private static List<Text> getStyle(Frame child) { 705 if (child == null) 706 return new LinkedList<Text>(); 707 694 708 List<Text> style = new ArrayList<Text>(8); 695 709 for (int i = 0; i < 10; i++) { … … 750 764 return alt; 751 765 752 String value = new AttributeValuePair(item.getText()).getValue().trim(); 753 if (value.length() > 0) { 754 item.setLink(value); 755 return value; 756 } else if (item.getLink() != null) 757 return item.getLink(); 766 AttributeValuePair avp = new AttributeValuePair(item.getText()); 767 assert (avp != null); 768 769 if (avp.hasPair()) { 770 item.setLink(avp.getValue()); 771 return avp.getValue(); 772 } else if (item.getLink() != null) { 773 return item.getAbsoluteLink(); 774 } 758 775 759 776 return alt; … … 1125 1142 } 1126 1143 1144 public static Item onItem(float floatX, float floatY, 1145 boolean changeLastEdited) { 1146 return onItem(DisplayIO.getCurrentFrame(), floatX, floatY, 1147 changeLastEdited); 1148 } 1149 1127 1150 /** 1128 1151 * Searches through the list of items on this frame to find one at the given … … 1135 1158 * @return The Item at the given coordinates, or NULL if none is found. 1136 1159 */ 1137 public static Item onItem(Frame toCheck, float floatX, float floatY) { 1160 public static Item onItem(Frame toCheck, float floatX, float floatY, 1161 boolean bResetLastEdited) { 1138 1162 // System.out.println("MouseX: " + floatX + " MouseY: " + floatY); 1139 1163 int x = Math.round(floatX); … … 1172 1196 // otherwise, the mouse is on the frame 1173 1197 } else { 1174 if (LastEdited != null && /* 1175 * LastEdited.isVisible() && 1176 */LastEdited.contains(x, y) 1177 && !FreeItems.getInstance().contains(LastEdited) 1178 && LastEdited.getParent() == DisplayIO.getCurrentFrame() 1179 && LastEdited.getParent().getItems().contains(LastEdited)) { 1180 LastEdited.setPermission(Permission.full); 1181 return LastEdited; 1182 } else { 1183 setLastEdited(null); 1198 if (LastEdited != null) { 1199 if (LastEdited.contains(x, y) 1200 && !FreeItems.getInstance().contains(LastEdited) 1201 && LastEdited.getParent() == DisplayIO 1202 .getCurrentFrame() 1203 && LastEdited.getParent().getItems().contains( 1204 LastEdited)) { 1205 LastEdited.setPermission(Permission.full); 1206 return LastEdited; 1207 } else if (bResetLastEdited) { 1208 setLastEdited(null); 1209 } 1184 1210 } 1185 1211 ArrayList<Item> checkList = new ArrayList<Item>(); … … 1236 1262 public synchronized static Item getCurrentItem() { 1237 1263 return onItem(DisplayIO.getCurrentFrame(), DisplayIO.getMouseX(), 1238 FrameMouseActions.getY() );1264 FrameMouseActions.getY(), true); 1239 1265 } 1240 1266 … … 1433 1459 1434 1460 yPos += spacing; 1435 profile.addText(xPos, yPos, "@HomeFrame : " + profile.getName(), null,1461 profile.addText(xPos, yPos, "@HomeFrame", null, 1436 1462 profile.getName()); 1437 1463 yPos += spacing; 1438 1464 String defaultFrameName = profile.getFramesetName() + "0"; 1439 profile.addText(xPos, yPos, "@DefaultFrame : " + defaultFrameName, null,1465 profile.addText(xPos, yPos, "@DefaultFrame", null, 1440 1466 defaultFrameName); 1441 1467 yPos += spacing; … … 1539 1565 1540 1566 public static void setLastEdited(Text lastEdited) { 1567 1541 1568 // If the lastEdited is being changed then check if its @i 1542 1569 Frame toReparse = null; 1543 1570 Frame toRecalculate = null; 1544 if (LastEdited != null) { 1571 Frame toUpdateObservers = null; 1572 1573 if (LastEdited == null) { 1574 // System.out.print("N"); 1575 } else if (LastEdited != null) { 1576 // System.out.print("T"); 1577 Frame parent = LastEdited.getParentOrCurrentFrame(); 1578 1545 1579 if (lastEdited != LastEdited) { 1546 1580 if (LastEdited.startsWith("@i")) { … … 1574 1608 } 1575 1609 } 1576 toReparse = LastEdited.getParent();1610 toReparse = parent; 1577 1611 } else if (LastEdited.recalculateWhenChanged()) { 1578 toRecalculate = LastEdited.getParentOrCurrentFrame(); 1612 toRecalculate = parent; 1613 } 1614 1615 if (parent.hasObservers()) { 1616 toUpdateObservers = parent; 1579 1617 } 1580 1618 // Update the formula if in XRay mode … … 1584 1622 } 1585 1623 if (lastEdited != LastEdited && LastEdited.getText().length() == 0) { 1586 LastEdited.getParentOrCurrentFrame().removeItem(LastEdited);1624 parent.removeItem(LastEdited); 1587 1625 } 1588 1626 } … … 1592 1630 if (toReparse != null) { 1593 1631 Parse(toReparse, false, false); 1594 } else if (toRecalculate != null) { 1595 toRecalculate.recalculate(); 1632 } else { 1633 if (toRecalculate != null) { 1634 toRecalculate.recalculate(); 1635 } 1636 1637 if (toUpdateObservers != null) { 1638 toUpdateObservers.notifyObservers(false); 1639 } 1596 1640 } 1597 1641 }
Note:
See TracChangeset
for help on using the changeset viewer.