Search in sources :

Example 86 with FieldConfigBase

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

the class FieldConfigVendorOptionTest method testCreateCopy.

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

        public TestFieldConfigVendorOption(FieldConfigCommonData commonData, List<VendorOptionInterface> veList) {
            super(commonData, veList);
        }

        public FieldConfigPopulate callCreateCopy(FieldConfigBase fieldConfigBase) {
            return createCopy(fieldConfigBase);
        }
    }
    TestFieldConfigVendorOption field = new TestFieldConfigVendorOption(new FieldConfigCommonData(Double.class, FieldIdEnum.NAME, "label", valueOnly), null);
    FieldConfigVendorOption copy = (FieldConfigVendorOption) field.callCreateCopy(null);
    assertNull(copy);
    copy = (FieldConfigVendorOption) 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) FieldConfigVendorOption(com.sldeditor.ui.detail.config.FieldConfigVendorOption) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 87 with FieldConfigBase

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

the class FieldConfigColourMapTest method testCreateCopy.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.colourmap.FieldConfigColourMap#createCopy(com.sldeditor.ui.detail.config.FieldConfigBase)}.
 */
@Test
public void testCreateCopy() {
    class TestFieldConfigColourMap extends FieldConfigColourMap {

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

        public FieldConfigPopulate callCreateCopy(FieldConfigBase fieldConfigBase) {
            return createCopy(fieldConfigBase);
        }
    }
    TestFieldConfigColourMap field = new TestFieldConfigColourMap(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", true));
    FieldConfigColourMap copy = (FieldConfigColourMap) field.callCreateCopy(null);
    assertNull(copy);
    copy = (FieldConfigColourMap) field.callCreateCopy(field);
    assertEquals(field.getFieldId(), copy.getFieldId());
    assertTrue(field.getLabel().compareTo(copy.getLabel()) == 0);
    assertEquals(field.isValueOnly(), copy.isValueOnly());
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) FieldConfigColourMap(com.sldeditor.ui.detail.config.colourmap.FieldConfigColourMap) FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Example 88 with FieldConfigBase

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

the class PolygonFillDetails method setSymbolTypeVisibility.

/**
 * Sets the symbol type visibility.
 *
 * @param panelId the panel id
 * @param selectedItem the selected item
 */
private void setSymbolTypeVisibility(Class<?> panelId, String selectedItem) {
    Map<GroupIdEnum, Boolean> groupList = fieldEnableState.getGroupIdList(panelId.getName(), selectedItem);
    for (GroupIdEnum groupId : groupList.keySet()) {
        boolean groupEnabled = groupList.get(groupId);
        GroupConfigInterface groupConfig = fieldConfigManager.getGroup(this.getClass(), groupId);
        if (groupConfig != null) {
            groupConfig.setGroupStateOverride(groupEnabled);
        } else {
            ConsoleManager.getInstance().error(this, "Failed to find group : " + groupId.toString());
        }
    }
    Map<FieldIdEnum, Boolean> fieldList = fieldEnableState.getFieldIdList(panelId.getName(), selectedItem);
    for (FieldIdEnum fieldId : fieldList.keySet()) {
        boolean fieldEnabled = fieldList.get(fieldId);
        FieldConfigBase fieldConfig = fieldConfigManager.get(fieldId);
        if (fieldConfig != null) {
            CurrentFieldState fieldState = fieldConfig.getFieldState();
            fieldState.setFieldEnabled(fieldEnabled);
            fieldConfig.setFieldState(fieldState);
        } else {
            ConsoleManager.getInstance().error(this, "Failed to find field : " + fieldId.toString());
        }
    }
}
Also used : FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) CurrentFieldState(com.sldeditor.ui.detail.config.base.CurrentFieldState) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) GroupIdEnum(com.sldeditor.common.xml.ui.GroupIdEnum)

Example 89 with FieldConfigBase

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

the class PolygonFillDetails method optionSelected.

