/** * Helper method that get layer legends info by merging deprecated legends info objects with the * new ones. */ private Map<String, LegendInfo> getLegendsInfo(TileLayer layer) { Map<String, LegendInfo> legendsInfo = new HashMap<>(); for (Map.Entry<String, TileLayer.LegendInfo> entry : layer.getLegendsInfo().entrySet()) { // convert deprecated model to new model legendsInfo.put( entry.getKey(), new LegendInfoBuilder() .withWidth(entry.getValue().width) .withHeight(entry.getValue().height) .withFormat(entry.getValue().format) .withCompleteUrl(entry.getValue().legendUrl) .withStyleName(entry.getKey()) .build()); } // add the new legend info model objects legendsInfo.putAll(layer.getLayerLegendsInfo()); return legendsInfo; }
String baseUrl = baseUrl(); gwcLegendInfo .withStyleName(styleInfo.getName()) .withWidth(legendInfo.getWidth()) .withHeight(legendInfo.getHeight()) .withStyleName(styleInfo.getName()) .withWidth(finalWidth) .withHeight(finalHeight)
.withStyleName("styla-b-legend") .withWidth(125) .withHeight(130)
@Test public void testWithValuesNoDefaults() { LegendInfo legendInfo = new LegendInfoBuilder() .withLayerName("layer1") .withLayerUrl("http://localhost:8080/geoserver") .withStyleName("style1") .withWidth(150) .withHeight(200) .withFormat("image/gif") .withMinScale(50.5) .withMaxScale(80.5) .build(); assertThat(legendInfo.getWidth(), is(150)); assertThat(legendInfo.getHeight(), is(200)); assertThat(legendInfo.getFormat(), is("image/gif")); assertThat(legendInfo.getStyleName(), is("style1")); assertThat(legendInfo.getMinScale(), is(50.5)); assertThat(legendInfo.getMaxScale(), is(80.5)); assertThat( legendInfo.getLegendUrl(), is( "http://localhost:8080/geoserver?" + "service=WMS&request=GetLegendGraphic&format=image/gif&width=150&height=200&layer=layer1&style=style1")); } }
/** * Build the concrete legend information using the provided layer information and defaults * values. */ public LegendInfo getLegendInfo( String layerName, String layerUrl, Integer defaultWidth, Integer defaultHeight, String defaultFormat) { return new LegendInfoBuilder() .withLayerName(layerName) .withLayerUrl(layerUrl) .withDefaultWidth(defaultWidth) .withDefaultHeight(defaultHeight) .withDefaultFormat(defaultFormat) .withStyleName(style) .withWidth(width) .withHeight(height) .withFormat(format) .withUrl(url) .withCompleteUrl(completeUrl) .withMinScale(minScale) .withMaxScale(maxScale) .build(); }
@Test public void testWithCompleteUrl() { LegendInfo legendInfo = new LegendInfoBuilder() .withLayerName("layer1") .withLayerUrl("http://localhost:8080/geoserver") .withDefaultWidth(50) .withDefaultHeight(100) .withDefaultFormat("image/png") .withStyleName("style1") .withWidth(150) .withHeight(200) .withFormat("image/gif") .withCompleteUrl("http://my.server.com/image.gif") .build(); assertThat(legendInfo.getWidth(), is(150)); assertThat(legendInfo.getHeight(), is(200)); assertThat(legendInfo.getFormat(), is("image/gif")); assertThat(legendInfo.getStyleName(), is("style1")); assertThat(legendInfo.getLegendUrl(), is("http://my.server.com/image.gif")); }
@Test public void testWithUrl() { LegendInfo legendInfo = new LegendInfoBuilder() .withLayerName("layer1") .withLayerUrl("http://localhost:8080/geoserver") .withDefaultWidth(50) .withDefaultHeight(100) .withDefaultFormat("image/png") .withStyleName("style1") .withWidth(150) .withHeight(200) .withFormat("image/gif") .withUrl("http://localhost:9090/image.gif?") .build(); assertThat(legendInfo.getWidth(), is(150)); assertThat(legendInfo.getHeight(), is(200)); assertThat(legendInfo.getFormat(), is("image/gif")); assertThat(legendInfo.getStyleName(), is("style1")); assertThat( legendInfo.getLegendUrl(), is( "http://localhost:9090/image.gif?" + "service=WMS&request=GetLegendGraphic&format=image/gif&width=150&height=200&layer=layer1&style=style1")); }
@Test public void testWithValues() { LegendInfo legendInfo = new LegendInfoBuilder() .withLayerName("layer1") .withLayerUrl("http://localhost:8080/geoserver") .withDefaultWidth(50) .withDefaultHeight(100) .withDefaultFormat("image/png") .withStyleName("style1") .withWidth(150) .withHeight(200) .withFormat("image/gif") .withMinScale(1000.55) .withMaxScale(2000.655) .build(); assertThat(legendInfo.getWidth(), is(150)); assertThat(legendInfo.getHeight(), is(200)); assertThat(legendInfo.getFormat(), is("image/gif")); assertThat(legendInfo.getStyleName(), is("style1")); assertThat(legendInfo.getMinScale(), is(1000.55)); assertThat(legendInfo.getMaxScale(), is(2000.655)); assertThat( legendInfo.getLegendUrl(), is( "http://localhost:8080/geoserver?" + "service=WMS&request=GetLegendGraphic&format=image/gif&width=150&height=200&layer=layer1&style=style1")); }
.withStyleName("styla-b-legend") .withWidth(125) .withHeight(130)