Package org.geotools.styling

Examples of org.geotools.styling.Font


    }

    public void test() throws Exception {
        SLDMockData.font(document, document);

        Font font = (Font) parse();
        assertNotNull(font);
        assertEquals("Arial", Filters.asString(font.getFontFamily()));
        assertEquals("normal", Filters.asString(font.getFontStyle()));
        assertEquals("normal", Filters.asString(font.getFontWeight()));
        assertEquals(14, Filters.asInt(font.getFontSize()));
    }
View Full Code Here


        assertEquals(14, Filters.asInt(font.getFontSize()));
    }
   
    public void testDefaultFont() throws Exception {
        SLDMockData.element(SLD.FONT, document, document);
        Font font = (Font) parse();
        assertNotNull(font);
        assertEquals("Serif", Filters.asString(font.getFontFamily()));
        assertEquals("normal", Filters.asString(font.getFontStyle()));
        assertEquals("normal", Filters.asString(font.getFontWeight()));
        assertEquals(10, Filters.asInt(font.getFontSize()));
    }
View Full Code Here

     *
     * @generated modifiable
     */
    public Object parse(ElementInstance instance, Node node, Object value)
        throws Exception {
        Font font = styleFactory.getDefaultFont();
       
        boolean familyFound = false;
        for (Iterator i = node.getChildValues(CssParameter.class).iterator(); i.hasNext();) {
            CssParameter css = (CssParameter) i.next();

            Expression exp = css.getExpression();
            if (exp == null) {
                continue;
            }

            if ("font-family".equals(css.getName())) {
                if(!familyFound) {
                    font.getFamily().set(0, exp);
                    familyFound = true;
                } else {
                    font.getFamily().add(exp);
                }
            }

            if ("font-style".equals(css.getName())) {
                font.setStyle(exp);
            }

            if ("font-weight".equals(css.getName())) {
                font.setWeight(exp);
            }

            if ("font-size".equals(css.getName())) {
                font.setSize(exp);
            }
        }

        return font;
    }
View Full Code Here

            }
        }
    }

    private void chooseLabelFont() {
        Font font = JFontChooser.showDialog(this, "Choose label font", labelFont);
        if (font != null) {
            labelFont = font;
        }
    }
View Full Code Here

        String fontName = this.font[0].getName();
        boolean fontBold = (this.font[0].getStyle() == SWT.BOLD);
        boolean fontItalic = (this.font[0].getStyle() == SWT.ITALIC);
        double fontSize = this.font[0].getHeight();
        Font gtFont = build.createFont(fontName, fontItalic, fontBold, fontSize);
        Fill fill = build.createFill(this.colour);

        LabelPlacement placement;
        if (pointPlacement) {
            // PointPlacement
View Full Code Here

     * @param symbolizer Text symbolizer information.
     * @return FontData[] of the font's fill, or null if unavailable.
     */
    public static FontData[] textFont( TextSymbolizer symbolizer ) {

        Font font = font(symbolizer);
        if (font == null)
            return null;

        FontData[] tempFD = new FontData[1];
        Expression fontFamilyExpression = font.getFamily().get(0);
        Expression sizeExpression = font.getSize();
        if (sizeExpression == null || fontFamilyExpression == null)
            return null;

        Double size = sizeExpression.evaluate(null, Double.class);

View Full Code Here

    }

    public static Font font( TextSymbolizer symbolizer ) {
        if (symbolizer == null)
            return null;
        Font font = symbolizer.getFont();
        return font;
    }
View Full Code Here

     *
     * @return a new Font object or {@code null} if the user cancelled the dialog
     */
    static Font showDialog(Component owner, String title, Font labelFont) {
        JFontChooser chooser = null;
        Font font = null;

        if (owner == null) {
            chooser = new JFontChooser((JFrame) null, title, labelFont);

        } else {
View Full Code Here

  protected Font parseFont(Node root) {
    if (LOGGER.isLoggable(Level.FINEST)) {
      LOGGER.finest("parsing font");
    }

    Font font = factory.getDefaultFont();
    NodeList list = findElements(((Element) root), "CssParameter");
    int length = list.getLength();
    for (int i = 0; i < length; i++) {
      Node child = list.item(i);

      if ((child == null) || (child.getNodeType() != Node.ELEMENT_NODE)) {
        continue;
      }

      Element param = (Element) child;
      org.w3c.dom.NamedNodeMap map = param.getAttributes();
      final int mapLength = map.getLength();
      for (int k = 0; k < mapLength; k++) {
        String res = map.item(k).getNodeValue();

        if (res.equalsIgnoreCase("font-family")) {
          font.setFontFamily(parseCssParameter(child));
        } else if (res.equalsIgnoreCase("font-style")) {
          font.setFontStyle(parseCssParameter(child));
        } else if (res.equalsIgnoreCase("font-size")) {
          font.setFontSize(parseCssParameter(child));
        } else if (res.equalsIgnoreCase("font-weight")) {
          font.setFontWeight(parseCssParameter(child));
        }
      }
    }

    return font;
View Full Code Here

        }

        protected void setLabelStyle(Style style, SimpleFeature feature, TextSymbolizer symbolizer) {
            LabelStyle ls = style.createAndSetLabelStyle();
            double scale = 1;
            Font font = symbolizer.getFont();
            if(font != null && font.getSize() != null) {
                // we make the scale proportional to the normal font size
                double size = font.getSize().evaluate(feature, Double.class);
                scale = Math.round(size / Font.DEFAULT_FONTSIZE * 100) / 100.0;
            }
            ls.setScale(scale);

            Fill fill = symbolizer.getFill();
View Full Code Here

TOP

Related Classes of org.geotools.styling.Font

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.