377 |
*/ |
*/ |
378 |
private Envelope fixAspectRatio(final Rectangle r, final Envelope mapArea, |
private Envelope fixAspectRatio(final Rectangle r, final Envelope mapArea, |
379 |
boolean grow) { |
boolean grow) { |
380 |
|
|
381 |
|
if (mapArea == null) { |
382 |
|
LOGGER.warn("mapArea has been null in method fixAspectRatio, returning an unmodified "); |
383 |
|
} |
384 |
|
|
385 |
final double mapWidth = mapArea.getWidth(); /* get the extent of the map */ |
final double mapWidth = mapArea.getWidth(); /* get the extent of the map */ |
386 |
final double mapHeight = mapArea.getHeight(); |
final double mapHeight = mapArea.getHeight(); |
625 |
protected void processDrag(final int x1, final int y1, final int x2, |
protected void processDrag(final int x1, final int y1, final int x2, |
626 |
final int y2, final MouseEvent e) { |
final int y2, final MouseEvent e) { |
627 |
|
|
628 |
|
|
629 |
/**** |
/**** |
630 |
* If no layer is availabe we dont want a NullPointerException |
* If no layers exist, we ignore the drag. |
631 |
*/ |
*/ |
632 |
if (mapArea == null) |
if (context.getLayerCount() <= 0) { |
633 |
return; |
return; |
634 |
|
} |
635 |
|
|
636 |
// System.out.println("processing drag from " + x1 + "," + y1 + " -> " |
// System.out.println("processing drag from " + x1 + "," + y1 + " -> " |
637 |
// + x2 + "," + y2); |
// + x2 + "," + y2); |
638 |
if ((x1 == x2) && (y1 == y2)) { |
if ((x1 == x2) && (y1 == y2)) { |
678 |
final Coordinate ur = new Coordinate(right, top); |
final Coordinate ur = new Coordinate(right, top); |
679 |
// xulu.sc |
// xulu.sc |
680 |
// mapArea = fixAspectRatio(this.getBounds(), new Envelope(ll, ur)); |
// mapArea = fixAspectRatio(this.getBounds(), new Envelope(ll, ur)); |
681 |
|
|
682 |
|
|
683 |
setMapArea(bestAllowedMapArea(new Envelope(ll, ur))); |
setMapArea(bestAllowedMapArea(new Envelope(ll, ur))); |
684 |
// xulu.ec |
// xulu.ec |
685 |
} else if (state == JMapPane.ZoomIn) { |
} else if (state == JMapPane.ZoomIn) { |