This discussion is archived
1 Reply Latest reply: Jan 24, 2013 9:38 PM by 978168 RSS

How to scale the scrollpane's vertical value

978168 Newbie
Currently Being Moderated
I am having a problem with zooming in a ScrollPane. I just want to keep track of where I am in my scrollPane because I want to generate content based on where I am.

I have a zoomhandler which handle the zooming just fine, but I am having problems with the scrollpane.vvalueProperty().get(). I want to keep track of the top left corner of the viewport so I made these adjustments:

double tempX = Math.floor((scroll.hvalueProperty().get()) * CANVASSIZE - (scroll.hvalueProperty().get()) * scrollPaneWidth);
double tempY = Math.floor((scroll.vvalueProperty().get()) * CANVASSIZE - (scroll.vvalueProperty().get()) * scrollPaneHeight);

I have tested those values and it is not always 100% correct. Any advice will be appreciated.

The next problem I have is keeping track of the top left corner after I scaled the content. I have tried something like this (tempScale is the current scale of the scrollPanes' content):

double rescaledX = tempX*tempScale
double rescaledY = tempY*tempScale

But that doesn't work 100% of the time.

Any input will be appreciated.

Jacques

Edited by: Jacques_ZA on Jan 24, 2013 1:38 PM

Edited by: Jacques_ZA on Jan 24, 2013 2:16 PM

Edited by: Jacques_ZA on Jan 24, 2013 10:19 PM

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points