Ignore:
Timestamp:
05/30/08 10:14:43 (16 years ago)
Author:
ra33
Message:

Added some more unit tests
Did a bunch of refactoring
AND added a few new features... @b @v were the most significant

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/gui/Frame.java

    r78 r80  
    3535public class Frame implements ImageObserver {
    3636
    37         public static final Color[] COLOR_WHEEL = { Color.BLACK, Color.GRAY,
     37        public static Color[] COLOR_WHEEL = { Color.BLACK, Color.WHITE, Color.GRAY,
    3838                        new Color(235, 235, 235), new Color(225, 225, 255),
    3939                        new Color(195, 255, 255), new Color(225, 255, 225),
     
    6060        private String _frozenDate = null;
    6161
    62         private Color _background;
    63 
    64         private Color _foreground = Item.DEFAULT_FOREGROUND;
     62        // Background color is clear
     63        private Color _background = null;
     64
     65        // Foreground color is automatic by default
     66        private Color _foreground = null;
    6567
    6668        public String path;
     
    236238                        }
    237239                }
    238                 bodyTextItems.remove(getTitle());
     240                bodyTextItems.remove(getTitleItem());
    239241
    240242                return bodyTextItems;
     
    285287         */
    286288        public void setTitle(String title) {
    287                 if (title == null || title == "")
     289                if (title == null || title.equals(""))
    288290                        return;
    289291
     
    292294                // remove any numbering this title has
    293295                title = title.replaceAll("^\\d*[.] *", "");
    294                 Text frameTitle = getTitle();
     296                Text frameTitle = getTitleItem();
    295297
    296298                if (frameTitle == null) {
     
    305307                        addItem(frameTitle);
    306308                } else {
     309                        // If it begins with a tag remove it
     310
     311                        // Remove the @ symbol if it is there
     312                        title = ItemUtils.StripTagSymbol(title);
    307313                        frameTitle.setText(title);
    308                         title = ItemUtils.StripTagSymbol(title);
     314                        // If the @ symbol is followed by numbering or a bullet remove that
     315                        // too
    309316                        String autoBulletText = FrameKeyboardActions.getAutoBullet(title);
    310317                        if (autoBulletText.length() > 0)
     
    314321                // Brook: Cannot figure what is going on above... widget annot titles
    315322                // should be stripped always
    316                 if (ItemUtils
    317                                 .isTag(frameTitle, ItemUtils.GetTag(ItemUtils.TAG_IWIDGET))) {
     323                if (ItemUtils.startsWithTag(frameTitle, ItemUtils
     324                                .GetTag(ItemUtils.TAG_IWIDGET))) {
    318325                        frameTitle.stripFirstWord();
    319326                }
     
    325332        }
    326333
    327         public Text getTitle() {
     334        public Text getTitleItem() {
    328335                List<Item> items = getItems();
    329336                for (Item i : items) {
    330337                        if (i instanceof Text && i.getX() < UserSettings.TitlePosition
    331                                         && i.getY() < UserSettings.TitlePosition)
     338                                        && i.getY() < UserSettings.TitlePosition && i.getY() > 0)
    332339                                return (Text) i;
    333340                }
     
    336343        }
    337344
    338         public Item getFrameNameItem() {
     345        public String getTitle() {
     346                Text title = getTitleItem();
     347                if (title == null)
     348                        return getName();
     349
     350                return title.getFirstLine();
     351        }
     352
     353        public Item getNameItem() {
    339354                return _frameName;
    340355        }
     
    424439        }
    425440
    426         public void setFrameName(String framename) {
     441        public void setName(String framename) {
    427442                int num = Conversion.getFrameNumber(framename);
    428443                String frameset = Conversion.getFrameset(framename, false);
    429444
    430                 setFrameName(frameset, num);
     445                setName(frameset, num);
    431446        }
    432447
     
    465480         * @return The Frame number of this Frame or -1 if it is not set.
    466481         */
    467         public int getFrameNumber() {
     482        public int getNumber() {
    468483                return _number;
    469484        }
     
    575590                        _body.add(item);
    576591                        item.setParent(this);
     592
     593                        // If the item is a line end and has constraints with items already
     594                        // on the frame then make sure the constraints hold
     595                        if (item.isLineEnd()) {
     596                                item.setPosition(item.getPosition());
     597                        }
    577598
    578599                        _sorted = false;
     
    636657         *            The List of Items to add to the undo stack.
    637658         */
    638         public void addAllToUndo(List<Item> items) {
     659        public void addAllToUndo(Collection<Item> items) {
    639660                if (items.size() < 1)
    640661                        return;
     
    718739        }
    719740
    720         public String getFrameName() {
     741        public String getName() {
    721742                return getFramesetName() + _number;
    722743        }
     
    765786                _background = back;
    766787                change();
    767                 FrameGraphics.Repaint();
     788                // FrameGraphics.Repaint();
    768789        }
    769790
     
    784805                _foreground = front;
    785806                change();
    786                 FrameGraphics.Repaint();
     807                // FrameGraphics.Repaint();
    787808        }
    788809
     
    792813
    793814        public Color getPaintForegroundColor() {
    794                 final int GRAY = 127;
     815                final int GRAY = Color.gray.getBlue();
    795816                final int THRESHOLD = 10;
    796817
     
    802823                                return Color.WHITE;
    803824
    804                         Color fore = new Color(Math.abs(255 - back.getRed()), Math
    805                                         .abs(255 - back.getGreen()), Math.abs(255 - back.getBlue()));
     825                        Color fore = new Color(
     826                                        Math.abs(Conversion.RGB_MAX - back.getRed()), Math
     827                                                        .abs(Conversion.RGB_MAX - back.getGreen()), Math
     828                                                        .abs(Conversion.RGB_MAX - back.getBlue()));
    806829                        return fore;
    807                         // return Item.DEFAULT_FOREGROUND;
    808830                }
    809831
     
    11671189        public boolean equals(Object o) {
    11681190                if (o instanceof String) {
    1169                         return (String.CASE_INSENSITIVE_ORDER.compare((String) o,
    1170                                         getFrameName()) == 0);
     1191                        return (String.CASE_INSENSITIVE_ORDER
     1192                                        .compare((String) o, getName()) == 0);
    11711193                }
    11721194
    11731195                if (o instanceof Frame) {
    1174                         return getFrameName().equals(((Frame) o).getFrameName());
     1196                        return getName().equals(((Frame) o).getName());
    11751197                }
    11761198
     
    11881210
    11891211                List<Item> copies = ItemUtils.CopyItems(toMergeWith.getItems());
    1190                 copies.remove(toMergeWith.getFrameNameItem());
     1212                copies.remove(toMergeWith.getNameItem());
    11911213
    11921214                for (Item i : copies) {
     
    12341256                List<Item> newBody = new ArrayList<Item>(0);
    12351257                for (Item i : _body)
    1236                         if (i.isAnnotation() || i == getFrameNameItem() || i == getTitle())
     1258                        if (i.isAnnotation() || i == getNameItem() || i == getTitleItem())
    12371259                                newBody.add(i);
    12381260
     
    13001322                // check for an updated template...
    13011323                for (Item i : this.getItems()) {
    1302                         if (ItemUtils.isTag(i, templateTag)) {
     1324                        if (ItemUtils.startsWithTag(i, templateTag)) {
    13031325                                t = (Text) i;
    13041326                                break;
     
    14011423         */
    14021424        public boolean isNormalTextItem(Item it) {
    1403                 if (it instanceof Text && it != getTitle() && it != _frameName
     1425                if (it instanceof Text && it != getTitleItem() && it != _frameName
    14041426                                && !((Text) it).isSpecialAnnotation()) {
    14051427                        return true;
     
    14551477                        if (it instanceof Text) {
    14561478                                Text t = (Text) it;
    1457                                 if (t.getTextNoList().toLowerCase().startsWith("@start")
    1458                                                 || t.getTextNoList().toLowerCase().equals("@start:")) {
     1479                                if (t.getText().toLowerCase().startsWith("@start")
     1480                                                || t.getText().toLowerCase().equals("@start:")) {
    14591481                                        t.stripFirstWord();
    14601482
    1461                                         if (t.getTextNoList().equals(""))
     1483                                        if (t.getText().equals(""))
    14621484                                                DisplayIO.getCurrentFrame().removeItem(t);
    14631485                                        if (!Frame.itemAttachedToCursor()) {
     
    14911513                }
    14921514
    1493                 return _frameName.getTextNoList();
     1515                return _frameName.getText();
    14941516        }
    14951517
     
    14991521        }
    15001522
    1501         public void setFrameName(String frameset, int i) {
     1523        public void setName(String frameset, int i) {
    15021524                setFrameset(frameset);
    15031525                setFrameNumber(i);
Note: See TracChangeset for help on using the changeset viewer.