Changeset 997


Ignore:
Timestamp:
02/05/16 09:33:19 (8 years ago)
Author:
davidb
Message:

Added new version of FrameIO

Location:
trunk/src/org/expeditee/gui
Files:
6 edited

Legend:

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

    r947 r997  
    197197            try
    198198        {
    199           URL iconURL = ClassLoader.getSystemResource("org/expeditee/assets/icons/expediteeicon128.png");
     199          URL iconURL = ClassLoader.getSystemResource("org/expeditee/assets/icons/expediteeicon128.png"); //this is ideal
    200200          if (iconURL != null)
    201201          {
  • trunk/src/org/expeditee/gui/Frame.java

    r979 r997  
    23702370                 * every time this method is called
    23712371                 */
    2372                 if (_interactableItems.size() > 0)
    2373                         return _interactableItems;
     2372                //if (_interactableItems.size() > 0)
     2373                //      return _interactableItems;
    23742374
    23752375                for (Item i : _body) {
     
    23842384                for (Item i : _overlayItems) {
    23852385                        if (i.hasPermission(UserAppliedPermission.followLinks)) {
    2386                                 _interactableItems.add(i);
    2387                         }
     2386                                _interactableItems.add(i);     
     2387                        }
     2388                       
     2389                       
    23882390                }
    23892391
  • trunk/src/org/expeditee/gui/FrameGraphics.java

    r984 r997  
    7272        // Start in XRay mode so that errors aren't thrown when parsing the profile
    7373        // frame if it has images on it
    74         private static int _Mode = MODE_XRAY;
     74        private static int _Mode = MODE_AUDIENCE;
    7575
    7676        private FrameGraphics() {
  • trunk/src/org/expeditee/gui/FrameIO.java

    r924 r997  
    3232import java.io.OutputStreamWriter;
    3333import java.io.Writer;
     34import java.nio.channels.FileChannel;
    3435import java.sql.Time;
    3536import java.util.Collection;
     
    214215        }
    215216
     217        //Loads the 'restore' version of a frame if there is one
     218                public static Frame LoadRestoreFrame(Frame frameToRestore) {                   
     219                       
     220                        String fullPath = getFrameFullPathName(frameToRestore.getPath(), frameToRestore
     221                                        .getName());
     222                        //System.out.println("fullpath: " + fullPath);
     223                        String restoreVersion = fullPath + ".restore";
     224                        //System.out.println("restoreversion" + restoreVersion);
     225                        File source = new File(restoreVersion);
     226                        File dest = new File(fullPath);
     227                       
     228                        FileChannel inputChannel = null;
     229                        FileChannel outputChannel = null;
     230                       
     231                        try{
     232                                        FileInputStream source_fis = new FileInputStream(source);
     233                                        inputChannel = source_fis.getChannel();
     234                                       
     235                                        FileOutputStream dest_fos = new FileOutputStream(dest);
     236                                        outputChannel = dest_fos.getChannel();
     237                                       
     238                                        outputChannel.transferFrom(inputChannel, 0, inputChannel.size());
     239                                        inputChannel.close();
     240                                        outputChannel.close();
     241                                        source_fis.close();
     242                                        dest_fos.close();
     243                        }               
     244                        catch(Exception e){
     245                               
     246                                System.err.println("No restore point detected.");
     247                        }
     248                        String frameName = frameToRestore.getName();
     249                        String frameNameLower = frameName.toLowerCase();
     250                       
     251                        // first try reading from cache
     252                        if (isCacheOn() && _Cache.containsKey(frameNameLower)) {
     253                                Logger.Log(Logger.SYSTEM, Logger.LOAD, "Clearing " + frameName
     254                                                + " from cache.");
     255                                Frame frame = _Cache.get(frameNameLower);
     256                                _Cache.remove(frameNameLower);                         
     257                        }
     258                       
     259                        return LoadFrame(frameName, frameToRestore.getPath(), true);
     260                }               
     261               
    216262        public static BufferedReader LoadPublicFrame(String frameName) {
    217263                String fullPath = FrameIO.getFrameFullPathName(PUBLIC_PATH, frameName);
     
    294340        public static synchronized String getFrameFullPathName(String path,
    295341                        String frameName) {
    296                 String source = path + Conversion.getFramesetName(frameName)
    297                                 + File.separator;
     342               
     343                String source;
     344                String fileName = null;
     345                if(frameName.contains("restore")){
     346                        source = path + File.separator;// + frameName;
     347                        fileName = path + File.separator + frameName + ExpReader.EXTENTION;
     348                       
     349                }
     350                else
     351                {
     352                        source = path + Conversion.getFramesetName(frameName)
     353                        + File.separator;
     354                }
     355       
    298356
    299357                File tester = new File(source);
     
    301359                        return null;
    302360
    303                 // check for the new file name format
    304                 String fullPath = source + Conversion.getFrameNumber(frameName)
    305                                 + ExpReader.EXTENTION;
     361                String fullPath;
     362               
     363                if(frameName.contains("restore")){
     364                       
     365                        fullPath = fileName;
     366                }
     367                else
     368                {
     369                        // check for the new file name format
     370                        fullPath = source + Conversion.getFrameNumber(frameName)
     371                        + ExpReader.EXTENTION;
     372                }               
     373               
    306374                tester = new File(fullPath);
    307375
     
    10221090
    10231091        /**
     1092         * Saves the given Frame to disk in the corresponding frameset directory as a RESTORE, if
     1093         * inc is true then the saved frames counter is incremented, otherwise it is
     1094         * untouched.
     1095         *
     1096         * @param toSave
     1097         *            The Frame to save to disk as the DEFAULT COPY
     1098         * @param inc
     1099         *            True if the saved frames counter should be incremented, false
     1100         *            otherwise.
     1101         * @param checkBackup
     1102         *            True if the frame should be checked for the back up tag
     1103         */
     1104        public static String SaveFrameAsRestore(Frame toSave, boolean inc,
     1105                        boolean checkBackup) {
     1106               
     1107                String sf = SaveFrame(toSave, inc, checkBackup);               
     1108                String originalFrameName = toSave.getFramesetName();
     1109                //System.out.println(originalFrameName + " : " + toSave.getPath());
     1110                String fullPath = getFrameFullPathName(toSave.getPath(), toSave
     1111                                .getName());
     1112                //System.out.println(fullPath);
     1113                String restoreVersion = fullPath + ".restore";
     1114                File source = new File(fullPath);
     1115                File dest = new File(restoreVersion);
     1116               
     1117                FileChannel inputChannel = null;
     1118                FileChannel outputChannel = null;
     1119               
     1120                try{
     1121                                FileInputStream source_fis = new FileInputStream(source);
     1122                                inputChannel = source_fis.getChannel();
     1123                               
     1124                                FileOutputStream dest_fos = new FileOutputStream(dest);
     1125                                outputChannel = dest_fos.getChannel();
     1126                               
     1127                                outputChannel.transferFrom(inputChannel, 0, inputChannel.size());
     1128                                inputChannel.close();
     1129                                outputChannel.close();
     1130                                source_fis.close();
     1131                                dest_fos.close();
     1132                }               
     1133                catch(Exception e){
     1134                        e.printStackTrace();
     1135                }                       
     1136               
     1137                return sf;
     1138        }
     1139       
     1140        /**
    10241141         * @param toAdd
    10251142         */
  • trunk/src/org/expeditee/gui/FrameMouseActions.java

    r949 r997  
    4444import java.util.List;
    4545import java.util.Set;
     46import java.util.TimerTask;
    4647
    4748import javax.swing.Timer;
     
    5354import org.expeditee.gui.indirect.mouse.MouseAction;
    5455import org.expeditee.gui.indirect.mouse.MouseInfo;
     56import org.expeditee.gui.Frame;
    5557import org.expeditee.io.ExpClipReader;
    5658import org.expeditee.io.ItemSelection;
     
    6870import org.expeditee.items.UserAppliedPermission;
    6971import org.expeditee.items.XRayable;
     72import org.expeditee.items.widgets.ButtonWidget;
    7073import org.expeditee.items.widgets.InteractiveWidget;
    7174import org.expeditee.items.widgets.WidgetCorner;
     
    8386
    8487        private boolean _autoStamp = false;
    85 
     88       
    8689        private FrameMouseActions() {
    8790                IndirectMouseActions.getInstance().setBackAction(new MouseAction() {
     
    898901                int buttonPressed = e.getButton();
    899902                _mouseDown += buttonPressed;
     903                //when border of bin is clicked we can pick up the widget has been clicked
    900904                _lastClickedOn = FrameUtils.getCurrentItem();
    901905                // load any frame if necessary
     
    13451349        private void leftButton(Item clicked, Collection<Item> clickedIn,
    13461350                        boolean isShiftDown, boolean isControlDown) {
     1351               
     1352                //Gets the current frame
     1353                Frame f = DisplayIO.getCurrentFrame();
     1354               
     1355                //Checks if the current frame is an overlay
     1356                if(f.getOverlays() != null && FrameUtils.getCurrentItem() != null){
     1357                        Item i = FrameUtils.getCurrentItem();
     1358                       
     1359                        //Checks if the item clicked in the overlay is a Rubbish Bin. If it is, delete the item attached to the cursor and return.
     1360                        if(i instanceof WidgetCorner){
     1361                               
     1362                                try{
     1363                                        WidgetCorner wc = (WidgetCorner)i;                                     
     1364                                        ButtonWidget bw = (ButtonWidget) wc.getWidgetSource();
     1365                                       
     1366                                        //Should call a button widgets 'itemheldwhileclicked' method, and process depending on the widget type - else will return false.
     1367                                        if(bw.itemHeldWhileClicked((InteractiveWidget)bw) == true){             
     1368                                        //if(bw.ItemsLeftClickDropped() == true){                                               
     1369                                               
     1370                                                return;
     1371                                        }                               
     1372                                }
     1373                                catch (Exception e){
     1374                                       
     1375                                        e.printStackTrace();
     1376                                }
     1377                        }
     1378                       
     1379                        Item on = _lastClickedOn;
     1380                        _lastClickedIn = FrameUtils.getCurrentItems(on);
     1381                }
     1382               
    13471383
    13481384                // if the user is pointing at something then either follow the link or
     
    13541390                        // System.out.println(mouseX + "," + mouseY);
    13551391                        for (Item i : DisplayIO.getCurrentFrame().getItems()) {
     1392                                //System.out.println(i.getName().toString());
    13561393                                if (i instanceof Text) {
    13571394                                        if (i.isNear(mouseX, mouseY)) {
     
    13771414                                && _lastClickedIn.size() >= 4) {
    13781415
    1379                         // Check to see if the use clicked into a widgets empty space
     1416                        // Check to see if the user clicked into a widgets empty space
    13801417                        InteractiveWidget iw = null;
    13811418
     
    13981435                                }
    13991436                               
    1400                                 // Note: musten't directly use source for handling the link
     1437                                // Note: mustn't directly use source for handling the link
    14011438                                // because all link operations will by-pass the widgets special
    14021439                                // handling with links...
     
    22962333        }
    22972334
     2335       
    22982336        public void refreshHighlights() {
    22992337                // ByMike: Get the item the mouse is hovering over
     
    23422380                                // Item.SelectedMode.Connected);
    23432381                                // TODO: The method below is for the most part redundant
     2382                               
     2383                                //start a timer to check how long mouse hovers over item for
     2384                                //java.util.Timer timer = new java.util.Timer();
     2385                                //timer.schedule(new TimerTask() {
     2386                                          //@Override
     2387                                          //public void run() {
     2388                                           
     2389                                                  //System.out.println("The mouse hovered over an item for 3 seconds");
     2390                                         //}
     2391                                        //}, 10000);
     2392                               
     2393                               
     2394                               
     2395                               
    23442396                                on = FrameGraphics.Highlight(on.getEditTarget());
    23452397                        }
  • trunk/src/org/expeditee/gui/FrameUtils.java

    r980 r997  
    5959import org.expeditee.items.UserAppliedPermission;
    6060import org.expeditee.items.XRayable;
     61import org.expeditee.items.widgets.ButtonWidget;
    6162import org.expeditee.items.widgets.InteractiveWidget;
    6263import org.expeditee.items.widgets.InteractiveWidgetInitialisationFailedException;
    6364import org.expeditee.items.widgets.InteractiveWidgetNotAvailableException;
     65import org.expeditee.items.widgets.RubbishBin;
    6466import org.expeditee.items.widgets.WidgetCorner;
    6567import org.expeditee.items.widgets.WidgetEdge;
     
    12221224            checkList.addAll(toCheck.getInteractableItems());
    12231225            checkList.add(toCheck.getNameItem());
     1226           
    12241227            for (Item i : checkList) {
     1228                       
    12251229                // do not check annotation items in audience mode
    12261230                if (i.isVisible()
    12271231                        && !(FrameGraphics.isAudienceMode() && i.isAnnotation())) {
    1228                     if (i.contains(x, y)
    1229                             && !FreeItems.getInstance().contains(i)) {
    1230                         possibles.add(i);
     1232                        if(i instanceof WidgetCorner){
     1233                                WidgetCorner wc = (WidgetCorner)i;
     1234                                if(wc.getWidgetSource() instanceof ButtonWidget){
     1235                                        ButtonWidget bw = (ButtonWidget) wc.getWidgetSource();
     1236                                       
     1237                                        if(bw.getdropInteractableStatus() == true){
     1238                                                InteractiveWidget iw = wc.getWidgetSource();
     1239                                               
     1240                                                if(iw.getBounds().contains(x, y)){
     1241                                                       
     1242                                                        if( !FreeItems.getInstance().contains(i))
     1243                                                {
     1244                                                                possibles.add(i);                                                       
     1245                                                }
     1246                                                }       
     1247                                        }
     1248                                       
     1249                                }
     1250                               
     1251                }
     1252
     1253                    if (i.contains(x, y)){
     1254                        if( !FreeItems.getInstance().contains(i))
     1255                        {
     1256                                possibles.add(i);                               
     1257                        }
    12311258                    }
     1259                           
    12321260                }
    12331261            }
     
    12631291            }
    12641292
    1265         }
     1293        }       
    12661294
    12671295        return closest;
Note: See TracChangeset for help on using the changeset viewer.