/** @param graphics */ private void cycleBodyRows(Graphics2D graphics) { for (ColorMapEntryLegendBuilder row : bodyRows) { // // row number i // // color element final Cell cm = row.getColorManager(); final Dimension colorDim = cm.getPreferredDimension(graphics); rowH = Math.max(rowH, colorDim.getHeight()); colorW = Math.max(colorW, colorDim.getWidth()); // rule if (forceRule) { final Cell ruleM = row.getRuleManager(); final Dimension ruleDim = ruleM.getPreferredDimension(graphics); rowH = Math.max(rowH, ruleDim.getHeight()); ruleW = Math.max(ruleW, ruleDim.getWidth()); } // label final Cell labelM = row.getLabelManager(); if (labelM == null) continue; final Dimension labelDim = labelM.getPreferredDimension(graphics); rowH = Math.max(rowH, labelDim.getHeight()); labelW = Math.max(labelW, labelDim.getWidth()); } }
if (forceRule) { final Cell ruleCell = row.getRuleManager();
@Test public void testRuleTextIntervalsThreeElements() { StyleBuilder sb = new StyleBuilder(); ColorMap cmap = sb.createColorMap( new String[] {null, null, null}, new double[] {10, 50, 100}, new Color[] {Color.RED, Color.WHITE, Color.BLUE}, ColorMap.TYPE_INTERVALS); Style style = sb.createStyle(sb.createRasterSymbolizer(cmap, 1)); RasterLayerLegendHelper helper = new RasterLayerLegendHelper(request, style, null); List<ColorMapEntryLegendBuilder> rows = new ArrayList<>(helper.getcMapLegendCreator().getBodyRows()); assertEquals(3, rows.size()); ColorMapEntryLegendBuilder firstRow = rows.get(0); assertEquals("x < 10.0", firstRow.getRuleManager().text); ColorMapEntryLegendBuilder midRow = rows.get(1); assertEquals("10.0 <= x < 50.0", midRow.getRuleManager().text); ColorMapEntryLegendBuilder lastRow = rows.get(2); assertEquals("50.0 <= x < 100.0", lastRow.getRuleManager().text); }
ColorMapEntryLegendBuilder firstRow = rows.get(0); assertEquals(colourToTest, firstRow.getColorManager().borderColor); assertEquals(colourToTest, firstRow.getRuleManager().borderColor); ColorMapEntryLegendBuilder midRow = rows.get(1); assertEquals(colourToTest, midRow.getColorManager().borderColor); assertEquals(colourToTest, midRow.getRuleManager().borderColor); firstRow = rows.get(0); assertEquals(colourToTest, firstRow.getColorManager().borderColor); assertEquals(colourToTest, firstRow.getRuleManager().borderColor); midRow = rows.get(1); assertEquals(colourToTest, midRow.getColorManager().borderColor); assertEquals(colourToTest, midRow.getRuleManager().borderColor); firstRow = rows.get(0); assertEquals(colourToTest, firstRow.getColorManager().borderColor); assertEquals(colourToTest, firstRow.getRuleManager().borderColor); midRow = rows.get(1); assertEquals(colourToTest, midRow.getColorManager().borderColor); assertEquals(colourToTest, midRow.getRuleManager().borderColor);
@Test public void testRuleTextRampThreeElements() { StyleBuilder sb = new StyleBuilder(); ColorMap cmap = sb.createColorMap( new String[] {null, null, null}, new double[] {10, 50, 100}, new Color[] {Color.RED, Color.WHITE, Color.BLUE}, ColorMap.TYPE_RAMP); Style style = sb.createStyle(sb.createRasterSymbolizer(cmap, 1)); RasterLayerLegendHelper helper = new RasterLayerLegendHelper(request, style, null); List<ColorMapEntryLegendBuilder> rows = new ArrayList<>(helper.getcMapLegendCreator().getBodyRows()); assertEquals(3, rows.size()); ColorMapEntryLegendBuilder firstRow = rows.get(0); assertEquals("10.0 >= x", firstRow.getRuleManager().text); ColorMapEntryLegendBuilder midRow = rows.get(1); assertEquals("50.0 = x", midRow.getRuleManager().text); ColorMapEntryLegendBuilder lastRow = rows.get(2); assertEquals("100.0 <= x", lastRow.getRuleManager().text); }
@Test public void testInfiniteOnIntervals() { StyleBuilder sb = new StyleBuilder(); ColorMap cmap = sb.createColorMap( new String[] {null, null, null}, new double[] {Double.NEGATIVE_INFINITY, 50, Double.POSITIVE_INFINITY}, new Color[] {Color.RED, Color.WHITE, Color.BLUE}, ColorMap.TYPE_INTERVALS); Style style = sb.createStyle(sb.createRasterSymbolizer(cmap, 1)); RasterLayerLegendHelper helper = new RasterLayerLegendHelper(request, style, null); List<ColorMapEntryLegendBuilder> rows = new ArrayList<>(helper.getcMapLegendCreator().getBodyRows()); assertEquals(2, rows.size()); ColorMapEntryLegendBuilder firstRow = rows.get(0); assertEquals("x < 50.0", firstRow.getRuleManager().text); ColorMapEntryLegendBuilder midRow = rows.get(1); assertEquals("50.0 <= x", midRow.getRuleManager().text); }
@Test public void testRuleTextIntervalsTwoElements() { StyleBuilder sb = new StyleBuilder(); ColorMap cmap = sb.createColorMap( new String[] {null, null}, new double[] {10, 100}, new Color[] {Color.RED, Color.BLUE}, ColorMap.TYPE_INTERVALS); Style style = sb.createStyle(sb.createRasterSymbolizer(cmap, 1)); RasterLayerLegendHelper helper = new RasterLayerLegendHelper(request, style, null); List<ColorMapEntryLegendBuilder> rows = new ArrayList<>(helper.getcMapLegendCreator().getBodyRows()); assertEquals(2, rows.size()); ColorMapEntryLegendBuilder firstRow = rows.get(0); assertEquals("x < 10.0", firstRow.getRuleManager().text); ColorMapEntryLegendBuilder lastRow = rows.get(1); assertEquals("10.0 <= x < 100.0", lastRow.getRuleManager().text); }
@Test public void testRuleTextRampTwoElements() { StyleBuilder sb = new StyleBuilder(); ColorMap cmap = sb.createColorMap( new String[] {null, null}, new double[] {10, 100}, new Color[] {Color.RED, Color.BLUE}, ColorMap.TYPE_RAMP); Style style = sb.createStyle(sb.createRasterSymbolizer(cmap, 1)); RasterLayerLegendHelper helper = new RasterLayerLegendHelper(request, style, null); List<ColorMapEntryLegendBuilder> rows = new ArrayList<>(helper.getcMapLegendCreator().getBodyRows()); assertEquals(2, rows.size()); ColorMapEntryLegendBuilder firstRow = rows.get(0); assertEquals("10.0 >= x", firstRow.getRuleManager().text); ColorMapEntryLegendBuilder lastRow = rows.get(1); assertEquals("100.0 <= x", lastRow.getRuleManager().text); }
@Test public void testRuleTextRampOneElements() { StyleBuilder sb = new StyleBuilder(); ColorMap cmap = sb.createColorMap( new String[] {null}, new double[] {10}, new Color[] {Color.RED}, ColorMap.TYPE_RAMP); Style style = sb.createStyle(sb.createRasterSymbolizer(cmap, 1)); RasterLayerLegendHelper helper = new RasterLayerLegendHelper(request, style, null); List<ColorMapEntryLegendBuilder> rows = new ArrayList<>(helper.getcMapLegendCreator().getBodyRows()); assertEquals(1, rows.size()); ColorMapEntryLegendBuilder firstRow = rows.get(0); assertEquals("", firstRow.getRuleManager().text); }
@Test public void testRuleTextIntervalOneElements() { StyleBuilder sb = new StyleBuilder(); ColorMap cmap = sb.createColorMap( new String[] {null}, new double[] {10}, new Color[] {Color.RED}, ColorMap.TYPE_INTERVALS); Style style = sb.createStyle(sb.createRasterSymbolizer(cmap, 1)); RasterLayerLegendHelper helper = new RasterLayerLegendHelper(request, style, null); List<ColorMapEntryLegendBuilder> rows = new ArrayList<>(helper.getcMapLegendCreator().getBodyRows()); assertEquals(1, rows.size()); ColorMapEntryLegendBuilder firstRow = rows.get(0); assertEquals("x < 10.0", firstRow.getRuleManager().text); }