Changeset 980


Ignore:
Timestamp:
12/14/15 13:40:04 (8 years ago)
Author:
davidb
Message:

Support for frame transitions added

Location:
trunk/src/org/expeditee/gui
Files:
1 added
2 edited

Legend:

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

    r940 r980  
    3030import java.awt.RenderingHints;
    3131import java.awt.geom.Area;
     32import java.lang.reflect.Method;
    3233import java.awt.image.BufferedImage;
    3334import java.util.Collection;
     
    599600                        Color background) {
    600601
     602            // Triggers a FrameTransition is this has been signalled
     603            // through an '@frameTransition: xxxx' on the frame.  The type of
     604            // transition is specified in the 'xxxx' part
     605
     606
    601607                // if TwinFrames mode is on, then clipping etc has to be set
    602608                if (DisplayIO.isTwinFramesOn()) {
     
    617623                                        Item.DEFAULT_BACKGROUND, null);
    618624
    619                         // otherwise, just draw whichever side is active
    620                 } else {
    621                         if (DisplayIO.getCurrentSide() == 0)
    622                                 g.drawImage(left, 0, 0, Item.DEFAULT_BACKGROUND, null);
    623                         else
    624                                 g.drawImage(right, 0, 0, Item.DEFAULT_BACKGROUND, null);
    625                 }
    626 
    627         }
     625                       
     626                }
     627                // otherwise, just draw whichever side is active
     628                else {
     629                    if (DisplayIO.getCurrentSide() == 0) {
     630                        g.drawImage(left, 0, 0, Item.DEFAULT_BACKGROUND, null);
     631                        paintTransition(g,left);
     632                    }
     633                    else {
     634                        g.drawImage(right, 0, 0, Item.DEFAULT_BACKGROUND, null);
     635                        paintTransition(g,right);
     636                    }
     637                }
     638
     639        }
     640
     641       
     642    private static void paintTransition(Graphics g, Image image)
     643    {
     644                                 
     645        //If we are doing a transition
     646        if(FrameTransitions.getSlide() == true){                                               
     647           
     648            String input = "org.expeditee.gui.FrameTransitions";
     649            String slide_mode_method = FrameTransitions.getslideModeMethod();
     650       
     651            try {
     652                Class<?> c = Class.forName(input);
     653                System.out.println(c.toString());
     654                Object t;
     655               
     656                t = c.newInstance();                                           
     657               
     658                Class[] cArg = new Class[3];
     659                cArg[0] = Graphics.class;
     660                cArg[1] = Image.class;
     661                cArg[2] = Dimension.class;                                                     
     662               
     663                //Gets the method of transition and calls it                                           
     664                Method lMethod = c.getDeclaredMethod(slide_mode_method, cArg); 
     665               
     666                if(lMethod != null){
     667                   
     668                    System.out.println("method = " + lMethod.toString());                                                                                           
     669                    Object o = lMethod.invoke(t, g, image, _MaxSize);
     670                }
     671                else{
     672                    System.err.println("Unable to locate the transition '" + slide_mode_method + "'");
     673                }                                               
     674               
     675            } catch (Exception e) {                                             
     676               
     677                System.err.println("An Reflection Exception occurred trying to invoke '" + slide_mode_method + "'");
     678                e.printStackTrace();
     679            }   
     680        }               
     681        //Tells the frame to only transition once
     682        FrameTransitions.setSlideFalse();                               
     683    }
     684   
    628685
    629686        public static void Clear() {
  • trunk/src/org/expeditee/gui/FrameUtils.java

    r977 r980  
    421421    }
    422422
     423    // TODO: consider reloating this method to Frame class?   
     424    protected static Item getAnnotation(Frame frame, String annotationStr)
     425    {
     426        Item matched_item = null;
     427       
     428        // check for an updated template...
     429        for (Item i : frame.getAnnotationItems()) {                             
     430           
     431            if (ItemUtils.startsWithTag(i, annotationStr)) {
     432
     433                matched_item = i;
     434                break;
     435            }
     436        }
     437
     438        return matched_item;
     439    }
     440
     441    protected static void doFrameTransition(Item frameTransition, Frame from, Frame to)
     442    {
     443        String s = frameTransition.getText();           
     444        String[] s_array = s.split(":");
     445        if(s_array.length > 1){
     446            String slide_mode_method = s_array[1].trim();
     447           
     448            FrameTransitions.setSlideModeMethod(slide_mode_method);
     449            System.out.println("Triggered on annotation: " + s);
     450            FrameTransitions.setSlideTrue();
     451            FrameTransitions.setSlideModeBaseImage(FrameGraphics.getBuffer(from, false, false));
     452        }
     453        else {
     454            System.err.println("Warning: failed to detect frameTransition type");
     455            // TODO: print list as a result of reflection listing         
     456        }
     457    }                           
     458
    423459    /**
    424460     * Displays the given Frame on the display. If the current frame has changed
     
    502538
    503539        Parse(toDisplay);
     540
     541        // Test to see if frame transition required, and perform it if one if found
     542        Item frameTransition = getAnnotation(toDisplay, "@frameTransition");
     543        if (frameTransition != null) {
     544            doFrameTransition(frameTransition,current,toDisplay);
     545        }
     546               
    504547        DisplayIO.setCurrentFrame(toDisplay, incrementStats);
    505548        FrameMouseActions.updateCursor();
Note: See TracChangeset for help on using the changeset viewer.