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

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

本文整理了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

  1. /**
  2. * Retrieve the color of a fill object
  3. *
  4. * @param fill a Fill object
  5. * @return color or null if fill was null
  6. */
  7. public static Color color(Fill fill) {
  8. if (fill == null) {
  9. return null;
  10. }
  11. return color(fill.getColor());
  12. }

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

  1. /** Reset to produce the default Fill. */
  2. public FillBuilder reset() {
  3. unset = false;
  4. color = Fill.DEFAULT.getColor();
  5. opacity = Fill.DEFAULT.getOpacity();
  6. graphic.unset();
  7. return this;
  8. }

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

  1. /**
  2. * Retrieves the colour of the font fill from a TextSymbolizer.
  3. *
  4. * @param symbolizer Text symbolizer information.
  5. * @return Color of the font's fill, or null if unavailable.
  6. */
  7. public static Color textFontFill(TextSymbolizer symbolizer) {
  8. if (symbolizer == null) {
  9. return null;
  10. }
  11. Fill fill = symbolizer.getFill();
  12. if (fill == null) {
  13. return null;
  14. }
  15. return color(fill.getColor());
  16. }

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

  1. /**
  2. * Retrieves the fill colour from a PolygonSymbolizer.
  3. *
  4. * <p>If you are using something fun like rules you will need to do your own thing.
  5. *
  6. * @param symbolizer Polygon symbolizer information.
  7. * @return Color of the polygon's fill, or null if unavailable.
  8. */
  9. public static Color polyFill(PolygonSymbolizer symbolizer) {
  10. if (symbolizer == null) {
  11. return null;
  12. }
  13. Fill fill = symbolizer.getFill();
  14. if (fill == null) {
  15. return null;
  16. }
  17. return color(fill.getColor());
  18. }

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

  1. /**
  2. * Retrieves the colour of the halo fill a TextSymbolizer.
  3. *
  4. * @param symbolizer Text symbolizer information.
  5. * @return Color of the halo's fill, or null if unavailable.
  6. */
  7. public static Color textHaloFill(TextSymbolizer symbolizer) {
  8. Halo halo = symbolizer.getHalo();
  9. if (halo == null) {
  10. return null;
  11. }
  12. Fill fill = halo.getFill();
  13. if (fill == null) {
  14. return null;
  15. }
  16. return color(fill.getColor());
  17. }

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

  1. protected Paint getPaint(Fill fill, Object feature, Symbolizer symbolizer) {
  2. if (fill == null) {
  3. return null;
  4. }
  5. // get fill color
  6. Paint fillPaint = evalToColor(fill.getColor(), feature, null);
  7. // if a graphic fill is to be used, prepare the paint accordingly....
  8. org.geotools.styling.Graphic gr = fill.getGraphicFill();
  9. if (gr != null && gr.graphicalSymbols() != null && gr.graphicalSymbols().size() > 0) {
  10. fillPaint = getTexturePaint(gr, feature, symbolizer);
  11. }
  12. return fillPaint;
  13. }

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

  1. public void visit(Fill fill) {
  2. Fill copy = sf.getDefaultFill();
  3. copy.setBackgroundColor(copy(fill.getBackgroundColor()));
  4. copy.setColor(copy(fill.getColor()));
  5. copy.setGraphicFill(copy(fill.getGraphicFill()));
  6. copy.setOpacity(copy(fill.getOpacity()));
  7. if (STRICT && !copy.equals(fill)) {
  8. throw new IllegalStateException("Was unable to duplicate provided Fill:" + fill);
  9. }
  10. pages.push(copy);
  11. }

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

  1. /** Computes and returns the fill based on the feature and the symbolizer */
  2. public java.awt.Paint getFill() {
  3. Fill fill = ps.getFill();
  4. if (fill == null) {
  5. return null;
  6. }
  7. Paint fillPaint = (Color) fill.getColor().evaluate(feature, Color.class);
  8. // if a graphic fill is to be used, prepare the paint accordingly....
  9. org.geotools.styling.Graphic gr = fill.getGraphicFill();
  10. if (gr != null) {
  11. SLDStyleFactory fac = new SLDStyleFactory();
  12. fillPaint = fac.getTexturePaint(gr, feature, ps);
  13. }
  14. return fillPaint;
  15. }

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

  1. /** @see org.geotools.styling.StyleVisitor#visit(org.geotools.styling.Fill) */
  2. public void visit(Fill fill) {
  3. if (fill.getBackgroundColor() != null) {
  4. fill.getBackgroundColor().accept(this, null);
  5. }
  6. if (fill.getColor() != null) {
  7. fill.getColor().accept(this, null);
  8. }
  9. if (fill.getGraphicFill() != null) {
  10. fill.getGraphicFill().accept(this);
  11. }
  12. if (fill.getOpacity() != null) {
  13. fill.getOpacity().accept(this, null);
  14. }
  15. }

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

  1. public Fill createFill(
  2. Expression color, Expression backgroundColor, Expression opacity, Graphic graphicFill) {
  3. Fill fill = new FillImpl(filterFactory);
  4. if (color == null) {
  5. color = Fill.DEFAULT.getColor();
  6. }
  7. fill.setColor(color);
  8. if (backgroundColor == null) {
  9. backgroundColor = Fill.DEFAULT.getBackgroundColor();
  10. }
  11. fill.setBackgroundColor(backgroundColor);
  12. if (opacity == null) {
  13. opacity = Fill.DEFAULT.getOpacity();
  14. }
  15. // would be nice to check if this was within bounds but we have to wait until use since it
  16. // may depend on an attribute
  17. fill.setOpacity(opacity);
  18. fill.setGraphicFill(graphicFill);
  19. return fill;
  20. }

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

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

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

  1. public void visit(Fill fill) {
  2. start("Fill");
  3. if (fill.getGraphicFill() != null) {
  4. start("GraphicFill");
  5. fill.getGraphicFill().accept(this);
  6. end("GraphicFill");
  7. }
  8. encodeCssParam("fill", fill.getColor(), "#808080");
  9. encodeCssParam("fill-opacity", fill.getOpacity(), 1.0);
  10. end("Fill");
  11. }

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

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

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

  1. @Test
  2. public void testExpressionLong() throws Exception {
  3. String yaml =
  4. "polygon:\n"
  5. + " 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";
  6. StyledLayerDescriptor sld = Ysld.parse(yaml);
  7. FeatureTypeStyle fs = SLD.defaultStyle(sld).featureTypeStyles().get(0);
  8. PolygonSymbolizer symb = (PolygonSymbolizer) fs.rules().get(0).symbolizers().get(0);
  9. Expression expr = symb.getFill().getColor();
  10. assertThat(expr, instanceOf(RecodeFunction.class));
  11. List<Expression> params = ((RecodeFunction) expr).getParameters();
  12. assertThat(params.size(), is(7 * 2 + 1));
  13. int i = 0;
  14. assertThat(params.get(i++), attribute("MAPCOLOR7"));
  15. assertThat(params.get(i++), literal(equalTo(1.0)));
  16. assertThat(params.get(i++), literal(isColor("FFC3C3")));
  17. assertThat(params.get(i++), literal(equalTo(2.0)));
  18. assertThat(params.get(i++), literal(isColor("FFE3C3")));
  19. assertThat(params.get(i++), literal(equalTo(3.0)));
  20. assertThat(params.get(i++), literal(isColor("FFFFC3")));
  21. assertThat(params.get(i++), literal(equalTo(4.0)));
  22. assertThat(params.get(i++), literal(isColor("C3FFE3")));
  23. assertThat(params.get(i++), literal(equalTo(5.0)));
  24. assertThat(params.get(i++), literal(isColor("C3FFFF")));
  25. assertThat(params.get(i++), literal(equalTo(6.0)));
  26. assertThat(params.get(i++), literal(isColor("C3C3FF")));
  27. assertThat(params.get(i++), literal(equalTo(7.0)));
  28. assertThat(params.get(i++), literal(isColor("BFC3FF")));
  29. }

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

  1. @Test
  2. public void testDynamicColor() throws Exception {
  3. String yaml =
  4. "point: \n"
  5. + " symbols: \n"
  6. + " - mark: \n"
  7. + " fill-color: ${colourAttribute}\n";
  8. StyledLayerDescriptor sld = Ysld.parse(yaml);
  9. PointSymbolizer p = SLD.pointSymbolizer(SLD.defaultStyle(sld));
  10. assertThat(SLD.fill(p).getColor(), attribute("colourAttribute"));
  11. }

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

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

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

  1. @Test
  2. public void testColorHex() throws Exception {
  3. String yaml =
  4. "point: \n"
  5. + " symbols: \n"
  6. + " - mark: \n"
  7. + " fill-color: 0x001122\n"
  8. + " stroke-color: 0x334455\n";
  9. StyledLayerDescriptor sld = Ysld.parse(yaml);
  10. PointSymbolizer p = SLD.pointSymbolizer(SLD.defaultStyle(sld));
  11. assertThat(SLD.fill(p).getColor(), literal(isColor("001122")));
  12. assertThat(SLD.stroke(p).getColor(), literal(isColor("334455")));
  13. }

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

  1. @Test
  2. public void testColorQuotedHex() throws Exception {
  3. String yaml =
  4. "point: \n"
  5. + " symbols: \n"
  6. + " - mark: \n"
  7. + " fill-color: '0x001122'\n"
  8. + " stroke-color: '0x334455'\n";
  9. StyledLayerDescriptor sld = Ysld.parse(yaml);
  10. PointSymbolizer p = SLD.pointSymbolizer(SLD.defaultStyle(sld));
  11. assertThat(SLD.fill(p).getColor(), literal(isColor("001122")));
  12. assertThat(SLD.stroke(p).getColor(), literal(isColor("334455")));
  13. }

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

  1. @Test
  2. public void testColorQuotedHash() throws Exception {
  3. String yaml =
  4. "point: \n"
  5. + " symbols: \n"
  6. + " - mark: \n"
  7. + " fill-color: '#001122'\n"
  8. + " stroke-color: '#334455'\n";
  9. StyledLayerDescriptor sld = Ysld.parse(yaml);
  10. PointSymbolizer p = SLD.pointSymbolizer(SLD.defaultStyle(sld));
  11. assertThat(SLD.fill(p).getColor(), literal(isColor("001122")));
  12. assertThat(SLD.stroke(p).getColor(), literal(isColor("334455")));
  13. }

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

  1. @Test
  2. public void testColorQuotedBare() throws Exception {
  3. String yaml =
  4. "point: \n"
  5. + " symbols: \n"
  6. + " - mark: \n"
  7. + " fill-color: '001122'\n"
  8. + " stroke-color: '334455'\n";
  9. StyledLayerDescriptor sld = Ysld.parse(yaml);
  10. PointSymbolizer p = SLD.pointSymbolizer(SLD.defaultStyle(sld));
  11. assertThat(SLD.fill(p).getColor(), literal(isColor("001122")));
  12. assertThat(SLD.stroke(p).getColor(), literal(isColor("334455")));
  13. }

相关文章