Search in sources :

Example 1 with TextSymbolizerDetails

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

the class TextSymbolizerDetailsTest method testTextSymbolizerDetails.

/**
 * Test method for {@link com.sldeditor.ui.detail.TextSymbolizerDetails#TextSymbolizerDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}.
 * Test method for {@link com.sldeditor.ui.detail.TextSymbolizerDetails#populate(com.sldeditor.common.data.SelectedSymbol)}.
 * Test method for {@link com.sldeditor.ui.detail.TextSymbolizerDetails#dataChanged(com.sldeditor.ui.detail.config.FieldId)}.
 * Test method for {@link com.sldeditor.ui.detail.TextSymbolizerDetails#getFieldDataManager()}.
 * Test method for {@link com.sldeditor.ui.detail.TextSymbolizerDetails#isDataPresent()}.
 * Test method for {@link com.sldeditor.ui.detail.TextSymbolizerDetails#preLoadSymbol()}.
 */
@Test
public void testTextSymbolizerDetails() {
    TextSymbolizerDetails panel = new TextSymbolizerDetails();
    panel.populate(null);
    // Set up test data
    StyledLayerDescriptor sld = DefaultSymbols.createNewSLD();
    SelectedSymbol.getInstance().createNewSLD(sld);
    NamedLayer namedLayer = DefaultSymbols.createNewNamedLayer();
    String expectedNameLayerValue = "named layer test value";
    namedLayer.setName(expectedNameLayerValue);
    Style style = DefaultSymbols.createNewStyle();
    String expectedNameStyleValue = "style test value";
    style.setName(expectedNameStyleValue);
    namedLayer.addStyle(style);
    FeatureTypeStyle fts = DefaultSymbols.createNewFeatureTypeStyle();
    String expectedNameFTSValue = "feature type style test value";
    fts.setName(expectedNameFTSValue);
    style.featureTypeStyles().add(fts);
    Rule rule = DefaultSymbols.createNewRule();
    String expectedRuleValue = "rule test value";
    rule.setName(expectedRuleValue);
    TextSymbolizer symbolizer = DefaultSymbols.createDefaultTextSymbolizer();
    String expectedNameValue = "symbolizer test value";
    symbolizer.setName(expectedNameValue);
    rule.symbolizers().add(symbolizer);
    fts.rules().add(rule);
    sld.layers().add(namedLayer);
    SelectedSymbol.getInstance().addNewStyledLayer(namedLayer);
    SelectedSymbol.getInstance().setStyledLayer(namedLayer);
    SelectedSymbol.getInstance().setStyle(style);
    SelectedSymbol.getInstance().setFeatureTypeStyle(fts);
    SelectedSymbol.getInstance().setRule(rule);
    SelectedSymbol.getInstance().setSymbolizer(symbolizer);
    panel.populate(SelectedSymbol.getInstance());
    GraphicPanelFieldManager fieldDataManager = panel.getFieldDataManager();
    assertNotNull(fieldDataManager);
    panel.dataChanged(null);
    FieldConfigString nameField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.NAME);
    assertNull(nameField);
    assertTrue(panel.isDataPresent());
    // Reset to default value
    panel.preLoadSymbol();
}
Also used : StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) TextSymbolizer(org.geotools.styling.TextSymbolizer) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) Rule(org.geotools.styling.Rule) NamedLayer(org.geotools.styling.NamedLayer) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) TextSymbolizerDetails(com.sldeditor.ui.detail.TextSymbolizerDetails) Test(org.junit.Test)

Example 2 with TextSymbolizerDetails

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

the class VOGeoServerTextSymbolizer2Test method testVOGeoServerTextSymbolizer2.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.vendor.geoserver.text.VOGeoServerTextSymbolizer2#VOGeoServerTextSymbolizer2(java.lang.Class, com.sldeditor.filter.v2.function.FunctionNameInterface)}.
 */
