Stupid questions about keeping important calls on the FX application thread

I'm working on a project that I've been developing for about the last 6 months. I'm using JavaFX as the graphical side, but I'm taking input from a music processing program called Max/MSP, and I'm getting user input from a camera. Both of these things need to run on separate threads from my FX application thread. Up until now, things have been going smoothly. I can manipulate things on screen from my user input, and I have two way communication working between my JavaFX application and Max. Now, however, I need to start actually drawing stuff at runtime. Up until now, pretty much all FX side manipulations of been to just make translations. I now need to create, add, and remove children from Nodes. So I'm of course getting an error saying "not on FX application thread". I understand why it isn't on this thread, and why this is a problem. So I made some changes, so that calls that will make changes to the nodes on the stage, will only note the data, and then make the changes later, on the FX application thread. And then I run into problems, involving my own stupidity...
I have no idea how to get these calls onto the FX application thread. I mean, this should be really easy. I'm obviously missing something. Or maybe I'm just really tired, and have been looking at this for too long, or maybe the fact that it's been 6 months since I wrote this part of the code. But I see my Mainstage class, which extends Application. It has a start function, which sets up all my on screen do-dads (extended from Nodes and such), calls stage.show()... and then seems to end. When I've done things like call translate functions on my nodes from my user input thread, or from my communication from Max thread, things seemed to have worked. But now I'm thinking I might have been handling that wrong from the ground up. It seems likely that I should be having a "main game loop" (it isn't actually a game, but still, same principle) where I can tell the stage to update all the various nodes with the changes that have happened since the last frame, and try to get everything to update in time for the graphics to render at a reliable frame rate. And yet, I'm just not seeing how to do that. I'm sure this should be obvious, but I'm flat out blanking. And the time crunch is starting to descend... Please, if you can point out some standard way of avoiding this hopefully common newb mistake, I would greatly appreciate it!
-cullam

Checkout the documentation on "Pulse" in the JavaFX Archictecture overview which may help clarify some of your questions.
http://docs.oracle.com/javafx/2.0/architecture/jfxpub-architecture.htm
In simple terms, as I understand it, the framework will check 60 times a second if anything is dirty and needs repainting. If everything is clean, it will do nothing. If something is dirty, it will repaint it (although the repaint is kind of clever and highly optimized to support region image caching, make use of hardware rendering, etc).
So you can see that the main rendering loop is essentially hidden from you. Instead you construct a SceneGraph, the system checks regularly whether or not the SceneGraph has changed, and if it has it renders the updated SceneGraph.
In most JavaFX applications, you have a UI with controls and add event handlers which respond to control input to update the SceneGraph. In such programs, creating a main loop is unnecessary.
You can set up an animation timeline say at, for example, 30fps (half the pulse rate), then, on every other pulse, nothing will have changed so no redraw will happen. This is only necessary if you are performing an animation or capturing camera input, etc yourself (rather than using a Transition for example).
Actually, if I get my state changes working properly in a runLater call, do I need to also write a main loop? No, you don't need to write a main loop. Depending on the exact application, you may want one, but if you are already getting events generated by your camera input at 30fps, processing each 30fps from the camera in a runLater call would work fine without creating a loop.
But you do need to be careful that you don't send too many runLater calls and eventually overload the JavaFX event queue. For example it makes no sense to make more than 60 runLater calls a second to update the scene, because the system will never update the scene more than 60 times a second anyway.
If you do get a working camera app integrated with JavaFX, please post or blog about it as I am sure many people are interested in such an application.

