gpt4 book ai didi

org.geotools.ysld.parse.YamlParseContext.push()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 13:21:15 30 4
gpt4 key购买 nike

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

YamlParseContext.push介绍

[英]Parse a child of the current object if present
[中]分析当前对象的子对象(如果存在)

代码示例

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

/**
 * Parse a child of the current object if present
 *
 * @param key key of the child entry
 * @param handler handler to use
 * @return self
 */
public YamlParseContext push(String key, YamlParseHandler handler) {
  return push(curr.obj, key, handler);
}

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

@Override
  public void handle(YamlObject<?> obj, YamlParseContext context) {
    YamlSeq seq = obj.seq();
    for (YamlObject o : seq) {
      context.push(
          o,
          "mark",
          new MarkParser(factory) {
            @Override
            protected void mark(Mark mark) {
              g.graphicalSymbols().add(mark);
            }
          });
      context.push(
          o,
          "external",
          new ExternalGraphicParser(factory) {
            @Override
            protected void externalGraphic(ExternalGraphic externalGraphic) {
              g.graphicalSymbols().add(externalGraphic);
            }
          });
    }
  }
}

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

@Override
  public void handle(YamlObject<?> obj, YamlParseContext context) {
    super.handle(obj, context);
    context.push(new GraphicParser(factory, sym.getGraphic()));
  }
}

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

@Override
  public void handle(YamlObject<?> obj, YamlParseContext context) {
    String name = obj.map().str("name");
    sel.setChannelName(name);
    context.push(
        "contrast-enhancement",
        new ContrastEnhancementHandler() {
          @Override
          protected void set() {
            sel.setContrastEnhancement(this.contrast);
          }
        });
  }
}

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

@Override
  public void handle(YamlObject<?> obj, YamlParseContext context) {
    YamlSeq seq = obj instanceof YamlMap ? YamlSeq.from(obj) : obj.seq();

    for (YamlObject o : seq) {
      YamlMap sym = o.map();

      if (sym.has("point")) {
        context.push(sym, "point", new PointParser(rule, factory));
      } else if (sym.has("line")) {
        context.push(sym, "line", new LineParser(rule, factory));
      } else if (sym.has("polygon")) {
        context.push(sym, "polygon", new PolygonParser(rule, factory));
      } else if (sym.has("text")) {
        context.push(sym, "text", new TextParser(rule, factory));
      } else if (sym.has("raster")) {
        context.push(sym, "raster", new RasterParser(rule, factory));
      }
    }
  }
}

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

@Override
public void handle(YamlObject<?> obj, YamlParseContext context) {
  super.handle(obj, context);
  YamlMap map = obj.map();
  if (map.has("opacity")) {
    sym.setOpacity(Util.expression(map.str("opacity"), factory));
  }
  context.push(
      "color-map",
      new ColorMapParser(factory) {
        @Override
        protected void colorMap(ColorMap colorMap) {
          sym.setColorMap(colorMap);
        }
      });
  context.push("contrast-enhancement", new ContrastEnhancementHandler());
  context.push("channels", new ChannelsHandler());
}

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

void parse(Band band, SelectedChannelType sel, YamlMap map, YamlParseContext context) {
  if (map.get(band.key) instanceof Map) {
    context.push(band.key, new SelectedChannelHandler(sel));
  } else {
    sel.setChannelName(map.str(band.key));
  }
}

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

@Override
public void handle(YamlObject<?> obj, YamlParseContext context) {
  mark(mark);
  YamlMap map = obj.map();
  if (map.has("shape")) {
    mark.setWellKnownName(Util.expression(map.str("shape"), factory));
  }
  context.push(
      new StrokeParser(factory) {
        @Override
        protected void stroke(Stroke stroke) {
          mark.setStroke(stroke);
        }
      });
  context.push(
      new FillParser(factory) {
        @Override
        protected void fill(Fill fill) {
          mark.setFill(fill);
        }
      });
}

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

@Override
public void handle(YamlObject<?> obj, YamlParseContext context) {
  colorMap(colorMap);
  YamlMap map = obj.map();
  if (map.has("type")) {
    String value = map.str("type");
    if ("ramp".equals(value)) {
      colorMap.setType(ColorMap.TYPE_RAMP);
    } else if ("intervals".equals(value)) {
      colorMap.setType(ColorMap.TYPE_INTERVALS);
    } else if ("values".equals(value)) {
      colorMap.setType(ColorMap.TYPE_VALUES);
    } else {
      LOG.warning("Unknown color map type: " + value);
    }
  }
  context.push("entries", new EntriesParser());
}

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