@Test
public void testVOGeoServerTextSymbolizer2() {
    TextSymbolizerDetails panel = new TextSymbolizerDetails();
    TextSymbolizer2 textSymbolizer = null;
    VOGeoServerTextSymbolizer2 testObj = new VOGeoServerTextSymbolizer2(panel.getClass());
    testObj.setParentPanel(panel);
    testObj.populate(textSymbolizer);
    testObj.updateSymbol(textSymbolizer);
    StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
    textSymbolizer = (TextSymbolizer2) styleFactory.createTextSymbolizer();
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    Literal featureDescription = ff.literal("feature description");
    textSymbolizer.setFeatureDescription(featureDescription);
    OtherText otherText = new OtherTextImpl();
    otherText.setTarget("target");
    Literal otherTextExpression = ff.literal("other text");
    otherText.setText(otherTextExpression);
    textSymbolizer.setOtherText(otherText);
    Literal snippet = ff.literal("snippet");
    textSymbolizer.setSnippet(snippet);
    // Try with marker symbol
    Graphic graphic = styleFactory.createDefaultGraphic();
    graphic.graphicalSymbols().add(styleFactory.createMark());
    textSymbolizer.setGraphic(graphic);
    Controller.getInstance().setPopulating(true);
    testObj.populate(textSymbolizer);
    Controller.getInstance().setPopulating(false);
    testObj.updateSymbol(textSymbolizer);
    // Try with external graphic
    graphic = styleFactory.createDefaultGraphic();
    try {
        graphic.graphicalSymbols().add(styleFactory.createExternalGraphic(new File("test.png").toURI().toURL(), "png"));
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
    textSymbolizer.setGraphic(graphic);
    Controller.getInstance().setPopulating(true);
    testObj.populate(textSymbolizer);
    Controller.getInstance().setPopulating(false);
    testObj.updateSymbol(textSymbolizer);
    // Find minimum version with textSymbolizer2 values set
    List<VendorOptionPresent> vendorOptionsPresentList = new ArrayList<VendorOptionPresent>();
    testObj.getMinimumVersion(null, textSymbolizer, vendorOptionsPresentList);
    assertEquals(1, vendorOptionsPresentList.size());
    // Find minimum version with no textSymbolizer2 values set
    vendorOptionsPresentList.clear();
    testObj.getMinimumVersion(null, styleFactory.createTextSymbolizer(), vendorOptionsPresentList);
    assertEquals(0, vendorOptionsPresentList.size());
    // Get the code coverage values up
    testObj.populate(SelectedSymbol.getInstance());
    PolygonSymbolizer polygon = null;
    testObj.populate(polygon);
    testObj.updateSymbol(polygon);
    RasterSymbolizer raster = null;
    testObj.populate(raster);
    testObj.updateSymbol(raster);
    testObj.preLoadSymbol();
    assertTrue(testObj.isDataPresent());
}
Also used : VendorOptionPresent(com.sldeditor.common.vendoroption.minversion.VendorOptionPresent) MalformedURLException(java.net.MalformedURLException) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) Graphic(org.geotools.styling.Graphic) ArrayList(java.util.ArrayList) OtherText(org.geotools.styling.OtherText) FilterFactory(org.opengis.filter.FilterFactory) RasterSymbolizer(org.geotools.styling.RasterSymbolizer) OtherTextImpl(org.geotools.styling.OtherTextImpl) TextSymbolizer2(org.geotools.styling.TextSymbolizer2) VOGeoServerTextSymbolizer2(com.sldeditor.ui.detail.vendor.geoserver.text.VOGeoServerTextSymbolizer2) StyleFactoryImpl(org.geotools.styling.StyleFactoryImpl) Literal(org.opengis.filter.expression.Literal) VOGeoServerTextSymbolizer2(com.sldeditor.ui.detail.vendor.geoserver.text.VOGeoServerTextSymbolizer2) File(java.io.File) TextSymbolizerDetails(com.sldeditor.ui.detail.TextSymbolizerDetails) Test(org.junit.Test)

Example 3 with TextSymbolizerDetails

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

the class VOGeoServerTextSpacingTest method testVOGeoServerTextSpacingTest.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.vendor.geoserver.text.VOGeoServerTextSpacingTest#VOGeoServerTextSpacingTest(java.lang.Class, com.sldeditor.filter.v2.function.FunctionNameInterface)}.
 */
