Search in sources :

Example 6 with FieldConfigFontPreview

use of com.sldeditor.ui.detail.config.font.FieldConfigFontPreview in project sldeditor by robward-scisys.

the class FieldConfigFontPreviewTest method testRevertToDefaultValue.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.font.FieldConfigFontPreview#revertToDefaultValue()}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.font.FieldConfigFontPreview#setDefaultValue(java.lang.String)}.
 */
@Test
public void testRevertToDefaultValue() {
    boolean valueOnly = true;
    FieldConfigFontPreview field = new FieldConfigFontPreview(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly));
    field.revertToDefaultValue();
    String actualValue = field.getStringValue();
    assertNull(actualValue);
    field.createUI();
    String expectedDefaultValue = fontFamilies[2];
    field.setDefaultValue(expectedDefaultValue);
    field.revertToDefaultValue();
    actualValue = field.getStringValue();
    // It returns the sample text
    assertNotNull(actualValue);
}
Also used : FieldConfigFontPreview(com.sldeditor.ui.detail.config.font.FieldConfigFontPreview) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Example 7 with FieldConfigFontPreview

use of com.sldeditor.ui.detail.config.font.FieldConfigFontPreview 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 8 with FieldConfigFontPreview

use of com.sldeditor.ui.detail.config.font.FieldConfigFontPreview in project sldeditor by robward-scisys.

the class FieldConfigFontPreviewTest method testCreateCopy.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.font.FieldConfigFontPreview#createCopy(com.sldeditor.ui.detail.config.FieldConfigBase)}.
 */
@Test
public void testCreateCopy() {
    boolean valueOnly = true;
    class TestFieldConfigFontPreview extends FieldConfigFontPreview {

        public TestFieldConfigFontPreview(FieldConfigCommonData commonData) {
            super(commonData);
        }

        public FieldConfigPopulate callCreateCopy(FieldConfigBase fieldConfigBase) {
            return createCopy(fieldConfigBase);
        }
    }
    TestFieldConfigFontPreview field = new TestFieldConfigFontPreview(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly));
    FieldConfigFontPreview copy = (FieldConfigFontPreview) field.callCreateCopy(null);
    assertNull(copy);
    copy = (FieldConfigFontPreview) field.callCreateCopy(field);
    assertEquals(field.getFieldId(), copy.getFieldId());
    assertTrue(field.getLabel().compareTo(copy.getLabel()) == 0);
    assertEquals(field.isValueOnly(), copy.isValueOnly());
}
Also used : FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) FieldConfigFontPreview(com.sldeditor.ui.detail.config.font.FieldConfigFontPreview) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Aggregations

FieldConfigFontPreview (com.sldeditor.ui.detail.config.font.FieldConfigFontPreview)8 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)7 Test (org.junit.Test)7 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)1 XMLFieldConfigBoolean (com.sldeditor.common.xml.ui.XMLFieldConfigBoolean)1 XMLFieldConfigColour (com.sldeditor.common.xml.ui.XMLFieldConfigColour)1 XMLFieldConfigColourMap (com.sldeditor.common.xml.ui.XMLFieldConfigColourMap)1 XMLFieldConfigDSProperties (com.sldeditor.common.xml.ui.XMLFieldConfigDSProperties)1 XMLFieldConfigDouble (com.sldeditor.common.xml.ui.XMLFieldConfigDouble)1 XMLFieldConfigEnum (com.sldeditor.common.xml.ui.XMLFieldConfigEnum)1 FieldList (com.sldeditor.common.xml.ui.XMLFieldConfigEnumValue.FieldList)1 XMLFieldConfigEnumValueList (com.sldeditor.common.xml.ui.XMLFieldConfigEnumValueList)1 XMLFieldConfigFeatureTypeConstraint (com.sldeditor.common.xml.ui.XMLFieldConfigFeatureTypeConstraint)1 XMLFieldConfigFont (com.sldeditor.common.xml.ui.XMLFieldConfigFont)1 XMLFieldConfigFontPreview (com.sldeditor.common.xml.ui.XMLFieldConfigFontPreview)1 XMLFieldConfigGeometry (com.sldeditor.common.xml.ui.XMLFieldConfigGeometry)1 XMLFieldConfigGeometryField (com.sldeditor.common.xml.ui.XMLFieldConfigGeometryField)1 XMLFieldConfigInlineFeature (com.sldeditor.common.xml.ui.XMLFieldConfigInlineFeature)1 XMLFieldConfigInteger (com.sldeditor.common.xml.ui.XMLFieldConfigInteger)1 XMLFieldConfigMapUnit (com.sldeditor.common.xml.ui.XMLFieldConfigMapUnit)1