Search in sources :

Example 16 with Font

use of org.geotools.styling.Font in project sldeditor by robward-scisys.

the class FieldConfigFontPreviewTest method testGenerateExpression.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.font.FieldConfigFontPreview#generateExpression()}. Test
 * method for
 * {@link com.sldeditor.ui.detail.config.font.FieldConfigFontPreview#populateExpression(java.lang.Object, org.opengis.filter.expression.Expression)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.font.FieldConfigFontPreview#populateField(org.geotools.styling.Font)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.font.FieldConfigFontPreview#setTestValue(com.sldeditor.ui.detail.config.FieldId, java.lang.String)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.font.FieldConfigFontPreview#getStringValue()}.
 */
@Test
public void testGenerateExpression() {
    boolean valueOnly = true;
    FieldConfigFontPreview field = new FieldConfigFontPreview(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly));
    field.setTestValue(FieldIdEnum.UNKNOWN, (String) null);
    field.populateField((String) null);
    field.populateField((Font) null);
    field.populateExpression((Font) null);
    String expectedValue = fontFamilies[0];
    field.createUI();
    field.populateField(expectedValue);
    String actualValue = field.getStringValue();
    assertNotNull(actualValue);
    field.setTestValue(FieldIdEnum.UNKNOWN, expectedValue);
    actualValue = field.getStringValue();
    assertNotNull(actualValue);
    StyleBuilder styleBuilder = new StyleBuilder();
    Font f1 = styleBuilder.createFont(expectedValue, false, true, 24.0);
    field.populateField(f1);
    assertNotNull(field.getStringValue());
    Font f2 = styleBuilder.createFont(expectedValue, true, true, 24.0);
    field.populateField(f2);
    assertNotNull(field.getStringValue());
    Font f3 = styleBuilder.createFont(expectedValue, true, false, 24.0);
    field.populateField(f3);
    assertNotNull(field.getStringValue());
    Font f4 = styleBuilder.createFont(expectedValue, false, false, 24.0);
    field.populateField(f4);
    assertNotNull(field.getStringValue());
}
Also used : FieldConfigFontPreview(com.sldeditor.ui.detail.config.font.FieldConfigFontPreview) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) StyleBuilder(org.geotools.styling.StyleBuilder) Font(org.geotools.styling.Font) Test(org.junit.Test)

Example 17 with Font

use of org.geotools.styling.Font in project sldeditor by robward-scisys.

