Package org.geomajas.configuration

Examples of org.geomajas.configuration.NamedStyleInfo


  public void testSingleStyle() throws JiBXException, LayerException {
    IBindingFactory bfact = BindingDirectory.getFactory(StyledLayerDescriptorInfo.class);
    IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
    Object object = uctx.unmarshalDocument(getClass().getResourceAsStream("/org/geomajas/testdata/sld/single_layer_no_stylename.sld"), null);
    StyledLayerDescriptorInfo sld = (StyledLayerDescriptorInfo) object;
    NamedStyleInfo info = styleConverterService.convert(sld, featureInfo, "layer", "style");
    Assert.assertNotNull(info);
    Assert.assertEquals("Some title", info.getName());
  }
View Full Code Here


  public void testPickStyle() throws JiBXException, LayerException {
    IBindingFactory bfact = BindingDirectory.getFactory(StyledLayerDescriptorInfo.class);
    IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
    Object object = uctx.unmarshalDocument(getClass().getResourceAsStream("/org/geomajas/testdata/sld/multiple_layer_stylename.sld"), null);
    StyledLayerDescriptorInfo sld = (StyledLayerDescriptorInfo) object;
    NamedStyleInfo info1 = styleConverterService.convert(sld, featureInfo, "Layer1", "Style1");
    Assert.assertNotNull(info1);
    Assert.assertEquals("Style1", info1.getName());
    Assert.assertEquals(1, info1.getFeatureStyles().size());
   
    NamedStyleInfo info2 = styleConverterService.convert(sld, featureInfo, "Layer2", "Style2");
    Assert.assertNotNull(info2);
    Assert.assertEquals("Style2", info2.getName());
    Assert.assertEquals(2, info2.getFeatureStyles().size());
  }
View Full Code Here

    obj.setPaintGeometries(true);
    obj.setPaintLabels(false);
    obj.setPanOrigin(new Coordinate(10, 20));
    obj.setRenderer("SVG");
    obj.setScale(2.5);
    NamedStyleInfo nsi = new NamedStyleInfo();
    nsi.setName("nsi");
    obj.setStyleInfo(nsi);
  }
View Full Code Here

      if (null == styleName || null == featureStyleId || "".equals(styleName) || "".equals(featureStyleId)) {
        throw new AdvancedviewsException(AdvancedviewsException.REQUIRED_PARAMETER_MISSING);
      }

      VectorLayer vl = (VectorLayer) l;
      NamedStyleInfo nsi = vl.getLayerInfo().getNamedStyleInfo(styleName);
      if (null == nsi) {
        throw new AdvancedviewsException(AdvancedviewsException.NO_SUCH_NAMEDSTYLE, styleName);
      }

      FeatureStyleInfo fsi = null;
      for (FeatureStyleInfo tmp : nsi.getFeatureStyles()) {
        if (featureStyleId.equals(tmp.getStyleId())) {
          fsi = tmp;
          break;
        }
      }
