/** * 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); }
margin, labelMargin, LegendUtils.getBackgroundColor(req), req.isTransparent(), LegendUtils.isFontAntiAliasing(req), LegendUtils.getLayout(req), LegendUtils.getRowWidth(req), LegendUtils.getRows(req), LegendUtils.getColumnHeight(req), LegendUtils.getColumns(req), LegendUtils.getLabelFont(req), forceLabelsOn, forceLabelsOff,
/** * Renders a label on the given image, using parameters from the request for the rendering * style. * * @param image * @param label * @param request */ protected static BufferedImage getRenderedLabel( BufferedImage image, String label, GetLegendGraphicRequest req) { final Graphics2D graphics = image.createGraphics(); Font labelFont = LegendUtils.getLabelFont(req); boolean useAA = LegendUtils.isFontAntiAliasing(req); graphics.setFont(labelFont); if (useAA) { graphics.setRenderingHint( RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); } else { graphics.setRenderingHint( RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); } return LegendUtils.renderLabel(label, graphics, req); } }
Rule rule = LegendUtils.getRule(ftStyles, ruleName); if (rule == null) { throw new ServiceException( applicableRules = LegendUtils.getApplicableRules(ftStyles, scaleDenominator); bgColor = LegendUtils.getBackgroundColor(request); cmapLegendBuilder.setLabelFont(LegendUtils.getLabelFont(request)); cmapLegendBuilder.setLabelFontColor(LegendUtils.getLabelFontColor(request)); cmapLegendBuilder.setLayout(LegendUtils.getLayout(request)); cmapLegendBuilder.setColumnHeight(LegendUtils.getColumnHeight(request)); cmapLegendBuilder.setRowWidth(LegendUtils.getRowWidth(request)); cmapLegendBuilder.setColumns(LegendUtils.getColumns(request)); cmapLegendBuilder.setRows(LegendUtils.getRows(request)); cmapLegendBuilder.setLabelFontColor(LegendUtils.getLabelFontColor(request));
previousColor = LegendUtils.color(previousCME); final double opacity = LegendUtils.getOpacity(previousCME); previousColor = new Color( Color color = LegendUtils.color(currentCME); double opacity = LegendUtils.getOpacity(currentCME); color, opacity, previousColor, requestedDimension, borderColor)); String label = LegendUtils.getLabel(currentCME); double quantity = LegendUtils.getQuantity(currentCME);
(!strict && layer == null && LegendUtils.checkRasterSymbolizer(gt2Style)) || (LegendUtils.checkGridLayer(layer) && !hasVectorTransformation) || hasRasterTransformation; Rule rule = LegendUtils.getRule(ftStyles, ruleName); if (rule == null) { throw new ServiceException( applicableRules = LegendUtils.getApplicableRules(ftStyles, scaleDenominator); ImageUtils.prepareTransparency( transparent, LegendUtils.getBackgroundColor(request), image, hintsMap);
for (Layer layer : mapContext.layers()) { Rule[] applicableRules = LegendUtils.getApplicableRules( layer.getStyle().featureTypeStyles().toArray(new FeatureTypeStyle[0]), scaleDenominator); Font newFont = LegendUtils.getLabelFont(request); newFont = newFont.deriveFont(Font.BOLD); newFont = newFont.deriveFont((float) newFont.getSize() + 2); if (LegendUtils.isFontAntiAliasing(legend.request)) { g2d.setRenderingHint( RenderingHints.KEY_TEXT_ANTIALIASING, BufferedImage titleImage = LegendUtils.renderLabel(title, g2d, request); g2d.setFont(oldFont);
/** * Checks the pixels for presence of colour against legend background * * @param img given row of the legend * @param req general mechanism for acquiring legend symbols * @return false if no colours are detected */ public static boolean checkColor(BufferedImage img, GetLegendGraphicRequest req) { int w = img.getWidth(); int h = img.getHeight(); boolean colourPresent = false; for (int j = 0; j < w; j++) { for (int k = 0; k < h; k++) { if (img.getRGB(j, k) != LegendUtils.getBackgroundColor(req).getRGB()) { colourPresent = true; } } } return colourPresent; }
/** * Receives a list of <code>BufferedImages</code> and produces a new one which holds all the * images in <code>imageStack</code> one above the other, handling labels. * * @param imageStack the list of BufferedImages, one for each applicable Rule * @param rules The applicable rules, one for each image in the stack (if not null it's used to * compute labels) * @param request The request. * @param forceLabelsOn true for force labels on also with a single image. * @param forceLabelsOff true for force labels off also with more than one rule. * @return the stack image with all the images on the argument list. * @throws IllegalArgumentException if the list is empty */ private BufferedImage mergeGroups( List<RenderedImage> imageStack, Rule[] rules, GetLegendGraphicRequest req, boolean forceLabelsOn, boolean forceLabelsOff, boolean forceTitlesOff) { LegendMerger.MergeOptions options = LegendMerger.MergeOptions.createFromRequest( imageStack, 0, 0, 0, 0, req, forceLabelsOn, forceLabelsOff, forceTitlesOff); options.setLayout(LegendUtils.getGroupLayout(req)); return LegendMerger.mergeGroups(rules, options); }
borderColor = LegendUtils.color((String) additionalOptions.get("borderColor"));
else leftEdge = false; Color color = LegendUtils.color(currentCME); final double opacity = LegendUtils.getOpacity(currentCME); color = new Color( color, opacity, requestedDimension, borderColor)); String label = LegendUtils.getLabel(currentCME); double quantity1 = leftEdge ? LegendUtils.getQuantity(currentCME) : LegendUtils.getQuantity(previousCME); double quantity2 = LegendUtils.getQuantity(currentCME);
(!strict && layer == null && LegendUtils.checkRasterSymbolizer(gt2Style)) || (LegendUtils.checkGridLayer(layer) && !hasVectorTransformation) || hasRasterTransformation; Rule rule = LegendUtils.getRule(ftStyles, ruleName); if (rule == null) { throw new ServiceException( applicableRules = LegendUtils.getApplicableRules(ftStyles, scaleDenominator); ImageUtils.prepareTransparency( transparent, LegendUtils.getBackgroundColor(request), image, hintsMap);
private BufferedImage getRenderedLabel( BufferedImage image, String label, GetLegendGraphicRequest request) { Font labelFont = LegendUtils.getLabelFont(request); boolean useAA = LegendUtils.isFontAntiAliasing(request); final Graphics2D graphics = image.createGraphics(); graphics.setFont(labelFont); if (useAA) { graphics.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); } else { graphics.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } return LegendUtils.renderLabel(label, graphics, request); } }
ImageUtils.prepareTransparency( false, LegendUtils.getBackgroundColor(legend.request), finalLegend, new HashMap<RenderingHints.Key, Object>());
/** * Receives a list of <code>BufferedImages</code> and produces a new one which holds all the * images in <code>imageStack</code> one above the other, handling labels. * * @param imageStack the list of BufferedImages, one for each applicable Rule * @param rules The applicable rules, one for each image in the stack (if not null it's used to * compute labels) * @param request The request. * @param forceLabelsOn true for force labels on also with a single image. * @param forceLabelsOff true for force labels off also with more than one rule. * @return the stack image with all the images on the argument list. * @throws IllegalArgumentException if the list is empty */ private BufferedImage mergeGroups( List<RenderedImage> imageStack, Rule[] rules, GetLegendGraphicRequest req, boolean forceLabelsOn, boolean forceLabelsOff, boolean forceTitlesOff) { LegendMerger.MergeOptions options = LegendMerger.MergeOptions.createFromRequest( imageStack, 0, 0, 0, 0, req, forceLabelsOn, forceLabelsOff, forceTitlesOff); options.setLayout(LegendUtils.getGroupLayout(req)); return LegendMerger.mergeGroups(rules, options); }
Color color = LegendUtils.color(currentCME); final double opacity = LegendUtils.getOpacity(currentCME); color = new Color( color, opacity, requestedDimension, borderColor)); final String label = LegendUtils.getLabel(currentCME); final double quantity = LegendUtils.getQuantity(currentCME); final String symbol = " = ";
ensureNotNull(req, "GetLegendGraphicRequestre"); final Map<String, Object> legendOptions = req.getLegendOptions(); if (legendOptions == null) return DEFAULT_BG_COLOR; return color((String) clr); } catch (NumberFormatException e) { LOGGER.warning(
ColorMapEntry[] entries = symbolizer.getColorMap().getColorMapEntries(); Color color = LegendUtils.color(entries[0]); int red = color.getRed(); assertEquals(255, red); assertEquals(0, blue); double quantity = LegendUtils.getQuantity(entries[1]); assertEquals(20.0, quantity, 0.0); double opacity = LegendUtils.getOpacity(entries[2]); assertEquals(0.5, opacity, 0.0); entries[2].setLabel( "${Concatenate('-', '4', '9', ' ', '-', ' ', '-', '2', '0', ' ', 'm', 'm')}"); assertEquals(fixedLabel, LegendUtils.getLabel(entries[2]));
ensureNotNull(req, "GetLegendGraphicRequestre"); final Map<String, Object> legendOptions = req.getLegendOptions(); final String color = legendOptions != null ? (String) legendOptions.get("fontColor") : null; return color(color); } catch (NumberFormatException e) { if (LOGGER.isLoggable(Level.WARNING))