Code example: Simple animation, smart use of clipping

The code posted below creates a set of eyes that will track the mouse around, and blink periodically.
In particular, notice the way I use clipping to only paint part of the eyelid oval.
There are two dependencies in the code. One is MathUtils.angle(). Comment this out and replace with the correct call to Math.atan2. The other place is WindowUtilities.visualize(). Remove this and put the Eyes class is a window and you should be good to go
tjacobs.ui.Eyes
package tjacobs.ui;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.JComponent;
import javax.swing.SwingUtilities;
import tjacobs.MathUtils;
public class Eyes extends JComponent implements MouseMotionListener {
     private int mEyeGap = 0;
     private double mEyeDir1 = Double.NaN, mEyeDir2;
     private double mEyeRatio = .6;
     private int mBatEyesState = 0;
     private Timer mEyeBatter;
     private long mTimeBetweenBats;
     private long mBatAnimationSpeed = 100;
     public Eyes() {
          //setBackground(Color.BLACK);
          setBackground(Color.PINK);
          setForeground(Color.BLUE);
          addMouseMotionListener(this);
     public void setBatAnimationSpeed(long speed) {
          mBatAnimationSpeed = speed;
     public long getBatAnimationSpeed() {
          return mBatAnimationSpeed;
     public void mouseMoved(MouseEvent me) {
          Point p = SwingUtilities.convertPoint(me.getComponent(), me.getPoint(), this);
          int height = getHeight();
          mEyeDir1 = MathUtils.angle(height / 2, height / 2, p.x, p.y);
          mEyeDir2 = MathUtils.angle((3 * height) / 2 + mEyeGap, height / 2, p.x, p.y);
          repaint();
     public void mouseDragged(MouseEvent me) {
          mouseMoved(me);
     public int getEyeGap() {
          return mEyeGap;
     public void setEyeGap(int gap) {
          mEyeGap = gap;
     public void setBatEyes(long timeBetweenBats) {
          mTimeBetweenBats = timeBetweenBats;
          if (mEyeBatter != null) {
               mEyeBatter.cancel();
               mEyeBatter = null;
          if (timeBetweenBats < mBatAnimationSpeed * 8) {
               return;
          else {
               mEyeBatter = new Timer(true); //allow it to be a daemon thread
               mEyeBatter.scheduleAtFixedRate(new BatEyesTask(), mTimeBetweenBats, mTimeBetweenBats);
               //Thread t = new Thread(mEyeBatter);
               //t.start();
     private class BatEyesTask extends TimerTask {
          public void run() {
               try {
                    //System.out.println("bat");
                    Thread t = Thread.currentThread();
                    mBatEyesState = 1;
                    repaint();
                    t.sleep(mBatAnimationSpeed);
                    mBatEyesState = 2;
                    repaint();
                    t.sleep(mBatAnimationSpeed);
                    mBatEyesState = 3;
                    repaint();
                    t.sleep(mBatAnimationSpeed);
                    mBatEyesState = 4;
                    repaint();
                    t.sleep(mBatAnimationSpeed);
                    mBatEyesState = 3;
                    repaint();
                    t.sleep(mBatAnimationSpeed);
                    mBatEyesState = 2;
                    repaint();
                    t.sleep(mBatAnimationSpeed);
                    mBatEyesState = 1;
                    repaint();
                    t.sleep(mBatAnimationSpeed);
                    mBatEyesState = 0;
                    repaint();
               catch (InterruptedException ex) {
                    if (mBatEyesState != 0) {
                         mBatEyesState = 0;
                         repaint();
     public void paintComponent(Graphics g) {
          int height = getHeight();
          int r = height / 2;
          g.setColor(Color.WHITE);
          g.fillOval(0, 0, height, height);
          g.fillOval(height + mEyeGap + 0, 0, height, height);
          g.setColor(Color.BLACK);
          g.drawOval(0, 0, height, height);
          g.drawOval(height + mEyeGap + 0, 0, height, height);
          g.setColor(getForeground());
          int irisR = (int) (r * mEyeRatio);
          if (Double.isNaN(mEyeDir1)) {
               int x1 = (r - irisR);
               int y1 = x1;
               g.fillOval(x1, y1, irisR * 2, irisR * 2);
               x1 += height + mEyeGap;
               g.fillOval(x1, y1, irisR * 2 , irisR * 2);
//               int x1 = r - r/4;
//               int y1 = r - r/4;
//               g.fillOval(x1, y1, (int) (r * mEyeRatio), (int) (r * mEyeRatio));
//               x1 += height + mEyeGap;
//               g.fillOval(x1, y1, (int) (r * mEyeRatio) , (int)(r * mEyeRatio));
          } else {
               int x1 = (r - irisR);
               int y1 = x1;
               x1 -= Math.cos(mEyeDir1) * (r - irisR);
               y1 -= Math.sin(mEyeDir1) * (r - irisR);
               g.fillOval(x1, y1, irisR * 2, irisR * 2);
               x1 = (r - irisR) + height + mEyeGap;
               y1 = r - irisR;
               x1 -= Math.cos(mEyeDir2) * (r - irisR);
               y1 -= Math.sin(mEyeDir2) * (r - irisR);
               g.fillOval(x1, y1, irisR * 2, irisR * 2);
//               int x1 = (int) (r - Math.cos(mEyeDir1) * r);
//               int y1 = (int) (r - Math.sin(mEyeDir1) * r);
//               System.out.println("height" + height + " x1 = " + x1 + " y1 = " + y1);
//               g.fillOval(x1, y1, (int) (r * mEyeRatio), (int) (r * mEyeRatio));
//               x1 = height + mEyeGap + (int) (r - Math.cos(mEyeDir2) * r);
//               y1 = (int) (r - Math.sin(mEyeDir2) * r);
//               g.fillOval(x1, y1, (int) (r * mEyeRatio), (int) (r * mEyeRatio));
               //Eye Batting
          //System.out.println("painting");
          if (mBatEyesState != 0) {
               Rectangle rect = new Rectangle(0,0,getWidth(), getHeight() * mBatEyesState / 4);
               g.setClip(rect);
               g.setColor(getBackground());
               g.fillOval(0, 0, height, height);
               g.fillOval(height + mEyeGap + 0, 0, height, height);
      * @param args
     public static void main(String[] args) {
          // TODO Auto-generated method stub
          Eyes eyes = new Eyes();
          eyes.setBatEyes(10000);
          eyes.setPreferredSize(new Dimension(60,25));
          eyes.setEyeGap(5);
          WindowUtilities.visualize(eyes);
}

The code posted below creates a set of eyes that will track the mouse around, and blink periodically.
In particular, notice the way I use clipping to only paint part of the eyelid oval.
There are two dependencies in the code. One is MathUtils.angle(). Comment this out and replace with the correct call to Math.atan2. The other place is WindowUtilities.visualize(). Remove this and put the Eyes class is a window and you should be good to go
tjacobs.ui.Eyes
package tjacobs.ui;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.JComponent;
import javax.swing.SwingUtilities;
import tjacobs.MathUtils;
public class Eyes extends JComponent implements MouseMotionListener {
     private int mEyeGap = 0;
     private double mEyeDir1 = Double.NaN, mEyeDir2;
     private double mEyeRatio = .6;
     private int mBatEyesState = 0;
     private Timer mEyeBatter;
     private long mTimeBetweenBats;
     private long mBatAnimationSpeed = 100;
     public Eyes() {
          //setBackground(Color.BLACK);
          setBackground(Color.PINK);
          setForeground(Color.BLUE);
          addMouseMotionListener(this);
     public void setBatAnimationSpeed(long speed) {
          mBatAnimationSpeed = speed;
     public long getBatAnimationSpeed() {
          return mBatAnimationSpeed;
     public void mouseMoved(MouseEvent me) {
          Point p = SwingUtilities.convertPoint(me.getComponent(), me.getPoint(), this);
          int height = getHeight();
          mEyeDir1 = MathUtils.angle(height / 2, height / 2, p.x, p.y);
          mEyeDir2 = MathUtils.angle((3 * height) / 2 + mEyeGap, height / 2, p.x, p.y);
          repaint();
     public void mouseDragged(MouseEvent me) {
          mouseMoved(me);
     public int getEyeGap() {
          return mEyeGap;
     public void setEyeGap(int gap) {
          mEyeGap = gap;
     public void setBatEyes(long timeBetweenBats) {
          mTimeBetweenBats = timeBetweenBats;
          if (mEyeBatter != null) {
               mEyeBatter.cancel();
               mEyeBatter = null;
          if (timeBetweenBats < mBatAnimationSpeed * 8) {
               return;
          else {
               mEyeBatter = new Timer(true); //allow it to be a daemon thread
               mEyeBatter.scheduleAtFixedRate(new BatEyesTask(), mTimeBetweenBats, mTimeBetweenBats);
               //Thread t = new Thread(mEyeBatter);
               //t.start();
     private class BatEyesTask extends TimerTask {
          public void run() {
               try {
                    //System.out.println("bat");
                    Thread t = Thread.currentThread();
                    mBatEyesState = 1;
                    repaint();
                    t.sleep(mBatAnimationSpeed);
                    mBatEyesState = 2;
                    repaint();
                    t.sleep(mBatAnimationSpeed);
                    mBatEyesState = 3;
                    repaint();
                    t.sleep(mBatAnimationSpeed);
                    mBatEyesState = 4;
                    repaint();
                    t.sleep(mBatAnimationSpeed);
                    mBatEyesState = 3;
                    repaint();
                    t.sleep(mBatAnimationSpeed);
                    mBatEyesState = 2;
                    repaint();
                    t.sleep(mBatAnimationSpeed);
                    mBatEyesState = 1;
                    repaint();
                    t.sleep(mBatAnimationSpeed);
                    mBatEyesState = 0;
                    repaint();
               catch (InterruptedException ex) {
                    if (mBatEyesState != 0) {
                         mBatEyesState = 0;
                         repaint();
     public void paintComponent(Graphics g) {
          int height = getHeight();
          int r = height / 2;
          g.setColor(Color.WHITE);
          g.fillOval(0, 0, height, height);
          g.fillOval(height + mEyeGap + 0, 0, height, height);
          g.setColor(Color.BLACK);
          g.drawOval(0, 0, height, height);
          g.drawOval(height + mEyeGap + 0, 0, height, height);
          g.setColor(getForeground());
          int irisR = (int) (r * mEyeRatio);
          if (Double.isNaN(mEyeDir1)) {
               int x1 = (r - irisR);
               int y1 = x1;
               g.fillOval(x1, y1, irisR * 2, irisR * 2);
               x1 += height + mEyeGap;
               g.fillOval(x1, y1, irisR * 2 , irisR * 2);
//               int x1 = r - r/4;
//               int y1 = r - r/4;
//               g.fillOval(x1, y1, (int) (r * mEyeRatio), (int) (r * mEyeRatio));
//               x1 += height + mEyeGap;
//               g.fillOval(x1, y1, (int) (r * mEyeRatio) , (int)(r * mEyeRatio));
          } else {
               int x1 = (r - irisR);
               int y1 = x1;
               x1 -= Math.cos(mEyeDir1) * (r - irisR);
               y1 -= Math.sin(mEyeDir1) * (r - irisR);
               g.fillOval(x1, y1, irisR * 2, irisR * 2);
               x1 = (r - irisR) + height + mEyeGap;
               y1 = r - irisR;
               x1 -= Math.cos(mEyeDir2) * (r - irisR);
               y1 -= Math.sin(mEyeDir2) * (r - irisR);
               g.fillOval(x1, y1, irisR * 2, irisR * 2);
//               int x1 = (int) (r - Math.cos(mEyeDir1) * r);
//               int y1 = (int) (r - Math.sin(mEyeDir1) * r);
//               System.out.println("height" + height + " x1 = " + x1 + " y1 = " + y1);
//               g.fillOval(x1, y1, (int) (r * mEyeRatio), (int) (r * mEyeRatio));
//               x1 = height + mEyeGap + (int) (r - Math.cos(mEyeDir2) * r);
//               y1 = (int) (r - Math.sin(mEyeDir2) * r);
//               g.fillOval(x1, y1, (int) (r * mEyeRatio), (int) (r * mEyeRatio));
               //Eye Batting
          //System.out.println("painting");
          if (mBatEyesState != 0) {
               Rectangle rect = new Rectangle(0,0,getWidth(), getHeight() * mBatEyesState / 4);
               g.setClip(rect);
               g.setColor(getBackground());
               g.fillOval(0, 0, height, height);
               g.fillOval(height + mEyeGap + 0, 0, height, height);
      * @param args
     public static void main(String[] args) {
          // TODO Auto-generated method stub
          Eyes eyes = new Eyes();
          eyes.setBatEyes(10000);
          eyes.setPreferredSize(new Dimension(60,25));
          eyes.setEyeGap(5);
          WindowUtilities.visualize(eyes);
}

Similar Messages

  • Assembler code example to can application using 8051

    Hi,
    I am developing a CAN application using 8051 family microcontrollers. I need recognize the information coming through Rxdc pin. So far, I was not able to do this. Where can I get some assembler code example for this microcontroller? Someone has one ?
    Thanks.

    Hello-
    Unfortunately, we only provide source code for the NI-CAN boards in Windows under CVI and LabVIEW. The Philips site may have some examples. I believe that they actually sell a CAN chip that is integrated with an 8051.
    Randy Solomonson
    Application Engineer
    National Instruments

  • Need Code Example

    Can someone please show me a code example of how to use RS_EXTERNAL_SELSCREEN_STATUS function.
    I want to delete "Create delivery in background" pushbutton from report vl10h.

    This is the example given in the FM documentation.
    Example
    Example for calling RS_EXTERNAL_SELSCREEN_STATUS:
    PROGRAM SAPDBxyz DEFINING DATABASE xyz.
    FORM INIT.
    CALL FUNCTION 'RS_EXTERNAL_SELSCREEN_STATUS'
    EXPORTING P_FB = 'TEST_EXTERNAL_STATUS'.
    ENDFORM.
    Example for function module that sets the status:
    FUNCTION TEST_EXTERNAL_STATUS.
    ""Local interface:
    *" IMPORTING
    *" P_SUBMIT_MODE
    *" TABLES
    *" P_EXCLUDE STRUCTURE RSEXFCODE
    *" EXCEPTIONS
    *" NO_ACTION
    IF P_SUBMIT_MODE NE SPACE.
    RAISE NO_ACTION.
    ENDIF.
    SET PF-STATUS 'TEST' EXCLUDING P_EXCLUDE.
    SET TITLEBAR 'TST'.
    ENDFUNCTION.
    INITIALIZATION.
    CUA *
    IMPORT T185V FROM MEMORY
    ID SD_COND_MEM_01. "JAY
    RV13B-KVEWE = 'B'.
    RV13B-KOTABNR = '001'.
    CALL FUNCTION 'RS_SUBMIT_INFO'
    IMPORTING
    P_SUBMIT_INFO = RSSUBINFO.
    IF NOT RSSUBINFO-MODE_NORML IS INITIAL.
    TITEL = T185V-CTITEL.
    CALL FUNCTION 'RV_CONDITION_GET_CUA_REPO'
    EXPORTING
    PFKEY_I = 'BSELE'
    TITLE_I = TITEL
    PAR1_I = T185V-PARA1
    PAR2_I = T185V-PARA2
    PAR3_I = T185V-PARA3
    PAR4_I = T185V-PARA4
    TABLES
    EXCL_I = AUSSCHLUSS.
    CALL FUNCTION 'RS_EXTERNAL_SELSCREEN_STATUS'
    EXPORTING
    P_FB = 'RV_CONDITION_SET_CUA_REPO'.
    ENDIF.

  • Example of application that use liveCycle Generation ES

    I´m using in an application web liveCycle Generation 7.2, that convert files to pdf files, but now, I want to migrate my application to liveCycle Generation ES, and I want a code example.
    Thanks

    I still use it.  While I was on vacation last week IT upgraded our MS Office from 2007 to 2010, which is not compatible with Acrobat 9, so now I have no Acrobat Ribbon in Office or Outlook (I also used to archive all my emails into PDF in Outlook).  Acrobat X is compatible with Office 2010, but no LiveCycle in X.  All of my forms are in LiveCycle Designer ES 8.2, so if I upgrade to Acrobat X, I lose LiveCycle. . .  I'm trying to figure out if it is now a separate stand alone or if it's gone all together and they've moved forms into something else.  Maybe Adobe is getting like the airlines . . .

  • Two code examples

    Hi,
    Look below, what is the difference between these two code examples? I always use the first one, but is it right to use the second one to get the same result?
    Ex.
    public void Hello(int i, Vector vec)
    int j;
    Vector vector;
    j=i;
    vector=vec;
    j++;
    vector[c]=8;
    public void Hello(int i, Vector vec)
    i++;
    vec[c]=8;
    /A

    The code is much the same but the second one performs better.
    You should also keep in mind that primitive datatypes like int, char, ... are call-by-value and objects are call-by-reference.
    call-by-value:
    Means that the only the value of the integer is copied to the function.
    call-by-reference:
    Means that the only the reference is given to the function and so you can manipulate the object. ==> the changes are also in the object in the calling fkt.

  • Beginner Question | The use of modulus in this simple code example.

    Hello everyone,
    I am just beginning to learn Java and have started reading "Java Programming for the absolute beginner". It is quite a old book but seems to be doing the trick, mainly.
    There is a code example which I follow mostly but the use of the modulus operator in the switch condition doesn't make sense to me, why is it used? Could someone shed some light on this for me?
    import java.util.Random;
    public class FortuneTeller {
      public static void main(String args[]) {
        Random randini = new Random();
        int fortuneIndex;
        String day;
        String[] fortunes = { "The world is going to end :-(.",
          "You will have a HORRIBLE day!",
          "You will stub your toe.",
          "You will find a shiny new nickel.",
          "You will talk to someone who has bad breath.",
          "You will get a hug from someone you love.",
          "You will remember that day for the rest of your life!",
          "You will get an unexpected phone call.",
          "Nothing significant will happen.",
          "You will bump into someone you haven't seen in a while.",
          "You will be publicly humiliated.",
          "You will find forty dollars.",
          "The stars will appear in the sky.",
          "The proper authorities will discover your secret.",
          "You will be mistaken for a god by a small country.",
          "You will win the lottery!",
          "You will change your name to \"Bob\" and move to Alaska.",
          "You will discover first hand that Bigfoot is real.",
          "You will succeed at everything you do.",
          "You will learn something new.",
          "Your friends will treat you to lunch.",
          "You will meet someone famous.",
          "You will be very bored.",
          "You will hear your new favorite song.",
          "Tomorrow... is too difficult to predict" };
        System.out.println("\nYou have awakened the Great Randini...");
        fortuneIndex = randini.nextInt(fortunes.length);
        switch (randini.nextInt(7) % 7) {   
          case 0:
            day = "Sunday";
            break;
          case 1:
            day = "Monday";
            break;
          case 2:
            day = "Tuesday";
            break;
          case 3:
            day = "Wednesday";
            break;
          case 4:
            day = "Thursday";
            break;
          case 5:
            day = "Friday";
            break;
          case 6:
            day = "Saturday";
            break;
          default:
            day = "Tomorrow";
        System.out.println("I, the Great Randini, know all!");
        System.out.println("I see that on " + day);
        System.out.println("\n" + fortunes[fortuneIndex]);
        System.out.println("\nNow, I must sleep...");
    }

    randini.nextInt(7) % 7randini.nextInt(7) returns a value in the range 0 <= x < 7, right? (Check the API!) And:
    0 % 7 == 0
    1 % 7 == 1
    2 % 7 == 2
    3 % 7 == 3
    4 % 7 == 4
    5 % 7 == 5
    6 % 7 == 6Looks like superfluous code to me. Maybe originally they wrote:
    randini.nextInt() % 7Note this code has problems, because, for example -1 % 7 == -1

  • Hello, i'm creating a very simple animation in ps cs5, but when I try to transform a smart object in a frame, all the frames are affected by it. What can I do ? Thanks, Ep

    Hello, i'm creating a very simple animation in ps cs5, but when I try to transform a smart object in a frame, all the frames are affected by it. What can I do ? Thanks, Ep

    Ok, you are in frame animation mode. I thought cs5 had a timeline mode, but now I think I was wrong.
    In frame animation mode what you do is in one frame you have the object rotated in one position, then select an other frame and rotate it. If it rotates the first frame, which I think it will. Create duplicate of the object in a new layer. Then rotate the second layer.
    At this point in my example you would have two layers, one of which has a rotated object.
    Clear the frames
    Convert the two layers to frames.
    You now have two frames, one for each layer.
    Select both frames then click the tween button.
    This will create the in between frames.
    In the tween dialog box the higher the number of frames set here, will create a smoother animation but will result in a longer time frame for the animation to play.
    Because Photoshop has no way of knowing which way the object should rotate, it is feasible for it to rotate the opposite direction or could look wonky. Just undo and add an in between layer showing how it should look in the middle, then continue on.
    So your layers should be the following, a frame that shows all objects in their rest state.
    All objects that remain in a rest state must be copied to the next layer (ctrl-j on Windows or cmd-j on Mac)
    All subsequent layers are then used for rotating a duplicate of the object. (Ctrl j or cmd j)
    You will find the commands to clear the frames, convert layers to frames and tweeting in the hidden menu found when you click the small icon in the upper right hand corner of the animation panel.

  • Example of  a Simple ALV Report using Function Modules (not OO)

    Hi,
    I am new to ABAP. Where can I get a proper Example of  a Simple ALV Report using Function Modules?  I searched the forum but did not find a proper solution. Kindly help.
    Smruthi.
    Edited by: Smruthi Acharya on Jan 29, 2009 7:13 PM

    Hi,
    Use this demo code:-
    REPORT  z_alv01 MESSAGE-ID zmsg.
    *          TABLES
    TABLES : ekpo.
    *          TYPE POOLS
    TYPE-POOLS : slis.
    *          TYPE DECLARATION
    TYPES : BEGIN OF t_ekpo,
              ebeln TYPE ekpo-ebeln,
              ebelp TYPE ekpo-ebelp,
              matnr TYPE ekpo-matnr,
              werks TYPE ekpo-werks,
              menge TYPE ekpo-menge,
            END OF t_ekpo.
    *          PARAMETERS
    PARAMETERS : s_var TYPE disvariant-variant.
    *          DATA DECLARATION
    *VARIABLES
    DATA : check(1),
           rep_id TYPE sy-repid.
    *INTERNAL TABLE TYPE OF ZEKPO
    DATA : it_ekpo TYPE STANDARD TABLE OF t_ekpo WITH HEADER LINE.
    *FIELD CATALOG
    DATA : it_field TYPE slis_t_fieldcat_alv,
           wa_field TYPE slis_fieldcat_alv.
    *SORTING
    DATA : it_sort TYPE slis_t_sortinfo_alv,
           wa_sort TYPE slis_sortinfo_alv.
    *FOR TOP OF THE PAGE
    DATA : it_top TYPE slis_t_listheader,
           wa_top TYPE slis_listheader.
    *FOR END OF THE PAGE
    DATA : it_end TYPE slis_t_listheader,
           wa_end TYPE slis_listheader.
    *TO CAPTURE EVENTS AND HANDLE
    DATA : it_event TYPE slis_t_event,
           wa_event TYPE slis_alv_event.
    *FOR GRID TITLE
    DATA : wa_title TYPE lvc_title.
    *FOR LAYOUT
    DATA : wa_layout TYPE slis_layout_alv.
    *FOR EXCLUDING STANDARD BUTTON FROM ALV TOOLBAR
    DATA : it_exclude TYPE slis_t_extab,
           wa_exclude TYPE slis_extab.
    *FOR VARIANT
    DATA : wa_variant TYPE disvariant.
    *          INITIALIZATION
    INITIALIZATION.
      check = 'X'.
      rep_id = sy-repid.
      wa_variant-report = sy-repid.
    *GET DEFUALT ON THE SELECTION SCREEN FOR DEFAULT DISPLAY
      CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
        EXPORTING
          i_save        = 'A'
        CHANGING
          cs_variant    = wa_variant
        EXCEPTIONS
          wrong_input   = 1
          not_found     = 2
          program_error = 3
          OTHERS        = 4.
      IF sy-subrc = 0.               " IF DEFAULT VARIANT FOUND
        s_var = wa_variant-variant.  " PASS THE DEFAULT VARIANT TO THE SELECTION SCREEN FIELD
      ENDIF.
    *          AT-SELECTION SCREEN ON VALUE REQUEST
    *          TO GET THE F4 HELP FOR VARIANT
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_var.
      CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
        EXPORTING
          is_variant                = wa_variant
    *   I_TABNAME_HEADER          =
    *   I_TABNAME_ITEM            =
    *   IT_DEFAULT_FIELDCAT       =
         i_save                    = 'A'
    *   I_DISPLAY_VIA_GRID        = ' '
       IMPORTING
    *   E_EXIT                    =
         es_variant                = wa_variant
       EXCEPTIONS
         not_found                 = 1
         program_error             = 2
         OTHERS                    = 3.
      IF sy-subrc = 0.
        s_var = wa_variant-variant. " PASS THE SELECTED VARIANT TO THE SELECTION SCREEN FIELD
      ENDIF.
    *          AT-SELECTION SCREEN
    *          TO CHECK THE EXISTENCE FOR VARIANT
    AT SELECTION-SCREEN.
      wa_variant-variant = s_var.
      CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
        EXPORTING
          i_save        = 'A'
        CHANGING
          cs_variant    = wa_variant
        EXCEPTIONS
          wrong_input   = 1
          not_found     = 2
          program_error = 3
          OTHERS        = 4.
      IF sy-subrc <> 0.
        MESSAGE w001.
      ENDIF.
    *          START OF SELECTION
    START-OF-SELECTION.
      SELECT ebeln
             ebelp
             matnr
             werks
             menge
             FROM ekpo
             INTO TABLE it_ekpo.
    *          FIELD CATALOG
      wa_field-fieldname = 'EBELN'.
      wa_field-tabname = 'IT_TAB'.
      wa_field-outputlen = 10.
      wa_field-seltext_l = 'PO #'.
      APPEND wa_field TO it_field.
      CLEAR wa_field.
      wa_field-fieldname = 'EBELP'.
      wa_field-tabname = 'IT_TAB'.
      wa_field-outputlen = 10.
      wa_field-seltext_l = 'Line Item'.
      APPEND wa_field TO it_field.
      CLEAR wa_field.
      wa_field-fieldname = 'MATNR'.
      wa_field-tabname = 'IT_TAB'.
      wa_field-outputlen = 15.
      wa_field-seltext_l = 'Material'.
    *  wa_field-input = check.
    *  wa_field-edit = check.
      APPEND wa_field TO it_field.
      CLEAR wa_field.
      wa_field-fieldname = 'WERKS'.
      wa_field-tabname = 'IT_TAB'.
      wa_field-outputlen = 6.
      wa_field-seltext_l = 'Plant'.
    *  wa_field-input = check.
    *  wa_field-edit = check.
      APPEND wa_field TO it_field.
      CLEAR wa_field.
      wa_field-fieldname = 'MENGE'.
      wa_field-tabname = 'IT_TAB'.
      wa_field-outputlen = 10.
      wa_field-seltext_l = 'Qty.'.
    *  wa_field-input = check.
    *  wa_field-edit = check.
      wa_field-do_sum = check.
      APPEND wa_field TO it_field.
      CLEAR wa_field.
    *          SORT W.R.T. PURCHASE ORDER NUMBER
      wa_sort-spos = 1.
      wa_sort-fieldname = 'EBELN'.
      wa_sort-tabname = 'IT_EKPO'.
      wa_sort-up = check.
      wa_sort-subtot = check.
      APPEND wa_sort TO it_sort.
      CLEAR wa_sort.
    *          FOR GRID TITLE
      wa_title = 'Hello'.
    *          FOR LAYOUT
      wa_layout-zebra = check.
    *          FOR EXCLUDING STANDARD BUTTONS FROM ALV TOOLBAR
      wa_exclude-fcode = '&OUP'.
      APPEND wa_exclude TO it_exclude.
      CLEAR wa_exclude.
      wa_exclude-fcode = '&ODN'.
      APPEND wa_exclude TO it_exclude.
      CLEAR wa_exclude.
      wa_exclude-fcode = '&OAD'.
      APPEND wa_exclude TO it_exclude.
      CLEAR wa_exclude.
    *  wa_exclude-fcode = '&AVE'.
    *  APPEND wa_exclude TO it_exclude.
    *  CLEAR wa_exclude.
      wa_exclude-fcode = '&INFO'.
      APPEND wa_exclude TO it_exclude.
      CLEAR wa_exclude.
    *          POPULATE ALL EVENTS INTO INTERNAL TABLE
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 0
        IMPORTING
          et_events       = it_event
        EXCEPTIONS
          list_type_wrong = 1
          OTHERS          = 2.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      READ TABLE it_event INTO wa_event WITH KEY name = 'END_OF_LIST'.
      wa_event-form = 'END'.
      MODIFY it_event FROM wa_event INDEX sy-tabix.
      CLEAR wa_event.
    *          DISPLAY RECORDS IN ALV GRID
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
    *   I_INTERFACE_CHECK                 = ' '
    *   I_BYPASSING_BUFFER                = ' '
    *   I_BUFFER_ACTIVE                   = ' '
       i_callback_program                = rep_id
    *   i_callback_pf_status_set          = 'PF'
       i_callback_user_command           = 'COMMAND'
       i_callback_top_of_page            = 'TOP'
    *   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
    *   I_CALLBACK_HTML_END_OF_LIST       = ' '
    *   I_STRUCTURE_NAME                  =
    *   I_BACKGROUND_ID                   = ' '
       i_grid_title                      = wa_title
    *   I_GRID_SETTINGS                   =
       is_layout                         = wa_layout
       it_fieldcat                       = it_field
       it_excluding                      = it_exclude
    *   IT_SPECIAL_GROUPS                 =
       it_sort                           = it_sort
    *   IT_FILTER                         =
    *   IS_SEL_HIDE                       =
    *   I_DEFAULT                         = 'X'
       i_save                            = 'A'
       is_variant                        = wa_variant
       it_events                         = it_event
    *   IT_EVENT_EXIT                     =
    *   IS_PRINT                          =
    *   IS_REPREP_ID                      =
    *   I_SCREEN_START_COLUMN             = 0
    *   I_SCREEN_START_LINE               = 0
    *   I_SCREEN_END_COLUMN               = 0
    *   I_SCREEN_END_LINE                 = 0
    *   I_HTML_HEIGHT_TOP                 = 0
    *   I_HTML_HEIGHT_END                 = 0
    *   IT_ALV_GRAPHICS                   =
    *   IT_HYPERLINK                      =
    *   IT_ADD_FIELDCAT                   =
    *   IT_EXCEPT_QINFO                   =
    *   IR_SALV_FULLSCREEN_ADAPTER        =
    * IMPORTING
    *   E_EXIT_CAUSED_BY_CALLER           =
    *   ES_EXIT_CAUSED_BY_USER            =
        TABLES
          t_outtab                          = it_ekpo
    EXCEPTIONS
       program_error                     = 1
       OTHERS                            = 2.
      IF sy-subrc <> 0.
      ENDIF.
    *&      Form  top
    *       TO WRITE THE HEADER
    FORM top.
      REFRESH it_top.
      wa_top-typ = 'S'.
      wa_top-key = text-001.
      wa_top-info = rep_id.
      APPEND wa_top TO it_top.
      CLEAR wa_top.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary       = it_top
    *   I_LOGO                   =
    *   I_END_OF_LIST_GRID       =
    *   I_ALV_FORM               =
    ENDFORM.                    "top
    *&      Form  end
    *       TO WRITE THE FOOTER
    FORM end.
      REFRESH it_end.
      wa_end-typ = 'S'.
      wa_end-key = text-001.
      wa_end-info = rep_id.
      APPEND wa_end TO it_end.
      CLEAR wa_end.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary       = it_end
    *   I_LOGO                   =
    *   I_END_OF_LIST_GRID       =
    *   I_ALV_FORM               =
    ENDFORM.                    "end
    *&      Form  pf
    *       FOR PF-STATUS WITH USER DEFINED BUTTONS
    *      -->RT_EXTAB   text
    FORM pf USING rt_extab TYPE slis_t_extab.
      SET PF-STATUS 'ZTG_PF_ALV'.
    ENDFORM.                    "pf
    *&      Form  command
    *       TO HANDLE USER ACTIONS AGAINST PF-STATUS
    *      -->UCOMM      text
    *      -->SELFIELD   text
    FORM command USING ucomm LIKE sy-ucomm selfield TYPE slis_selfield.
      DATA : ok_code TYPE sy-ucomm.
      ok_code = ucomm.
      CASE ok_code.
        WHEN 'T_DOWN'.
          CALL FUNCTION 'POPUP_TO_INFORM'
            EXPORTING
              titel = 'HELLO'
              txt1  = 'USER COMMAND'
              txt2  = 'TOTAL DOWN'.
        WHEN 'DOWN'.
          CALL FUNCTION 'POPUP_TO_INFORM'
            EXPORTING
              titel = 'HELLO'
              txt1  = 'USER COMMAND'
              txt2  = 'DOWN'.
        WHEN 'UP'.
          CALL FUNCTION 'POPUP_TO_INFORM'
            EXPORTING
              titel = 'HELLO'
              txt1  = 'USER COMMAND'
              txt2  = 'UP'.
        WHEN 'T_UP'.
          CALL FUNCTION 'POPUP_TO_INFORM'
            EXPORTING
              titel = 'HELLO'
              txt1  = 'USER COMMAND'
              txt2  = 'TOTAL UP'.
      ENDCASE.
    ENDFORM.                    "command
    Hope this helps you.
    Thanks & Regards,
    Tarun Gambhir

  • Convert simple animation code from as2 to as3

    Hi everyone,
    I have a simple animation that is controlled by the y movement of the mouse. The code for the animation is put in frame 1 and is as follows:
    var animationDirection:Boolean = false;
    var prevMousePosition:Boolean = false;
    var mouseListener = new Object();
    mouseListener.onMouseMove = function () {
    var curMousePosition = _ymouse;
    if(curMousePosition > prevMousePosition) {
    animationDirection = false;
    }else if(curMousePosition < prevMousePosition) {
    animationDirection = true;
    prevMousePosition = curMousePosition;
    Mouse.addListener(mouseListener);
    function onEnterFrame() {
    if(animationDirection && _currentframe < _totalframes) {
    nextFrame();
    }else if(!animationDirection && _currentframe > 1) {
    prevFrame();
    Is it possible to use this code in as3 or do I need to convert it? I am grateful for any help. Best wishes

    Yes, you need to convert the code. Here is what looks like a similar logic in AS3:
    import flash.events.Event;
    import flash.events.MouseEvent;
    var animationDirection:Boolean = false;
    var prevMousePosition:Boolean = false;
    addEventListener(Event.ENTER_FRAME, onEnterFrame);
    addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
    function onMouseMove(e:MouseEvent):void {
        var curMousePosition = mouseX;
        if (curMousePosition > prevMousePosition)
            animationDirection = false;
        else if (curMousePosition < prevMousePosition)
            animationDirection = true;
        prevMousePosition = curMousePosition;
    function onEnterFrame(e:Event):void
        if (animationDirection && _currentframe < _totalframes)
            nextFrame();
        else if (!animationDirection && _currentframe > 1)
            prevFrame();

  • I am trying to create a simple animated gif in Photoshop. I've set up my frames and want to use the tween to make the transitions less jerky. When I tween between frame 1 and frame 2 the object in frame two goes out of position, appearing in a different p

    I am trying to create a simple animated gif in Photoshop. I've set up my frames and want to use the tween to make the transitions less jerky. When I tween between frame 1 and frame 2 the object in frame two goes out of position, appearing in a different place than where it is on frame 2. Confused!

    Hi Melissa - thanks for your interest. Here's the first frame, the second frame and the tween frame. I don't understand why the tween is changing the position of the object in frame 2, was expecting it to just fade from one frame to the next.

  • ABAP Code example using "GENERATE DYNPRO"

    I am looking for ABAP code example who use the "Generate dynpro" dynamic generation of dynpro at runtime under SAP 4.6C version.
    Best regards,

    We have some programs that do:
    form %view.
    data: anz type i,
          prog like sy-repid.
      prog = sy-repid.
      perform init_download(rsaqexce).
      case %tab.
      when 'G00'.
        perform generate_view_dynpro(rsaqexce)
                using prog text-grl.
        describe table %g00 lines anz.
        tview100-lines = anz.
        perform init_view(rsaqexce) tables %g00 using tview100.
        call screen 100.
        perform reset_view_dynpro(rsaqexce).
      when others.
        message s860(aq).
      endcase.
    endform.
    I think they were copied from existing SAP programs. In any event, look at the relevant forms in program rsaqexce.
    And as Rich noted, SAP doesn't recommend this.
    Rob

  • Pause & Play Animation When i'm using movie clips- filters

    Pause & Play Animation When i am using movie clips-
    filters
    Graphic and movieclips are using for my animation
    When i Press the pause the movieclip animation not stopped.
    Any way to apply the filters on graphic
    I want to apply the filters for particular graphics or movie
    clips. with navigational button working.
    Please help me.
    Thanks
    S.Satheesh Kumar

    Audio on the timeline, especially stream, tends to play very reliably. Is this project under any NDA or can you provide a FLA to examine? Let me know if you want to private message it and I'll shoot you a message.
    What version of Flash Player are you targeting and is this AS2 or AS3?

  • Code example using interface controller ?

    Hi, guys:
    I have a question.
    In CRM UI, I need to integrate one component with another component, and I want to pass the value from 1st component to 2nd component using interface controller. Does any one who have done this before and have a code example?
    Really appreciate!
    Eric

    Hi Eric,
    Refer:
    [http://forums.sdn.sap.com/thread.jspa?threadID=2014259|http://forums.sdn.sap.com/thread.jspa?threadID=2014259]
    [http://forums.sdn.sap.com/thread.jspa?threadID=1909625|http://forums.sdn.sap.com/thread.jspa?threadID=1909625]
    Regards,
    Leon

  • WTC code examples using FML32

    Hi,
    Are there any code examples of using WTC with FML32 buffers?
    The examples are using the TypedString buffer. Where does the field table fit
    in?

    An FML32 buffer example has been added with the WLS 6.1 release of
    WTC. It can be found in the samples/examples/wtc/atmi/simpFML32
    directory of the WLS 6.1 distribution.
    An explanation of FML field table administration can be found with the WLS 6.1
    WTC documentation at:
    http://e-docs.bea.com/wls/docs61/wtc_admin/index.html
    Bob Finan
    Barry wrote:
    Hi,
    Are there any code examples of using WTC with FML32 buffers?
    The examples are using the TypedString buffer. Where does the field table fit
    in?

  • Photoshop animated smart object to Flash??

    Hey All,
    I could use a little help here, I am working on this project for a company and they need it to be animated. I tried using Photoshop's animation capabilities, but could only go so far with that. So I'm working on it in flash now. I have managed to import the scene I was working on in Photoshop to flash, but I can't seem to figure how to get the animated smart object (with a screen layer blending mode) to come across in flash. I'm sure there is some super simple way of doing this, but I can't think of one. I've got years of experience with Photoshop, but little time with Flash.
    When I import the PSD file to Flash I am selecting the animated smart object layer as "Bitmap image with editable layer styles" selected, and have it also selected to be a movie clip. But it only shows up as a static layer without the screen blending like it was in Photoshop. What am I doing wrong here?
    Thanks,
    Paul

    Paul you may want to ask this question over in the AI forum http://forums.adobe.com/community/illustrator its audience may have more experience then this forum's audience with Illustrator and Photoshop combo many here only use Photoshop. I for example have no idea what you mean when you write  a spot color.

Maybe you are looking for

  • Missing ease-of-use features

    Has anyone else noticed some obvious missing UI items in iMovie 08? I just imported 28 DV-25 tapes of data and am shocked and chagrined at the lack of fit and finish to iMovie 08. No, I don't really miss the timeline and the "newer" way of trimming c

  • Desktop Conference 2007

    Desktop Conference 2007 Last call of the Call for Papers. Share the lessons your organization learned with its business intelligence or data warehousing project. Do you have tips and techniques that might benefit your colleagues? Remember that if you

  • Thunderbolt DaisyChain Woes

    I have a late 2012 iMac and late 2012 Mac Mini, both with Thunderbolt. I'd like to use the iMac as a display for the Mini, no problem (CMD+F2) when linked directly together via Thunderbolt. The problem here is that I have a bunch of Thunderbolt drive

  • Using web-service with forms9i

    Hi I have a setup of oracle9ias release 2 on solaris machine. I have made a web-service which is deployed on nt machine on weblogic server. I have made a call from my form (forms9i) to this web-service. When i try to use that web-service after deploy

  • Mutliple receivers

    Hi All, I got 2 queries. 1.Can anyone explain when to go for BPM and when to go for normal scenario(enhanced Receiver determination) in case there are multiple receivers?Please give some detailed description as I am pretty confused with this topic. 2