Changeset 107
- Timestamp:
- 06/20/08 16:48:33 (16 years ago)
- Location:
- trunk/src/org/expeditee
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/actions/Misc.java
r105 r107 318 318 fontsList.append(s).append('\n'); 319 319 } 320 fontsList.deleteCharAt(fontsList.length()-1); 320 321 321 322 Text text = DisplayIO.getCurrentFrame().createNewText(); -
trunk/src/org/expeditee/actions/Simple.java
r106 r107 1133 1133 context.getPrimitives().setValue(tokens[2], 1134 1134 new SString(currentFrame.getName())); 1135 } 1136 } else if (tokens[0].equals("getcurrentitem")) { 1137 assertMinParametreCount(tokens, 1); 1138 assertVariableType(tokens[1], 1, SPointer.itemPrefix); 1139 1140 Item currentItem = FrameUtils.getCurrentItem(); 1141 1142 context.getPointers().setObject(tokens[1], currentItem); 1143 1144 // check if the user is also after line position 1145 if (currentItem != null && currentItem instanceof Text 1146 && tokens.length > 2) { 1147 Text text = (Text) currentItem; 1148 int cursorLinePos = text 1149 .getLinePosition(FrameMouseActions.getY()); 1150 context.getPrimitives().setValue(tokens[2], 1151 new SInteger(cursorLinePos + 1)); 1152 if (tokens.length > 3) { 1153 int cursorCharPos = text.getCharPosition( 1154 cursorLinePos, DisplayIO.getMouseX()) 1155 .getCharIndex(); 1156 context.getPrimitives().setValue(tokens[3], 1157 new SInteger(cursorCharPos + 1)); 1158 } 1135 1159 } 1136 1160 } … … 1724 1748 boolean success = fileContents != null; 1725 1749 if (!success) 1726 FrameGraphics.WarningMessage("Error copying " + frameToCopy.getName()); 1750 FrameGraphics.WarningMessage("Error copying " 1751 + frameToCopy.getName()); 1727 1752 FrameIO.ResumeCache(); 1728 1753 if (tokens.length > 4) { -
trunk/src/org/expeditee/gui/FrameUtils.java
r105 r107 1099 1099 */ 1100 1100 public static Item onItem(Frame toCheck, float floatX, float floatY) { 1101 //System.out.println("MouseX: " + floatX + " MouseY: " + floatY); 1102 1101 1103 int x = Math.round(floatX); 1102 1104 int y = Math.round(floatY); … … 1150 1152 if (!(FrameGraphics.isAudienceMode() && i.isAnnotation())) { 1151 1153 if (i.contains(x, y) && !Frame.FreeItems.contains(i)) { 1152 // names have copy permissions only 1153 if (i == toCheck.getNameItem()) { 1154 // i.Permission = Item.PERMISSION_TDFC; 1155 possibles.add(i); 1156 } else { 1157 // i.Permission = Item.PERMISSION_FULL; 1158 possibles.add(i); 1159 } 1154 possibles.add(i); 1160 1155 } 1161 1156 } … … 1214 1209 } 1215 1210 1216 public s tatic Item getCurrentItem() {1211 public synchronized static Item getCurrentItem() { 1217 1212 return onItem(DisplayIO.getCurrentFrame(), DisplayIO.getMouseX(), 1218 1213 FrameMouseActions.getY()); -
trunk/src/org/expeditee/items/Item.java
r106 r107 1 1 package org.expeditee.items; 2 2 3 import java.awt.BasicStroke; 3 4 import java.awt.Color; 4 5 import java.awt.Cursor; … … 38 39 public abstract class Item implements Comparable<Item>, Runnable { 39 40 41 protected final int JOIN = BasicStroke.JOIN_ROUND; 42 43 protected final int CAP = BasicStroke.CAP_BUTT; 44 40 45 // contains all dots (including this one) that form an enclosure 41 46 // if this dot is part of an enclosing shape -
trunk/src/org/expeditee/items/Line.java
r105 r107 57 57 58 58 private boolean _isCircle = false; 59 60 // TODO find out why bevel is not working61 private final int JOIN = BasicStroke.JOIN_ROUND;62 63 private final int CAP = BasicStroke.CAP_BUTT;64 59 65 60 // brush strokes used for painting this line and highlighting -
trunk/src/org/expeditee/items/Text.java
r106 r107 8 8 import java.awt.Point; 9 9 import java.awt.Polygon; 10 import java.awt.Rectangle;11 10 import java.awt.Stroke; 12 11 import java.awt.event.KeyEvent; … … 396 395 float y = getLineDrop(last) * line; 397 396 398 int x = (Math.round(getX() + caret[0]) + getJustOffset(last));397 float x = getX() + caret[0] + getJustOffset(last); 399 398 x = Math 400 399 .min( 401 400 x, 402 401 (getX() - Item.MARGIN_RIGHT - (2 * getGravity()) + getBoundsWidth())); 403 return new Point( x, Math.round(getY() + y + caret[1]));402 return new Point(Math.round(x), Math.round(getY() + y + caret[1])); 404 403 } 405 404 … … 617 616 float y = getLineDrop(current) * line; 618 617 619 int x = Math.round(getX() + caret[0])+ getJustOffset(current);618 float x = getX() + caret[0] + getJustOffset(current); 620 619 x = Math 621 620 .min( 622 621 x, 623 622 (getX() - Item.MARGIN_RIGHT - (2 * getGravity()) + getBoundsWidth())); 624 return new Point( x, Math.round(getY() + y + caret[1]));623 return new Point(Math.round(x), Math.round(getY() + y + caret[1])); 625 624 } 626 625 … … 701 700 float y = getLineDrop(current) * line; 702 701 703 return new Point(Math.round(getX() + caret[0]) 704 + getJustOffset(current), Math.round(getY() + y + caret[1])); 702 return new Point( 703 Math.round(getX() + caret[0]) + getJustOffset(current), Math 704 .round(getY() + y + caret[1])); 705 705 } 706 706 … … 715 715 * @return The position in the string of the character being pointed at. 716 716 */ 717 p rivateTextHitInfo getCharPosition(int line, int mouseX) {717 public TextHitInfo getCharPosition(int line, int mouseX) { 718 718 if (line < 0 || line >= _textLayouts.size()) 719 719 return null; … … 726 726 } 727 727 728 p rivateint getLinePosition(int mouseY) {728 public int getLinePosition(int mouseY) { 729 729 mouseY += getOffset().y; 730 730 731 int y = getY();731 float y = getY(); 732 732 733 733 for (TextLayout text : _textLayouts) { 734 734 // calculate X to ensure it is in the shape 735 Rectangle bounds = text.getLogicalHighlightShape(0,736 text.getCharacterCount()).getBounds ();735 Rectangle2D bounds = text.getLogicalHighlightShape(0, 736 text.getCharacterCount()).getBounds2D(); 737 737 738 738 if (bounds.getWidth() < 1) 739 bounds = new Rectangle((int) bounds.getMinX(), (int)bounds740 .getMinY(), 10, (int)bounds.getHeight());739 bounds.setRect(bounds.getMinX(), bounds 740 .getMinY(), 10, bounds.getHeight()); 741 741 742 742 double x = bounds.getCenterX(); 743 743 744 // if(text.getLogicalHighlightShape(0,745 // text.getCharacterCount()).contains(text.getBounds().getMinX()746 // + 10, mouseY - getY() - (y - getY())))747 744 if (bounds.contains(x, mouseY - getY() - (y - getY()))) 748 745 return _textLayouts.indexOf(text); … … 973 970 public boolean intersects(Polygon p) { 974 971 if (super.intersects(p)) { 975 int textY = getY();972 float textY = getY(); 976 973 977 974 for (TextLayout text : _textLayouts) { 978 975 // check left and right of each box 979 Rectangle textOutline = text.getLogicalHighlightShape(0, 980 text.getCharacterCount()).getBounds(); 981 textOutline.width += 2; 982 textOutline.height += 2; 983 984 textOutline.translate(getX() - 1, textY - 1); 976 Rectangle2D textOutline = text.getLogicalHighlightShape(0, 977 text.getCharacterCount()).getBounds2D(); 978 textOutline 979 .setRect(textOutline.getX() + getX() - 1, textOutline 980 .getY() 981 + textY - 1, textOutline.getWidth() + 2, 982 textOutline.getHeight() + 2); 985 983 if (p.intersects(textOutline)) 986 984 return true; … … 1000 998 mouseY += getOffset().y; 1001 999 1002 int textY = getY();1003 int textX = getX();1004 1005 Rectangle outline = getPolygon().getBounds();1000 float textY = getY(); 1001 float textX = getX(); 1002 1003 Rectangle2D outline = getPolygon().getBounds2D(); 1006 1004 1007 1005 // Check if its outside the top and left and bottom bounds 1008 if (outline.x - mouseX > gravity || outline.y - mouseY > gravity 1009 || mouseY - (outline.y + outline.height) > gravity 1010 || mouseX - (outline.x + outline.width) > gravity) { 1006 if (outline.getX() - mouseX > gravity 1007 || outline.getY() - mouseY > gravity 1008 || mouseY - (outline.getY() + outline.getHeight()) > gravity 1009 || mouseX - (outline.getX() + outline.getWidth()) > gravity) { 1011 1010 return false; 1012 1011 } … … 1014 1013 for (TextLayout text : _textLayouts) { 1015 1014 // check left and right of each box 1016 Rectangle textOutline = text.getLogicalHighlightShape(0,1017 text.getCharacterCount()).getBounds ();1015 Rectangle2D textOutline = text.getLogicalHighlightShape(0, 1016 text.getCharacterCount()).getBounds2D(); 1018 1017 1019 1018 // check if the cursor is within the top, bottom and within the 1020 1019 // gravity of right 1021 if (mouseY - textY > textOutline.y 1022 && mouseY - textY < textOutline.y + textOutline.height 1023 && mouseX - textX < textOutline.width + gravity 1020 if (mouseY - textY > textOutline.getY() 1021 && mouseY - textY < textOutline.getY() 1022 + textOutline.getHeight() 1023 && mouseX - textX < textOutline.getWidth() + gravity 1024 1024 + Item.MARGIN_RIGHT) 1025 1025 return true; … … 1353 1353 g.setColor(getPaintHighlightColor()); 1354 1354 Stroke _highlightStroke = new BasicStroke( 1355 (float) _highlightThickness, BasicStroke.CAP_BUTT, 1356 BasicStroke.JOIN_ROUND); 1355 (float) _highlightThickness, CAP, JOIN); 1357 1356 g.setStroke(_highlightStroke); 1358 1357 g.drawPolygon(getPolygon()); … … 1621 1620 // bottom of text lines... so the cursor must be between two text 1622 1621 // lines 1623 int textY = getY();1624 int textX = getX();1622 float textY = getY(); 1623 float textX = getX(); 1625 1624 1626 1625 for (TextLayout text : _textLayouts) { 1627 1626 // check left and right of each box 1628 Rectangle textOutline = text.getLogicalHighlightShape(0,1629 text.getCharacterCount()).getBounds ();1627 Rectangle2D textOutline = text.getLogicalHighlightShape(0, 1628 text.getCharacterCount()).getBounds2D(); 1630 1629 1631 1630 // check if the cursor is within the top, bottom and within the 1632 1631 // gravity of right 1633 if (y - textY > textOutline. y- NEAR_DISTANCE1634 && y - textY < textOutline. y + textOutline.height1635 + NEAR_DISTANCE1636 && x - textX < textOutline. width+ NEAR_DISTANCE)1632 if (y - textY > textOutline.getY() - NEAR_DISTANCE 1633 && y - textY < textOutline.getY() 1634 + textOutline.getHeight() + NEAR_DISTANCE 1635 && x - textX < textOutline.getWidth() + NEAR_DISTANCE) 1637 1636 return true; 1638 1637 textY += getLineDrop(text);
Note:
See TracChangeset
for help on using the changeset viewer.