How does the jvm handle drawing images outside an applet window?

I have a question about an applet I want to optimize.
Essentially the applet allows the user to scroll through a large map while viewing only a small portion of the map through the applet window.
The map has a large array of circles with coordinates on the map that are drawn in their appropriate place in the applet window when the user scrolls the map.
As it stands, the paint method loops through every circle in the array to draw them, but most of them are not visible in the window and end up getting drawn in a negative coordinate or a very large coordinate.
My question is are these circles that are not seen in the applet window but are still calling drawCircle in the paint method putting a strain on the computer's graphics card?
Would it be better if I looped through all circles and only called the drawCircle method on circles whose coordinates would be visible? Or would the extra step of checking each circle's coordinates before drawing be not worth as efficient?
Any help would be appreciated.

If the amount of stuff being rendered outside of the clip rectangle is small then it's usually not worth it to attempt to figure out what's being clipped and not draw it. If the clip rectangle represents only a small portion of the entire canvas that can be drawn, however, it's usually worthwhile to put in some logic to only draw what is necessary.
Take JTextArea, for example. It could be displaying a text document thousands of lines long. Instead of rendering every line of text on every repaint operation, it contains the following logic:
1. Get the current clip bounds (i.e. what part of the text area is "dirty" and must be repainted).
2. Figure out what lines are displayed in the clip bounds. Some lines may be only partially visible (a line "halfway" scrolled down), but they need to be repainted too. If word wrap is disabled this is a very quick and cheap operation, but if word wrap is enabled, it's a little more complex.
3. Only repaint those lines.
This way, in the best-case scenario JTextArea only repaints a single line (the line the user is typing in). Worst case, it repaints the number of lines that can fit on the screen. But it never repaints too much.
Anyway, I guess my advice would be: If it's cheap and easy to determine if something is out of the clip bounds, do it. If it's difficult to determine, do it only if you have a noticeable performance issue in your rendering code.