Similar Messages

  • Hello , I want to ask some question about ipads \  How powerful is the iPad?  How useful is it for reading books, newspaper or magazines or for surfing the web? Can you identify any shortcomings of the device?   please help me :(

    Hello ,
    I want to ask some question about ipads \
    How powerful is the iPad? 
    How useful is it for reading books, newspaper or magazines or for surfing the web?
    Can you identify any shortcomings of the device?  
    please help me

    it's less powerful than your average computer. THink of it like a netbook but with a better processor.
    It'll do fine for surfing (although if you browse a lot of flash based sites you will need to get a third party browser since safari doesn't accommodate it)
    You may do OK on reading books, papers or magazines, especially if they have apps, but the ipad's screen is backlit, so it doesn't work well outdoors and you may need to fiddle with the brightness so that you don't get eye strain (it's just like doing too much reading from a computer screen)
    I would say the biggest short comings are data transfer. Apple's preferred work flow is that everything is done via iTunes or the internet....well people dont' always have 100% reliable always on internet access so you can find yourself in a situation where you can't get things on/off the iPad.
    By and large, it's a good device for day to day stuff, but is not a computer replacement.

  • It does not cover my question about in what order does the sync work?

    It does not cover my question about in what order does the sync work?
    Does the first signed on computer copy its information to the cloud?
    Does the second computer/pad/cell then download the information from the cloud overwriting the information on the second device even if some of the information is different?
    What happens to the information on the second device that is not in the cloud?
    If you delete a record (eg a bookmark) from the second device how does it then delete it on the first device?
    What are the keys to the different types of information?

    Hi I have answered you questions inline below:
    Does the first signed on computer copy its information to the cloud?
    Yes when you first set up the account or when you first add a device to the cloud, if it is not the first time, it will merge with the other data
    Does the second computer/pad/cell then download the information from the cloud overwriting the information on the second device even if some of the information is different?
    By default it merges. There is no option to change this.
    What happens to the information on the second device that is not in the cloud?
    It will sync at the next sync interval if that data is selected to sync.
    If you delete a record (eg a bookmark) from the second device how does it then delete it on the first device? What are the keys to the different types of information?
    It resolved the entry the next time the first and second device syncs. Can you elaborate on the second part of this question?

  • My phone keeps dropping calls.  The phone reads call failed!

    my phone keeps dropping calls.  The phone reads call failed!  (as this is how I find out where I am working each day.  I am losing money Help!)

    Settings > General > Reset > Reset Network Settings
    If the issue persists, contact the carrier.

  • Direct calls within the oracle application server to the IIS using reverse

    trying to direct calls within the oracle application server to the IIS using reverse proxy. I am having problems...
    What is trying to be achieved is a call to the 3rd party web server (IIS with Oracle SSO plug-in) that will be invoked from the OAS.
    Any suggestions

    First you might get more response if you move your question to following forum:
    Oracle Application Server - General
    Second, I didn't quite understand your question. Can you pl. clarify it bit more? What exactly do you mean by invoking IIS from OAS (I am assuming by OAS you mean OC4J here)?
    Thanks
    Shail

  • Question about using multiple iPods on the same PC

    I've read the FAQs on this subject but I still have a couple of questions about multiple users with separate iPods using the same PC.
    I want to use my family's desktop (A new Gateway with Vista, if it matters) for my new iPod Classic, but my father already has an iTunes account on there for his iPod. I know I can create a new user account on the PC and move iTunes to a shared folder so that we can share music, but will this second account be able to purchase music from the iTunes store or am I going to have to switch between Windows User accounts to make purchases and then move new songs into my separate iTunes account via the shared folder? Will it be its own separate iTunes account (separate user name, separate credit card used, etc.) or will it just be a second library that's dependant on the first?
    I want to be able to have my own iTunes account, make my own purchases in it, and maybe occasionally share tv shows or something with my father.
    If this can't be done, would I be better off just creating new playlists for our two iPods from the same library, or creating a second library on my Father's account?
    Also, if I want to access things I've purchased from iTunes on this desktop in iTunes on my notebook, will I be able to?
    I hope that made sense.
    Sorry if these seem like silly questions. This will be my first iPod as I'm really excited about the 160gig and want to know if these things are possible.
    Thanks in advance for any help

    Hi, Wes.
    Congratulations on your new iPod Classic and Welcome to the Apple Discussions.
    For no particular reason, let's answer your last question first ...
    ... if I want to access things I've purchased from iTunes on this desktop in iTunes on my notebook, will I be able to?
    The iTunes Store operates on a one download per purchase policy so you will have to copy the purchases from one computer to the other and make sure that you authorize the laptop to play the songs.
    As to your first question ...
    ... will this second account be able to purchase music from the iTunes store or am I going to have to switch between Windows User accounts to make purchases ...
    Whatever XP User Account you are logged in to doesn't really matter. What's important is which Apple Account you sign in to ... yours or your Dad's or - if you had my Apple ID and password - The Mimico Kid's for that matter. You can sign in to any Apple Account on any XP User Account. Or any computer for that matter.
    Where the XP User Account comes into play is that it will determine where on your computer the purchases are downloaded. Files will be sent to the iTunes Music folder as specified in the iTunes Edit menu > Preferences > Advanced tab > General sub-tab. Default settings will have a different location for each User Account - C:\Documents and Settings\ user name \My Documents\My Music\iTunes - but if you've read this article in the Apple Knowledge Base, you will know you can change the location of the iTunes Music folder in each XP Account to a common location such as C:\Documents and Settings\All Users\Documents\My Music\iTunes.
    Post back if all this hasn't been as clear as mud and you need anything clarified.

  • Probably a stupid question about cropping a video..

    OK, so I shot an interview with a black background and once I went to edit it, I noticed a red object in the far right corner. Is there a way I can add black over this object or crop it out? I know this is a stupid question, but I'm new to video and editing in general so I thought it wouldn't hurt to ask.

    There are several ways to accomplish what you want.
    KGCW has talked about the Crop Effect.
    Depending on exactly where the object is, and whether the camera was locked down, it might be possible to duplicate your Clip, place it above your initial Clip, then offset it a bit (Motion>Position), with the Fixed Effect>Motion>Position, and then apply the Garbage Matte to that offset duplicate, effectively Cropping out everything, but a small "patch" from the existing background. Note: if the edges of that Garbage Matte are too hard for you, you could create a soft-edged Track Matte, and use that to hold out the rest of the offset duplicate.
    Another method, and depending on where, and how large the offending item is, would be to go to the Fixed Effect>Motion, and use Motion>Scale to increase the size of the Clip (do not do too much Scale, or quality will suffer). You might also need to do a bit of Motion>Position, to get that red object behind the Video's Frame Size. This will effectively Crop the object.
    Good luck,
    Hunt

  • A Question about contacts that are in the history

    Hi, I am a novice in the Mac world and have a 2 part questions.
    1- I deleted my bosses Pop Account and lost all his email. I used File Salvage to get them back. No problem I found all 3235 of them. I cannot figure out how to get them back into the Mac Mail program? I tried hiring two Mac companies and they still could not do it. Any suggestions?
    2- When I re-created his Pop account in the Mac Mail program all his contacts were still there in the history. So when you start to type the persons name it brings up the whole name and Email address. Where can I find the hidden historyfile with all the information in it so I can import them into Entourage. Even if I could not import them I would like to be able to print them out and wwill type them in individually myself. I really need to make my boss happy again. Any Suggestions

    Hi Combreeze2.
    I cannot figure out how to get them back into the Mac Mail program?
    Mail doesn’t import individual messages, only entire mailboxes. In order to import .emlx messages in Mail, they must be organized as if they were in an .mbox mailbox, i.e. they must be in a Messages folder within an .mbox folder. You may create a folder called Recovered.mbox, then a Messages folder within this folder, then put the .emlx files within the Messages folder, then import that.
    In Mail, do File > Import Mailboxes, choose Mail for Mac OS X as the data format, and follow the instructions. Note that Mail wants you to select the folder that contains the mailboxes to be imported (i.e. the folder where the .mbox folders to be imported reside), not the .mbox folders themselves nor the Messages folders within them.
    Given the circumstances, however, there could be something wrong with one or more of the recovered messages and that might cause the import to fail. If that’s the case, you may try organizing the recovered messages in several smaller mailboxes and try to identify the messages that Mail has trouble with. Alternatively, you may try using emlx to mbox Converter or Emailchemy to convert the .emlx files to standard mbox format, then import that in Mail as Other.
    Where can I find the hidden historyfile with all the information in it
    Window > Previous Recipients
    I don’t think there is a way to print that info or import it into another application without adding them to Address Book as regular contacts first.

  • Keeping Swing calls on the EDT, app code off the EDT, and boilerplate code

    I have been reading about the EDT and Swing for a while now and I have not been able to find very good tutorials or explanations. I understand that swing calls should be on the EDT and I have seen hints about application code needing to be on its own thread, which seems obvious. I have seen code for how to do this, but it seems like in order to really enforce these rules, I'd have to setup invoke SwingUtilities.invokeLater on all my swing related functions (I have a ton of them), and then for non-swing related functions, I'd have to constantly check to make sure they are not on the EDT with javax.swing.SwingUtilities.isEventDispatchThread?

    BoBear2681 wrote:
    Also keep in mind that many very quick non-UI tasks can safely be done on the EDT. For example, if you load a very small text file (a few KB), this is usually so fast that there's no need to do it off the EDT. Just pointing out that not literally everything needs to be done off the EDT, just anything that runs long enough to produce a noticeable unresponsive pause in your GUI. Users are okay with an application taking 0.1 seconds to open a file, for example. But doing 10 seconds of number crunching, connecting to a remote server, etc. are the kinds of things you'd want to do off the EDT.That's extremely true, and I meant to touch on that but forgot (yep, my memory is so bad that I forget what I was going to type in the amount of time it takes to post a reply).
    When I first started to figure out the EDT, I became paranoid about keeping non-GUI stuff off of it. However, I've since realized that sometimes it's unavoidable, and usually it doesn't matter anyway.

  • A very stupid question about MDic application[SOLVED]

    I have tried StarDict in Arch which I think that is the best known dictionary application in Linux world. Since I had to use mouse to access StarDict, I decided to try MDic instead. My problems is that I do not know the default location of MDic dictionary files. After search topics for about two hours, I gave up.
    There must be a directory where MDic searches for dictionary files. Where is it? or What MDic configuration file has the information? So, I can install dictionary files int to the directory. I looked for this information in http://mdic.gnufolks.org/ and google.com. I believe this kind of very fundamental information should be in the wiki fo MDic. But I couldn't find one. Maybe, it is because I am so idiot. Would somebody help me how to install MDic dictionary in a appropriate location or the default location? Thank you so much for your helps.
    Last edited by since1992 (2010-11-06 11:28:30)

    Yes, it was a stupid question. I found that I can configure the location of the dictionary file. I also installed PyGlossary to convert dictionaries for MDic. Everything works fine now. Thank you.

  • Probably a stupid question about upgrades...

    I originally bought Adobe CS3 Web Premium and upgraded to CS5.5 Design Premium last year.  I'm wondering if I upgrade, will my price be based on the CS3 license or the CS5.5 upgrade...?
    I'm guessing it will be based on CS5.5, but I want to make sure.
    -A. Ka

    There are no stupid questions!
    Regardless of whether you got to CS5.5 via upgrading to it or by originally licensing CS5.5 is irrelevant in terms of the upgrade price to CS6 as well as the media you use for the upgrade.
              - Dov

  • Quick question about making system calls

    hello all
    i have a simple quick question regarding making system calls. Basically I want to mimic the command "system" for perl. I am not quite sure how to do this for java.
    any feedback would be appreciated.

    look at:
    java.lang.RunTime

  • Question about Keep Alive feature in Forte 3.

    Does anyone use Keep Alive feature under Forte 3.0F.2 environment.
    I got trouble and encounters the following problem in the service objects
    daily:
    INFORMATION: An abnormal disconnect from partition
    (CFFE2500-85B0-11D1-B37F-E2F7F3F1AA77:0xec254) was received. Since there
    are
    no method invocations outstanding to this partition, no notification could
    be
    given of this disconnect (by indicating a method invocation failed).
    Therefore, the information associated with this disconnect is being
    reported
    to the log.
    Class: qqsp_DistAccessException
    Error #: [601, 119]
    INFORMATION: The connection to the partner was terminated by the
    Communication Manager for the reasons below.
    Class: qqsp_DistAccessException
    Detected at: qqdo_PartitionMgr::StopLocation at 1
    Error Time: Fri Nov 26 17:45:39
    SYSTEM ERROR: Failed to establish connection: OS Error 61: Connection
    refused
    Class: qqsp_DistAccessException
    Detected at: qqcm_HoseFSM::SetError at 5
    Error Time: Fri Nov 26 17:45:39
    SYSTEM ERROR: hose 15 STATE_CONNECTING (EXT_RECEIVED) from
    qqcm_HoseFSM::IssueConnect (after EstablishConnection)
    Class: qqsp_ErrorDescriptor
    Detected at: qqcm_HoseFSM::SetError at 1
    Error Time: Fri Nov 26 17:45:39
    It seems that Keep Alive sometimes disconnects the connection between the
    service objects and the environmental manager.
    So that any further connection request from the client encounters the
    abnormal exception.
    Forte seems not to recommend to use this feature in the Forte Relase note
    3.0J1.
    She states that "Sites that chooses to test KeepAlives should report all
    problems to Technical Support ( and let
    Technical Support know that you have enabled this capability)"
    Should I disable Keep Alive feature under Forte 3.0F2 environment?
    Rgds
    Tom

    Hey Marco,
    I can`t find a view that is named like "APEX_APPLICATION_PAGE_IR%". Is it not available on the evaluation instance.
    I don`t want to use the build-in CSV download, becaus I want to export thousands of data sets. I got this already to work with APEX 3.0 and I get the sql from the application views. The procedure which creates the file runs a few hours and after that it is inserted into a table from which the user can download the file. In the procedure there happens a few other things, which are very import, so I have to create my custom solution.
    And for that I thought it would be very very very cool if I can get the sql behind the interactive report with the filters ant those things.
    Don`t you think that would be possible? I guess the APEX create a SQL although, or am I wrong?
    Thank you,
    Tim

  • Stupid questions about float operation

    Hi guys.
    I have this code:
    public class Stupida{
         public static void main(String args[]){
              float uno = 14.8210f;
              float due = 14.7110f;
              System.out.println("" + uno + " - " + due + " = " + (uno-due));
    and this is the output:
    14.821 - 14.711 = 0.10999966
    Why the result it's not 0.110????
    I tried with double, but the problem's the same.
    I tried to use the "strictfp" modifier, but the compiler doesn't recognize it.
    What should I do to get the exact result?
    Thanx,
    Pierlu.

    and this is the output:
    14.821 - 14.711 = 0.10999966
    Why the result it's not 0.110????Because floating-point calcuations are inherently imprecise.
    I tried with double, but the problem's the same.If you use double, the answer should be more accurate - you still can not expect it to be precise.
    I tried to use the "strictfp" modifier, but the
    compiler doesn't recognize it.Then you should get a new compiler.
    Even so, the result you have posted is what I got using the strictfp modifier.
    What should I do to get the exact result?I'm not going to go into detail because there are many threads in the forums that already cover this, and there's plently of good technical explainations on the Web - you just have to do a couple of simple searches.
    In short, there are a couple of ways to get correct results. The safest is to use BigDecimal. Another (faster) option is to perform all your calculations using int or long, and keep track of where the decimal point should be, then add it in afterwards for display purposes (however, this requires a prior knowledge of a bounding range in which the figures you are operating on lie).

  • Stupid question How to Import into Motion???

    Just curious how to import video into Motion, can't get it to go. I use a sony ex3, and Final Cut Pro.
    Help please, just getting started!!! Thanks ahead of time

    FCS is sooo easy to use it's insane... easy way to import - right click the clip in FC and Send To~ Motion / Color
    That's the ultra basic persons way :P

Maybe you are looking for

  • Can Romanian Companies open a iTunes store and sell audio content  ?

    Hello dear friends, I own a Romanian Company that produces audio content. I wanted to know if Romanian Companies are allowed to create stores and sell their content online on iTunes. Before posting this post, I tried to find the answer to this questi

  • Ce550 with IE 6?

    Hi there. The CE550 has a java monitor for watching activity, but it doesnt want to work with firefox 1.5 or IE6+. All the updates to java etc are there, any ideas? thanks bob

  • Customised field at WBSE

    Hi, we have requirement of adding few customised fields in Basic data tab of WBSE. is this advisable to change SAP screen. We need to update this data at 1st level WBSE and its required to flow to all below level WBSEs. whether its achievable, if yes

  • New e-mail...

    umm this is kind of off topic... but i didnt know where else to ask it... umm how do i change the e-mail adress in my profile? thanks tina

  • Problem battery iPhone 4 after ios 6.1.2

    Problem battery descharge after actualitation ios 6.1.2