View Full Code Here

      VectorLayer layer = context.get(PipelineCode.LAYER_KEY, VectorLayer.class);
      Filter filter = context.get(PipelineCode.FILTER_KEY, Filter.class);
      int offset = context.get(PipelineCode.OFFSET_KEY, Integer.class);
      int maxResultSize = context.get(PipelineCode.MAX_RESULT_SIZE_KEY, Integer.class);
      int featureIncludes = context.get(PipelineCode.FEATURE_INCLUDES_KEY, Integer.class);
      NamedStyleInfo style = context.get(PipelineCode.STYLE_KEY, NamedStyleInfo.class);
      CrsTransform transformation = context.getOptional(PipelineCode.CRS_TRANSFORM_KEY, CrsTransform.class);
      List<StyleFilter> styleFilters = context.getOptional(GetFeaturesStyleStep.STYLE_FILTERS_KEY, List.class);

      if (log.isDebugEnabled()) {
        log.debug("getElements " + filter + ", offset = " + offset + ", maxResultSize= " + maxResultSize);
      }
      Envelope bounds = null;
      Iterator<?> it = layer.getElements(filter, 0, 0); // do not limit result here, security needs to be applied

      int count = 0;
      while (it.hasNext()) {
        log.debug("process feature");
        Object featureObj = it.next();
        Geometry geometry = layer.getFeatureModel().getGeometry(featureObj);
        InternalFeature feature = convertFeature(featureObj, geometry, layer, transformation,
            styleFilters, style.getLabelStyle(), featureIncludes);
        if (null != feature) {
          count++;
          if (count > offset) {
            features.add(feature);
View Full Code Here

    }

    public void init() {
      if (layer instanceof VectorLayer) {
        VectorLayer vl = (VectorLayer) layer;
        NamedStyleInfo nsi = vl.getLayerInfo().getNamedStyleInfo();
        for (FeatureStyleInfo fsi : nsi.getFeatureStyles()) {
          LayerTreeLegendItemNode tn = new LayerTreeLegendItemNode(this, vl.getServerLayerId(),
              nsi.getName(), fsi);
          tree.add(tn, this);
        }
      } else {
        RasterLayer rl = (RasterLayer) layer;
        LayerTreeLegendItemNode tn = new LayerTreeLegendItemNode(this, rl.getServerLayerId(),
View Full Code Here

    }
  }

  private Style createSldStyle(VectorLayer layer, VectorLayerRasterizingInfo vectorLayerRasterizingInfo)
      throws LayerException {
    NamedStyleInfo namedStyle = vectorLayerRasterizingInfo.getStyle();
    String location = namedStyle.getSldLocation();
    Style[] styles = styleMap.get(location);
    if (styles == null) {
      Resource sld = applicationContext.getResource(location);
      SLDParser parser = new SLDParser(styleFactory);
      // external graphics will be resolved with respect to the SLD URL !
      try {
        parser.setInput(sld.getURL());
        styles = parser.readXML();
        // apply missing titles (needed for legend)
        String styleName = (namedStyle.getSldStyleName() != null ?
            namedStyle.getSldStyleName() : layer.getId());
        for (Style style : styles) {
          if (style.getDescription().getTitle() == null) {
            style.getDescription().setTitle(styleName);
          }
          for (FeatureTypeStyle fts : style.featureTypeStyles()) {
View Full Code Here

  public void execute(PipelineContext context, GetTileContainer tileContainer) throws GeomajasException {
    VectorLayer layer = context.get(PipelineCode.LAYER_KEY, VectorLayer.class);
    TileMetadata tileMetadata = context.get(PipelineCode.TILE_METADATA_KEY, TileMetadata.class);
    // put the image in a raster container
    RasterizingContainer rasterizingContainer = new RasterizingContainer();
    NamedStyleInfo style = tileMetadata.getStyleInfo();
    if (style == null) {
      // no style specified, take the first
      style = layer.getLayerInfo().getNamedStyleInfos().get(0);
    } else if (style.getFeatureStyles().isEmpty()) {
      // only name specified, find it
      style = layer.getLayerInfo().getNamedStyleInfo(style.getName());
    }
    ClientMapInfo mapInfo = new ClientMapInfo();
    MapRasterizingInfo mapRasterizingInfo = new MapRasterizingInfo();
    mapRasterizingInfo.setBounds(converterService.toDto(tileContainer.getTile().getBounds()));
    mapInfo.setCrs(tileMetadata.getCrs());
View Full Code Here

    tileMetadata.setCode(new TileCode(0,0,0));
    tileMetadata.setRenderer(TileMetadata.PARAM_SVG_RENDERER);
    tileMetadata.setLayerId(LAYER_ID);
    tileMetadata.setPaintGeometries(true);
    tileMetadata.setScale(1.0);
    NamedStyleInfo styleInfo = new NamedStyleInfo();
    styleInfo.setName("beansStyleInfo");
    tileMetadata.setStyleInfo(styleInfo);
    tileMetadata.setPanOrigin(new org.geomajas.geometry.Coordinate(0, 0));
    return tileMetadata;
  }
View Full Code Here

  }

  public void execute(PipelineContext context, GetFeaturesContainer response) throws GeomajasException {
    VectorLayer layer = context.get(PipelineCode.LAYER_KEY, VectorLayer.class);
    int featureIncludes = context.get(PipelineCode.FEATURE_INCLUDES_KEY, Integer.class);
    NamedStyleInfo style = context.getOptional(PipelineCode.STYLE_KEY, NamedStyleInfo.class);

    List<StyleFilter> styleFilters = null;
    if (style == null) {
      // no style specified, take the first
      style = layer.getLayerInfo().getNamedStyleInfos().get(0);
    } else if (style.getFeatureStyles().isEmpty()) {
      // only name specified, find it
      style = layer.getLayerInfo().getNamedStyleInfo(style.getName());
    }
    context.put(PipelineCode.STYLE_KEY, style);

    if ((featureIncludes & VectorLayerService.FEATURE_INCLUDE_STYLE) != 0) {
      if (style == null) {
        throw new GeomajasException(ExceptionCode.RENDER_FEATURE_MODEL_PROBLEM, "Style not found");
      }
      styleFilters = initStyleFilters(style.getFeatureStyles());
    }

    context.put(STYLE_FILTERS_KEY, styleFilters);
  }
View Full Code Here

TOP

Related Classes of org.geomajas.configuration.NamedStyleInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.