Trackball motion events

Hello world!

Well, I have a little problem. My application must handle trackball movements--up, down, left and right. Can someone tell me how this could be done?

Have you looked at the 'listener' navigationMovement() method.

Tags: BlackBerry Developers

Similar Questions

  • Trackball system event value

    What is the value of the event system for press trackball/trackpad? I know that for the previous button, it's 'number const KEY_BACK = 0'.

    I have this link

    http://www.BlackBerry.com/developers/docs/widgetapi/BlackBerry.System.event.html#BlackBerry.System.e...

    but not able to understand for press track ball.

    A trackball/trackpad click sends an onclick to the target element or the element that the cursor is currently over.

  • Hurry trackball event repetition

    Hi all

    Is it possible to detect trackball continuous event pressed in BlackBerry? Any suggestions are welcome.

    Kind regards

    Roney

    I got it. I used navigationClick and navigationUnclicked. measure the delay between the calls and that's it. My problem was the behavior of the emulator was wrong. He calls the method to clear the event. Thanks for everyone.

  • Problem led the TweenEvent event.target

    Hello

    The logic of the code is as follows (pseudo):

    function X {}

    switch

    (1) tween1-> tween finishing launch onTweenFinish();

    (2)-> finishing launch onTweenFinish() tween tween2;

    (3) tween3-> tween finishing launch onTweenFinish();

    ]

    and now AS3:

    int onTweenFinish(e:TweenEvent):void

    {

    trace ("Motion event triggered");

    trace (e.Target.Name);

    }

    results in: ReferenceError: Error #1069: the property name not found on fl.transitions.Tween and there is no default value.

    What I want is to treat all the interpolations of three in one function, but I need to know what tween it was. It is of course possible to make three separate functions, one for each tween, but it's just not good.

    Any suggestions?

    Thank you

    Maxim.

    You could test to see who it is...

    function onTweenFinish(e:TweenEvent):void

    {
    if(e.currentTarget == tween1) {}
    trace ("tween1 triggered event");
    } else if(e.currentTarget == tween2) {}
    trace ("tween2 triggered event");
    } etc...

    }

  • Problems capturing pictures about OS6 - East System.getProperty ("video.snapshot.encodings"); valid?

    Hello

    I hope someone can help with this query.

    I use the code that is very similar to the sample application camerademo to take a photo using the camera. It works properly on devices running OS5. However, on devices running OS6 photo is just an image of white/black.

    I think I followed the problem until the encoding string passed to getSnapshot(). When I switch which must be a valid encoding string (based on the output of System.getProperty ("video.snapshot.encodings")) the captured image is a black screen. However, when I pass null to getSnapshot() it works correctly. I want to avoid using null as the captured image is much more that I need and for reasons of effectiveness, I would like to avoid having to reduce its size after the capture of the photo.

    I tested this on the 9780 Simulator. The corresponding code is included below for reference.

    Thanks in advance!

    /*
     * CameraDemo.java
     *
     * Copyright © 1998-2008 Research In Motion Ltd.
     *
     * Note: For the sake of simplicity, this sample application may not leverage
     * resource bundles and resource strings.  However, it is STRONGLY recommended
     * that application developers make use of the localization features available
     * within the BlackBerry development platform to ensure a seamless application
     * experience across a variety of languages and geographies.  For more information
     * on localizing your application, please refer to the BlackBerry Java Development
     * Environment Development Guide associated with this release.
     */
    
    package com.rim.samples.device.camerademo;
    
    import java.util.Vector;
    
    import javax.microedition.amms.control.camera.CameraControl;
    import javax.microedition.media.Manager;
    import javax.microedition.media.Player;
    import javax.microedition.media.control.VideoControl;
    
    import net.rim.device.api.system.Characters;
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.Keypad;
    import net.rim.device.api.ui.UiApplication;
    import net.rim.device.api.ui.component.Dialog;
    import net.rim.device.api.ui.component.RichTextField;
    import net.rim.device.api.ui.container.MainScreen;
    import net.rim.device.api.util.StringUtilities;
    
    /**
     * A sample application used to demonstrate the VideoControl.getSnapshot()
     * method. Creates a custom camera which can take snapshots from the
     * Blackberry's camera.
     */
    final class CameraDemo extends UiApplication
    {
        /** Entry point for this application. */
        public static void main(String[] args)
        {
            CameraDemo demo = new CameraDemo();
            demo.enterEventDispatcher();
        }
    
        /** Constructor. */
        private CameraDemo()
        {
            CameraScreen screen = new CameraScreen();
            pushScreen( screen );
        }
    }
    
    /**
     * A UI screen to display the camera display and buttons.
     */
    final class CameraScreen extends MainScreen
    {
        /** The camera's video controller. */
        private VideoControl _videoControl;
    
        /** The field containing the feed from the camera. */
        private Field _videoField;
    
        private Player player;
    
        /** An array of valid snapshot encodings. */
        private EncodingProperties[] _encodings;
    
        /**
         * Constructor. Initializes the camera and creates the UI.
         */
        public CameraScreen()
        {
            //Set the title of the screen.
            //setTitle( new LabelField( "Camera Demo" , LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH ) );
    
            //Initialize the camera object and video field.
            initializeCamera();
    
            //Initialize the list of possible encodings.
            initializeEncodingList();
    
            //If the field was constructed successfully, create the UI.
            if(_videoField != null)
            {
                createUI();
            }
            //If not, display an error message to the user.
            else
            {
                add( new RichTextField( "Error connecting to camera." ) );
            }
    
        }
    
        /**
         * Adds the VideoField and the "Take Photo" button to the screen.
         */
        private void createUI()
        {
            //Add the video field to the screen.
            add(_videoField);
    
        }
    
        /**
         * Initializes the Player, VideoControl and VideoField.
         */
        private void initializeCamera()
        {
            try
            {
                //Create a player for the Blackberry's camera.
               player = Manager.createPlayer( "capture://video" );
    
                //Set the player to the REALIZED state (see Player docs.)
                player.realize();
    
                //Grab the video control and set it to the current display.
                _videoControl = (VideoControl)player.getControl( "VideoControl" );
    
                if (_videoControl != null)
                {
                    //Create the video field as a GUI primitive (as opposed to a
                    //direct video, which can only be used on platforms with
                    //LCDUI support.)
                    _videoField = (Field) _videoControl.initDisplayMode (VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");
                    //Display the video control
                    _videoControl.setDisplayFullScreen(true);
                    _videoControl.setVisible(true);
                }
    
                //Set the player to the STARTED state (see Player docs.)
                player.start();
    
            }
            catch(Exception e)
            {
                Dialog.alert( "ERROR " + e.getClass() + ":  " + e.getMessage() );
            }
        }
    
        /**
         * Create a screen used to display a snapshot.
         * @param raw A byte array representing an image.
         */
        private void createImageScreen( byte[] raw )
        {
            //Initialize the screen.
            ImageScreen imageScreen = new ImageScreen( raw );
    
            //Push this screen to display it to the user.
            UiApplication.getUiApplication().pushScreen( imageScreen );
        }
    
        /**
         * Handle trackball click events.
         * @see net.rim.device.api.ui.Screen#invokeAction(int)
         */
        protected boolean invokeAction(int action)
        {
            boolean handled = super.invokeAction(action); 
    
            if(!handled)
            {
                switch(action)
                {
                    case ACTION_INVOKE: // Trackball click.
                    {
                    try
                    {
                        //A null encoding indicates that the camera should
                        //use the default snapshot encoding.
                        String encoding = null;
    
                        // All the below result in a black screen being captured on OS6 devices
                        // encoding = "encoding=jpeg&width=1024&height=768";
                        // encoding = "encoding=jpeg&width=1024&height=768&quality=superfine";
                        // encoding = _encodings[1].getFullEncoding();
                        // Null works but the image captured is large (~1MB)
                        encoding = null;
    
                        //Retrieve the raw image from the VideoControl and
                        //create a screen to display the image to the user.
                        createImageScreen(_videoControl.getSnapshot(  encoding ) );//null works
                    }
                    catch(final Throwable e)
                    {
                        UiApplication.getUiApplication().invokeLater(new Runnable()
                        {
                            public void run()
                            {
                                Dialog.alert( "ERROR " + e.getClass() + ":  " + e.getMessage() );
                            }
                        });
                    }
    
                        return true;
                    }
                }
            }
            return handled;
        }
    
        /**
         * Prevent the save dialog from being displayed.
         * @see net.rim.device.api.ui.container.MainScreen#onSavePrompt()
         */
        public boolean onSavePrompt()
        {
            return true;
        }
    
        /**
         * Initialize the list of encodings.
         */
        private void initializeEncodingList()
        {
            try
            {
                //Retrieve the list of valid encodings.
                String encodingString = System.getProperty("video.snapshot.encodings");
    
                //Extract the properties as an array of words.
                String[] properties = StringUtilities.stringToKeywords(encodingString);
    
                //The list of encodings;
                Vector encodingList = new Vector();
    
                //Strings representing the four properties of an encoding as
                //returned by System.getProperty().
                String encoding = "encoding";
                String width = "width";
                String height = "height";
    
                EncodingProperties temp = null;
    
                for(int i = 0; i < properties.length ; ++i)
                {
                    if( properties[i].equals(encoding))
                    {
                        if(temp != null && temp.isComplete())
                        {
                            //Add a new encoding to the list if it has been
                            //properly set.
                            encodingList.addElement( temp );
                        }
                        temp = new EncodingProperties();
    
                        //Set the new encoding's format.
                        ++i;
                        temp.setFormat(properties[i]);
                    }
                    else if( properties[i].equals(width))
                    {
                        //Set the new encoding's width.
                        ++i;
                        temp.setWidth(properties[i]);
                    }
                    else if( properties[i].equals(height))
                    {
                        //Set the new encoding's height.
                        ++i;
                        temp.setHeight(properties[i]);
                    }
                }
    
                //If there is a leftover complete encoding, add it.
                if(temp != null && temp.isComplete())
                {
                    encodingList.addElement( temp );
                }
    
                //Convert the Vector to an array for later use.
                _encodings = new EncodingProperties[ encodingList.size() ];
                encodingList.copyInto((Object[])_encodings);
            }
            catch (Exception e)
            {
                //Something is wrong, indicate that there are no encoding options.
                _encodings = null;
            }
        }
        protected  boolean keyDown(int keycode,
                               int time) {
            System.out.println("Input" + keycode + "/" + Keypad.key(keycode) + " C1 = " + Keypad.KEY_CONVENIENCE_1 +  " C2 = " + Keypad.KEY_CONVENIENCE_2);
            if ( Keypad.key(keycode) == Keypad.KEY_CONVENIENCE_1 ) {
                return true;
            }
            return super.keyDown(keycode, time);
        }
    
            protected  boolean keyChar(char c, int status, int time) {
                System.out.println("Input" + c + ":" + Keypad.getKeyCode(c, status));
                switch (c) {
                    case Characters.ESCAPE:
                        this.close();
                        return true;
                    default:
                        return super.keyChar(c, status, time);
                }
    
            }
    }
    

    Thanks for getting back to me.

    It turns out that it was only a problem on the Simulator. I managed to get my hands on a real device 9780 and the code works fine on it.

  • Linksys EA9500: FTP issues

    I recently bought and installed a Linksys EA9500 V1.1 running the latest version of the software package (1.1.6.173418).  Overall, the router performs as advertised with almost an improvement of the order of magnitude of speed on my previous router network.  However, it has some quirks that I can't work around.  With a bit of luck, I'm too stupid to configure the settings of the router correctly, but I suspect they are limits in firmware.

    Question No. 1: the FTP server cannot use TLS or SFTP; Passwords are sent in clear text over the internet

    When I try to connect to my router, either from the local network or remotely from the WAN IP address I am unable to connect with active TLS.  Therefore, the user name and password is sent by plain text that could be easily intercepted by someone using a packet sniffer.  This is not a big problem on the local network, but is a serious risk to security connecting from the internet.  At least with TLS, the communication should be encrypted, but it does not appear to be supported by the firmware. am I missing a setting somewhere?  In turn SFTP would work, but it doesn't seem to be an option to activate the SFTP, just a power switch for the FTP setting.  Is there a way to change the default 21 FTP server port to another arbitrary port?  This would at least make it a little less obvious to the casual observer.

    Question #2: FTP server cannot be restricted to the single LAN traffic

    It would bypass the first question I have a unix machine on the internal network that supports SSH and SFTP, and can get in the car to the routher via samba.  Port forwarding can redirect ports to that machine.  I have 4 network security cameras which internal download motion events via FTP on the network.  Through the firmware of the router I can only turn ftp 'on' or 'off' without additional control.  Is there a way to restrict FTP to only the LAN and preventing access over the WAN?

    Alternatively, is there any support for the DD - WRT firmware as with the WRT1900?

    Thank you

    Mike

    mcurtis wrote:

    I recently bought and installed a Linksys EA9500 V1.1 running the latest version of the software package (1.1.6.173418).  Overall, the router performs as advertised with almost an improvement of the order of magnitude of speed on my previous router network.  However, it has some quirks that I can't work around.  With a bit of luck, I'm too stupid to configure the settings of the router correctly, but I suspect they are limits in firmware.

    Question No. 1: the FTP server cannot use TLS or SFTP; Passwords are sent in clear text over the internet

    When I try to connect to my router, either from the local network or remotely from the WAN IP address I am unable to connect with active TLS.  Therefore, the user name and password is sent by plain text that could be easily intercepted by someone using a packet sniffer.  This is not a big problem on the local network, but is a serious risk to security connecting from the internet.  At least with TLS, the communication should be encrypted, but it does not appear to be supported by the firmware. am I missing a setting somewhere?  In turn SFTP would work, but it doesn't seem to be an option to activate the SFTP, just a power switch for the FTP setting.  Is there a way to change the default 21 FTP server port to another arbitrary port?  This would at least make it a little less obvious to the casual observer.

    Question #2: FTP server cannot be restricted to the single LAN traffic

    It would bypass the first question I have a unix machine on the internal network that supports SSH and SFTP, and can get in the car to the routher via samba.  Port forwarding can redirect ports to that machine.  I have 4 network security cameras which internal download motion events via FTP on the network.  Through the firmware of the router I can only turn ftp 'on' or 'off' without additional control.  Is there a way to restrict FTP to only the LAN and preventing access over the WAN?

    Alternatively, is there any support for the DD - WRT firmware as with the WRT1900?

    Thank you

    Mike

    Don't you did everything correctly. The points you mention are not part of the design of the Wifi chip. Without encryption of FTP or the Restriction on the ability of LAN.

    I have this will forward to the genius of Linksys as a feature request.

  • Add a keyListener to the BlackBerry e-mail client

    Hello

    I'm new to the BlackBerry Java development and found this forum really useful. The problem I am trying to solve is to hang a keyListener to the e-mail client BlackBerry existing (MessageApplication).  My request is a background process (run in the module of the system initially up). I was able to add a menu item for the e-mail client using the method ApplicationMenuItemRepository.getInstance (.addMenuItem) without problem. However, I had a hard time to install a keyListener to the MessageApplication, so that my partner can get called when the user clicks a certain key in the BlackBerry email client.

    I don't know if this is possible, but I guess that since we can connect the menu item, then we should be able to hang the keyListener as well. Please notify.

    Thanks in advance for your help.

    Chris

    This is not supported.  Applications can listen wheel/trackball/key events when they display in the foreground.

  • Detect click trackpad

    Hi, I detect a click on the touchscreen with TouchEvent.DOWN

    but is there a way to detect a trackpad/trackball click event?

    Thank you in advance!

    Too bad! I found the solution!

  • Overlap two images, ordinary java works, and not in BlackBerry JDE 5

    I have an application for swing of simple java that takes two images and overlaps the other. While trying to this port in JDE5, I got out there is no class BufferedImage in the api of BB, but a similar class of the Bitmap. It's brought to BB mixing function is unable to produce an image that overlap. It shows a blank white screen.

    Here's the plain java function

    public BufferedImage blend( BufferedImage bi1, BufferedImage bi2,            double weight )   {     if (bi1 == null)          throw new NullPointerException("bi1 is null");
    
          if (bi2 == null)          throw new NullPointerException("bi2 is null");
    
          int width = bi1.getWidth();       if (width != bi2.getWidth())          throw new IllegalArgumentException("widths not equal");
    
         int height = bi1.getHeight();     if (height != bi2.getHeight())
    
              throw new IllegalArgumentException("heights not equal");
    
            BufferedImage bi3 = new BufferedImage(width, height,              BufferedImage.TYPE_INT_RGB);      int[] rgbim1 = new int[width];        int[] rgbim2 = new int[width];        int[] rgbim3 = new int[width];
    
          for (int row = 0; row < height; row++)     {         bi1.getRGB(0, row, width, 1, rgbim1, 0, width);           bi2.getRGB(0, row, width, 1, rgbim2, 0, width);
    
             for (int col = 0; col < width; col++)          {             int rgb1 = rgbim1[col];               int r1 = (rgb1 >> 16) & 255;                int g1 = (rgb1 >> 8) & 255;             int b1 = rgb1 & 255;
    
                    int rgb2 = rgbim2[col];               int r2 = (rgb2 >> 16) & 255;                int g2 = (rgb2 >> 8) & 255;             int b2 = rgb2 & 255;
    
                    int r3 = (int) (r1 * weight + r2 * (1.0 - weight));               int g3 = (int) (g1 * weight + g2 * (1.0 - weight));               int b3 = (int) (b1 * weight + b2 * (1.0 - weight));               rgbim3[col] = (r3 << 16) | (g3 << 8) | b3;            }
    
               bi3.setRGB(0, row, width, 1, rgbim3, 0, width);       }
    
           return bi3;   } 
    

    Here's the java function of BB

      public Bitmap blend( Bitmap bi1, Bitmap  bi2,                      double weight )        {
    
                  if (bi1 == null)                       throw new NullPointerException("bi1 is null");
    
                    if (bi2 == null)                       throw new NullPointerException("bi2 is null");
    
                    int width = bi1.getWidth();            if (width != bi2.getWidth())                   throw new IllegalArgumentException("widths not equal");
    
                   int height = bi1.getHeight();          if (height != bi2.getHeight())
    
                            throw new IllegalArgumentException("heights not equal");
    
             Bitmap bi3 = new Bitmap(width, height);         int[] rgbim1 = new int[width];         int[] rgbim2 = new int[width];         int[] rgbim3 = new int[width];
    
                    for (int row = 0; row < height; row++)         {
    
                           bi1.getARGB(rgbim1,0,width,0,row, width,1);                       bi2.getARGB(rgbim2,0,width,0,row, width,1); 
    
                           for (int col = 0; col < width; col++)                  {                              int rgb1 = rgbim1[col];                                int r1 = (rgb1 >> 16) & 255;                           int g1 = (rgb1 >> 8) & 255;                            int b1 = rgb1 & 255;
    
                              int rgb2 = rgbim2[col];                                int r2 = (rgb2 >> 16) & 255;                           int g2 = (rgb2 >> 8) & 255;                            int b2 = rgb2 & 255;
    
                              int r3 = (int) (r1 * weight + r2 * (1.0 - weight));                            int g3 = (int) (g1 * weight + g2 * (1.0 - weight));                            int b3 = (int) (b1 * weight + b2 * (1.0 - weight));                            rgbim3[col] = (r3 << 16) | (g3 << 8) | b3;                     }
    
                         bi3.setARGB(rgbim3, 0, width, 0,  row,width, 1);
    
                    }
    
                 return bi3;    }
    

    The weight of the arg is a value from 1 to 100.

    For reference, the full plain java source

    /* * To change this template, choose Tools | Templates * and open the template in the editor. */
    
    package imagetest;
    
    /** * * @author COMPUTER */// Blender1.java
    
    import java.awt.*;import java.awt.image.*;
    
    import javax.swing.*;import javax.swing.event.*;
    
    /** * This class describes and contains the entry point to an application that * demonstrates the blending transition. */
    
    public class Blender1 extends JFrame{  /**    *     */   private static final long serialVersionUID = 1L;
    
        /**    * Construct Blender1 GUI.     */
    
     public Blender1() {     super("Blender #1");      setDefaultCloseOperation(EXIT_ON_CLOSE);
    
            // Load first image from JAR file and draw image into a buffered image.
    
         ImageIcon ii1 = new ImageIcon(getClass().getResource("x.png"));       final BufferedImage bi1;      bi1 = new BufferedImage(ii1.getIconWidth(), ii1.getIconHeight(),              BufferedImage.TYPE_INT_RGB);      Graphics2D g2d = bi1.createGraphics();        int h = ii1.getImage().getHeight(null);       System.out.println("Blender1.Blender1()--------> height :" + h);       g2d.drawImage(ii1.getImage(), 0, 0, null);        g2d.dispose();
    
          // Load second image from JAR file and draw image into a buffered image.
    
            ImageIcon ii2 = new ImageIcon(getClass().getResource("y.png"));       final BufferedImage bi2;      bi2 = new BufferedImage(ii2.getIconWidth(), ii2.getIconHeight(),              BufferedImage.TYPE_INT_RGB);      g2d = bi2.createGraphics();       int h2 = ii2.getImage().getHeight(null);      System.out.println("Blender1.Blender1()--------> height :" + h2);      g2d.drawImage(ii2.getImage(), 0, 0, null);        g2d.dispose();
    
          // Create an image panel capable of displaying entire image. The widths       // of both images and the heights of both images must be identical.
    
         final ImagePanel ip = new ImagePanel();       ip.setPreferredSize(new Dimension(ii1.getIconWidth(), ii1             .getIconHeight()));       getContentPane().add(ip, BorderLayout.NORTH);
    
           // Create a slider for selecting the blending percentage: 100% means      // show all of first image; 0% means show all of second image.
    
          final JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 100, 100);      slider.setMinorTickSpacing(5);        slider.setMajorTickSpacing(10);       slider.setPaintTicks(true);       slider.setPaintLabels(true);      slider.setLabelTable(slider.createStandardLabels(10));        slider.setInverted(true);     ChangeListener cl;        cl = new ChangeListener()     {         public void stateChanged( ChangeEvent e )         {             // Each time the user adjusts the slider, obtain the new              // blend percentage value and use it to blend the images.
    
                   int value = slider.getValue();                ip.setImage(blend(bi1, bi2, value / 100.0));          }     };        slider.addChangeListener(cl);     getContentPane().add(slider, BorderLayout.SOUTH);
    
           // Display the first image, which corresponds to a 100% blend     // percentage.
    
          ip.setImage(bi1);
    
           pack();       setVisible(true); }
    
       /**    * Blend the contents of two BufferedImages according to a specified weight.   *     * @param bi1  *            first BufferedImage  * @param bi2  *            second BufferedImage     * @param weight   *            the fractional percentage of the first image to keep     *     * @return new BufferedImage containing blended contents of BufferedImage  *         arguments   */
    
     public BufferedImage blend( BufferedImage bi1, BufferedImage bi2,         double weight )   {     if (bi1 == null)          throw new NullPointerException("bi1 is null");
    
          if (bi2 == null)          throw new NullPointerException("bi2 is null");
    
          int width = bi1.getWidth();       if (width != bi2.getWidth())          throw new IllegalArgumentException("widths not equal");
    
         int height = bi1.getHeight();     if (height != bi2.getHeight())
    
              throw new IllegalArgumentException("heights not equal");
    
            BufferedImage bi3 = new BufferedImage(width, height,              BufferedImage.TYPE_INT_RGB);      int[] rgbim1 = new int[width];        int[] rgbim2 = new int[width];        int[] rgbim3 = new int[width];
    
          for (int row = 0; row < height; row++)     {         bi1.getRGB(0, row, width, 1, rgbim1, 0, width);           bi2.getRGB(0, row, width, 1, rgbim2, 0, width);
    
             for (int col = 0; col < width; col++)          {             int rgb1 = rgbim1[col];               int r1 = (rgb1 >> 16) & 255;                int g1 = (rgb1 >> 8) & 255;             int b1 = rgb1 & 255;
    
                    int rgb2 = rgbim2[col];               int r2 = (rgb2 >> 16) & 255;                int g2 = (rgb2 >> 8) & 255;             int b2 = rgb2 & 255;
    
                    int r3 = (int) (r1 * weight + r2 * (1.0 - weight));               int g3 = (int) (g1 * weight + g2 * (1.0 - weight));               int b3 = (int) (b1 * weight + b2 * (1.0 - weight));               rgbim3[col] = (r3 << 16) | (g3 << 8) | b3;            }
    
               bi3.setRGB(0, row, width, 1, rgbim3, 0, width);       }
    
           return bi3;   }
    
       /**    * Application entry point.    *     * @param args     *            array of command-line arguments  */
    
     public static void main( String[] args )  {     Runnable r = new Runnable()       {         public void run()         {             // Create Blender1's GUI on the event-dispatching             // thread.
    
                  new Blender1();           }     };        EventQueue.invokeLater(r);    }}
    
    /** * This class describes a panel that displays a BufferedImage's contents. */
    
    class ImagePanel extends JPanel{ /**    *     */   private static final long serialVersionUID = 4977990666209629996L;    private BufferedImage bi;
    
       /**    * Specify and paint a new BufferedImage.  *     * @param bi   *            BufferedImage whose contents are to be painted   */
    
     void setImage( BufferedImage bi ) {     this.bi = bi;     repaint();    }
    
       /**    * Paint the image panel.  *     * @param g    *            graphics context used to paint the contents of the current   *            BufferedImage    */
    
     public void paintComponent( Graphics g )  {     if (bi != null)       {         Graphics2D g2d = (Graphics2D) g;          g2d.drawImage(bi, null, 0, 0);        } }}
    

    Full java BB source

    /* * ImageScreen.java * * © ,  * Confidential and proprietary. */
    
    package src;
    
    /** *  */
    
    import java.io.OutputStream;import javax.microedition.io.Connector;import javax.microedition.io.file.FileConnection;import net.rim.device.api.system.Bitmap;import net.rim.device.api.ui.Field;import net.rim.device.api.ui.FieldChangeListener;import net.rim.device.api.ui.UiApplication;import net.rim.device.api.ui.component.BitmapField;import net.rim.device.api.ui.component.ButtonField;import net.rim.device.api.ui.component.Dialog;import net.rim.device.api.ui.component.LabelField;import net.rim.device.api.ui.container.HorizontalFieldManager;import net.rim.device.api.ui.container.MainScreen;import net.rim.device.api.ui.component.GaugeField;/** * The main screen to display an image taken from the camera demo. */public final class ImageScreen extends MainScreen{    /** The down-scaling ratio applied to the snapshot Bitmap */    private static final int IMAGE_SCALING = 7;
    
        /** The base file name used to store pictures */    private static final String FILE_NAME = System.getProperty("fileconn.dir.photos") + "IMAGE";
    
        /** The extension of the pictures to be saved */    private static final String EXTENSION = ".bmp";
    
        /** A counter for the number of snapshots taken */    private static int _counter;    Bitmap image1,image2; BitmapField imageField;     /** A reference to the current screen for listeners */    private ImageScreen _imageScreen;
    
       /**    * Constructor    * @param raw A byte array representing an image    */    public ImageScreen( final byte[] raw1,final byte[] raw2 )    {        // A reference to this object, to be used in listeners        _imageScreen = this;
    
            setTitle("Blend and Save");
    
            // Convert the byte array to a Bitmap image        image1 = Bitmap.createBitmapFromBytes( raw1, 0, -1, 1 );        image2 = Bitmap.createBitmapFromBytes( raw2, 0, -1, 1 );        // Create two field managers to center the screen's contents        HorizontalFieldManager hfm1 = new HorizontalFieldManager( Field.FIELD_HCENTER );        HorizontalFieldManager hfm2 = new HorizontalFieldManager( Field.FIELD_HCENTER );        HorizontalFieldManager hfm3 = new HorizontalFieldManager( Field.FIELD_HCENTER );        // Create the field that contains the image//blend(image1, image2, 50/ 100.0)        imageField = new BitmapField(blend(image1, image2, 50/ 100.0) ){
    
               public int getPreferredWidth(){ return 250;}           public int getPreferredHeight(){ return 150;}
    
             };
    
            hfm1.add( imageField ); 
    
            GaugeField scroller = new GaugeField("Adjust (alt + < >)",0,100,50,Field.EDITABLE | Field.FOCUSABLE);        //scroller.setBackground( net.rim.device.api.ui.decor.BackgroundFactory.createSolidBackground(0x00000000));          scroller.setChangeListener( new GaugeFieldListener() );         hfm2.add(scroller);         // Create the SAVE button which returns the user to the main camera        // screen and saves the picture as a file.        ButtonField photoButton = new ButtonField( "Save" );        photoButton.setChangeListener( new SaveListener(raw1,raw2) );        hfm3.add(photoButton);
    
            // Create the CANCEL button which returns the user to the main camera        // screen without saving the picture.        ButtonField cancelButton = new ButtonField( "Cancel" );        cancelButton.setChangeListener( new CancelListener() );        hfm3.add(cancelButton);
    
            // Add the field managers to the screen        add( hfm1 );        add( hfm2 );        add( hfm3 );scroller.setFocus();//scroller.setValue(50);    }    public Bitmap blend( Bitmap bi1, Bitmap  bi2,                      double weight )        {
    
                  if (bi1 == null)                       throw new NullPointerException("bi1 is null");
    
                    if (bi2 == null)                       throw new NullPointerException("bi2 is null");
    
                    int width = bi1.getWidth();            if (width != bi2.getWidth())                   throw new IllegalArgumentException("widths not equal");
    
                   int height = bi1.getHeight();          if (height != bi2.getHeight())
    
                            throw new IllegalArgumentException("heights not equal");
    
             Bitmap bi3 = new Bitmap(width, height);         int[] rgbim1 = new int[width];         int[] rgbim2 = new int[width];         int[] rgbim3 = new int[width];
    
                    for (int row = 0; row < height; row++)         {            // bi -> int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize) 
    
                 // bit - > int[] argbData, int offset, int scanLength, int x, int y, int width, int height) 
    
                           bi1.getARGB(rgbim1,0,width,0,row, width,1);//  row, width, 1, , 0, width);                       bi2.getARGB(rgbim2,0,width,0,row, width,1); 
    
                           //bi1.getRGB(0, row, width, 1, rgbim1, 0, width);                       //bi2.getRGB(0, row, width, 1, rgbim2, 0, width);
    
                           for (int col = 0; col < width; col++)                  {                              int rgb1 = rgbim1[col];                                int r1 = (rgb1 >> 16) & 255;                           int g1 = (rgb1 >> 8) & 255;                            int b1 = rgb1 & 255;
    
                              int rgb2 = rgbim2[col];                                int r2 = (rgb2 >> 16) & 255;                           int g2 = (rgb2 >> 8) & 255;                            int b2 = rgb2 & 255;
    
                              int r3 = (int) (r1 * weight + r2 * (1.0 - weight));                            int g3 = (int) (g1 * weight + g2 * (1.0 - weight));                            int b3 = (int) (b1 * weight + b2 * (1.0 - weight));                            rgbim3[col] = (r3 << 16) | (g3 << 8) | b3;                     }                    //bi -> int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize)                     //bit -> (int[] data, int offset, int scanLength, int left, int top, int width, int height)                      bi3.setARGB(rgbim3, 0, width, 0,  row,width, 1);
    
                        // bi3.setRGB(0, row, width, 1, rgbim3, 0, width);                }
    
                 return bi3;    }
    
       /**    * Handles trackball click events    * @see net.rim.device.api.ui.Screen#invokeAction(int)    */       protected boolean invokeAction(int action)    {        boolean handled = super.invokeAction(action); 
    
            if(!handled)        {            switch(action)            {                case ACTION_INVOKE: // Trackball click.                {                                 return true;                }            }        }                return handled;              }
    
     /**    * A listener used for the "Save" button    */    private class GaugeFieldListener implements FieldChangeListener    {        public void fieldChanged(Field field, int context)        {          int value =  ((GaugeField)field).getValue(); if (value==0){return;}          imageField.setBitmap( blend(image1, image2, value/ 100.0) );          ((GaugeField)field).setLabel("Adjust (alt + < >)"+value);        }    }   /**    * A listener used for the "Save" button    */    private class SaveListener implements FieldChangeListener    {        /** A byte array representing an image */        private byte[] _raw1,_raw2;
    
           /**        * Constructor.        * @param raw A byte array representing an image        */        SaveListener(byte[] raw1,byte[] raw2)        {            _raw1 = raw1;            _raw2 = raw2;        }
    
           /**        * Saves the image as a file in the BlackBerry filesystem        */        public void fieldChanged(Field field, int context)        {            try            {                       // Create the connection to a file that may or                // may not exist.                FileConnection file = (FileConnection)Connector.open( FILE_NAME + _counter + EXTENSION );
    
                    // If the file exists, increment the counter until we find                // one that hasn't been created yet.                while( file.exists() )                {                    file.close();                    ++_counter;                    file = (FileConnection)Connector.open( FILE_NAME + _counter + EXTENSION );                }
    
                    // We know the file doesn't exist yet, so create it                file.create();
    
                    // Write the image to the file                OutputStream out = file.openOutputStream();                out.write(_raw1);
    
                    // Close the connections                out.close();                file.close();            }            catch(Exception e)            {                Dialog.alert( "ERROR " + e.getClass() + ":  " + e.getMessage() );            }
    
                // Inform the user where the file has been saved            Dialog.inform( "Saved to " + FILE_NAME + _counter + EXTENSION );
    
                // Increment the image counter            ++_counter;
    
                // Return to the main camera screen            UiApplication.getUiApplication().popScreen( _imageScreen );        }    }
    
       /**    * A listener used for the "Cancel" button    */    private class CancelListener implements FieldChangeListener    {       /**        * Return to the main camera screen        */        public void fieldChanged(Field field, int context)        {            UiApplication.getUiApplication().popScreen( _imageScreen );        }    }}
    

    Yes, your original code:

    for (int col = 0; col < width; col++){int rgb1 = rgbim1[col];int r1 = (rgb1 >> 16) & 255;int g1 = (rgb1 >> 8) & 255;int b1 = rgb1 & 255;
    
    int rgb2 = rgbim2[col];int r2 = (rgb2 >> 16) & 255;int g2 = (rgb2 >> 8) & 255;int b2 = rgb2 & 255;
    
    int r3 = (int) (r1 * weight + r2 * (1.0 - weight));int g3 = (int) (g1 * weight + g2 * (1.0 - weight));int b3 = (int) (b1 * weight + b2 * (1.0 - weight));rgbim3[col] = (r3 << 16) | (g3 << 8) | b3;}
    

    Labour Code:

    for (int col = 0; col < width; col++)
    {
    int rgb1 = rgbim1[col];
    int a1 = (rgb1 >> 24) & 255;
    int r1 = (rgb1 >> 16) & 255;
    int g1 = (rgb1 >> 8) & 255;
    int b1 = rgb1 & 255;
    
    int rgb2 = rgbim2[col];
    int a2 = (rgb2 >> 24) & 255;
    int r2 = (rgb2 >> 16) & 255;
    int g2 = (rgb2 >> 8) & 255;
    int b2 = rgb2 & 255;
    
    int a3 = (int) (a1 * weight + a2 * (1.0 - weight));
    int r3 = (int) (r1 * weight + r2 * (1.0 - weight));
    int g3 = (int) (g1 * weight + g2 * (1.0 - weight));
    int b3 = (int) (b1 * weight + b2 * (1.0 - weight));
    rgbim3[col] = (a3 << 24) | (r3 << 16) | (g3 << 8) | b3;
    }
    
  • MouseEvents or TouchEvents?

    Hey,.

    I just wanted to ask if you have used MouseEvents or TouchEvents.

    I used MouseEvents for my application I need a single touch point, Multitouch will be added later.

    He worked in the Simulator, I hope this works on the real device, but as far as I know the first TouchEvent also generates a MouseEvent.

    Hello

    on a mobile device, when you tap on the screen, you will receive two MouseEvents and TouchEvents for backward compatibility (using MouseEvents applications in their code). If you start coding, you always have the choice, you must use the TouchEvents instead of MouseEvents.

    Be careful with the. MOVE those who can carry a lot of overhead and spread too many times. Best thing to do is an event. ENTER_FRAME event listener and check the stage.mouseX / stage.mouseY properties. It's the thing more optimized to mobile for MOTION events.

  • Is it possible to listen to a motion tween and use an event handler to do something?

    I looked at a few tutorials Manager tween event but could not understand how to operate with the below. I copied the code in 'tween and paste it into a framework that presents an animated character. I want the character to run across the screen, and after the Tween is finished, I want to be able to jump to a different image.

    Thank you.

    [AS3]

    Import fl.motion.AnimatorFactory;
    Import fl.motion.MotionBase;
    Import fl.motion.Motion;
    flash.filters import. *;
    to import flash.geom.Point;
    var __motion_run:MotionBase;
    if(__motion_run == null) {}
    __motion_run = new Motion();
    __motion_run. Duration = 24;

    Call overrideTargetTransform to prevent scale, tilt,
    or values of rotation is made relative to the target
    transformation of the original object.
    __motion_run.overrideTargetTransform ();

    Subsequent calls to addPropertyArray assign data values
    for each property interpolated. There is only one value in the table
    for every frame of the tween, or less if the last value
    remains the same for the rest of the frames.
    __motion_run.addPropertyArray ('x', [0,14.7826,29.5652,44.3478,59.1304,73.913,88.6957,103.478,118.261,133.043,147.826,162.609, 177.391,192.174,206.957,221.739,236.522,251.304,266.087,280.87,295.652,310.435,325.217,34 0]);
    __motion_run.addPropertyArray ("y", [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);
    __motion_run.addPropertyArray ("scaleX", [1.000000]);
    __motion_run.addPropertyArray ("scaleY", [1.000000]);
    __motion_run.addPropertyArray ("Scewx", [0]);
    __motion_run.addPropertyArray ("transformations", [0]);
    __motion_run.addPropertyArray ("rotationConcat", [0]);
    __motion_run.addPropertyArray ("blendMode", "normal");
    __motion_run.addPropertyArray ("cacheAsBitmap", [false]);

    Create an AnimatorFactory instance, that will manage
    targets for the corresponding request.
    var __animFactory_run:AnimatorFactory = new AnimatorFactory (__motion_run);
    __animFactory_run.transformationPoint = new Point (0.500000, 0.500000);

    Call the function on the AnimatorFactory addTarget
    instance to target a DisplayObject with this Motion.
    The second parameter is the number of times where the animation
    going to play - the default value 0 means there will be a loop.
    __animFactory_run.addTarget (lancer, 1);
    }

    [/ AS3]

    You create an interpolation of manual editing and then copying the motion as AS3 code (which looks always a little weird, compared to your animation with AS3 from scratch with Adobe fl.transition package, or greensock TweenLite, or any other 3rd party tyween engine of coding). And I presume that eager to customize it with a completion event detection.

    First, familiarize yourself with the AS3 package that defines such things when you use Flash to convert your tweens as code:

    Package: fl.motion

    http://livedocs.Adobe.com/Flash/9.0/ActionScriptLangRefV3/FL/motion/package-detail.html

    Here you will see classes in this package. And there is an interested, MotionEvent.

    MotionEvent

    http://livedocs.Adobe.com/Flash/9.0/ActionScriptLangRefV3/FL/motion/MotionEvent.html

    Right at the top of this page is an example of adding an event listener, which I'll paste here...

    import fl.motion.MotionEvent;
    abox_animator.addEventListener(MotionEvent.MOTION_END, afterMotion);
    function afterMotion(e:MotionEvent) {
       trace("animation complete!");
    }
    

    CS4/CS5 names your class objects of movement as "__motion_SymbolName". In your case, it is __motion_run. As above, to add the event to your object, follow these steps:

    import fl.motion.MotionEvent;
    
    __motion_run.addEventListener(MotionEvent.MOTION_END, afterMotion);
    function afterMotion(e:MotionEvent) {
       trace("animation complete!");
    }
    

    If you're curious about making all your animation from scratch using the code, I highly suggest to check greensock Tween engine:

    http://www.greensock.com/

  • On the motion tween event listener

    Hi all

    I have worked with Flasg CS4 HAVE 3.0 for a few weeks now, and I touched something that left me open-mouthed all by building a portfolio site.

    Staging:

    In order to maintain the low initial file size, I currently use UILoaders to control the content that is currently viewing.  I have five total UILoaders that change the source in that based on what the user clicks on the button.  Each UILoader is nested inside two clips so that I can control the transition animations and so they do not overlap.   Example:

    I.Index/Stage

    A.Parent Movie Clip

    1. nested Movie Clip with custom entering and leaving the motion tweens on the UILoader child.

    a. UILoader

    So far, I was able to use the buttons on the main to shoot to the top of the UILoaders eco-friendly stage.  When you click a button, an event listener calls the UILoader, sets its source and anime 'in' thanks to its parent movie clip.  When you click a different button to replace the source of the UILoader, the original source is anime 'out' with the same parent movie clip.

    Here's the problem:

    I can't understand how to change the source of the UILoader that after the custom motion tween is completed.  I know how to configure a listener of events on each button to change the source of its respectful UILoader, but I need the animation 'out' motion tween to complete to the UILoader before the new source is caught.

    It seems to me that there should be an event listener to attach to button, listen to an interpolation of specific movement at the end and attach a function to change the source of the UILoader only at this time there.

    Here's a sample script that toggles the IULoader source:

    content_mc.profile_btn.addEventListener (MouseEvent.CLICK, profileClick);


    function profileClick(e:MouseEvent):void {}
    profile_mc.profile_mc.profileLoader.source = "Profile.swf";
    profile_mc.gotoAndPlay ("Enter");
    }

    content_mc.work_btn.addEventListener (MouseEvent.CLICK, workClick);

    function workClick(e:MouseEvent):void {}
    profile_mc.gotoAndPlay ("Exit");
    }

    Any ideas?

    I would really appreciate it.

    Yes, you might have a function coded everywhere where he would be executed better and you could call this function at the end of the Tween.  If interpolation is inside a movieclip, then you can precede the function call with MovieClip (parent).  or MovieClip (root).  Depending on how deep you are on children...

    MovieClip (parent) .callFunction ();

    You can also assign an event listener personalized to the movieclip that listen to the parents.  At the end of the Tween in the mc, you might have...

    dispatchEvent (new Event ("imDone"));

    In your parent assign you a listener for the event to the mc.

    youTweeningMC. addEventListener ("imDone", eventHandler);

    function eventHandler(event:Event):void {}
    Regardless of your intentions
    }

  • AVT Guppy 033 B device is the same image twice on the &lt; Session Out &gt; event: Frame made

    Sometimes the event gets the same image twice, but with an increase, correct the image of the index (see photo index 125, 126).

    We use a type AVT Guppy 033 B firewire camera to measure the distance between plants. The camera fires all 40mm the breakpoint of the NI7344 of motion control output.

    We work with the latest Labview and Vision version 8.6.1 could the firewire driver cause this problem. We use the original driver

    Microsoft XP, SP3. Should install us the driver of the TRA instead, other suggestions?

    Thanks for any help.

    Syn66,

    Looks like your code without taking into account the fact that the Images are passed by reference. It seems that you still spend the same image GetImage and then put it in your queue. Each iteration you will be overwrite the content of the image of the singular and all the elements in the queue is pointing to the same data of the image.

    If you want to structure your code like this, you'll probably want to create an image of each iteration of the loop, call GetImage use it and then put it in the queue. When you treat it and get out of the queue, you can then destroy it. You can optimize the image allocate/free sentence (which may or may not be meaningful) with a strategy of ping-pong by having a separate queue images empty and then you delete the images of this queue empty, GetImage to use and place it in your existing queue of images to process. After the treatment, instead of simply releasing them you would put them back in the empty queue.

    Hope this helps,
    Eric

  • No response to the events of the cluster.

    Hi all

    I am preparing for the CLD and find a problem with the exercise of ATM Simulator as shown in the attached file.

    Please follow the below steps to reproduce this problem.

    1 extract the files.

    2. open atm.lvproj, and then run main.vi.

    3 press card Simulator to enable user input.

    4. put 12345 in user input, and then press ENTER.

    5. left and right menu will display its function and you should be able to press the left and right, but they have no answer to your intervention.

    If you have an idea, please share it with goodness.

    Please note that I use LV2010, but I'm going down my code to 8.5 so that we can share more.

    Sincerely, Kate

    There are serious problems with dataflow doe to wrong choice of program design.

    You shouldn't ever have event inside the strctures case structures, especially structures event, each in a situation different from the structure of the case. Event structures are not dataflow leads, so they queue of events even if there is now way to the service of the event due to issues of data flow. Your events are defined to lock the front until the end of the event, so any event that cannot be handled by the program crashes to the top of the façade for ever.

    So: Get rid of the box structure and use a structure of single event with several instances of the event. That should be all you need. The structure of the event should be directly on the diagram of the while loop. Simplify! Put your business structure housing unique timeout and modulate the duration of the time-out period by an if necessary shift register.

    A good tool is also highlighted. Use the VI while looking at the chart in Slow Motion. You'll see where it gets stuck.

  • Distinguish the wheel trackball click OS v4.1

    I wish that my application for manage easily clicks trackball on devices, which provide a special touch to access the menu.  However, I still work on older devices on wheel, which is not a separate menu key.

    To this end, I noticed that I can start by replacing the Screen.trackwheelClick () method.  However, I would like to find a way to tell the difference between the wheel and trackball clicks and do not use magic numbers in my code.

    My own quick test found that the status of trackwheelClick() parameter is different on the two types of devices.  With a 7100t (wheel), its "17039360" and with an 8820 (ball), his "536870912.  If I converted to binary, the two following numbers look quite clean.  However, I prefer to use constant official APIs for my checks in trackwheelClick().

    Any recommendations?

    Hello

    The substitution of Screen.trackwheelClick () is not recommended for various reasons, including the fact that it can be called internally by other events such as the invocation of the menu buttons, etc.

    An elegant way to support/differentiate wheel vs. use of the trackball with a unique construction is to check the instance of the Screen.onMenu () event parameter. On a trackball device this value will be 65536 when it is clicked on the trackball or 1073741824 when the button main menu is used (default = 0 for devices on the wheel). So, you can implement your logic as below. This also has the effect that the menu will also be displayed in the correct location on the display depending on whether you click the main menu button (menu left) vs trackball (context menu, at the bottom) or menu knob (in the top right menu). You can of course replace one of these to the capture and the action just click (by wheel or trackball).

    private final static int MENU_CONTEXT = 65536;
    private final static int MENU_MAIN = 1073741824;
    
    public boolean onMenu(int instance)
    {
         if (instance == MENU_MAIN) //main menu button pressed, display menu bottom left
         {
              super.onMenu(instance);
              return false;
         }
         else if (instance == MENU_CONTEXT) //trackball click (context menu, display bottom) - override here
         {
                return openItem();
         }
         else //trackwheel click, display main menu top right (or override if required)
         {
              super.onMenu(instance);
              return false;
         }
    }
    

    Hope that helps,

    James

Maybe you are looking for