Package org.geotools.styling

Examples of org.geotools.styling.Mark


    public void testRescaleGraphicPointSymbolizer() {
        // create a graphic that needs rescaling
        StyleBuilder sb = new StyleBuilder();
       
        // create a circle
        Mark circle = sb.createMark("circle", null, sb.createStroke(500));
        Graphic g = sb.createGraphic(null, circle, null);
       
        // a point symbolizer with the specified circle
        PointSymbolizer ps = sb.createPointSymbolizer(g);
       
        // first see it in feet
        ps.setUnitOfMeasure(NonSI.FOOT);
       
        // rescale it
        UomRescaleStyleVisitor visitor = new UomRescaleStyleVisitor(10);
        ps.accept(visitor);
        PointSymbolizer rps = (PointSymbolizer) visitor.getCopy();
        Mark rm = (Mark) rps.getGraphic().graphicalSymbols().get(0);
        assertEquals(1524.0, rm.getStroke().getWidth().evaluate(null, Double.class), 0d);
       
        // now let's see the same in meters
        ps.setUnitOfMeasure(SI.METER);
       
        // rescale it
        visitor = new UomRescaleStyleVisitor(10);
        ps.accept(visitor);
        rps = (PointSymbolizer) visitor.getCopy();
        rm = (Mark) rps.getGraphic().graphicalSymbols().get(0);
        assertEquals(5000.0, rm.getStroke().getWidth().evaluate(null, Double.class), 0d);
    }
View Full Code Here


        Graphic graphic = (Graphic) parse();
        assertNotNull(graphic);

        assertEquals(graphic.getMarks().length, 1);

        Mark mark = graphic.getMarks()[0];

        Color c = org.geotools.styling.SLD.color(mark.getFill().getColor());
        assertEquals(Integer.parseInt("12", 16), c.getRed());
        assertEquals(Integer.parseInt("34", 16), c.getGreen());
        assertEquals(Integer.parseInt("56", 16), c.getBlue());

        assertEquals(1, Filters.asInt(graphic.getSize()));
View Full Code Here

       
        Graphic g = sym.getGraphic();
        assertEquals(8.0, g.getSize().evaluate(null, Double.class));
        assertEquals(1, g.getMarks().length);
       
        Mark m = g.getMarks()[0];
        assertEquals("star", m.getWellKnownName().evaluate(null, String.class));
        Color c = m.getFill().getColor().evaluate(null, Color.class);
        assertEquals(255, c.getRed());
    }
View Full Code Here

        Graphic g = sym.getGraphic();
        assertEquals(15.0, g.getSize().evaluate(null, Double.class));
        assertEquals(1, g.graphicalSymbols().size());

        Mark mark = (Mark) g.graphicalSymbols().get(0);
        ExternalMark em = mark.getExternalMark();
        assertNotNull(em);
        assertEquals("image/png", em.getFormat());
        assertImagesEqual(referenceImage, em.getInlineContent());
        assertNull(em.getOnlineResource());
    }
View Full Code Here

    }

    public void testWithoutStroke() throws Exception {
        SLDMockData.mark(document, document);

        Mark mark = (Mark) parse();
        assertNotNull(mark);

        assertNotNull(mark.getFill());

        Color c = org.geotools.styling.SLD.color(mark.getFill().getColor());

        assertEquals(Integer.parseInt("12", 16), c.getRed());
        assertEquals(Integer.parseInt("34", 16), c.getGreen());
        assertEquals(Integer.parseInt("56", 16), c.getBlue());

        assertNotNull(mark.getWellKnownName());
        assertEquals(Filters.asString(mark.getWellKnownName()), "wellKnownName");
    }
View Full Code Here

        throws Exception {
        String wkName = (String) node.getChildValue("WellKnownName");
        Stroke stroke = (Stroke) node.getChildValue("Stroke");
        Fill fill = (Fill) node.getChildValue("Fill");

        Mark mark = styleFactory.createMark();

        if (wkName != null) {
            mark.setWellKnownName(filterFactory.literal(wkName));
        }

        if (stroke != null) {
            mark.setStroke(stroke);
        }

        if (fill != null) {
            mark.setFill(fill);
        }

        return mark;
    }
View Full Code Here

     * <!-- begin-user-doc --> <!-- end-user-doc -->
     *
     * @generated modifiable
     */
    public Object parse(ElementInstance instance, Node node, Object value) throws Exception {
        Mark mark = (Mark) super.parse(instance, node, value);
       
        if (node.getChildValue("WellKnownName") == null) {
            String format = (String) node.getChildValue("Format");
            int markIndex = -1;
           
            if (node.hasChild("MarkIndex")) {
                markIndex = (Integer) node.getChildValue("MarkIndex");
            }
           
            ExternalMark emark = null;
           
            if (node.hasChild("OnlineResource")) {
                emark = styleFactory.externalMark(
                    new OnLineResourceImpl((URI)node.getChildValue("OnlineResource")), format, markIndex);
            }
            else if (node.hasChild("InlineContent")) {
                Icon ic = (Icon) node.getChildValue("InlineContent");
                emark = styleFactory.externalMark(ic);
                emark.setFormat((String) node.getChildValue("Format"));
            }
           
            mark.setExternalMark(emark);
        }

        return mark;
    }
View Full Code Here

        PolygonSymbolizer ps = sb.createPolygonSymbolizer(stroke, fill);
       
        // rescale it
        ps.accept(visitor);
        PolygonSymbolizer rps = (PolygonSymbolizer) visitor.getCopy();
        Mark rm = (Mark) rps.getStroke().getGraphicStroke().graphicalSymbols().get(0);
        assertEquals(2.0, rm.getStroke().getWidth().evaluate(null, Double.class), 0d);
        rm = (Mark) rps.getFill().getGraphicFill().graphicalSymbols().get(0);
        assertEquals(4.0, rm.getStroke().getWidth().evaluate(null, Double.class), 0d);

       
        // a line symbolizer that uses a graphic stroke
        LineSymbolizer ls = sb.createLineSymbolizer(stroke);
       
        // rescale it
        ls.accept(visitor);
        LineSymbolizer lps = (LineSymbolizer) visitor.getCopy();
        rm = (Mark) lps.getStroke().getGraphicStroke().graphicalSymbols().get(0);
        assertEquals(2.0, rm.getStroke().getWidth().evaluate(null, Double.class), 0d);
    }
View Full Code Here

     * @return the created style.
     */
    public static Style createPointStyle() {
        Graphic gr = styleFactory.createDefaultGraphic();

        Mark mark = styleFactory.getCircleMark();

        mark.setStroke(styleFactory.createStroke(filterFactory.literal(Color.BLUE), filterFactory.literal(1)));

        mark.setFill(styleFactory.createFill(filterFactory.literal(Color.CYAN)));

        gr.graphicalSymbols().clear();
        gr.graphicalSymbols().add(mark);
        gr.setSize(filterFactory.literal(5));

View Full Code Here

            return null;
        }

        for( GraphicalSymbol gs : graphic.graphicalSymbols() ) {
            if ((gs != null) && (gs instanceof Mark)) {
                Mark mark = (Mark) gs;
                Fill fill = mark.getFill();
                if (fill != null) {
                    Color colour = color(fill.getColor());
                    if (colour == null) {
                        return null;
                    }
View Full Code Here

TOP

Related Classes of org.geotools.styling.Mark

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.