Changeset 920


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
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/gui/DisplayIO.java

    r919 r920  
    4242import org.expeditee.items.Item;
    4343import org.expeditee.items.ItemParentStateChangedEvent;
     44import org.expeditee.items.ItemUtils;
    4445import org.expeditee.items.Picture;
    4546import org.expeditee.items.Text;
     
    592593                        }
    593594                }
     595               
    594596                frame.reset();
     597               
     598                // fix text items
     599                ItemUtils.Justify(frame);
     600               
    595601                FrameMouseActions.getInstance().refreshHighlights();
    596602                FrameGraphics.refresh(false);
  • trunk/src/org/expeditee/gui/FrameMouseActions.java

    r919 r920  
    3737import java.util.ArrayList;
    3838import java.util.Collection;
     39import java.util.Comparator;
    3940import java.util.Date;
    4041import java.util.HashSet;
     
    15291530                                                clearParent(copies);
    15301531                                }
     1532                               
     1533                                ItemUtils.Justify(copies);
    15311534
    15321535                                pickup(copies);
     
    15421545                                                copies = copy(enclosed);
    15431546                                                clearParent(copies);
     1547                                                ItemUtils.Justify(copies);
    15441548                                                pickup(copies);
    15451549                                                for (Item i : clickedIn) {
     
    32653269                        ItemUtils.EnclosedCheck(f.getItems());
    32663270                }
     3271               
     3272                // justify text items now
     3273                ItemUtils.Justify(toAnchorCopy);
    32673274
    32683275                Frame currentFrame = DisplayIO.getCurrentFrame();
  • 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.