public void visit(ColorMapEntry colorEntry) { if (colorEntry != null) { AttributesImpl atts = new AttributesImpl(); atts.addAttribute( "", "color", "color", "", colorEntry.getColor().evaluate(null, String.class)); if (colorEntry.getOpacity() != null) { atts.addAttribute( "", "opacity", "opacity", "", colorEntry.getOpacity().toString()); } if (colorEntry.getQuantity() != null) { atts.addAttribute( "", "quantity", "quantity", "", colorEntry.getQuantity().toString()); } if (colorEntry.getLabel() != null) { atts.addAttribute("", "label", "label", "", colorEntry.getLabel()); } element("ColorMapEntry", (String) null, atts); } }
@Override public ColorMapEntryBuilder reset(ColorMapEntry original) { if (original == null) { return unset(); } label = original.getLabel(); color = original.getColor(); opacity = original.getOpacity(); quantity = original.getQuantity(); unset = false; return this; }
public void visit(ColorMapEntry colorMapEntry) { ColorMapEntry copy = sf.createColorMapEntry(); copy.setColor(copy(colorMapEntry.getColor())); copy.setLabel(colorMapEntry.getLabel()); copy.setOpacity(copy(colorMapEntry.getOpacity())); copy.setQuantity(copy(colorMapEntry.getQuantity())); if (STRICT && !copy.equals(colorMapEntry)) { throw new IllegalStateException( "Was unable to duplicate provided ColorMapEntry:" + colorMapEntry); } pages.push(copy); }
@Override public Tuple next() { ColorMapEntry entry = entries.next(); return Tuple.of( toColorOrNull(entry.getColor()), toObjOrNull(entry.getOpacity()), toObjOrNull(entry.getQuantity()), entry.getLabel()); }
public void visit(ColorMapEntry colorMapEntry) { ColorMapEntry copy = sf.createColorMapEntry(); copy.setColor(copyCqlExpression(colorMapEntry.getColor())); copy.setLabel(colorMapEntry.getLabel()); copy.setOpacity(copyCqlExpression(colorMapEntry.getOpacity())); copy.setQuantity(copyCqlExpression(colorMapEntry.getQuantity())); if (STRICT && !copy.equals(colorMapEntry)) { throw new IllegalStateException( "Was unable to duplicate provided ColorMapEntry:" + colorMapEntry); } pages.push(copy); } }
String label = colorMapEntry.getLabel(); label = label == null ? "ColorMapEntry" + this.colormapElements.size() : label;
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { if (value != null && value instanceof ColorMapEntry) { entry = (ColorMapEntry) value; but.setText(entry.getLabel()); } else { entry = null; } return but; } }
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JLabel lbl = (JLabel) super.getTableCellRendererComponent(table, text, isSelected, hasFocus, row, column); ColorMapEntry f = (ColorMapEntry) value; lbl.setText(f.getLabel()); return lbl; } }
public void testColorMapEntryDuplication() throws Exception { ColorMapEntry cme = sf.createColorMapEntry(); cme.setColor(sb.colorExpression(Color.YELLOW)); cme.setLabel("thelabel"); cme.setQuantity(sb.literalExpression(66.66)); cme.setOpacity(sb.literalExpression(0.77)); cme.accept(visitor); ColorMapEntry cme2 = (ColorMapEntry) visitor.getCopy(); assertEquals( "Colormaps LABEL must be equal after duplication ", cme.getLabel(), cme2.getLabel()); assertEquals( "Colormaps QUANTITY must be equal after duplication ", cme.getQuantity(), cme2.getQuantity()); assertEquals( "Colormaps COLOR must be equal after duplication ", cme.getColor(), cme2.getColor()); assertEquals( "Colormaps OPACITY must be equal after duplication ", cme.getOpacity(), cme2.getOpacity()); }
/** * Encode colour map entries into a string. * * @param colourMap the colour map * @return the string */ public static String encode(ColorMap colourMap) { StringBuilder sb = new StringBuilder(); for (ColorMapEntry entry : colourMap.getColorMapEntries()) { sb.append((entry.getLabel() == null) ? "" : entry.getLabel()); sb.append(SEPARATOR); sb.append(entry.getColor()); sb.append(SEPARATOR); sb.append(Double.valueOf(entry.getOpacity().toString())); sb.append(SEPARATOR); sb.append(entry.getQuantity()); sb.append(ENTRY_SEPARATOR); } return sb.toString(); }
public void visit(ColorMapEntry colorEntry) { if (colorEntry != null) { AttributesImpl atts = new AttributesImpl(); atts.addAttribute("", "color", "color", "", colorEntry.getColor().toString()); if (colorEntry.getOpacity() != null) { atts.addAttribute("", "opacity", "opacity", "", colorEntry.getOpacity().toString()); } if (colorEntry.getQuantity() != null) { atts.addAttribute("", "quantity", "quantity", "", colorEntry.getQuantity().toString()); } if (colorEntry.getLabel() != null) { atts.addAttribute("", "label", "label", "", colorEntry.getLabel()); } element("ColorMapEntry", null, atts); } }
public void visit(ColorMapEntry colorEntry) { if (colorEntry != null) { AttributesImpl atts = new AttributesImpl(); atts.addAttribute("", "color", "color", "",colorEntry.getColor().evaluate(null, String.class)); if (colorEntry.getOpacity() != null) { atts.addAttribute("", "opacity", "opacity", "", colorEntry.getOpacity().toString()); } if (colorEntry.getQuantity() != null) { atts.addAttribute("", "quantity", "quantity", "", colorEntry.getQuantity().toString()); } if (colorEntry.getLabel() != null) { atts.addAttribute("", "label", "label", "", colorEntry.getLabel()); } element("ColorMapEntry", (String) null, atts); } }
/** * Parses the list. * * @param entries the entries */ public void parseList(List<ColorMapEntry> entries) { firstEntry = entries.get(0); String labelValue = firstEntry.getLabel(); String opacityValue = firstEntry.getOpacity().toString(); String quantityValue = firstEntry.getQuantity().toString(); String colourValue = firstEntry.getColor().toString(); for (ColorMapEntry entry : entries) { if ((labelValue != null) && labelValue.compareTo(entry.getLabel()) != 0) { labelMultipleValue = false; } if ((opacityValue != null) && opacityValue.compareTo(entry.getOpacity().toString()) != 0) { opacityMultipleValue = false; } if ((quantityValue != null) && quantityValue.compareTo(entry.getQuantity().toString()) != 0) { quantityMultipleValue = false; } if ((colourValue != null) && colourValue.compareTo(entry.getColor().toString()) != 0) { colourMultipleValue = false; } } }
/** * 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; }
public String[] getLabels(final int band) { String[] labels = null; if (this.symbolizer.getColorMap() != null) { final ColorMapEntry[] colors = this.symbolizer.getColorMap() .getColorMapEntries(); final int numColors = colors.length; labels = new String[numColors]; for (int ci = 0; ci < numColors; ci++) { labels[ci] = colors[ci].getLabel(); } } return labels; }
public void setEdited(ColorMapEntry entry) { this.entry = entry; if (entry != null) { guiColor.setExpression(entry.getColor()); guiLabel.setText(entry.getLabel()); guiOpacity.setExpression(entry.getOpacity()); guiQuantity.setExpression(entry.getQuantity()); } }
public void visit(ColorMapEntry colorMapEntry) { ColorMapEntry copy = sf.createColorMapEntry(); copy.setColor(copy(colorMapEntry.getColor())); copy.setLabel(colorMapEntry.getLabel()); copy.setOpacity(copy(colorMapEntry.getOpacity())); copy.setQuantity(colorMapEntry.getQuantity()); if (STRICT && !copy.equals(colorMapEntry)) { throw new IllegalStateException("Was unable to duplicate provided ColorMapEntry:" + colorMapEntry); } pages.push(copy); }
@Override public Tuple next() { ColorMapEntry entry = entries.next(); return Tuple.of( toColorOrNull(entry.getColor()), toObjOrNull(entry.getOpacity()), toObjOrNull(entry.getQuantity()), entry.getLabel()); }
/** * Populate. * * @param value the value */ public void populate(ColorMap value) { colourMapList.clear(); for (ColorMapEntry colourMapEntry : value.getColorMapEntries()) { Expression colourExpression = colourMapEntry.getColor(); Expression opacityExpression = colourMapEntry.getOpacity(); Expression quantityExpression = colourMapEntry.getQuantity(); String label = colourMapEntry.getLabel(); ColourMapData data = new ColourMapData(); data.setColour(colourExpression); data.setOpacity(opacityExpression); data.setQuantity(quantityExpression); data.setLabel(label); colourMapList.add(data); } this.fireTableDataChanged(); }
/** * Gets the colour map entry. * * @return the colour map entry */ public ColorMapEntry getColourMapEntry() { ColorMapEntry entry = new ColorMapEntryImpl(); if (firstEntry != null) { entry.setLabel(labelMultipleValue ? firstEntry.getLabel() : null); entry.setOpacity(opacityMultipleValue ? firstEntry.getOpacity() : null); entry.setQuantity(quantityMultipleValue ? firstEntry.getQuantity() : null); entry.setColor(colourMultipleValue ? firstEntry.getColor() : null); } return entry; } }