Search in sources :

Example 1 with MultiOptionGroup

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

the class VOGeoServerContrastEnhancementNormalizeGreenTest method testVOGeoServerContrastEnhancementNormalizeGreen.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.vendor.geoserver.raster.VOGeoServerContrastEnhancementNormalizeGreen#VOGeoServerContrastEnhancementNormalizeGreen(java.lang.Class, com.sldeditor.ui.detail.RasterSymbolizerDetails)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.vendor.geoserver.raster.VOGeoServerContrastEnhancementNormalizeGreen#getContrastEnhancement(com.sldeditor.common.xml.ui.GroupIdEnum, org.geotools.styling.ChannelSelection)}.
 */
@Test
public void testVOGeoServerContrastEnhancementNormalizeGreen() {
    RasterSymbolizerDetails panel = new RasterSymbolizerDetails();
    VOGeoServerContrastEnhancementNormalizeGreen testObj = new VOGeoServerContrastEnhancementNormalizeGreen(panel.getClass(), panel);
    RasterSymbolizer rasterSymbolizer = null;
    testObj.setParentPanel(panel);
    testObj.populate(rasterSymbolizer);
    testObj.updateSymbol(rasterSymbolizer);
    StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
    rasterSymbolizer = styleFactory.createRasterSymbolizer();
    GroupConfigInterface constrastMethodGroup = panel.getGroup(GroupIdEnum.RASTER_RGB_CHANNEL_GREEN_CONTRAST_METHOD);
    assertNotNull(constrastMethodGroup);
    MultiOptionGroup constrastMethodGroup2 = (MultiOptionGroup) constrastMethodGroup;
    Box box = Box.createVerticalBox();
    constrastMethodGroup2.createUI(panel.getFieldDataManager(), box, panel, panel.getPanelId());
    constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_LOGARITHMIC);
    ChannelSelection channelSelection = createChannelSelection(styleFactory, ContrastMethod.LOGARITHMIC);
    rasterSymbolizer.setChannelSelection(channelSelection);
    testObj.populate(rasterSymbolizer);
    SelectedSymbol.getInstance().setSymbolizer(rasterSymbolizer);
    Controller.getInstance().setPopulating(true);
    panel.populate(SelectedSymbol.getInstance());
    Controller.getInstance().setPopulating(false);
    testObj.updateSymbol(rasterSymbolizer);
    channelSelection = createChannelSelection(styleFactory, ContrastMethod.EXPONENTIAL);
    rasterSymbolizer.setChannelSelection(channelSelection);
    constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_EXPONENTIAL);
    testObj.populate(rasterSymbolizer);
    testObj.updateSymbol(rasterSymbolizer);
    channelSelection = createChannelSelection(styleFactory, ContrastMethod.HISTOGRAM);
    rasterSymbolizer.setChannelSelection(channelSelection);
    constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_HISTOGRAM);
    testObj.populate(rasterSymbolizer);
    testObj.updateSymbol(rasterSymbolizer);
    channelSelection = createChannelSelection(styleFactory, ContrastMethod.NORMALIZE);
    constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_NORMALIZE);
    rasterSymbolizer.setChannelSelection(channelSelection);
    testObj.populate(rasterSymbolizer);
    testObj.updateSymbol(rasterSymbolizer);
    // Error
    channelSelection = createChannelSelectionError(styleFactory, ContrastMethod.NORMALIZE);
    rasterSymbolizer.setChannelSelection(channelSelection);
    testObj.populate(rasterSymbolizer);
    testObj.updateSymbol(rasterSymbolizer);
    // Increase code coverage
    testObj.populate((SelectedSymbol) null);
    testObj.populate((TextSymbolizer) null);
    testObj.populate((PolygonSymbolizer) null);
    testObj.updateSymbol((TextSymbolizer) null);
    testObj.updateSymbol((PolygonSymbolizer) null);
    testObj.preLoadSymbol();
    assertTrue(testObj.isDataPresent());
    testObj.dataChanged(FieldIdEnum.DESCRIPTION);
}
Also used : RasterSymbolizer(org.geotools.styling.RasterSymbolizer) StyleFactoryImpl(org.geotools.styling.StyleFactoryImpl) ChannelSelection(org.geotools.styling.ChannelSelection) RasterSymbolizerDetails(com.sldeditor.ui.detail.RasterSymbolizerDetails) VOGeoServerContrastEnhancementNormalizeGreen(com.sldeditor.ui.detail.vendor.geoserver.raster.VOGeoServerContrastEnhancementNormalizeGreen) Box(javax.swing.Box) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup) Test(org.junit.Test)

