Ignore:
Timestamp:
07/03/08 16:48:09 (16 years ago)
Author:
bjn8
Message:

Added invalidation for graphics... biiiig commit. LOts of effeciency improvements - now can animate

File:
1 edited

Legend:

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

    r115 r121  
    22
    33import java.awt.Color;
     4import java.awt.Rectangle;
    45import java.awt.image.ImageObserver;
    56import java.io.File;
     
    1718import org.expeditee.gui.DisplayIO;
    1819import org.expeditee.gui.Frame;
     20import org.expeditee.gui.FreeItems;
    1921import org.expeditee.gui.Vector;
    2022import org.expeditee.items.Item.HighlightMode;
     23
    2124
    2225//Static methods that provide functions for the objects\
     
    847850        }
    848851
     852        /**
     853         * Determines if an item is visible from a the current frame(s).
     854         * If the item is free then it is considered visible.
     855         * @param i The item to check
     856         * @return True if visible/free from given frame.
     857         */
     858        public static boolean isVisible(Item i) {
     859                if (DisplayIO.isTwinFramesOn()) {
     860                        if (!isVisible(DisplayIO.getFrames()[0], i)) {
     861                                return isVisible(DisplayIO.getFrames()[1], i);
     862                        } else {
     863                                return true;
     864                        }
     865                } else  {
     866                        return isVisible(DisplayIO.getCurrentFrame(), i);
     867                }
     868        }
     869
     870        /**
     871         * Determines if an item is visible from a given frame.
     872         * If the item is free then it is considered visible.
     873         *
     874         * @param fromFrame The frame to check from.
     875         * @param i The item to check
     876         * @return True if visible/free from given frame.
     877         */
     878        public static boolean isVisible(Frame fromFrame, Item i) {
     879                if (fromFrame == null) return false;
     880               
     881                Frame parent = i.getParent();
     882               
     883                if (parent == fromFrame) return true;
     884               
     885                else if (parent == null) return FreeItems.getInstance().contains(i);
     886               
     887                return fromFrame.getAllItems().contains(i) && i.isVisible();
     888        }
     889       
     890        public static Rectangle expandRectangle(Rectangle r, int n) {
     891                return new Rectangle(r.x - (n >> 1), r.y - (n >> 1),
     892                                r.width + n, r.height + n);
     893        }
     894       
    849895        /*
    850896         * FrameMouseActions while (!copies.isEmpty()) { Iterator<Item> iterator =
Note: See TracChangeset for help on using the changeset viewer.