本文整理了Java中org.geotools.styling.Fill.setColor()
方法的一些代码示例,展示了Fill.setColor()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Fill.setColor()
方法的具体详情如下:
包路径:org.geotools.styling.Fill
类名称:Fill
方法名:setColor
[英]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).
[中]此参数提供将用于填充的纯色。
颜色值是使用每个原色分量的两个十六进制数字进行RGB编码的,顺序为红色、绿色、蓝色,前缀为哈希(#)符号。A和F之间的十六进制数字可以是大写或小写。例如,全红色编码为“#ff0000”(不带引号)。
代码示例来源:origin: geotools/geotools
fill.setColor(parseCssParameter(child));
} else if (res.equalsIgnoreCase(opacityString)
|| res.equalsIgnoreCase("fill-opacity")) {
代码示例来源:origin: geotools/geotools
public Fill getDefaultFill() {
Fill fill = new FillImpl(filterFactory);
try {
fill.setColor(filterFactory.literal("#808080"));
fill.setOpacity(filterFactory.literal(new Double(1.0)));
fill.setBackgroundColor(filterFactory.literal("#FFFFFF"));
} catch (org.geotools.filter.IllegalFilterException ife) {
throw new RuntimeException("Error creating fill", ife);
}
return fill;
}
代码示例来源: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
/**
* create a default fill 50% gray
*
* @return the fill created
*/
public Fill createFill() {
Fill f = sf.getDefaultFill();
f.setColor(literalExpression("#808080"));
f.setBackgroundColor(literalExpression("#808080"));
f.setOpacity(literalExpression(1.0));
return f;
}
代码示例来源: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
/**
* Sets the colour to use for outline (stroke) and fill in a polygon symbolizer
*
* @param symbolizer the polygon symbolizer
* @param colour the colour for polygon outlines and fill
*/
public static void setPolyColour(PolygonSymbolizer symbolizer, Color colour) {
if (symbolizer == null || colour == null) {
return;
}
Expression colourExp = ff.literal(colour);
Stroke stroke = symbolizer.getStroke();
if (stroke == null) {
stroke = sf.createStroke(colourExp, Stroke.DEFAULT.getWidth());
symbolizer.setStroke(stroke);
} else {
stroke.setColor(ff.literal(colour));
}
Fill fill = symbolizer.getFill();
if (fill != null) {
fill.setColor(colourExp);
}
}
代码示例来源: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
/**
* 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: geotools/geotools
private PolygonSymbolizer polysym(StyleFactory sFac) throws IllegalFilterException {
Stroke myStroke;
PolygonSymbolizer polysym = sFac.createPolygonSymbolizer();
Fill myFill = sFac.getDefaultFill();
myFill.setColor(filterFactory.literal("#ff0000"));
polysym.setFill(myFill);
myStroke = sFac.getDefaultStroke();
myStroke.setColor(filterFactory.literal("#0000ff"));
myStroke.setWidth(filterFactory.literal(Integer.valueOf(2)));
polysym.setStroke(myStroke);
return polysym;
}
代码示例来源:origin: geotools/geotools
private PolygonSymbolizer polysym1(StyleFactory sFac) throws IllegalFilterException {
Stroke myStroke;
PolygonSymbolizer polysym = sFac.createPolygonSymbolizer();
Fill myFill = sFac.getDefaultFill();
myFill.setColor(filterFactory.literal("#00ff00"));
polysym.setFill(myFill);
myStroke = sFac.getDefaultStroke();
myStroke.setColor(filterFactory.literal("#00ff00"));
myStroke.setWidth(filterFactory.literal(Integer.valueOf(2)));
polysym.setStroke(myStroke);
return polysym;
}
代码示例来源:origin: geotools/geotools
@Test
public void testRescalePolygonMargin() throws Exception {
// create a graphic that needs rescaling
StyleBuilder sb = new StyleBuilder();
// a graphic fill
Fill fill = sb.createFill();
fill.setColor(null);
fill.setGraphicFill(
sb.createGraphic(null, sb.createMark("square", null, sb.createStroke(2)), null));
// a polygon and line symbolizer using them
PolygonSymbolizer polygonSymbolizer = sb.createPolygonSymbolizer(sb.createStroke(), fill);
polygonSymbolizer.getOptions().put(PolygonSymbolizer.GRAPHIC_MARGIN_KEY, "1 2 3 4");
// rescale it
polygonSymbolizer.accept(visitor);
PolygonSymbolizer rps = (PolygonSymbolizer) visitor.getCopy();
Mark rm = (Mark) rps.getFill().getGraphicFill().graphicalSymbols().get(0);
assertEquals(4.0, rm.getStroke().getWidth().evaluate(null, Double.class), 0d);
assertEquals("2 4 6 8", rps.getOptions().get(PolygonSymbolizer.GRAPHIC_MARGIN_KEY));
}
}
代码示例来源:origin: org.geotools/gt2-main
private void init() {
try {
radius = filterFactory.literal(1);
} catch (org.geotools.filter.IllegalFilterException ife) {
LOGGER.severe("Failed to build defaultHalo: " + ife);
}
fill.setColor(filterFactory.literal("#FFFFFF")); // default halo is white
}
代码示例来源:origin: org.geotools/gt2-main
/**
* Creates a new instance of DefaultTextSymbolizer
*/
protected TextSymbolizerImpl( FilterFactory factory ) {
this.filterFactory = factory;
fill = new FillImpl();
fill.setColor(filterFactory.literal("#000000")); // default text fill is black
halo = null;
placement = new PointPlacementImpl();
}
代码示例来源:origin: org.geoserver/gs-wms
@Override
public void visit(Fill fill) {
super.visit(fill);
Fill copy = (Fill) pages.peek();
if (copy.getGraphicFill() != null) {
copy.setGraphicFill(null);
copy.setColor(sb.colorExpression(Color.BLACK));
}
}
代码示例来源:origin: org.geotools/gt-main
public Fill getDefaultFill() {
Fill fill = new FillImpl(filterFactory);
try {
fill.setColor(filterFactory.literal("#808080"));
fill.setOpacity(filterFactory.literal(
new Double(1.0)));
fill.setBackgroundColor(filterFactory.literal("#FFFFFF"));
} catch (org.geotools.filter.IllegalFilterException ife) {
throw new RuntimeException("Error creating fill", ife);
}
return fill;
}
代码示例来源:origin: geotools/geotools
polysym.setGeometryPropertyName("polygon");
Fill myFill = sFac.getDefaultFill();
myFill.setColor(filterFactory.literal("#ff0000"));
polysym.setFill(myFill);
polysym.setStroke(sFac.getDefaultStroke());
代码示例来源:origin: geotools/geotools
fill.setColor(null);
fill.setGraphicFill(
sb.createGraphic(null, sb.createMark("square", null, sb.createStroke(2)), null));
代码示例来源:origin: org.geotools/gt-main
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
fill.setColor(null);
fill.setGraphicFill(
sb.createGraphic(null, sb.createMark("square", null, sb.createStroke(2)), null));
代码示例来源:origin: org.geotools/gt-main
/**
* create a default fill 50% gray
*
* @return the fill created
*/
public Fill createFill() {
Fill f = sf.getDefaultFill();
f.setColor(literalExpression("#808080"));
f.setBackgroundColor(literalExpression("#808080"));
f.setOpacity(literalExpression(1.0));
return f;
}
内容来源于网络,如有侵权,请联系作者删除!