context.push(new FontHandler());
context.push("halo", new HaloParser());
context.push(new PlacementParser());
context.push(
    new FillParser(factory) {
      @Override
context.push(
    "graphic",
    new GraphicParser(factory) {

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

/**
   * Parse the yaml provided to this instance using the provided {@link YamlParseHandler}.
   *
   * @param root The {@link YamlParseHandler} that handles the root of the parsed {@link
   *     YamlObject}.
   * @param hints
   * @return The root {@link YamlParseHandler}, once it has finished handling the parsed {@link
   *     YamlObject}..
   * @throws IOException
   */
  @SuppressWarnings("PMD.EmptyWhileStmt")
  public <T extends YamlParseHandler> T parse(T root, Map<String, Object> hints)
      throws IOException {
    Object parsed = YamlUtil.getSafeYaml().load(yaml);

    YamlParseContext context = new YamlParseContext();
    context.mergeDocHints(hints);
    context.push(YamlObject.create(parsed), root);

    while (context.next()) ;

    return root;
  }
}

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

@Override
  public void handle(YamlObject<?> obj, YamlParseContext context) {
    super.handle(obj, context);

    YamlMap map = obj.map();
    context.push(
        new StrokeParser(factory) {
          @Override
          protected void stroke(Stroke stroke) {
            sym.setStroke(stroke);
          }
        });
    if (map.has("offset")) {
      sym.setPerpendicularOffset(Util.expression(map.str("offset"), factory));
    }
  }
}

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

@Override
  public void handle(YamlObject<?> obj, YamlParseContext context) {
    sym.setHalo(halo);
    YamlMap map = obj.map();
    context.push(
        new FillParser(factory) {
          @Override
          protected void fill(Fill fill) {
            halo.setFill(fill);
          }
        });
    if (map.has("radius")) {
      halo.setRadius(Util.expression(map.str("radius"), factory));
    }
  }
}

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

@Override
  public void handle(YamlObject<?> obj, YamlParseContext context) {
    super.handle(obj, context);

    YamlMap map = obj.map();
    context.push(
        new StrokeParser(factory) {
          @Override
          protected void stroke(Stroke stroke) {
            sym.setStroke(stroke);
          }
        });
    context.push(
        new FillParser(factory) {
          @Override
          protected void fill(Fill fill) {
            sym.setFill(fill);
          }
        });

    if (map.has("offset")) {
      sym.setPerpendicularOffset(Util.expression(map.str("offset"), factory));
    }
    if (map.has("displacement")) {
      sym.setDisplacement(Util.displacement(map.str("displacement"), factory));
    }
  }
}

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

@Override
  public void handle(YamlObject<?> obj, YamlParseContext context) {
    YamlSeq seq = obj.seq();
    for (YamlObject<?> o : seq) {
      YamlMap fs = o.map();

      FeatureTypeStyle featureStyle = factory.style.createFeatureTypeStyle();
      style.featureTypeStyles().add(featureStyle);

      featureStyle.setName(fs.str("name"));
      if (fs.has("title")) {
        featureStyle.getDescription().setTitle(fs.str("title"));
      }
      if (fs.has("abstract")) {
        featureStyle.getDescription().setAbstract(fs.str("abstract"));
      }

      featureStyle.getOptions().putAll(Util.vendorOptions(fs));

      context.push(fs, "transform", new TransformHandler(featureStyle, factory));
      context.push(fs, "rules", new RuleParser(featureStyle, factory));
    }
  }
}

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

context.push("feature-styles", new FeatureStyleParser(style, factory));
} else if (root.has("rules")) {
  context.push("rules", new RuleParser(newFeatureTypeStyle(), factory));
} else if (root.has("symbolizers")) {
  context.push("symbolizers", new SymbolizersParser(newRule(), factory));
} else if (root.has("point")
    || root.has("line")
    || root.has("text")
    || root.has("raster")) {
  context.push(new SymbolizersParser(newRule(), factory));

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

@Override
public void handle(YamlObject<?> obj, YamlParseContext context) {
  YamlMap map = obj.map();
  if (map.has("fill-color")) {
    fill().setColor(Util.color(map.get("fill-color"), factory));
  }
  if (map.has("fill-opacity")) {
    fill().setOpacity(Util.expression(map.str("fill-opacity"), factory));
  }
  context.push(
      "fill-graphic",
      new GraphicParser(factory) {
        @Override
        protected void graphic(Graphic g) {
          fill().setGraphicFill(g);
        }
      });
}

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

context.push(
    r,
    "legend",
context.push(r, "symbolizers", new SymbolizersParser(rule, factory));

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

@Test
  public void testDocHints() throws Exception {
    YamlParseContext ctxt = new YamlParseContext();
    YamlParseHandler handler = createMock(YamlParseHandler.class);
    YamlObject obj1 = createMock(YamlObject.class);

    replay(handler);

    ctxt.push(obj1, handler);

    assertThat(ctxt.getDocHint("testHint1"), nullValue());
    ctxt.setDocHint("testHint1", "th1v1");
    assertThat((String) ctxt.getDocHint("testHint1"), is("th1v1"));
    ctxt.setDocHint("testHint1", "th1v2");
    assertThat((String) ctxt.getDocHint("testHint1"), is("th1v2"));

    assertThat(ctxt.getDocHint("testHint2"), nullValue());
    ctxt.setDocHint("testHint2", "th2v1");
    assertThat((String) ctxt.getDocHint("testHint2"), is("th2v1"));
    assertThat((String) ctxt.getDocHint("testHint1"), is("th1v2"));

    verify(handler);
  }
}

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

@Override
public void handle(YamlObject<?> obj, YamlParseContext context) {
  graphic(g);
  YamlMap map = obj.map();
  if (map.has("anchor")) {
    g.setAnchorPoint(Util.anchor(map.get("anchor"), factory));
  }
  if (map.has("opacity")) {
    g.setOpacity(Util.expression(map.str("opacity"), factory));
  }
  if (map.has("size")) {
    g.setSize(Util.expression(map.str("size"), factory));
  }
  if (map.has("displacement")) {
    g.setDisplacement(Util.displacement(map.get("displacement"), factory));
  }
  if (map.has("rotation")) {
    g.setRotation(Util.expression(map.str("rotation"), factory));
  }
  if (map.has("gap")) {
    g.setGap(Util.expression(map.str("gap"), factory));
  }
  if (map.has("initial-gap")) {
    g.setInitialGap(Util.expression(map.str("initial-gap"), factory));
  }
  context.push("symbols", new SymbolsParser());
}

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com