Search in sources :

Example 41 with GroupConfigInterface

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

the class RasterSymbolizerDetails method populate.

/**
 * Populate.
 *
 * @param selectedSymbol the selected symbol
 */
/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.ui.iface.PopulateDetailsInterface#populate(com.sldeditor.ui.detail.selectedsymbol.SelectedSymbol)
     */
@Override
public void populate(SelectedSymbol selectedSymbol) {
    if (selectedSymbol != null) {
        RasterSymbolizer rasterSymbolizer = (RasterSymbolizer) selectedSymbol.getSymbolizer();
        if (rasterSymbolizer != null) {
            populateStandardData(rasterSymbolizer);
            // Opacity
            fieldConfigVisitor.populateField(FieldIdEnum.RASTER_OPACITY, rasterSymbolizer.getOpacity());
            // Contrast enhancement
            ContrastEnhancement contrast = rasterSymbolizer.getContrastEnhancement();
            GroupConfigInterface group = getGroup(GroupIdEnum.RASTER_CONTRAST);
            if (group != null) {
                group.enable(contrast != null);
            }
            if (contrast != null) {
                Expression gammaValue = contrast.getGammaValue();
                fieldConfigVisitor.populateField(FieldIdEnum.RASTER_CONTRAST_GAMMAVALUE, gammaValue);
                populateContrastMethod(contrast, GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD);
            }
            // Channel selection
            group = getGroup(GroupIdEnum.RASTER_CHANNELSELECTION);
            if (group != null) {
                MultiOptionGroup channelSelectionGroup = (MultiOptionGroup) group;
                ChannelSelection channelSelection = rasterSymbolizer.getChannelSelection();
                boolean enableChannelSelection = false;
                if (channelSelection != null) {
                    SelectedChannelType[] rgbChannels = channelSelection.getRGBChannels();
                    enableChannelSelection = ((channelSelection.getGrayChannel() != null) || (rgbChannels[0] != null) || (rgbChannels[1] != null) || (rgbChannels[2] != null));
                }
                channelSelectionGroup.enable(enableChannelSelection);
                if (enableChannelSelection) {
                    SelectedChannelType greyChannel = channelSelection.getGrayChannel();
                    if (greyChannel != null) {
                        channelSelectionGroup.setOption(GroupIdEnum.RASTER_GREY_CHANNEL_OPTION);
                        populateContrastEnhancementGroup(GroupIdEnum.RASTER_GREY_CHANNEL, FieldIdEnum.RASTER_RGB_GREY_NAME, GroupIdEnum.RASTER_RGB_CHANNEL_GREY_CONTRAST, FieldIdEnum.RASTER_RGB_CHANNEL_GREY_CONTRAST_GAMMA, GroupIdEnum.RASTER_RGB_CHANNEL_GREY_CONTRAST_METHOD, greyChannel);
                    } else {
                        SelectedChannelType[] rgbChannels = channelSelection.getRGBChannels();
                        channelSelectionGroup.setOption(GroupIdEnum.RASTER_RGB_CHANNEL_OPTION);
                        populateContrastEnhancementGroup(GroupIdEnum.RASTER_RGB_CHANNEL_RED, FieldIdEnum.RASTER_RGB_RED_NAME, GroupIdEnum.RASTER_RGB_CHANNEL_RED_CONTRAST, FieldIdEnum.RASTER_RGB_CHANNEL_RED_CONTRAST_GAMMA, GroupIdEnum.RASTER_RGB_CHANNEL_RED_CONTRAST_METHOD, rgbChannels[0]);
                        populateContrastEnhancementGroup(GroupIdEnum.RASTER_RGB_CHANNEL_GREEN, FieldIdEnum.RASTER_RGB_GREEN_NAME, GroupIdEnum.RASTER_RGB_CHANNEL_GREEN_CONTRAST, FieldIdEnum.RASTER_RGB_CHANNEL_GREEN_CONTRAST_GAMMA, GroupIdEnum.RASTER_RGB_CHANNEL_GREEN_CONTRAST_METHOD, rgbChannels[1]);
                        populateContrastEnhancementGroup(GroupIdEnum.RASTER_RGB_CHANNEL_BLUE, FieldIdEnum.RASTER_RGB_BLUE_NAME, GroupIdEnum.RASTER_RGB_CHANNEL_BLUE_CONTRAST, FieldIdEnum.RASTER_RGB_CHANNEL_BLUE_CONTRAST_GAMMA, GroupIdEnum.RASTER_RGB_CHANNEL_BLUE_CONTRAST_METHOD, rgbChannels[2]);
                    }
                }
            }
            // Colour map
            ColorMap colourMap = rasterSymbolizer.getColorMap();
            fieldConfigVisitor.populateComboBoxField(FieldIdEnum.RASTER_COLOURMAP_TYPE, Integer.valueOf(colourMap.getType()).toString());
            fieldConfigVisitor.populateColourMapField(FieldIdEnum.RASTER_COLOURMAP, colourMap);
            // Shaded relief
            ShadedRelief shadedRelief = rasterSymbolizer.getShadedRelief();
            group = getGroup(GroupIdEnum.RASTER_SHADEDRELIEF);
            if (group != null) {
                group.enable(shadedRelief != null);
            }
            if (shadedRelief != null) {
                fieldConfigVisitor.populateBooleanField(FieldIdEnum.RASTER_SHADEDRELIEF_BRIGHTNESS, shadedRelief.isBrightnessOnly());
                fieldConfigVisitor.populateField(FieldIdEnum.RASTER_SHADEDRELIEF_FACTOR, shadedRelief.getReliefFactor());
            }
            // Overlap behaviour
            OverlapBehavior overlapBehaviour = rasterSymbolizer.getOverlapBehavior();
            group = getGroup(GroupIdEnum.RASTER_OVERLAP);
            if (group != null) {
                group.enable(overlapBehaviour != null);
            }
            if (overlapBehaviour != null) {
                fieldConfigVisitor.populateComboBoxField(FieldIdEnum.RASTER_OVERLAP_BEHAVIOUR, overlapBehaviour.name());
            }
            if (vendorOptionRasterFactory != null) {
                vendorOptionRasterFactory.populate(rasterSymbolizer);
            }
        }
    }
}
Also used : RasterSymbolizer(org.geotools.styling.RasterSymbolizer) SelectedChannelType(org.geotools.styling.SelectedChannelType) ContrastEnhancement(org.geotools.styling.ContrastEnhancement) Expression(org.opengis.filter.expression.Expression) ChannelSelection(org.geotools.styling.ChannelSelection) ColorMap(org.geotools.styling.ColorMap) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup) ShadedRelief(org.geotools.styling.ShadedRelief) OverlapBehavior(org.opengis.style.OverlapBehavior)