Example 2 with MultiOptionGroup

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

the class VOGeoServerContrastEnhancementNormalizeOverallTest method testVOGeoServerContrastEnhancementNormalizeOverall.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.vendor.geoserver.raster.VOGeoServerContrastEnhancementNormalizeOverall#VOGeoServerContrastEnhancementNormalizeOverall(java.lang.Class, com.sldeditor.ui.detail.RasterSymbolizerDetails)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.vendor.geoserver.raster.VOGeoServerContrastEnhancementNormalizeOverall#getContrastEnhancement(com.sldeditor.common.xml.ui.GroupIdEnum, org.geotools.styling.ChannelSelection)}.
 */
@Test
public void testVOGeoServerContrastEnhancementNormalizeOverall() {
    RasterSymbolizerDetails panel = new RasterSymbolizerDetails();
    VOGeoServerContrastEnhancementNormalizeOverall testObj = new VOGeoServerContrastEnhancementNormalizeOverall(panel.getClass(), panel);
    RasterSymbolizer rasterSymbolizer = null;
    testObj.setParentPanel(panel);
    testObj.populate(rasterSymbolizer);
    testObj.updateSymbol(rasterSymbolizer);
    StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
    rasterSymbolizer = styleFactory.createRasterSymbolizer();
    GroupConfigInterface constrastMethodGroup = panel.getGroup(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD);
    assertNotNull(constrastMethodGroup);
    MultiOptionGroup constrastMethodGroup2 = (MultiOptionGroup) constrastMethodGroup;
    Box box = Box.createVerticalBox();
    constrastMethodGroup2.createUI(panel.getFieldDataManager(), box, panel, panel.getPanelId());
    constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_LOGARITHMIC);
    ChannelSelection channelSelection = createChannelSelection(styleFactory, ContrastMethod.LOGARITHMIC);
    rasterSymbolizer.setChannelSelection(channelSelection);
    testObj.populate(rasterSymbolizer);
    SelectedSymbol.getInstance().setSymbolizer(rasterSymbolizer);
    Controller.getInstance().setPopulating(true);
    panel.populate(SelectedSymbol.getInstance());
    Controller.getInstance().setPopulating(false);
    testObj.updateSymbol(rasterSymbolizer);
    channelSelection = createChannelSelection(styleFactory, ContrastMethod.EXPONENTIAL);
    rasterSymbolizer.setChannelSelection(channelSelection);
    constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_EXPONENTIAL);
    testObj.populate(rasterSymbolizer);
    testObj.updateSymbol(rasterSymbolizer);
    channelSelection = createChannelSelection(styleFactory, ContrastMethod.HISTOGRAM);
    rasterSymbolizer.setChannelSelection(channelSelection);
    constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_HISTOGRAM);
    testObj.populate(rasterSymbolizer);
    testObj.updateSymbol(rasterSymbolizer);
    channelSelection = createChannelSelection(styleFactory, ContrastMethod.NORMALIZE);
    constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_NORMALIZE);
    rasterSymbolizer.setChannelSelection(channelSelection);
    testObj.populate(rasterSymbolizer);
    testObj.updateSymbol(rasterSymbolizer);
    // Error
    channelSelection = createChannelSelectionError(styleFactory, ContrastMethod.NORMALIZE);
    rasterSymbolizer.setChannelSelection(channelSelection);
    testObj.populate(rasterSymbolizer);
    testObj.updateSymbol(rasterSymbolizer);
    // Increase code coverage
    testObj.populate((SelectedSymbol) null);
    testObj.populate((TextSymbolizer) null);
    testObj.populate((PolygonSymbolizer) null);
    testObj.updateSymbol((TextSymbolizer) null);
    testObj.updateSymbol((PolygonSymbolizer) null);
    testObj.preLoadSymbol();
    assertTrue(testObj.isDataPresent());
    testObj.dataChanged(FieldIdEnum.DESCRIPTION);
}
Also used : VOGeoServerContrastEnhancementNormalizeOverall(com.sldeditor.ui.detail.vendor.geoserver.raster.VOGeoServerContrastEnhancementNormalizeOverall) RasterSymbolizer(org.geotools.styling.RasterSymbolizer) StyleFactoryImpl(org.geotools.styling.StyleFactoryImpl) ChannelSelection(org.geotools.styling.ChannelSelection) RasterSymbolizerDetails(com.sldeditor.ui.detail.RasterSymbolizerDetails) Box(javax.swing.Box) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup) Test(org.junit.Test)

