Commit cb43db3d authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck
Browse files

Fix Issue #41 Selection of ScenarioElements in the Onlinevis

If the Viewport is changed due to a zoom or scroll action the
calculation of the world coordinates can lead to negative x, y
coordinates of the viewport. The view port coordinates should not
be negative.
parent 66147784
......@@ -26,11 +26,12 @@ public class JViewportChangeListener implements ChangeListener {
public void stateChanged(final ChangeEvent e) {
Rectangle2D.Double topographyBound = defaultModel.getTopographyBound();
JViewport viewPort = (JViewport) e.getSource();
if (topographyBound != null) {
Rectangle rect = ((JViewport) e.getSource()).getViewRect();
double x = rect.getX() / defaultModel.getScaleFactor();
double y = topographyBound.getHeight()
- ((rect.getY() + verticalScrollBar.getHeight()) / defaultModel.getScaleFactor());
Rectangle rect = viewPort.getViewRect();
double x = Math.max(0.0, rect.getX() / defaultModel.getScaleFactor());
double y = Math.max(0.0, topographyBound.getHeight()
- ((rect.getY() + verticalScrollBar.getHeight()) / defaultModel.getScaleFactor()));
double w = rect.getWidth() / defaultModel.getScaleFactor();
double h = rect.getHeight() / defaultModel.getScaleFactor();
defaultModel.setViewportBound(new Rectangle2D.Double(x, y, w, h));
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment