Changeset 282


Ignore:
Timestamp:
08/27/08 09:18:49 (16 years ago)
Author:
ra33
Message:
 
Location:
trunk/src/org/expeditee
Files:
28 edited
2 moved

Legend:

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

    r278 r282  
    234234         */
    235235        public static void LoadMethods(Class c) {
    236                 assert(c != null);
    237                
     236                assert (c != null);
     237
    238238                // list of methods to test
    239239                Method[] toLoad = c.getMethods();
     
    306306                String mname = getName(command);
    307307                command = command.substring(mname.length()).trim();
    308                 //If no params are provided get them from a text item on the cursor
    309                 if(command.length() == 0 && launcher instanceof Text){
     308                // If no params are provided get them from a text item on the cursor
     309                if (command.length() == 0 && launcher instanceof Text) {
    310310                        command = launcher.getText();
    311311                }
     
    366366                        }
    367367                }
    368                 //If the actions was not found... then it is run as an agent
     368                // If the actions was not found... then it is run as an agent
    369369                assert (possibles.size() > 0);
    370370                throw new RuntimeException("Incorrect parameters for " + mname);
     
    412412                        // determine correct parameters for constructor
    413413                        for (Constructor c : constructors) {
    414                                 if (parameters.length() > 0
    415                                                 && c.getParameterTypes().length == 1) {
     414                                Class[] paramTypes = c.getParameterTypes();
     415                                int paramCount = paramTypes.length;
     416                                if (paramCount > 0) {
     417                                        params = new Object[paramCount];
     418                                        String[] paramStrings = parameters.split("\\s+");
     419                                        if (paramCount != paramStrings.length)
     420                                                continue;
     421                                        for (int i = 0; i < paramCount; i++) {
     422                                                if (paramTypes[i].equals(int.class)
     423                                                                || paramTypes[i].equals(Integer.class)) {
     424                                                        try {
     425                                                                params[i] = Integer.parseInt(paramStrings[i]);
     426                                                        } catch (Exception e) {
     427                                                                continue;
     428                                                        }
     429                                                } else if (paramTypes[i].equals(double.class)
     430                                                                || paramTypes[i].equals(Double.class)) {
     431                                                        try {
     432                                                                params[i] = Double.parseDouble(paramStrings[i]);
     433                                                        } catch (Exception e) {
     434                                                                continue;
     435                                                        }
     436                                                } else if (paramTypes[i].equals(String.class)) {
     437                                                        params[i] = paramStrings[i];
     438                                                } else {
     439                                                        continue;
     440                                                }
     441                                        }
    416442                                        con = c;
    417                                         params = new String[1];
    418                                         params[0] = parameters;
    419443                                        break;
    420444                                } else if (c.getParameterTypes().length == 0 && con == null) {
     
    543567
    544568                // if the first class in the list is a frame or item, it is the source
    545                 //or launcher
     569                // or launcher
    546570                // length must be at least one if we are still running
    547571                if (paramTypes[ind] == Frame.class) {
     
    550574                }
    551575
    552                 //Check if the second item is an item
     576                // Check if the second item is an item
    553577                if (paramCount > ind && Item.class.isAssignableFrom(paramTypes[ind])) {
    554578                        objects[ind] = launcher;
    555579                        ind++;
    556                 }//If there is stuff on the cursor use it for the rest of the params
    557                 else if (launcher != null && launcher.isFloating()){
     580                }// If there is stuff on the cursor use it for the rest of the params
     581                else if (launcher != null && launcher.isFloating()) {
    558582                        values = launcher.getText();
    559583                }
     
    702726        }
    703727
    704         public static Object PerformActionCatchErrors(Frame current, Item launcher, String command) {
    705                 try{
     728        public static Object PerformActionCatchErrors(Frame current, Item launcher,
     729                        String command) {
     730                try {
    706731                        return PerformAction(current, launcher, command);
    707                 }catch(Exception e) {
     732                } catch (Exception e) {
    708733                        MessageBay.errorMessage(e.getMessage());
    709734                }
  • trunk/src/org/expeditee/actions/MailActions.java

    r247 r282  
    55import org.expeditee.agents.mail.MailSession;
    66import org.expeditee.gui.DisplayIO;
     7import org.expeditee.gui.Frame;
     8import org.expeditee.gui.FrameKeyboardActions;
    79import org.expeditee.gui.FrameMouseActions;
     10import org.expeditee.items.Item;
     11import org.expeditee.items.Text;
    812
    913public class MailActions {
     
    2731
    2832        public static String getNewMailString() {
    29                 String mail = MailSession.getInstance().getMailString(Flag.RECENT, true);
     33                String mail = MailSession.getInstance()
     34                                .getMailString(Flag.RECENT, true);
    3035                if (mail.length() == 0) {
    3136                        return "No new mail";
     
    4146                return mail;
    4247        }
    43        
     48
    4449        public static void getUnreadMail() {
    45                 MailSession.getInstance().getMail(Flag.SEEN, false, DisplayIO.getCurrentFrame(), FrameMouseActions.getPosition());
     50                MailSession.getInstance().getMail(Flag.SEEN, false,
     51                                DisplayIO.getCurrentFrame(), FrameMouseActions.getPosition());
    4652        }
    47        
     53
    4854        public static void getAllMail() {
    49                 MailSession.getInstance().getMail(null, null, DisplayIO.getCurrentFrame(), FrameMouseActions.getPosition());
     55                MailSession.getInstance().getMail(null, null,
     56                                DisplayIO.getCurrentFrame(), FrameMouseActions.getPosition());
    5057        }
    51        
     58
    5259        public static void getNewMail() {
    53                 MailSession.getInstance().getMail(Flag.RECENT, true, DisplayIO.getCurrentFrame(), FrameMouseActions.getPosition());
     60                MailSession.getInstance().getMail(Flag.RECENT, true,
     61                                DisplayIO.getCurrentFrame(), FrameMouseActions.getPosition());
    5462        }
    5563
     
    8391        }
    8492
     93        public static void reply(Frame frame, Item reply) {
     94                String fromAddress = frame.getAnnotationValue("from");
     95                if (fromAddress == null) {
     96                        return;
     97                }
     98                String fromName = frame.getAnnotationValue("fromName");
     99               
     100                reply.setActions(null);
     101                FrameMouseActions.tdfc(reply);
     102               
     103                Frame replyFrame = DisplayIO.getCurrentFrame();
     104                replyFrame.setTitle("RE: " + frame.getTitle());
     105                FrameKeyboardActions.Drop(null, false);
     106                Text original = replyFrame.createNewText("@original");
     107                original.setPosition(FrameMouseActions.getPosition());
     108                original.setLink(frame.getName());
     109                FrameKeyboardActions.Drop(original, false);
     110               
     111                Text to = replyFrame.createNewText("@to: " + fromAddress);
     112                to.setPosition(FrameMouseActions.getPosition());
     113                to.addAction("MailFrame");
     114                FrameKeyboardActions.Drop(to, false);
     115                if (fromName != null) {
     116                        Text toName = replyFrame.createNewText("@toName: " + fromName);
     117                        toName.setPosition(FrameMouseActions.getPosition());
     118                        FrameKeyboardActions.Drop(toName, false);
     119                }
     120        }
     121
    85122}
  • trunk/src/org/expeditee/actions/Misc.java

    r278 r282  
    107107         *
    108108         */
    109         public static void DeleteFrame() {
    110                 Frame toDelete = DisplayIO.getCurrentFrame();
     109        public static void DeleteFrame(Frame toDelete) {
    111110                String deletedFrame = toDelete.getName();
    112111                String deletedFrameNameLowercase = deletedFrame.toLowerCase();
     
    770769        public static void importFiles(Item item) {
    771770                List<File> files = new LinkedList<File>();
    772                 for (String s : item.getText().split("\n")) {
    773                         File file = new File(s);
     771                for (String s : item.getText().split("\\s+")) {
     772                        File file = new File(s.trim());
    774773                        if (file.exists()) {
    775774                                files.add(file);
     
    784783
    785784        public static void importFile(Item item) {
    786                 File file = new File(item.getText());
     785                File file = new File(item.getText().trim());
    787786                if (file.exists()) {
    788787                        try {
     
    810809                double curAngle = 0;
    811810                double size = 50F;
    812                 if (item instanceof Dot && item.getLines().size() > 0) {
     811                if (item.isLineEnd() && item.getLines().size() > 0) {
    813812                        item = item.getLines().get(0);
    814813                }
  • trunk/src/org/expeditee/agents/MailTree.java

    r278 r282  
    88import org.expeditee.gui.AttributeValuePair;
    99import org.expeditee.gui.Frame;
     10import org.expeditee.gui.FrameIO;
    1011import org.expeditee.gui.FreeItems;
    1112import org.expeditee.items.Item;
    1213import org.expeditee.items.Text;
    1314
    14 public class MailFrame extends DefaultAgent {
     15public class MailTree extends DefaultAgent {
    1516
    1617        @Override
    1718        public boolean initialise(Frame frame, Item item) {
    1819                return super.initialise(frame, item);
     20        }
     21
     22        private String getFrameText(Frame frame, String prefix) {
     23                StringBuffer sb = new StringBuffer();
     24                // Get the text to mail
     25                for (Text t : frame.getBodyTextItems(false)) {
     26                        if (t.hasLink()) {
     27                                Frame linkedFrame = FrameIO.LoadFrame(t.getAbsoluteLink());
     28                                if (linkedFrame == null)
     29                                        continue;
     30
     31                                String frameTitle = linkedFrame.getTitle();
     32                                sb.append(prefix).append(frameTitle).append('\n')
     33                                                .append(prefix);
     34                                for (int i = 0; i < frameTitle.length(); i++) {
     35                                        sb.append('-');
     36                                }
     37                                sb.append("\n\n");
     38                                sb.append(getFrameText(linkedFrame, prefix));
     39                        } else {
     40                                sb.append(prefix).append(t.getText()).append("\n\n");
     41                        }
     42                }
     43
     44                Text original = frame.getAnnotation("original");
     45                if (original != null) {
     46                        Frame linkedFrame = FrameIO.LoadFrame(original.getAbsoluteLink());
     47                        if (linkedFrame != null) {
     48                                sb.append("\n\n").append("Original Message").append(
     49                                                "----------------").append("\n\n");
     50                                sb.append(getFrameText(linkedFrame, ">"));
     51                        }
     52                }
     53
     54                return sb.toString();
    1955        }
    2056
     
    3066        protected Frame process(Frame frame) {
    3167                String subject = frame.getTitle();
    32                 List<Text> text = frame.getBodyTextItems(false);
    33                 StringBuilder body = new StringBuilder();
    34                 for (Text t : text) {
    35                         body.append(t.getText()).append("\n\n");
    36                 }
     68
     69                // Get the text to mail
     70                String body = getFrameText(frame, "");
     71
    3772                String to = frame.getAnnotationValue("to");
    3873                String cc = frame.getAnnotationValue("cc");
     
    115150                // Allow the user to do other stuff while the message gets sent
    116151                _running = false;
    117                 MailSession.sendTextMessage(to, cc, bcc, subject, body.toString());
     152                MailSession.sendTextMessage(to, cc, bcc, subject, body, null);
    118153
    119154                return null;
  • trunk/src/org/expeditee/agents/PdfFrameset.java

    r228 r282  
    11package org.expeditee.agents;
    22
    3 import java.awt.Dimension;
    4 import java.io.FileNotFoundException;
    5 import java.io.FileOutputStream;
     3import java.io.IOException;
    64
    75import org.expeditee.gui.Frame;
    8 import org.expeditee.gui.FrameGraphics;
    9 import org.expeditee.gui.FrameIO;
    10 import org.expeditee.gui.UserSettings;
     6import org.expeditee.gui.MessageBay;
     7import org.expeditee.io.PdfFramesetWriter;
    118
    12 import com.lowagie.text.Document;
    13 import com.lowagie.text.DocumentException;
    14 import com.lowagie.text.Rectangle;
    15 import com.lowagie.text.pdf.PdfContentByte;
    16 import com.lowagie.text.pdf.PdfWriter;
    179
    1810public class PdfFrameset extends DefaultAgent {
    19         private long _firstFrame = 1;
     11        private PdfFramesetWriter _pdfWriter;
     12       
     13        private int _firstFrame = 1;
    2014
    21         private long _maxFrame = Integer.MAX_VALUE;
     15        private int _maxFrame = Integer.MAX_VALUE;
    2216
    23         public PdfFrameset(long firstFrame, long maxFrame) {
     17        public PdfFrameset(int firstFrame, int maxFrame) {
    2418                super();
    2519                _firstFrame = firstFrame;
     
    3529        @Override
    3630        protected Frame process(Frame frame) {
    37                 String framesetName = frame.getFramesetName();
    38                 String fileName = FrameIO.EXPORTS_DIR + framesetName + ".pdf";
    39                 int count = FrameIO.getLastNumber(framesetName);
    40 
    41                 Dimension d = FrameGraphics.getMaxSize();
    42                 Document _pdfDocument = new Document(new Rectangle(d.width, d.height));
     31                _pdfWriter = new PdfFramesetWriter(_firstFrame, _maxFrame);
    4332               
    44                 PdfContentByte cb = null;
    4533                try {
    46                         PdfWriter writer = PdfWriter.getInstance(_pdfDocument,
    47                                         new FileOutputStream(fileName));
    48                         _pdfDocument.open();
    49                         _pdfDocument.addCreationDate();
    50                         _pdfDocument.addAuthor(UserSettings.Username);
    51                         _pdfDocument.addCreator("Expeditee");
    52                         cb = writer.getDirectContent();
    53 
    54                 } catch (FileNotFoundException e) {
    55                         e.printStackTrace();
    56                         return null;
    57                 } catch (DocumentException e) {
    58                         e.printStackTrace();
    59                         return null;
     34                        _pdfWriter.writeFrame(frame);
     35                } catch (IOException e) {
     36                        MessageBay.errorMessage("PdfFrameset error: " + e.getMessage());
     37                        //e.printStackTrace();
    6038                }
    61 
    62                 for (long i = _firstFrame; i <= _maxFrame && i <= count; i++) {
    63                         if (_stop) {
    64                                 break;
    65                         }
    66                         String frameName = framesetName + i;
    67                         Frame toPaint = FrameIO.LoadFrame(frameName);
    68                         if (toPaint != null) {
    69                                 overwriteMessage("Converting " + frameName);
    70                                 java.awt.Graphics2D g2 = cb.createGraphics(FrameGraphics
    71                                                 .getMaxSize().width, FrameGraphics.getMaxSize().height);
    72                                 FrameGraphics.paintFrame(toPaint, null, false, false, g2);
    73                                 g2.dispose();
    74                                 // Move to the next page?
    75                                 _pdfDocument.setPageCount(_pdfDocument.getPageNumber() + 1);
    76                         }
    77                 }
    78                 try {
    79                         _pdfDocument.close();
    80                 } catch (Exception e) {
    81                         overwriteMessage("Error writing PDF document");
    82                 }
     39               
    8340                return null;
    8441        }
     42       
     43        @Override
     44        public void stop(){
     45                _pdfWriter.stop();
     46        }
    8547}
  • trunk/src/org/expeditee/agents/mail/MailSession.java

    r254 r282  
    224224
    225225        public static boolean sendTextMessage(String to, String cc, String bcc,
    226                         String subject, String body) {
     226                        String subject, String body, Object attachments) {
    227227
    228228                if (_theMailSession == null) {
     
    236236                }
    237237
    238                 return _theMailSession.sendText(to, cc, bcc, subject, body);
     238                return _theMailSession.sendText(to, cc, bcc, subject, body, attachments);
    239239        }
    240240
    241241        private synchronized boolean sendText(String to, String cc, String bcc,
    242                         String subject, String body) {
     242                        String subject, String body, Object attachments) {
    243243                if (!_transport.isConnected()) {
    244244                        MessageBay
     
    263263                        // -- Create a new message --
    264264                        Message msg = new MimeMessage(_session);
    265 
     265                       
    266266                        // -- Set the FROM and TO fields --
    267267                        msg.setFrom(new InternetAddress(_address));
     
    409409                                if (flag == null
    410410                                                || msgs[msgNum].getFlags().contains(flag) == isPresent) {
    411                                         Item newItem = readMessage(msgs[msgNum], msgNum, frame, point);
     411                                        Item newItem = readMessage(msgs[msgNum], msgNum, frame,
     412                                                        point);
    412413                                        if (newItem != null) {
    413414                                                mailItems.add(newItem);
     
    423424        }
    424425
    425         private Item readMessage(final Message message, int messageNo, Frame frame, Point point) {
    426                 String subject;
    427                 try {
    428                         subject = message.getSubject();
    429                 } catch (MessagingException e) {
    430                         MessageBay.errorMessage("GetMail error: " + e.getMessage());
    431                         return null;
    432                 }
    433 
    434                 final Text source = FrameDNDTransferHandler
    435                                 .importString(subject, point);
    436                 // Create a frameCreator
    437                 final FrameCreator frames = new FrameCreator(frame.getFramesetName(),
    438                                 frame.path, messageNo + ". " + subject, false);
     426        private Item readMessage(final Message message, final int messageNo,
     427                        final Frame frame, final Point point) {
     428
     429                final Text source = FrameDNDTransferHandler.importString(
     430                                "Loading message " + messageNo, point);
    439431
    440432                new Thread() {
    441433                        public void run() {
    442434                                try {
     435                                        String subject = message.getSubject();
     436                                        source.setText(messageNo + ". " + subject);
     437                                        // Create a frameCreator
     438                                        final FrameCreator frames = new FrameCreator(frame
     439                                                        .getFramesetName(), frame.path, subject, false);
     440
    443441                                        // Get the header information
    444442                                        String from = ((InternetAddress) message.getFrom()[0])
    445443                                                        .getPersonal();
    446                                         if( from != null){
    447                                                 frames.addText("@fromName: " + from, null, null, null, false);
     444                                        if (from != null) {
     445                                                frames.addText("@fromName: " + from, null, null, null,
     446                                                                false);
    448447                                        }
    449448                                        from = ((InternetAddress) message.getFrom()[0])
    450                                                                 .getAddress();
    451                                         frames.addText("@fromAddress: " + from, null, null, null, false);
     449                                                        .getAddress();
     450                                        Text fromAddressItem = frames.addText("@from: " + from,
     451                                                        null, null, null, false);
     452
     453                                        Text reply = frames.addText("@reply" + from, null, null,
     454                                                        null, false);
     455                                        reply.setPosition(10 + fromAddressItem.getX()
     456                                                        + fromAddressItem.getBoundsWidth(), fromAddressItem
     457                                                        .getY());
    452458
    453459                                        // -- Get the message part (i.e. the message itself) --
     
    461467                                        }
    462468                                        // -- Get the content type --
    463                                         String contentType = messagePart.getContentType().toLowerCase();
     469                                        String contentType = messagePart.getContentType()
     470                                                        .toLowerCase();
    464471                                        // -- If the content is plain text, we can print it --
    465472                                        // System.out.println("CONTENT:" + contentType);
     
    479486                                        frames.save();
    480487                                        source.setLink(frames.getName());
     488                                } catch (MessagingException e) {
     489                                        MessageBay.errorMessage("GetMail error: " + e.getMessage());
    481490                                } catch (Exception e) {
    482                                         MessageBay.errorMessage("GetMail error: " + e.getMessage());
     491                                        MessageBay.errorMessage("Error reading mail: "
     492                                                        + e.getMessage());
    483493                                }
    484494                        }
  • trunk/src/org/expeditee/gui/AttributeUtils.java

    r247 r282  
    351351                                                        o = i;
    352352                                        } else if (o instanceof Float) {
    353                                                 // -1 indicates default value
    354                                                 if (((Float) o) < 0.0001)
     353                                                if (((Float) o) < -0.0001)
    355354                                                        continue;
     355                                                //Null indicates default
    356356                                                o = Math.round((Float) o);
    357357                                        } else if (o instanceof Double) {
     
    398398                                                        sb.append(values[i]).append(' ');
    399399                                                }
    400                                                 sb.deleteCharAt(attributes.length() - 1);
     400                                                sb.deleteCharAt(sb.length() - 1);
    401401                                                o = sb.toString();
    402402                                        } else if (o instanceof Boolean) {
  • trunk/src/org/expeditee/gui/Browser.java

    r262 r282  
    207207                        // Must be loaded after setupGraphics if images are on the frame
    208208                        // Turn off XRay mode and load the first frame
     209                        FrameGraphics.setMode(FrameGraphics.MODE_NORMAL, false);
    209210                        FrameUtils.loadFirstFrame(profile);
    210                         FrameGraphics.setMode(FrameGraphics.MODE_NORMAL, false);
    211211                        DisplayIO.UpdateTitle();
    212212
  • trunk/src/org/expeditee/gui/DisplayIO.java

    r278 r282  
    6969         * The title to display in the Title bar.
    7070         */
    71         public static final String TITLE = "Exp08Aug2008A";
     71        public static final String TITLE = "Exp27Aug2008A";
    7272
    7373        private DisplayIO() {
  • trunk/src/org/expeditee/gui/Frame.java

    r278 r282  
    696696                        InteractiveWidget iw = ((WidgetCorner) item).getWidgetSource();
    697697                        if (!this._iWidgets.contains(iw)) { // A set would have been
    698                                 // best
    699                                 _iWidgets.add(iw);
     698                                if(FrameMouseActions.isControlDown())
     699                                        _iWidgets.add(iw);
     700                                else
     701                                        _iWidgets.add(0, iw);
    700702                        }
    701703                }
  • trunk/src/org/expeditee/gui/FrameCreator.java

    r278 r282  
    2323
    2424        private Item _Mprev;
     25       
     26        private Item _Mfirst;
    2527
    2628        // Next and previous links for the current frame
     
    2931        private Item _prev;
    3032
    31         private Frame _first;
     33        private Frame _firstFrame;
    3234
    3335        public FrameCreator(String frameTitle) {
     
    5557         * @return the newly created button.
    5658         */
    57         public Item createButton(String text, Float x, Float y, Float right,
     59        public static Item createButton(String text, Float x, Float y, Float right,
    5860                        Float bottom) {
    59                 Item button = new Text(text);
     61                Text button = new Text(text);
    6062                button.setBackgroundColor(Color.LIGHT_GRAY);
    6163                button.setBorderColor(Color.DARK_GRAY);
     
    6668                        button.setX(x);
    6769                if (right != null)
    68                         button.setAnchorRight(15F);
     70                        button.setAnchorRight(right);
    6971                if (y != null)
    7072                        button.setY(y);
    7173
     74                button.updatePolygon();
     75               
    7276                return button;
    7377        }
     
    7579        public FrameCreator(String name, String path, String frameTitle,
    7680                        boolean recreate) {
    77                 _Mnext = createButton("@Next", null, null, 15F, 15F);
    78                 _Mprev = createButton("@Previous", 30F, null, null, 15F);
    79 
     81
     82                _Mnext = createButton("@Next", null, null, 10F, 15F);
     83
     84                _Mprev = createButton("@Previous", null, null, _Mnext.getBoundsWidth() + _Mnext.getAnchorRight() + 20F, 15F);
     85               
     86                _Mfirst = createButton("@First", null, null, _Mprev.getBoundsWidth() + _Mprev.getAnchorRight() + 20F, 15F);
     87               
    8088                Frame toUse = null;
    8189                try {
     
    8896
    8997                resetGlobals(toUse);
    90                 _first = toUse;
     98                _firstFrame = toUse;
    9199                // set positions of next\prev frame links
    92100                // _Mnext.setPosition(FrameGraphics.getMaxSize().width - 100,
     
    96104
    97105        public String getName() {
    98                 return _first.getName();
     106                return _firstFrame.getName();
    99107        }
    100108
     
    110118
    111119                        // add link to previous frame
    112                         _prev = _Mprev.copy();
    113                         _prev.setID(newFrame.getNextItemID());
    114                         _prev.setLink(_current.getName());
    115                         newFrame.addItem(_prev);
     120                        _prev = addPreviousButton(newFrame, _current.getName());
    116121
    117122                        // add link to new frame
    118                         _next = _Mnext.copy();
    119                         _next.setID(_current.getNextItemID());
    120                         _next.setLink(newFrame.getName());
    121                         _current.addItem(_next);
     123                        _next = addNextButton(_current,newFrame.getName());
     124                       
     125//                       add link to new frame
     126                        addFirstButton(newFrame,_firstFrame.getName());
     127                       
    122128                        FrameIO.SaveFrame(_current, false);
    123129
     
    193199        }
    194200
    195         public void addText(String toAdd, Color c, String link, String action,
     201        public Text addText(String toAdd, Color c, String link, String action,
    196202                        boolean bSave) {
    197203                Text text = _current.createNewText();
     
    202208
    203209                addItem(text, bSave);
     210               
     211                return text;
    204212        }
    205213
     
    221229
    222230        public Frame getFirstFrame() {
    223                 return _first;
     231                return _firstFrame;
     232        }
     233
     234        public Item addNextButton(Frame current, String link) {
     235                return addButton(_Mnext, current, link);
     236        }
     237       
     238        public Item addPreviousButton(Frame current, String link) {
     239                return addButton(_Mprev, current, link);
     240        }
     241       
     242        public Item addFirstButton(Frame current, String link) {
     243                return addButton(_Mfirst, current, link);
     244        }
     245       
     246        public Item addButton(Item template, Frame current, String link) {
     247                // add link to new frame
     248                Item previousButton = template.copy();
     249                previousButton.setID(current.getNextItemID());
     250                previousButton.setLink(link);
     251                current.addItem(previousButton);
     252               
     253                return previousButton;
    224254        }
    225255}
  • trunk/src/org/expeditee/gui/FrameGraphics.java

    r281 r282  
    349349                // Note that these are the anchored widgets
    350350                ListIterator<InteractiveWidget> widgetItor = paintWidgets.listIterator(paintWidgets.size());
    351                 while (widgetItor.hasPrevious())  { // Paint first-in-last-serve ordering - like swing
     351                while (widgetItor.hasPrevious())  {
     352                        //Paint first-in-last-serve ordering - like swing
     353                        //If it is done the other way around then widgets are covered up by the box that is supposed to be underneath
    352354                        InteractiveWidget iw = widgetItor.previous();
    353355                        if (clip == null
  • trunk/src/org/expeditee/gui/FrameIO.java

    r247 r282  
    121121                MessageBay.supressMessages(true);
    122122                // loading automatically caches the frame is caching is turned on
    123                 LoadUnknownPath(framename);
     123                LoadUnknownPath(framename, false);
    124124                MessageBay.supressMessages(false);
    125125        }
     
    143143
    144144        public static Frame LoadFrame(String frameName) {
     145                return LoadFrame(frameName, false);
     146        }
     147       
     148        public static Frame LoadFrame(String frameName, boolean ignoreAnnotations) {
    145149                if (!isValidFrameName(frameName))
    146150                        return null;
     
    157161                Logger.Log(Logger.SYSTEM, Logger.LOAD, "Loading " + frameName
    158162                                + " from disk.");
    159                 return LoadUnknownPath(frameName);
    160         }
    161 
    162         private static Frame LoadUnknownPath(String framename) {
     163                return LoadUnknownPath(frameName, ignoreAnnotations);
     164        }
     165
     166        private static Frame LoadUnknownPath(String framename, boolean ignoreAnnotations) {
    163167                Frame loaded = null;
    164168
     
    166170                        loaded = LoadFrame(path, framename);
    167171                        if (loaded != null) {
    168                                 FrameUtils.Parse(loaded, true);
     172                                FrameUtils.Parse(loaded, true, ignoreAnnotations);
    169173                                break;
    170174                        }
  • trunk/src/org/expeditee/gui/FrameKeyboardActions.java

    r278 r282  
    3838        private static Text _toRemove = null;
    3939
     40        private static Collection<Item> _enclosedItems = null;
     41       
     42        public static void resetEnclosedItems() {
     43                _enclosedItems = null;
     44        }
     45
    4046        public synchronized void keyTyped(KeyEvent e) {
    4147                if (Simple.isProgramRunning()) {
     
    324330        public void keyPressed(KeyEvent e) {
    325331                int keyCode = e.getKeyCode();
     332               
     333                if(keyCode != KeyEvent.VK_F1 && keyCode != KeyEvent.VK_F2){
     334                        resetEnclosedItems();
     335                }
     336               
    326337                SessionStats.AddFrameEvent("k" + KeyEvent.getKeyText(keyCode));
    327338
     
    516527        }
    517528
    518         /**
    519          * Currently ignored.
    520          */
     529
    521530        public void keyReleased(KeyEvent e) {
    522531                if (e.getKeyCode() == KeyEvent.VK_CONTROL) {
     
    761770                                        Item lastItem = null;
    762771
    763                                         boolean drop = currentFrame.hasAnnotation("more");
     772                                        boolean drop = currentFrame.hasAnnotation("next");
    764773                                        // separate the clipboard content into items based on
    765774                                        // blank lines
     
    11181127         *            indicate the cursor is in free space.
    11191128         */
    1120         private static void Drop(Item toDropFrom, boolean bPasting) {
     1129        public static void Drop(Item toDropFrom, boolean bPasting) {
    11211130                try {
    11221131                        FrameUtils.setLastEdited(null);
     
    11911200                                Frame current = DisplayIO.getCurrentFrame();
    11921201                                Item itemTemplate = current.getItemTemplate();
    1193                                 int xPos = title.getX();
     1202                                int xPos = title.getX() + 25;
    11941203                                int yPos = title.getY() + title.getBoundsHeight()
    11951204                                                + itemTemplate.getBoundsHeight();
     
    12191228                                                || dummyItem.getY() > FrameGraphics.getMaxFrameSize()
    12201229                                                                .getHeight()) {
    1221                                         // Check for the @more tag!
     1230                                        // Check for the 'next' tag!
    12221231                                        Frame current = DisplayIO.getCurrentFrame();
    1223                                         Item i = current.getAnnotation("more");
    1224 
    1225                                         if (i != null) {
     1232                                        Item next = current.getAnnotation("next");
     1233                                        Item prev = current.getAnnotation("previous");
     1234                                        // Check for an unlinked next tag
     1235                                        if ((next != null && !next.hasLink())
     1236                                                        || (prev != null && prev.hasLink())) {
    12261237                                                Frame firstFrame = current;
    1227                                                 boolean mouseMoved = FrameMouseActions.tdfc(i);
     1238                                                if (next != null)
     1239                                                        next.delete();
     1240                                                FrameCreator frameCreator = new FrameCreator(null);
     1241                                                // Add the next button
     1242                                                next = frameCreator.addNextButton(current, null);
     1243
     1244                                                // Create the new frame linked to the next tag
     1245                                                boolean mouseMoved = FrameMouseActions.tdfc(next);
    12281246                                                Frame moreFrame = DisplayIO.getCurrentFrame();
    1229                                                 // Add the @more if we are pasting
    1230                                                 if (bPasting) {
    1231                                                         Item copy = i.copy();
    1232                                                         copy.setLink(null);
    1233                                                         moreFrame.addItem(copy);
     1247
     1248                                                // Add previous button to the new frame
     1249                                                frameCreator.addPreviousButton(moreFrame, firstFrame
     1250                                                                .getName());
     1251                                                Item first = current.getAnnotation("first");
     1252                                                if (first != null) {
     1253                                                        frameCreator.addFirstButton(moreFrame, first
     1254                                                                        .getLink());
     1255                                                } else {
     1256                                                        frameCreator.addFirstButton(moreFrame, firstFrame
     1257                                                                        .getName());
    12341258                                                }
     1259                                                // Add the @next if we are pasting
     1260                                                // if (bPasting) {
     1261                                                // Item copy = next.copy();
     1262                                                // copy.setLink(null);
     1263                                                // moreFrame.addItem(copy);
     1264                                                // }
    12351265
    12361266                                                moreFrame.setTitle(firstFrame.getTitleItem().getText());
    12371267                                                // need to move the mouse to the top of the frame if
    1238                                                 // there
    1239                                                 // wasnt an @start on it
     1268                                                // there wasnt an @start on it
    12401269                                                if (!mouseMoved) {
    12411270                                                        Item moreTitle = moreFrame.getTitleItem();
     
    14891518                        // change copying to copy only the stuff completely enclosed
    14901519                        if (insideEnclosure) {
    1491                                 for (Item i : FrameUtils.getCurrentItems(toSet)) {
    1492                                         if (i.hasPermission(Permission.full) && !toSize.contains(i))
    1493                                                 toSize.addAll(i.getAllConnected());
    1494                                 }
     1520                                if (_enclosedItems == null) {
     1521                                        for (Item i : FrameUtils.getCurrentItems(toSet)) {
     1522                                                if (i.hasPermission(Permission.full)
     1523                                                                && !toSize.contains(i))
     1524                                                        toSize.addAll(i.getAllConnected());
     1525                                        }
     1526                                        _enclosedItems = toSize;
     1527                                } else {
     1528                                        toSize = _enclosedItems;
     1529                                }
     1530
    14951531                        }// Enclosed circle centers are resized with the center as origin
    14961532                        // Just add the circle center to the list of items to size
     
    15701606                                if (i instanceof Text && i.getSize() != oldSize) {
    15711607                                        i.translate(origin, resizeRatio);
     1608                                        if (i.isLineEnd()) {
     1609                                                i.setPosition(i.getPosition());
     1610                                        }
    15721611                                }
    15731612                        }
  • trunk/src/org/expeditee/gui/FrameMouseActions.java

    r278 r282  
    15481548
    15491549        private static boolean _controlDown;
     1550       
     1551        public static boolean isControlDown() {
     1552                return _controlDown;
     1553        }
    15501554
    15511555        public static void setLastRobotMove(float x, float y) {
     
    15731577
    15741578        private void mouseMoved(MouseEvent e, boolean shiftStateChanged) {
     1579                FrameKeyboardActions.resetEnclosedItems();
    15751580                // System.out.println(e.getX() + "," + e.getY() + " " + e.getWhen());
    15761581                if (LastRobotX != null) {
     
    22202225                        ItemUtils.EnclosedCheck(parent.getItems());
    22212226                        if (toDelete.hasOverlay()) {
    2222                                 FrameUtils.Parse(parent, false);
     2227                                FrameUtils.Parse(parent, false, false);
    22232228                                FrameGraphics.requestRefresh(false);
    22242229                        }
     
    22942299                itemList.clear();
    22952300                if (bReparse)
    2296                         FrameUtils.Parse(currentFrame, false);
     2301                        FrameUtils.Parse(currentFrame, false, false);
    22972302
    22982303        }
     
    26312636                }
    26322637                if (bReparse)
    2633                         FrameUtils.Parse(DisplayIO.getCurrentFrame(), false);
     2638                        FrameUtils.Parse(DisplayIO.getCurrentFrame(), false, false);
    26342639
    26352640                FrameGraphics.Repaint();
     
    27242729                }
    27252730                if (bReparse)
    2726                         FrameUtils.Parse(DisplayIO.getCurrentFrame(), false);
     2731                        FrameUtils.Parse(DisplayIO.getCurrentFrame(), false, false);
    27272732                FrameGraphics.Repaint();
    27282733        }
  • trunk/src/org/expeditee/gui/FrameUtils.java

    r247 r282  
    734734         */
    735735        public static void Parse(Frame toParse, boolean firstParse) {
     736                Parse(toParse, firstParse, false);
     737        }
     738
     739        /**
     740         *
     741         * @param toParse
     742         * @param firstParse
     743         * @param ignoreAnnotations
     744         *            used to prevent infinate loops such as when performing TDFC
     745         *            with an ao tag linked to a frame with an frameImage of a frame
     746         *            which also has an ao tag on it.
     747         */
     748        public static void Parse(Frame toParse, boolean firstParse,
     749                        boolean ignoreAnnotations) {
    736750                // TODO check why we are getting toParse == null... when profile frame
    737751                // is being created and change the lines below
     
    833847                                                }
    834848                                                // check for new OVERLAY items
    835                                                 else if (ItemUtils.startsWithTag(i,
     849                                                else if (!ignoreAnnotations && ItemUtils.startsWithTag(i,
    836850                                                                ItemUtils.TAG_OVERLAY)
    837851                                                                && i.getLink() != null) {
     
    856870                                                }
    857871                                                // check for ACTIVE_OVERLAY items
    858                                                 else if (ItemUtils.startsWithTag(i,
     872                                                else if (!ignoreAnnotations && ItemUtils.startsWithTag(i,
    859873                                                                ItemUtils.TAG_ACTIVE_OVERLAY)
    860874                                                                && i.getLink() != null) {
     
    11431157        /**
    11441158         *
    1145          * @param currentItem 
     1159         * @param currentItem
    11461160         * @return
    11471161         */
     
    11491163                return getCurrentItems(getCurrentItem());
    11501164        }
    1151        
     1165
    11521166        public static Collection<Item> getCurrentItems(Item currentItem) {
    11531167
     
    11861200
    11871201        public static Collection<Item> getEnclosingLineEnds() {
    1188                 return getEnclosingLineEnds(new Point(DisplayIO.getMouseX(), FrameMouseActions.getY()));
    1189         }
    1190        
     1202                return getEnclosingLineEnds(new Point(DisplayIO.getMouseX(),
     1203                                FrameMouseActions.getY()));
     1204        }
     1205
    11911206        public static Collection<Item> getEnclosingLineEnds(Point position) {
    11921207                // update enclosed shapes
     
    14511466                if (!FrameGraphics.isXRayMode()) {
    14521467                        if (toReparse != null) {
    1453                                 Parse(toReparse, false);
     1468                                Parse(toReparse, false, false);
    14541469                        } else if (toRecalculate != null) {
    14551470                                toRecalculate.recalculate();
  • trunk/src/org/expeditee/importer/TextImporter.java

    r253 r282  
    2626                final String fullPath = f.getAbsolutePath();
    2727
    28                 final Text source = FrameDNDTransferHandler.importString(f.getName(),
     28                final Text source = FrameDNDTransferHandler.importString(f.getPath(),
    2929                                location);
    3030
  • trunk/src/org/expeditee/io/DefaultFramesetWriter.java

    r226 r282  
    88
    99public class DefaultFramesetWriter extends DefaultFrameWriter {
    10         private int  _firstFrame = 1;
    11         private int _maxFrame = Integer.MAX_VALUE;
     10        private long  _firstFrame = 1;
     11        private long _maxFrame = Long.MAX_VALUE;
    1212       
     13        protected DefaultFramesetWriter(long firstFrame, long maxFrame){
     14                _firstFrame = firstFrame;
     15                _maxFrame = maxFrame;
     16        }
    1317       
    1418        @Override
  • trunk/src/org/expeditee/io/PDF2Writer.java

    r226 r282  
    2323import com.lowagie.text.pdf.PdfWriter;
    2424
     25/**
     26 *
     27 * @author root
     28 *
     29 */
    2530public class PDF2Writer extends DefaultFrameWriter {
    2631
     
    99104                        cb.addImage(iTextImage);
    100105                } catch (DocumentException e) {
    101                         // TODO Auto-generated catch block
    102106                        e.printStackTrace();
    103107                }
  • trunk/src/org/expeditee/io/PDFWriter.java

    r226 r282  
    1818import com.lowagie.text.pdf.PdfWriter;
    1919
     20/**
     21 * Writes out a tree in a linear format.
     22 * @author root
     23 *
     24 */
    2025public class PDFWriter extends DefaultTreeWriter {
    2126
  • trunk/src/org/expeditee/io/PdfFramesetWriter.java

    r278 r282  
    2323import com.lowagie.text.pdf.PdfWriter;
    2424
    25 public class PDF3Writer extends DefaultFramesetWriter {
     25/**
     26 *
     27 * @author root
     28 *
     29 */
     30public class PdfFramesetWriter extends DefaultFramesetWriter {
    2631
    2732        private Document _pdfDocument;
     
    2934        private PdfWriter _pdfWriter;
    3035
    31         public PDF3Writer() {
     36        public PdfFramesetWriter(long firstFrame, long maxFrame) {
     37                super(firstFrame, maxFrame);
    3238                Dimension d = FrameGraphics.getMaxSize();
    3339                _pdfDocument = new Document(new Rectangle(d.width, d.height));
     40        }
     41       
     42        public PdfFramesetWriter() {
     43                this(1, Long.MAX_VALUE);
    3444        }
    3545
     
    6070        protected void writeEndFrame(Frame ending) throws IOException {
    6171                super.writeEndFrame(ending);
    62                 // Move to the next page?
     72                // Move to the next page
    6373                _pdfDocument.newPage();
    64                 //int nextPage = _pdfDocument.getPageNumber() + 1;
    65                 //_pdfDocument.setPageCount(nextPage);
    6674        }
    6775
     
    100108        protected void writePicture(Picture pic) throws IOException {
    101109                Image image = pic.getCroppedImage();
     110                if(image == null)
     111                        return;
    102112                try {
    103113                        PdfContentByte cb = _pdfWriter.getDirectContent();
  • trunk/src/org/expeditee/items/Dot.java

    r278 r282  
    7474        @Override
    7575        public void setAnchorBottom(Float anchor) {
    76                 if(!isLineEnd()){
     76                if (!isLineEnd()) {
    7777                        super.setAnchorBottom(anchor);
    7878                        return;
     
    8484                        float deltaY = FrameGraphics.getMaxFrameSize().height - anchor
    8585                                        - getBoundsHeight() - oldY;
    86                         //Check for a more efficient way to do this!!
    87                         //Invalidate all the items
    88                         for (Item i : this.getAllConnected()) {
    89                                 i.invalidateAll();
    90                         }
    91                         //Move the items
    92                         for (Item i : this.getAllConnected()) {
    93                                 if (i.isLineEnd()){
    94                                         i.setAnchorBottom(null);
    95                                         i.setXY(i.getX(), i.getY() + deltaY);
    96                                         i.updatePolygon();
    97                                         i.invalidateAll();
    98                                 }
    99                         }
    100                         //Invalidate them again!!
    101                         for (Item i : this.getAllConnected()) {
    102                                 i.invalidateAll();
    103                         }
     86                        anchorConnected(null, deltaY);
    10487                }
    10588                this._anchorBottom = anchor;
     
    10790                invalidateFill();
    10891        }
    109        
     92
    11093        @Override
    11194        public void setAnchorRight(Float anchor) {
    112                 if(!isLineEnd()){
     95                if (!isLineEnd()) {
    11396                        super.setAnchorRight(anchor);
    11497                        return;
     
    120103                        float deltaX = FrameGraphics.getMaxFrameSize().width - anchor
    121104                                        - getBoundsWidth() - oldX;
    122                         //Check for a more efficient way to do this!!
    123                         //Invalidate all the items
    124                         for (Item i : this.getAllConnected()) {
    125                                 i.invalidateAll();
    126                         }
    127                         //Move the items
    128                         for (Item i : this.getAllConnected()) {
    129                                 if (i.isLineEnd()){
    130                                         i.setAnchorRight(null);
    131                                         i.setXY(i.getX() + deltaX, i.getY());
    132                                         i.updatePolygon();
    133                                         i.invalidateAll();
    134                                 }
    135                         }
    136                         //Invalidate them again!!
    137                         for (Item i : this.getAllConnected()) {
    138                                 i.invalidateAll();
    139                         }
     105
     106                        anchorConnected(deltaX, null);
    140107                }
    141108                this._anchorRight = anchor;
  • trunk/src/org/expeditee/items/FrameImage.java

    r181 r282  
    3737                // parseSize();
    3838                assert (_source.getLink() != null);
    39                 Frame frame = FrameIO.LoadFrame(_source.getAbsoluteLink());
     39                Frame frame = FrameIO.LoadFrame(_source.getAbsoluteLink(), true);
    4040                if (frame == null)
    4141                        return false;
  • trunk/src/org/expeditee/items/Item.java

    r278 r282  
    182182                dest.setArrow(source.getArrowheadLength(), source.getArrowheadRatio());
    183183
    184                 dest.setAnchorBottom(source.getAnchorBottom());
    185                 dest.setAnchorRight(source.getAnchorRight());
    186                
     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                dest._anchorBottom = source._anchorBottom;
     188                dest._anchorRight = source._anchorRight;
     189
    187190                dest.setFormula(source.getFormula());
    188191                dest.setParent(source.getParent());
     
    880883
    881884        public int getWidth() {
     885                return 0;
     886        }
     887
     888        public int getHeight() {
    882889                return 0;
    883890        }
     
    10631070                if (sourceItem == null) {
    10641071                        sourceItem = this;
    1065                 }else{
    1066                         for(Item i: sourceItem.getAllConnected()){
    1067                                 if(i instanceof Text){
     1072                } else {
     1073                        for (Item i : sourceItem.getAllConnected()) {
     1074                                if (i instanceof Text) {
    10681075                                        sourceItem = i;
    10691076                                        break;
     
    13681375                for (Line line : _lines) {
    13691376                        Item other = line.getOppositeEnd(this);
    1370                         if (other.getFillColor() != c){
     1377                        if (other.getFillColor() != c) {
    13711378                                other.setFillColor(c);
    13721379                        }
     
    15341541        private void invalidateCommonTraitForAll(ItemAppearence trait) {
    15351542                invalidateCommonTrait(trait);
    1536                 for (Line line : getLines())
    1537                         line.invalidateCommonTrait(trait);
     1543                if (isLineEnd()) {
     1544                        boolean hasLinePattern = getLines().get(0).getLinePattern() != null;
     1545                        if (hasLinePattern) {
     1546                                for (Item i : getAllConnected()) {
     1547                                        if (i instanceof Line) {
     1548                                                ((Line)i).invalidateCommonTrait(trait);
     1549                                        }
     1550                                }
     1551                        } else {
     1552                                for (Line line : getLines()) {
     1553                                        line.invalidateCommonTrait(trait);
     1554                                }
     1555                        }
     1556                }
    15381557                if (_colorFill != null) {
    15391558                        invalidateFill(); // only invalidates if has fill
     
    16511670                        line.updatePolygon();
    16521671                }
     1672               
     1673//              for (Item item : getAllConnected()) {
     1674//                      item.updatePolygon();
     1675//              }
    16531676
    16541677                invalidateCommonTraitForAll(ItemAppearence.PostMoved);
     
    17591782                                "Item type does not support width attribute!");
    17601783        }
    1761        
     1784
    17621785        public void setRightMargin(int i) {
    17631786                setWidth(i - getX() - Item.MARGIN_LEFT);
     
    25412564                this._anchorRight = anchor;
    25422565                if (anchor != null)
    2543                         setX(FrameGraphics.getMaxFrameSize().width - anchor - getBoundsWidth());
     2566                        setX(FrameGraphics.getMaxFrameSize().width - anchor
     2567                                        - getBoundsWidth());
    25442568        }
    25452569
     
    25512575                this._anchorBottom = anchor;
    25522576                if (anchor != null)
    2553                         setY(FrameGraphics.getMaxFrameSize().height - anchor - getBoundsHeight());
     2577                        setY(FrameGraphics.getMaxFrameSize().height - anchor);
    25542578        }
    25552579
     
    26062630                return null;
    26072631        }
     2632
     2633        public boolean hasLink() {
     2634                return _link != null;
     2635        }
     2636
     2637        protected void anchorConnected(Float deltaX, Float deltaY) {
     2638                // Check for a more efficient way to do this!!
     2639                // Invalidate all the items
     2640                for (Item i : this.getAllConnected()) {
     2641                        i.invalidateAll();
     2642                }
     2643                // Move the items
     2644                for (Item i : this.getAllConnected()) {
     2645                        if (i.isLineEnd()) {
     2646                                if (deltaX != null) {
     2647                                        i.setAnchorRight(null);
     2648                                        i.setXY(i.getX() + deltaX, i.getY());
     2649                                }
     2650                                if (deltaY != null) {
     2651                                        i.setAnchorBottom(null);
     2652                                        i.setXY(i.getX(), i.getY() + deltaY);
     2653                                }
     2654                        }
     2655                }
     2656                // Invalidate them again!!
     2657                for (Item i : this.getAllConnected()) {
     2658                        i.updatePolygon();
     2659                        i.invalidateAll();
     2660                }
     2661        }
    26082662}
  • trunk/src/org/expeditee/items/Picture.java

    r242 r282  
    288288         * Gets the height with which the picture is displayed on the screen.
    289289         */
     290        @Override
    290291        public int getHeight() {
    291292                return Math.round((_end.y - _start.y) * _scale);
     
    483484
    484485        public Image getCroppedImage() {
     486                if(_image == null)
     487                        return null;
    485488                return Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(
    486489                                _image.getSource(),
  • trunk/src/org/expeditee/items/Text.java

    r278 r282  
    14221422                }
    14231423
     1424                if (hasFormula()) {
     1425                        g.setColor(getPaintHighlightColor());
     1426                        Stroke highlightStroke = new BasicStroke(
     1427                                        1F, CAP, JOIN);
     1428                        g.setStroke(highlightStroke);
     1429
     1430                        Point2D.Float start = getEdgePosition(0, true);
     1431                        Point2D.Float end = getEdgePosition(0, false);
     1432                        g.drawLine(Math.round(start.x), Math.round(start.y), Math
     1433                                        .round(end.x), Math.round(end.y));
     1434                }
     1435
    14241436                if (isHighlighted()) {
    14251437                        g.setColor(getPaintHighlightColor());
     
    16441656                        if (s.equals("@old") || s.equals("@ao")
    16451657                                        || s.equals("@itemtemplate") || s.equals("@parent")
    1646                                         || s.equals("@more") || s.equals("@next")
    1647                                         || s.equals("@previous") || s.equals("@i")
     1658                                        || s.equals("@next") || s.equals("@previous")
     1659                                        || s.equals("@first") || s.equals("@i") || s.equals("@iw")
    16481660                                        || s.equals("@f"))
    16491661                                return true;
     
    18831895                                                e.printStackTrace();
    18841896                                        }
    1885                                 } else {
    1886                                         try {
    1887                                                 double value = pair.getDoubleValue();
    1888                                                 myParser.addVariable("$" + nextVarNo++, value);
    1889                                         } catch (NumberFormatException nfe) {
    1890                                                 continue;
    1891                                         } catch (Exception e) {
    1892                                                 e.printStackTrace();
    1893                                         }
     1897                                } // else {
     1898                                // Add anonomous vars
     1899                                try {
     1900                                        double value = pair.getDoubleValue();
     1901                                        myParser.addVariable("$" + nextVarNo++, value);
     1902                                } catch (NumberFormatException nfe) {
     1903                                        continue;
     1904                                } catch (Exception e) {
     1905                                        e.printStackTrace();
    18941906                                }
     1907                                // }
    18951908                        }
    18961909                }
     
    20002013                        float deltaX = FrameGraphics.getMaxFrameSize().width - anchor
    20012014                                        - getBoundsWidth() + getLeftMargin() - oldX;
    2002                         // Check for a more efficient way to do this!!
    2003                         // Invalidate all the items
    2004                         for (Item i : this.getAllConnected()) {
    2005                                 i.invalidateAll();
    2006                         }
    2007                         // Move the items
    2008                         for (Item i : this.getAllConnected()) {
    2009                                 if (i.isLineEnd()) {
    2010                                         i.setAnchorRight(null);
    2011                                         i.setXY(i.getX() + deltaX, i.getY());
    2012                                 }
    2013                         }
    2014                         // Invalidate them again!!
    2015                         for (Item i : this.getAllConnected()) {
    2016                                 i.updatePolygon();
    2017                                 i.invalidateAll();
    2018                         }
     2015                        anchorConnected(deltaX, null);
    20192016                }
    20202017                this._anchorRight = anchor;
     
    20222019                invalidateFill();
    20232020        }
    2024        
     2021
    20252022        @Override
    20262023        public void setAnchorBottom(Float anchor) {
    2027                 if(!isLineEnd()){
     2024                if (!isLineEnd()) {
    20282025                        super.setAnchorBottom(anchor);
    20292026                        return;
     
    20342031                if (anchor != null) {
    20352032                        float deltaY = FrameGraphics.getMaxFrameSize().height - anchor
    2036                                         - getBoundsHeight() - oldY;
    2037                         //Check for a more efficient way to do this!!
    2038                         //Invalidate all the items
    2039                         for (Item i : this.getAllConnected()) {
    2040                                 i.invalidateAll();
    2041                         }
    2042                         //Move the items
    2043                         for (Item i : this.getAllConnected()) {
    2044                                 if (i.isLineEnd()){
    2045                                         i.setAnchorBottom(null);
    2046                                         i.setXY(i.getX(), i.getY() + deltaY);
    2047                                         i.updatePolygon();
    2048                                         i.invalidateAll();
    2049                                 }
    2050                         }
    2051                         //Invalidate them again!!
    2052                         for (Item i : this.getAllConnected()) {
    2053                                 i.invalidateAll();
    2054                         }
     2033                                        - oldY;
     2034                        anchorConnected(null, deltaY);
    20552035                }
    20562036                this._anchorBottom = anchor;
  • trunk/src/org/expeditee/items/XRayable.java

    r278 r282  
    66import java.util.LinkedList;
    77import java.util.List;
     8
     9import org.expeditee.gui.FrameGraphics;
    810
    911public abstract class XRayable extends Item {
     
    115117        public float getThickness() {
    116118                return _source.getThickness();
     119        }
     120       
     121        @Override
     122        public Float getAnchorBottom() {
     123                return _source.getAnchorBottom();
     124        }
     125       
     126        @Override
     127        public Float getAnchorRight() {
     128                return _source.getAnchorRight();
    117129        }
    118130       
     
    205217        public void setAnchorBottom(Float anchor) {
    206218                _source.setAnchorBottom(anchor);
     219                if (anchor != null)
     220                        _source.setY(FrameGraphics.getMaxFrameSize().height - getHeight() - anchor);
    207221        }
    208222       
  • trunk/src/org/expeditee/items/widgets/InteractiveWidget.java

    r279 r282  
    1919import javax.swing.SwingUtilities;
    2020
     21import org.expeditee.gui.AttributeUtils;
    2122import org.expeditee.gui.Browser;
    2223import org.expeditee.gui.DisplayIO;
     
    133134                text = text.trim();
    134135
     136                // Check starts with the widget tag and seporator
     137                if (!text.startsWith(TAG + ":"))
     138                        throw new IllegalArgumentException("Source text must begin with \""
     139                                        + TAG + ":\"");
     140
     141                text = text.substring(TAG.length() + 1).trim();
     142
    135143                int index = 0;
    136                 if (text.length() > TAG.length() + 1) {
    137                         index = text.indexOf(':', TAG.length() + 1); // used for
     144                if (text.length() > 0) {
     145                        index = text.indexOf(':'); // used for
    138146                        // signifying start
    139                         // of
    140                 }
    141 
    142                 // arguments
     147                        // of arguments
     148                }
     149
    143150                if (index == 0)
    144151                        throw new IllegalArgumentException("Source text must begin with \""
     
    148155                                0, index).split(" ");
    149156
    150                 // Check starts with the widget tag and seporator
    151                 if (tokens.length == 0 || !tokens[0].equals(TAG + ":"))
    152                         throw new IllegalArgumentException("Source text must begin with \""
    153                                         + TAG + ":\"");
    154 
    155157                float width = -1, height = -1;
    156158
    157                 if (tokens.length < 2)
     159                if (tokens.length < 1)
    158160                        throw new IllegalArgumentException(
    159161                                        "Missing widget class name in source text");
     
    161163                try {
    162164
    163                         if (tokens.length >= 3) { // parse optional width
    164                                 width = Integer.parseInt(tokens[2]);
     165                        if (tokens.length >= 2) { // parse optional width
     166                                width = Integer.parseInt(tokens[1]);
    165167                                width = (width <= 0) ? width = -1 : width;
    166168                        }
    167169
    168                         if (tokens.length >= 4) { // parse optional height
    169                                 height = Integer.parseInt(tokens[3]);
     170                        if (tokens.length >= 3) { // parse optional height
     171                                height = Integer.parseInt(tokens[2]);
    170172                                height = (height <= 0) ? height = -1 : height;
    171173                        }
     
    176178                }
    177179
    178                 if (tokens.length > 4)
     180                if (tokens.length > 3)
    179181                        throw new IllegalArgumentException(
    180182                                        "to many arguments given before \":\" in source text");
    181183
    182                 String classname = tokens[1];
     184                String classname = tokens[0];
    183185                if (classname.charAt(0) == '$')
    184186                        classname = "org.expeditee.items.widgets." + classname.substring(1);
     
    704706
    705707        public void setPosition(int x, int y) {
    706                 if (x == getX() && y == getY()) return;
     708                if (x == getX() && y == getY())
     709                        return;
    707710
    708711                boolean vfloating[] = new boolean[] { _d1.isFloating(),
     
    925928                                                .getCurrentMouseEvent())
    926929                        return; // already dealt with this event
    927                
     930
    928931                _lastParentStateChangedEvent = e;
    929                 _lastParentStateChangedMouseEvent = MouseEventRouter.getCurrentMouseEvent();
     932                _lastParentStateChangedMouseEvent = MouseEventRouter
     933                                .getCurrentMouseEvent();
    930934
    931935                switch (e.getEventType()) {
     
    10721076        /**
    10731077         *
    1074          * @return
    1075          *              The current bounds for this widget. Never null.
     1078         * @return The current bounds for this widget. Never null.
    10761079         */
    10771080        public Rectangle getBounds() {
     
    11551158                if (_textRepresentation.getLink() != null
    11561159                                || _textRepresentation.hasAction()) {
    1157                         //System.out.println("Painted link");
     1160                        // System.out.println("Painted link");
    11581161                        _textRepresentation.paintLinkGraphic(g, getLinkX(), getLinkY());
    11591162
     
    14931496
    14941497                if (newData != null) {
    1495                         if (data != null) data.add(newData);
     1498                        if (data != null)
     1499                                data.add(newData);
    14961500                        else {
    14971501                                data = new LinkedList<String>();
    14981502                                data.add(newData);
    14991503                                getCurrentRepresentation().setData(data);
    1500                                
    1501                         }
    1502                 } 
     1504
     1505                        }
     1506                }
    15031507        }
    15041508
     
    15071511         *
    15081512         * @param link
    1509          *              The new frame link. Can be null (for no link)
    1510          *              
     1513         *            The new frame link. Can be null (for no link)
     1514         *
    15111515         */
    15121516        public void setLink(String link) {
     
    15181522                        invalidateLink();
    15191523        }
    1520        
    1521         public void setBackgroundColor(Color c){
     1524
     1525        public void setBackgroundColor(Color c) {
    15221526                getSource().setBackgroundColor(c);
    15231527        }
    1524        
    1525         /**
    1526          * @return
    1527          *              The link for this widget. Null if none.
     1528
     1529        /**
     1530         * @return The link for this widget. Null if none.
    15281531         */
    15291532        public String getLink() {
    15301533                return _textRepresentation.getLink();
    15311534        }
    1532        
    1533 
    1534         /**
    1535          * <b>Note:</b> That if the widget has no parent (e.g. the widget is a free-item) then
    1536          * the absolute link returned will be for the frameset of the current frame.
    1537          *
    1538          * @return
    1539          *              The absolute link for this item. Null if there is no link, or if
    1540          *              there is no parent for this widget and the current frame is unavailable.
    1541          *
     1535
     1536        /**
     1537         * <b>Note:</b> That if the widget has no parent (e.g. the widget is a
     1538         * free-item) then the absolute link returned will be for the frameset of
     1539         * the current frame.
     1540         *
     1541         * @return The absolute link for this item. Null if there is no link, or if
     1542         *         there is no parent for this widget and the current frame is
     1543         *         unavailable.
     1544         * 
    15421545         */
    15431546        public String getAbsoluteLink() {
    1544                
    1545                 // Note:  cannot return the source absolute link since it does not have
     1547
     1548                // Note: cannot return the source absolute link since it does not have
    15461549                // a parent ... thus must manually format link
    1547                
     1550
    15481551                String link = getLink();
    1549                
    1550                 if (link == null || link.length() == 0) return null;
    1551                
    1552                 if (FrameIO.isPositiveInteger(link)) { // relative - convert to absolute
    1553                        
     1552
     1553                if (link == null || link.length() == 0)
     1554                        return null;
     1555
     1556                if (FrameIO.isPositiveInteger(link)) { // relative - convert to
     1557                                                                                                // absolute
     1558
    15541559                        // Get the frameset of this item
    15551560                        Frame parent = getParentFrame();
    1556                         if (parent == null) parent = DisplayIO.getCurrentFrame();
    1557                         if (parent == null) return null;
    1558                        
     1561                        if (parent == null)
     1562                                parent = DisplayIO.getCurrentFrame();
     1563                        if (parent == null)
     1564                                return null;
     1565
    15591566                        String framesetName = parent.getFramesetName();
    1560                        
    1561                         if (framesetName == null) return null;
    1562                        
     1567
     1568                        if (framesetName == null)
     1569                                return null;
     1570
    15631571                        return framesetName + link;
    1564                        
     1572
    15651573                } else if (FrameIO.isValidFrameName(link)) { // already absolute
    15661574                        return link;
    15671575                }
    1568                
     1576
    15691577                return null;
    15701578        }
     
    16001608                _textRepresentation.setColor(c);
    16011609        }
    1602        
     1610
    16031611        public void setSourceBorderColor(Color c) {
    16041612                _textRepresentation.setBorderColor(c);
    16051613        }
    1606        
     1614
    16071615        public void setSourceFillColor(Color c) {
    16081616                _textRepresentation.setFillColor(c);
    16091617        }
    1610        
     1618
    16111619        public void setSourceThickness(float newThickness, boolean setConnected) {
    16121620                _textRepresentation.setThickness(newThickness, setConnected);
     
    16161624                _textRepresentation.setData(data);
    16171625        }
    1618        
     1626
    16191627        protected Point getOrigin() {
    16201628                return _d1.getPosition(); // BROOK: This flips around ... the origin can be any point
    16211629        }
    1622        
     1630
    16231631        protected Item getFirstCorner() {
    16241632                return _d1;
  • trunk/src/org/expeditee/simple/SVariable.java

    r4 r282  
    77 *
    88 */
    9 public abstract class SVariable<T> {
     9public abstract class SVariable<T extends Object> {
    1010        public static final String prefix = "$";
    1111
  • trunk/src/org/expeditee/simple/Variables.java

    r270 r282  
    6363                }
    6464                //TODO:figure out how to fix the ANT build error
    65                 toSet.setValue(toGetValueFrom);
     65                ((SVariable)toSet).setValue(toGetValueFrom);
    6666        }
    6767
Note: See TracChangeset for help on using the changeset viewer.