Changeset 400
- Timestamp:
- 11/18/08 13:34:54 (16 years ago)
- Location:
- trunk/src/org/expeditee
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/gui/AttributeUtils.java
r376 r400 141 141 Class[] pString = { String.class }; 142 142 Class[] pInt = { int.class }; 143 Class[] pIntO = { Integer.class }; 143 144 Class[] pFloat = { float.class }; 144 145 Class[] pFloatO = { Float.class }; … … 267 268 _SetMethods.put("j", Text.class.getMethod("setJustification", 268 269 pJustification)); 269 _SetMethods.put("width", Text.class.getMethod("setWidth", pInt ));270 _SetMethods.put("w", Text.class.getMethod("setWidth", pInt ));270 _SetMethods.put("width", Text.class.getMethod("setWidth", pIntO)); 271 _SetMethods.put("w", Text.class.getMethod("setWidth", pIntO)); 271 272 272 273 _SetMethods.put("size", Item.class.getMethod("setSize", pFloat)); -
trunk/src/org/expeditee/gui/DisplayIO.java
r390 r400 23 23 import org.expeditee.items.Item; 24 24 import org.expeditee.items.ItemParentStateChangedEvent; 25 import org.expeditee.items.Permission;26 25 import org.expeditee.items.Picture; 27 26 import org.expeditee.items.Text; … … 72 71 * The title to display in the Title bar. 73 72 */ 74 public static final String TITLE = "Exp31Oct2008A";73 public static String TITLE = "ExpDev"; 75 74 76 75 private DisplayIO() { -
trunk/src/org/expeditee/gui/FrameCreator.java
r328 r400 195 195 toAdd.setOffset(0, 0); 196 196 toAdd.setID(_current.getNextItemID()); 197 toAdd.setRightMargin(FrameGraphics.getMaxFrameSize().width );197 toAdd.setRightMargin(FrameGraphics.getMaxFrameSize().width, true); 198 198 199 199 _current.addItem(toAdd); -
trunk/src/org/expeditee/gui/FrameIO.java
r376 r400 680 680 681 681 // Assign a width to the title. 682 titleItem.setRightMargin(template.getNameItem().getX() );682 titleItem.setRightMargin(template.getNameItem().getX(), true); 683 683 684 684 return template; -
trunk/src/org/expeditee/gui/FrameKeyboardActions.java
r376 r400 163 163 // DisplayIO.UpdateTitle(); 164 164 text = createText(ch); 165 justify(text);165 text.justify(false); 166 166 167 167 FrameUtils.setLastEdited(text); … … 193 193 */ 194 194 if (oldY < newMouse.y) { 195 // float diff = newMouse.y - oldY;195 // float diff = newMouse.y - oldY; 196 196 // System.out.print("c"); 197 197 Rectangle rect = text.getPolygon().getBounds(); 198 199 // Text lastEdited = FrameUtils.getLastEdited();200 // FrameUtils.setLastEdited(null);201 198 199 // Text lastEdited = FrameUtils.getLastEdited(); 200 // FrameUtils.setLastEdited(null); 201 202 202 Item justBelow = FrameUtils.onItem(DisplayIO.getCurrentFrame(), 203 203 text.getX() + 10, rect.y + rect.height + 1, false); 204 205 //FrameUtils.setLastEdited(lastEdited); 206 207 //Dont drop unless 208 if (justBelow != null && justBelow instanceof Text && justBelow != on) { 204 205 // FrameUtils.setLastEdited(lastEdited); 206 207 // Dont drop unless 208 if (justBelow != null && justBelow instanceof Text 209 && justBelow != on) { 209 210 // Drop all the items below it down! 210 211 // Get the list of items that must be dropped … … 237 238 // DisplayIO.getCurrentFrame().removeItem(text); 238 239 DisplayIO.setCursor(Item.DEFAULT_CURSOR); 239 }240 }241 }242 243 /**244 * @param text245 */246 private static void justify(Text text) {247 // Check if that text item is inside an enclosing rectangle...248 // Set its max width accordingly249 Polygon enclosure = FrameUtils.getEnlosingPolygon();250 if (enclosure != null) {251 Rectangle bounds = enclosure.getBounds();252 text.setRightMargin(bounds.x + bounds.width);253 } else {254 text.setRightMargin(FrameGraphics.getMaxFrameSize().width);255 256 // Check for the annotation that restricts the width of text items257 // on the frame258 String widthString;259 if ((widthString = text.getParentOrCurrentFrame()260 .getAnnotationValue("maxwidth")) != null) {261 try {262 int width = text.getWidth();263 int maxWidth = Integer.parseInt(widthString);264 if (maxWidth < width)265 text.setWidth(maxWidth);266 } catch (NumberFormatException nfe) {267 }268 240 } 269 241 } … … 630 602 } 631 603 textItem.setX(FrameMouseActions.getX()); 632 justify(textItem);604 textItem.justify(false); 633 605 DisplayIO.getCurrentFrame().addItem(textItem); 634 606 return textItem; … … 969 941 if (text == null) { 970 942 for (Text t : currentFrame.getBodyTextItems(false)) { 971 justify(t);943 t.justify(true); 972 944 } 973 945 … … 978 950 // text.setWidth(text.getBoundsWidth() - Item.MARGIN_RIGHT 979 951 // - UserSettings.Gravity); 980 justify(text);952 text.justify(true); 981 953 break; 982 954 case KeyEvent.VK_S: … … 1435 1407 || FreeItems.itemsAttachedToCursor()) { 1436 1408 dummyItem.getParentOrCurrentFrame().removeItem(dummyItem); 1437 dummyItem.setRightMargin(FrameGraphics.getMaxFrameSize().width); 1409 dummyItem.setRightMargin(FrameGraphics.getMaxFrameSize().width, 1410 false); 1438 1411 } else { 1439 1412 dummyItem.setWidth(toDropFrom.getWidth()); -
trunk/src/org/expeditee/gui/FrameUtils.java
r390 r400 1091 1091 MessageBay.warningMessage("Exception occured when loading " 1092 1092 + i.getClass().getSimpleName() + "(ID: " + i.getID() 1093 + ") " + e.getMessage() );1093 + ") " + e.getMessage() != null ? e.getMessage() : ""); 1094 1094 } 1095 1095 } -
trunk/src/org/expeditee/gui/UserSettings.java
r355 r400 72 72 static { 73 73 String jarPath = getJarLocation(); 74 if (jarPath != null) 74 if (jarPath != null){ 75 75 FrameIO.changeParentFolder(jarPath); 76 } 76 77 else 77 78 FrameIO.changeParentFolder("." + File.separator + "expeditee" … … 117 118 118 119 int lastFileSeparator = jarName.lastIndexOf(File.separator); 120 121 DisplayIO.TITLE = jarName.substring(lastFileSeparator + 1, jarName.length() - 4); 122 119 123 return jarName.substring(0, lastFileSeparator + 1); 120 124 } -
trunk/src/org/expeditee/io/Conversion.java
r390 r400 400 400 return Float.parseFloat(value); 401 401 } 402 403 if (type.equals(Integer.class)) { 404 if (orig instanceof Integer 405 && (value.startsWith("+") || value.startsWith("-"))) { 406 value = value.replace("+", ""); 407 408 return ((Integer) orig) + Integer.parseInt(value); 409 } 410 411 if (value.length() == 0 || value.equals("null")) 412 return null; 413 414 return Integer.parseInt(value); 415 } 402 416 403 417 if (type.equals(double.class)) { … … 583 597 584 598 // integers can also be returned immediately 585 if (output instanceof Integer && (Integer) output >= 0)599 if (output instanceof Integer) 586 600 return "" + output; 587 601 -
trunk/src/org/expeditee/io/DefaultFrameWriter.java
r376 r400 113 113 _ItemTags 114 114 .put("m", Text.class.getMethod("getInitialSpacing", param)); 115 _ItemTags.put("w", Text.class.getMethod("getWidth ", param));115 _ItemTags.put("w", Text.class.getMethod("getWidthToSave", param)); 116 116 _ItemTags.put("k", Text.class.getMethod("getJustification", param)); 117 117 -
trunk/src/org/expeditee/io/FrameReader.java
r362 r400 28 28 protected static Class[] pString = { String.class }; 29 29 protected static Class[] pInt = { int.class }; 30 protected static Class[] pIntO = { Integer.class }; 30 31 protected static Class[] pFloat = { float.class }; 31 32 protected static Class[] pFloatO = { Float.class }; … … 115 116 _ItemTags.put('b', Text.class.getMethod("setLetterSpacing", pInt)); 116 117 _ItemTags.put('m', Text.class.getMethod("setInitialSpacing", pInt)); 117 _ItemTags.put('w', Text.class.getMethod("setWidth", pInt ));118 _ItemTags.put('w', Text.class.getMethod("setWidth", pIntO)); 118 119 _ItemTags.put('k', Text.class.getMethod("setJustification", pJustification)); 119 120 -
trunk/src/org/expeditee/io/KMSReader.java
r390 r400 106 106 _ItemTags.put("b", Text.class.getMethod("setLetterSpacing", pInt)); 107 107 _ItemTags.put("m", Text.class.getMethod("setInitialSpacing", pInt)); 108 _ItemTags.put("w", Text.class.getMethod("setWidth", pInt ));108 _ItemTags.put("w", Text.class.getMethod("setWidth", pIntO)); 109 109 _ItemTags.put("k", Text.class.getMethod("setJustification", pJustification)); 110 110 -
trunk/src/org/expeditee/items/Item.java
r390 r400 191 191 * the user uses backspace to delete a text line end 192 192 */ 193 dest._anchorBottom = source._anchorBottom;194 dest._anchorRight = source._anchorRight;193 //dest._anchorBottom = source._anchorBottom; 194 //dest._anchorRight = source._anchorRight; 195 195 196 196 dest.setFormula(source.getFormula()); … … 946 946 } 947 947 948 public int getWidth() { 949 return 0; 948 public Integer getWidthToSave() { 949 return getWidth(); 950 } 951 952 public Integer getWidth() { 953 return null; 950 954 } 951 955 … … 1862 1866 } 1863 1867 1864 public void setWidth( intwidth) throws UnsupportedOperationException {1868 public void setWidth(Integer width) throws UnsupportedOperationException { 1865 1869 throw new UnsupportedOperationException( 1866 1870 "Item type does not support width attribute!"); 1867 1871 } 1868 1872 1869 public void setRightMargin(int i) { 1870 setWidth(i - getX() - Item.MARGIN_LEFT); 1873 public void setRightMargin(int i, boolean fixWidth) { 1874 int newWidth = i - getX() - Item.MARGIN_LEFT; 1875 if(!fixWidth){ 1876 newWidth *= -1; 1877 } 1878 1879 setWidth(newWidth); 1871 1880 } 1872 1881 … … 2809 2818 return _locks.contains(item); 2810 2819 }*/ 2820 2821 2811 2822 } -
trunk/src/org/expeditee/items/Picture.java
r376 r400 273 273 274 274 @Override 275 public void setWidth( intwidth) {275 public void setWidth(Integer width) { 276 276 _scale = width * 1F / (_end.x - _start.x); 277 277 } … … 289 289 */ 290 290 @Override 291 public intgetWidth() {291 public Integer getWidth() { 292 292 return Math.round((_end.x - _start.x) * _scale); 293 293 } -
trunk/src/org/expeditee/items/Text.java
r390 r400 47 47 */ 48 48 public class Text extends Item { 49 private static final int ADJUST_WIDTH_THRESHOLD = 200; 50 49 51 public static String LINE_SEPARATOR = System.getProperty("line.separator"); 50 52 … … 98 100 public static final int PAGE_UP = 8; 99 101 100 private int _maxWidth = -1;102 private Integer _maxWidth = null; 101 103 102 104 private Justification _justification = Justification.left; … … 181 183 */ 182 184 @Override 183 public void setWidth(int width) { 184 invalidateAll(); 185 // 0 is the default 186 if (width <= 0) { 187 width = -1; 185 public void setWidth(Integer width) { 186 invalidateAll(); 187 188 if (width == null) { 188 189 setJustification(Justification.left); 190 setRightMargin(FrameGraphics.getMaxFrameSize().width, false); 191 return; 189 192 } 190 193 … … 194 197 } 195 198 199 public Integer getWidthToSave() { 200 return _maxWidth; 201 } 202 196 203 /** 197 204 * Returns the maximum width of this Text item when justifcation is used. 198 * Note the returned value may be -1, which indicates that there is no 199 * maximum size set 205 * If the width is negative, it means no explicit width has been set 200 206 * 201 207 * @return The maximum width of this Text item when justification is used 202 208 */ 203 209 @Override 204 public int getWidth() { 210 public Integer getWidth() { 211 if (_maxWidth == null || _maxWidth <= 0) 212 return null; 205 213 return _maxWidth; 214 } 215 216 public Integer getAbsoluteWidth() { 217 if (_maxWidth == null) { 218 return Integer.MAX_VALUE; 219 } 220 221 return Math.abs(_maxWidth); 206 222 } 207 223 … … 224 240 225 241 // Only justification left works with 0 width 226 if (just != Justification.left && getWidth() <= 0) {227 228 229 }242 // if (just != null && just != Justification.left && !hasWidth()) { 243 // // TODO Tighten this up so it subtracts the margin widths 244 // setWidth(getBoundsWidth()); 245 // } 230 246 231 247 _justification = just; … … 247 263 248 264 private int getJustOffset(TextLayout layout) { 249 if (getWidth() < 0)250 return 0;251 252 265 if (getJustification() == Justification.center) 253 return (int) ((get Width() - layout.getAdvance()) / 2);266 return (int) ((getAbsoluteWidth() - layout.getAdvance()) / 2); 254 267 else if (getJustification() == Justification.right) 255 return (int) (get Width() - layout.getAdvance());268 return (int) (getAbsoluteWidth() - layout.getAdvance()); 256 269 257 270 return 0; … … 269 282 setText(text, false); 270 283 } 271 284 272 285 public void setText(String text, Boolean clearCache) { 273 286 // if (_text != null && text.length() < _text.length()) … … 279 292 * mode 280 293 */ 281 if (clearCache){294 if (clearCache) { 282 295 clearCache(); 283 } 284 296 } 297 285 298 rebuild(true); 286 299 invalidateAll(); … … 1314 1327 // If its justification right or center then DONT limit the width 1315 1328 if (getJustification() != null) { 1316 maxX = Item.MARGIN_RIGHT + get Width();1329 maxX = Item.MARGIN_RIGHT + getAbsoluteWidth(); 1317 1330 } 1318 1331 … … 1368 1381 1369 1382 if (limitWidth) { 1370 if (getWidth() > 0) 1371 width = getWidth(); 1383 width = getAbsoluteWidth(); 1372 1384 // else if (getMaxWidth() > 0) 1373 1385 // width = Math.max(50, getMaxWidth() - getX() … … 1400 1412 _lineOffsets.add(_lineBreaker.getPosition()); 1401 1413 1402 if ( getWidth() > 0 &&getJustification() == Justification.full1414 if (/* hasWidth() && */getJustification() == Justification.full 1403 1415 && _lineBreaker.getPosition() < _text.length()) 1404 1416 layout = layout.getJustifiedLayout(width); … … 1409 1421 updatePolygon(); 1410 1422 1423 } 1424 1425 private boolean hasFixedWidth() { 1426 assert (_maxWidth != null); 1427 if(_maxWidth == null){ 1428 justify(false); 1429 } 1430 return _maxWidth > 0; 1411 1431 } 1412 1432 … … 1658 1678 copy.setSpacing(getSpacing()); 1659 1679 copy.setInitialSpacing(getInitialSpacing()); 1680 1681 copy.setWidth(getWidth()); 1660 1682 copy.setJustification(getJustification()); 1661 1683 copy.setLetterSpacing(getLetterSpacing()); … … 1669 1691 } 1670 1692 copy.setHidden(!isVisible()); 1671 // copy.setWidth(getWidth());1672 1693 return copy; 1673 1694 } … … 1856 1877 setPosition(MARGIN_LEFT, MARGIN_LEFT + getBoundsHeight()); 1857 1878 Frame modelFrame = getParentOrCurrentFrame(); 1858 if (modelFrame != null) { 1859 setRightMargin(modelFrame.getNameItem().getX() 1860 - MARGIN_LEFT); 1879 if (modelFrame != null) { 1880 setRightMargin(modelFrame.getNameItem().getX() - MARGIN_LEFT, true); 1861 1881 } else { 1862 System.out.print("Error: text.resetTitlePosition, getParent or currentFrame returned null"); 1863 setRightMargin(MARGIN_LEFT); 1882 System.out 1883 .print("Error: text.resetTitlePosition, getParent or currentFrame returned null"); 1884 setRightMargin(MARGIN_LEFT, true); 1864 1885 } 1865 1886 } … … 1943 1964 if (isLineEnd()) 1944 1965 DisplayIO.setCursor(Item.DEFAULT_CURSOR); 1966 1967 if (!hasFixedWidth()) { 1968 int frameWidth = FrameGraphics.getMaxFrameSize().width; 1969 /* 1970 * Only change width if it is more than 150 pixels from the right of 1971 * the screen 1972 */ 1973 if (frameWidth - getX() > ADJUST_WIDTH_THRESHOLD) { 1974 justify(false); 1975 //setRightMargin(frameWidth, false); 1976 } 1977 } 1978 } 1979 1980 public void justify(boolean fixWidth) { 1981 Integer width = FrameGraphics.getMaxFrameSize().width; 1982 1983 // Check if that text item is inside an enclosing rectangle... 1984 // Set its max width accordingly 1985 Polygon enclosure = FrameUtils.getEnlosingPolygon(); 1986 if (enclosure != null) { 1987 Rectangle bounds = enclosure.getBounds(); 1988 if(bounds.width > 200 && getX() < bounds.width / 3 + bounds.x){ 1989 width = bounds.x + bounds.width; 1990 } 1991 } 1992 1993 if (getWidth() == null) 1994 setRightMargin(width, fixWidth); 1995 1996 // Check for the annotation that restricts the width of text items 1997 // on the frame 1998 String widthString; 1999 if ((widthString = getParentOrCurrentFrame().getAnnotationValue( 2000 "maxwidth")) != null) { 2001 try { 2002 int oldWidth = getWidth(); 2003 int maxWidth = Integer.parseInt(widthString); 2004 if (maxWidth < oldWidth) 2005 setWidth(maxWidth); 2006 } catch (NumberFormatException nfe) { 2007 } 2008 2009 } 1945 2010 } 1946 2011 … … 2210 2275 public void scale(Float scale, int originX, int originY) { 2211 2276 setSize(getSize() * scale); 2277 2212 2278 setWidth(Math.round(getWidth() * scale)); 2213 2279 super.scale(scale, originX, originY); -
trunk/src/org/expeditee/items/widgets/InteractiveWidget.java
r374 r400 183 183 184 184 String classname = tokens[0]; 185 if (classname.charAt(0) == '$') 186 classname = Actions.getClassName(classname.substring(1)); 185 if (classname.charAt(0) == '$'){ 186 String shortClassname = classname.substring(1); 187 classname = Actions.getClassName(shortClassname); 188 189 if (classname == null) // ensure it exists 190 throw new InteractiveWidgetNotAvailableException(shortClassname 191 + " does not exist or is not an InteractiveWidget"); 192 } 187 193 // Attempt to locate the class using reflection 188 194 Class<?> iwclass = findIWidgetClass(classname); … … 234 240 */ 235 241 private static Class findIWidgetClass(String classname) { 242 if(classname == null) 243 return null; 244 236 245 try { 237 246 Class c = Class.forName(classname); // attempt to find the class
Note:
See TracChangeset
for help on using the changeset viewer.