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

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

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

GetLegendGraphicRequest.setLocale介绍

[英]Sets the optional Locale to be used for text in legend output.
[中]设置用于图例输出中文本的可选区域设置。

代码示例

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

request.setLocale(new Locale(language));

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

/** Tests that minSymbolSize legend option is respected. */
@org.junit.Test
public void testInternationalizedLabels() throws Exception {
  GetLegendGraphicRequest req = new GetLegendGraphicRequest();
  Map<String, String> options = new HashMap<String, String>();
  options.put("forceLabels", "on");
  req.setLegendOptions(options);
  FeatureTypeInfo ftInfo =
      getCatalog()
          .getFeatureTypeByName(
              MockData.MPOINTS.getNamespaceURI(),
              MockData.MPOINTS.getLocalPart());
  req.setLayer(ftInfo.getFeatureType());
  req.setStyle(readSLD("Internationalized.sld"));
  BufferedImage image = this.legendProducer.buildLegendGraphic(req);
  int noLocalizedWidth = image.getWidth();
  req.setLocale(Locale.ITALIAN);
  image = this.legendProducer.buildLegendGraphic(req);
  // test that using localized labels we get a different label than when not using it
  int itWidth = image.getWidth();
  assertTrue(itWidth != noLocalizedWidth);
  req.setLocale(Locale.ENGLISH);
  image = this.legendProducer.buildLegendGraphic(req);
  // test that using localized labels we get a different label than when not using it
  int enWidth = image.getWidth();
  assertTrue(enWidth != noLocalizedWidth);
  assertTrue(enWidth != itWidth);
}

相关文章