org.geotools.styling.Mark类的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(150)

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

Mark介绍

[英]A Mark element defines a "shape" which has coloring applied to it.

The details of this object are taken from the OGC Styled-Layer Descriptor Report (OGC 02-070) version 1.0.0.:

<xsd:element name="Mark"> 
<xsd:annotation> 
<xsd:documentation> 
A "Mark" specifies a geometric shape and applies coloring to it. 
</xsd:documentation> 
</xsd:annotation> 
<xsd:complexType> 
<xsd:sequence> 
<xsd:element ref="sld:WellKnownName" minOccurs="0"/> 
<xsd:element ref="sld:Fill" minOccurs="0"/> 
<xsd:element ref="sld:Stroke" minOccurs="0"/> 
</xsd:sequence> 
</xsd:complexType> 
</xsd:element>

Renderers can use this information when displaying styled features, though it must be remembered that not all renderers will be able to fully represent strokes as set out by this interface. For example, opacity may not be supported.

Notes:

<xsd:element name="Mark"> 
<xsd:annotation> 
<xsd:documentation> 
A "Mark" specifies a geometric shape and applies coloring to it. 
</xsd:documentation> 
</xsd:annotation> 
<xsd:complexType> 
<xsd:sequence> 
<xsd:element ref="sld:WellKnownName" minOccurs="0"/> 
<xsd:element ref="sld:Fill" minOccurs="0"/> 
<xsd:element ref="sld:Stroke" minOccurs="0"/> 
</xsd:sequence> 
</xsd:complexType> 
</xsd:element>

渲染器可以在显示样式化特征时使用此信息,但必须记住,并非所有渲染器都能够完全表示此界面设置的笔划。例如,不透明度可能不受支持。
笔记:
*图形参数及其值源自SVG/CSS2标准,其名称和语义尽可能接近。

代码示例

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

/** @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.Mark) */
public void visit(Mark mark) {
  if (mark.getFill() != null) {
    mark.getFill().accept(this);
  }
  if (mark.getStroke() != null) {
    mark.getStroke().accept(this);
  }
  if (mark.getWellKnownName() != null) {
    if (mark.getWellKnownName() instanceof Literal) {
      visitCqlExpression(mark.getWellKnownName().evaluate(null, String.class));
    } else {
      mark.getWellKnownName().accept(this, null);
    }
  }
}

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

/**
 * create a mark with the supplied fill and stroke
 *
 * @param wellKnownName an Expression representing the well known name of the mark
 * @param fill the fill to use
 * @param stroke the stroke to use
 * @return the mark created
 */
public Mark createMark(Expression wellKnownName, Fill fill, Stroke stroke) {
  Mark mark = sf.createMark();
  mark.setWellKnownName(wellKnownName);
  mark.setStroke(stroke);
  mark.setFill(fill);
  return mark;
}

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

public void visit(Mark mark) {
  Mark copy = null;
  copy = sf.createMark();
  copy.setFill(copy(mark.getFill()));
  copy.setStroke(copy(mark.getStroke()));
  copy.setWellKnownName(copy(mark.getWellKnownName()));
  copy.setExternalMark(copy(mark.getExternalMark()));
  if (STRICT && !copy.equals(mark)) {
    throw new IllegalStateException("Was unable to duplicate provided Mark:" + mark);
  }
  pages.push(copy);
}

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

protected MarkParser(Factory factory) {
  super(factory);
  mark = factory.style.createMark();
  mark.setStroke(null);
  mark.setFill(null);
}

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

@Override
public void visit(Mark mark) {
  //        if (mark.getExternalMark() != null) {
  //            mark.getExternalMark().accept(this, null);
  //        }
  if (mark.getFill() != null) {
    mark.getFill().accept(this);
  }
  if (mark.getStroke() != null) {
    mark.getStroke().accept(this);
  }
}

代码示例来源:origin: org.geotools/gt-main

public void visit(Mark mark) {
  Mark copy = null;
  copy = sf.createMark();
  copy.setFill(copy( mark.getFill() ));
  copy.setStroke(copy( mark.getStroke() ));
  copy.setWellKnownName(copy( mark.getWellKnownName() ));
  
  if( STRICT && !copy.equals( mark )){
    throw new IllegalStateException("Was unable to duplicate provided Mark:"+mark );
  }
  pages.push(copy);
}

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

/**
 * Retrieves the Stroke from a PointSymbolizer.
 *
 * @param sym the symbolizer
 * @return the Stroke or null if not found.
 */
public static Stroke stroke(PointSymbolizer sym) {
  Mark mark = mark(sym);
  return (mark == null) ? null : mark.getStroke();
}

代码示例来源:origin: org.geotools/gt-main

