/** * Ensures that the provided argument is not <code>null</code>. * * <p>If it <code>null</code> it must throw a {@link NullPointerException}. * * @param argument argument to check for <code>null</code>. */ protected static void ensureNotNull(final Object argument) { ensureNotNull(argument, "Argument cannot be null"); }
/** * Tries to decode the provided {@link String} into an HEX color definition in RRGGBB, 0xRRGGBB * or #RRGGBB format * * <p>In case the {@link String} is not correct a {@link NumberFormatException} will be thrown. * * @param hex a {@link String} that should contain an Hexadecimal color representation. * @return a {@link Color} representing the provided {@link String}. * @throws NumberFormatException in case the string is badly formatted. */ public static Color color(String hex) { ensureNotNull(hex, "hex value"); if (hex.startsWith("0x")) { hex = hex.substring(2); } if (!hex.startsWith("#")) { hex = "#" + hex; } return Color.decode(hex); }
/** * Retrieves column height of legend from the provided {@link GetLegendGraphicRequest}. * * @param req a {@link GetLegendGraphicRequest} from which we should extract column height * information. * @return the column height specified in the provided {@link GetLegendGraphicRequest} or a * default DEFAULT_COLUMN_HEIGHT. */ public static int getColumnHeight(final GetLegendGraphicRequest req) { ensureNotNull(req, "GetLegendGraphicRequestre"); final Map<String, Object> legendOptions = req.getLegendOptions(); int columnheight = DEFAULT_COLUMN_HEIGHT; if (legendOptions != null && legendOptions.get("columnheight") != null) { try { columnheight = Integer.parseInt((String) legendOptions.get("columnheight")); } catch (NumberFormatException e) { } } return columnheight; }
/** * Retrieves row width of legend from the provided {@link GetLegendGraphicRequest}. * * @param req a {@link GetLegendGraphicRequest} from which we should extract row width * information. * @return the row width specified in the provided {@link GetLegendGraphicRequest} or a default * DEFAULT_ROW_WIDTH. */ public static int getRowWidth(final GetLegendGraphicRequest req) { ensureNotNull(req, "GetLegendGraphicRequestre"); final Map<String, Object> legendOptions = req.getLegendOptions(); int rowwidth = DEFAULT_ROW_WIDTH; if (legendOptions != null && legendOptions.get("rowwidth") != null) { try { rowwidth = Integer.parseInt((String) legendOptions.get("rowwidth")); } catch (NumberFormatException e) { } } return rowwidth; }
/** * Retrieves rows of legend from the provided {@link GetLegendGraphicRequest}. * * @param req a {@link GetLegendGraphicRequest} from which we should extract rows information. * @return the rows specified in the provided {@link GetLegendGraphicRequest} or a default * DEFAULT_ROWS. */ public static int getRows(final GetLegendGraphicRequest req) { ensureNotNull(req, "GetLegendGraphicRequestre"); final Map<String, Object> legendOptions = req.getLegendOptions(); int rows = DEFAULT_ROWS; if (legendOptions != null && legendOptions.get("rows") != null) { try { rows = Integer.parseInt((String) legendOptions.get("rows")); } catch (NumberFormatException e) { } } return rows; }
/** * Retrieves columns of legend from the provided {@link GetLegendGraphicRequest}. * * @param req a {@link GetLegendGraphicRequest} from which we should extract columns * information. * @return the columns specified in the provided {@link GetLegendGraphicRequest} or a default * DEFAULT_COLUMNS. */ public static int getColumns(final GetLegendGraphicRequest req) { ensureNotNull(req, "GetLegendGraphicRequestre"); final Map<String, Object> legendOptions = req.getLegendOptions(); int columns = DEFAULT_COLUMNS; if (legendOptions != null && legendOptions.get("columns") != null) { try { columns = Integer.parseInt((String) legendOptions.get("columns")); } catch (NumberFormatException e) { } } return columns; }
/** * Retrieves the group legend layout from the provided {@link GetLegendGraphicRequest}. * * @param req a {@link GetLegendGraphicRequest} from which we should extract the group {@link * LegendLayout} information. * @return the group {@link LegendLayout} specified in the provided {@link * GetLegendGraphicRequest} or a default DEFAULT_LAYOUT. */ public static LegendLayout getGroupLayout(final GetLegendGraphicRequest req) { ensureNotNull(req, "GetLegendGraphicRequestre"); final Map<String, Object> legendOptions = req.getLegendOptions(); LegendLayout layout = DEFAULT_LAYOUT; if (legendOptions != null && legendOptions.get("grouplayout") != null) { try { layout = LegendLayout.valueOf( ((String) legendOptions.get("grouplayout")).toUpperCase()); } catch (IllegalArgumentException e) { } } return layout; }
/** * Retrieves the legend layout from the provided {@link GetLegendGraphicRequest}. * * @param req a {@link GetLegendGraphicRequest} from which we should extract the {@link * LegendLayout} information. * @return the {@link LegendLayout} specified in the provided {@link GetLegendGraphicRequest} or * a default DEFAULT_LAYOUT. */ public static LegendLayout getLayout(final GetLegendGraphicRequest req) { ensureNotNull(req, "GetLegendGraphicRequestre"); final Map<String, Object> legendOptions = req.getLegendOptions(); LegendLayout layout = DEFAULT_LAYOUT; if (legendOptions != null && legendOptions.get("layout") != null) { try { layout = LegendLayout.valueOf(((String) legendOptions.get("layout")).toUpperCase()); } catch (IllegalArgumentException e) { } } return layout; }
/** * Get the {@link Color} out of this {@link ColorMapEntry}. * * @param entry the {@link ColorMapEntry} from which to extract the {@link Color} component. * @return the {@link Color} out of this {@link ColorMapEntry}. * @throws NumberFormatException in case the color string is badly formatted. */ public static Color color(final ColorMapEntry entry) { ensureNotNull(entry, "entry"); Expression color = entry.getColor(); ensureNotNull(color, "color"); String colorString = color.evaluate(null, String.class); if (colorString != null && colorString.startsWith("${")) { color = ExpressionExtractor.extractCqlExpressions(colorString); colorString = color.evaluate(null, String.class); } ensureNotNull(colorString, "colorString"); return color(colorString); }
/** * Extracts the quantity part from the provided {@link ColorMapEntry}. * * @param entry the provided {@link ColorMapEntry} from which we should extract the quantity * part. * @return the quantity part for the provided {@link ColorMapEntry}. */ public static double getQuantity(final ColorMapEntry entry) { ensureNotNull(entry, "entry"); Expression quantity = entry.getQuantity(); ensureNotNull(quantity, "quantity"); Double quantityString = quantity.evaluate(null, Double.class); if (quantityString == null && quantity instanceof Literal) { String quantityExp = quantity.evaluate(null, String.class); quantity = ExpressionExtractor.extractCqlExpressions(quantityExp); quantityString = quantity.evaluate(null, Double.class); } ensureNotNull(quantityString, "quantityString"); return quantityString.doubleValue(); }
ensureNotNull(ftStyles, "FeatureTypeStyle array ");
/** * Extracts the label part from the provided {@link ColorMapEntry}. * * @param entry the provided {@link ColorMapEntry} from which we should extract the label part. * @return the label part for the provided {@link ColorMapEntry}. */ public static String getLabel(final ColorMapEntry entry) { ensureNotNull(entry, "entry"); String labelString = entry.getLabel(); if (labelString != null && labelString.startsWith("${")) { Expression label = ExpressionExtractor.extractCqlExpressions(labelString); labelString = label.evaluate(null, String.class); } return labelString; }
ensureNotNull(label); ensureNotNull(g); ensureNotNull(req);
ensureNotNull(req, "GetLegendGraphicRequestre"); final Map<String, Object> legendOptions = req.getLegendOptions(); if (legendOptions == null) return DEFAULT_FONT;
ensureNotNull(req, "GetLegendGraphicRequestre"); final Map<String, Object> legendOptions = req.getLegendOptions(); final String color = legendOptions != null ? (String) legendOptions.get("fontColor") : null;
ensureNotNull(req, "GetLegendGraphicRequestre"); final Map<String, Object> legendOptions = req.getLegendOptions(); if (legendOptions == null) return DEFAULT_BG_COLOR;
throws IllegalArgumentException, MissingResourceException { ensureNotNull(entry, "ColorMapEntry");