Similar Messages

  • How does the JVM handle private class parameters in a utility class?

    If I have a class that is public and not labeled as static, but it's constructor is private so that it cannot be instantiated, and all of its parameters and methods are both private and static. The methods modify the private parameters. In this case, the code explicitly is avoiding a singleton pattern, so there isn't even a class being instantiated, so this is a true utility class.
    However, the static methods are accessible from multiple objects, and as far as I can tell, the JVM is persisting the parameters in memory beyond the specific thread that called the static method to begin with.
    The question I have is how the JVM handles this? Are these private parameters assigned memory and are indeed persisted independent of thread, since there is no class reference. I am working with byte code injection, and the assumption is that a direct reference to a static parameter is much faster to call than having to go through an object reference. Of course, from a programmer point of view, I much prefer the singleton pattern since I am so used to hang my hat on a class reference.
    Thanks.

    entguru wrote:
    However, the static methods are accessible from multiple objects...Not if the methods are private, as you seemed to indicate ("all of its parameters and methods are both private and static").
    Are these private parameters assigned memory and are indeed persisted independent of thread, since there is no class reference. There is a class reference. It refers to the class, and is obtainable via the class literal; e.g., MyClass.class.
    ~

  • How does the iMac handle HD video editing?

    Tired of Window PCs, looking to buy an Apple System. I would like to do some video editing but want to make sure I get a powerful enough system from the start. How does the iMac handle HD video editing or should I look a better, faster computer?

    I have a mid 2011 iMac, 21 inch 4 GB RAM (the next to bottom iMac), Lion. I run Final Cut Express 4 with no difficulty (at least so far). It is certainly fast enough. My old G5, 7 years old, was also, and the iMac is faster.
    As I remember, I heard from someone on the Final Cut Express Discussions that some people might be having difficulty with FCE 4 on Lion, but I am a bit hazy. Its bigger brother, Final Cut Pro, is also available. I suggest that you post on the Final Cut Express or Final Cut Pro Discussion sites. They have many reliable users.

  • How does the TIFF format compress images?

    When we choose "File> Save As" to save an image to a TIFF file, a TIFF Options dialogue box appears with 4 image compression options( None, LZW, Zip, Jpeg). What is this for? Does the TIFF format compress images? Are they destructive to the image quality? THANK YOU

    If you select no compression, it will take up too much space, guaranteed.  TIFF lets you pick any compression method supported by your program and the viewing program.  Some are lossy, some are lossless.  Most TIFFs tend to be compressed in LZW or ZIP, both of which are lossless.  You can also choose to compress your TIFF using JPEG compression, which is lossy, but I can't imagine why you would do this instead of simply saving as a JPEG file, which is more likely to be properly opened in browsers than a JPEG-compressed TIFF file.
    And in response to one of the previous posts, not all compression throws away details from your file.  Only lossy compression (e.g., JPEG, or in the music area MP3) throws away data.  The lossless compression techniques simply encode the data in fewer bits if possible.  (One important fact not relevant to the web, where you will use 8-bit-per-channel files:  If your photos are 16-bit-per-channel, don't save in LZW compressed format; they will actually become larger than the uncompressed image.)  For a simplified example, if there is a series of 16 pixels of solid white, a losslessly compressed image will have code that says, in effect, 16 pixels of (255,255,255) using an abbreviated code instead of simply listing (255,255,255) sixteen times.  It builds up a directory of byte combinations and can use just a few bytes to refer to many bytes of image data.  Because the coding and decoding is exact, there is no change in the image data when it's opened.
    JPEG is a lossy compression technique that doesn't actually record pixel values at all.  It uses formulas to specify averages and changes within regions.  In effect, it records the fact that a given group of pixels has values centered on X color, and that the upper left is much pinker and the lower right is much greener than the average.  When you pick the degree of quality for JPEG compression, you tell it how small to make the comparison cells.  As you can imagine, if the image has text, tree branches, or other highly contrasty subject matter, this will cause serious weirdness if the comparison cells aren't very small (i.e., you don't have the quality set to max).

  • How does the JVM call Windows GDI Text functions?

    I need to find out how the JVM calls Windows GDI functions for Java running on Windows. I am a programmer at an imaging software company and we "hook" to client applications to extract information for searching and indexing. Basically what we do is tell the app to refresh itself and then we intercept the text output functions to the GDI. Recently, when trying to image enable an Oracle app (Sun JVM or bastard version thereof), we failed to capture any text output. None of the documented MS GDI text output functions are being called to display that text. Does anyone with an intimate knowledge of the workings of the JVM on a Windows platform know how this is accomplished. I currently have calls pending at Sun and Microsoft, but sometimes these forums have more info than they do. Thanks in advance for any help you can provide. ([email protected])
    Jason Nix

    I would venture to say that SUN is generating its own
    text. That would be necessary in order to handle all
    of the sizing and layout management issues which
    happen in Java real time, as opposed to Windows once
    at compile time.Not likely. Font rendering is always done at runtime and it would be generally unwise to do it yourself given the availability of TrueType fonts and the highly optimized rendering engines. I would be shocked if Sun tried to do it themselves.
    Chuck

  • How does the EDB handle deleted items and why am I only able to recover some and not all previously deleted emails?

    Hello,
    I have been unable to locate information regarding how the EDB handles deleted files.  I am able to recover deleted emails from the EDB; however, there are numerous emails that I know have been deleted, that were not recovered during the recovery process.
     Is this because the EDB dumps deleted emails once it reaches a certain amount of entries?  Or is it more likely the deleted items are corrupted and thus not recoverable?  Thank you for your time and I look forward to your responses.  The
    product in question is Microsoft Exchange Server 2007.

    Great information from the other posters and one other possible explanation is if the users did a HARD DELETE.  More information on this below
    Pre-Exchange 2010 Dumpster 1.0 worked as follows;
    1. When a user does a normal delete of an item via Outlook or OWA it gets sent to your deleted items folder
    2. If the user then empties deleted items folder those items are then marked with the ptagDeletedOnFlag attribute which in essence hides them from the view of the user
    3. At this point the user can use the Recover Deleted Items function in Outlook to recover those items as long as the items were NOT purged using the Recover Deleted Items option OR the items have not passed still the deleted item retention period.
    NOTE: Every day there is a nightly maintenance process that in short looks through  the DB and examines items that have been deleted. Items that have met or exceeded the deleted item retention period are purged from the system and are
    completely non-recoverable.  More about this at the end of my post.
    4. However if the end user were to  delete an item from the Inbox or another folder in Outlook by using Shift + Delete aka a Hard Deletion the item is left in its orignal location and gets marked with the ptagDeletedOnFlag attribute which again just
    hides it from view.
    5. By default you can only use the Recover Deleted Items option on the Delted Items folder.  Howeve you can make it so that you can recover hard Deleted items from other folders.  More on that here http://support.microsoft.com/kb/246153
    5. The problem with this method though IMO is that you have to know where to look and that can be rather time consuming.
    6. If you want a more elegant method to resolve this and are open to using 3rd party utilities check out Lucid8's DigiScope. 
    http://www.lucid8.com/product/digiscope.asp which will allow you to open any offline copy of the DB from a forensic point of view and to solve your specific issue you can either turn on a filter to ONLY
    show hard deleted items OR you can search the entire store and all mailboxes for just deleted items and can then view or export them to PST or MSG format.  You can download the product and obtain a 30 day demo license which will allow you to find any
    hard deleted items, however to view them or export your would need to purchase a license.
    NOTE: When a database is backed up or copied it is an "Offline" database and then its offline the data retention period is not an issue because the nightly online maintenance process can only act on a database that is mounted on an
    Exchange server.  So for this reason if you want to recover the most data possible use offline copies/backups of the DB with a 3rd party utility like DigiScope
    NOTE 2: Exchange 2010 and 2013 use Dumpster 2.0 which is an entirely different beast and I will not go into that in this post since its nearly 1AM  however DigiScope can expose that information as well
    Search, Recover, & Extract Mailboxes, Folders, & Email Items from Offline Exchange Mailbox and Public Folder EDB's and Live Exchange Servers or Import/Migrate direct from Offline EDB to Any Production Exchange Server, even cross version i.e. 2003
    --> 2007 --> 2010 --> 2013 with Lucid8's
    DigiScope

  • How does the JVM recover from a java.lang.StackOverflowError?

    As far as I know that whenever a java.lang.OutOfMemoryError is thrown, the application is in an unknown state and only a restart of the JVM can fix this. How about java.lang.StackOverflowError? If uncaught, the calling thread is terminated for sure, but the other threads? Are there side-effects?

    In windows OS that thread will die and thats all.
    I think that in some unix systems the whole process
    is likely to fail.Not exactly. It's not nearly as dependent on the operating system as it is on the quality of the JVM implementation. StackOverflowErrors are tricky to handle correctly in all cases, but most JVMs (including Sun's) now properly handle the vast majority of them. FWIW, most unix-based or unix-like operating systems make it somewhat easier to deal with StackOverflowError than Windows, particularly Windows versions prior to Win2K.
    A thread that triggers a StackOverflowError can actually catch it and recover; the important thing to note is that if you want to keep executing code on that thread, you have to allow many or most of the activations (i.e., function calls) on the stack to be unwound. Otherwise, you'll quickly provoke another StackOverflowError since you will still be close to the end of the stack.

  • How does the filesystem handle bad blocks?

    Let's suppose your hard drive develops a bad sector on it. What happens?
    I remember early products where the OS would constantly try to store new files right on top of the bad block, find the file couldn't be written/verified, then would write it elsehere... then the next time it would do the same thing again, expecting the block to "heal" I guess
    What happens on MacOS (extended, journaled) if it's writing a file and finds a bad block in freespace? Does the OS know how to "cocoon off" or tag the bad block as bad and not use it?
    Now what happens if the bad block develops underneath an active file? What's the recovery pattern? Or is there none - does it just leave the block bad permanently? Is there any way to fix that?

    Boot your computer from the DVD that came with it, and use Disk Utility to check the status of the disk. Select the disk and look at the S.M.A.R.T. status at the bottom. If it displays anything other than Verified, then the disk isn't going to last much longer.
    Modern hard disks don't develop "bad sectors" that the OS needs to handle. The disk drive itself automatically remaps bad sectors to spare unused sectors in a way that is transparent to the OS. When too many of those bad sectors are remapped, the S.M.A.R.T. status will report an error.
    What you're describing is a failing disk. It's more than likely the early stages of a total failure, rather than just a bunch of bad sectors. Same thing happened to my MacBook a few months ago. After about two hours, it failed completely. I picked up a new drive on the way home, and restored it from Time Machine overnight. The only data that I lost was an iTunes purchase that I made that morning (iTunes Support let me download it again). You have a backup, right?
    It's also possible that you've either run out of free space on the startup disk, or you have a process running that's consuming too much CPU and/or RAM resources. If that's the case, a reboot will clear it (until whatever caused it happens again).

  • How does the ASA handle Host Headers for a webserver

    If I have an IIS webserver with multiple private IP address, and a site assigned to each of these private IPs. I have defined all internal private IPs in the ASA and now I want to map 1 public IP to all sites on these different private IP's but need to use port 80, is this possible?                  

    I know this is a old thread and maybe no one is watching it anymore but I'm going to be dealing with a similar situation and trying to sort it out.  All my past experience is with non-Cisco products so I a not familiar with ASA (yet).
    In the original question here I think it is complicated by having multiple private IPs on the *same* web server. This should not really be. Since it is one server it can do fine with multple sites all runing on the same port 80 and the same IP# as long as they are separated via Host Headers.  If this were done then the question to me would be "Does the ASA retain the hostHeader when it passed the traffic back to the web server?" If the answer to that is "Yes" then the problem is solved.  The ASA does not need to "care" about individual web sites,...all it has to do is take whatever comes in on the Public IP on port 80 and send it back the the Web server on port 80 at whatever Single IP# it is (should be) running and then the Web Server software "sorts it out" and picks the correct web site to feed it to.
    Would this be a correct way to look at it?

  • Garageband/photoshop users: how does the MBP handle them well?

    since these are important apps for me before i buy
    can any of you pros tell me how its handling
    complex songs/photo files, RAW imaging and the like.
    im sure im not the only one interested in this area.
    is it faster and more powerful than its predecessors?
    thanks
    gl

    Garageband will be fine, since it's already Intel Native. Photoshop however is not and will run under Rosetta. If you are a heavy photoshop user you will notice the speed difference.

  • How does the viewcontroller class draw that cool "back" button?

    When you use a view controller, as you get deeper, you see the "back" button on the screen. I don't use a top level view controller, but when I get to my second level down, i want to add a view controller, with the "back" enabled. I figured it might be easier just to create a toolbar of my own and put in a button just like there. Is there a predefined system button that has "back" inside it? anybody know where this kind of tapered button shape is really stored on the system? or how to get this shape programmatically? Weird that apple doesn't have a programmatic interface exposed for this button type, which they are using.

    Ah, but when I am doing this manually, and since I don't have a previous view controller, I want to fake up this button because it has a nice shape; where is this button coming from? it is clearly built in but not in the list of "standard" buttons which is a very short list I might add. This icon is a PNG resource undoubtedly in some framework or somewhere, and where is it, or how can I get this button to come up programmatically it is not a simple oval.

  • How does the exception handling work ?

    Hello,
    the reason why I ask this is the following behaviour:
    I declared a customized DCErrorHandlerImpl in my application. Here I'm able to see some exceptions but not all, e.g.the following:
    In the constructor of a managed bean I entered a statement to create an exception:
    int i = 1/0;
    which will cause an arithmetic exception of course, when the managed bean would be created (which is not based on the exception).
    But I don't get this exception in my customized DCErrorHandlerImpl. Why not ? Where can I find more about how all this fits together?
    Many thanks in advance.
    Best regards
    Martin

    DCErrorHandler (as the "DC" part of the name implies) only handles exceptions from the binding layer (aka Data Controls). [url http://docs.oracle.com/cd/E17904_01/apirefs.1111/e10653/oracle/adf/model/binding/DCErrorHandlerImpl.html]The javadocs say this:
    This handler caches the exception in the bindingContainer and then...JOhn

  • How Does the Reflection Go if image is Tilted? A Bit OT.

    Sorry if this is too much of a novice question and not really an Illustrator Question but I'll ask it anyway and risk being ignored.
    I'm trying to do a reflection for a web image.  It's easy if the image is dead straight but I want the image to be tilted and when I do that it loses something.  I'm not sure if it's because  the angles are wrong so, that's my question. This is near to what I'm thinking - am I close?
    Thanks

    martcol wrote:
    Many thanks,
    I'm grateful for you going so easy on me.  It's not as tough here as it can be on the Dreamweaver Board!
    Martin
    Don't write us off so fast…just need a little more time…and a really stupid quest ion would help as well.

  • How does Media Manager handle Motion Projects within the Sequence being cop

    How does Media Manager handle Motion Projects within the Sequence being copied?
    I've highlighted my sequence, opened Media Manager, and copied it to another drive. When I open up the sequence in it's new project, the rendered Motion Project plays within my sequence but it won't let me go back into this Motion Project to make changes. I tried starting over. This time I highlighted the actual motion sequence and clip that is created within FCP after sending something to Motion and copied those to the new drive. When I went into the newly created 'media' folder and double clicked on the motion project it launched. It looked liked it was going to play but while my crops moves and borders were there, the filmed material is shown as a freeze frame for the duration of the motion project.
    I did this with and without 'including master clips within selection'. Any advice would be appreciated. Thanks.

    Is there anyone who knows the answer to this? Thanks.

  • How does the SDK and Reader handle printing with orientation?

    I have a document that I want to print, and it contains a portrait page on Page 1, and a landscape page on Page 2.  Acrobat Reader correctly prints these pages (with a single print job), and I'm assuming it's because of the auto-rotate option on the print dialog.  Is this a feature of Reader, the API, or how the printer handles the request.  I've tried printing this PDF just using the JAva API, but the orientation remain portrait for all pages.  How does the Adobe Acrobat API deal with mixed orientation pages?  Ignore the fact that I did my test printing with Java, because my question is whether or not the auto orientation is a feature of the UI, the SDK, or the printer (or a combination).

    Same as the current Ipod Video or "Classic" there is an option under settings to toggle between original aspect ratio or Full Screen.
    Kenal0

Maybe you are looking for