@Override
public void visit(Mark mark) {
  if (mark.getExternalMark() != null) {
    //mark.getExternalMark().accept(this, extraData);
  }
  if (mark.getFill() != null) {
    mark.getFill().accept(this);
  }
  if (mark.getStroke() != null) {
    mark.getStroke().accept(this);
  }
  if (mark.getWellKnownName() != null) {
    //mark.getWellKnownName().accept(visitor, extraData)
  }
}

代码示例来源:origin: org.geotools/gt-widgets-swing-pending

public void setEdited(Mark mk) {
  this.mark = mk;
  if (mark != null) {
    guiFill.setEdited(mark.getFill());
    guiRotation.setExpression(mark.getRotation());
    guiSize.setExpression(mark.getSize());
    guiStroke.setEdited(mark.getStroke());
    guiWKN.setExpression(mark.getWellKnownName());
  }
}

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

@SuppressWarnings("deprecation")
  static MarkImpl cast(GraphicalSymbol item) {
    if (item == null) {
      return null;
    } else if (item instanceof MarkImpl) {
      return (MarkImpl) item;
    } else if (item instanceof Mark) {
      Mark mark = (Mark) item;
      MarkImpl copy = new MarkImpl();
      copy.setStroke(mark.getStroke());
      copy.setWellKnownName(mark.getWellKnownName());
      copy.setExternalMark(mark.getExternalMark());
      return copy;
    }
    return null;
  }
}

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

/**
 * Sets the Colour for the given point symbolizer
 *
 * @param symbolizer the point symbolizer
 * @param colour the new colour
 */
public static void setPointColour(PointSymbolizer symbolizer, Color colour) {
  if (symbolizer == null || colour == null) {
    return;
  }
  Graphic graphic = symbolizer.getGraphic();
  if (graphic == null) {
    graphic = sf.createDefaultGraphic();
  }
  for (GraphicalSymbol gs : graphic.graphicalSymbols()) {
    if (gs != null && gs instanceof Mark) {
      Mark mark = (Mark) gs;
      Stroke stroke = mark.getStroke();
      if (stroke == null) {
        stroke = sf.createStroke(ff.literal(Color.BLACK), Stroke.DEFAULT.getWidth());
        mark.setStroke(stroke);
      }
      Fill fill = mark.getFill();
      if (fill != null) {
        fill.setColor(ff.literal(colour));
      }
    }
  }
}

代码示例来源:origin: org.geotools/gt-widgets-swing-pending

public void apply() {
  if (mark != null) {
    mark.setFill(guiFill.getEdited());
    mark.setRotation(guiRotation.getExpression());
    mark.setSize(guiSize.getExpression());
    mark.setStroke(guiStroke.getEdited());
    mark.setWellKnownName(guiWKN.getExpression());
  }
}

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

/**
 * create a mark with default fill (50% gray) and the supplied outline
 *
 * @param wellKnownName the well known name of the mark
 * @param borderColor the outline color
 * @param borderWidth the outline width
 * @return the mark created
 */
public Mark createMark(String wellKnownName, Color borderColor, double borderWidth) {
  Mark mark = sf.createMark();
  mark.setWellKnownName(literalExpression(wellKnownName));
  mark.setStroke(createStroke(borderColor, borderWidth));
  return mark;
}

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

public Mark getTriangleMark() {
  Mark mark = getDefaultMark();
  mark.setWellKnownName(filterFactory.literal("Triangle"));
  return mark;
}

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

@Override
public void visit(Mark mark) {
  final Expression wellKnownName = mark.getWellKnownName();
  if (wellKnownName instanceof Literal) {
    final String name = wellKnownName.evaluate(null, String.class);
    if (name.startsWith("resource:/")) {
      try {
        Resource r = resourceLoader.fromURL(name);
        if (r != null && r.getType() != Type.UNDEFINED) {
          resources.add(r);
        }
      } catch (IllegalArgumentException e) {
        GeoServerConfigPersister.LOGGER.log(
            Level.WARNING,
            "Error attemping to process SLD resource",
            e);
      }
    }
  }
}

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

@Override
  protected void fill(Fill fill) {
    mark.setFill(fill);
  }
});

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

/**
 * Retrieves the Fill from a PointSymbolizer.
 *
 * @param sym the symbolizer
 * @return the Fill or null if not found.
 */
public static Fill fill(PointSymbolizer sym) {
  Mark mark = mark(sym);
  return (mark == null) ? null : mark.getFill();
}

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

@Override
  protected void stroke(Stroke stroke) {
    mark.setStroke(stroke);
  }
});

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

assertEquals("shape://times", Filters.asString(mark.getWellKnownName()));
assertEquals(color("990099"), SLD.color(mark.getStroke()));
assertEquals(1, SLD.width(mark.getStroke()));

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

if (mark.getExternalMark() != null) {
  Shape shape = TTFMarkFactory.INSTANCE.getShape(mark.getExternalMark());
  if (shape != null) {
    return shape;
Expression name = mark.getWellKnownName();

相关文章