Ignore:
Timestamp:
08/27/08 09:18:49 (16 years ago)
Author:
ra33
Message:
 
File:
1 edited

Legend:

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

    r279 r282  
    1919import javax.swing.SwingUtilities;
    2020
     21import org.expeditee.gui.AttributeUtils;
    2122import org.expeditee.gui.Browser;
    2223import org.expeditee.gui.DisplayIO;
     
    133134                text = text.trim();
    134135
     136                // Check starts with the widget tag and seporator
     137                if (!text.startsWith(TAG + ":"))
     138                        throw new IllegalArgumentException("Source text must begin with \""
     139                                        + TAG + ":\"");
     140
     141                text = text.substring(TAG.length() + 1).trim();
     142
    135143                int index = 0;
    136                 if (text.length() > TAG.length() + 1) {
    137                         index = text.indexOf(':', TAG.length() + 1); // used for
     144                if (text.length() > 0) {
     145                        index = text.indexOf(':'); // used for
    138146                        // signifying start
    139                         // of
    140                 }
    141 
    142                 // arguments
     147                        // of arguments
     148                }
     149
    143150                if (index == 0)
    144151                        throw new IllegalArgumentException("Source text must begin with \""
     
    148155                                0, index).split(" ");
    149156
    150                 // Check starts with the widget tag and seporator
    151                 if (tokens.length == 0 || !tokens[0].equals(TAG + ":"))
    152                         throw new IllegalArgumentException("Source text must begin with \""
    153                                         + TAG + ":\"");
    154 
    155157                float width = -1, height = -1;
    156158
    157                 if (tokens.length < 2)
     159                if (tokens.length < 1)
    158160                        throw new IllegalArgumentException(
    159161                                        "Missing widget class name in source text");
     
    161163                try {
    162164
    163                         if (tokens.length >= 3) { // parse optional width
    164                                 width = Integer.parseInt(tokens[2]);
     165                        if (tokens.length >= 2) { // parse optional width
     166                                width = Integer.parseInt(tokens[1]);
    165167                                width = (width <= 0) ? width = -1 : width;
    166168                        }
    167169
    168                         if (tokens.length >= 4) { // parse optional height
    169                                 height = Integer.parseInt(tokens[3]);
     170                        if (tokens.length >= 3) { // parse optional height
     171                                height = Integer.parseInt(tokens[2]);
    170172                                height = (height <= 0) ? height = -1 : height;
    171173                        }
     
    176178                }
    177179
    178                 if (tokens.length > 4)
     180                if (tokens.length > 3)
    179181                        throw new IllegalArgumentException(
    180182                                        "to many arguments given before \":\" in source text");
    181183
    182                 String classname = tokens[1];
     184                String classname = tokens[0];
    183185                if (classname.charAt(0) == '$')
    184186                        classname = "org.expeditee.items.widgets." + classname.substring(1);
     
    704706
    705707        public void setPosition(int x, int y) {
    706                 if (x == getX() && y == getY()) return;
     708                if (x == getX() && y == getY())
     709                        return;
    707710
    708711                boolean vfloating[] = new boolean[] { _d1.isFloating(),
     
    925928                                                .getCurrentMouseEvent())
    926929                        return; // already dealt with this event
    927                
     930
    928931                _lastParentStateChangedEvent = e;
    929                 _lastParentStateChangedMouseEvent = MouseEventRouter.getCurrentMouseEvent();
     932                _lastParentStateChangedMouseEvent = MouseEventRouter
     933                                .getCurrentMouseEvent();
    930934
    931935                switch (e.getEventType()) {
     
    10721076        /**
    10731077         *
    1074          * @return
    1075          *              The current bounds for this widget. Never null.
     1078         * @return The current bounds for this widget. Never null.
    10761079         */
    10771080        public Rectangle getBounds() {
     
    11551158                if (_textRepresentation.getLink() != null
    11561159                                || _textRepresentation.hasAction()) {
    1157                         //System.out.println("Painted link");
     1160                        // System.out.println("Painted link");
    11581161                        _textRepresentation.paintLinkGraphic(g, getLinkX(), getLinkY());
    11591162
     
    14931496
    14941497                if (newData != null) {
    1495                         if (data != null) data.add(newData);
     1498                        if (data != null)
     1499                                data.add(newData);
    14961500                        else {
    14971501                                data = new LinkedList<String>();
    14981502                                data.add(newData);
    14991503                                getCurrentRepresentation().setData(data);
    1500                                
    1501                         }
    1502                 } 
     1504
     1505                        }
     1506                }
    15031507        }
    15041508
     
    15071511         *
    15081512         * @param link
    1509          *              The new frame link. Can be null (for no link)
    1510          *              
     1513         *            The new frame link. Can be null (for no link)
     1514         *
    15111515         */
    15121516        public void setLink(String link) {
     
    15181522                        invalidateLink();
    15191523        }
    1520        
    1521         public void setBackgroundColor(Color c){
     1524
     1525        public void setBackgroundColor(Color c) {
    15221526                getSource().setBackgroundColor(c);
    15231527        }
    1524        
    1525         /**
    1526          * @return
    1527          *              The link for this widget. Null if none.
     1528
     1529        /**
     1530         * @return The link for this widget. Null if none.
    15281531         */
    15291532        public String getLink() {
    15301533                return _textRepresentation.getLink();
    15311534        }
    1532        
    1533 
    1534         /**
    1535          * <b>Note:</b> That if the widget has no parent (e.g. the widget is a free-item) then
    1536          * the absolute link returned will be for the frameset of the current frame.
    1537          *
    1538          * @return
    1539          *              The absolute link for this item. Null if there is no link, or if
    1540          *              there is no parent for this widget and the current frame is unavailable.
    1541          *
     1535
     1536        /**
     1537         * <b>Note:</b> That if the widget has no parent (e.g. the widget is a
     1538         * free-item) then the absolute link returned will be for the frameset of
     1539         * the current frame.
     1540         *
     1541         * @return The absolute link for this item. Null if there is no link, or if
     1542         *         there is no parent for this widget and the current frame is
     1543         *         unavailable.
     1544         * 
    15421545         */
    15431546        public String getAbsoluteLink() {
    1544                
    1545                 // Note:  cannot return the source absolute link since it does not have
     1547
     1548                // Note: cannot return the source absolute link since it does not have
    15461549                // a parent ... thus must manually format link
    1547                
     1550
    15481551                String link = getLink();
    1549                
    1550                 if (link == null || link.length() == 0) return null;
    1551                
    1552                 if (FrameIO.isPositiveInteger(link)) { // relative - convert to absolute
    1553                        
     1552
     1553                if (link == null || link.length() == 0)
     1554                        return null;
     1555
     1556                if (FrameIO.isPositiveInteger(link)) { // relative - convert to
     1557                                                                                                // absolute
     1558
    15541559                        // Get the frameset of this item
    15551560                        Frame parent = getParentFrame();
    1556                         if (parent == null) parent = DisplayIO.getCurrentFrame();
    1557                         if (parent == null) return null;
    1558                        
     1561                        if (parent == null)
     1562                                parent = DisplayIO.getCurrentFrame();
     1563                        if (parent == null)
     1564                                return null;
     1565
    15591566                        String framesetName = parent.getFramesetName();
    1560                        
    1561                         if (framesetName == null) return null;
    1562                        
     1567
     1568                        if (framesetName == null)
     1569                                return null;
     1570
    15631571                        return framesetName + link;
    1564                        
     1572
    15651573                } else if (FrameIO.isValidFrameName(link)) { // already absolute
    15661574                        return link;
    15671575                }
    1568                
     1576
    15691577                return null;
    15701578        }
     
    16001608                _textRepresentation.setColor(c);
    16011609        }
    1602        
     1610
    16031611        public void setSourceBorderColor(Color c) {
    16041612                _textRepresentation.setBorderColor(c);
    16051613        }
    1606        
     1614
    16071615        public void setSourceFillColor(Color c) {
    16081616                _textRepresentation.setFillColor(c);
    16091617        }
    1610        
     1618
    16111619        public void setSourceThickness(float newThickness, boolean setConnected) {
    16121620                _textRepresentation.setThickness(newThickness, setConnected);
     
    16161624                _textRepresentation.setData(data);
    16171625        }
    1618        
     1626
    16191627        protected Point getOrigin() {
    16201628                return _d1.getPosition(); // BROOK: This flips around ... the origin can be any point
    16211629        }
    1622        
     1630
    16231631        protected Item getFirstCorner() {
    16241632                return _d1;
Note: See TracChangeset for help on using the changeset viewer.