Changeset 348


Ignore:
Timestamp:
10/06/08 14:16:30 (16 years ago)
Author:
ra33
Message:
 
Location:
trunk/src/org/expeditee
Files:
29 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/actions/Mail.java

    r306 r348  
    7979        }
    8080
    81         public static Text getMail(int messageNo) {
     81        public static Text getMail(int firstMessage, int lastMessage) {
     82                // Swap message numbers if they are around the wrong way
     83                if (firstMessage > lastMessage) {
     84                        int temp = firstMessage;
     85                        firstMessage = lastMessage;
     86                        lastMessage = temp;
     87                }
     88
     89                MessageBay.errorMessage("Not yet supported");
     90
     91                return null;
     92        }
     93       
     94        public static Collection<Text> getMail(int count) {
     95                return getMail(null, null, count);
     96        }
     97
     98        public static Text getMailByID(int messageNo) {
    8299                Text mailItem = MailSession.getInstance().getMail(
    83100                                DisplayIO.getCurrentFrame(), FrameMouseActions.getPosition(),
     
    85102                // MessageBay.displayMessage(mailItems.size() + " messages read",
    86103                // Color.green);
     104                if (mailItem == null) {
     105                        MessageBay
     106                                        .errorMessage("Mail message does not exist: " + messageNo);
     107                }
    87108
    88109                return mailItem;
  • trunk/src/org/expeditee/agents/mail/MailSession.java

    r311 r348  
    190190                                                try {
    191191                                                        MessageBay.displayMessage("New mail message!",
    192                                                                         null, Color.green, true, "getMail "
     192                                                                        null, Color.green, true, "getMailByID "
    193193                                                                                        + _folder.getMessageCount());
     194                                                        /*
     195                                                         * TODO use messageID incase mail gets deleted
     196                                                         * externally
     197                                                         */
    194198                                                } catch (MessagingException e1) {
    195199                                                        e1.printStackTrace();
     
    444448                        msgs = _folder.getMessages();
    445449
     450                        // msgs[0].get
     451
    446452                        int messagesRead = 0;
    447453
     
    456462                                                point.y += newItem.getBoundsHeight();
    457463                                                messagesRead++;
     464                                        } else {
     465                                                newItem = null;
    458466                                        }
    459467                                }
     
    475483                        Message[] msgs = _folder.getMessages();
    476484                        return readMessage(msgs[msgNum], msgNum + 1, frame, point);
    477                 } catch (MessagingException e) {
     485                } catch (ArrayIndexOutOfBoundsException ae) {
     486                        /*
     487                         * Just return null... error message will be displayed in the
     488                         * calling method
     489                         */
     490                } catch (Exception e) {
    478491                        e.printStackTrace();
    479492                }
     
    492505                                try {
    493506                                        String subject = message.getSubject();
    494                                         source.setText(messageNo + ". " + subject);
     507                                        source.setText(" " + messageNo + ". " + subject);
    495508                                        // Create a frameCreator
    496509                                        final FrameCreator frames = new FrameCreator(frame
  • trunk/src/org/expeditee/gui/AttributeUtils.java

    r307 r348  
    7070                        _Ignore.add("p");
    7171                        _Ignore.add("x");
    72                         _Ignore.add("y");                       
     72                        _Ignore.add("y");
    7373
    7474                        _ExtractIgnore = new LinkedList<String>();
     
    209209                                        "setGradientColor", pColor));
    210210
     211                        _SetMethods.put("ga", Item.class.getMethod("setGradientAngle",
     212                                        pInt));
     213                        _SetMethods.put("gradientangle", Item.class.getMethod(
     214                                        "setGradientAngle", pInt));
     215
    211216                        _SetMethods.put("fillpattern", Item.class.getMethod(
    212217                                        "setFillPattern", pString));
     
    263268                        _SetMethods.put("width", Text.class.getMethod("setWidth", pInt));
    264269                        _SetMethods.put("w", Text.class.getMethod("setWidth", pInt));
    265                        
     270
    266271                        _SetMethods.put("size", Item.class.getMethod("setSize", pFloat));
    267272                        _SetMethods.put("s", Item.class.getMethod("setSize", pFloat));
     
    355360                                                if (((Float) o) < -0.0001)
    356361                                                        continue;
    357                                                 //Null indicates default
     362                                                // Null indicates default
    358363                                                o = Math.round((Float) o);
    359364                                        } else if (o instanceof Double) {
     
    446451                return setAttribute(toSet, attribs, 1);
    447452        }
    448        
    449         public static boolean setAttribute(Object toSet, Text attribs, int minAttributeLength) {
     453
     454        public static boolean setAttribute(Object toSet, Text attribs,
     455                        int minAttributeLength) {
    450456                // error checking
    451457                if (toSet == null || attribs == null)
     
    454460                if (_Ignore == null)
    455461                        initLists();
    456                
    457                 //if(attribs.isAnnotation())
    458                 //      return false;
     462
     463                // if(attribs.isAnnotation())
     464                // return false;
    459465
    460466                // get the list of attribute: value pairs
     
    467473                // loop through all attribute: value pairs
    468474                for (int i = 0; i < values.size(); i++) {
    469                         AttributeValuePair avp = new AttributeValuePair(values.get(i), false);
     475                        AttributeValuePair avp = new AttributeValuePair(values.get(i),
     476                                        false);
    470477
    471478                        // If the first is not an attribute value pair then dont do
    472479                        // attrubute merging
    473                         if (!avp.hasAttribute() || avp.getAttribute().length() < minAttributeLength)
     480                        if (!avp.hasAttribute()
     481                                        || avp.getAttribute().length() < minAttributeLength)
    474482                                return false;
    475483
  • trunk/src/org/expeditee/gui/Browser.java

    r345 r348  
    1414import java.awt.event.WindowListener;
    1515import java.awt.event.WindowStateListener;
     16import java.io.File;
    1617import java.util.Collection;
     18import java.util.LinkedList;
    1719
    1820import javax.swing.JFrame;
     
    5355
    5456        public static Browser _theBrowser = null;
    55        
     57
    5658        private MouseEventRouter _mouseEventRouter;
    5759
     
    98100                return getContentPane().getLocationOnScreen();
    99101        }
    100        
    101         /**
    102          * @return
    103          *              The mouse event router used fot this browser.
    104          *              Never null after browser constructed.
     102
     103        /**
     104         * @return The mouse event router used fot this browser. Never null after
     105         *         browser constructed.
    105106         */
    106107        public MouseEventRouter getMouseEventRouter() {
     
    151152
    152153                UserSettings.Init();
    153                 UserSettings.Username = FrameIO.ConvertToValidFramesetName(System
     154                UserSettings.ProfileName = FrameIO.ConvertToValidFramesetName(System
    154155                                .getProperty("user.name"));
    155                 String userName = UserSettings.Username;
     156                String userName = UserSettings.ProfileName;
     157                UserSettings.UserName = UserSettings.ProfileName;
     158
     159                Frame profile = loadProfile(userName);
     160
     161                // Need to display errors once things have been init otherwise
     162                // exceptions occur if there are more than four messages neededing to be
     163                // displayed.
     164
     165                Frame defaultProfile = loadProfile(UserSettings.DEFAULT_PROFILE_NAME);
     166
     167                Collection<String> warningMessages = FrameUtils
     168                                .ParseProfile(defaultProfile);
     169
     170                warningMessages.addAll(FrameUtils.ParseProfile(profile));
     171
     172                // set the layout to absolute layout for widgets
     173                this.getContentPane().setLayout(new AbsoluteLayout());
     174
     175                _mouseEventRouter = new MouseEventRouter(getJMenuBar(),
     176                                getContentPane());
     177
     178                // enable the glasspane-for capturing all mouse events
     179                this.setGlassPane(_mouseEventRouter);
     180
     181                this.getGlassPane().setVisible(true);
     182                this.getContentPane().setBackground(Color.white);
     183                this.getContentPane().setFocusTraversalKeysEnabled(false);
     184
     185                addComponentListener(this);
     186                pack();
     187
     188                // Reset windows to user specified size
     189                // Must be done after initialising the content pane above!
     190                setSizes(new Dimension(UserSettings.InitialWidth,
     191                                UserSettings.InitialHeight));
     192
     193                /*
     194                 * See Java bug ID 4016934. They say that window closed events are
     195                 * called once the JFrame is disposed.
     196                 */
     197                setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
     198
     199                // Expeditee handles its own repainting of AWT/Swing components
     200                RepaintManager.setCurrentManager(ExpediteeRepaintManager.getInstance());
     201
     202                // Listen for save status to display during and after runtime
     203                EntitySaveManager.getInstance().addSaveStateChangedEventListener(this);
     204
     205                String version = System.getProperty("java.version");
     206
     207                if (version.startsWith("1.6")) {
     208                        // Set the drag and drop handler
     209                        _version6 = true;
     210                        setTransferHandler(FrameDNDTransferHandler.getInstance());
     211                } else {
     212                        System.out.println("Upgrade to Java 1.6 to enable drag and drop");
     213                }
     214
     215                try {
     216                        warningMessages.addAll(Actions.Init());
     217
     218                        DisplayIO.Init(this);
     219                        // Set visible must be just after DisplayIO.Init for the message box
     220                        // to
     221                        // be the right size
     222                        setVisible(true);
     223
     224                        setupGraphics();
     225
     226                        // required to accept TAB key
     227                        setFocusTraversalKeysEnabled(false);
     228
     229                        // Must be loaded after setupGraphics if images are on the frame
     230                        // Turn off XRay mode and load the first frame
     231                        FrameGraphics.setMode(FrameGraphics.MODE_NORMAL, false);
     232                        FrameUtils.loadFirstFrame(profile);
     233                        DisplayIO.UpdateTitle();
     234
     235                        /*
     236                         * I think this can be moved back up to the top of the Go method
     237                         * now... It used to crash the program trying to print error
     238                         * messages up the top
     239                         */
     240                        for (String message : warningMessages)
     241                                MessageBay.warningMessage(message);
     242
     243                        this.getContentPane().addKeyListener(FrameKeyboardActions.getInstance());
     244                        this.addKeyListener(FrameKeyboardActions.getInstance());
     245
     246                        _mouseEventRouter.addExpediteeMouseListener(FrameMouseActions
     247                                        .getInstance());
     248                        _mouseEventRouter.addExpediteeMouseMotionListener(FrameMouseActions
     249                                        .getInstance());
     250                        _mouseEventRouter.addExpediteeMouseWheelListener(FrameMouseActions
     251                                        .getInstance());
     252
     253                        /*
     254                         * Dont refresh for the profile frame otherwise error messages are
     255                         * shown twice
     256                         */
     257                        if (!DisplayIO.getCurrentFrame().equals(profile))
     258                                FrameKeyboardActions.Refresh();
     259                        // setVisible(true);
     260                } catch (Exception e) {
     261                        e.printStackTrace();
     262                        Logger.Log(e);
     263                }
     264        }
     265
     266        /**
     267         * @param userName
     268         * @return
     269         */
     270        private Frame loadProfile(String userName) {
    156271                Frame profile = FrameIO.LoadProfile(userName);
    157272                if (profile == null) {
     
    165280                        }
    166281                }
    167 
    168                 // Need to display errors once things have been init otherwise
    169                 // exceptions occur if there are more than four messages neededing to be
    170                 // displayed.
    171                 Collection<String> warningMessages = FrameUtils.ParseProfile(profile);
    172 
    173                 // set the layout to absolute layout for widgets
    174                 this.getContentPane().setLayout(new AbsoluteLayout());
    175                
    176                 _mouseEventRouter = new MouseEventRouter(getJMenuBar(), getContentPane());
    177                
    178                 // enable the glasspane-for capturing all mouse events
    179                 this.setGlassPane(_mouseEventRouter);
    180                
    181                 this.getGlassPane().setVisible(true);
    182                 this.getContentPane().setBackground(Color.white);
    183                 this.getContentPane().setFocusTraversalKeysEnabled(false);
    184 
    185                 addComponentListener(this);
    186                 pack();
    187 
    188                 // Reset windows to user specified size
    189                 // Must be done after initialising the content pane above!
    190                 setSizes(new Dimension(UserSettings.InitialWidth,
    191                                 UserSettings.InitialHeight));
    192 
    193                 // See java bug ID 4016934. They say that window closed events are
    194                 // called once the
    195                 // jframe is disposed.
    196                 setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    197 
    198                 // Expeditee handles its own repainting of AWT/Swing components
    199                 RepaintManager.setCurrentManager(ExpediteeRepaintManager.getInstance());
    200 
    201                 // Listen for save status to display during and after runtime
    202                 EntitySaveManager.getInstance().addSaveStateChangedEventListener(this);
    203 
    204                 String version = System.getProperty("java.version");
    205 
    206                 if (version.startsWith("1.6")) {
    207                         // Set the drag and drop handler
    208                         _version6 = true;
    209                         setTransferHandler(FrameDNDTransferHandler.getInstance());
    210                 } else {
    211                         System.out.println("Upgrade to Java 1.6 to enable drag and drop");
    212                 }
    213 
    214                 try {
    215                         warningMessages.addAll(Actions.Init());
    216 
    217                         DisplayIO.Init(this);
    218                         // Set visible must be just after DisplayIO.Init for the message box
    219                         // to
    220                         // be the right size
    221                         setVisible(true);
    222 
    223                         setupGraphics();
    224 
    225                         // required to accept TAB key
    226                         setFocusTraversalKeysEnabled(false);
    227 
    228                         // Must be loaded after setupGraphics if images are on the frame
    229                         // Turn off XRay mode and load the first frame
    230                         FrameGraphics.setMode(FrameGraphics.MODE_NORMAL, false);
    231                         FrameUtils.loadFirstFrame(profile);
    232                         DisplayIO.UpdateTitle();
    233 
    234                         // I think this can be moved back up to the top of the Go method
    235                         // now...
    236                         // It used to crash the program trying to print error messages up
    237                         // the top
    238                         for (String message : warningMessages)
    239                                 MessageBay.warningMessage(message);
    240 
    241                         this.getContentPane().addKeyListener(FrameKeyboardActions.getInstance());
    242                         this.addKeyListener(FrameKeyboardActions.getInstance());
    243                        
    244                         _mouseEventRouter.addExpediteeMouseListener(FrameMouseActions.getInstance());
    245                         _mouseEventRouter.addExpediteeMouseMotionListener(FrameMouseActions.getInstance());
    246                         _mouseEventRouter.addExpediteeMouseWheelListener(FrameMouseActions.getInstance());
    247 
    248                         FrameKeyboardActions.Refresh();
    249                         // setVisible(true);
    250                 } catch (Exception e) {
    251                         e.printStackTrace();
    252                         Logger.Log(e);
    253                 }
     282                return profile;
    254283        }
    255284
     
    455484                                        MessageBay.displayMessage("System exited");
    456485
    457                                         //Finally remove the messages frameset
    458                                         FrameIO.moveFrameset("messages",
    459                                                         FrameIO.MESSAGES_PATH);
     486                                        // Finally remove the messages frameset
     487                                        FrameIO.moveFrameset("messages", FrameIO.MESSAGES_PATH);
     488
     489                                        /*
     490                                         * Create a new messages folder so that it doesn't throw
     491                                         * Exceptions when two Expeditee's open at once and the
     492                                         * second tries to save its messages
     493                                         */
     494                                        File file = new File(FrameIO.MESSAGES_PATH + "messages");
     495                                        file.mkdirs();
    460496
    461497                                        System.exit(0);
  • trunk/src/org/expeditee/gui/DisplayIO.java

    r336 r348  
    7171         * The title to display in the Title bar.
    7272         */
    73         public static final String TITLE = "Exp22Sep2008A";
     73        public static final String TITLE = "Exp03Oct2008A";
    7474
    7575        private DisplayIO() {
     
    806806                _Robot.keyRelease(key);
    807807                // _Robot.waitForIdle();
    808                 Thread.sleep(100);
     808                Thread.sleep(200);
    809809        }
    810810
  • trunk/src/org/expeditee/gui/Frame.java

    r336 r348  
    999999                s.append(String.format("Name: %s%d%n", _frameset, _number));
    10001000                s.append(String.format("Version: %d%n", _version));
    1001                 //s.append(String.format("Permission: %s%n", _permission.toString()));
    1002                 //s.append(String.format("Owner: %s%n", _owner));
    1003                 //s.append(String.format("Date Created: %s%n", _creationDate));
    1004                 //s.append(String.format("Last Mod. User: %s%n", _modifiedUser));
    1005                 //s.append(String.format("Last Mod. Date: %s%n", _modifiedDate));
     1001                // s.append(String.format("Permission: %s%n", _permission.toString()));
     1002                // s.append(String.format("Owner: %s%n", _owner));
     1003                // s.append(String.format("Date Created: %s%n", _creationDate));
     1004                // s.append(String.format("Last Mod. User: %s%n", _modifiedUser));
     1005                // s.append(String.format("Last Mod. Date: %s%n", _modifiedDate));
    10061006                s.append(String.format("Items: %d%n", _body.size()));
    10071007                return s.toString();
     
    14551455                // t.setMaxWidth(FrameGraphics.getMaxFrameSize().width);
    14561456                // if (t.getWidth() <= 0) {
    1457                 t.setRightMargin(FrameGraphics.getMaxFrameSize().width);
     1457//              String maxWidthString = getAnnotationValue("maxwidth");
     1458//              int width = FrameGraphics.getMaxFrameSize().width;
     1459//              if (maxWidthString != null) {
     1460//                      try {
     1461//                              width = Math.min(width, Integer.parseInt(maxWidthString));
     1462//                      } catch (NumberFormatException nfe) {
     1463//                      }
     1464//              }
     1465//
     1466//              t.setRightMargin(width);
    14581467                // }
    14591468                addItem(t);
  • trunk/src/org/expeditee/gui/FrameGraphics.java

    r311 r348  
    88import java.awt.GraphicsEnvironment;
    99import java.awt.Image;
     10import java.awt.Polygon;
    1011import java.awt.Rectangle;
    1112import java.awt.RenderingHints;
     
    146147                        if (DisplayIO.isTwinFramesOn()) {
    147148                                Frame opposite = DisplayIO.getOppositeFrame();
    148                                
    149                                 /*When running the test suite opposite may be null!*/
     149
     150                                /* When running the test suite opposite may be null! */
    150151                                if (opposite != null) {
    151                                 opposite.setBuffer(null);
    152                                 opposite.refreshSize();
     152                                        opposite.setBuffer(null);
     153                                        opposite.refreshSize();
    153154                                }
    154155                        }
     
    319320        public static void paintFrame(Frame toPaint, Area clip,
    320321                        boolean isActualFrame, boolean createVolitile, Graphics2D bg) {
    321                
     322
    322323                // Prepare render passes
    323324                if (isActualFrame) {
     
    328329                        }
    329330                }
    330                
     331
    331332                bg.setClip(clip);
    332333
     
    671672                                int cmp = aArea.compareTo(bArea);
    672673                                if (cmp == 0) {
    673                                         // System.out.println(a.getEnclosureID() + " " + b.getID());
    674                                         return new Integer(a.getEnclosureID()).compareTo(b
    675                                                         .getEnclosureID());
     674                                        // System.out.println(a.getEnclosureID() + " " +
     675                                        // b.getID());\
     676                                        //Shapes to the left go underneath
     677                                        Polygon pA = a.getEnclosedShape();
     678                                        Polygon pB = b.getEnclosedShape();
     679                                        if(pA == null || pB == null)
     680                                                return 0;
     681                                        return new Integer(pA.getBounds().x)
     682                                                        .compareTo(pB.getBounds().x);
    676683                                }
    677684                                return cmp * -1;
     
    920927                                damagedAreas.clear();
    921928                        }
    922                         //System.out.println("FULLSCREEN REFRESH"); // TODO: REMOVE
     929                        // System.out.println("FULLSCREEN REFRESH"); // TODO: REMOVE
    923930                }
    924931
     
    10321039         */
    10331040        public interface FrameRenderPass {
    1034                
     1041
    10351042                /**
    10361043                 *
    10371044                 * @param currentClip
    10381045                 *
    1039                  * @return
    1040                  *              The clip that the pass should use instead.
    1041                  *              i.e. if there are any effects that cannot invladate prior to paint call.
     1046                 * @return The clip that the pass should use instead. i.e. if there are
     1047                 *         any effects that cannot invladate prior to paint call.
    10421048                 */
    10431049                Area paintStarted(Area currentClip);
    1044                
     1050
    10451051                void paintFinalPass(Graphics g);
    1046                
     1052
    10471053                void paintPreLayeredPanePass(Graphics g);
    10481054        }
  • trunk/src/org/expeditee/gui/FrameIO.java

    r336 r348  
    11package org.expeditee.gui;
    22
     3import java.io.BufferedOutputStream;
    34import java.io.BufferedReader;
    45import java.io.BufferedWriter;
     
    1011import java.io.FileWriter;
    1112import java.io.IOException;
     13import java.io.OutputStream;
     14import java.io.OutputStreamWriter;
     15import java.io.Writer;
    1216import java.sql.Time;
    1317import java.util.Collection;
     
    653657                                + template.getName() + " from TDFC");
    654658
    655                 template.setOwner(UserSettings.Username);
     659                template.setOwner(UserSettings.UserName);
    656660                template.resetDateCreated();
    657661                for (Item i : template.getItems()) {
     
    664668
    665669                if (!DisplayIO.isTwinFramesOn()) {
    666                         // BROOK: This had recursion!! Changed to avoid...
    667670                        if ((titleItem.getX() + 1) < template.getNameItem().getX()) {
    668                                 while (titleItem.getBoundsWidth() + titleItem.getX() > template
     671                                while (titleItem.getSize() > Text.MINIMUM_FONT_SIZE && titleItem.getBoundsWidth() + titleItem.getX() > template
    669672                                                .getNameItem().getX()) {
    670673                                        titleItem.setSize(titleItem.getSize() - 1);
     674                                       
    671675                                }
    672676                        } else {
     
    832836                                savedVersion = KMSReader.getVersion(fullPath);
    833837                        }
     838
     839                        // Check if the frame doesnt exist
     840//                      if (savedVersion < 0) {
     841//                              /*
     842//                               * This will happen if the user has two Expeditee's running at
     843//                               * once and closes the first. When the second one closes the
     844//                               * messages directory will have been deleted.
     845//                               */
     846//                              MessageBay
     847//                                              .errorMessage("Could not save frame that does not exist: "
     848//                                                              + toSave.getName());
     849//                              return null;
     850//                      }
     851
    834852                        // Check if we are trying to save an out of date version
    835853                        if (savedVersion > toSave.getVersion()
     
    944962                if (toCheck.getNumber() == 0)
    945963                        return false;
    946                 return toCheck.getFramesetName()
    947                                 .equalsIgnoreCase(UserSettings.Username);
     964                return toCheck.getPath().equals(PROFILE_PATH);
     965                //return toCheck.getFramesetName()
     966                //              .equalsIgnoreCase(UserSettings.ProfileName);
    948967        }
    949968
     
    954973        public static Frame CreateNewProfile(String username) throws Exception {
    955974                Frame profile = CreateFrameset(username, PROFILE_PATH, true);
    956                 FrameUtils.CreateDefaultProfile(profile);
     975                FrameUtils.CreateDefaultProfile(username, profile);
    957976                return profile;
    958977        }
     
    14451464                // Save the new version
    14461465                try {
    1447                         FileWriter fw = new FileWriter(file);
     1466                        // FileWriter fw = new FileWriter(file);
     1467
     1468                        // Open an Output Stream Writer to set encoding
     1469                        OutputStream fout = new FileOutputStream(file);
     1470                        OutputStream bout = new BufferedOutputStream(fout);
     1471                        Writer fw = new OutputStreamWriter(bout, "UTF-8");
     1472
    14481473                        String nextLine = null;
    14491474                        while ((nextLine = packetContents.readLine()) != null) {
     
    14701495        public static void setSavedProperties(Frame toSave) {
    14711496                toSave.setLastModifyDate(Logger.EasyDateFormat("ddMMMyyyy:HHmm"));
    1472                 toSave.setLastModifyUser(UserSettings.Username);
     1497                toSave.setLastModifyUser(UserSettings.UserName);
    14731498                toSave.setVersion(toSave.getVersion() + 1);
    14741499                Time darkTime = new Time(SessionStats.getFrameDarkTime().getTime()
  • trunk/src/org/expeditee/gui/FrameKeyboardActions.java

    r345 r348  
    219219                } else {
    220220                        text.setRightMargin(FrameGraphics.getMaxFrameSize().width);
     221
     222                        // Check for the annotation that restricts the width of text items
     223                        // on the frame
     224                        String widthString;
     225                        if ((widthString = text.getParentOrCurrentFrame()
     226                                        .getAnnotationValue("maxwidth")) != null) {
     227                                try {
     228                                        int width = text.getWidth();
     229                                        int maxWidth = Integer.parseInt(widthString);
     230                                        if (maxWidth < width)
     231                                                text.setWidth(maxWidth);
     232                                } catch (NumberFormatException nfe) {
     233                                }
     234                        }
    221235                }
    222236        }
     
    912926                        break;
    913927                case KeyEvent.VK_S:
     928                        /*
     929                         * Only split when shift is down... it is too easy to accidentally
     930                         * hit Ctrl+S after completing a paragraph because this is the
     931                         * shortcut for saving a document in most word processors and text
     932                         * editors!
     933                         *
     934                         */
     935                        if (!isShiftDown){
     936                                Save();
     937                                return;
     938                        }
    914939                        Text text2 = getCurrentTextItem();
    915940                        // split the current text item
     
    10091034                                                Rectangle rect = firstConnected.getEnclosedShape()
    10101035                                                                .getBounds();
    1011                                                 DisplayIO.setCursorPosition(rect.x + Text.MARGIN_LEFT,
    1012                                                                 Text.MARGIN_LEFT
    1013                                                                                 + rect.y
    1014                                                                                 + DisplayIO.getCurrentFrame()
    1015                                                                                                 .getItemTemplate()
    1016                                                                                                 .getBoundsHeight());
     1036                                                int newX = rect.x + Text.MARGIN_LEFT;
     1037                                                int newY = Text.MARGIN_LEFT
     1038                                                                + rect.y
     1039                                                                + DisplayIO.getCurrentFrame().getItemTemplate()
     1040                                                                                .getBoundsHeight();
     1041                                                moveCursorAndFreeItems(newX, newY);
     1042                                                // TODO can resetOffset be put inside
     1043                                                // moveCursorAndFreeItems
     1044                                                FrameMouseActions.resetOffset();
    10171045                                        }
    10181046                                        break;
     
    12591287
    12601288                                dummyItem.setPosition(xPos, yPos);
    1261                                 DisplayIO.setCursorPosition(xPos, yPos);
     1289                                // DisplayIO.setCursorPosition(xPos, yPos);
     1290
     1291                                checkMovingCursor(dummyItem);
    12621292                        } else {
    12631293                                int yPos = column.get(0).getY() + 1;
     1294                                int xPos = column.get(0).getX();
    12641295                                // Either position the new item below the title or just above
    12651296                                // the first item below the title
    1266                                 if (toDropFrom == title && column.get(0) != title)
    1267                                         yPos = Math.min(column.get(0).getY() - 1, title.getY()
    1268                                                         + title.getBoundsHeight()
    1269                                                         + dummyItem.getBoundsHeight());
    1270                                 dummyItem.setPosition(column.get(0).getX(), yPos);
     1297                                if (toDropFrom == title && column.get(0) != title) {
     1298                                        // If dropping from the title position just above top item
     1299                                        yPos = column.get(0).getY() - 1;
     1300
     1301                                        Frame current = DisplayIO.getCurrentFrame();
     1302                                        // Check for @start on the zero frame
     1303                                        Frame zero = FrameIO
     1304                                                        .LoadFrame(current.getFramesetName() + '0');
     1305                                        Text start = zero.getAnnotation("start");
     1306                                        if (start != null) {
     1307                                                yPos = Math.min(yPos, start.getY());
     1308                                        }
     1309                                }
     1310                                dummyItem.setPosition(xPos, yPos);
    12711311                                column.add(dummyItem);
    12721312                                FrameUtils.Align(column, false, 0);
     
    13361376                                }
    13371377
    1338                                 // Move the item to the cursor position
    1339                                 if (FreeItems.itemsAttachedToCursor()) {
    1340                                         DisplayIO.setCursorPosition(dummyItem.getX(), dummyItem
    1341                                                         .getY());
    1342                                         Item firstItem = FreeItems.getItemAttachedToCursor();
    1343                                         int deltaX = firstItem.getX() - dummyItem.getX();
    1344                                         int deltaY = firstItem.getY() - dummyItem.getY();
    1345 
    1346                                         for (Item i : FreeItems.getInstance()) {
    1347                                                 i.setPosition(i.getX() - deltaX, i.getY() - deltaY);
    1348                                         }
    1349                                 } else {
    1350                                         DisplayIO.MoveCursorToEndOfItem(dummyItem);
    1351                                 }
     1378                                checkMovingCursor(dummyItem);
    13521379                        }
    13531380                        if (dummyItem.getText().length() == 0
     
    13671394                }
    13681395                return true;
     1396        }
     1397
     1398        /**
     1399         * @param dummyItem
     1400         */
     1401        private static void checkMovingCursor(Text dummyItem) {
     1402                // Move the item to the cursor position
     1403                if (FreeItems.itemsAttachedToCursor()) {
     1404                        moveCursorAndFreeItems(dummyItem.getX(), dummyItem.getY());
     1405                } else {
     1406                        DisplayIO.MoveCursorToEndOfItem(dummyItem);
     1407                }
     1408        }
     1409
     1410        /**
     1411         * @param dummyItem
     1412         */
     1413        public static void moveCursorAndFreeItems(int x, int y) {
     1414                DisplayIO.setCursorPosition(x, y);
     1415                Item firstItem = FreeItems.getItemAttachedToCursor();
     1416                int deltaX = firstItem.getX() - x;
     1417                int deltaY = firstItem.getY() - y;
     1418
     1419                for (Item i : FreeItems.getInstance()) {
     1420                        i.setPosition(i.getX() - deltaX, i.getY() - deltaY);
     1421                }
    13691422        }
    13701423
     
    15901643                                toSize.addAll(toSet.getLines());
    15911644                        } else if (toSet instanceof Line) {
    1592                                
     1645
    15931646                                Line line = (Line) toSet;
    1594                                
    1595                                 if (!(toSet instanceof WidgetEdge) || ((WidgetEdge)toSet).getWidgetSource().isWidgetEdgeThicknessAdjustable()) {
     1647
     1648                                if (!(toSet instanceof WidgetEdge)
     1649                                                || ((WidgetEdge) toSet).getWidgetSource()
     1650                                                                .isWidgetEdgeThicknessAdjustable()) {
    15961651
    15971652                                        float current = Math.abs(line.getThickness());
     
    16001655                                        FrameGraphics.Repaint();
    16011656                                        return;
    1602        
    1603                                 }
    1604                                
     1657
     1658                                }
     1659
    16051660                        } else {
    16061661                                toSize.add(toSet);
     
    16201675
    16211676                                if (i.isLineEnd()) {
    1622                                        
    1623                                         if (!(i instanceof WidgetCorner) || !((WidgetCorner)i).getWidgetSource().isFixedSize()) { // don't size fixed widgets
    1624                                                
     1677
     1678                                        if (!(i instanceof WidgetCorner)
     1679                                                        || !((WidgetCorner) i).getWidgetSource()
     1680                                                                        .isFixedSize()) { // don't size fixed
     1681                                                // widgets
     1682
    16251683                                                Collection<Item> allConnected = i.getAllConnected();
    16261684                                                done.addAll(allConnected);
    16271685                                                for (Item it : allConnected) {
    16281686                                                        it.translate(origin, ratio);
    1629                                                         it
    1630                                                                         .setArrowheadLength((float) (it
    1631                                                                                         .getArrowheadLength() * ratio));
     1687                                                        it.setArrowheadLength((float) (it
     1688                                                                        .getArrowheadLength() * ratio));
    16321689                                                }
    16331690                                                i.setThickness((float) (i.getThickness() * ratio));
     
    16381695                                        // Ensure that the source is done before the XRayable
    16391696                                        if (!done.contains(source)) {
    1640                                                 scaleText(origin, ratio, done, source);
     1697                                                scaleText(insideEnclosure, origin, ratio, done, source);
    16411698                                        }
    16421699
     
    16621719                                        item.getParent().parse();
    16631720                                } else if (i instanceof Text) {
    1664                                         scaleText(origin, ratio, done, (Text) i);
     1721                                        scaleText(insideEnclosure, origin, ratio, done, (Text) i);
    16651722                                }
    16661723                        }
     
    17271784         * @param source
    17281785         */
    1729         private static void scaleText(Point2D origin, double ratio,
     1786        private static void scaleText(boolean insideEnclosure, Point2D origin, double ratio,
    17301787                        Collection<Item> done, Text source) {
     1788                if(insideEnclosure)
     1789                        source.setWidth(Math.round((float) (source.getWidth() * ratio)));
    17311790                source.translate(origin, ratio);
    17321791                source.setSize((float) (source.getSize() * ratio));
     
    21172176        public static void Refresh() {
    21182177                Frame currentFrame = DisplayIO.getCurrentFrame();
    2119                
    2120                 //Refresh widgets that use its self as a data source
     2178
     2179                // Refresh widgets that use its self as a data source
    21212180                currentFrame.notifyObservers();
    2122                
     2181
    21232182                if (FrameIO.isProfileFrame(currentFrame)) {
    21242183                        // TODO ensure that users can not delete the first frame in a
  • trunk/src/org/expeditee/gui/FrameMouseActions.java

    r320 r348  
    649649                if (clicked instanceof Text) {
    650650                        Text text = (Text) clicked;
    651                         /*Dont follow link when just highlighting text with the left button*/
     651                        /* Dont follow link when just highlighting text with the left button */
    652652                        if (text.getText().length() == 0)
    653653                                clicked = null;
    654                         else if (text.getSelectionSize() > 0){
     654                        else if (text.getSelectionSize() > 0) {
    655655                                return;
    656656                        }
     
    689689                if (clicked != null) {
    690690                        // check item permissions
    691                         if (!clicked.hasPermission(Permission.followLinks)) {
     691                        if ((clicked.hasLink() && !clicked
     692                                        .hasPermission(Permission.followLinks))
     693                                        || (!clicked.hasLink() && !clicked
     694                                                        .hasPermission(Permission.createFrames))) {
    692695                                Item editTarget = clicked.getEditTarget();
    693696                                if (editTarget != clicked
     
    16091612        private void mouseMoved(MouseEvent e, boolean shiftStateChanged) {
    16101613
    1611                 //System.out.println(_context);
     1614                // System.out.println(_context);
    16121615                if (_context == CONTEXT_FREESPACE)
    16131616                        FrameKeyboardActions.resetEnclosedItems();
     
    20432046                // around it
    20442047                String text = linker.getText();
    2045                 if (text.equals("@v") || text.equals("@f")) {
     2048                boolean isVector = text.equals("@v") || text.equals("@av");
     2049
     2050                if (isVector || text.equals("@f")) {
    20462051                        Collection<Item> enclosure = FrameUtils.getEnclosingLineEnds(linker
    20472052                                        .getPosition());
     
    20492054                                for (Item i : enclosure) {
    20502055                                        if (i.isLineEnd() && i.isEnclosed()) {
    2051                                                 DisplayIO.getCurrentFrame().removeAllItems(enclosure);
     2056                                                if (!isVector)
     2057                                                        DisplayIO.getCurrentFrame().removeAllItems(
     2058                                                                        enclosure);
    20522059                                                Rectangle rect = i.getEnclosedRectangle();
    20532060                                                long width = Math.round(rect.getWidth());
    2054                                                 if (text.equals("@v")) {
     2061                                                if (isVector) {
    20552062                                                        NumberFormat nf = Vector.getNumberFormatter();
    2056                                                         linker.setText("@v: "
     2063                                                        linker.setText(linker.getText()
     2064                                                                        + ": "
    20572065                                                                        + nf.format((width / FrameGraphics
    20582066                                                                                        .getMaxFrameSize().getWidth())));
     
    20672075                                        }
    20682076                                }
    2069                                 FrameMouseActions.deleteItems(enclosure, false);
     2077                                if (!isVector)
     2078                                        FrameMouseActions.deleteItems(enclosure, false);
    20702079                        }
    20712080                }
     
    29832992                return new Point(getX(), getY());
    29842993        }
    2985        
     2994
    29862995        public static Point getFreeItemsOffset() {
    29872996                return new Point(_offX, _offY);
  • trunk/src/org/expeditee/gui/FrameUtils.java

    r336 r348  
    5454        public static int MINIMUM_INTERITEM_SPACING = -6;
    5555
     56        public static Double MAXIMUM_SPACING_RATIO = null;
     57
     58        public static Double MINIMUM_SPACING_RATIO = null;
     59
    5660        public static float getResponseTimeTotal() {
    5761                return _ResponseTimeSum;
     
    148152                Collections.sort(toAlign);
    149153
    150                 // Single items dont need alignment
    151                 if (toAlign.size() < 2)
     154                /*
     155                 * Single items dont need alignment But if there are two items we may
     156                 * still want to format them... ie if they are too close together.
     157                 */
     158                if (toAlign.size() < 1)
    152159                        return 0;
    153160
     
    215222                        if (space < MINIMUM_INTERITEM_SPACING)
    216223                                space = MINIMUM_INTERITEM_SPACING;
     224
     225                        if (MAXIMUM_SPACING_RATIO != null) {
     226                                double maxSpace = MAXIMUM_SPACING_RATIO * above.getSize();
     227                                if (maxSpace < space) {
     228                                        space = (int) Math.round(maxSpace);
     229                                }
     230                        }
     231
     232                        if (MINIMUM_SPACING_RATIO != null) {
     233                                double minSpace = MINIMUM_SPACING_RATIO * above.getSize();
     234                                if (minSpace > space) {
     235                                        space = (int) Math.round(minSpace);
     236                                }
     237                        }
    217238
    218239                        if (above != curr.getNameItem() && above != curr.getTitleItem())
     
    451472
    452473        public static void DisplayProfileFrame() {
    453                 DisplayFrame(UserSettings.Username + '1');
     474                DisplayFrame(UserSettings.ProfileName + '1');
    454475        }
    455476
     
    576597                                        UserSettings.HomeFrame = profile.getName();
    577598                                }
    578                         } else if (attribute.equals("menuframe"))
    579                                 UserSettings.MenuFrame = getLink(item, UserSettings.MenuFrame);
    580                         else if (attribute.equals("defaultframe"))
     599                        } else if (attribute.equals("username")) {
     600                                UserSettings.UserName = avp.getValue();
     601                        } else if (attribute.equals("defaultframe"))
    581602                                UserSettings.DefaultFrame = getLink(item,
    582603                                                UserSettings.DefaultFrame);
     
    599620                        else if (attribute.equals("noopthreshold"))
    600621                                UserSettings.NoOpThreshold = avp.getIntegerValue();
    601                         else if (attribute.equals("initialwidth")) {
     622                        else if (attribute.equals("formatspacingmin")) {
     623                                FrameUtils.MINIMUM_SPACING_RATIO = avp.getDoubleValue();
     624                        } else if (attribute.equals("formatspacingmax")) {
     625                                FrameUtils.MAXIMUM_SPACING_RATIO = avp.getDoubleValue();
     626                        } else if (attribute.equals("initialwidth")) {
    602627                                UserSettings.InitialWidth = avp.getIntegerValue();
    603628                        } else if (attribute.equals("initialheight")) {
     
    670695        }
    671696
     697        /**
     698         * Sets the first frame to be displayed.
     699         *
     700         * @param profile
     701         */
    672702        public static void loadFirstFrame(Frame profile) {
    673703                if (UserSettings.HomeFrame == null)
    674704                        UserSettings.HomeFrame = profile.getName();
    675                 // else {
     705
    676706                Frame firstFrame = FrameIO.LoadFrame(UserSettings.HomeFrame);
    677707                if (firstFrame == null) {
     
    683713                        DisplayIO.setCurrentFrame(firstFrame, true);
    684714                }
    685                 // }
     715
    686716        }
    687717
     
    13631393         * Fills the given Frame with default profile tags
    13641394         */
    1365         public static void CreateDefaultProfile(Frame profile) {
     1395        public static void CreateDefaultProfile(String username, Frame profile) {
    13661396                Text title = profile.getTitleItem();
    1367                 title.setText("Profile Frame");
     1397                if(username.equals(UserSettings.DEFAULT_PROFILE_NAME)){
     1398                        title.setText("Default Profile Frame");
     1399                }else{
     1400                        title.setText(username + "'s Profile Frame");
     1401                }
    13681402                title.setSize(50);
    13691403                title.setFontStyle("Bold");
     
    13781412
    13791413                yPos += spacing;
    1380                 profile.addText(xPos, yPos, "HomeFrame: " + profile.getName(), null,
     1414                profile.addText(xPos, yPos, "@HomeFrame: " + profile.getName(), null,
    13811415                                profile.getName());
    13821416                yPos += spacing;
    13831417                String defaultFrameName = profile.getFramesetName() + "0";
    1384                 profile.addText(xPos, yPos, "DefaultFrame: " + defaultFrameName, null,
     1418                profile.addText(xPos, yPos, "@DefaultFrame: " + defaultFrameName, null,
    13851419                                defaultFrameName);
    13861420                yPos += spacing;
    13871421
    1388                 profile.addText(xPos, yPos, "InitialWidth: "
     1422                profile.addText(xPos, yPos, "@InitialWidth: "
    13891423                                + UserSettings.InitialWidth, null);
    13901424                yPos += spacing;
    13911425
    1392                 profile.addText(xPos, yPos, "InitialHeight: "
     1426                profile.addText(xPos, yPos, "@InitialHeight: "
    13931427                                + UserSettings.InitialHeight, null);
    13941428                yPos += spacing;
    13951429
    1396                 Text t = profile.addText(xPos, yPos, "ItemTemplate", null);
     1430                Text t = profile.addText(xPos, yPos, "@ItemTemplate", null);
    13971431                t.setColor(null);
    13981432
    13991433                yPos += spacing;
    1400                 t = profile.addText(xPos, yPos, "AnnotationTemplate", null);
     1434                t = profile.addText(xPos, yPos, "@AnnotationTemplate", null);
    14011435                t.setColor(Color.gray);
    14021436
    14031437                yPos += spacing;
    1404                 t = profile.addText(xPos, yPos, "CommentTemplate", null);
     1438                t = profile.addText(xPos, yPos, "@CommentTemplate", null);
    14051439                t.setColor(Color.green.darker());
    14061440
    14071441                yPos += spacing;
    1408                 t = profile.addText(xPos, yPos, "StatsTemplate", null);
     1442                t = profile.addText(xPos, yPos, "@StatsTemplate", null);
    14091443                t.setColor(Color.BLACK);
    14101444                t.setBackgroundColor(new Color(0.9F, 0.9F, 0.9F));
     
    14131447
    14141448                xPos = 600;
    1415                 yPos = intialYPos;
     1449                yPos = intialYPos + spacing;
    14161450
    14171451                // Iterate through the help folder and add links
  • trunk/src/org/expeditee/gui/Reminders.java

    r285 r348  
    5858                                                                _alertsRunning--;
    5959                                                                reminderItem.setText("@" + reminderItem.getText());
     60                                                                FrameIO.ForceSaveFrame(reminderItem.getParent());
    6061                                                                if (_alertsRunning == 0) {
    6162                                                                        _bStop = false;
  • trunk/src/org/expeditee/gui/UserSettings.java

    r311 r348  
    1414 */
    1515public abstract class UserSettings {
     16       
     17        public final static String DEFAULT_PROFILE_NAME = "default";
    1618
    1719        public static List<Text> Style = new LinkedList<Text>();;
     
    3133        public static int InitialHeight = 768;
    3234       
    33         public static String Username;
    34 
     35        public static String ProfileName;
     36       
     37        public static String UserName;
     38       
    3539        public static String DefaultFrame = null;
    3640
  • trunk/src/org/expeditee/io/AbstractHTMLWriter.java

    r309 r348  
    2626                _writer.write("<html>" + ItemWriter.NEW_LINE);
    2727                _writer.write("<head>" + ItemWriter.NEW_LINE);
     28                _writer
     29                                .write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">");
    2830                _writer.write("<title>" + start.getTitle());
    2931                _writer.write("</title>" + ItemWriter.NEW_LINE);
     
    5961                                + Conversion.getCssFontFamily(font.getFamily()));
    6062
    61                 //writer.write("; font-size: " + Math.round(style.getSize()) + "px");
    62                
     63                // writer.write("; font-size: " + Math.round(style.getSize()) + "px");
     64
    6365                if (font.isBold()) {
    6466                        writer.write("; font-weight: bold");
  • trunk/src/org/expeditee/io/DefaultFrameWriter.java

    r309 r348  
    22
    33import java.awt.Desktop;
     4import java.io.BufferedOutputStream;
    45import java.io.File;
    5 import java.io.FileWriter;
     6import java.io.FileOutputStream;
    67import java.io.IOException;
     8import java.io.OutputStream;
     9import java.io.OutputStreamWriter;
    710import java.io.Writer;
    811import java.lang.reflect.Method;
     
    8790                        _ItemTags.put("e", Item.class.getMethod("getFillColor", param));
    8891                        _ItemTags.put("E", Item.class.getMethod("getGradientColor", param));
     92                        _ItemTags.put("Q", Item.class.getMethod("getGradientAngle", param));
    8993
    9094                        _ItemTags.put("i", Item.class.getMethod("getFillPattern", param));
     
    198202                        File test = new File(_filename);
    199203
    200                         test = test.getParentFile();
    201                         if (test != null && !test.exists()) {
    202                                 test.mkdirs();
    203                         }
    204 
    205                         _writer = new ProxyWriter(new FileWriter(_filename));
     204                        File parent = test.getParentFile();
     205                        if (parent != null && !parent.exists()) {
     206                                parent.mkdirs();
     207                        }
     208
     209                        // Open an Output Stream Writer to set encoding
     210                        OutputStream fout = new FileOutputStream(_filename);
     211                        OutputStream bout = new BufferedOutputStream(fout);
     212                        Writer out = new OutputStreamWriter(bout, "UTF-8");
     213
     214                        _writer = new ProxyWriter(out);
    206215                        _output = _filename;
    207216                }
  • trunk/src/org/expeditee/io/ExpReader.java

    r298 r348  
    271271                } catch (Exception e) {
    272272                }
    273                 return 0;
     273                return -1;
    274274        }
    275275}
  • trunk/src/org/expeditee/io/ExpWriter.java

    r306 r348  
    11package org.expeditee.io;
    22
     3import java.io.BufferedOutputStream;
    34import java.io.File;
    4 import java.io.FileWriter;
     5import java.io.FileOutputStream;
    56import java.io.IOException;
     7import java.io.OutputStream;
     8import java.io.OutputStreamWriter;
    69import java.io.Writer;
    710import java.lang.reflect.Method;
     
    1215import org.expeditee.agents.DefaultAgent;
    1316import org.expeditee.gui.Frame;
     17import org.expeditee.gui.MessageBay;
    1418import org.expeditee.items.Constraint;
    1519import org.expeditee.items.Item;
     
    4549
    4650                _stringWriter = new StringBuilder();
    47                
    48                
    49                 if (writer != null){
     51
     52                if (writer != null) {
    5053                        _writer = new ProxyWriter(writer);
    5154                        _output = writer.toString();
    52                 }else if (_filename.equalsIgnoreCase(DefaultAgent.CLIPBOARD)) {
     55                } else if (_filename.equalsIgnoreCase(DefaultAgent.CLIPBOARD)) {
    5356                        _writer = new ProxyWriter(true);
    5457                        _filename = DefaultAgent.CLIPBOARD;
    55                 } else
    56                         _writer = new ProxyWriter(new FileWriter(_filename));
    57                
    58                
    59                
     58                } else {
     59                        // Open an Output Stream Writer to set encoding
     60                        OutputStream fout = new FileOutputStream(_filename);
     61                        OutputStream bout = new BufferedOutputStream(fout);
     62                        Writer out = new OutputStreamWriter(bout, "UTF-8");
     63
     64                        _writer = new ProxyWriter(out);
     65                }
     66
    6067                try {
    6168                        _FrameTags.remove("A");
    62                         _ItemTags.put("S", Item.class.getMethod("getTypeAndID", new Class[] {}));
     69                        _ItemTags.put("S", Item.class.getMethod("getTypeAndID",
     70                                        new Class[] {}));
    6371                } catch (Exception e) {
    6472
     
    6775
    6876        /**
    69          * Writes the given Frame (and all items it contains) to a Expeditee file. Note:
    70          * File path and location must be set before calling this or it will do
    71          * nothing.
     77         * Writes the given Frame (and all items it contains) to a Expeditee file.
     78         * Note: File path and location must be set before calling this or it will
     79         * do nothing.
    7280         *
    7381         * @param frame
     
    8290                writeHeader(frame);
    8391
    84 
    8592                // write each item in the frame
    8693                for (Item i : frame.getItemsToSave()) {
    87                         assert(!(i instanceof Line));
     94                        assert (!(i instanceof Line));
    8895                        writeItem(i);
    8996                }
     
    96103                writeTerminator();
    97104                writeLine(SessionStats.getFrameEventList(frame));
    98                
     105
    99106                return;
    100107        }
     
    139146                _stringWriter.append(toWrite);
    140147        }
    141        
     148
    142149        // writes the given Item out to the file
    143150        // This method is not used to write out LINE items
  • trunk/src/org/expeditee/io/FrameReader.java

    r298 r348  
    55import java.awt.Point;
    66import java.io.BufferedReader;
     7import java.io.FileInputStream;
    78import java.io.FileReader;
    89import java.io.IOException;
     10import java.io.InputStreamReader;
     11import java.io.Reader;
    912import java.lang.reflect.Method;
    1013import java.util.LinkedHashMap;
     
    9396                        _ItemTags.put('e', Item.class.getMethod("setFillColor", pColor));
    9497                        _ItemTags.put('E', Item.class.getMethod("setGradientColor", pColor));
     98                        _ItemTags.put('Q', Item.class.getMethod("setGradientAngle", pInt));
     99                       
    95100                        _ItemTags.put('i', Item.class.getMethod("setFillPattern", pString));
    96101                        _ItemTags.put('o', Item.class.getMethod("setOwner", pString));
     
    129134       
    130135        public Frame readFrame(String fullPath) throws IOException {
    131                 return readFrame(new BufferedReader(new FileReader(fullPath)));
     136                Reader in = new InputStreamReader(new FileInputStream(fullPath), "UTF-8");
     137                return readFrame(new BufferedReader(in));
    132138        }
    133139       
  • trunk/src/org/expeditee/io/KMSReader.java

    r298 r348  
    550550                } catch (Exception e) {
    551551                }
    552                 return 0;
     552                return -1;
    553553        }
    554554}
  • trunk/src/org/expeditee/io/KMSWriter.java

    r306 r348  
    11package org.expeditee.io;
    22
     3import java.io.BufferedOutputStream;
    34import java.io.File;
     5import java.io.FileOutputStream;
    46import java.io.FileWriter;
    57import java.io.IOException;
     8import java.io.OutputStream;
     9import java.io.OutputStreamWriter;
    610import java.io.Writer;
    711import java.lang.reflect.InvocationTargetException;
     
    5054                        _writer = new ProxyWriter(true);
    5155                        _filename = DefaultAgent.CLIPBOARD;
    52                 } else
    53                         _writer = new ProxyWriter(new FileWriter(_filename));
    54 
     56                } else{
     57//                       Open an Output Stream Writer to set encoding
     58                        OutputStream fout = new FileOutputStream(_filename);
     59                        OutputStream bout = new BufferedOutputStream(fout);
     60                        Writer out = new OutputStreamWriter(bout, "UTF-8");
     61                        _writer = new ProxyWriter(out);
     62                }
     63               
    5564                try {
    5665                        _FrameTags.put("A", Frame.class.getMethod("getName", new Class[] {}));
  • trunk/src/org/expeditee/io/Logger.java

    r86 r348  
    11package org.expeditee.io;
    22
     3import java.io.BufferedOutputStream;
    34import java.io.BufferedWriter;
    45import java.io.File;
     6import java.io.FileOutputStream;
    57import java.io.FileWriter;
    68import java.io.IOException;
     9import java.io.OutputStream;
     10import java.io.OutputStreamWriter;
     11import java.io.Writer;
    712import java.sql.Time;
    813import java.text.SimpleDateFormat;
  • trunk/src/org/expeditee/io/PDF2Writer.java

    r306 r348  
    4949                        _pdfDocument.open();
    5050                        _pdfDocument.addCreationDate();
    51                         _pdfDocument.addAuthor(UserSettings.Username);
     51                        _pdfDocument.addAuthor(UserSettings.UserName);
    5252                        _pdfDocument.addCreator("Expeditee");
    5353                } catch (DocumentException e) {
  • trunk/src/org/expeditee/io/PDFWriter.java

    r309 r348  
    5252                        _pdfDocument.open();
    5353                        _pdfDocument.addCreationDate();
    54                         _pdfDocument.addAuthor(UserSettings.Username);
     54                        _pdfDocument.addAuthor(UserSettings.UserName);
    5555                        _pdfDocument.addCreator("Expeditee");
    5656                        _pdfDocument.addTitle(start.getTitle());
  • trunk/src/org/expeditee/io/PdfFramesetWriter.java

    r306 r348  
    7272                        _pdfDocument.open();
    7373                        _pdfDocument.addCreationDate();
    74                         _pdfDocument.addAuthor(UserSettings.Username);
     74                        _pdfDocument.addAuthor(UserSettings.UserName);
    7575                        _pdfDocument.addCreator("Expeditee");
    7676                } catch (DocumentException e) {
  • trunk/src/org/expeditee/items/Item.java

    r311 r348  
    7474        protected boolean _connectedToAnnotation = false;
    7575
     76        private int _gradientAngle = 0;
     77
    7678        public static final int NEAR_DISTANCE = 15;
    7779
     
    162164                dest.setFillColor(source.getFillColor());
    163165                dest.setGradientColor(source.getGradientColor());
     166                dest.setGradientAngle(source.getGradientAngle());
    164167                dest.setFillPattern(source.getFillPattern());
    165168
     
    182185                dest.setArrow(source.getArrowheadLength(), source.getArrowheadRatio());
    183186
    184                 // Calling the methods will move the item...
    185                 // This messes things up when the user uses backspace to delete a text
    186                 // line end
     187                /*
     188                 * Calling the methods will move the item... This messes things up when
     189                 * the user uses backspace to delete a text line end
     190                 */
    187191                dest._anchorBottom = source._anchorBottom;
    188192                dest._anchorRight = source._anchorRight;
     
    206210                // dest.setID(source.getID());
    207211                // }
     212        }
     213
     214        public void setGradientAngle(int gradientAngle) {
     215                _gradientAngle = gradientAngle;
     216
     217                for (Line line : _lines) {
     218                        Item other = line.getOppositeEnd(this);
     219                        if (other.getGradientAngle() != gradientAngle)
     220                                other.setGradientAngle(gradientAngle);
     221                }
     222
     223                invalidateCommonTrait(ItemAppearence.GradientColor);
     224                invalidateFill();
     225        }
     226
     227        public int getGradientAngle() {
     228                return _gradientAngle;
    208229        }
    209230
     
    10541075                Color gradientColor = getGradientColor();
    10551076                if (gradientColor != null) {
    1056                         // The painting is not efficient enough for gradients...
     1077                        /*
     1078                         * It is slow when painting gradients... modify so this is only done
     1079                         * once unless it is resized...
     1080                         */
    10571081                        Shape s = getEnclosedShape();
    10581082                        if (s != null) {
    10591083                                Rectangle b = s.getBounds();
    1060                                 GradientPaint gp = new GradientPaint(
    1061                                                 (int) (b.x + b.width * 0.3), b.y, fillColor,
    1062                                                 (int) (b.x + b.width * 1.3), b.y, gradientColor);
     1084                                double rads = getGradientAngle() * Math.PI / 180;
     1085                                double cos = Math.cos(rads);
     1086                                double sin = Math.sin(rads);
     1087
     1088                                GradientPaint gp = new GradientPaint((int) (b.x + b.width
     1089                                                * (0.2 * cos + 0.5)), (int) (b.y + b.height
     1090                                                * (0.2 * sin + 0.5)), fillColor, (int) (b.x + b.width
     1091                                                * (-0.8 * cos + 0.5)), (int) (b.y + b.height
     1092                                                * (-0.8 * sin + 0.5)), gradientColor);
    10631093                                g.setPaint(gp);
    10641094                        }
  • trunk/src/org/expeditee/items/Justification.java

    r147 r348  
    1616                assert (justCode != null);
    1717                justCode = justCode.trim().toLowerCase();
    18                
     18
    1919                // if it is a single char just match the first character
    2020                if (justCode.length() == 1) {
    21                         char code =justCode.charAt(0);
     21                        char code = justCode.charAt(0);
    2222                        Justification[] values = values();
    23                         for(int i = 1; i < values.length; i++) {
     23                        for (int i = 0; i < values.length; i++) {
    2424                                Justification j = values[i];
    25                                 if(Character.toLowerCase(j.name().charAt(0)) == code)
     25                                if (Character.toLowerCase(j.name().charAt(0)) == code)
    2626                                        return j;
    2727                        }
    2828                        // Otherwise match the whole string
    29                 }else{
    30                         try{
    31                         return valueOf(justCode);
    32                         }catch (Exception e) {
     29                } else {
     30                        try {
     31                                return valueOf(justCode);
     32                        } catch (Exception e) {
    3333                        }
    3434                }
  • trunk/src/org/expeditee/items/Text.java

    r336 r348  
    378378         */
    379379        public Point2D.Float insertChar(char ch, float mouseX, float mouseY) {
    380                 if (ch != '\t')
     380                if (ch != '\t') /* && ch != '\n'*/
    381381                        return insertText("" + ch, mouseX, mouseY);
    382382
     
    951951        private static final int NEARBY_GRAVITY = 2;
    952952
    953         private static final int MINIMUM_FONT_SIZE = 6;
     953        public static final int MINIMUM_FONT_SIZE = 6;
    954954
    955955        public void toggleFontFamily() {
     
    10411041                        return null;
    10421042
    1043                 if (_text.indexOf("\n") < 0)
    1044                         return _text.toString();
    1045 
    1046                 return _text.substring(0, _text.indexOf("\n"));
     1043                // start at the first non-newLine char
     1044                int index = 0;
     1045                while (_text.charAt(index) == '\n') {
     1046                        index++;
     1047                }
     1048
     1049                int nextNewLine = _text.indexOf("\n", index);
     1050
     1051                /* If there are no more newLines return the remaining text */
     1052                if (nextNewLine < 0)
     1053                        return _text.substring(index);
     1054
     1055                return _text.substring(index, nextNewLine);
    10471056        }
    10481057
     
    11501159                        // check if the cursor is within the top, bottom and within the
    11511160                        // gravity of right
     1161                        int justOffset = getJustOffset(text);
     1162
    11521163                        if (mouseY - textY > textOutline.getY()
    11531164                                        && mouseY - textY < textOutline.getY()
    11541165                                                        + textOutline.getHeight()
    1155                                         && mouseX - textX < textOutline.getWidth() + gravity
    1156                                                         + Item.MARGIN_RIGHT)
     1166                                        && mouseX - textX - justOffset < textOutline.getWidth()
     1167                                                        + gravity + Item.MARGIN_RIGHT
     1168                        /* &&(justOffset == 0 || mouseX > textX + justOffset - gravity ) */)
    11571169                                return true;
    11581170                        textY += getLineDrop(text);
     
    12021214                minX -= getLeftMargin();
    12031215                maxX += Item.MARGIN_RIGHT;
     1216
     1217                // If its justification right or center then DONT limit the width
     1218                if (getJustification() != null) {
     1219                        maxX = Item.MARGIN_RIGHT + getWidth();
     1220                }
    12041221
    12051222                _poly.addPoint(minX - getGravity(), minY - getGravity());
     
    15511568                copy.setText(_text.toString());
    15521569                copy.setHidden(!isVisible());
    1553                 copy.setWidth(getWidth());
     1570                // copy.setWidth(getWidth());
    15541571                return copy;
    15551572        }
     
    15801597                        size = MINIMUM_FONT_SIZE;
    15811598                setFont(getPaintFont().deriveFont(size));
     1599                rebuild(true);
    15821600                invalidateAll();
    15831601        }
  • trunk/src/org/expeditee/simple/Context.java

    r130 r348  
    11package org.expeditee.simple;
    22
     3import java.io.BufferedOutputStream;
    34import java.io.BufferedReader;
    45import java.io.BufferedWriter;
    56import java.io.File;
     7import java.io.FileOutputStream;
    68import java.io.FileReader;
    79import java.io.FileWriter;
     10import java.io.OutputStream;
     11import java.io.OutputStreamWriter;
     12import java.io.Writer;
    813
    914import org.expeditee.actions.Simple;
     
    132137                // Get the values to be set
    133138                File filePath = new File(primitives_.getStringValue(fileNameVar));
     139               
     140//               Open an Output Stream Writer to set encoding
     141                OutputStream fout = new FileOutputStream(filePath);
     142                Writer out = new OutputStreamWriter(fout, "UTF-8");
    134143                BufferedWriter currentFile = new BufferedWriter(
    135                                 new FileWriter(filePath));
     144                                out);
    136145
    137146                pointers_.setObject(fileVar, currentFile);
  • trunk/src/org/expeditee/stats/StatsLogger.java

    r78 r348  
    11package org.expeditee.stats;
    22
     3import java.io.BufferedOutputStream;
    34import java.io.BufferedWriter;
    45import java.io.File;
     6import java.io.FileOutputStream;
    57import java.io.FileWriter;
    68import java.io.IOException;
     9import java.io.OutputStream;
     10import java.io.OutputStreamWriter;
     11import java.io.Writer;
    712
    813import org.expeditee.io.Logger;
     
    5156                        BufferedWriter writer = new BufferedWriter(new FileWriter(
    5257                                        org.expeditee.gui.FrameIO.STATISTICS_DIR + _filename, true));
     58                       
    5359                        writer.write(SessionStats.getCurrentStats());
    5460                        writer.newLine();
Note: See TracChangeset for help on using the changeset viewer.