Search in sources :

Example 6 with FieldConfigFont

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

the class FieldConfigFontTest method testSetVisible.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.font.FieldConfigFont#setVisible(boolean)}.
 */
@Test
public void testSetVisible() {
    boolean valueOnly = true;
    FieldConfigFont field = new FieldConfigFont(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly));
    boolean expectedValue = true;
    field.setVisible(expectedValue);
    field.createUI();
    expectedValue = false;
    field.setVisible(expectedValue);
}
Also used : FieldConfigFont(com.sldeditor.ui.detail.config.font.FieldConfigFont) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Example 7 with FieldConfigFont

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

the class FieldConfigFontTest method testUndoAction.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.font.FieldConfigFont#undoAction(com.sldeditor.common.undo.UndoInterface)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.font.FieldConfigFont#redoAction(com.sldeditor.common.undo.UndoInterface)}.
 */
@Test
public void testUndoAction() {
    boolean valueOnly = true;
    FieldConfigFont field = new FieldConfigFont(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly));
    String expectedDefaultValue1 = fontFamilies[0];
    field.createUI();
    field.populateField(expectedDefaultValue1);
    String actualValue1 = field.getStringValue();
    assertTrue(expectedDefaultValue1.compareTo(actualValue1) == 0);
    String expectedDefaultValue2 = fontFamilies[0];
    field.populateField(expectedDefaultValue2);
    String actualValue2 = field.getStringValue();
    assertTrue(expectedDefaultValue2.compareTo(actualValue2) == 0);
    UndoManager.getInstance().undo();
    String actualValue = field.getStringValue();
    assertTrue(expectedDefaultValue1.compareTo(actualValue) == 0);
    UndoManager.getInstance().redo();
    actualValue = field.getStringValue();
    assertTrue(expectedDefaultValue2.compareTo(actualValue) == 0);
    // Increase the code coverage
    field.undoAction(null);
    field.undoAction(new UndoEvent(null, FieldIdEnum.NAME, Double.valueOf(1.0), Double.valueOf(2.0)));
    field.redoAction(null);
    field.redoAction(new UndoEvent(null, FieldIdEnum.NAME, Double.valueOf(1.0), Double.valueOf(2.0)));
}
Also used : FieldConfigFont(com.sldeditor.ui.detail.config.font.FieldConfigFont) UndoEvent(com.sldeditor.common.undo.UndoEvent) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Example 8 with FieldConfigFont

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

the class FieldConfigFontTest method testAttributeSelection.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.font.FieldConfigFont#attributeSelection(java.lang.String)}.
 */
@Test
public void testAttributeSelection() {
    boolean valueOnly = true;
    FieldConfigFont field = new FieldConfigFont(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly));
    field.attributeSelection("field");
// Does nothing
}
Also used : FieldConfigFont(com.sldeditor.ui.detail.config.font.FieldConfigFont) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Example 9 with FieldConfigFont

use of com.sldeditor.ui.detail.config.font.FieldConfigFont 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)

Aggregations

FieldConfigFont (com.sldeditor.ui.detail.config.font.FieldConfigFont)9 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)8 Test (org.junit.Test)8 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)2 Font (org.geotools.styling.Font)2 StyleBuilder (org.geotools.styling.StyleBuilder)2 UndoEvent (com.sldeditor.common.undo.UndoEvent)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