Why is drawRect() so expensive?

I have a view which contains elements such as text and images. In some instances I draw a rectangle around the elements to show their borders.
I have tabs on the top, and when the user clicks the tabs the program changes which elements that are drawn with borders and which that are not.
I've noticed that this takes time, so out of curiosity I booted up JProfiler to inspect CPU usage during runtime.
It turns out that drawRect() is using between 54% and 15% of the resources each time. Text drawing, etc. is around 4-5% ..
Why is drawRect() so expensive? Any ways to optimize?

This is just strange .. there are 6 rectangles on my page, and the first time they are painted the paintComponent() method uses 842ms .. (89% of that time is used to paint the rectangles, although one should think that paiting JTextPane's content was more expensive?):
Here's the System.out from my paintComponent() method:
CompositeView.paintComponent(), scalex=1.8 - time: 842 ms
CompositeView.paintComponent(), scalex=1.8 - time: 20 ms
CompositeView.paintComponent(), scalex=1.8 - time: 0 ms
CompositeView.paintComponent(), scalex=1.8 - time: 20 ms
CompositeView.paintComponent(), scalex=1.8 - time: 20 ms
CompositeView.paintComponent(), scalex=1.8 - time: 30 msAs you can see, the first paint is extremely slow.
Can it have something to do with the graphics object being scaled? I've noticed that things go much faster if scale is 1, or 2.

Similar Messages

  • Why are iPads so expensive on Ebay?

    I am interested in buying one of these devices, but I just don't have the money to buy a new one at this moment. I don't understand why it is impossible to find one for under $500, yet that is what the 16 GB Wi-Fi version costs from Apple. I understand tax adds about $20, but it still should be quite a bit less for a used model.
    I want one of these, but it's not easy to swing at $500.

    Why are iPads so expensive on Ebay?
    Supply and demand, plus it's the only way some international people can buy one at the moment.
    Check out the new remodeled MacOSG website! 24-hour Apple-related news & support.
     MacOSG: An Apple User Group  iTunes: MacOSG Podcast  Follow us on Twitter: MacOSG

  • Why lightning adapter so expensive

    why lightning adapter so expensive
    biggest let down iphone5

    Really?
    It is the cost that Apple has chosen to charge.  Like most manufacturers, they do not divuldge their cost structure and prive model.
    Like any other business, they charge what the market will bear, based on their requirments.

  • Why is Dreamweaver so expensive for UK residents?

    So I have just finished my 30 day free trial and want to buy the full version of DreamWeaver but can anyone tell me why is it so expensive in the UK?
    US price is $399 to buy or download
    UK price is the equvilent of $574 to buy boxed and $606 to download!
    How do Adobe justify me paying $207 more than a US resident for exactley the same product because I happen to live in the UK?

    This is a user-to-user forum, so you'll get sympathy, but not an official response.
    There is no import duty on software apart from VAT. The difference in price between the boxed and download versions is explained by the fact that VAT is charged at the point of supply. The Adobe server is based in Ireland, so you pay Irish VAT for a download. The boxed version is supplied to you in the UK, so UK VAT applies. If you're not registered for VAT, it makes sense to buy the boxed version, because it's cheaper.
    As for the non-tax price differential, Adobe is not alone among US companies charging considerably higher prices for software outside the USA. My version of Microsoft Expression Web cost twice as much as it would have done in the United States.
    Not the answer you wanted, but that's the current situation. You could get a friend in the US to buy it for you, but Adobe Technical Support won't give help if you have a US serial number and live outside the States. You could also complain to your MP. There is also an online petition somewhere for fairer software pricing.

  • Why is subscription more expensive?

    My Creative Cloud Student Edition is finishing the 6.11.2013. Under my subscription there is written that new payment is the 7.11.2013 and it's gonna be €148,83 pr. months. Before I payed only €19,84 pr. month. Why is subscription become so expensive?

    Hi Bev
    I'll attach screenshoot, so you can se price.
    I've called to support, hanged on phone for 40 min and talked to many
    people from support, but they just send my call further, without any help.
    I'm really tired of that support!
    Best regards
    Gmenka
    [removed customer information]
    Hi Bev
    I'll attach screenshoot, so you can se price.
    I've called to support, hanged on phone for 40 min and talked to many
    people from support, but they just send my call further, without any help.
    I'm really tired of that support!
    Best regards
    Gmenka
    >
    2013/11/1 Beverley Gray <[email protected]>
    >> **
    >>    Re: Why is subscription more expensive?  created by Beverley Gray<http://forums.adobe.com/people/Beverley+Gray>in
    >> Adobe Creative Cloud - View the full discussion<http://forums.adobe.com/message/5806239#5806239>

  • Why is Kodak more expensive in iPhoto?

    Why is it more expensive to order Kodak prints through iPhoto than through Kodak.com?? Apple charges $.19 and Kodak charges $.15. I'm not sure if I'm getting any significant benefits of those extra $.04. Is there any way to make the service cheaper?

    Hi, dnase2000.
    I'm not sure if I'm getting any significant benefits of those extra $.04.
    You're getting the convenience of ordering through iPhoto, instead of having to export your pictures from it, order prints of the exported pictures, and then trash the exported pictures, since you already have copies of them stored in iPhoto's library. Only you can decide whether that's worth $.04 per picture to you.
    Is there any way to make the service cheaper?
    Yes. Don't use it.

  • Why Iphone is so expensive in Portugal?

    I would like to know why Iphone is so expensive in Portugal? How is possible a lot of countries in europe get a Iphone for 399€ and Portugal have the stupid price of 699€.

    The lower price is the carrier's subsidized or discounted price that requires signing a contract with the carrier which is usually for two years with such a discount.
    Does the carrier (or carriers) in Portugal offer a subsidized or discounted price with a contract, or is the iPhone sold as unlocked or without a contract only in Portugal?

  • Why is Black more expensive than white?

    There is 2 whitemac books! Then a black one! Why does the black cost more than the high end white?
    Is one made of metal and the other one made of plastic? Are macbooks durible or more durible than the MacBook pro?

    The OP was not comparing the BlackBook to the low end WhiteBook. His question specifically was aimed at the high end WhiteBook compared to the BlackBook. If you add the 160 GB drive to the Whitebook so the specs are the same the BlacBook still cost 125 dollars more. Hence your paying more for it being Black. In my opinion the Black is well worth it.
    Check the link out you gave. All three come with one GB of RAM so your statement about more RAM was wrong. The only difference is the BlackBook has a 160 GB drive compared to the 120 GB drive in the high end WhiteBook.

  • Why are ThinkPads so expensive in some countries, at least mine?

    Hi,
    First of all, I would like to apologize for starting this discussion in an irrelevant thread.
    I live in Indonesia. ThinkPads in my country are expensive, in my opinion. ThinkPad Twist in my country costs more than USD 1200 while in the US only costs around $800 for the same spec. ThinkPad T series (excluding the ones with with the 'i' and 'u' suffix), costs no less than $1500 while in other countries they are cheaper than that. The T430u costs more than $1200.  Do you know what might be the cause?

    The US will always have the cheapest prices (well maybe China will get cheap too!), because they are the target market, and home market of Apple.
    Also take into account shipping, market size, and exchange rate.
    I live in New Zealand, and we also have the iPhone 4s for $1000, but that's NZ$1000.
    Translated into US dollars we pay US$832
    But contract free in the US it costs US$649
    That is not nice, but can be expected as we only have 4million people and live in the middle of the ocean.
    And the iPhone is a want, not a nessesity, so if you can't afford it then really you shouldn't get it.

  • What is cellular? And why is it more expensive to get?

    What is cellular?

    Cellular means it connects to the Internet via a mobile cellular data network, not just via Wifi. Wifi is generally only available where there are buildings. Cellular networks exist out in the open, wherever you can get a mobile phone signal.
    It is more expensive because it contains extra hardware to allow the additional connection method.

  • Wow.  Why is educational so expensive?

    So, I logged into the Education store to grab Leopard and was surprised to see a discount that wasn't even 10%. Heck, it won't even cover tax in my area. Is there a reason why it's so high. Educational software discounts typically START at 25%. Tiger was one such example, with the Ed price being 50% off. Is this just because Leopard is new and if I wait it out it'll drop? Anyone have any reason why it's so high? Heck, even Vista was 50% off...

    You may need to go into your school bookstore and buy Leopard in person to get a good price. At my school (Georgia Tech), the "educational" price listed for Leopard on the Apple Store website is ridiculously high ($116) but if you physically walk into the bookstore and check out the software section, you can buy it for only $69. Of course, you have to bring your student ID and all that sort of stuff. Call your school bookstore and see how much they're actually selling it for.

  • Why is Leopard so expensive at eBay and Amazon?

    I can find Tiger and Snow Leopard cheap, but Leopard is incredibly expensive. Is it because it was the last G4 OS? Are there other resellers that would have it?

    As previous posters noted, Leopard is the last PowerPC OS that can run the current iTunes to sync iPads, iPods and iPhones.
    There is definitely a lot of life left in Leopard. Even though Apple has officially dropped support for Leopard, they still support it with the current 10.x.x versions of iTunes.
    Adobe just released a 9.5.x update to 10.4 and 10.5 in January (https://discussions.apple.com/thread/3648328?start=0&tstart=0).
    Firefox 3.6.x is still being updated (http://www.mozilla.org/en-US/firefox/all-older.html) (system requirements: http://www.mozilla.org/en-US/firefox/3.6/system-requirements/).
    When Mozilla drops support you can always go to TenFourFox. (http://www.floodgap.com/software/tenfourfox/)
    In December TexasMacMan (https://discussions.apple.com/people/Texas%20Mac%20Man) discovered a hack for using Flash 11 on PowerPC even though it's not officially supported: see Apple      Discussions thread 3599648
    VideoLAN is still releasing PowerPC versions of VLC Media Player with their latest 2.0 software just released (http://www.videolan.org/vlc/download-macosx.html). IMO VLC is the best media player out there, practically plays any media file that exists.

  • Why it's Too expensive in my country?

    Hi, my name is Diego, I'm from Argentina and I've been customer of apple for 10 years, had an ipod video, an 1,2 and 4 gen of ipod touch and I've been working with macs for 10 years. So i think i get the spirit within apple products.
    On Friday i lost my old phone and i thought 'i should buy an iphone' I went to my carrier (personal, personal.com.ar, and the rest of the carriers are almost the same) and i told them i want to buy an iphone 4g on apple.com cost u$s 199 they want to sell it to me at u$s 1025.
    And i thought 'ok maybe i should buy the iphone 3gS' u$s 49 they want to sell it to me at u$s 725.
    Of course i didn't buy the iphones.
    And since i'm an apple customer i want to know why in Argentina an iphone cost from 5 to 16 times more than it costs in the US.
    Maybe it's a con from personal maybe are taxes but you can be sure it feels like a con.
    Please you must take actions. You always say that apple cares, show it. This is WRONG
    Would you buy one of your products if someone want you to pay 21 times more than what you know it costs in other country?
    Sorry for complaining and for my english and i hope someone in apple take actions to stop this.
    Waiting for an answer.
    Regards
    Diego
    Message was edited by: Kanon123

    We are all users here just like you and none of us will be able to tell you why your carrier is charging that price for the iPhone. The prices you see on Apple.com (US store) are for US iPhone's on either AT&T or Verizon. Those prices are only applicable in the US on those 2 carriers.
    It may be due to exchange rates and carrier policies in your country that results in the high price. We do not know, no one here works for Apple. That is the price your carrier is charging and there is nothing that be done. You could check if another carrier is selling it for less but that is the only option you have.

  • Why is Adobe so expensive???

    bum

    Ok, thanks. I did this for my dad a few years back, and I'm very glad I did.
    Now, scanning to PDF wasn't actually the best choice. It's a great choice if you just want the records to print again later, or review on screen, but not for anything else. You can overcome this, but I still need to understand what you mean by "edit", because your problem has completely different solutions. Let me give you some choices.
    1. What I did. Took historical documents like birth certificate, and old photos. Cropped them (that is, as if I cut them smaller with scissors). Resized them. Put them on a page and added a caption "Photo 23 July 1942, Cairo" or whatever.
    2. Reuse the text. Like taking a page of a report, and pick out the fact that on 24 August 1943, Cpl Ryan was wounded, while on 5 September he returned to action. Write in your book, "Ryan returned to action on 5 September 1943, a couple of weeks after he was wounded on 24 August that year".
    3. Something else.

  • Why is the support so bad and expensive?

    Putting in my serial number of a product that is now useless tells me I'm not covered by the support so I have to pay £25 to have someone call me.
    When I put in all my details so I can phone Apple myself I then get given a premium rate number to phone and when I get through I start getting asked the same questiuons I answered online ( to get my case number ) so the call is going to end up costing more than it should. The case number is supposed to make the call quicker.
    Why is help so expensive here?
    Why can't I just email support?

    John Galt, the poster already did that as he said in this discussion. He said:
    I'm sure with the millions of dollars Apple make every day they can pay staff for support. Instead of that they create a forum where people can do their work for them for free.
    I've posted details about my problem herehttps://discussions.apple.com/message/25581520#25581520
    John Galt wrote:
    Post details of your own problem by starting your own Discussion, not by replying to someone else's. That is the best way to exploit the free resources of this free website.
    Otherwise, your only question "why is the support so bad and expensive" stands. It has been answered in this Discussion, which will effectively close it for those willing to help.

Maybe you are looking for

  • Download file send directly to mail attachement

    Hi All, We are working on Forms11g, Reports11g and Oracle11g DB in AIX Env. Our Client Systems are in Windows7. My Req. is : Once the user download a report in CSV File , that will go to mail attachment directly.. please guide us anybody share the so

  • Ref: Text Resolution from Photoshop... High or Low Resolution ?

    Hi people... Can anyone tell me... for sure... that text set in Adobe Photoshop will output similar to that of text set in Adobe Illustrator... or will it output as a bitmap file and be pixelated and blurry when enlarged by 400% ? I have the text set

  • Everytime I boot up firefox, this help page occurs, won't close and then will reappear dozens of times at the same time

    All of s a sudden, my home pages takes forever to come up and when I try to call up another web address,The mozilla hlp page appears. If I try to close it, new tabs will appear,often dozens of them all attempting to reopen the mozilla help page.

  • Can anyone explain why

    Can anyone explain why when I signed up to BT broadband some 4 years ago the estimated line speed I would get was estimated at 3.5Mbps (I was actually getting between 1 and 2 and every so often 2.5). Recently I've noticed a drop in speed, last week t

  • IPod frozen, won't unlock so can't reset it. What to do?

    My old original (5G) iPod was playing a song with the lock on, when there was an ominous loud click and the music stopped. The display shows Now Playing but nothing happens and unlocking with the Hold button does not in fact unlock it (the lock icon