org.geotools.styling.Rule.setLegend()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(2.2k)|赞(0)|评价(0)|浏览(94)

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

Rule.setLegend介绍

暂无

代码示例

代码示例来源:origin: geotools/geotools

@Override
  protected void graphic(Graphic g) {
    rule.setLegend(g);
  }
});

代码示例来源:origin: geotools/geotools

public Rule build() {
  if (unset) {
    return null;
  }
  if (symbolizerBuilder == null && symbolizers.size() == 0) {
    symbolizerBuilder = new PointSymbolizerBuilder();
  }
  if (symbolizerBuilder != null) {
    symbolizers.add(symbolizerBuilder.build());
  }
  Rule rule = sf.createRule();
  rule.setName(name);
  // TODO: rule's description cannot be set
  rule.setTitle(title);
  rule.setAbstract(ruleAbstract);
  rule.setMinScaleDenominator(minScaleDenominator);
  rule.setMaxScaleDenominator(maxScaleDenominator);
  rule.setFilter(filter);
  rule.setElseFilter(elseFilter);
  rule.symbolizers().addAll(symbolizers);
  GraphicLegend gl = legend.build();
  if (gl != null) {
    rule.setLegend(gl);
  }
  if (parent == null) {
    reset();
  }
  return rule;
}

代码示例来源:origin: geotools/geotools

@Test
public void testLegend() throws Exception {
  StyleFactory sf = CommonFactoryFinder.getStyleFactory();
  FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
  PointSymbolizer p = sf.createPointSymbolizer();
  Mark mark = sf.mark(ff.literal("circle"), sf.fill(null, ff.literal("#FF0000"), null), null);
  p.setGraphic(sf.createGraphic(null, new Mark[] {mark}, null, null, null, null));
  Rule rule = sf.createRule();
  rule.symbolizers().add(p);
  ExternalGraphic eg = sf.createExternalGraphic("smileyface.png", "image/png");
  rule.setLegend(sf.createGraphic(new ExternalGraphic[] {eg}, null, null, null, null, null));
  StringWriter out = new StringWriter();
  Ysld.encode(sld(sf.createFeatureTypeStyle(new Rule[] {rule})), out);
  // System.out.append(out.toString());
  YamlMap obj = new YamlMap(YamlUtil.getSafeYaml().load(out.toString()));
  YamlMap result =
      obj.seq("feature-styles")
          .map(0)
          .seq("rules")
          .map(0)
          .map("legend")
          .seq("symbols")
          .map(0)
          .map("external");
  assertEquals("smileyface.png", result.str("url"));
  assertEquals("image/png", result.str("format"));
}

相关文章