Search in sources :

Example 91 with FieldConfigBase

use of com.sldeditor.ui.detail.config.FieldConfigBase 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 92 with FieldConfigBase

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

the class BasePanel method populateOptionGroup.

/**
 * Populate option group.
 *
 * @param parent the parent
 * @param optionGroupConfig the option group config
 */
private void populateOptionGroup(UpdateSymbolInterface parent, GroupConfig optionGroupConfig) {
    List<FieldConfigBase> fieldList = optionGroupConfig.getFieldConfigList();
    fieldConfigManager.addGroup(optionGroupConfig);
    // Create field user interface
    for (FieldConfigBase field : fieldList) {
        addFieldConfig(field);
        fieldConfigManager.addField(field);
    }
    // Register for notifications when data has changed
    registerForSymbolUpdates(fieldList, parent);
    for (GroupConfigInterface subOptionGroupConfig : optionGroupConfig.getSubGroupList()) {
        if (subOptionGroupConfig instanceof GroupConfig) {
            populateOptionGroup(parent, (GroupConfig) subOptionGroupConfig);
        } else if (subOptionGroupConfig instanceof MultiOptionGroup) {
            MultiOptionGroup multiOption = (MultiOptionGroup) subOptionGroupConfig;
            fieldConfigManager.addMultiOptionGroup(multiOption);
            for (OptionGroup optionGroup : multiOption.getGroupList()) {
                for (GroupConfigInterface subMultiOptionGroupConfig : optionGroup.getGroupList()) {
                    if (subMultiOptionGroupConfig instanceof GroupConfig) {
                        populateOptionGroup(parent, (GroupConfig) subMultiOptionGroupConfig);
                    }
                }
            }
        }
    }
}
Also used : OptionGroup(com.sldeditor.ui.detail.config.base.OptionGroup) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup) FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) GroupConfig(com.sldeditor.ui.detail.config.base.GroupConfig) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup)

Example 93 with FieldConfigBase

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

the class FilterManagerTest method testConvertParameters.

/**
 * Test method for
 * {@link com.sldeditor.filter.v2.function.FilterManager#convertParameters(java.lang.Class, com.sldeditor.ui.detail.config.FieldId, org.opengis.filter.capability.FunctionName)}.
 */
@Test
public void testConvertParameters() {
    DefaultFunctionFactory functionFactory = new DefaultFunctionFactory();
    List<FunctionName> functionNameList = functionFactory.getFunctionNames();
    // Try with empty parameters
    Class<?> panelId = null;
    List<GroupConfigInterface> list = FilterManager.getInstance().convertParameters(panelId, null);
    assertTrue(list.isEmpty());
    // Find a known function
    for (FunctionName functionName : functionNameList) {
        list = FilterManager.getInstance().convertParameters(panelId, functionName);
        System.out.println(functionName.getName());
        assertEquals(1, list.size());
        GroupConfig groupConfig = (GroupConfig) list.get(0);
        List<FieldConfigBase> fieldList = groupConfig.getFieldConfigList();
        assertEquals(functionName.getName(), fieldList.size(), Math.abs(functionName.getArgumentCount()));
        List<String> argList = new ArrayList<String>();
        for (int fieldIndex = 0; fieldIndex < fieldList.size(); fieldIndex++) {
            checkFieldType(fieldIndex, fieldList, functionName, argList);
        }
        StringBuilder sb = new StringBuilder();
        sb.append(functionName.getName());
        sb.append("(");
        for (int index = 0; index < argList.size(); index++) {
            if (index > 0) {
                sb.append(", ");
            }
            sb.append(argList.get(index));
        }
        sb.append(")");
        String prototype = groupConfig.getLabel();
        assertNotNull(functionName.getName(), prototype);
        assertNotNull(functionName.getName(), sb.toString());
        assertTrue(prototype.compareTo(sb.toString()) == 0);
    }
}
Also used : FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) ArrayList(java.util.ArrayList) LineString(com.vividsolutions.jts.geom.LineString) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) FunctionName(org.opengis.filter.capability.FunctionName) GroupConfig(com.sldeditor.ui.detail.config.base.GroupConfig) DefaultFunctionFactory(org.geotools.filter.function.DefaultFunctionFactory) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface) Test(org.junit.Test)

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