Smoother animation - Please help...

Hi,
I'm writing a graphical editor where multiple shapes can be moved , resized and so on.
Let's say I want to move around a rectangular Shape.
*What is the best way to avoid redrawing all the elements of the screen - just the ones that get "dirty" by the Shape's movement??? If I keep all the Shapes in a Vector , then test which Shapes intersect with the moving box and only redraw those - would that be a fast or a slow thing to do???
*Is there any way to take a "screenshot" of the shapes that stay foot so that I least I won't have to regenerate all the shapes to be drawn , just "paste" this screenshot then draw above it the box in its new position??? ( I mean something like copyArea(x,y,width,height, 0 , 0 )
* If the above makes sence , can I have multiple layers - like the first for the background , the second for the "bottom" objects and so on - then sort of
super-compose one in top of the other???
Please give me detailed solutions (with some code if possible ) It ' s not like I have no idea how to do it , I just want to know how to get things faster...
Thanks!!!

When you repaint a shape, user repaint(myShape.getBounds()). In the paint-method, use these bounds to draw a subimage off a BufferedImage. Oh, and before drawing the subimage, do this:
Vector myShapes = ...;
for(int i = 0; i < myShapes.size(); i++) {
if(((Shape)myShapes.elementAt(i)).getBounds().intersects(myRectangle))
((Graphics2D).fill(((Shape)myShapes.elementAt(i));
myShapes = a Vector containing all the shapes.
myRectangle = the the bounds of the shape in need of repaint.
Now this is as optimized as it gets: It paints a small part of the screen, it paints only the shapes needed, and it only paints a small part of the BufferedImage. If you need movement, though, you might have to work a bit on this.
Nille

Similar Messages

  • I need help with animation, PLEASE help!

    I am trying to create pacman animation by using a series of filled arcs that I create by coding in java. I know how to create the arcs, but I don't know how to use them to create animation. In other words I don't know how to put them in sequence to create animation.
    I have searched the web, and all I find is animation that use a series of GIF or JPEG images.
    can you please help me or point me to the right direction.
    by the way, which of these two animation would run faster? The one that uses GIF images, or the one that would use shapes created in java?
    Thanx

    Perhaps you could do this two ways
    One way, (im not sure if this will work), is to create a .gif file that is already animated. An open mouth animated to a closed mouth. But i don't know if Java will accept this.
    The second way would be to create a Thread. And to create however many images you want to display the open to closed mouth. Then continuously change the image so it appears the mouth is opening and closing.
    Put in a delay so it doens't go too fast, and there ya have it.
    Public void run()
    int i =0;
    while(true)
    myThread.sleep(10);
    image = difImage;
    }something like that. Might used a bufferedImage and make just use subImage to pull off each picture you need to change.

  • Java swing choppy animation: PLEASE HELP

    jklh;j
    Edited by: 806886 on Nov 2, 2010 5:21 AM

    Hi, [url http://forums.oracle.com/forums/ann.jspa?annID=1391]Welcome to the new home(Announcement:the code tags)
    Sorry to change the subject, but your code seems to cause an IllegalArgumentException:
    //RGB[0] = random.nextInt(255);
    //randomizeColor[0] = 1+random.nextInt(3);
    //randomizeColor[0] = 1+random.nextInt(3);
    //randomizeColor[0] = 1+random.nextInt(3);
    randomizeColor[0] = 1+random.nextInt(4);
    randomizeColor[1] = 1+random.nextInt(4);
    randomizeColor[2] = 1+random.nextInt(4);
    //ball colors change
    //for (int i = 0; i < RGB.length; i++)
    //    if (RGB[i] >= 250 || RGB[i] <= 4)
    //        randomizeColor[i] = -randomizeColor;
    //RGB[0]+= randomizeColor[0];
    //RGB[1]+= randomizeColor[1];
    //RGB[2]+= randomizeColor[2];
    for (int i = 0; i < RGB.length; i++) {
    RGB[i] += randomizeColor[i];
    if(RGB[i]>255) {
    RGB[i] = 255;
    randomizeColor[i] = -Math.abs(randomizeColor[i]);
    }else if(RGB[i]<0) {
    RGB[i] = 0;
    randomizeColor[i] = Math.abs(randomizeColor[i]);
    color = new Color(RGB[0],RGB[1],RGB[2]);
    Edited by: aterai on 2010/11/02 19:52                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Please Help me, How to cut image ?

    I have a image (jpg file). The image is animal, and the image contain 2 basic colours (white is background, black describe animal). I want to cut background around animal
    Please Help me ???
    Please source code .??? Example??

    well it depends what you want to do with this- do you just want to use the black part without a whit contour?
    however if you want to have 2 colors PLEASE save as GIF or as PNG and not as JPG - JPG tends to blur the image a little so your mask will get screwed up with JPG
    the easiest way for me is to do this job in photoshop and save as Tiff then load it with Javax.ImageIO so transparency is kept

  • Please, Help me. I need to do Pluse Width Modulation using LabVIEW 7.1

    I need to do Pluse Width Modulation (PWM) using LabVIEW 7.1. I have some analog signal e.g. sine-wave, then I want to transform this signal to be PWM signal.
    See in Figure,
    Now I already make by myself, but it 's not good. Because the frequency of sawtooth is very low, so the PWM signal is not smooth. Please , help me or give me for example.
    I will try its.
    Attachments:
    fig4.gif ‏5 KB

    Hello,
    I think the problem you're having comes down to how you're using the function.  Basically, the frequency input to the sawtooth function is defined poorly in units of cycles/sample.  Of course, we're used to seeing frequency defined in terms of samples/second.  But remember, all we have in any programming language is data - in this case we have an array of data.  The timing information is to be interpreted, and has nothing to do with the data that defines the waveform.  What I mean here is, the time per sample in the sawtooth waveform is completely arbitrary and has nothing to do with the sawtooth itself.  It will be defined if you physically output that waveform, because you will be writing some number or samples per second - that will define the frequency of the waveform.  Thus, when you are working entirely in software, what you fundamentally care about are the number of samples, or perhaps a bit more specifically, the number of samples/cycle (for periodic functions) and also the number of cycles you'd like to define (together these two tell you the total number of samples).  Of course, if you know the rate at which your samples will be output, and you know the samples/cycle that you've defined, those to pieces of information tell you the actual frequency that the signal you output will have.
    The moral of the story is, when you wired 100 to the f input of the sawtooth function, it was interpreted as 100 cycles/sample, which clearly doesn't make sense because a single sample cannot represent 100 cycles, let alone even a single cycle.  Take a look at the attached VI, where all I have done is used the reciprical function to make the front panel input be in units of samples/cycle instead of cycles/sample.  This way you can specify the total number of samples and the samples/cycle, and you should have a pretty good feel for how to use the function in the slightly modified form.
    I think that clears things up!
    Best Regards,
    JLS
    Best,
    JLS
    Sixclear
    Attachments:
    Sawtooth.vi ‏24 KB

  • Animated Globe - Please help!

    Hi Everyone,
    First off let me please start by saying thanks in advance! I was hoping someone could help me out. I wanted to add the rotating globe to a family movie but my OS is messed up! Can anyone just create an MOV file for me and email it??
    All in a 3d - blue marble globe - THANK YOU!!!!!!!!!!
    Perth, Australia to Auckland, New Zealand to San Francisco - Clip 1
    Turlock, CA to Los Angeles, CA - clip 2
    San Francisco to Las Vegas - clip 3
    last clip
    San Francisco to Auckland NZ to Perth, Australia - clip 4
    IF this is too much to ask for, I'd love clip 1 and clip 4 at the very minimum. Please help!!!! Thanks so much in advance.
    Thank you!!!!!!!!!!
    email address: [email protected]

    As far as I know, you cannot put a SWF file in an email and
    have it successfully show across all email client. Try exporting
    your banner to an animated GIF. If that doesn't produce a good
    enough image then export it as a bitmap sequence and convert those
    files to an animated GIF in ImageReady or something like that.
    Apparently Flash's export to animated GIF is not that great.
    Here's a good article on HTML emails you can read. You'll
    need to make sure your GIF is posted somewhere that the HTML email
    can refer to. It explains it in the article.

  • HT204266 I erase all application of my iphone 4 with erase restore and now it's in restore mode. Now is there any way to restore my iphone without backup. Please help me. I have no need my previous file i just want my i phone ok and work smoothly as new p

    Hi,
    I erase all application of my iphone 4 with erase restore without any backup & i also lose the product serial number. Now it's in restore mode. Now is there any way to restore my iphone without backup. Please help me. I have no need my previous file I just want my iphone4 ok and work smoothly as like new ipone justlike i bought it at first time. I can't restore it. So Please help me to solv this proble.

    See Here  > without the Backup  >  http://support.apple.com/kb/HT4137

  • Smooth Cam not exporting properly in FCP 7.03 - please help

    Hello
    I have a 30 minute video edit. A small number of clips have the smooth cam filter applied with default settings. When I export the finished project to a number of varied settings - pro res, pro res LT, apple tv, iphone etc... All the smooth cam clips are jittery and juddering -  and are not working for some reason.
    I have done a bit of research and apparently it's a bug in FCP 7.03 with interlaced footage (progressive works fine, apparently). All the source footage was transcoded to pro res.
    Someone said that putting the clips in motion and smoothing them out in optical flow would work and people had results. However I have no clue how to do this..
    Can someone please help me - I need to render a finished project today..
    Thanks in advance
    Nick

    Apparently it's a bug with Smoothcam's handling of interlaced footage in FCP 7.0.3 ... there's a post over on the Creative COW website detailing using Motion instead as Finnur mentions above.  Here's my own quick summary of that for those that aren't used to it :
    In FCP select the clip instance and choose FIle > Send To > Motion Project (or right click and choose Send To > Motion Project) and save the Exported clip to your scratch disk 
    The exported clip will open in Motion. Click the clip to select it and then from the toolbar at the top of the main window choose ➀ Add Behavior > Motion Tracking > Stabilize
    Next choose ➁ HUD (heads up display), and in that window ➂ set Method : Smooth, Borders : Zoom, and select Adjust : Position & Scale, and click the Movement : Analyze button
    When the Analysis is complete, choose Motion menu > Quit, and press "Save" when prompted. 
    When you return to FCP the smoothed Motion project (.motn) should be sitting in the sequence in place of the original clip ... it'll probably need rendering .
    Personally, I'd be inclined to just try adding the Shift Fields filter (Effects > Video Filters > Video > Shift Fields) to the jittery Smoothcam shot in FCP first, and see if that works, before jumping through the Motion hoops.
    Hope it helps
    Andy

  • I can't see the animations on the website or access most of the options when I log in.Works perfect with Internet explorer though! Please help

    I can't see the animations on this page (looks like a very small image) and when I log in can't access/see some of the options in the website . The page however works perfect with Internet explorer though! Please help identify the kind of plugin/add-on needed to make it work.

    If you're using it in bright light, you may be getting sunlight through the back of the machine which can wash out the display.  The Apple logo on the back of the lid is actually a cut-out that uses the systems back light to make it glow.  Bright light (especially sunlight) can actually shine through the back.  As the users in the login are typically in the middle of the display, this is the area most likely to be washed out as that is where the Apple logo is.  You can try just putting your hand over the Apple logo on the back to block the sunlight when trying to log in.

  • When I apply smoothing to a clip, it does nothing and the video frame remains static! Please Help!

    When I apply smoothing to a clip, it does nothing and the video frame remains static. As opposed to moving around in order to compensate for my movement, which exposes black edges. That is what I am trying to get. Please help
    These are the steps I follow. Import clip > Library > Behaviours > Motion > Stabilize. I then add the stabilize > go to inspector and change method to smooth and finally, analyze. However, it is not doing anything. My Macbook Pro was recently replaced and this is what I recall doing on my previous one, but it doesnt seem to be working for me. Is there a step im missing or something?
    Thanks for any help!

    Smooth is just going to smooth out a little "jitter" or jerkiness in the footage. Unless there is a lot of camera movement, you won't notice much. If you really want to see Motion go to work, change the Method to Stabilize.
    BTW, once the footage is analyzed, you can make any changes you want to any of the other parameters - you don't have to re-analyze. I recommend Stabilize with Adjust: Position Scale and Rotation and Borders set to Zoom (depending on the quality of the video) — or you might consider adding a mask to the group the stabilized video is in

  • Hi, I am having trouble using the smooth tool on a logo that I created. I have watched tutorials and something isn't working for me. When trace with the smooth the line just disappears and doesn't smooth anything out. Please help.

    Hi, I am having trouble using the smooth tool on a logo that I created. I have watched tutorials and something isn't working for me. When trace with the smooth the line just disappears and doesn't smooth anything out. Please help.

    Sorry, that's Monika with a k
    On Tue, Nov 18, 2014 at 2:26 PM, Monika Gause <[email protected]>

  • Why are my tools like brush, eraser, pencil (basically any that you would use to make a smooth motion that would affect the layers) is not working and acts as if I clicked once and let go.  I have checked spacing and reset tools and brushes. Please help!

    I haven't had issues with this in the past and I've checked the different modes the layers are in as well as the brushes are in.  I've also checked spacing to make sure it isn't wrong.  An example of what it is doing, would be to use the brush tool and try to draw a circle.  Normally, this wouldn't be an issue but the tool only makes a dot as if I quickly pressed and released tool, but I'm holding down to draw the image.  All tools that do similar functions such as blur, eraser, pencil, paint are doing the same thing.... Please help!!

    Photoshop Elements doesn't respond when you use editing tools in Mac OS X 10.10

  • I'm getting this choppy effect with motion, please help!

    Hi all.
    I'm animating photos with white borders in AE, like polaroids. It's basically a camera slow panning and tracking around them.
    Each time the camera gets closer, and pans appear to be faster, I get this choppy look caused by the sharp white borders.
    I have tried
    - Subtle Gaussian Blue
    - Enabling Motion Blur
    and while they help a little, the effect is still there. Is there another technique? Someone suggested to take into PPro and apply the anti flicker effect.
    Please help. Deadline today.

    There are things like critical panning speeds that you must be aware of. The lower the frame rate the bigger the problem. The FAQ section of this forum has a link to two articles that may help. One is for horizontal motion the other is for vertical. FAQ: Why does horizontal motion stutter (judder) in my movies, such as during pans?
    There is a lot of good information about all kinds of problems in the FAQ section. You'll find a link on the form homepage. After Effects FAQ List
    You could also be experiencing skipped frames during playback. The answer to that problem is also in the FAQ: FAQ: Why is my output file huge, and why doesn't it play back smoothly in a media player?

  • Which FPS for Smooth Animation?

    I'm a new flash user and I'm having trouble making a simple
    animation (small bitmap single color airplane motion tweened to
    move across the background) for a website. FPS is set to 21 but
    when i test the movie, the animation is choppy & not smooth at
    all. If i try 60FPS, it's very smooth but I think that'd be
    ridiculously high for a website.
    Please take a look at this link because I want my animation
    to be as smooth as this, what FPS do you think they used here?
    http://www.taito.co.jp
    What are some other options for me to retain a 21FPS swf
    file and still keep my animation as smooth as possible? or are
    people just using really high FPS to achieve this? Please help
    me...thank you.

    I use 30fps, I think its smooth but not overkill. Higher than
    that, and you will start to run into PC strains and slow downs on
    older machines, lower than that and things are just inheritantly
    choppy.
    Also, you mention you are animating a bitmap. Bitmaps tend to
    have a harder time than vectors. Also, with Bitmaps, be sure to
    check "allow smoothing" in it's properties in library.

  • Itunes wont recognize my iphone 5s!!! Please help

    Hi Everyone.. can someone please help me? Ive been searching this forum for 2 days now and cannot find a fix to the issue I am having.
    My wife and I had iphone 4s' untill we recently upgraded to the 5s... we got both phones on the same day and simply installed from backup and everything appeared to run smoothly in both cases... Until i recently noticed that some of the music was missing from a playlist I made a while ago.
    Naturally I thought to sync the phone.. This is not possible over wifi (device options are greyed out) and it wont even work using a cable as the device driver times out.  Now please note I have forced an update to the driver multiple times now following advice on this site, and I have made sure that my windows updates and itunes software are fully upto date, yet I still cannot get itunes to see my phone... or my wifes phone!
    Iphone software is upto date and i have tried different cables just to be sure, and still nothing!  Help me apple support community.. your my only hope!
    Thanks

    Hello mcenteemike,
    Thank you for contacting Apple Support Communities.
    The first thing I would check on would be what version of iTunes you have installed on your computer.
    System Requirements
    Apple ID (required for some features)
    Internet access4
    Syncing with iTunes on a Mac or PC requires:
    Mac: OS X v10.6.8 or later
    PC: Windows 7; Windows Vista; or Windows XP Home or Professional with Service Pack 3 or later
    iTunes 10.7 or later (free download from www.itunes.com/download)
    From:
    iPhone 5 - Technical Specifications
    http://support.apple.com/kb/SP655
    If your iTunes is up to date, then you use the appropriate link:
    Not seen in iTunes / USB connection issues
    See these articles for help with troubleshooting this issue:
    iOS: Not recognized in iTunes for Mac OS X
    iOS: Not recognized in iTunes for Windows
    iOS: Troubleshooting USB connections
    From
    iPhone: Hardware troubleshooting
    http://support.apple.com/kb/TS2802
    Regards,
    Jeff D.

Maybe you are looking for

  • To display Total sum of a column in a table view control ?

    Hi,   I am unable to display the sum of a column in a table view control ( using HTMLB ). How should one display the sum of a column in a table view control ? Thanks in advance. Vara.

  • Installing oracle 8i on windows xp

    So that we may better diagnose DOWNLOAD problems, please provide the following information. - Server name :windows xp - Filename - Date/Time - Browser + Version - O/S + Version - Error Msg Installing oracle 8i on windows xp. will this work properly

  • I am unable to start Managed Servers through Weblogic AdminConsole

    Hi, We are using Weblogic 10.3.1.0 version. Totaly 4 Managed Severs 1 Admin Server with Nodemanger. In Admin Console When ever we going to Stop the Manged Servers. 1. Environment ----- > Servers ---- > Control ----------- > Mananged Server 1 --------

  • Clearing unwanted Tags using XmlElement()

    Hi, Using the following Select clause produces the flwg XML Document: SQL> SELECT dbms_xmlquery.getXML('select deptno, dname, '|| 2 'cursor(select empno, ename, sal from emp e where e.deptno = d.deptno) employees '|| 3 'from dept d where d.deptno in

  • My iphone 5 is in recovery mode and won't connect to itunes

    I was trying to update my phone using itunes but now my iphone 5 is stuck in recovery mode and won't connect to itunes.