Example 3 with MultiOptionGroup

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

the class VOGeoServerContrastEnhancementNormalizeRedTest method testVOGeoServerContrastEnhancementNormalizeRed.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.vendor.geoserver.raster.VOGeoServerContrastEnhancementNormalizeRed#VOGeoServerContrastEnhancementNormalizeRed(java.lang.Class, com.sldeditor.ui.detail.RasterSymbolizerDetails)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.vendor.geoserver.raster.VOGeoServerContrastEnhancementNormalizeRed#getContrastEnhancement(com.sldeditor.common.xml.ui.GroupIdEnum, org.geotools.styling.ChannelSelection)}.
 */
@Test
public void testVOGeoServerContrastEnhancementNormalizeRed() {
    RasterSymbolizerDetails panel = new RasterSymbolizerDetails();
    VOGeoServerContrastEnhancementNormalizeRed testObj = new VOGeoServerContrastEnhancementNormalizeRed(panel.getClass(), panel);
    RasterSymbolizer rasterSymbolizer = null;
    testObj.setParentPanel(panel);
    testObj.populate(rasterSymbolizer);
    testObj.updateSymbol(rasterSymbolizer);
    StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
    rasterSymbolizer = styleFactory.createRasterSymbolizer();
    GroupConfigInterface constrastMethodGroup = panel.getGroup(GroupIdEnum.RASTER_RGB_CHANNEL_RED_CONTRAST_METHOD);
    assertNotNull(constrastMethodGroup);
    MultiOptionGroup constrastMethodGroup2 = (MultiOptionGroup) constrastMethodGroup;
    Box box = Box.createVerticalBox();
    constrastMethodGroup2.createUI(panel.getFieldDataManager(), box, panel, panel.getPanelId());
    constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_LOGARITHMIC);
    ChannelSelection channelSelection = createChannelSelection(styleFactory, ContrastMethod.LOGARITHMIC);
    rasterSymbolizer.setChannelSelection(channelSelection);
    testObj.populate(rasterSymbolizer);
    SelectedSymbol.getInstance().setSymbolizer(rasterSymbolizer);
    Controller.getInstance().setPopulating(true);
    panel.populate(SelectedSymbol.getInstance());
    Controller.getInstance().setPopulating(false);
    testObj.updateSymbol(rasterSymbolizer);
    channelSelection = createChannelSelection(styleFactory, ContrastMethod.EXPONENTIAL);
    rasterSymbolizer.setChannelSelection(channelSelection);
    constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_EXPONENTIAL);
    testObj.populate(rasterSymbolizer);
    testObj.updateSymbol(rasterSymbolizer);
    channelSelection = createChannelSelection(styleFactory, ContrastMethod.HISTOGRAM);
    rasterSymbolizer.setChannelSelection(channelSelection);
    constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_HISTOGRAM);
    testObj.populate(rasterSymbolizer);
    testObj.updateSymbol(rasterSymbolizer);
    channelSelection = createChannelSelection(styleFactory, ContrastMethod.NORMALIZE);
    constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_NORMALIZE);
    rasterSymbolizer.setChannelSelection(channelSelection);
    testObj.populate(rasterSymbolizer);
    testObj.updateSymbol(rasterSymbolizer);
    // Error
    channelSelection = createChannelSelectionError(styleFactory, ContrastMethod.NORMALIZE);
    rasterSymbolizer.setChannelSelection(channelSelection);
    testObj.populate(rasterSymbolizer);
    testObj.updateSymbol(rasterSymbolizer);
    // Increase code coverage
    testObj.populate((SelectedSymbol) null);
    testObj.populate((TextSymbolizer) null);
    testObj.populate((PolygonSymbolizer) null);
    testObj.updateSymbol((TextSymbolizer) null);
    testObj.updateSymbol((PolygonSymbolizer) null);
    testObj.preLoadSymbol();
    assertTrue(testObj.isDataPresent());
    testObj.dataChanged(FieldIdEnum.DESCRIPTION);
}
Also used : RasterSymbolizer(org.geotools.styling.RasterSymbolizer) StyleFactoryImpl(org.geotools.styling.StyleFactoryImpl) ChannelSelection(org.geotools.styling.ChannelSelection) RasterSymbolizerDetails(com.sldeditor.ui.detail.RasterSymbolizerDetails) VOGeoServerContrastEnhancementNormalizeRed(com.sldeditor.ui.detail.vendor.geoserver.raster.VOGeoServerContrastEnhancementNormalizeRed) Box(javax.swing.Box) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup) Test(org.junit.Test)

