private Coordinate calcCenterFromPoint(final Coordinate worldCenter) {
		double xCenter = worldCenter.getX();
		double yCenter = worldCenter.getY();
		if (maxBounds != null) {
			Coordinate minCoordinate = maxBounds.getOrigin();
			Coordinate maxCoordinate = maxBounds.getEndPoint();

			if (BoundsLimitOption.COMPLETELY_WITHIN_MAX_BOUNDS.equals(viewBoundsLimitOption)) {
				/** View must lay completely within maxBounds. **/
				double w = getViewSpaceWidth() / 2;
				double h = getViewSpaceHeight() / 2;
	
				if ((w * 2) > maxBounds.getWidth()) {
					xCenter = maxBounds.getCenterPoint().getX();
				} else {
					if ((xCenter - w) < minCoordinate.getX()) {
						xCenter = minCoordinate.getX() + w;
					}
					if ((xCenter + w) > maxCoordinate.getX()) {
						xCenter = maxCoordinate.getX() - w;
					}
				}
				if ((h * 2) > maxBounds.getHeight()) {
					yCenter = maxBounds.getCenterPoint().getY();
				} else {
					if ((yCenter - h) < minCoordinate.getY()) {
						yCenter = minCoordinate.getY() + h;
					}
					if ((yCenter + h) > maxCoordinate.getY()) {
						yCenter = maxCoordinate.getY() - h;
					}
				}
			} else if (BoundsLimitOption.CENTER_WITHIN_MAX_BOUNDS.equals(viewBoundsLimitOption)) {
				/** Center of view must lay within maxBounds. **/
				Coordinate center = new Coordinate(xCenter, yCenter);
				if (!maxBounds.contains(center)) {
					if (xCenter < minCoordinate.getX()) {
						xCenter = minCoordinate.getX();
					} else if (xCenter > maxCoordinate.getX()) {
						xCenter = maxCoordinate.getX();
					}
					if (yCenter < minCoordinate.getY()) {
						yCenter = minCoordinate.getY();
					} else if (yCenter > maxCoordinate.getY()) {
						yCenter = maxCoordinate.getY();
					}
				}
			}
		}
		return new Coordinate(xCenter, yCenter);
	}
private Coordinate calcCenterFromPoint ( final Coordinate worldCenter ) { double xCenter = worldCenter . getX ( ) ; double yCenter = worldCenter . getY ( ) ; if ( maxBounds != null ) { Coordinate minCoordinate = maxBounds . getOrigin ( ) ; Coordinate maxCoordinate = maxBounds . getEndPoint ( ) ; if ( BoundsLimitOption . COMPLETELY_WITHIN_MAX_BOUNDS . equals ( viewBoundsLimitOption ) ) { double w = getViewSpaceWidth ( ) / 2 ; double h = getViewSpaceHeight ( ) / 2 ; if ( ( w * 2 ) > maxBounds . getWidth ( ) ) { xCenter = maxBounds . getCenterPoint ( ) . getX ( ) ; } else { if ( ( xCenter - w ) < minCoordinate . getX ( ) ) { xCenter = minCoordinate . getX ( ) + w ; } if ( ( xCenter + w ) > maxCoordinate . getX ( ) ) { xCenter = maxCoordinate . getX ( ) - w ; } } if ( ( h * 2 ) > maxBounds . getHeight ( ) ) { yCenter = maxBounds . getCenterPoint ( ) . getY ( ) ; } else { if ( ( yCenter - h ) < minCoordinate . getY ( ) ) { yCenter = minCoordinate . getY ( ) + h ; } if ( ( yCenter + h ) > maxCoordinate . getY ( ) ) { yCenter = maxCoordinate . getY ( ) - h ; } } } else if ( BoundsLimitOption . CENTER_WITHIN_MAX_BOUNDS . equals ( viewBoundsLimitOption ) ) { Coordinate center = new Coordinate ( xCenter , yCenter ) ; if ( ! maxBounds . contains ( center ) ) { if ( xCenter < minCoordinate . getX ( ) ) { xCenter = minCoordinate . getX ( ) ; } else if ( xCenter > maxCoordinate . getX ( ) ) { xCenter = maxCoordinate . getX ( ) ; } if ( yCenter < minCoordinate . getY ( ) ) { yCenter = minCoordinate . getY ( ) ; } else if ( yCenter > maxCoordinate . getY ( ) ) { yCenter = maxCoordinate . getY ( ) ; } } } } return new Coordinate ( xCenter , yCenter ) ; }
Adjusts the center point of the map, to an allowed center point. This method tries to make sure the whole map
extent is inside the maximum allowed bounds.

@param worldCenter world center
@return new center