Package org.geotools.styling

Examples of org.geotools.styling.Stroke


     * Returns the contour paint
     *
     * @return the contour paint
     */
    public java.awt.Paint getContour() {
        Stroke stroke = ls.getStroke();

        if (stroke == null) {
            return null;
        }

        // the foreground color
        Paint contourPaint = (Color) stroke.getColor().evaluate(feature,Color.class);
        if( contourPaint == null ){           
            String text = (String) stroke.getColor().evaluate(feature,String.class);
            if( text != null ){
                contourPaint = Color.decode( text );
            }
        }

        // if a graphic fill is to be used, prepare the paint accordingly....
        org.geotools.styling.Graphic gr = stroke.getGraphicFill();
        SLDStyleFactory fac = new SLDStyleFactory();

        if (gr != null) {
            contourPaint = fac.getTexturePaint(gr, feature, ls);
        }
View Full Code Here


    rule1.getDescription().setAbstract("Rule for drawing cities");
    rule1.setFilter(ff.less(ff.property("POPULATION"), ff.literal(50000)));
   
    //
    // create the graphical mark used to represent a city
    Stroke stroke = sf.stroke(ff.literal("#000000"), null, null, null, null, null, null);
    Fill fill = sf.fill(null, ff.literal(Color.BLUE), ff.literal(1.0));
   
    // OnLineResource implemented by gt-metadata - so no factory!
    OnLineResourceImpl svg = new OnLineResourceImpl(new URI("file:city.svg"));
    svg.freeze(); // freeze to prevent modification at runtime
View Full Code Here

     * <p>
     * Based on feedback we may need to change the dash array as well.
     * <p>
     */
    public void visit(org.geotools.styling.Stroke stroke) {
        Stroke copy = sf.getDefaultStroke();
        copy.setColor( copy(stroke.getColor()));
        copy.setDashArray( rescale(stroke.getDashArray()));
        copy.setDashOffset( rescale(stroke.getDashOffset()));
        copy.setGraphicFill( copy(stroke.getGraphicFill()));
        copy.setGraphicStroke( copy( stroke.getGraphicStroke()));
        copy.setLineCap(copy(stroke.getLineCap()));
        copy.setLineJoin( copy(stroke.getLineJoin()));
        copy.setOpacity( copy(stroke.getOpacity()));
        copy.setWidth( rescale(stroke.getWidth()));
        pages.push(copy);
    }  
View Full Code Here

    @Override
    public void visit(LineSymbolizer line) {
        super.visit(line);
        LineSymbolizer copy = (LineSymbolizer) pages.peek();
        Unit<Length> uom = copy.getUnitOfMeasure();
        Stroke copyStroke = copy.getStroke();
        rescaleStroke(copyStroke, uom);
        copy.setUnitOfMeasure(NonSI.PIXEL);
    }
View Full Code Here

        }
        pages.push(copy);
    }

    public void visit(Stroke stroke) {
        Stroke copy = sf.getDefaultStroke();
        copy.setColor( copy(stroke.getColor()));
        copy.setDashArray( copy(stroke.getDashArray()));
        copy.setDashOffset( copy( stroke.getDashOffset()));
        copy.setGraphicFill( copy(stroke.getGraphicFill()));
        copy.setGraphicStroke( copy( stroke.getGraphicStroke()));
        copy.setLineCap(copy(stroke.getLineCap()));
        copy.setLineJoin( copy(stroke.getLineJoin()));
        copy.setOpacity( copy(stroke.getOpacity()));
        copy.setWidth( copy(stroke.getWidth()));

        if( STRICT && !copy.equals( stroke)){
            throw new IllegalStateException("Was unable to duplicate provided Stroke:"+stroke );
        }
        pages.push(copy);
    }
View Full Code Here

        visitor = new DpiRescaleStyleVisitor(scale);
    }

    @Test
    public void testNoUnit() throws Exception {
        Stroke original = sb.createStroke(Color.RED, 2, new float[] { 5, 10 });
        LineSymbolizer ls = sb.createLineSymbolizer(original);
        ls.accept(visitor);
        Stroke clone = ((LineSymbolizer) visitor.getCopy()).getStroke();

        assertEquals(4.0d, clone.getWidth().evaluate(null, Double.class), 0d);
        assertEquals(10.0f, clone.getDashArray()[0], 0f);
        assertEquals(20.0f, clone.getDashArray()[1], 0f);
    }
View Full Code Here

        assertEquals(20.0f, clone.getDashArray()[1], 0f);
    }
   
    @Test
    public void testAllMeters() throws Exception {
        Stroke original = sb.createStroke(Color.RED, 2, new float[] { 5, 10 });
        LineSymbolizer ls = sb.createLineSymbolizer(original);
        ls.setUnitOfMeasure(SI.METER);
        ls.accept(visitor);
        Stroke clone = ((LineSymbolizer) visitor.getCopy()).getStroke();

        assertEquals(2d, clone.getWidth().evaluate(null, Double.class), 0d);
        assertEquals(5f, clone.getDashArray()[0], 0f);
        assertEquals(10f, clone.getDashArray()[1], 0f);
    }
View Full Code Here

        assertEquals(10f, clone.getDashArray()[1], 0f);
    }
   
    @Test
    public void testAllFeet() throws Exception {
        Stroke original = sb.createStroke(Color.RED, 2, new float[] { 5, 10 });
        LineSymbolizer ls = sb.createLineSymbolizer(original);
        ls.setUnitOfMeasure(NonSI.FOOT);
        ls.accept(visitor);
        Stroke clone = ((LineSymbolizer) visitor.getCopy()).getStroke();

        assertEquals(2d, clone.getWidth().evaluate(null, Double.class), 0d);
        assertEquals(5f, clone.getDashArray()[0], 0f);
        assertEquals(10f, clone.getDashArray()[1], 0f);
    }
View Full Code Here

        assertEquals(10f, clone.getDashArray()[1], 0f);
    }
   
    @Test
    public void testSymbolizerMeterOverrideInPixels() throws Exception {
        Stroke original = sb.createStroke(Color.RED, 2, new float[] { 5, 10 });
        original.setWidth(ff.literal("2px"));
        LineSymbolizer ls = sb.createLineSymbolizer(original);
        ls.setUnitOfMeasure(SI.METER);
        ls.accept(visitor);
        Stroke clone = ((LineSymbolizer) visitor.getCopy()).getStroke();

        // this one has been rescaled
        assertEquals(4d, clone.getWidth().evaluate(null, Double.class), 0d);
        // the dash array did not, it's supposed to be meters
        assertEquals(5f, clone.getDashArray()[0], 0f);
        assertEquals(10f, clone.getDashArray()[1], 0f);
    }
View Full Code Here

        assertEquals(10f, clone.getDashArray()[1], 0f);
    }
   
    @Test
    public void testSymbolizerPixelOverrideInMeters() throws Exception {
        Stroke original = sb.createStroke(Color.RED, 2, new float[] { 5, 10 });
        original.setWidth(ff.literal("2m"));
        LineSymbolizer ls = sb.createLineSymbolizer(original);
        ls.accept(visitor);
        Stroke clone = ((LineSymbolizer) visitor.getCopy()).getStroke();

        // this one has not been rescaled
        assertEquals("2m", clone.getWidth().evaluate(null, String.class));
        // the dash array did , it's supposed to be pixels
        assertEquals(10f, clone.getDashArray()[0], 0f);
        assertEquals(20f, clone.getDashArray()[1], 0f);
    }
View Full Code Here

TOP

Related Classes of org.geotools.styling.Stroke

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.