org.geoserver.wms.GetLegendGraphicRequest.setWidth()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(5.0k)|赞(0)|评价(0)|浏览(114)

本文整理了Java中org.geoserver.wms.GetLegendGraphicRequest.setWidth()方法的一些代码示例,展示了GetLegendGraphicRequest.setWidth()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GetLegendGraphicRequest.setWidth()方法的具体详情如下:
包路径:org.geoserver.wms.GetLegendGraphicRequest
类名称:GetLegendGraphicRequest
方法名:setWidth

GetLegendGraphicRequest.setWidth介绍

暂无

代码示例

代码示例来源:origin: org.geoserver/gs-wms

/**
 * Ensures the online resource is stored on the GetLegendGraphicRequest and native dimensions
 * are configured if not specified on the original request.
 *
 * @param request GetLegendGraphicRequest original KWP Request
 * @param legend LegendRequest internal Class containing references to Resources
 * @param legendInfo LegendInfo used to document use external graphic
 */
private void configureLegendInfo(
    GetLegendGraphicRequest request, LegendRequest legend, LegendInfo legendInfo) {
  legend.setLegendInfo(legendInfo);
  if (legendInfo.getHeight() > 0 && !request.getKvp().containsKey("HEIGHT")) {
    request.setHeight(legendInfo.getHeight());
  }
  if (legendInfo.getWidth() > 0 && !request.getKvp().containsKey("WIDTH")) {
    request.setWidth(legendInfo.getWidth());
  }
}
/**

代码示例来源:origin: robward-scisys/sldeditor

request.setWidth(legendOptionData.getImageWidth());
request.setHeight(legendOptionData.getImageHeight());
request.setTransparent(legendOptionData.isTransparent());

代码示例来源:origin: org.geoserver/gs-wms

/** Tests that symbols relative sizes are proportional. */
@org.junit.Test
public void testThickPolygonBorder() throws Exception {
  GetLegendGraphicRequest req = new GetLegendGraphicRequest();
  req.setWidth(20);
  req.setHeight(20);
  FeatureTypeInfo ftInfo =
      getCatalog()
          .getFeatureTypeByName(
              MockData.MPOINTS.getNamespaceURI(),
              MockData.MPOINTS.getLocalPart());
  req.setLayer(ftInfo.getFeatureType());
  req.setStyle(readSLD("ThickBorder.sld"));
  BufferedImage image = this.legendProducer.buildLegendGraphic(req);
  assertNotBlank("testThickPolygonBorder", image, LegendUtils.DEFAULT_BG_COLOR);
  // thick symbol, there is padding, black thick border, and center
  assertPixel(image, 1, 1, new Color(255, 255, 255));
  assertPixel(image, 6, 6, new Color(0, 0, 0));
  assertPixel(image, 10, 10, new Color(255, 0, 0));
  // second symbol, padding, border, green center
  assertPixel(image, 1, 21, new Color(255, 255, 255));
  // assertPixel(image, 4, 25, new Color(0, 0, 0)); // unsafe, the border is thin here
  assertPixel(image, 10, 30, new Color(0, 255, 0));
}

代码示例来源:origin: org.geoserver/gs-wms

/** Tests that symbols relative sizes are proportional. */
@org.junit.Test
public void testThickPolygonAsymmetricSymbol() throws Exception {
  GetLegendGraphicRequest req = new GetLegendGraphicRequest();
  req.setWidth(40);
  req.setHeight(20);
  FeatureTypeInfo ftInfo =
      getCatalog()
          .getFeatureTypeByName(
              MockData.MPOINTS.getNamespaceURI(),
              MockData.MPOINTS.getLocalPart());
  req.setLayer(ftInfo.getFeatureType());
  req.setStyle(readSLD("ThickBorder.sld"));
  BufferedImage image = this.legendProducer.buildLegendGraphic(req);
  assertNotBlank("testThickPolygonBorder", image, LegendUtils.DEFAULT_BG_COLOR);
  // thick symbol, there is padding, black thick border, and center
  assertPixel(image, 1, 1, new Color(255, 255, 255));
  assertPixel(image, 9, 6, new Color(0, 0, 0));
  assertPixel(image, 20, 10, new Color(255, 0, 0));
  // second symbol, padding, border, green center
  assertPixel(image, 1, 23, new Color(255, 255, 255));
  // assertPixel(image, 4, 25, new Color(0, 0, 0)); // unsafe, the border is thin here
  assertPixel(image, 20, 30, new Color(0, 255, 0));
}

代码示例来源:origin: org.geoserver/gs-wms

/** Tests that symbols relative sizes are proportional. */
@org.junit.Test
public void testLargeCirclePlacement() throws Exception {
  GetLegendGraphicRequest req = new GetLegendGraphicRequest();
  req.setWidth(48);
  req.setHeight(25);
  FeatureTypeInfo ftInfo =
      getCatalog()
          .getFeatureTypeByName(
              MockData.MPOINTS.getNamespaceURI(),
              MockData.MPOINTS.getLocalPart());
  req.setLayer(ftInfo.getFeatureType());
  req.setStyle(readSLD("largeCircle.sld"));
  BufferedImage image = this.legendProducer.buildLegendGraphic(req);
  assertNotBlank("largeCircle", image, LegendUtils.DEFAULT_BG_COLOR);
  // the border is visible both top middle and bottom middle. Different JDK
  // build wildly different colors for the border unfortunately, so the test
  // checks that pixels at top/middle bottom/middle are similar color (they used to be
  // different, significantly)
  Color colorTop = getPixelColor(image, 24, 0);
  Color colorBottom = getPixelColor(image, 24, 24);
  assertColorSimilar(colorTop, colorBottom, 20);
}

代码示例来源:origin: org.geoserver/gs-wms

/** Tests that symbols relative sizes are proportional. */
@org.junit.Test
public void testSimpleLine() throws Exception {
  GetLegendGraphicRequest req = new GetLegendGraphicRequest();
  req.setWidth(20);
  req.setHeight(20);
  FeatureTypeInfo ftInfo =
      getCatalog()
          .getFeatureTypeByName(
              MockData.MPOINTS.getNamespaceURI(),
              MockData.MPOINTS.getLocalPart());
  req.setLayer(ftInfo.getFeatureType());
  req.setStyle(readSLD("line.sld"));
  BufferedImage image = this.legendProducer.buildLegendGraphic(req);
  assertNotBlank("line", image, LegendUtils.DEFAULT_BG_COLOR);
  // line in the middle, but off the middle, it's white
  Color colorCenter = getPixelColor(image, 10, 10);
  assertColorSimilar(Color.BLUE, colorCenter, 20);
  Color colorOutsideCenter = getPixelColor(image, 6, 6);
  assertColorSimilar(Color.WHITE, colorOutsideCenter, 20);
}

相关文章