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

x33g5p2x  于2022-01-19 转载在 其他  
字(9.9k)|赞(0)|评价(0)|浏览(156)

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

Fill.getColor介绍

[英]This parameter gives the solid color that will be used for a Fill.
The color value is RGB-encoded using two hexidecimal digits per primary-color component, in the order Red, Green, Blue, prefixed with the hash (#) sign. The hexidecimal digits beetween A and F may be in either upper or lower case. For example, full red is encoded as "#ff0000" (with no quotation marks). The default color is defined to be 50% gray ("#808080"). Note: in CSS this parameter is just called Fill and not Color.
[中]此参数提供将用于填充的纯色。
颜色值是使用每个原色分量的两个十六进制数字进行RGB编码的,顺序为红色、绿色、蓝色,前缀为哈希(#)符号。A和F之间的十六进制数字可以是大写或小写。例如,全红色编码为“#ff0000”(不带引号)。默认颜色定义为50%灰色(“8080”)。注意:在CSS中,这个参数只称为Fill,而不是Color。

代码示例

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

/**
 * Retrieve the color of a fill object
 *
 * @param fill a Fill object
 * @return color or null if fill was null
 */
public static Color color(Fill fill) {
  if (fill == null) {
    return null;
  }
  return color(fill.getColor());
}

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

/** Reset to produce the default Fill. */
public FillBuilder reset() {
  unset = false;
  color = Fill.DEFAULT.getColor();
  opacity = Fill.DEFAULT.getOpacity();
  graphic.unset();
  return this;
}

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

/**
 * Retrieves the colour of the font fill from a TextSymbolizer.
 *
 * @param symbolizer Text symbolizer information.
 * @return Color of the font's fill, or null if unavailable.
 */
public static Color textFontFill(TextSymbolizer symbolizer) {
  if (symbolizer == null) {
    return null;
  }
  Fill fill = symbolizer.getFill();
  if (fill == null) {
    return null;
  }
  return color(fill.getColor());
}

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

/**
 * Retrieves the fill colour from a PolygonSymbolizer.
 *
 * <p>If you are using something fun like rules you will need to do your own thing.
 *
 * @param symbolizer Polygon symbolizer information.
 * @return Color of the polygon's fill, or null if unavailable.
 */
public static Color polyFill(PolygonSymbolizer symbolizer) {
  if (symbolizer == null) {
    return null;
  }
  Fill fill = symbolizer.getFill();
  if (fill == null) {
    return null;
  }
  return color(fill.getColor());
}

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

/**
 * Retrieves the colour of the halo fill a TextSymbolizer.
 *
 * @param symbolizer Text symbolizer information.
 * @return Color of the halo's fill, or null if unavailable.
 */
public static Color textHaloFill(TextSymbolizer symbolizer) {
  Halo halo = symbolizer.getHalo();
  if (halo == null) {
    return null;
  }
  Fill fill = halo.getFill();
  if (fill == null) {
    return null;
  }
  return color(fill.getColor());
}

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

protected Paint getPaint(Fill fill, Object feature, Symbolizer symbolizer) {
  if (fill == null) {
    return null;
  }
  // get fill color
  Paint fillPaint = evalToColor(fill.getColor(), feature, null);
  // if a graphic fill is to be used, prepare the paint accordingly....
  org.geotools.styling.Graphic gr = fill.getGraphicFill();
  if (gr != null && gr.graphicalSymbols() != null && gr.graphicalSymbols().size() > 0) {
    fillPaint = getTexturePaint(gr, feature, symbolizer);
  }
  return fillPaint;
}

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

public void visit(Fill fill) {
  Fill copy = sf.getDefaultFill();
  copy.setBackgroundColor(copy(fill.getBackgroundColor()));
  copy.setColor(copy(fill.getColor()));
  copy.setGraphicFill(copy(fill.getGraphicFill()));
  copy.setOpacity(copy(fill.getOpacity()));
  if (STRICT && !copy.equals(fill)) {
    throw new IllegalStateException("Was unable to duplicate provided Fill:" + fill);
  }
  pages.push(copy);
}

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

/** Computes and returns the fill based on the feature and the symbolizer */
public java.awt.Paint getFill() {
  Fill fill = ps.getFill();
  if (fill == null) {
    return null;
  }
  Paint fillPaint = (Color) fill.getColor().evaluate(feature, Color.class);
  // if a graphic fill is to be used, prepare the paint accordingly....
  org.geotools.styling.Graphic gr = fill.getGraphicFill();
  if (gr != null) {
    SLDStyleFactory fac = new SLDStyleFactory();
    fillPaint = fac.getTexturePaint(gr, feature, ps);
  }
  return fillPaint;
}

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

/** @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.Fill) */
public void visit(Fill fill) {
  if (fill.getBackgroundColor() != null) {
    fill.getBackgroundColor().accept(this, null);
  }
  if (fill.getColor() != null) {
    fill.getColor().accept(this, null);
  }
  if (fill.getGraphicFill() != null) {
    fill.getGraphicFill().accept(this);
  }
  if (fill.getOpacity() != null) {
    fill.getOpacity().accept(this, null);
  }
}

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

public Fill createFill(
    Expression color, Expression backgroundColor, Expression opacity, Graphic graphicFill) {
  Fill fill = new FillImpl(filterFactory);
  if (color == null) {
    color = Fill.DEFAULT.getColor();
  }
  fill.setColor(color);
  if (backgroundColor == null) {
    backgroundColor = Fill.DEFAULT.getBackgroundColor();
  }
  fill.setBackgroundColor(backgroundColor);
  if (opacity == null) {
    opacity = Fill.DEFAULT.getOpacity();
  }
  // would be nice to check if this was within bounds but we have to wait until use since it
  // may depend on an attribute
  fill.setOpacity(opacity);
  fill.setGraphicFill(graphicFill);
  return fill;
}

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

@Override
  protected void encode(Fill fill) {
    putColor("fill-color", fill.getColor());
    put("fill-opacity", nullIf(fill.getOpacity(), 1d));
    if (fill.getGraphicFill() != null) {
      push("fill-graphic").inline(new GraphicEncoder(fill.getGraphicFill()));
    }
  }
}

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

public void visit(Fill fill) {
  start("Fill");
  if (fill.getGraphicFill() != null) {
    start("GraphicFill");
    fill.getGraphicFill().accept(this);
    end("GraphicFill");
  }
  encodeCssParam("fill", fill.getColor(), "#808080");
  encodeCssParam("fill-opacity", fill.getOpacity(), 1.0);
  end("Fill");
}

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

@Test
public void testEvilExpression1() throws Exception {
  String yaml =
      "point: \n" + "  symbols: \n" + "  - mark: \n" + "      fill-color: \\$\\}\\\\\n";
  StyledLayerDescriptor sld = Ysld.parse(yaml);
  PointSymbolizer p = SLD.pointSymbolizer(SLD.defaultStyle(sld));
  assertThat(SLD.fill(p).getColor(), literal(equalTo("$}\\")));
}

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

@Test
public void testExpressionLong() throws Exception {
  String yaml =
      "polygon:\n"
          + "  fill-color: ${recode(MAPCOLOR7, 1.0, '#FFC3C3', 2.0, '#FFE3C3', 3.0, '#FFFFC3', 4.0, '#C3FFE3', 5.0, '#C3FFFF', 6.0, '#C3C3FF', 7.0, '#BFC3FF')}\n";
  StyledLayerDescriptor sld = Ysld.parse(yaml);
  FeatureTypeStyle fs = SLD.defaultStyle(sld).featureTypeStyles().get(0);
  PolygonSymbolizer symb = (PolygonSymbolizer) fs.rules().get(0).symbolizers().get(0);
  Expression expr = symb.getFill().getColor();
  assertThat(expr, instanceOf(RecodeFunction.class));
  List<Expression> params = ((RecodeFunction) expr).getParameters();
  assertThat(params.size(), is(7 * 2 + 1));
  int i = 0;
  assertThat(params.get(i++), attribute("MAPCOLOR7"));
  assertThat(params.get(i++), literal(equalTo(1.0)));
  assertThat(params.get(i++), literal(isColor("FFC3C3")));
  assertThat(params.get(i++), literal(equalTo(2.0)));
  assertThat(params.get(i++), literal(isColor("FFE3C3")));
  assertThat(params.get(i++), literal(equalTo(3.0)));
  assertThat(params.get(i++), literal(isColor("FFFFC3")));
  assertThat(params.get(i++), literal(equalTo(4.0)));
  assertThat(params.get(i++), literal(isColor("C3FFE3")));
  assertThat(params.get(i++), literal(equalTo(5.0)));
  assertThat(params.get(i++), literal(isColor("C3FFFF")));
  assertThat(params.get(i++), literal(equalTo(6.0)));
  assertThat(params.get(i++), literal(isColor("C3C3FF")));
  assertThat(params.get(i++), literal(equalTo(7.0)));
  assertThat(params.get(i++), literal(isColor("BFC3FF")));
}

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

@Test
public void testDynamicColor() throws Exception {
  String yaml =
      "point: \n"
          + "  symbols: \n"
          + "  - mark: \n"
          + "      fill-color: ${colourAttribute}\n";
  StyledLayerDescriptor sld = Ysld.parse(yaml);
  PointSymbolizer p = SLD.pointSymbolizer(SLD.defaultStyle(sld));
  assertThat(SLD.fill(p).getColor(), attribute("colourAttribute"));
}

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

@Test
public void testColorSexegesimal() throws Exception {
  String yaml =
      "point: \n"
          + "  symbols: \n"
          + "  - mark: \n"
          + "      fill-color: 1:17:40:20:15\n";
  StyledLayerDescriptor sld = Ysld.parse(yaml);
  PointSymbolizer p = SLD.pointSymbolizer(SLD.defaultStyle(sld));
  assertThat(SLD.fill(p).getColor(), literal(isColor("FFFFFF")));
}

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

@Test
public void testColorHex() throws Exception {
  String yaml =
      "point: \n"
          + "  symbols: \n"
          + "  - mark: \n"
          + "      fill-color: 0x001122\n"
          + "      stroke-color: 0x334455\n";
  StyledLayerDescriptor sld = Ysld.parse(yaml);
  PointSymbolizer p = SLD.pointSymbolizer(SLD.defaultStyle(sld));
  assertThat(SLD.fill(p).getColor(), literal(isColor("001122")));
  assertThat(SLD.stroke(p).getColor(), literal(isColor("334455")));
}

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

@Test
public void testColorQuotedHex() throws Exception {
  String yaml =
      "point: \n"
          + "  symbols: \n"
          + "  - mark: \n"
          + "      fill-color: '0x001122'\n"
          + "      stroke-color: '0x334455'\n";
  StyledLayerDescriptor sld = Ysld.parse(yaml);
  PointSymbolizer p = SLD.pointSymbolizer(SLD.defaultStyle(sld));
  assertThat(SLD.fill(p).getColor(), literal(isColor("001122")));
  assertThat(SLD.stroke(p).getColor(), literal(isColor("334455")));
}

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

@Test
public void testColorQuotedHash() throws Exception {
  String yaml =
      "point: \n"
          + "  symbols: \n"
          + "  - mark: \n"
          + "      fill-color: '#001122'\n"
          + "      stroke-color: '#334455'\n";
  StyledLayerDescriptor sld = Ysld.parse(yaml);
  PointSymbolizer p = SLD.pointSymbolizer(SLD.defaultStyle(sld));
  assertThat(SLD.fill(p).getColor(), literal(isColor("001122")));
  assertThat(SLD.stroke(p).getColor(), literal(isColor("334455")));
}

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

@Test
public void testColorQuotedBare() throws Exception {
  String yaml =
      "point: \n"
          + "  symbols: \n"
          + "  - mark: \n"
          + "      fill-color: '001122'\n"
          + "      stroke-color: '334455'\n";
  StyledLayerDescriptor sld = Ysld.parse(yaml);
  PointSymbolizer p = SLD.pointSymbolizer(SLD.defaultStyle(sld));
  assertThat(SLD.fill(p).getColor(), literal(isColor("001122")));
  assertThat(SLD.stroke(p).getColor(), literal(isColor("334455")));
}

相关文章