Example 4 with MultiOptionGroup

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

the class BasePanel method populateGroup.

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

Example 5 with MultiOptionGroup

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

the class ReadPanelConfig method read.

/**
 * Read configuration file and store the configuration in the object.
 *
 * @param panelId the panel id
 * @param resourceString the resource string
 * @return true, if successful
 */
public boolean read(Class<?> panelId, String resourceString) {
    groupList = new ArrayList<GroupConfigInterface>();
    PanelConfig panelConfig = (PanelConfig) ParseXML.parseUIFile(resourceString, SCHEMA_RESOURCE, PanelConfig.class);
    if (panelConfig == null) {
        return false;
    }
    Class<?> localisationClass = ReadPanelConfig.class;
    if (panelConfig.getLocalisation() != null) {
        try {
            localisationClass = Class.forName(panelConfig.getLocalisation());
        } catch (ClassNotFoundException e) {
            ConsoleManager.getInstance().exception(ReadPanelConfig.class, e);
        }
    }
    panelTitle = getLocalisedText(localisationClass, panelConfig.getPanelTitle());
    vendorOptionVersion = getVendorOptionVersion(panelConfig);
    for (Object groupObj : panelConfig.getGroupOrMultiOptionGroup()) {
        if (groupObj instanceof XMLGroupConfig) {
            GroupConfig groupConfig = parseGroup(localisationClass, panelId, (XMLGroupConfig) groupObj);
            groupList.add(groupConfig);
        } else if (groupObj instanceof XMLMultiOptionGroup) {
            MultiOptionGroup groupConfig = parseMultiOptionGroup(localisationClass, panelId, (XMLMultiOptionGroup) groupObj);
            groupList.add(groupConfig);
        }
    }
    return true;
}
Also used : XMLGroupConfig(com.sldeditor.common.xml.ui.XMLGroupConfig) GroupConfig(com.sldeditor.ui.detail.config.base.GroupConfig) XMLGroupConfig(com.sldeditor.common.xml.ui.XMLGroupConfig) XMLMultiOptionGroup(com.sldeditor.common.xml.ui.XMLMultiOptionGroup) PanelConfig(com.sldeditor.common.xml.ui.PanelConfig) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface) XMLMultiOptionGroup(com.sldeditor.common.xml.ui.XMLMultiOptionGroup) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup)

Aggregations

MultiOptionGroup (com.sldeditor.ui.detail.config.base.MultiOptionGroup)23 GroupConfigInterface (com.sldeditor.ui.detail.config.base.GroupConfigInterface)18 OptionGroup (com.sldeditor.ui.detail.config.base.OptionGroup)10 ChannelSelection (org.geotools.styling.ChannelSelection)8 RasterSymbolizer (org.geotools.styling.RasterSymbolizer)7 Test (org.junit.Test)6 Expression (org.opengis.filter.expression.Expression)6 RasterSymbolizerDetails (com.sldeditor.ui.detail.RasterSymbolizerDetails)5 GroupConfig (com.sldeditor.ui.detail.config.base.GroupConfig)5 Box (javax.swing.Box)5 StyleFactoryImpl (org.geotools.styling.StyleFactoryImpl)5 ContrastEnhancement (org.geotools.styling.ContrastEnhancement)4 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)3 GroupIdEnum (com.sldeditor.common.xml.ui.GroupIdEnum)3 XMLGroupConfig (com.sldeditor.common.xml.ui.XMLGroupConfig)3 XMLMultiOptionGroup (com.sldeditor.common.xml.ui.XMLMultiOptionGroup)3 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)3 SelectedChannelType (org.geotools.styling.SelectedChannelType)3 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)2 FieldConfigColour (com.sldeditor.ui.detail.config.FieldConfigColour)2