Ignore:
Timestamp:
09/01/14 17:58:47 (10 years ago)
Author:
jts21
Message:

Text items are now correctly justfied on Frame load, and when picked up or placed down inside a polygon

Location:
trunk/src/org/expeditee/items
Files:
2 edited

Legend:

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

    r919 r920  
    3636import org.expeditee.gui.DisplayIO;
    3737import org.expeditee.gui.Frame;
     38import org.expeditee.gui.FrameUtils;
    3839import org.expeditee.gui.FreeItems;
    3940import org.expeditee.gui.Vector;
     
    10321033                return iWidgets;
    10331034        }
     1035       
     1036        public static void Justify(Collection<Item> items) {
     1037                for (Item i : items) {
     1038                        if (i instanceof Text) {
     1039                                Collection<Item> enclosure = FrameUtils.getEnclosingLineEnds(i.getPosition());
     1040                                if (enclosure != null) {
     1041                                        ((Text)i).justify(false, enclosure.iterator().next().getEnclosedShape());
     1042                                }
     1043                        }
     1044                }
     1045        }
     1046       
     1047        public static void Justify(Frame frame) {
     1048                EnclosedCheck(frame.getItems());
     1049                Justify(frame.getItems());
     1050        }
    10341051}
  • trunk/src/org/expeditee/items/Text.java

    r919 r920  
    22692269                }
    22702270        }
    2271 
    2272         public void justify(boolean fixWidth) {
    2273                
     2271       
     2272        public void justify(boolean fixWidth, Polygon enclosure) {
    22742273                // if autowrap is on, wrapping is done every time we draw
    22752274                if(ExperimentalFeatures.AutoWrap.get()) {
     
    22812280                // Check if that text item is inside an enclosing rectangle...
    22822281                // Set its max width accordingly
    2283                 Polygon enclosure = FrameUtils.getEnlosingPolygon();
    22842282                if (enclosure != null) {
    22852283                        Rectangle bounds = enclosure.getBounds();
     
    23062304
    23072305                }
     2306        }
     2307
     2308        public void justify(boolean fixWidth) {
     2309                // if autowrap is on, wrapping is done every time we draw
     2310                if(ExperimentalFeatures.AutoWrap.get()) {
     2311                        return;
     2312                }
     2313                this.justify(fixWidth, FrameUtils.getEnlosingPolygon());
    23082314        }
    23092315
Note: See TracChangeset for help on using the changeset viewer.