How to limit repainting to 75 hz in a Panel?

Hello all, I have created a geometrical editor and I want to limit refresh rate of the repaints when I am moving an object on the screen to 75hz (or to the monitor refresh rate) because it uses 90% of CPU when moving an object.
When user drags an object I:
- detect it in the mouse listener (drag method)
- move the object in the memory (tree of objects)
- I call repaint of the panel
How can I enable t his limiting? I know there is some class called BufferStrategy, can I use something similar in JPanel? Or does this swing automatically? Thanks

Everybody gave you very good advices, but nobody
answer the question "how to limit to 75Hz ?" !
What is the best way to do this ? I don't know, but I
can give my own solution until a Java2D freak give
the ultimate one :
Create a framecounter
1)Create a counter : each time you execute the method
that render a frame, increase the counter.
2) in paint method, get the
System.currentTimeMillis(). Compare it with the last
value to compute de delta of time. Compare the
current framecounter value with the last value. You
have the delta of framecount. Compute framecount
delta over delta of time then multiply the result by
1000 to get the current framecount by seconds. If
result is over 75, paint method should return. Else
you call the method that render a frame.
What do you think about that ? I'm using this
solution, and it gives a quite good Fps control. Note
that I do not compute the curent Fps until an amount
of time is past. Exemple : I'm waiting for the delta
of time to reach about 300ms before computing delta
of framecount. That give a better current Fps average
but approximates the Fps control.
Have you a better method ?For timing that accurate you would need to use System.nanoTime().
Another way of achieving a framerate lock of 75 fps, is to change to a fullscreen mode, with a DisplayMode that is refreshing at 75hz, then create a BufferStrategy.
The BufferStrategy will be vsync locked (if the hardware driver allows vsync'ing), this will make BufferStrategy.show() block until the next vsync signal occurs.

Similar Messages

  • How to limit sharing apps to only two devices? because i have an iPod touch and an iPad. i just want to limit the sharing of apps to those two.

    how to limit sharing apps to only two devices? because i have an iPod touch and an iPad. i just want to limit the sharing of apps to those two. because my brother is using my apple id too on his ipod. i want to limit it to mine only. tnx!

    You can go into settings and turn sharing off in the programs on the device you don't want to share too.

  • How to limit the max dialog no that one user can use at the same time?

    Hi,
    I meet one performance problem that one user can open 6 sessions in the GUI and he/she can run 6 reports at the same time witch could occupy 6 dialogs in the sap R/3 instance. It makes poor performance for other users.
    Would you pls tell me how to limit the no. of sessions one user can create at the same time or how to limit the no. of dialogs one user can occupy at the same time?
    Thanks a lot!
    I used this parameters in the default profile as blew:
    rdisp/rfc_check 1
    rdisp/rfc_use_quotas 1
    rdisp/rfc_max_own_used_wp 20 (means: 20%)
    It still didn't work.
    Sean

    Hello,
    We can reserve DIA W.P by giving value to the parameter :- rdisp/rfc_min_wait_dia_wp=1(default)
    that have to necessarily remain free for other users.
    This parameter is used to reserve a number of dialog work processes for Dailog mode.
    For eg. If 10 dialog w.p. are configured for the instance(rdsip/wp_no_dia=10) and the parameter rdisp/rfc_min_wait_dia_wp=3 is set,parallel RFC's can occupy a maximum of 7 DIA W.P.3 DAI W.P. always remain free for dialog mode.
    But now the question is how we assign/restrict this free dialog w.p. to the specific user.
    Reply...
    Regards,
    JUNAID

  • Mountain Lion: on the Notification Center notification and Mail:  how to limit notifications to an email account?

    Mountain Lion: on the Notification Center notification and Mail:
    how to limit notifications to an email account?
    At least, is it possible to choose what email account, the arrival of a message launch a notification.
    When running more than a dozen e-mail accounts, it may be appropriate to display only the notifications of one or two major accounts.

    Which os are you using?  Which Mail version are you using? 

  • How to limit the number of items in a KPI Status list web part?

    How to limit the number of items in a KPI Status list web part? There is no paging option for Business Category Status list or any limit can be made by changing the Item limit in default view unlike other SharePoint List web parts. So How to achieve it?
    Kindly help.
    Regards,
    ZA
    zzzSharePoint

    Hi,
    According your post, I know you would like to set the item display limit in Status List web part.
    In the web part, the number of items to display is based on the view which you selected when configuring the web part. The default view for status list is status list view.
    However, I am not able to limit the items’ display number of the status list view. After changing the items limit, the list item displayed would not match the number specified by Item Limit. Thus, it is not possible to limit the number
    of items in the Status list web part.
    It could be a potential issue in SharePoint 2010.
    We will log this issue to our suggestion box. As after the submission, we may not have any time guarantee when the fix may be released, but it may come out on next cumulative update.
    Appreciate your time and efforts.
    Thanks.
    Tracy Cai
    TechNet Community Support

  • How to limit the number of items that a list control can hold?

    Hi,
    I am using a Flex3 List control for one of my projects.
    I add drag & drop functionality to it, so that i can drag & drop elements from one control to another.
    How to limit the number of items that a list control can hold / can be dropped in a list control ?
    - Sen.

    1. Listen for the dragdrop event on the control you are dragging onto.
    2. check the length of the items in the dataprovider - if it exceeds your maximum override the default drop action with e.preventDefault(); (assuming you used e for the event on the handler).
    Regards,
    Mark.

  • How to limit the number of rows in a smart form , sap script.

    Can anyone tell me how to limit the number of rows in the output of a sap script/smart form. I have tried "protect/endprotect" in sap script but have no idea of how to do in smart form. In sap script the only way it has happened is by reducing the size of the main window.

    Hi,
    In Smartform also, why dont you try reducing the size of the window if you want to limit the rows in it. Also if you are printing Line Items in a LOOP, you can write
    LOOP AT T_ITAB FROM 1 TO N in the LOOP Node if you know how many records exactly you want to display in 1 Page processing.
    regards,
    Mahesh

  • How to limit  dimensions values of querybuilder

    Hi,
    I want to learn how to limit dimension value in query builder. i want, the user who run the querybuilder can not see a dimension value which i do not want to display.
    For example,
    The time dimension has "2000" and "2001" values as default which is defined in database. Normally when i run the querybuilder for create new presentation or calculation, In the dimensions panel of the querybuilder display all values of each of dimension. The user can select values which she/he want from that list.
    But i want to limit values which the user can see in the dimensions panel of the querybuilder. for this time dimension example, i want to hide "2001" value from the user. How can i do it. if there is any sample code, please share.
    Thank you very much for your helps.
    ilknur

    Thanks Thomas, excellent suggestions as always.
    If anybody wants more information regarding Thomas' suggestions please refer to
    Oracle9i OLAP Developer's Guide to the OLAP DML for the AW Permit command.
    In sumamry: To create permission programs, you define two programs with the names permit_read and permit_write. In these programs, you can specify PERMIT commands that grant or restrict access to individual workspace objects. In addition, you write these programs as user-defined functions that return a Boolean value, and the return value indicates to Oracle OLAP whether or not the user has the right to attach the workspace.
    For relational security there is an excellent tutorial on the database pages of OTN, follow this link:
    http://otn.oracle.com/obe/start/index.html
    then follow the links for Oracle9i Database Release 9.2.0.2 - Security - Creating Label-based Access Control. This module describes how to use Oracle Label Security to setup security based on label policies
    These security layers should be transparent to the OLAP metadata layer, therefore, once you have implemented your chosen security method your BI Beans application will only need to connect with the appropriate user to inherit the security layer. For more information see the Security section of the BI Beans Help:
    http://otn.oracle.com/bibeans/903/help/
    BI Beans product Management Team
    Oracle Corporation

  • How to limit the search scope in single site collection for SP2013?

    On our SP2013 farm, there is one web application and 4 site collections under it. At the beginning I was trying to setup 4 different "Content Sources" but Sharepoint warn me that I can only setup 1 source per web application.
    I don't want user search at site collection A get search result from B, C and D. Also I like to use continuous crawling. What is the best practice to achieve? Thanks.

    Hi,
    Please check this links
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/615edaa8-f522-4496-a57e-9681d83b0ac3/how-to-create-content-type-search-scope-depending-on-each-site-collection?forum=sharepointdevelopmentprevious
    http://sadomovalex.blogspot.in/2013/08/how-to-limit-search-results-to-current.html
    Please remember to click 'Mark as Answer' on the answer if it helps you

  • How to limit numbers of rows in a sortable table

    Hi,
    I created a table that shows the first 25 of over 200.000 rows. This table is sortable. That means that I cant use the topN function to restrict the total numbers of rows.
    Is there any chance mabe by using the advanced tab to limit the rows.
    Regards,
    Frank

    Hy,
    Take a look here :
    http://gerardnico.com/wiki/dat/obiee/obiee_limit_clause
    I had the same problem but unfortunately I don't have find how to limit the sql performed in a answer. You can only force your users to limit the number of rows returned by applying a filter.
    Regards
    Nico

  • How to limit threads in a Java QuickSort algorithm.

    With the following piece of code, I quickly run into OutOfMemory exceptions, since the code starts creating Threads exponentially. However, after waiting for a long time (for all the exception texts to print out, obviously making it slower than running it with one thread only), the program eventually ends with the correct result. Is there a way to run the code as is, but making sure that no more that x threads are running at a time?
    things I have tried:
    - sleeping the current thread - makes it slower than one-thread.
    - looping blank while Thread.activeCount() > x - doesnt work at all
    - suspending resuming threads based on the activeCount - doesnt work too
    Code:
    import java.util.*;
    import java.io.*;
    public class ThreadedSort extends Thread{
    private ArrayList<Integer> _list;
         public ThreadedSort()
              _list = new ArrayList<Integer>();
         public ThreadedSort(ArrayList<Integer> List)
              _list = List;
         public void run()
              threadQuickSort();
    public void threadQuickSort()
              try{
    if (_list.size() < 2)
    return;
    Integer pivot = new Integer(_list.get(_list.size()-1));
              ArrayList<Integer> left = new ArrayList<Integer>();
              ArrayList<Integer> right = new ArrayList<Integer>();
    //ListIterator iter = arr.listIterator();
              // *** optimize here
    for (int i = 0; i < _list.size()-1; i++) {
                   Integer next = (Integer)_list.get(i);
                   if (next <= pivot)
                        left.add(next);
                   else
                        right.add(next);
              ThreadedSort LeftThread = new ThreadedSort(left);
              ThreadedSort RightThread = new ThreadedSort(right);
    //          System.out.println(Thread.currentThread().getName()+" --> "+Thread.activeCount());
    //          Thread.sleep(4000);
              LeftThread.start();
              RightThread.start();
    //          System.out.println(Thread.currentThread().getName()+" --> "+Thread.activeCount());
              LeftThread.join();
              RightThread.join();
              _list.clear();
              list.addAll(LeftThread.list);
              _list.add(pivot);
              list.addAll(RightThread.list);
              }catch (InterruptedException ie) { ie.printStackTrace(); }
              return;
    public static void main(String[] args) { ///////////////////////////////////////////
              Random rand = new Random();
              ArrayList arr1 = new ArrayList();
              long before_threadedQuickSort, after_threadedQuickSort;
              try{
              FileWriter fout = new FileWriter("out.txt");
              BufferedWriter bw = new BufferedWriter(fout);
              before_populate = System.currentTimeMillis();
              for (int i = 0; i< 2000; i++){//***
                   arr1.add(rand.nextInt(2000000));
              after_populate = System.currentTimeMillis();
              ThreadedSort sorter3 = new ThreadedSort(new ArrayList(arr1));
              before_threadedQuickSort = System.currentTimeMillis();
              sorter3.start();
              sorter3.join();
              after_threadedQuickSort = System.currentTimeMillis();
              bw.write("time for threadedQuickSort: " + (after_threadedQuickSort - before_threadedQuickSort)); bw.newLine();
              bw.newLine();
              arr1.clear();
              bw.close();
              }catch (Exception IOException){};
              System.out.printf("\n\n");
    } //end of main
    } //end of class

    So you dont have to go thru the code:
    Quicksort:
    with one thread only I start the sorting by choosing a pivot from the initial list and then generating a left list (all values less then pivot) and a right list (all values greater then pivot).
    then i recursively call quicksort with the left and right lists.
    with one thread that works fine.
    threadedQuickSort:
    each thread object has a variable _list that keeps its list.
    from the initial thread, i do generate again two lists (left and right) but then i construct two threadable objects with those lists and start them, creating for each list a new thread.
    so each thread will create two new threads.
    for a initial list with up to 2000 rows, that yields to the correct result although much slower than the one-threaded version. maximum number of threads ever used was around 500~600.
    for a list with 20000 rows, my machine chokes at around 2600 threads. (OutOfMemory exception)
    My Processor is a 8 core (each core can run up to two threads) giving me a total of 16 actual threads i can work with.
    So the question is how to limit the threads that are created to 16. There is no method in the Thread class where you can specify the max number of threads in a threadgroup.
    @ jverd:
    I looked at ThreadPoolExecutor, but it looks kinda complicated. I see that the idea is creating a queue of jobs to be executed (which would be the different sublists (left and right lists), and then using the specified number of threads to work with the queued jobs, but im failing to understand how it works. Can you point to a simple example somewhere showing how to declare a ThreadPoolExecutor object and work with it. thanks

  • How to limit the number of boxes to tick in LC

    I would like to know the "javascript" in Lice Cycle to limit the number of boxes ticked
    for example i have 20 boxes and i would like that the client can only tick 5 boxes
    thank you

    Thank you Steeve
    But my problem is that i don't know which boxes the client will want to tick so all boxes have to be available at the beginning.
    When the client will have ticked 5 boxes in this case and only in this case, all others boxes must become unavailable so it is very difficult to set up
    if you have any idea
    thanks anyway
    Date: Fri, 15 May 2009 09:44:33 -0600
    From: [email protected]
    To: [email protected]
    Subject: How to limit the number of boxes to tick in LC
    This is a form validation issue. For example, you may have a text field and the value entered into that field determines which checkboxes must be completed to satisfy a validation or business rule. The attached sample requests the value "foobar" to be entered into a text field. If you enter "foobar" and exit the field, 2 of 3 checkboxes have the access property changed to "protected", meaning a user cannot no longer select those checkboxes.
    // form1.page1.subform1.input::exit - (JavaScript, client)
    if (this.rawValue == "foobar") {
        form1.page1.subform1.cb2.access = "protected";
        form1.page1.subform1.cb3.access = "protected";
    Steve
    >

  • How to limit the number of search results returned by oracle text

    Hello All,
    I am running an oracle text search which returned the following error to my java program.
    ORA-20000: Oracle Text error:
    DRG-51030: wildcard query expansion resulted in too many terms
    #### ORA-29902: Fehler bei der Ausführung von Routine ODCIIndexStart()
    ORA-20000: Oracle Text error:
    DRG-51030: wildcard query expansion resulted in too many terms
    java.sql.SQLException: ORA-29902: Fehler bei der Ausführung von Routine ODCIIndexStart()
    ORA-20000: Oracle Text error:
    DRG-51030: wildcard query expansion resulted in too many terms
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:169)
    When i looked up the net, one suggestion that was given is to narrow the wildcard query, which i cannot in my search page. Hence I am left with the only alternative of limiting the number of results returned by oracle text search query.
    Please let me know how to limit the number of search results returned by oracle text so that this error can be avoided.
    Thanks in advance
    krk

    Hi,
    If not set explicitly, the default value for WILDCARD_MAXTERMS is 5000. This is set as a wordlist preference. This means that if your wildcard query matches more than 5000 terms the message is returned. Exceeding that would give the user a lot to sift through.
    My suggestion: trap the error and return a meaningful message to the user indicating that the search needs to be refined. Although it is possible to increase the number of terms before hitting maxterms (increase wildcard_maxterms preference value for your wordlist), 5000 records is generally too much for a user to deal with anyway. The search is not a good one since it is not restricting rows adequately. If it happens frequently, get the query log and see the terms that are being searched that generate this message. It may be necessary to add one or more words to a stoplist if they are too generic.
    Example: The word mortgage might be a great search term for a local business directory. It might be a terrible search term for a national directory of mortgage lenders though (since 99% of them have the term in their name). In the case of the national directory, that term would be a candidate for inclusion in the stoplist.
    Also remember that full terms do not need a wildcard. Search for "car %" is not necessary and will give you the error you mentioned. A search for "car" will yield the results you need even if it is only part of a bigger sentence because everything is based on the token. You may already know all of this, but without an example query I figured I'd mention it to be sure.
    As for limiting the results - the best way to do that is to allow the user to limit the results through their query. This will ensure accurate and more meaningful results for them.
    -Ron

  • HT5100 How to limit the number of downloaded videos in parallel to one.i want my iPad itunesu to download only one video at once at time and when finished from downloading it to pass to the second queued one.

    How to limit the number of downloaded videos in parallel to one.i want my iPad itunesu to download only one video at once at time and when finished from downloading it to pass to the second queued one.

    @Tylerdowner: hmm.. maybe yes.. I just want to use the DOWNTHEMALL AddsOn for the saving file not the default download.. because my costumer download MP3 files and save it 3 or more files at a time so my Internet Connection goes down :( so I just want to limit them to save 1 file at a time.
    or if there is another way to limit it to 1.. please tell me :(

  • CISCO ACS, How to Limit User Session ?

    Hi Guys,
    hope you would help me,
    how to limit the user session in ACS 5.x ?
    i'm aware the menu on
    Access Policies >Max User Session Policy > Max Session Group Settings
    i already set the global value to 1, Max Session for User in Group to 1, and Max Session for Group to 1.
    so it means the user only could open 1 connect at the same time right?
    the problem, it didn't works.
    i had 1 ACS 5.5
    2 CISCO Cisco IOS Software, 3700 Software (C3725-ADVENTERPRISEK9-M), Version 12.4(15)T13, RELEASE SOFTWARE (fc3)
    (let's call it R1 and R2 )
    i'm trying to telnet both of them at the same time, and it works ( it means the session limit didn't works, cmiiw )
    i already include :
    radius-server attribute 44 include-in-access-req
    radius-server host 192.168.217.98 auth-port 1645 acct-port 1646 key somekey
    on the line vty :
     accounting connection acs
     login authentication acs
    am i missing something?
    also, is this feature works on tacacs+ too?
    Thanks,

    Dash,
    You can leverage the group mapping feature where members of a certain AD group are mapped to a local group in ACS with the max sessions defined.
    http://www.cisco.com/c/en/us/td/docs/net_mgmt/cisco_secure_access_control_system/5-3/user/guide/acsuserguide/access_policies.html#pgfId-1162308
    Thanks,
    Tarik Admani

Maybe you are looking for

  • How do i remove photostream from one computer and put onto laptop?

    When i got my iphone 4s i didn't have a laptop so i had to download itunes onto my mums computer. I now have a laptop and i want to take photostream off my mums computer and put it onto my laptop but its all so confusing. please help!!!!

  • PDF file not useful in iPad or in different PCs

    I just made a web form. It works fine in the test. I made a PDF that should allow direct ordering just by filling in which products to order and which amount.  The PDF works fine in my PC and I received the orders just fine. However, when I try to op

  • Bank Information in AP_SUPPLIER_SITES_ALL table (R12)

    All, My requirement is to query the bank information of all the supplier sites. When I query the 'sites_all' table, I can see the bank_account_num,bank_account_name and bank_num fields with Null value. But when I check the particular supplier sites i

  • Iphone music not showing up in itunes

    Help! My iphone 4S works just fine when i[m using it, but when I plug it into my computer it doesn't show my music in iTunes. iTunes no longer opens automaticallly when I attach the iPhone, although it is visible in the windows Device Manager and in

  • 2007.08 Don't Panic Isos released, installation feedback

    Hi Arch community, 5th August, 23:00 CEST (Central European Summer Time) Arch Linux Don't-Panic 2007.08 ISO release Get Archlinux ISOs in /iso/2007.08/{i686,x86_64} on your favorite mirror. http://wiki.archlinux.org/index.php/Mirrors or http://www.ar