Ignore:
Timestamp:
01/07/09 13:25:13 (15 years ago)
Author:
ra33
Message:
 
File:
1 edited

Legend:

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

    r407 r427  
    2727import org.expeditee.items.widgets.WidgetEdge;
    2828
    29 
    3029//Static methods that provide functions for the objects\
    3130//mostly to transform values (string -> color etc).
     
    7675
    7776        public static final int TAG_VECTOR = 19;
    78        
     77
    7978        public static final int TAG_ACTIVE_VECTOR = 21;
    8079
     
    457456
    458457                for (Item i : toCopy) {
    459                         //Dont copy parts of a vector
    460                         if(!i.hasPermission(Permission.copy))
     458                        // Dont copy parts of a vector
     459                        if (!i.hasPermission(Permission.copy))
    461460                                continue;
    462                        
     461
    463462                        // BROOK
    464463                        if (i instanceof WidgetCorner) { // dont add these
     
    587586
    588587                }
    589                
    590                 //Make sure filled rectangles are shown filled on vector overlays
    591                 if(v != null)
     588
     589                // Make sure filled rectangles are shown filled on vector overlays
     590                if (v != null)
    592591                        EnclosedCheck(copies);
    593592
     
    654653                copy.removeAllConstraints();
    655654
    656                 for(Line l: origEnd.getLines()){
     655                for (Line l : origEnd.getLines()) {
    657656                        l.invalidateAll();
    658657                }
    659                
     658
    660659                // create a new line
    661660                Frame currentFrame = DisplayIO.getCurrentFrame();
     
    867866
    868867        /**
    869          * Determines if an item is visible from a the current frame(s).
    870          * If the item is free then it is considered visible.
    871          * @param i The item to check
     868         * Determines if an item is visible from a the current frame(s). If the item
     869         * is free then it is considered visible.
     870         *
     871         * @param i
     872         *            The item to check
    872873         * @return True if visible/free from given frame.
    873874         */
     
    879880                                return true;
    880881                        }
    881                 } else  {
     882                } else {
    882883                        return isVisible(DisplayIO.getCurrentFrame(), i);
    883884                }
     
    885886
    886887        /**
    887          * Determines if an item is visible from a given frame.
    888          * If the item is free then it is considered visible.
    889          *
    890          * @param fromFrame The frame to check from.
    891          * @param i The item to check
     888         * Determines if an item is visible from a given frame. If the item is free
     889         * then it is considered visible.
     890         *
     891         * @param fromFrame
     892         *            The frame to check from.
     893         * @param i
     894         *            The item to check
    892895         * @return True if visible/free from given frame.
    893896         */
    894897        public static boolean isVisible(Frame fromFrame, Item i) {
    895                 if (fromFrame == null) return false;
     898                if (fromFrame == null)
     899                        return false;
     900
     901                Frame parent = i.getParent();
     902
     903                if (parent == fromFrame)
     904                        return true;
    896905               
    897                 Frame parent = i.getParent();
    898                
    899                 if (parent == fromFrame) return true;
    900                
    901                 else if (parent == null) return FreeItems.getInstance().contains(i);
    902                
     906                else if (parent == null)
     907                        return FreeItems.getInstance().contains(i)
     908                                        || FreeItems.getCursor().contains(i);
     909
    903910                return fromFrame.getAllItems().contains(i) && i.isVisible();
    904911        }
    905        
     912
    906913        public static Rectangle expandRectangle(Rectangle r, int n) {
    907                 return new Rectangle(r.x - (n >> 1), r.y - (n >> 1),
    908                                 r.width + n, r.height + n);
    909         }
    910        
     914                return new Rectangle(r.x - (n >> 1), r.y - (n >> 1), r.width + n,
     915                                r.height + n);
     916        }
     917
    911918        /*
    912919         * FrameMouseActions while (!copies.isEmpty()) { Iterator<Item> iterator =
     
    943950                item.setPermission(permission);
    944951
    945                 //TODO encapsulate this somewhere inside of circle class!
    946 //              if(item instanceof Circle){
    947 //                      scaleItem(v, ((Circle)item).getCenter());
    948 //              }
    949                
    950                 if (!(item instanceof Line)) {         
     952                // TODO encapsulate this somewhere inside of circle class!
     953                // if(item instanceof Circle){
     954                // scaleItem(v, ((Circle)item).getCenter());
     955                // }
     956
     957                if (!(item instanceof Line)) {
    951958                        if (item.getColor() == null) {
    952959                                item.setColor(defaultForeground);
     
    963970                                item.setActionMark(false);
    964971                        }
    965                        
     972
    966973                        item.scale(scale, originX, originY);
    967974                }
    968975
    969976        }
    970        
     977
    971978        /**
    972979         * Extracts widgets from an item list.
    973980         *
    974981         * @param items
    975          *              Items to extract from. Must not be null.
    976          *
    977          * @return
    978          *              List of (unique)widgets in items. Never null.
     982         *            Items to extract from. Must not be null.
     983         *
     984         * @return List of (unique)widgets in items. Never null.
    979985         */
    980986        public static List<InteractiveWidget> extractWidgets(List<Item> items) {
    981                 assert(items != null);
    982                
     987                assert (items != null);
     988
    983989                List<InteractiveWidget> iWidgets = new LinkedList<InteractiveWidget>();
    984                
     990
    985991                for (Item i : items) {
    986992                        if (i instanceof WidgetEdge) {
    987                                 WidgetEdge we = (WidgetEdge)i;
     993                                WidgetEdge we = (WidgetEdge) i;
    988994                                if (!iWidgets.contains(we.getWidgetSource()))
    989995                                        iWidgets.add(we.getWidgetSource());
    990996                        } else if (i instanceof WidgetCorner) {
    991                                 WidgetCorner wc = (WidgetCorner)i;
     997                                WidgetCorner wc = (WidgetCorner) i;
    992998                                if (!iWidgets.contains(wc.getWidgetSource()))
    993999                                        iWidgets.add(wc.getWidgetSource());
    9941000                        }
    9951001                }
    996                
     1002
    9971003                return iWidgets;
    9981004        }
    999        
     1005
    10001006}
Note: See TracChangeset for help on using the changeset viewer.