the class FieldConfigFontTest method testGenerateExpression.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.font.FieldConfigFont#generateExpression()}. Test method
 * for
 * {@link com.sldeditor.ui.detail.config.font.FieldConfigFont#populateField(org.geotools.styling.Font)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.font.FieldConfigFont#setTestValue(com.sldeditor.ui.detail.config.FieldId, java.lang.String)}.
 * Test method for {@link com.sldeditor.ui.detail.config.font.FieldConfigFont#getFont()}. Test
 * method for
 * {@link com.sldeditor.ui.detail.config.font.FieldConfigFont#populateExpression(java.lang.Object, org.opengis.filter.expression.Expression)}.
 * Test method for {@link com.sldeditor.ui.detail.config.font.FieldConfigFont#getStringValue()}.
 */
@Test
public void testGenerateExpression() {
    boolean valueOnly = true;
    FieldConfigFont field = new FieldConfigFont(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly));
    field.setTestValue(FieldIdEnum.UNKNOWN, (String) null);
    field.populateField((String) null);
    field.populateField((Font) null);
    field.populateExpression((Font) null);
    String expectedValue = fontFamilies[0];
    field.createUI();
    field.populateField(expectedValue);
    String actualValue = field.getStringValue();
    assertTrue(expectedValue.compareTo(actualValue) == 0);
    field.setTestValue(FieldIdEnum.UNKNOWN, expectedValue);
    actualValue = field.getStringValue();
    assertTrue(expectedValue.compareTo(actualValue) == 0);
    StyleBuilder styleBuilder = new StyleBuilder();
    Font f1 = styleBuilder.createFont(expectedValue, false, true, 24.0);
    field.populateField(f1);
    actualValue = field.getStringValue();
    assertTrue(expectedValue.compareTo(actualValue) == 0);
}
Also used : FieldConfigFont(com.sldeditor.ui.detail.config.font.FieldConfigFont) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) StyleBuilder(org.geotools.styling.StyleBuilder) FieldConfigFont(com.sldeditor.ui.detail.config.font.FieldConfigFont) Font(org.geotools.styling.Font) Test(org.junit.Test)

Example 18 with Font

use of org.geotools.styling.Font in project sldeditor by robward-scisys.

the class FontDetails method updateSymbol.

/**
 * Update symbol.
 */
private void updateSymbol() {
    // 
    // Font
    // 
    Font font = extractFont();
    // Any changes made to the font details need to be reflected
    // back to the FieldConfigFontPreview field
    fieldConfigVisitor.populateFontField(FieldIdEnum.FONT_PREVIEW, font);
}
Also used : Font(org.geotools.styling.Font)

Example 19 with Font

use of org.geotools.styling.Font in project sldeditor by robward-scisys.

the class FontDetails method populate.

/**
 * Populate.
 *
 * @param fontList the font list
 */
public void populate(List<Font> fontList) {
    boolean emptyList = (fontList == null) || fontList.isEmpty();
    boolean showMultipleCheckbox = (fontList != null) && (fontList.size() > 1);
    MultipleFont multipleFont = new MultipleFont();
    multipleFont.parseList(fontList);
    Font font = multipleFont.getFont();
    FieldConfigBase fieldConfig = fieldConfigManager.get(FieldIdEnum.FONT_FAMILY);
    if (fieldConfig != null) {
        if (emptyList) {
            fieldConfig.showOptionField(false);
            fieldConfig.setEnabled(false);
        } else {
            fieldConfig.setEnabled(true);
            fieldConfigVisitor.populateFontField(FieldIdEnum.FONT_FAMILY, font);
            fieldConfig.showOptionField(showMultipleCheckbox);
            boolean isSelected = !font.getFamily().isEmpty();
            fieldConfig.setOptionFieldValue(isSelected);
        }
    }
    populateField(emptyList, showMultipleCheckbox, FieldIdEnum.FONT_WEIGHT, font.getWeight());
    populateField(emptyList, showMultipleCheckbox, FieldIdEnum.FONT_STYLE, font.getStyle());
    populateField(emptyList, showMultipleCheckbox, FieldIdEnum.FONT_SIZE, font.getSize());
    fieldConfigVisitor.populateFontField(FieldIdEnum.FONT_PREVIEW, font);
}
Also used : FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) Font(org.geotools.styling.Font)

Example 20 with Font

use of org.geotools.styling.Font in project sldeditor by robward-scisys.

the class MultipleFont method parseList.

/**
 * Parses the list.
 *
 * @param entries the entries
 */
public void parseList(List<Font> entries) {
    familyMultipleValue = true;
    styleMultipleValue = true;
    weightMultipleValue = true;
    sizeMultipleValue = true;
    if ((entries == null) || entries.isEmpty()) {
        firstEntry = null;
        familyMultipleValue = false;
        styleMultipleValue = false;
        weightMultipleValue = false;
        sizeMultipleValue = false;
    } else {
        firstEntry = entries.get(0);
        String fontFamilyValue = firstEntry.getFamily().get(0).toString();
        String styleValue = firstEntry.getStyle().toString();
        String weightValue = firstEntry.getWeight().toString();
        String sizeValue = firstEntry.getSize().toString();
        for (Font entry : entries) {
            if (fontFamilyValue.compareTo(entry.getFamily().get(0).toString()) != 0) {
                familyMultipleValue = false;
            }
            if (styleValue.compareTo(entry.getStyle().toString()) != 0) {
                styleMultipleValue = false;
            }
            if (weightValue.compareTo(entry.getWeight().toString()) != 0) {
                weightMultipleValue = false;
            }
            if (sizeValue.compareTo(entry.getSize().toString()) != 0) {
                sizeMultipleValue = false;
            }
        }
    }
}
Also used : Font(org.geotools.styling.Font)

Aggregations

Font (org.geotools.styling.Font)23 TextSymbolizer (org.geotools.styling.TextSymbolizer)9 Test (org.junit.Test)8 Expression (org.opengis.filter.expression.Expression)7 ArrayList (java.util.ArrayList)6 Rule (org.geotools.styling.Rule)5 StyleBuilder (org.geotools.styling.StyleBuilder)5 StyleFactoryImpl (org.geotools.styling.StyleFactoryImpl)5 FilterFactory (org.opengis.filter.FilterFactory)5 AnchorPoint (org.geotools.styling.AnchorPoint)4 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)4 Style (org.geotools.styling.Style)4 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)4 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)3 Displacement (org.geotools.styling.Displacement)3 Halo (org.geotools.styling.Halo)3 NamedLayer (org.geotools.styling.NamedLayer)3 Symbolizer (org.geotools.styling.Symbolizer)3 SLDData (com.sldeditor.common.data.SLDData)2 StyleWrapper (com.sldeditor.common.data.StyleWrapper)2