Example 42 with GroupConfigInterface

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

the class BasePanel method isPanelEnabled.

/**
 * Checks if is panel enabled.
 *
 * @param groupId the group id
 * @return true, if is panel enabled
 */
protected boolean isPanelEnabled(GroupIdEnum groupId) {
    boolean isEnabled = false;
    GroupConfigInterface group = getGroup(groupId);
    if (group != null) {
        isEnabled = group.isPanelEnabled();
    }
    return isEnabled;
}
Also used : GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface)

Example 43 with GroupConfigInterface

use of com.sldeditor.ui.detail.config.base.GroupConfigInterface 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 44 with GroupConfigInterface

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

the class BasePanel method configureUI.

/**
 * Configure ui.
 *
 * @param parent the parent
 * @param useScrollFrame the use scroll frame
 * @param config the config
 */
private void configureUI(UpdateSymbolInterface parent, boolean useScrollFrame, PanelConfigInterface config) {
    groupConfigList = config.getGroupList();
    vendorOptionVersion = config.getVendorOptionVersion();
    if (vendorOptionVersion == null) {
        vendorOptionVersion = VendorOptionManager.getInstance().getDefaultVendorOptionVersion();
    }
    defaultFieldMap = config.getDefaultFieldMap();
    setBorder(BorderFactory.createTitledBorder(config.getPanelTitle()));
    if (containingPanel == null) {
        setLayout(new BorderLayout());
        containingPanel = new JPanel();
        containingPanel.setLayout(new BorderLayout());
        box = Box.createVerticalBox();
        padding = new BasePanelPadding(box);
        containingPanel.add(box, BorderLayout.CENTER);
    }
    for (GroupConfigInterface groupConfig : groupConfigList) {
        populateGroup(parent, box, groupConfig, null);
    }
    if (scrollFrame == null) {
        if (useScrollFrame) {
            scrollFrame = new JScrollPane(containingPanel);
            containingPanel.setAutoscrolls(true);
            // Create a vertical strut so all the fields are pushed to the top of the panel
            Dimension boxSize = padding.addPadding();
            scrollFrame.setPreferredSize(boxSize);
            preferredSize = boxSize;
            add(scrollFrame, BorderLayout.CENTER);
        } else {
            add(containingPanel, BorderLayout.CENTER);
            preferredSize = this.getPreferredSize();
        }
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface) Dimension(java.awt.Dimension)

Example 45 with GroupConfigInterface

use of com.sldeditor.ui.detail.config.base.GroupConfigInterface 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

GroupConfigInterface (com.sldeditor.ui.detail.config.base.GroupConfigInterface)45 MultiOptionGroup (com.sldeditor.ui.detail.config.base.MultiOptionGroup)18 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)13 Expression (org.opengis.filter.expression.Expression)13 OptionGroup (com.sldeditor.ui.detail.config.base.OptionGroup)9 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)8 GroupIdEnum (com.sldeditor.common.xml.ui.GroupIdEnum)8 ChannelSelection (org.geotools.styling.ChannelSelection)8 RasterSymbolizer (org.geotools.styling.RasterSymbolizer)7 Test (org.junit.Test)7 GroupConfig (com.sldeditor.ui.detail.config.base.GroupConfig)6 AnchorPoint (org.geotools.styling.AnchorPoint)6 Displacement (org.geotools.styling.Displacement)6 RasterSymbolizerDetails (com.sldeditor.ui.detail.RasterSymbolizerDetails)5 Box (javax.swing.Box)5 ContrastEnhancement (org.geotools.styling.ContrastEnhancement)5 StyleFactoryImpl (org.geotools.styling.StyleFactoryImpl)5 GraphicalSymbol (org.opengis.style.GraphicalSymbol)5 CurrentFieldState (com.sldeditor.ui.detail.config.base.CurrentFieldState)4 Graphic (org.geotools.styling.Graphic)4