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

Support for frame transitions added

File:
1 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() {
Note: See TracChangeset for help on using the changeset viewer.