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/items/ItemUtils.java

    r72 r78  
    1212import java.util.Collection;
    1313import java.util.HashMap;
    14 import java.util.HashSet;
    1514import java.util.LinkedHashSet;
    1615import java.util.LinkedList;
     
    7170
    7271        public static final int TAG_STAT_TEMPLATE = 18;
     72       
     73        public static final int TAG_VECTOR = 19;
     74       
     75        public static final int TAG_BITMAP_IMAGE = 20;
    7376
    7477        public static final int TAG_MIN = 0;
    7578
    76         public static final int TAG_MAX = 18;
     79        public static final int TAG_MAX = 20;
    7780
    7881        /**
     
    115118         *         is found
    116119         */
    117         public static Text FindTag(List<Item> items, int tag) {
     120        public static Item FindTag(List<Item> items, int tag) {
    118121                return FindTag(items, GetTag(tag));
    119122        }
     
    139142        }
    140143
    141         public static Text FindExactTag(List<Item> items, String toFind) {
     144        public static Item FindExactTag(List<Item> items, String toFind) {
    142145                for (Item i : items) {
    143146                        if (i instanceof Text && i.isAnnotation())
    144147                                if (((Text) i).getTextNoList().trim().equalsIgnoreCase(toFind))
    145                                         return (Text) i;
     148                                        return (Item) i;
    146149                }
    147150
     
    149152        }
    150153
    151         public static Text FindExactTag(List<Item> items, int tag) {
     154        public static Item FindExactTag(List<Item> items, int tag) {
    152155                return FindExactTag(items, GetTag(tag));
    153156        }
     
    285288                case TAG_OVERLAY:
    286289                        return "@o";
     290                case TAG_VECTOR:
     291                        return "@v";
    287292                case TAG_ACTIVE_OVERLAY:
    288293                        return "@ao";
     
    307312                case TAG_FRAME_IMAGE:
    308313                        return "@f";
     314                case TAG_BITMAP_IMAGE:
     315                        return "@b";
    309316                case TAG_BACKUP:
    310317                        return "@old";
     
    418425        }
    419426
    420         public static Picture CreateFramePicture(Text source, ImageObserver observer) {
     427        public static Picture CreateFrameImage(Text source, ImageObserver observer) {
    421428                String size = source.getFirstLine();
    422429
     
    426433
    427434                try {
    428                         Picture pic = new Picture(source, null, size, observer);
     435                        Picture pic = new FrameImage(source, size, observer);
    429436                        return pic;
    430437                } catch (Exception e) {
     
    433440                }
    434441        }
     442       
     443        public static Picture CreateFrameBitmap(Text source, ImageObserver observer) {
     444                String size = source.getFirstLine();
     445
     446                // remove @b tag
     447                size = size.replaceFirst("@b", "");
     448                size = size.trim();
     449
     450                try {
     451                        Picture pic = new FrameBitmap(source, size, observer);
     452                        return pic;
     453                } catch (Exception e) {
     454                        // e.printStackTrace();
     455                        return null;
     456                }
     457        }
    435458
    436459        /**
     
    450473
    451474                // list of dots at the end of lines
    452                 Collection<Item> lineEnds = new HashSet<Item>();
    453                 Collection<Line> lines = new HashSet<Line>();
    454                 Collection<Constraint> constraints = new HashSet<Constraint>();
    455 
    456                 Collection<Item> singles = new HashSet<Item>();
     475                Collection<Item> lineEnds = new LinkedHashSet<Item>();
     476                Collection<Line> lines = new LinkedHashSet<Line>();
     477                Collection<Constraint> constraints = new LinkedHashSet<Constraint>();
     478
     479                Collection<Item> singles = new LinkedHashSet<Item>();
    457480
    458481                Map<Item, Item> lineEndMap = new HashMap<Item, Item>();
     
    529552                for (Line line : lines) {
    530553                        Line lineCopy = line.copy();
    531                         lineCopy.setEndItem(lineEndMap.get(line.getEndItem()));
    532                         lineCopy.setStartItem(lineEndMap.get(line.getStartItem()));
     554                        //get the lineEnd we copied above if it is in the MAPPING
     555                        Item originalLineEnd = line.getEndItem();
     556                        Item actualLineEnd = lineEndMap.get(originalLineEnd);
     557                        if (actualLineEnd == null)
     558                                lineCopy.setEndItem(originalLineEnd);
     559                        else
     560                                lineCopy.setEndItem(actualLineEnd);
     561                       
     562                        Item originalLineStart = line.getStartItem();
     563                        Item actualLineStart = lineEndMap.get(originalLineStart);
     564                        if (actualLineStart == null)
     565                                lineCopy.setStartItem(originalLineStart);
     566                        else
     567                                lineCopy.setStartItem(actualLineStart);
     568                       
    533569                        copies.add(lineCopy);
    534570                }
Note: See TracChangeset for help on using the changeset viewer.