/**
 * Option selected.
 *
 * @param fieldPanelId the field panel id
 * @param selectedItem the selected item
 */
@Override
public void optionSelected(Class<?> fieldPanelId, String selectedItem) {
    setSymbolTypeVisibility(fieldPanelId, selectedItem);
    selectedFillPanelId = fieldPanelId;
    FieldConfigBase fieldConfig = fieldConfigManager.get(FieldIdEnum.SIZE);
    if (fieldConfig.isEnabled()) {
        Expression expression = fieldConfig.getExpression();
        if (expression instanceof LiteralExpressionImpl) {
            LiteralExpressionImpl l = (LiteralExpressionImpl) expression;
            Double d = (Double) l.getValue();
            if (d <= 0.0) {
                fieldConfigVisitor.populateField(FieldIdEnum.SIZE, getFilterFactory().literal(1));
            }
        }
    }
    dataHasChanged();
}
Also used : FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) Expression(org.opengis.filter.expression.Expression) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl)

Example 90 with FieldConfigBase

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

the class StandardPanel method populateStandardData.

/**
 * Populate standard data.
 *
 * @param standardData the standard data
 */
private void populateStandardData(StandardData standardData) {
    Description description = standardData.description;
    String titleString = "";
    String descriptionString = "";
    if (description != null) {
        InternationalString title = description.getTitle();
        if (title != null) {
            titleString = title.toString();
        }
        InternationalString abstractDesc = description.getAbstract();
        if (abstractDesc != null) {
            descriptionString = abstractDesc.toString();
        }
    }
    if (fieldConfigVisitor.getFieldConfig(FieldIdEnum.NAME) != null) {
        fieldConfigVisitor.populateTextField(FieldIdEnum.NAME, standardData.name);
    }
    if (fieldConfigVisitor.getFieldConfig(FieldIdEnum.TITLE) != null) {
        fieldConfigVisitor.populateTextField(FieldIdEnum.TITLE, titleString);
    }
    if (fieldConfigVisitor.getFieldConfig(FieldIdEnum.DESCRIPTION) != null) {
        fieldConfigVisitor.populateTextField(FieldIdEnum.DESCRIPTION, descriptionString);
    }
    FieldConfigBase uomFieldConfig = fieldConfigManager.get(FieldIdEnum.UOM);
    if (uomFieldConfig != null) {
        uomFieldConfig.updateAttributeSelection(SelectedSymbol.getInstance().isRasterSymbol());
        String uomString = UnitsOfMeasure.getInstance().convert(standardData.unit);
        fieldConfigVisitor.populateField(FieldIdEnum.UOM, getFilterFactory().literal(uomString));
    }
}
Also used : Description(org.geotools.styling.Description) FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) InternationalString(org.opengis.util.InternationalString) InternationalString(org.opengis.util.InternationalString)

Aggregations

FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)93 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)43 Test (org.junit.Test)42 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)27 FieldConfigColour (com.sldeditor.ui.detail.config.FieldConfigColour)22 Expression (org.opengis.filter.expression.Expression)19 Mark (org.geotools.styling.Mark)14 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)13 FieldConfigSlider (com.sldeditor.ui.detail.config.FieldConfigSlider)13 FieldConfigSymbolType (com.sldeditor.ui.detail.config.FieldConfigSymbolType)13 GroupConfigInterface (com.sldeditor.ui.detail.config.base.GroupConfigInterface)13 PointFillDetails (com.sldeditor.ui.detail.PointFillDetails)12 ColourFieldConfig (com.sldeditor.ui.detail.ColourFieldConfig)10 ArrayList (java.util.ArrayList)10 Fill (org.geotools.styling.Fill)10 GraphicFill (org.opengis.style.GraphicFill)10 GraphicalSymbol (org.opengis.style.GraphicalSymbol)10 Geometry (com.vividsolutions.jts.geom.Geometry)9 StyleBuilder (org.geotools.styling.StyleBuilder)8 FieldConfigMarker (com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker)7