Ignore:
Timestamp:
05/23/08 09:02:59 (16 years ago)
Author:
ra33
Message:

Added lots of stuff

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/items/Text.java

    r71 r72  
    2222import java.util.List;
    2323
     24import org.expeditee.gui.DisplayIO;
    2425import org.expeditee.gui.FrameGraphics;
     26import org.expeditee.gui.FrameKeyboardActions;
    2527import org.expeditee.gui.FrameMouseActions;
    2628
     
    745747        }
    746748
     749        public static final String MONOSPACED_FONT = "monospaced";
     750
    747751        public static final String[] FONT_WHEEL = { "sansserif", "monospaced",
    748752                        "serif", "dialog", "dialoginput" };
     
    751755
    752756        private static final int NEARBY_GRAVITY = 2;
     757
     758        private static final int MINIMUM_FONT_SIZE = 8;
    753759
    754760        public void toggleFontFamily() {
     
    939945                }
    940946
    941                 // check if the cursor is on the left border of the bounding box
    942                 if (Math.abs(mouseX - LEFT_MARGIN - outline.x) <= gravity) {
    943                         return true;
    944                 }
    945 
    946947                for (TextLayout text : _textLayouts) {
    947948                        // check left and right of each box
     
    953954                        if (mouseY - textY > textOutline.y
    954955                                        && mouseY - textY < textOutline.y + textOutline.height
    955                                         && mouseX - textX < textOutline.width + gravity)
     956                                        && mouseX - textX < textOutline.width + gravity
     957                                                        + Item.MARGIN_RIGHT)
    956958                                return true;
    957959                        textY += getLineDrop(text);
     
    9991001                }
    10001002
    1001                 minX -= Item.MARGIN_RIGHT;
    1002 
    1003                 if (getWidth() > 0)
    1004                         maxX = getWidth();
     1003                minX -= getLeftMargin();
     1004                maxX += Item.MARGIN_RIGHT;
    10051005
    10061006                _poly.addPoint(minX - getGravity(), minY - getGravity());
     
    10081008                _poly.addPoint(maxX + getGravity(), maxY + getGravity());
    10091009                _poly.addPoint(minX - getGravity(), maxY + getGravity());
    1010 
    1011                 // _poly.addPoint(minX, minY);
    1012                 // _poly.addPoint(maxX, minY);
    1013                 // _poly.addPoint(maxX, maxY);
    1014                 // _poly.addPoint(minX, maxY);
     1010        }
     1011
     1012        /**
     1013         * Gets the distance between the start of the text and the left border of
     1014         * the item. This distance changes depending on whether or not the item is
     1015         * linked or has an associated action.
     1016         *
     1017         * @return the gap size in pixels
     1018         */
     1019        private int getLeftMargin() {
     1020                return ((getLinkMark() && getLink() != null)
     1021                                || (getActionMark() && getAction() != null) ? Item.MARGIN_LEFT
     1022                                - Item.MARGIN_RIGHT : Item.MARGIN_RIGHT);
    10151023        }
    10161024
     
    13891397        @Override
    13901398        public void setSize(int size) {
    1391                 setFont(getPaintFont().deriveFont((float) size));
     1399                if (size >= MINIMUM_FONT_SIZE)
     1400                        setFont(getPaintFont().deriveFont((float) size));
    13921401        }
    13931402
     
    13991408                                return;
    14001409
    1401                         /*
    1402                          * // Remove 'a: ' from the begining if it is there if
    1403                          * (_text.length() > 3 && _text.charAt(0) == 'a' && _text.charAt(1) ==
    1404                          * ':') { _text.delete(0, 2); while (_text.charAt(0) == ' ')
    1405                          * _text.delete(0, 1); }
    1406                          */
    14071410                        _text.insert(0, "@");
    14081411
     
    14181421                                return;
    14191422
     1423                        if (_text.length() == 1) {
     1424                                // Remove and replace with a dot
     1425                                FrameKeyboardActions.replaceText(this);
     1426
     1427                                DisplayIO.setCursorPosition(this.getPosition());
     1428                                return;
     1429                        }
     1430
    14201431                        _text.deleteCharAt(0);
    14211432
     
    14321443        @Override
    14331444        public boolean isAnnotation() {
    1434                 if (_text != null && _text.length() > 0 && _text.indexOf("@") == 0)
     1445                if (_text != null && _text.length() > 0 && _text.charAt(0) == '@')
    14351446                        return true;
    14361447
Note: See TracChangeset for help on using the changeset viewer.