/** * Renders the legend image label * * @param img the BufferedImage * @param rule the applicable rule for img, if rule is not null the label will be rendered * @param req the request * @param options options to be used for merging * @return the BufferedImage of label */ private static BufferedImage renderLabel( RenderedImage img, Rule rule, GetLegendGraphicRequest req, MergeOptions options) { BufferedImage labelImg = null; if (!options.isForceLabelsOff() && rule != null) { String label = LegendUtils.getRuleLabel(rule, req); if (label != null && label.length() > 0) { final BufferedImage renderedLabel = getRenderedLabel((BufferedImage) img, label, req); labelImg = renderedLabel; } } return labelImg; }
BufferedImage img = (BufferedImage) imageStack.get(i); if (rules != null && rules[i] != null) { BufferedImage label = renderLabel(img, rules[i], req, mergeOptions); if (label != null) { img = joinBufferedImageHorizzontally( img, label, BufferedImage finalLegend = null; if (layout == LegendLayout.HORIZONTAL) { Row[] rows = createRows(nodes, mergeOptions.getRowWidth(), mergeOptions.getRows()); finalLegend = buildFinalHLegend(rows, mergeOptions); createColumns( nodes, mergeOptions.getColumnHeight(), req, true); finalLegend = buildFinalVLegend(columns, mergeOptions);
BufferedImage img = (BufferedImage) imageStack.get(i + 1); img = joinBufferedImageVertically( lbl, img, BufferedImage finalLegend = null; if (layout == LegendLayout.HORIZONTAL) { Row[] rows = createRows(nodes, 0, 0); finalLegend = buildFinalHLegend(rows, mergeOptions); Column[] columns = createColumns(nodes, 0, 0, null, false); finalLegend = buildFinalVLegend(columns, mergeOptions);
Row[] rows = createRows(nodes, mergeOptions.getRowWidth(), mergeOptions.getRows()); finalLegend = buildFinalHLegend(rows, mergeOptions); createColumns( nodes, mergeOptions.getColumnHeight(), null, false); finalLegend = buildFinalVLegend(columns, mergeOptions);
/** * 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); }
if (ruleCount > 0) { BufferedImage image = LegendMerger.mergeLegends(applicableRules, request, options);
if (checkColor) { colourPresent = checkColor(nodes.get(i), req); if (colourPresent) { legendMatrix[cn].addNode(nodes.get(i));
/** * 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); }
if (ruleCount > 0) { BufferedImage image = LegendMerger.mergeLegends(applicableRules, request, options);
/** * Renders a title for a layer (to be put on top of the layer legend). * * @param legend FeatureType representing the layer * @param w width for the image (hint) * @param h height for the image (hint) * @param transparent (should the image be transparent) * @param request GetLegendGraphicRequest being built * @return image with the title */ private RenderedImage getLayerTitle( LegendRequest legend, int w, int h, boolean transparent, GetLegendGraphicRequest request) { String title = legend.getTitle(); final BufferedImage image = ImageUtils.createImage(w, h, (IndexColorModel) null, transparent); return LegendMerger.getRenderedLabel(image, title, request); }
/** * Renders a title for a layer (to be put on top of the layer legend). * * @param legend FeatureType representing the layer * @param w width for the image (hint) * @param h height for the image (hint) * @param transparent (should the image be transparent) * @param request GetLegendGraphicRequest being built * @return image with the title */ private RenderedImage getLayerTitle( LegendRequest legend, int w, int h, boolean transparent, GetLegendGraphicRequest request) { String title = legend.getTitle(); final BufferedImage image = ImageUtils.createImage(w, h, (IndexColorModel) null, transparent); return LegendMerger.getRenderedLabel(image, title, request); }