Package org.geotools.styling

Examples of org.geotools.styling.Font$Weight


        TextSymbolizer ps = (TextSymbolizer) collector.symbolizers.get(1);
        assertEquals(ff.property("name"), ps.getLabel());
        assertEquals(Color.BLACK, ps.getFill().getColor().evaluate(null, Color.class));

        // font
        Font font = ps.getFont();
        assertEquals("Arial", font.getFamily().get(0).evaluate(null, String.class));
        assertEquals(12, (int) font.getSize().evaluate(null, Integer.class));
        assertEquals(Font.Style.NORMAL, font.getStyle().evaluate(null, String.class));
        assertEquals(Font.Weight.BOLD, font.getWeight().evaluate(null, String.class));

        // placement
        PointPlacement pp = (PointPlacement) ps.getLabelPlacement();
        assertEquals(0.5, pp.getAnchorPoint().getAnchorPointX().evaluate(null, Double.class), 0);
        assertEquals(0, pp.getAnchorPoint().getAnchorPointY().evaluate(null, Double.class), 0);
View Full Code Here


        TextSymbolizer ps = (TextSymbolizer) collector.symbolizers.get(1);
        assertEquals(ff.property("name"), ps.getLabel());
        assertEquals(Color.BLACK, ps.getFill().getColor().evaluate(null, Color.class));

        // font
        Font font = ps.getFont();
        assertEquals("Arial", font.getFamily().get(0).evaluate(null, String.class));
        assertEquals(12, (int) font.getSize().evaluate(null, Integer.class));
        assertEquals(Font.Style.NORMAL, font.getStyle().evaluate(null, String.class));
        assertEquals(Font.Weight.BOLD, font.getWeight().evaluate(null, String.class));

        // placement
        PointPlacement pp = (PointPlacement) ps.getLabelPlacement();
        assertEquals(-45, pp.getRotation().evaluate(null, Double.class), 0.0);
        assertEquals(0.5, pp.getAnchorPoint().getAnchorPointX().evaluate(null, Double.class), 0);
View Full Code Here

    }
   
    public void testUnknownFont() throws Exception {
      TextSymbolizer ts = sf.createTextSymbolizer();
      ts.setFill(sf.createFill(null));
      Font font = sf.createFont(ff.literal("notExistingFont"), ff.literal("italic"), ff.literal("bold"), ff.literal(20));
      ts.setFont(font);
     
      TextStyle2D tsd = (TextStyle2D) sld.createTextStyle(feature, ts, range);
      assertEquals(20, tsd.getFont().getSize());
      assertEquals(java.awt.Font.ITALIC | java.awt.Font.BOLD, tsd.getFont().getStyle());
View Full Code Here

        // try to build a font using the full spec
        if (fonts != null) {

            for (int k = 0; k < fonts.length; k++) {
                Font curr = fonts[k];
                String requestedFont = evalToString(curr.getFontFamily(),
                        feature, null);
                java.awt.Font javaFont = FontCache.getDefaultInstance().getFont(
                        requestedFont);

                if (javaFont != null) {
View Full Code Here

     * @param fonts
     * @return copy of provided fonts
     */
    protected Font[] copy(Font[] fonts) {
        if( fonts == null ) return null;
        Font copy[] = new Font[ fonts.length ];
        for( int i=0; i<fonts.length; i++){
            copy[i] = copy( fonts[i] );
        }
        return copy;
    }
View Full Code Here

       
        Expression fontFamily = copy( font.getFontFamily() );
        Expression fontStyle = copy( font.getFontStyle() );
        Expression fontWeight = copy( font.getFontWeight() );
        Expression fontSize = copy( font.getFontSize() );
        Font copy = sf.createFont(fontFamily, fontStyle, fontWeight, fontSize);
        return copy;
    }
View Full Code Here

            StyleBuilder styleBuilder = new StyleBuilder();

            TextSymbolizerImpl textSymb = (TextSymbolizerImpl) styleBuilder.createTextSymbolizer();
            textSymb.setUnitOfMeasure(uom);
           
            Font font = styleBuilder.createFont(new java.awt.Font("Verdana",java.awt.Font.PLAIN,fontSize));
            textSymb.setFont(font);
           
            PointPlacement placement = styleBuilder.createPointPlacement(0.3, 0.3, displacementX, displacementY, 10);
            textSymb.setLabelPlacement(placement);
           
View Full Code Here

            StyleBuilder styleBuilder = new StyleBuilder();

            TextSymbolizerImpl textSymb = (TextSymbolizerImpl) styleBuilder.createTextSymbolizer();
            textSymb.setUnitOfMeasure(uom);
           
            Font font = styleBuilder.createFont(new java.awt.Font("Verdana",java.awt.Font.PLAIN,fontSize));
            textSymb.setFont(font);
           
            LinePlacement placement = styleBuilder.createLinePlacement(perpOffset);
            placement.setGap(styleBuilder.literalExpression(gap));
            placement.setInitialGap(styleBuilder.literalExpression(initialGap));
View Full Code Here

        notEq.setLabelPlacement(placement);
        assertEqualsContract(clone, notEq, textSymb);
    }

    public void testFont() {
        Font font = sf.getDefaultFont();
        Font clone = visitor.copy(font);
        assertCopy(font, clone);
        assertEqualsContract(font, clone);

        Font other = sf.createFont(ff.literal("other"),
                ff.literal("normal"),
                ff.literal("BOLD"),
                ff.literal(12));

        assertEqualsContract(clone, other, font);
View Full Code Here

       
        Function l = (Function) sym.getLabel();
        assertEquals("foobar (10)", l.evaluate(f1));
        //assertEquals("hospitalName", l);
       
        Font f = sym.getFont();
        assertEquals(2, f.getFamily().size());
        assertEquals("Arial", f.getFamily().get(0).evaluate(null, String.class));
        assertEquals("Sans-Serif", f.getFamily().get(1).evaluate(null, String.class));
        assertEquals("italic", f.getStyle().evaluate(null, String.class));
        assertEquals("10", f.getSize().evaluate(null, String.class));
       
        Fill fill = sym.getFill();
        assertEquals(Color.BLACK, fill.getColor().evaluate(null, Color.class));
    }
View Full Code Here

TOP

Related Classes of org.geotools.styling.Font$Weight

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.