@Test
public void testVOGeoServerTextSpacingTest() {
    TextSymbolizerDetails panel = new TextSymbolizerDetails();
    TextSymbolizer2 textSymbolizer = null;
    VOGeoServerTextSpacing testObj = new VOGeoServerTextSpacing(panel.getClass());
    testObj.setParentPanel(panel);
    testObj.populate(textSymbolizer);
    testObj.updateSymbol(textSymbolizer);
    StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
    textSymbolizer = (TextSymbolizer2) styleFactory.createTextSymbolizer();
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    Literal featureDescription = ff.literal("feature description");
    textSymbolizer.setFeatureDescription(featureDescription);
    OtherText otherText = new OtherTextImpl();
    otherText.setTarget("target");
    Literal otherTextExpression = ff.literal("other text");
    otherText.setText(otherTextExpression);
    textSymbolizer.setOtherText(otherText);
    Literal snippet = ff.literal("snippet");
    textSymbolizer.setSnippet(snippet);
    // Try with marker symbol
    Graphic graphic = styleFactory.createDefaultGraphic();
    graphic.graphicalSymbols().add(styleFactory.createMark());
    textSymbolizer.setGraphic(graphic);
    Controller.getInstance().setPopulating(true);
    testObj.populate(textSymbolizer);
    Controller.getInstance().setPopulating(false);
    testObj.updateSymbol(textSymbolizer);
    // Try with external graphic
    graphic = styleFactory.createDefaultGraphic();
    try {
        graphic.graphicalSymbols().add(styleFactory.createExternalGraphic(new File("test.png").toURI().toURL(), "png"));
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
    textSymbolizer.setGraphic(graphic);
    textSymbolizer.getOptions().put("wordSpacing", String.valueOf(42));
    textSymbolizer.getOptions().put("charSpacing", String.valueOf(21));
    Controller.getInstance().setPopulating(true);
    testObj.populate(textSymbolizer);
    Controller.getInstance().setPopulating(false);
    testObj.updateSymbol(textSymbolizer);
    // Find minimum version with textSymbolizer2 values set
    List<VendorOptionPresent> vendorOptionsPresentList = new ArrayList<VendorOptionPresent>();
    testObj.getMinimumVersion(null, textSymbolizer, vendorOptionsPresentList);
    assertEquals(2, vendorOptionsPresentList.size());
    // Find minimum version with no textSymbolizer2 values set
    vendorOptionsPresentList.clear();
    testObj.getMinimumVersion(null, styleFactory.createTextSymbolizer(), vendorOptionsPresentList);
    assertEquals(0, vendorOptionsPresentList.size());
    // Get the code coverage values up
    testObj.populate(SelectedSymbol.getInstance());
    PolygonSymbolizer polygon = null;
    testObj.populate(polygon);
    testObj.updateSymbol(polygon);
    FeatureTypeStyle fts = null;
    testObj.populate(fts);
    testObj.updateSymbol(fts);
    RasterSymbolizer raster = null;
    testObj.populate(raster);
    testObj.updateSymbol(raster);
    testObj.preLoadSymbol();
    assertTrue(testObj.isDataPresent());
}
Also used : VendorOptionPresent(com.sldeditor.common.vendoroption.minversion.VendorOptionPresent) MalformedURLException(java.net.MalformedURLException) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) Graphic(org.geotools.styling.Graphic) ArrayList(java.util.ArrayList) OtherText(org.geotools.styling.OtherText) FilterFactory(org.opengis.filter.FilterFactory) RasterSymbolizer(org.geotools.styling.RasterSymbolizer) OtherTextImpl(org.geotools.styling.OtherTextImpl) TextSymbolizer2(org.geotools.styling.TextSymbolizer2) StyleFactoryImpl(org.geotools.styling.StyleFactoryImpl) Literal(org.opengis.filter.expression.Literal) VOGeoServerTextSpacing(com.sldeditor.ui.detail.vendor.geoserver.text.VOGeoServerTextSpacing) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) File(java.io.File) TextSymbolizerDetails(com.sldeditor.ui.detail.TextSymbolizerDetails) Test(org.junit.Test)

Aggregations

TextSymbolizerDetails (com.sldeditor.ui.detail.TextSymbolizerDetails)3 Test (org.junit.Test)3 VendorOptionPresent (com.sldeditor.common.vendoroption.minversion.VendorOptionPresent)2 File (java.io.File)2 MalformedURLException (java.net.MalformedURLException)2 ArrayList (java.util.ArrayList)2 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)2 Graphic (org.geotools.styling.Graphic)2 OtherText (org.geotools.styling.OtherText)2 OtherTextImpl (org.geotools.styling.OtherTextImpl)2 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)2 RasterSymbolizer (org.geotools.styling.RasterSymbolizer)2 StyleFactoryImpl (org.geotools.styling.StyleFactoryImpl)2 TextSymbolizer2 (org.geotools.styling.TextSymbolizer2)2 FilterFactory (org.opengis.filter.FilterFactory)2 Literal (org.opengis.filter.expression.Literal)2 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)1 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)1 VOGeoServerTextSpacing (com.sldeditor.ui.detail.vendor.geoserver.text.VOGeoServerTextSpacing)1 VOGeoServerTextSymbolizer2 (com.sldeditor.ui.detail.vendor.geoserver.text.VOGeoServerTextSymbolizer2)1