Search in sources :

Example 1 with MultipleFont

use of com.sldeditor.tool.batchupdatefont.MultipleFont in project sldeditor by robward-scisys.

the class MultipleFontTest method testParseList.

/**
 * Test method for {@link com.sldeditor.tool.batchupdatefont.MultipleFont#parseList(java.util.List)}. Test method for
 * {@link com.sldeditor.tool.batchupdatefont.MultipleFont#getFont()}.
 */
@Test
public void testParseList() {
    StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
    List<Font> entries = new ArrayList<Font>();
    MultipleFont testObj = new MultipleFont();
    testObj.parseList(null);
    assertNotNull(testObj.getFont());
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    String originalFontname = "Serif";
    String originalFontStyle = "normal";
    String originalFontWeight = "normal";
    int originalFontSize = 24;
    Font font = styleFactory.createFont(ff.literal(originalFontname), ff.literal(originalFontStyle), ff.literal(originalFontWeight), ff.literal(originalFontSize));
    entries.add(font);
    testObj.parseList(entries);
    Font actualFont = testObj.getFont();
    assertNotNull(actualFont.getSize());
    assertNotNull(actualFont.getStyle());
    assertNotNull(actualFont.getWeight());
    assertTrue(!actualFont.getFamily().isEmpty());
    // 2nd font is completely different
    String newFontname = "Serif2";
    String newFontStyle = "italic";
    String newFontWeight = "bold";
    int newFontSize = 25;
    Font font2 = styleFactory.createFont(ff.literal(newFontname), ff.literal(newFontStyle), ff.literal(newFontWeight), ff.literal(newFontSize));
    entries.add(font2);
    testObj.parseList(entries);
    actualFont = testObj.getFont();
    assertNull(actualFont.getSize());
    assertNull(actualFont.getStyle());
    assertNull(actualFont.getWeight());
    assertTrue(actualFont.getFamily().isEmpty());
    // Change family, style, weight and size
    entries.clear();
    entries.add(font);
    Font font3 = styleFactory.createFont(ff.literal(originalFontname), ff.literal(originalFontStyle), ff.literal(originalFontWeight), ff.literal(originalFontSize));
    entries.add(font3);
    testObj.parseList(entries);
    actualFont = testObj.getFont();
    assertNotNull(actualFont.getSize());
    assertNotNull(actualFont.getStyle());
    assertNotNull(actualFont.getWeight());
    assertTrue(!actualFont.getFamily().isEmpty());
}
Also used : StyleFactoryImpl(org.geotools.styling.StyleFactoryImpl) ArrayList(java.util.ArrayList) MultipleFont(com.sldeditor.tool.batchupdatefont.MultipleFont) Font(org.geotools.styling.Font) MultipleFont(com.sldeditor.tool.batchupdatefont.MultipleFont) FilterFactory(org.opengis.filter.FilterFactory) Test(org.junit.Test)

Aggregations

MultipleFont (com.sldeditor.tool.batchupdatefont.MultipleFont)1 ArrayList (java.util.ArrayList)1 Font (org.geotools.styling.Font)1 StyleFactoryImpl (org.geotools.styling.StyleFactoryImpl)1 Test (org.junit.Test)1 FilterFactory (org.opengis.filter.FilterFactory)1