Swapping Components with Fade Transition

Hey,
There are many places in my application where I swap one component out for another one. I was trying to achieve a fade transition instead of just having the new component appear. I got it working, but it is very slow. Any ideas of how to get up the FPS?
Whenever I want to transition the content into the container, I create a new SwappableComponent with the two arguments.
Thanks!
private static class SwappableComponent extends JPanel {
          private static final float[] scales = { 1f, 1f, 1f, 0.5f };
          private static final float[] offsets = new float[4];
          private static final int TRANSITION_TIME = 1000;
          private final int w, h;
          private final JComponent container, content;
          private BufferedImage fromImage, toImage, currentImage;
          private long start = System.currentTimeMillis();
          private boolean finished = false;
          public SwappableComponent(JComponent container, JComponent content) {
               this.container = container;
               this.content = content;
               w = container.getWidth();
               h = container.getHeight();
               if (w == 0 || h == 0) {
                    finish();
               } else {
                    fromImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
                    Graphics g = fromImage.getGraphics();
                    container.printAll(g);
                    g.dispose();
                    toImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
                    g = toImage.getGraphics();
                    Components.setAllSizes(content, w, h);
                    container.removeAll();
                    container.add(content);
                    container.validate();
                    container.revalidate();
                    content.printAll(g);
                    g.dispose();
                    currentImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
                    this.setPreferredSize(new Dimension(w, h));
                    container.removeAll();
                    container.add(this);
                    container.revalidate();
                    updateCurrentImage(0.0f);
          @Override
          protected void paintComponent(Graphics g) {
               g.drawImage(currentImage, 0, 0, null);
          // return true if finished
          public boolean tick() {
               if (finished) {
                    return true;
               long time = System.currentTimeMillis();
               double percent = 1.0 * (time - start) / TRANSITION_TIME;
               if (percent >= 1) {
                    finish();
                    return true;
               updateCurrentImage((float) percent);
               repaint();
               return false;
          private void updateCurrentImage(float p) {
               Graphics2D g = (Graphics2D) currentImage.getGraphics();
               g.setColor(Color.white);
               g.fillRect(0, 0, w, h);
               scales[3] = 1 - p;
               RescaleOp rop = new RescaleOp(scales, offsets, null);
               g.drawImage(fromImage, rop, 0, 0);
               scales[3] = p;
               rop = new RescaleOp(scales, offsets, null);
               g.drawImage(toImage, rop, 0, 0);
               g.dispose();
          private void finish() {
               finished = true;
               SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                         container.removeAll();
                         container.add(content);
                         container.revalidate();
                         container.repaint();
     }

We can't see the behaviour you describe.
If you need further help then you need to create a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://homepage1.nifty.com/algafield/sscce.html], that demonstrates the incorrect behaviour.

Similar Messages

  • Exporting animated gifs with fade transitions in PS CS6

    So I created a basic slideshow banner with three different images that fade from one to the next. When I preview it on the timeline, everything looks great, but when I go to save for web and select gif, then hit play for a preview, the fade transitions are gone and they just hard cut from one to the next. Anyone know how to keep those fade transitions when exporting?

    The only way to optimize this is to use less colors and define the frame durations manualyl in the timeline in frame mode, i.e. setting the actual posters to a very long duration on a single frame and then only have the transition regions use multiple frames with short durations. Still, I don't think you will ever arrive at 40-50kB. Even a normal mail blast with static PNGs/ GIFs and JPEGs is larger than that if it contains a huge logo, decorative lines and borders and button graphics... It's unrealistic. With the above optimizations you may get to somewhere about 300kB, but not below, if you wnat to retain the fades. They are what makes your files fat because they introduce lots of colors in teh palette that can't be optimized away easily...
    Mylenium

  • Audio fade in and  out in imovie 11 with a transition not working

    When I fade audio out and fade audio in imovie 11 with a transition in between the fade would not work. If I remove the transition they would work. How can I fix this. If i reinstall life 11 would it lose my would or repair the issue.

    I am having the same problem. I found a decent workaround:
    At the point where you want to fade out, record a voiceover (using a mic) of silence. In other words, cover the microphone and record nothing for a second or two.
    Then go into the audio settings for this voiceover and select the "ducking" checkbox, and change the setting so that all other tracks go to 0% sound when the voiceover is playing. The ducking feature has a built-in fader, so this way, when the silent voiceover comes on, it fades out the other track(s)--effectively giving you a fade-out effect on any concurrent track.
    Not a perfect solution but can help...good luck!

  • Fade transitions not showing in web browser

    Hi guys,
    when exporting an animated GIF with a simple fade transition between two layers, it appears to work within Photoshop but when previewing in the save for web window and in a browser,
    the fade transitions don't appear.
    Cheers
    Chris

    When a GIF supports transparency it only supports 255 colors the 256 color is reserved for transparent. Which does not support a partly transparent a pixel is either 100% opaque or empty. A fade or something something like a drop would be made by dithering. Scaling that kind of gif can help how it looks on screen. The large one is not scaled the other two are the same gif file scaled. Animater pgn would be better but all browser  do not support the use abs some like Chrome may have a plugin that support them. Latr image is an animated png...

  • Can't Drag & Drop Cross Fade Transition ?

    I'm a new user and can't figure out why when I attempt to drag and drop a cross-fade transition into my timeline it won't stick or apply. Can anybody help with this. Also, is there a setting that would automatically apply the cross-fade transition to all clip joining points in the timeline ?

    http://www.fcpbook.com/Effects1.html
    http://www.fcpbook.com/Effects2.html
    The second techniques assumes there are handles available to create the transition overlap.

  • Ken Burns with Fade in Fade out Dissolve

    I have about 300 pictures and want to add kens burns and fade in fade out dissolve to all at once then go one by one and adjust.
    I figured out how to do copy paste attriubutes to all pics for Ken Burns, BUT not sure if there is a simple way to add Fade in Fade out Dissolve btn each of them to avoid doing 300x
    Thanks much
    drgwtv

    OK I'll bite... Who is this Ken Burns?
    There's a couple of ways to go about adding your transitions. I think is the easiest.
    Make sure the favorite transition and length you want it are set in your effects tab. Select all of your clips in the timeline and drag them up to the canvas holding down the mouse. Several options should display and I believe the one you want is overwright with favorite transition. Its been a while since I've done but give it a try and post back if I'm wrong.
    For bonus points-
    Another way to quickly add your favorite transition is to use the arrow key or mouse to position the cursor at the edit point and press Apple+T

  • Problems with removing transitions

    I am using iMovie v5. When I remove transitions, my clips are not restored to the original version. For example, if I have two clips with a transition between them, and then I remove the transition the following happens:
    1. Clip 1 will have a second or two of merged from Clip 2
    2. Clip 2 will be truncated in the beginning by a second or two.
    I have looked in the manual and other discussion threads and can't find an answer. Oh... I'm using the fade out transition.

    John:
    That can happen with non-destructive veideo.
    Don't know for certain that this will fix it, but it sure won't hurt anything...
    Quit iMovie.
    Locate a file named com.apple.iMovie.plist and get rid of it. iMovie will create a new one the next time it runs. Empty the trash and restart imovie.
    -->/Users/YourName**/Library/Preferences/com.apple.iMovie.plist
    Sue

  • How can I do a simple fade transition between clips??

    I'm trying to learn my new Premiere Elements 9. I am a simple man, with simple needs. I like to just do a simple fade transition between video clips. There is no "fade" option on the transitions for PE9, I have tried "cross disolve" and "non-additive disolve", and they are freaking wierd. The one that comes the closest is cross-dissolve, It fades out the first clip fine, but the follow on clip starts with an awkward momentary freeze frame, which is not acceptable.
    Any thoughts?
    Clem

    A "fade" is a just that. It fades to black.
    Fades to black are far from weird.They are very useful for indicating a complete change of subject or chapter in a long video story.
    I think you are using the wrong descriptions,
    Probably you want a cross dissolve where one scene slowly dissapears while the next one appears, the average picture level being constant.
    There are two of them provided in transitions. Cross dissolve (what you call a fade) and non additive dissolve.
    They both work perfectly if you apply them correctly and you have set up your project correctly to match your video camera or slides. (see many other posts on this)
    You simply drag the 'transition icon' for the dissolve to the cut line between the two clips. Cant be any easier than that can it?
    If you are seeing jerky results, it is because your computer is not fast enough to preview unrendered video (or set up right) - so render it!
    As I said there should be no red lines at the top of the timeline where the transition is (otherwise render just that red part of the timeline)
    More advanced:-
    The dissolve period plainly shows in the video track. You can have it before, centered or after the cut depending on where you want the dissolve to start or finish in relation to moving objects in the video. (Right click and select effect properties to adjust)
    You can even change the speed of the dissolve by dragging the edges of the effect boix in the timeline

  • Cryptsetup: Swap encryption with supend-to-disk doesn't work

    Hello Community,
    i'm trying to get swap encryption with suspend-to-disk support to a working state.
    On my system only the /home partition is encrypted with cryptsetup-LUKS.
    I'm using the howto on "Using a swap file" (with /home/swapfile as swap file) in the wiki: https://wiki.archlinux.org/index.php/Dm … sk_support
    I followed exactly the given instructions:
    From /etc/mkinitcpio.conf
    HOOKS="base udev autodetect encrypt block resume filesystems keymap fsck"
    From /etc/default/grub
    GRUB_CMDLINE_LINUX="pcie_aspm=force pcie_aspm.policy=powersave pcie_port=native ipv6.disable=1 init=/usr/lib/systemd/systemd resume=/dev/mapper/crypthome resume_offset=16721572"
    From /etc/fstab:
    /home/swapfile none swap defaults 0 0
    The swapfile is working. Suspend-to-disk also works. But when resuming, I always get:
    ERROR: failed to open encryption mapping
    The device UUID=... is not a LUKS volume and the crypto= parameter was not specified
    running hook [resume]
    Waiting 10 seconds for /dev/mapper/crypthome
    ERROR: resume: hibernation device /dev/mapper/crypthome not found
    Then the system recovers the filesystem of / and later after the passphrase input of /dev/mapper/home it is forced to recover the filesystem of /home.
    Shouldn't I get a passphrase input when running the [resume] hook?
    Where is the problem I have missed?
    Thanks in advance!
    Last edited by indianahorst (2014-01-23 17:39:31)

    ball wrote:It seems that you've specified your home partition for the resume parameter, that is wrong. It should be the swap partition: https://wiki.archlinux.org/index.php/Su … parameters
    No. Have you read my posting completely?
    I don't use a swap partition.  I'm using a Swapfile on my encrypted home partition. See the link in the first posting and go to "Using a swap file".

  • MB26 ,CO27 - goods issue components with serial number?

    Hi ,everyone!
    I know CO27 and MB26 can do goods issue to production order very easily and quickly!
    But It seems CO27 and MB26 can not work well with the component with serial number.
    I aslo know MB1A and MB1B can post goods issue for component with serial number.But in MB1A and MB11 , it is very difficult to can material by material number quickly while doing more then 100 components issue to one production order.
    And for authorization purpose we restrict MIGO not to use goods issue for production order.
    So I want to ask how CO27 and MB26 do goods issue for the component with serial number?
    Or there is another ways to goods issue component with serial number to production order easily,exclude MB1A,MB11 and MIGO?
    Thanks for any reply!

    Hi Vivek     
    We use CO27 for goods issue to production order ,just like MB1A goods issue to production order.
    But in the BOM components of the production orders ,some semi finished products are with  with serial numbers ,so we can not use CO27 or MB26 to issue these components with serial numbers to production orders!

  • Embed Video PDF InDesign Booklet with Page Transitions & Playable Video

    e.g.
    http://help.adobe.com/en_US/InDesign...3D6C6A460.html
    also such as:
    http://www.page-flip.com (although yet to implement  feature...)
    So...
    Is there any way to get embedded video within pdf - once placed in  InDesign - to export (either swf or xfl) creating a booklet-type  publication with page transitions (curl/ page-flip) with the videos  playable?

    Only Adobe Acrobat or Reader can show those PDFs (and many others) correctly. Are you sure that the PDF was opened in one of these 2 applications and not in Apple Preview or Ghostviewer or something else?
    Only Adobe Reader 9 and X and Acrobat 9 and X can show PDFs with Flash content correctly. If you have an older version, let us say Version 8 or older, you are not able to see Flash content at all. If you have a newer version, that is Reader XI or Acrobat XI you need additional Adobe Flash player have installed on that computer and allow access to your PDFs. Can you check, if these substantial requirement are fulfilled?

  • Firefox is hanging when the page scrolls down to a html5 video or the page to a slideshow with fade effect

    Every time a page has a html5 video or a slideshow with fade effect Firefox 3.6 becomes terriblely slow. It freezes with this test: http://demos.hacks.mozilla.org/openweb/HWACCEL/
    I have Fedora 14 and before that Fedora 13 and the problem happens with both.
    The same doesn't happen on Opera or Google Chrome.
    '''UPDATE 1''': I have already tryed the Safe Mode and the problem happens the same.
    '''UPDATE 2:''' This page full of videos scroll smothly without any problemas: http://brettgaylor.tumblr.com/tagged/webmademovies

    I forgot to say that I did tryed the Safe Mode just to see if the slow was not being caused by some extension or plugin. However the result was all the same. By the way, the slow happens even if there is only one page opened. I am not thinking it is something related to the ATI video card or even Fedora because the same slow does't happen in Chrome and Opera...

  • HT201342 I have not been able to upgrade to a new computer. So I am running an old OS 10.5.8 in a Powerbook Pro 15¨. I recently have had some e-mail problems. I would like to know if this is related with all transitional process from @mac to @icloud.

    I have just starting having problems with my @mac.com account because I still have an old computer. Un fortunatelly so many years this is my main account and no option to send e-mail are possible.
    Is this related with the transitional process from moving to an @icloud.com account?
    regards

    pvonk wrote:
    First of all, your profile says you are using OSX 10.5.8 which is incompatible wth all features of icloud, although users have been able to use icloud's email with older versions.  With the transition to @icloud.com accounts, it's difficult to say what the effect is regarding older versions of OSX.  I've read posts by others who are still using these versions and have now been having problems with emails. 
    iCloud mail is a standard Imap account, any version of OSX (or Windows) with an Imap compatible mail client can use it.

  • When importing Abode premiere footage with video transitions they get wipped out :-(

    Afternoon from York UK,  (USING LATEST VERSIONS OF ALL SOFTWARE)
    Ok here's today's stress.... I build i video clip with Video transitions, dissolve dip to white to be specific. When i imported the project into After effects all transitions are lost :-( I'm so very confused.
    To help here is a screen shot showing the transitions effects exist in the layers but on ram preview and export to mpeg no video transitions show. It is as if i added no transition effects between the clips!
    http://i216.photobucket.com/albums/cc53/zymurgy_bucket/lost-video-transitions_zps254d346c. jpg
    p.s. Really wanted above link to open in separate window but Ive had enough today of battling with CMS's
    Thanks in advance,
    David

    Thanks Rick,
    But I'm such a noob at Ae i've little idea on how to go about "Dynamically linked AE..." I appreciate now Ae is a technical tool which is going to take time to master which is difficult when I had yesterday to send the completed video to the client. Big problems for me are getting generated when I try to import Pr with Ae. Case in point is my Ae created animation being so much bigger than my imported video clip creating this effect: http://i216.photobucket.com/albums/cc53/zymurgy_bucket/misfit-video-clip-langleys-glitch_z pseec728d8.jpg
    Spent all day trying to fix this but no joy, I have today to fix this, wish me luck ;-)

  • How to make link between xcelsius components with sap data using Web servic

    Hi all,
    I have a doubt regarding connection between Xcelsius components and SAP data.
    I created one Web service using Function module and made a connection between xcelsius and that web service using binding URL. It shows imput and output parameters perfectly.
    But I cant get any idea as to how to connect Xcelsius components with these parameters.
    Can anybody help me out..
    please its urgent.
    Thanks,
    Simadri

    Have you bound your output parameters to ranges of cells? Select the item, then click the icon to the right of the Insert In: box and select the cells.
    Add a spreadsheet component to your chart and bind it to the cells, then preview the model. Do you see the data coming through?
    If you do, then you can click File > Snapshot > Export Excel Data. Then close Preview mode, and import data from spreadsheet and select the sheet you just exported. This gives you real data to work with when designing the dashboard.
    Hope that helps.

Maybe you are looking for

  • Key figure flag in the planning layout

    Hi, Can anyone explain the importance of the key figure flag in the planning layout? Regds Pavan.

  • Issue in Vendor A/c clearing

    Hi We have an issue in which we have paid some advance to vendor in EURO at a certain rate say 1 EURO = 1.25 USD. Now at the same rate we have booked the vendor invoice in USD because the bills from vendor  have come in USD. Thus both the down paymen

  • Ad-hoc and Internet sharing

    Apologies, mistakenly posted in wrong forum. I am REALLY sorry.

  • Running two VI's at once, with shared GPIB Resource - How to...

    ...keep mouse pointer within the confines of one VI's front panel? Hello, a LV newbie here.  Here's my situation. I have a "Main" LV program that uses a GPIB-controlled DMM (Keithley 2700) to take a scan of current measurements.   However, before tak

  • Using two drives as source/target for copying a disk?

    Greetings, Please bear with what is probably a stupid question from a pc ship-jumper Mac newbie. I ordered my new Mac Pro with two Pioneer optical drives in order to, as Apple says, "streamline disk burning". I learned that Toast is the gold standard