@SuppressWarnings("nls")
	public static final Rectangle toRectangle(String encoded) throws NumberFormatException {
		if (encoded == null) {
			throw new NumberFormatException("Not a rectangle");
		}
		String[] parts = encoded.split(",", 4);
		if (parts.length != 2 && parts.length != 4) {
			throw new NumberFormatException("Not a rectangle");
		}
		return new Rectangle(Integer.parseInt(parts[0].trim()), Integer.parseInt(parts[1].trim()), parts.length > 2 ? Integer.parseInt(parts[2].trim()) : 1, parts.length > 2 ? Integer.parseInt(parts[3].trim()) : 1);
	}