• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Clipping question

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm having a problem with clipping bounds not being what I expect them to be. I must not fully understand what's going on. Here is a simple example to illustrate the problem:



In the code above, java.awt.Rectangle[x=0,y=0,width=98,height=144] is initially printed. This seems like a reasonable clip. However, when I scroll down one unit, I get java.awt.Rectangle[x=0,y=144,width=98,height=1]. What is happening here? I was expecting to see something like java.awt.Rectangle[x=0,y=1,width=98,height=144]. Also, if I then scroll back up one unit, I get java.awt.Rectangle[x=0,y=0,width=98,height=1]. Why is it not back to the original clip?

Can someone please explain what's going on? Thank you.
 
Rancher
Posts: 3324
32
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When scrolling in a viewport you don't need to repaint the entire component, only the part that wasn't visible in the viewport before.

So the first time you need to paint everything.

When you scroll down 1 pixel you only need to paint the 1 pixel line at the bottom of the viewport.

When you scroll up 1 pixel you only need to repaint the 1 piexl line at the top of the viewport.
 
J Wallace
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you. This makes perfect sense now.
 
Look ma! I'm selling my stuff!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic