Graphics2D and AffineTransform needs object-reuse for smooth animation!

Hi,
I'm currently working on a graphical framework for animation using Java2D but has come to a dead end. The goal of the framework is to deliver smooth animation on various platforms, but this seems impossible due to the following fact:
I have a tree of graphical objects i render on a Graphics2D-object. Some of the objects to be rendered are transforms on the Graphics2D instead of visible objects - this way I can have transform-objects in my tree which will affect all child-objects. This is all very nice, but when doing transformations on the Graphics2D A LOT of objects are being created by the implementation of Graphics2D (SunGraphics2D). I've designed my framework to utilize object-reuse and cacheing-mechanisms to ensure no garbage collection is performed when actual animation is in progress - if gc's are performed, this results in visible pauses in the animation. Now, I would like to ask if someone knows how to get around this problem, or suggest I simply abandon Java2D?
The details of my problem is the following:
When doing transforms on the Graphics2D-object which is passed to every object in the tree (and hence, a lot of transformations are being done), a lot of FontInfo-objects are being created - even though I don't use any of them - it's all in the subsystem. The source in the SunGraphics2D is as follows:
// this is called by my framework to rotate all childs in the tree
public void rotate(double d) {
  transform.rotate(d);
  invalidateTransform(); // the evil starts here
// this is called a lot of places in SunGraphics2D
protected void invalidateTransform() {
  // a lot is thigs are going on in this method - cutted out...
  // before this method returns, the following takes place
  fontInfo = checkFontInfo(null, font); // now we are getting there
// this is the method of pure evil object allocations
public FontInfo checkFontInfo(FontInfo fontinfo, Font font1) {
  // every time this method is called, a FontInfo-object is allocated
  FontInfo fontinfo1 = new FontInfo();
  // and a lot of other objects are being created as well...
}I have come to think, that Java2D is pretty old and should be pretty mature at this point, but now I doubt it since object-reuse is a pretty obvious way of doing optimizations.
Has any of you experienced the same problem or maybe found a solution to doing transformations on a Graphics2D-object without a ton of objects being created?
If you would like to have a look at the problem you can do the following:
Make yourself a little program which is doing some transforms on a Graphics2D-object in a loop (to emulate the 25fps animation and the transform-objects in the tree). Now use your favorite memory profiler (I use JProbe Memory Profiler, free evaluation) and see for yourself - the objects which are garbage collected includes a ton of FontInfo-objects and many AffineTransform-objects.
If I do not find any solution to this problem, I'm forced to face the fact, that Java2D is not suitable for animation-purposes - gc's during animation is no solution!
Thank you for your time - hope to hear from you soon.
Regards,
// x-otic.

I think the main point is java transform objects are to slow to use in animations. They definitly have there uses, but for fast animations you need something more optimized.
If you assume a general graphic objects has getHeight, width, x, y, render(). You could do translations using these general properties at an abstract level, letting each graphic object implements its own way to render itself and use the properties.
I tryed to make sense!

Similar Messages

  • HT201441 if the employee has been terminated and I need to reuse the phone and have no ability to contact them, how can I erase the phone?

    if the employee has been terminated and I need to reuse the phone and have no ability to contact them, how can I erase the phone?

    Welcome to the Apple community.
    Contact AppleCare (or Apple ID Support), upon speaking to an operator you should explain that your problem is related to your Apple ID, this way you will not be charged for assistance, even if you don’t have an AppleCare plan.
    I'm not exactly sure what procedures are in place for such events but Apple can assist in such cases, but it may take a while and you may need to provide proof of purchase and other corporate documents.
    For future reference your best tactic might be to use Apple Configurator to set up all your companies devices. You can set the password for 'Find my Phone' to be identical for all your devices, whilst allowing the user to use their own password for the remainder of the iCloud services.

  • I bought Adobe Photoshop Elements 13 They sent me the one for Windows and I need the one for Macbook Pro!!!

    The download that adobe sent me is for Windows. I have a Mac and I need the one for Macbook Pro. I have been looking for a contact with customer service and even the chat is not working. Help please! I haven't use the product they sent me

    Please open link
    Contact Customer Care
    Then click on still need help, you will get the chat option

  • Please help us, after we installing the flash player is said that the plug-in version is not installed and i need Flash Player for my windows 7 Professional 64-bit Japanese version and Internet explorer 10

    Please help us, after we installing the flash player is said that the plug-in version is not installed and i need Flash Player for my windows 7 Professional 64-bit Japanese version and Internet explorer 10

    Hello,
    There are two versions of Flash Player for Windows:  ActiveX for Internet Explorer and Plug-in for non-IE browsers. It appear you may have installed the one for non-IE browsers.  Please use the links below to download and install:
    Flash Player ActiveX (Internet Explorer
    Flash Player Plug-in (All other browsers)
    Maria

  • HT5312 Hi, i didn't put a rescue email and i need the answers for the security questions cuz i forgot them

    Hi, i didn't put a rescue email and i need the answers for the security questions cuz i forgot them

    If you can't remember your security questions / answers go to  Express Lane.
    select iTunes from the list, then iTunes store.        On the next screen select account Management.  There, select iTunes store account security and write that you would like to reset your security questions and / or answers.   You should get an eMail reply over the next 24 hours.

  • HT4970 I bought a printer Polaroid POGO, MINI PRINTER. I can not connect it via Bluetooth with my iPhone 4. Is there an app to solve this problem, because I'm Judicial Medical Expert, and I need this tool for quick things. grateful

    I bought a printer Polaroid POGO, MINI PRINTER. I can not connect it via Bluetooth with my iPhone 4. Is there an app to solve this problem, because I'm Judicial Medical Expert, and I need this tool for quick things. grateful
    Max Cavichini
    Medical Legal Expert
    Problem ipad and i phone

    This has never been a feature of iphone,ipod touch or ipad.

  • How to pull sales orders based on a Campaign??( I have created one Campaign and i need to know,for how many orders it was applicable)

    How to pull sales orders based on a Campaign ID??( I have created one Campaign and i need to know,for how many orders it was applicable)

    Hello,
    as far I understand you are talking about campaign determination. Once a sales order is generated having a campaign determined the campaign creates a reference to the sales order. The best way to track the assigned sales orders is using the related transactions function:
    The same feature is available for trade promotions as well.
    The data is available in table CRMD_BRELVONAE - you can also write a report selecting on OBJGUID_A_SEL with the campaign or TP guid and OBJTYPE_A_SEL with BUS2010020 for campaigns and BUS2010030 for trade promotions.
    Is this answering your questions?
    best regards,
    Johannes

  • I have a older ipod and i need a charger for it the model

    help please i have an older ipod and i need to find a charger for it please help model number m8541

    So, if that is your iPod model, and you have a computer with a FireWire port, which even the current Macs do not have anymore, the cables are commonly available.  However, the one to get depends on the type of FireWire port you have on the computer.  The two likely types are 6-pin (older FireWire 400) and 9-pin (newer FireWire 800).  Your iPod has the 6-pin (400) port.
    Apple-centric vendor OWC has a selection of all types
    http://eshop.macsales.com/catsearch/firewire+1394+cables
    If your computer has 9-pin (800), you need a 6-pin (400) to 9-pin (800) cable.  If it has 6-pin (400) that looks like the port on the iPod, then you need 6-pin to 6-pin.

  • My IPad mini wifi only has been glitching out since the beginning of term 2 of my school year it has been very annoying and I need my device for school as I'm in a E-Learning class!!!!!!!!!!!

    I need my Ipad for school!

    Not me.  Neither I nor anyone in my family has had any problems with any of our iDevices upgrading to iOS 6.
    Probably user error or faiure to take the recommended troubleshooting steps.

  • I have cq40-317tu machine and i need audio driver for xp

    Laptop Model CQ40-317TU
    OS Winxp Proffesional
    Sound driver URL Needed

    Hi:
    Please read the XP downgrade guide at the link below:
    http://h30434.www3.hp.com/t5/Notebook-Operating-systems-and/General-XP-Downgrade-Guide-for-HP-Laptop...
    The downgrade guide help for your model series can be found under the section labeled 3. Difficult Models
    Carefully read and follow the guidance to install the audio drivers on your machine. The audio drivers are the most difficult to install.
    Paul

  • About clsid and more in object tag for deployment

    I've found it a bit hard to get up-to-date information about the best-practice for writing applet/object/embed tags in html when deploying java applets. Anyway, I found this.
    <!--[if !IE]> Firefox and others will use outer object -->
    <object classid="java:com.myCompany.MyApplet.class"
            type="application/x-java-applet"
            archive="../MyApplet.jar"
            width="400" height="600">
        <param name="mayscript" value="true" />
        <param name="someParameter" value="someValue" />
        <!-- Konqueror browser needs the following param -->
        <param name="archive" value="../MyApplet.jar" />
    <!--<![endif]-->
        <!-- MSIE (Microsoft Internet Explorer) will use inner object -->
        <object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
                codebase="http://java.sun.com/update/1.5.0/jinstall-1_5_0-windows-i586.cab"
                width="400" height="600" >
        <param name="code" value="com.myCompany.MyApplet" />
        <param name="archive" value="../MyApplet.jar" />
        <param name="mayscript" value="true" />
        <param name="someParameter" value="someValue" />
        <strong>
            Some error message...<br />
            <a href="http://java.sun.com/products/plugin/downloads/index.html">Download!</a>
        </strong>
        </object>
    <!--[if !IE]> close outer object -->
    </object>
    <!--<![endif]-->This code works in Firefox 2/3 and IE7 (on Vista). Would you experts here say this is an acceptable way of doing it, or do you have a better way to recommend?
    But there is one thing that was really hard to find googling, and that is what should the clsid ("clsid:8AD9C840-044E-11D1-B3E9-00805F499D93") and codebase ("http://java.sun.com/update/1.5.0/jinstall-1_5_0-windows-i586.cab") be if I want the applet to run in the latest Java version? Or at least 1.6.0 instead of 1.5.0 since I compile the applet using jdk1.6.0_06.
    And wouldn't www.java.com be a more user-friendly download link instead of http://java.sun.com/products/plugin/downloads/index.html? On this site it says "The above default release, 1.4, is the latest release of Java Plug-in." and links to http://java.sun.com/j2se/1.4.2/download.html, which in term says "J2SE 1.4.2 is in its Java Technology End of Life (EOL) transition period." Why couldn't Sun keep their web sites a bit more up-to-date?

    >
    Isn't it anybody here that wants to share...>I look at questions with Dukes, but when I open a thread and it turns out it has less than 10 dukes, I take it is 'less than imperative' to the original poster to fix the problem - so often move on to the next thread/post.
    What do you think 3 Dukes indicates to someone like me? (Oh go on, guess - it'll be fun.)
    >
    ... how you usually write your applet/object/embed tags in the html file? I'm interested in "new" development for Java 6, i.e. no legacy support for older code needed.>You might check out the deployJava.js which is described in the latest [deployment advice|https://jdk6.dev.java.net/deployment_advice.html].
    If you find that answer works for you, and you appreciate the advice, the best way to show it is to raise those Dukes before assignation.

  • Add advanced action to submit button and setting different objectives score for the same course

    Hi, i would like to increase a counter in a quiz slide when the user press the submit button, using advanced actions.
    It's like if the submit button is somehow inhibited from certain options, and i cannot find how to add an advanced action to it.
    what i need, is to allow unlimited attempt until the user selects the right answer. each time the user click on submit, a counter increases by one. When user finally select the right answer, we read the counter value and assign a different score, depending on the attempt (for example: 1st attempt=20 points, 2nd attempt=10 points, 3rd attempt=0 points)
    After that, i need to save all score obtained for a certain group of quiz slide separately from the "main score" (i think the main score is stored in cmi.objectives.0.score)  to have partials scores for a course. I examined the "advanced interactions" panel and i noticed that for each quiz slide there is a specific interaction ID and each quiz slide is associated typically to the same Objective ID. What i need is to associate different groups of slides to different Objective ID's.
    In Storyline i was able to do this by passing to the lms a cmi.objectives.n.score (where "n" is the place in the objectives array) and i did it by executing a javascript on success for each question slide. (each javascript added the score of previous slides in the same group to obtain the total score of the group to be passed to lms with a specific function).
    examining captivate scorm functions in the published scormdriver.js i found the following function
    function SCORM_SetObjectiveScore(strObjectiveID,intScore,intMaxScore,intMinScore)
    so i think it can be done the same way in captivate executing javascript in the right way.
    Is there also an easier solution to write different scores to different obectives in the same course?
    many thanks for any help!

    Have a look at:
    Question Question Slides in Captivate - Captivate blog
    Question Question Slides - Part 2 - Captivate blog
    Indeed, Submit button is part of the Question slide, not a normal button. You can add a custom shape button, but it will never replace what happens when the Submit button is clicked: validation of the answer, showing captions, adding to score etc. Making the score depending on the attempt is not possible with default functionality, it is possible with custom question slides, but then the reporting to LMS is another issue. You should try to do it by JS, or if you only need SWF-output you could use the Master widget by InfoSemantics.
    Link score to attempts in Custom questions - Captivate blog
    Lilybiri

  • I lost my Blackberry and I need a solution for preventing informatio​n from being seen.

    HELP! I lost my business BB Curve 8320 the other day. It was supposedly found and the person was going to mail it to me, but I haven't heard from him in 2 days. Is there any way to prevent him from looking at business classified emails on my phone? I do not have a password on the phone and called T-Mobile (my carrier) who says I am out of luck. Can you delete an email address or anything? I really don't want my information in the wrong hands.
    Thanks for any help anyone can provide!!

    Hi
    Sorry to hear your trouble. maybe its in the mail as we speak.
    If you have a BIS account, you could log-in on PC and edit/delete it. If you run on BES, your admin will need to sort it.
    Blackberry Best Advice - Back-up weekly
    If I have helped you please check the "Kudos" star on the right >>>>

  • How to get XI projects requirements? What and i need to ask for Project ?

    Hi Experts
        I know XI for some extend but i don't know any thing about requirements
        Next week i have meeting with client so what and all things i need to ask ?
        Pls...guide me on this
    It will be really helpful to me.....
    adv thanks and points to all
    Regards
    Kiran LVS

    Hi Kiran
       In addition to the above link  are the things you can ask the client to get the requirements
    1) What is the problem? This will give answer for why they are going for XI? Here try to 
        Understand the business as well as integration? Where XI come into the picture?
    2) Total number of systems involved in integration? That is their SLD? Details?
    3) Scenario’s (interfaces)? Total? What kind of? But here once again this is depends on project
        Some times client will give this (or) based on the requirement you people have to decide?
        It is fully depends …..!!!!  take care
    4) Then based on the scenario you need to get the full information ....this is
        place where you can ask all the questions …from scenario to scenario ….get all the details as
        mentioned below
    apart from the basics try to ask some thing technically
    5)  Are they providing any XSD,WSDL, documents, Naming conventions..etc
    6) Protocals related like http, ftp, smtp, soap....
    7) If file related then CSV, Fixed....like that delimiter specific details ….very imp this one
    8) If R/3 present then ....it is Idoc, Rfc, BAPI,....any proxies and webservices for
       direct communication ....etc
    these are the basic things for XI integration project and after that every thing is specific to
    scenario’s
    Same time check in the SDN with key word “XI Requirements “
    I hope this will help you to face the client but before that try to understand the client business and systems…..!!!!(Imp)
    Regards
    Prasad K

  • New Retina iMac and i need a recamendation for a UPS

    Hello all,
              I just purchased a Retina iMac with 4GHz i7, 32gb ram, 256 ssd, r9 m295x 4GB gp. What type of UPS(Battery Backup) do i need? I have read many different articles but they all seem to contradict each other. I noticed that apple has this for sale in the online store http://store.apple.com/us/product/TY121LL/A?fnode=5a however it does not tell me what mac's it will work on. I know the battery capacity is enough but I'm not sure if this is a pure sine wave or not. I have read that you need a pure since wave for a Retina iMac. Any advice would be greatly appreciated.
    Thanks in advance
    Joshua

    Macnerd08,
         I purchased a 5k iMac with similar specs a couple months ago and wanted to get a battery backup to protect my investment. I currently have my 5k iMac connected to an APC Back-UPS Pro 1000. I was unaware of the sine wave power issue with some of the Macs until after I bought this UPS. However, the Pro 1000 works great with my iMac. The power has gone out twice since I've had it and I had plenty of time to save my work, close my programs and shut down my computer. I've had no issues.
         My only gripe with the UPS is the clicking noise it makes every time my computer shuts down or goes to sleep. It's not that big of deal but it can be annoying if you put your computer to sleep at night and then the UPS clicks on at 2am when you're trying to sleep. I believe this can be avoided if you turn off the power saving feature but I normally just shut down my computer when I'm done using it. That prevents unnecessary clicking once the computer is off.
         I've had no experience with any other UPS so I can't speak if the Pro 1000 will work with other mac products but for the 5k iMac, it works great! I unplugged my UPS and wrote this review with the battery back up to prove it! Estimated run time was over 100 minutes, the only application open was Safari. Hope this helps!
    Spencer

Maybe you are looking for