Ignore:
Timestamp:
05/26/08 09:11:05 (16 years ago)
Author:
ra33
Message:

Added @b and @v...
Also changed @f... so that images can be displayed with transparent backgrounds.
Did a bunch of refactoring in the process to remove duplicated code and simplify managing @i, @f and @b.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        88testdummyaudio
        99tests_apollos
         10*.txt
  • trunk/src/org/expeditee/gui/Frame.java

    r74 r78  
    6262        private Color _background;
    6363
    64         private Color _foreground;
     64        private Color _foreground = Item.DEFAULT_FOREGROUND;
    6565
    6666        public String path;
     
    9797        private List<Overlay> _overlays = new ArrayList<Overlay>();
    9898
    99         private VolatileImage _buffer = null;
     99        private List<Vector> _vectors = new ArrayList<Vector>();
     100
     101        private Image _buffer = null;
    100102
    101103        private boolean _validBuffer = true;
     
    108110        }
    109111
    110         public VolatileImage getBuffer() {
     112        public Image getBuffer() {
    111113                return _buffer;
    112114        }
    113115
    114         public void setBuffer(VolatileImage newBuffer) {
     116        public void setBuffer(Image newBuffer) {
    115117                _buffer = newBuffer;
    116118        }
    117119
    118120        public boolean isBufferValid() {
    119                 if (_buffer == null || _buffer.contentsLost())
     121                if (_buffer == null
     122                                || (_buffer instanceof VolatileImage && ((VolatileImage) _buffer)
     123                                                .contentsLost()))
    120124                        return false;
    121125
     
    243247         * @return the last non annotation text item.
    244248         */
    245         public Text getLastNonAnnotationTextItem() {
     249        public Item getLastNonAnnotationTextItem() {
    246250                List<Item> items = getItems();
    247251
     
    251255
    252256                        if (it instanceof Text && !it.isAnnotation()) {
    253                                 return (Text) it;
     257                                return (Item) it;
    254258                        }
    255259                }
     
    332336        }
    333337
    334         public Text getFrameNameItem() {
     338        public Item getFrameNameItem() {
    335339                return _frameName;
    336340        }
     
    364368        }
    365369
    366         public Text getStatsTextItem(String itemText) {
     370        public Item getStatsTextItem(String itemText) {
    367371                Text t = getStatTemplate();
    368372                // We dont want the stats to wrap at all
     
    769773
    770774        public Color getPaintBackgroundColor() {
    771                 if (_background == null)
    772                         return DisplayIO.DEFAULT_BACKGROUND;
     775                // If null... return white
     776                if (_background == null) {
     777                        return Item.DEFAULT_BACKGROUND;
     778                }
    773779
    774780                return _background;
     
    895901
    896902        /**
     903         * Adds the given Vector to the list of vector Frames being drawn with this
     904         * Frame.
     905         *
     906         * @param vector
     907         *            The Vector to add
     908         *
     909         * @throws NullPointerException
     910         *             If overlay is null.
     911         */
     912        public void addVector(Vector vector) {
     913                if (vector == null)
     914                        throw new NullPointerException("Frame.addVector");
     915                // make sure we dont add this frame as an overlay of itself
     916                if (vector.Frame == this)
     917                        return;
     918
     919                // if (_vectors.contains(vector))
     920                // return;
     921
     922                _vectors.add(vector);
     923
     924                // TODO add the code below
     925                // Items must be notified that they have been added to this frame via
     926                // the vector...
     927                // List<Item> items = new LinkedList<Item>();
     928                // FrameGraphics.AddAllOverlayItems(items, vector.Frame,
     929                // new LinkedList<Frame>());
     930                //             
     931                // for (Item i : items) {
     932                // i.onParentStateChanged(new ItemParentStateChangedEvent(this,
     933                // ItemParentStateChangedEvent.EVENT_TYPE_ADDED_VIA_VECTOR,
     934                // overlay.Level));
     935                // }
     936        }
     937
     938        /**
    897939         * Adds the given Frame to the list of overlays Frames being drawn with this
    898940         * Frame.
     
    957999
    9581000        /**
     1001         * Removes the given vector from the list of vector being drawn with this
     1002         * Frame.
     1003         *
     1004         * @param vector
     1005         *            The overlay to remove
     1006         *
     1007         * @throws NullPointerException
     1008         *             If overlay is null.
     1009         */
     1010        public void removeVector(Vector vector) {
     1011                if (vector == null)
     1012                        throw new NullPointerException("Frame.removeVector");
     1013
     1014                this._vectors.remove(vector);
     1015
     1016                // TODO figure out what the code below needs to be changed to
     1017                // Items must be notified that they have been removed from this frame
     1018                // via the overlay...
     1019                // List<Item> items = new LinkedList<Item>();
     1020                // FrameGraphics.AddAllOverlayItems(items, vector.Frame,
     1021                // new LinkedList<Frame>());
     1022                // for (Item i : items) {
     1023                // i.onParentStateChanged(new ItemParentStateChangedEvent(this,
     1024                // ItemParentStateChangedEvent.EVENT_TYPE_REMOVED_VIA_OVERLAY,
     1025                // vector.Level));
     1026                // }
     1027        }
     1028
     1029        /**
    9591030         * Removes the given Frame from the list of overlayed Frames being drawn
    9601031         * with this Frame.
     
    9831054        }
    9841055
     1056        public List<Vector> getVectors() {
     1057                List<Vector> l = new LinkedList<Vector>();
     1058                l.addAll(_vectors);
     1059                return l;
     1060        }
     1061
    9851062        public List<Overlay> getOverlays() {
    9861063                List<Overlay> l = new LinkedList<Overlay>();
     
    9971074                getOverlaysDeep(l, this, new LinkedList<Frame>());
    9981075                return l;
     1076        }
     1077
     1078        /**
     1079         * @return All vectosr seen by this frame (including its vector's vectors).
     1080         */
     1081        public List<Vector> getVectorsDeep() {
     1082                List<Vector> l = new LinkedList<Vector>();
     1083                getVectorsDeep(l, this, new LinkedList<Frame>());
     1084                return l;
     1085        }
     1086
     1087        private boolean getVectorsDeep(List<Vector> vectors, Frame vector,
     1088                        List<Frame> seenVectors) {
     1089
     1090                if (seenVectors.contains(vector))
     1091                        return false;
     1092
     1093                seenVectors.add(vector);
     1094
     1095                for (Vector o : vector.getVectors()) {
     1096                        if (getVectorsDeep(vectors, o.Frame, seenVectors)) {
     1097                                vectors.add(o);
     1098                        }
     1099                }
     1100
     1101                return true;
    9991102        }
    10001103
     
    10371140        }
    10381141
     1142        public void clearVectors() {
     1143                while (!_vectors.isEmpty()) {
     1144                        removeVector(_vectors.get(0)); // centralise removing
     1145                }
     1146        }
     1147
    10391148        public void clearOverlays() {
    10401149                while (!_overlays.isEmpty()) {
    10411150                        removeOverlay(_overlays.get(0)); // centralise removing
     1151                }
     1152        }
     1153
     1154        public void addAllVectors(List<Vector> vectors) {
     1155                for (Vector v : vectors) {
     1156                        addVector(v); // centralise adding
    10421157                }
    10431158        }
     
    11671282                                getNextItemID());
    11681283
    1169                 Text template = getTemplate(UserSettings.LineTemplate,
     1284                Item template = getTemplate(UserSettings.LineTemplate,
    11701285                                ItemUtils.TAG_LINE_TEMPLATE);
    11711286                float thickness = template.getThickness();
     
    12361351        }
    12371352
    1238         public Text addText(int x, int y, String text, String action, String link) {
    1239                 Text t = addText(x, y, text, action);
     1353        public Item addText(int x, int y, String text, String action, String link) {
     1354                Item t = addText(x, y, text, action);
    12401355                t.setLink(link);
    12411356                return t;
Note: See TracChangeset for help on using the changeset viewer.