Animation LabelField

Y at - he wants an easy way to create a LabelFiled with sliding effect of the text - the text drag from left to right. I want to use this approach to show longer texts in a single line label field.

Instead of using setText, just invalidate the Timer field.  Then replace the painting field on the label and drawText in there.

You can certainly use the approach of 1 more character at a time.  But I think that if you wanted to move a number of pixels, then you place just 'x' position - ve, and the text will be drawn out of the screen and will not display until a pixel on the screen is written to.  Sure it will work, but I have never tested.

Another option is to put text in a scrolling HorizontalFieldManager and parchment, Manager of the programmer

And still another option is to write the text in a bitmap, and then, in the paint, move the window that opens along the Bitmap.

But the lowest impact, so more likely to do better, approach the painting/drawText method I described first - give that a try and let us know how you go.

Tags: BlackBerry Developers

Similar Questions

  • animated GIF not showing do not adequately

    I have an animated gif image, and I used http://supportforums.blackberry.com/t5/Java-Development/Display-an-animated-GIF/ta-p/445014 this link to animate the noise towards the top of the screen and that did not work properly

    You can see the animation below

    public class UpdatePopScreen extends PopupScreen{
    
            public UpdatePopScreen(){
                 super(new VerticalFieldManager(), Screen.DEFAULT_CLOSE); 
    
                 GIFEncodedImage ourAnimation = (GIFEncodedImage) GIFEncodedImage.getEncodedImageResource("sunblackk.gif");
                AnimatedGIFField _ourAnimation = new AnimatedGIFField(ourAnimation, Field.FIELD_HCENTER);
    
                this.add(_ourAnimation);
               add(new LabelField("Loading..."));
    
        }         
    
        }
    

    and I have attached AnimatedGIFField.java

    I think something is wrong in your establishment or the way you use this code, because it works very well for me.  Sorry you'll have to do investigative work to identify the problem.

    I suspect there are two possibilities:

    (a) you have not configured your environment properly

    (b) you use something else keeps track of events

    I think that (b) is the most likely, but to test these two at the same time, you must proceed as follows:

    Create a new project and a new example application, then, in this application, test the screen.  Nothing else in this project - it should start just a screen, the screen should have a button, when you click the button the treatment should push the pop-up screen.

    I have included my code (which combines Animation and popup screen into one file - not recommended but useful source under test).  Use this code and the image as an attachment in your new project.

    Test it on your Simulator.

    Assuming that you can get this working, then we can investigate on what is actually wrong in your application.

    package mypackage;
    
    import net.rim.device.api.system.GIFEncodedImage;
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.Graphics;
    import net.rim.device.api.ui.Screen;
    import net.rim.device.api.ui.UiApplication;
    import net.rim.device.api.ui.component.BitmapField;
    import net.rim.device.api.ui.component.LabelField;
    import net.rim.device.api.ui.container.PopupScreen;
    import net.rim.device.api.ui.container.VerticalFieldManager;
    
    public class UpdatePopScreen extends PopupScreen {
        public UpdatePopScreen(){
    
             super(new VerticalFieldManager(), Screen.DEFAULT_CLOSE); 
    
             GIFEncodedImage ourAnimation = (GIFEncodedImage) GIFEncodedImage.getEncodedImageResource("animated.agif");
            AnimatedGIFField _ourAnimation = new AnimatedGIFField(ourAnimation, Field.FIELD_HCENTER);
    
            this.add(_ourAnimation);
            add(new LabelField("Loading..."));
    
        }
    }
    
    class AnimatedGIFField extends BitmapField
    {
        private GIFEncodedImage _image;     //The image to draw.
        private int _currentFrame;          //The current frame in the animation sequence.
        private AnimatorThread _animatorThread;
    
        public AnimatedGIFField(GIFEncodedImage image)
        {
            this(image, 0);
        }
    
        public AnimatedGIFField(GIFEncodedImage image, long style)
        {
            //Call super to setup the field with the specified style.
            //The image is passed in as well for the field to configure its required size.
            super(image.getBitmap(), style);
    
            //Store the image and it's dimensions.
            _image = image;
    
            //Start the animation thread.
            _animatorThread = new AnimatorThread(this);
            _animatorThread.start();
        }
    
        protected void paint(Graphics graphics)
        {
            //Call super.paint.  This will draw the first background frame and handle any required focus drawing.
            super.paint(graphics);
    
            //Don't redraw the background if this is the first frame.
            if (_currentFrame != 0)
            {
                //Draw the animation frame.
                graphics.drawImage(_image.getFrameLeft(_currentFrame), _image.getFrameTop(_currentFrame),  _image.getFrameWidth(_currentFrame)
                                    , _image.getFrameHeight(_currentFrame), _image, _currentFrame, 0, 0);
            }
        }
    
        //Stop the animation thread when the screen the field is on is
        //popped off of the display stack.
        protected void onUndisplay()
        {
            _animatorThread.stop();
            super.onUndisplay();
        }
    
        //A thread to handle the animation.
        private class AnimatorThread extends Thread
        {
            private AnimatedGIFField _theField;
            private boolean _keepGoing = true;
            private int _totalFrames;               //The total number of frames in the image.
            private int _loopCount;                 //The number of times the animation has looped (completed).
            private int _totalLoops;                //The number of times the animation should loop (set in the image).
    
            public AnimatorThread(AnimatedGIFField theField)
            {
                _theField = theField;
                _totalFrames = _image.getFrameCount();
                _totalLoops = _image.getIterations();
    
            }
    
            public synchronized void stop()
            {
                _keepGoing = false;
            }
    
            public void run()
            {
                while(_keepGoing)
                {
                    //Invalidate the field so that it is redrawn.
                    UiApplication.getUiApplication().invokeAndWait(new Runnable()
                    {
                        public void run()
                        {
                            _theField.invalidate();
                        }
                    });                
    
                   try
                    {
                        //Sleep for the current frame delay before the next frame is drawn.
                        sleep(_image.getFrameDelay(_currentFrame) * 10);
                    }
                    catch (InterruptedException iex)
                    {
    
                    } //Couldn't sleep.
    
                    //Increment the frame.
                    ++_currentFrame;      
    
                    if (_currentFrame == _totalFrames)
                    {
                        //Reset back to frame 0 if we have reached the end.
                        _currentFrame = 0;
    
                        ++_loopCount;
    
                        //Check if the animation should continue.
                        if (_loopCount == _totalLoops)
                        {
                            _keepGoing = false;
                        }
                    }
                }
            }
        }
    }
    
  • Animation in a manager need to

    Hi all

    I want to give the animation in a Manager. I have a list, while clicking on the first line of this list it will add more than 3 lines below that, and when I click again in the same line that will remove these lines. I do that by addind and removing the Manager but I want to give the animation while addind or removing the Manager!

    Please suggest!

    Hi shivam.

    I got this code somewhere and I managed to change the code for the handler.
    Hope that this code will be useful for you...

    TestScreen.java

    package com.animationtest;
    
    import net.rim.device.api.ui.component.ButtonField;
    import net.rim.device.api.ui.component.LabelField;
    import net.rim.device.api.ui.component.NullField;
    import net.rim.device.api.ui.container.MainScreen;
    import net.rim.device.api.ui.container.VerticalFieldManager;
    
    public class TestScreen extends MainScreen {
        private AnimatedManager _manager1,_manager2;
    
        public TestScreen() {
    
            VerticalFieldManager vfm =new VerticalFieldManager();
            vfm.add(new LabelField("labelField 1"));
            vfm.add(new ButtonField("buttonField 1"));
            vfm.add(new LabelField("labelField 2"));
            vfm.add(new ButtonField("buttonField 2"));
    
            _manager1=new AnimatedManager(vfm,true);
            add(_manager1);
    
            VerticalFieldManager vfm2 =new VerticalFieldManager();
            vfm2.add(new LabelField("labelField 3"));
            vfm2.add(new ButtonField("buttonField 3"));
            vfm2.add(new LabelField("labelField 4"));
            vfm2.add(new ButtonField("buttonField 4"));
    
            _manager2=new AnimatedManager(vfm2,false);
            add(_manager2);
        }
    
        protected void onUiEngineAttached(boolean attached) {
            super.onUiEngineAttached(attached);
    
            if (attached) {
                _manager1.startAnimation();
                _manager2.startAnimation();
            }
        }
    }
    

    AnimatedManager.java

    package com.animationtest;
    
    import net.rim.device.api.system.Application;
    import net.rim.device.api.system.Display;
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.Manager;
    
    import com.animationtest.Animation.AnimationListener;
    
    public class AnimatedManager extends Manager implements AnimationListener {
        private final Animation _animation;
        private final int _duration = 1000;
        private boolean isFromTop;
        private volatile boolean _isAnimating;
    
        private Manager _field = new Manager(FIELD_HCENTER) {
            protected void sublayout(int width, int height) {
                setExtent(getPreferredWidth(), getPreferredHeight());
            }
        };
    
        private AnimatedField leftToRightAnimationManager = new AnimatedField() {
    
            private final int _sx = - Display.getWidth();
            private final Point _pos = new Point(_sx, 0);
            private final Point _dest = new Point(0 , 0);
    
            public void setField(Manager _manager) {
                _field=_manager;
            }
    
            public Point getCurrentPosition() {
                return _pos;
            }
    
            public Field getField() {
                return _field;
            }
    
            public void updatePosition(int time, int duration) {
                _pos.x = _sx + (_dest.x - _sx) * time / duration;
            }
        };
    
        private AnimatedField topToBottomAnimationManager = new AnimatedField() {
    
            private final int _sy = - Display.getHeight();
            private final Point _pos = new Point(0,_sy);
            private final Point _dest = new Point(0, 0);
    
            public void setField(Manager _manager) {
                _field=_manager;
            }
    
            public Point getCurrentPosition() {
                return _pos;
            }
            public Field getField() {
                return _field;
            }
            public void updatePosition(int time, int duration) {
                _pos.y = _sy + (_dest.y - _sy)  * time / duration;
            }
        };
    
        public AnimatedManager(Manager _manage, boolean _isFromTop) {
            super(USE_ALL_HEIGHT | USE_ALL_WIDTH);
            isFromTop=_isFromTop;
            _animation = new Animation(_duration);
            _animation.setListener(this);
    
            if(isFromTop){
                topToBottomAnimationManager.setField(_manage);
                add(topToBottomAnimationManager.getField());
            }
            else{
                leftToRightAnimationManager.setField(_manage);
                add(leftToRightAnimationManager.getField());
            }
        }
    
        public void startAnimation() {
            _isAnimating = true;
            _animation.start();
        }
    
        protected void sublayout(int maxwidth, int maxheight) {
            final int width = _field.getPreferredWidth();
            final int height = _field.getPreferredHeight();
            if(isFromTop)
                updateAnimation(topToBottomAnimationManager);
            else
                updateAnimation(leftToRightAnimationManager);
    
            setExtent(width, height);
        }
    
        private void updateAnimation(AnimatedField af) {
            Field f = af.getField();
            final int width = f.getPreferredWidth();
            final int height = f.getPreferredHeight();
    
            if (!_isAnimating) layoutChild(f, width, height);
            setPositionChild(f, af.getCurrentPosition().x, af.getCurrentPosition().y);
        }
    
        public int getPreferredHeight() {
            return _field.getPreferredHeight();
        }
    
        public int getPreferredWidth() {
            return _field.getPreferredWidth();
        }
    
        public void onNewFrame(int time) {
            if(isFromTop)
                topToBottomAnimationManager.updatePosition(time, _duration);
            else
                leftToRightAnimationManager.updatePosition(time, _duration);
            synchronized(Application.getEventLock()) {
                updateLayout();
                _isAnimating = time == _duration;
            }
        }
    }
    

    Animation.Java

    package com.animationtest;
    
    public class Animation {
        public static interface AnimationListener {
            void onNewFrame(int time);
        }
    
        private static final int DEFAULT_FPS = 40;
    
        private int _duration;
        private int _time;
        private int _fps = DEFAULT_FPS;
        private Thread _thread;
        private volatile boolean _running;
    
        private AnimationListener _listener;
    
        public Animation(int duration) {
            _duration = duration;
        }
    
        public void setFPS(int fps) {
            _fps = fps;
        }
    
        public int getFPS() {
            return _fps;
        }
    
        public void setDuration(int duration) {
            _duration = duration;
        }
    
        public int getDuration() {
            return _duration;
        }
    
        public int getTimeElapsed() {
            return _time;
        }
    
        public void setListener(AnimationListener l) {
            _listener = l;
        }
    
        public synchronized void start() {
            if (_thread == null) {
                _running = true;
                _thread = new Thread(new Runnable() {
                    public void run() {
    
                        final int idleTime = (1000 / _fps * 10 + 10) / 10;
                        final int duration = _duration;
                        _time = 0;
    
                        try {
                            while(_running && _time <= duration) {
                                animate(_time);
                                _time += idleTime;
    
                                Thread.sleep(idleTime);
                            }
    
                            if (_time - idleTime < duration) animate(duration);
    
                        } catch (InterruptedException e) {}
    
                        stop();
                    }
                });
    
                _thread.start();
            }
        }
    
        public synchronized void stop() {
    
            _running = false;
    
            if (_thread != null && _thread.isAlive()) {
                _thread.interrupt();
                _thread = null;
            }
        }
    
        private void animate(int time) {
            AnimationListener listener = _listener;
            if (listener != null) {
                listener.onNewFrame(time);
            }
    
        }
    }
    

    AnimatedField.java

    package com.animationtest;
    
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.Manager;
    
    public interface AnimatedField {
    
        Field getField();
    
        void setField(Manager _manager);
    
        void updatePosition(int time, int duration);
    
        Point getCurrentPosition();
    }
    

    Point.Java

    package com.animationtest;
    
    public final class Point {
        public int x, y;
    
        public Point(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }
    
  • Loading screen is not animated, during the operation, but after

    Hi all!

    Here's my problem: I am display a gif animated using the class presented here.

    It is used in a specific class loader that perform an action, while the gif is displayed (the gif is a spinner). Only once the operation is completed, the LoadingScreen came out of the screen.

    Here's my class loader:

    public class LoadingScreen extends MainScreen {
    
        /**
         * The action to be processed during the loading.
         */
        Runnable action = null;
    
        private AnimatedGIFField _image;
    
        /**
         * Default constructor.
         *
         * @param action the action to manage.
         */
        public LoadingScreen(Runnable action)
        {
            super(FIELD_VCENTER);
            this.setTitle(CommonTools.initTitleBar());
            this.action = action;
    
            displayAnimation();
    
            if(this.action != null)
            {
                UiApplication.getUiApplication().invokeLater(this.action);
            }
        }
    
        /**
         * Display the animation during the loading process.
         */
        private void displayAnimation()
        {
            EncodedImage encImg =
                GIFEncodedImage.getEncodedImageResource("loading.gif");
            GIFEncodedImage img = (GIFEncodedImage) encImg;
    
            _image = new AnimatedGIFField(img);
    
            getMainManager().setBackground(BackgroundFactory.createSolidBackground(Color.BLACK));
    
            LabelField label = new LabelField("Connect..."){
                public void paint(Graphics g)
                {
                    g.setColor(Color.WHITE);
                    super.paint(g);
                    }
            };
    
            HorizontalFieldManager containerSpin = new HorizontalFieldManager(FIELD_HCENTER);
            HorizontalFieldManager containerLabel = new HorizontalFieldManager(FIELD_HCENTER);
            containerSpin.add(_image);
            containerLabel.add(label);
    
            containerSpin.setPadding(Display.getHeight()>>2, 0, 0, 0);
    
            this.add(containerSpin);
            this.add(containerLabel);
    
            KasualApplication.isLoading = true;
        }
    }
    

    The problem is that the gif is not animated, while the action runs. But if I have a popup appears at the end of the action to let the loading screen, I see that the gif is animated. As well as the animation starts when the action is complete.

    I think something is wrong in the clock of my son, but I don't see that.

    Could you please help me?

    Thanks in advance.

    It's ok, the solution is described here.

  • How to make animated gifs to work in FCPX?

    Hello

    How to make animated gifs to work in FCPX?

    They work in FCP7 (FCS) but not FCPX. Strange.

    assailed

    Elmer

    If you had FCP7, you have Quicktime 7 Pro (upgraded automatically at installation FCP7). Check your Applications > Utilities folder.

    Open the gif in QT7 and export as... (Sequence Quicktime Movie > Open Options)... might as well go with ProRes LT and make sure that you pay attention to the size option (select current if the original is 100%).

  • Animation switching Office issues

    Does anyone else know a different animation in the Yosemite Sierra? Switching between desktop computers, the files animate as well and will be geek sometimes. Just curious, if it is a bug. I also have problems with the desktop image not resizing not between my Apple screen and the laptop, but one thing at a time. Thank you!

    Link to screenshot: https://www.dropbox.com/s/tl2bb1el5p4trs7/Full%20Screen%20Switching.mov?dl=0

    Hello SixThreeThree,

    Welcome to Apple Support communities. I see your message and your video as the glitch icons visually in the transition from desktop computers. I know it shouldn't. I'll be more than happy to help.

    Since it is a Visual problem, I recommend you to reset the NVRAM. This is the temporary video memory. Instructions that are below:

    How to reset the NVRAM on your Mac - Apple Support

    Once done, test to see if it happens again. If so, it wouldn't hurt to test this question on a new user. Take a look at this article:

    How to test a question in another account on your Mac - Apple Support

    Take care!

  • Old iPhone users - Animations in text?

    Just out of curiosity, older models of iPhone users can do the new animations and writing in the text? Also, if they update iOS can they see how iPhone users 7 may?

    I think that all 10 iOS devices support touch digital.

    Use number key on your iPhone, iPad and iPod touch - Apple Support

  • I have iOS 10 and I am still unable to make messages with animation effects. How can I solve this problem?

    I have iOS 10 and I am still unable to make messages with animation effects. How can I solve this problem?

    Without knowing what is happening when you try, it is difficult to recommend troubleshooting. However, one of the first steps is to ensure that you don't have to reduce the Motion activated in accessibility.

  • Why am I unable to send animation effects when I press and hold send key

    I have the ios10 update on my phone but when I hold down the Send button to add animations, little option to choose what I want will not appear in my messages nor can I receive the animation when someone sends me

    Disable the reduced movement.

    Settings > general > accessibility > reduce motion > [disable]

  • iPhone 7 slower Animations &amp; Chop?

    I use an iPhone 7, coming of the 6 s. I noticed that when an application is closed, there is a stutter that occurs about 80% of the time when you return to the home screen. On the 6s is one, smooth animation. I even recorded two screens in slow motion to make sure I wasn't crazy, and of course, the iPhone 7 stops just after that starts the animation. In addition, I noticed that using the task on the iPhone switch 7 is rougher. Even more, I noticed that unity apps are much more turbulent and unstable on the iPhone 7 when they are smooth as silk on the 6s. Has anyone else noticed similar experiences? I noticed lag on iPhone Home screen a friend 7 at work, and I've seen other people mention the same thing. I just want to get this out there while Apple is aware. (If they are not already.) And, Yes, I already wrote a request for feedback. Just want to get more visibility in the present, or if someone has found solutions.

    We could do with as many people as possible put your comments in on this one. I was in the Apple Store the other day, trying to attract the attention of the assistant to this problem; He couldn't see it. I know I'm picky, but I can really see it.

    The only solution I've seen involves reducing transparency and movement in accessibility options. They have some workarounds, however.

  • View seeks to create graphic animations in the videos, the FCPX is capable?

    Hello useful community! A two-part question.

    I'm just getting started on the video production and have some needs in mind. I hope you can let me know if FCPX can do that hopefully, if there is an obvious solution, I am missing, or some of you approach use.

    I'll be doing a few videos of interview style and will have several camera angles, with that I need to work. So if I understand correctly to work with iMovie, I'll have a main video timeline and then 'cut' in and out secondary structures for the other angles. But I must have a logo sitting in the corner as well. Is there still enough chronologies to cut in different camera angles while having a timeline showing the stationary chart? iMovie does not you have only your primary and another calendar cut in and out, but I hope that FCPX has the ability to overlay 2 more than at a time? Or maybe I'm going about this the wrong way need?

    The second part is linked, I want to be the logo/text animation because it is (as a brief introduction). Not throughout the entire video or something extremely complex, but to animate shapes and text sliding in such that the name of the speaker, the name of show graphics, etc... And I'm hoping to create my own custom animations, not the familiar "motions of text" located in iMovie. I feel like the examples I found online that all look like they have animations the same model and I hope for much more creative in this area occasionally, if that makes sense. In its most simple example I guess, the design and animation capabilities/techniques you can do in Keynote for graphics/text that can be market timed, fades, slides, etc.

    Is FCPX the right program to incorporate more complex forms of text animations as well? Or is it the work of another software?

    I hope that makes sense. Any help is appreciated, thanks!

    Mark

    TYou can have an unlimited number of video layers.

    Yes, you can make custom animations. For more complex animations, you use Motion.

  • shift iPhone animation 7...

    Just took my 7 32 GB iPhone... Noticed a lagg when opening and closing an application for the first time.

    When I press the home button and reopen all the app goes smooth...
    Already talked to Apple support, they suggested to restore to the factory with IOS 10.0.1 and does not restore any backups.
    Just did that, still lagg...  Little disappointed, my iPhone 6 is smoother...

    Someone else this issue? Must be! Check it out really well, I think that this is gonne be reported a lot!

    I have a similar but slightly different problem on my iPhone 7. Every time I close an app, the animation lags badly and it's annoying. All other animations, including the opening animation app, are very good. I have initially restored from a backup, but I tried to restore normal settings, and it made no difference. My iPhone 5 has no problem of lag during the opening and closing of 10 iOS apps.

  • The animation is pixelated when exporting

    Hi all, I am a novice user FCPX and I just edited a 6 minute together animation.

    I exported using the following parameters, but the quality is very bad. I'm doing something wrong here?

    It does not take that long to make which makes me wonder if it is compressing somehow?

    This seems OK, but can not say without seeing the original exit or what you do. How to watch videos within FCP?

  • Kanji animation does not

    The site is http://www.csse.monash.edu.au/~jwb/cgi-bin/wwwjdic.cgi?
    (They also have alternative URLS but the animation doesn't always work.)

    An example would be http://www.csse.monash.edu.au/~jwb/cgi-bin/wwwjdic.cgi?163568_%C5%EC

    I use Windows 7 Pro. Firefox 38.0.5. (Everything worked fine before this last update).
    Not this problem when I use Google Chrome.
    I disabled all the modules etc. Closed and restarted Windows 7 several times.
    Nothing helps. I install a fresh copy full of FF 38.0.5 on a new folder with the new name, but it has integrated all the old content. I guess you should completely remove the existing copy and then manually insert inserts the bookmarks, modules etc. from recorded files. Too risky and complicated for this old geezer.

    Any ideas on how to solve this problem? Much obliged.

    Make sure the image.animation_mode pref isn't the value none, but at least once or normal.

    You can open the topic: config page via the address bar.
    You can accept the warning and click on "I'll be careful" to continue.

  • composite reflectivity loop (animated weather radar image) does not work in Firefox.

    Just switched from XP to Windows 7 Pro. Installed Firefox. When you try to view a loop of composite reflectivity (animated weather radar image) on the site of the National Weather Service, I get an error message that a plug-in is missing, but no further details.

    Thank you

    Ed

    These are the most common in Firefox you can try:

    Update your plugins to the latest version. Make sure you are aware:

    If you see problems see also:

Maybe you are looking for