Changeset 116


Ignore:
Timestamp:
07/02/08 17:26:51 (16 years ago)
Author:
ra33
Message:

Added SearchItem and SearchStr

Location:
trunk/src/org/expeditee
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/actions/Simple.java

    r115 r116  
    323323                        // an item without a link signals to run the current frame
    324324                        if (current.getLink() == null) {
    325                                 //Make a copy but hide it
     325                                // Make a copy but hide it
    326326                                current = current.copy();
    327327                                current.setLink(DisplayIO.getCurrentFrame().getName());
     
    352352         */
    353353        public static void DebugFrame(Text current, float pause, Color color) {
    354                 if(isProgramRunning()){
     354                if (isProgramRunning()) {
    355355                        stop();
    356356                }
     
    412412                        context.getPointers().setObject(SPointer.framePrefix + varName,
    413413                                        frame);
     414                        context.getPointers().setObject(SPointer.itemPrefix + varName,
     415                                        frame.getTitleItem());
    414416                        context.getPrimitives().add(SString.prefix + varName,
    415417                                        new SString(frame.getName()));
     
    481483                if (_step) {
    482484                        DisplayIO.removeFromBack();
    483                         if(DisplayIO.getCurrentFrame() != current.getParent())
     485                        if (DisplayIO.getCurrentFrame() != current.getParent())
    484486                                DisplayIO.setCurrentFrame(current.getParent());
    485487                }
     
    766768                        // Check if the user wants to display a message
    767769                        // Check for set statements
     770                } else if (tokens[0].startsWith("search")) {
     771                        if (tokens[0].equals("searchstr")) {
     772                                assertExactParametreCount(tokens, 5);
     773                                String searchStr = context.getPrimitives().getStringValue(
     774                                                tokens[1]);
     775                                String pattern = context.getPrimitives().getStringValue(
     776                                                tokens[2]);
     777                                String[] result = searchStr.split(pattern, 2);
     778                                boolean bFound = result.length > 1;
     779                                context.getPrimitives().setValue(tokens[3],
     780                                                new SBoolean(bFound));
     781                                if (bFound) {
     782                                        context.getPrimitives().setValue(tokens[4],
     783                                                        new SInteger(result[0].length() + 1));
     784                                        context.getPrimitives().setValue(tokens[5],
     785                                                        new SInteger(searchStr.length() - result[1].length()));
     786                                }
     787                        }else if (tokens[0].equals("searchitem")) {
     788                                assertExactParametreCount(tokens, 5);
     789                                assertVariableType(tokens[1], 1, SPointer.itemPrefix);
     790                                Text searchItem = (Text)context.getPointers().getVariable(tokens[1]).getValue();
     791                                String searchStr = searchItem.getText();
     792                                String pattern = context.getPrimitives().getStringValue(
     793                                                tokens[2]);
     794                                String[] result = searchStr.split(pattern, 2);
     795                                boolean bFound = result.length > 1;
     796                                context.getPrimitives().setValue(tokens[3],
     797                                                new SBoolean(bFound));
     798                                if (bFound) {
     799//                                      context.getPrimitives().setValue(tokens[4],
     800//                                                      new SInteger(1));
     801                                        context.getPrimitives().setValue(tokens[4],
     802                                                        new SInteger(result[0].length() + 1));
     803//                                      context.getPrimitives().setValue(tokens[6],
     804//                                                      new SInteger(1));
     805                                        context.getPrimitives().setValue(tokens[5],
     806                                                        new SInteger(searchStr.length() - result[1].length()));
     807                                }
     808                        }
    768809                } else if (tokens[0].startsWith("set")) {
    769810                        if (tokens[0].equals("set")) {
     
    794835                                assertExactParametreCount(tokens, 3);
    795836
    796                                 Map<String,String> map = (Map<String,String>) context.getPointers().getVariable(tokens[1])
    797                                                 .getValue();
     837                                Map<String, String> map = (Map<String, String>) context
     838                                                .getPointers().getVariable(tokens[1]).getValue();
    798839                                String attribute = context.getPrimitives().getStringValue(
    799840                                                tokens[2]);
  • trunk/src/org/expeditee/gui/DisplayIO.java

    r115 r116  
    6060         * The title to display in the Title bar.
    6161         */
    62         public static final String TITLE = "Exp28Jun2008A";
     62        public static final String TITLE = "Exp02Jul2008A";
    6363
    6464        private DisplayIO() {
  • trunk/src/org/expeditee/gui/Frame.java

    r115 r116  
    750750        public void undo() {
    751751                Item undo = null;
     752                boolean bReparse = false;
    752753
    753754                if (_undo.size() <= 0)
     
    755756
    756757                undo = _undo.pop();
    757 
     758               
    758759                // if the change was to characteristics
    759760                if (undo.isVisible() && _body.contains(undo)) {
     
    786787
    787788                        for (Item i : toRestore) {
     789                                bReparse |= i.hasOverlay();
    788790                                if (i instanceof Line) {
    789791                                        Line line = (Line) i;
     
    798800                change();
    799801                FrameMouseActions.getInstance().refreshHighlights();
     802                if(bReparse)
     803                        FrameUtils.Parse(this, false);
    800804                FrameGraphics.Repaint();
    801805                ItemUtils.EnclosedCheck(_body);
  • trunk/src/org/expeditee/gui/FrameMouseActions.java

    r115 r116  
    20732073                        updateCursor();
    20742074                        ItemUtils.EnclosedCheck(current.getItems());
     2075                        if (toDelete.hasOverlay())
     2076                                FrameUtils.Parse(current, false);
    20752077                        FrameGraphics.Repaint();
    20762078                }
     
    20802082
    20812083        private static void deleteItems(Collection<Item> itemList) {
     2084                boolean bReparse = false;
    20822085                SessionStats.DeletedItems(itemList);
    20832086                List<Frame> modifiedFrames = new LinkedList<Frame>();
     
    20882091                                modifiedFrames.add(parent);
    20892092                        i.setHighlightMode(HighlightMode.None);
     2093                        bReparse |= i.hasOverlay();
    20902094                }
    20912095                // If they are all free items then add the current frame
     
    21192123                // TODO: How should undelete deal with undo when items are removed from
    21202124                // the current frame as well as the overlay frame
    2121                 DisplayIO.getCurrentFrame().addAllToUndo(itemList);
     2125                Frame currentFrame = DisplayIO.getCurrentFrame();
     2126                currentFrame.addAllToUndo(itemList);
    21222127                itemList.clear();
     2128                if (bReparse)
     2129                        FrameUtils.Parse(currentFrame, false);
     2130
    21232131        }
    21242132
     
    23742382
    23752383        public static void pickup(Collection<Item> toGrab) {
    2376 
     2384                boolean bReparse = false;
    23772385                String currentFrame = DisplayIO.getCurrentFrame().getName();
    23782386                Iterator<Item> iter = toGrab.iterator();
     
    23962404                        Frame.FreeItems.add(i);
    23972405                        i.setFloating(true);
     2406                        if (i.hasVector()) {
     2407                                bReparse = true;
     2408                                // Frame overlayFrame = FrameIO.LoadFrame(i.getAbsoluteLink());
     2409                                // Collection<Item> copies = ItemUtils.CopyItems(overlayFrame
     2410                                // .getNonAnnotationItems(), i.getVector());
     2411                                // Frame.FreeItems.addAll(copies);
     2412                                // TODO add the copies to the free items so they are visible
     2413                                // when the cursor is moving around but are not anchored
     2414                        }
    23982415                }
    23992416                _lastHighlightedItem = null;
     
    24342451                                        .DisplayMessage("Insufficient permission pickup the items");
    24352452                }
     2453                if (bReparse)
     2454                        FrameUtils.Parse(DisplayIO.getCurrentFrame(), false);
     2455
    24362456                FrameGraphics.Repaint();
    24372457        }
     
    24872507
    24882508        public static void anchor(Collection<Item> toAnchor) {
     2509                boolean bReparse = false;
    24892510                // Need to make sure we check enclosure for overlays etc
    24902511                Set<Frame> checkEnclosure = new HashSet<Frame>();
     
    24922513                        anchor(i, false);
    24932514                        checkEnclosure.add(i.getParentOrCurrentFrame());
     2515                        bReparse |= i.hasOverlay();
    24942516                }
    24952517                toAnchor.clear();
     
    24982520                        ItemUtils.EnclosedCheck(f.getItems());
    24992521                }
     2522                if (bReparse)
     2523                        FrameUtils.Parse(DisplayIO.getCurrentFrame(), false);
    25002524                FrameGraphics.Repaint();
    25012525        }
  • trunk/src/org/expeditee/gui/FrameUtils.java

    r115 r116  
    889889                                                        } catch (Exception e) {
    890890                                                        }
    891                                                         vectors.add(new Vector(vector, vectorPermission, i
     891                                                        Vector newVector = new Vector(vector, vectorPermission, i
    892892                                                                        .getPosition(), scale, i.getColor(), i
    893                                                                         .getBackgroundColor()));
     893                                                                        .getBackgroundColor());
     894                                                        i.setOverlay(newVector);
     895                                                        vectors.add(newVector);
    894896                                                }
    895897                                        }
     
    946948                                                        // If it wasnt in the list create it and add it.
    947949                                                        if (!found) {
    948                                                                 overlays.add(new Overlay(overlay,
    949                                                                                 permissionLevel));
     950                                                                Overlay newOverlay = new Overlay(overlay,
     951                                                                                permissionLevel);
     952                                                                i.setOverlay(newOverlay);
     953                                                                overlays.add(newOverlay);
    950954                                                        }
    951955                                                }
  • trunk/src/org/expeditee/items/Item.java

    r115 r116  
    2929import org.expeditee.gui.FrameIO;
    3030import org.expeditee.gui.FrameUtils;
     31import org.expeditee.gui.Overlay;
     32import org.expeditee.gui.Vector;
    3133import org.expeditee.io.Conversion;
    3234import org.expeditee.io.Logger;
     
    114116                        new Color(150, 150, 255), new Color(150, 255, 150),
    115117                        new Color(255, 150, 255), new Color(255, 255, 100), Color.WHITE,
    116                          Color.BLACK};
    117                                                                                                                                  /* Color.GRAY,
    118                                                                                                                                  * Color.DARK_GRAY,
    119                                                                                                                                  */
     118                        Color.BLACK };
     119
     120        /*
     121         * Color.GRAY, Color.DARK_GRAY,
     122         */
    120123
    121124        public static final int UNCHANGED_CURSOR = -100;
     
    236239
    237240        public Permission _permission = Permission.full;
    238        
    239         public void setPermission(Permission permission){
     241
     242        public void setPermission(Permission permission) {
    240243                _permission = permission;
    241244        }
    242        
    243         public boolean hasPermission(Permission permission){
     245
     246        public boolean hasPermission(Permission permission) {
    244247                return _permission.ordinal() >= permission.ordinal();
    245248        }
     
    315318                }
    316319
    317                 if (_actions == null){
     320                if (_actions == null) {
    318321                        _poly = null;
    319322                        _actions = new LinkedList<String>();
     
    931934                Color fillColor = getFillColor();
    932935                if (fillColor != null && getEnclosingDots() != null) {
    933                         if(isFloating()){
    934                                 //TODO experiment with adding alpha when picking up filled items...
    935                                 //Slows things down quite alot!!
    936                                 fillColor = new Color(fillColor.getRed(), fillColor.getGreen(), fillColor.getBlue());
    937                         }                       
     936                        if (isFloating()) {
     937                                // TODO experiment with adding alpha when picking up filled
     938                                // items...
     939                                // Slows things down quite alot!!
     940                                fillColor = new Color(fillColor.getRed(), fillColor.getGreen(),
     941                                                fillColor.getBlue());
     942                        }
    938943                        g.setColor(fillColor);
    939944                        // The painting is not efficient enough for gradients...
     
    10391044                // Check if all the characters are digits and hence it is a relative
    10401045                // link
    1041                 if(!FrameIO.isPositiveInteger(link))
     1046                if (!FrameIO.isPositiveInteger(link))
    10421047                        return;
    10431048
     
    10541059
    10551060        /**
    1056          * Sets any action code that should be associated with
    1057          * this Item Each entry in the list is one line of code
     1061         * Sets any action code that should be associated with this Item Each entry
     1062         * in the list is one line of code
    10581063         *
    10591064         * @param actions
     
    10611066         */
    10621067        public void setActions(List<String> actions) {
    1063                 //Want to resize the highlight box for text items if actions have been added
     1068                // Want to resize the highlight box for text items if actions have been
     1069                // added
    10641070                _poly = null;
    10651071                if (actions == null || actions.size() == 0)
     
    14201426                        return;
    14211427                assert (_parent != null);
    1422                
    1423                 if(FrameIO.isPositiveInteger(link))
     1428
     1429                if (FrameIO.isPositiveInteger(link))
    14241430                        return;
    1425                
     1431
    14261432                // Check if the link is for the current frameset
    14271433                if (_parent.getFramesetName().equalsIgnoreCase(
     
    14401446        /**
    14411447         * Sets the thickness of the item.
     1448         *
    14421449         * @param thick
    14431450         */
    1444         public void setThickness(float thick){
     1451        public void setThickness(float thick) {
    14451452                setThickness(thick, true);
    14461453        }
    1447        
     1454
    14481455        /**
    14491456         * Sets the thickness of this item.
    1450          * @param thick the new thickness for the item
    1451          * @param setConnectedThickness true if all items connected to this item should also have their thickness set
     1457         *
     1458         * @param thick
     1459         *            the new thickness for the item
     1460         * @param setConnectedThickness
     1461         *            true if all items connected to this item should also have
     1462         *            their thickness set
    14521463         */
    14531464        public void setThickness(float thick, boolean setConnectedThickness) {
     
    15551566                this._visible = !state;
    15561567        }
    1557        
    15581568
    15591569        public void setVisible(boolean state) {
     
    17001710                return _lines.size() > 0;
    17011711        }
    1702        
    1703         public boolean hasEnclosures(){
     1712
     1713        public boolean hasEnclosures() {
    17041714                return _enclosures.size() > 0;
    17051715        }
     
    17591769
    17601770        public void setAction(String string) {
    1761                 //Want to resize the highlight box for text items if actions are been added
    1762                 if(_actions == null || _actions.size() == 0){
     1771                // Want to resize the highlight box for text items if actions are been
     1772                // added
     1773                if (_actions == null || _actions.size() == 0) {
    17631774                        _poly = null;
    17641775                }
     
    18571868                        // if parent is null it is an item on the message box
    18581869                        // so it must already be absolute
    1859                         //assert (!FrameIO.isPositiveInteger(link));
    1860                         //return link;
    1861                        
     1870                        // assert (!FrameIO.isPositiveInteger(link));
     1871                        // return link;
     1872
    18621873                }
    18631874
     
    19611972         * @param ratio
    19621973         */
    1963         public void translate(Point2D origin, double ratio) {           
     1974        public void translate(Point2D origin, double ratio) {
    19641975                _x = (float) (origin.getX() + ratio * (_x - origin.getX()));
    19651976                _y = (float) (origin.getY() + ratio * (_y - origin.getY()));
     
    20032014        private boolean _deleted = false;
    20042015
     2016        private Overlay _overlay = null;
     2017
    20052018        /**
    20062019         * For now there can only be one enclosure per item
     2020         *
    20072021         * @param enclosure
    20082022         */
     
    20242038                return _deleted;
    20252039        }
     2040
     2041        public boolean hasVector() {
     2042                return _overlay instanceof Vector;
     2043        }
     2044       
     2045        public boolean hasOverlay() {
     2046                return _overlay != null;
     2047        }
     2048
     2049        public Vector getVector() {
     2050                if (_overlay instanceof Vector)
     2051                        return (Vector) _overlay;
     2052                return null;
     2053        }
     2054
     2055        public void setOverlay(Overlay overlay) {
     2056                _overlay = overlay;
     2057        }
    20262058}
  • trunk/src/org/expeditee/items/Text.java

    r115 r116  
    17171717                return c== '*' || c == '+' || c == '>' || c == '-' || c == 'o';
    17181718        }
     1719       
     1720        public boolean hasOverlay() {
     1721                if(!isAnnotation() || getLink()==null)
     1722                        return false;
     1723                return ItemUtils.startsWithTag(this, "@ao") ||ItemUtils.startsWithTag(this, "@v");
     1724        }
    17191725}
Note: See TracChangeset for help on using the changeset viewer.