Search in sources :

Example 6 with ExternalGraphicImpl

use of org.geotools.styling.ExternalGraphicImpl in project sldeditor by robward-scisys.

the class FieldConfigFilenameTest method testAccept.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.symboltype.externalgraphic.FieldConfigFilename#accept(org.opengis.style.GraphicalSymbol)}.
 */
@Test
public void testAccept() {
    boolean valueOnly = true;
    FieldConfigFilename field = new FieldConfigFilename(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), null, null, null);
    assertFalse(field.accept(null));
    StyleBuilder styleBuilder = new StyleBuilder();
    ExternalGraphicImpl externalGraphic = (ExternalGraphicImpl) styleBuilder.createExternalGraphic("test.tmp", "png");
    assertTrue(field.accept(externalGraphic));
    Mark marker = styleBuilder.createMark("triangle");
    assertFalse(field.accept(marker));
}
Also used : FieldConfigFilename(com.sldeditor.ui.detail.config.symboltype.externalgraphic.FieldConfigFilename) ExternalGraphicImpl(org.geotools.styling.ExternalGraphicImpl) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) StyleBuilder(org.geotools.styling.StyleBuilder) Mark(org.geotools.styling.Mark) Test(org.junit.Test)

Example 7 with ExternalGraphicImpl

use of org.geotools.styling.ExternalGraphicImpl in project sldeditor by robward-scisys.

the class FieldConfigFilenameTest method testSetValue.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.symboltype.externalgraphic.FieldConfigFilename#setValue(com.sldeditor.ui.detail.GraphicPanelFieldManager, com.sldeditor.ui.detail.config.FieldConfigSymbolType, org.opengis.style.GraphicalSymbol)}.
 */
@Test
public void testSetValue() {
    boolean valueOnly = true;
    GraphicPanelFieldManager fieldConfigManager = null;
    Class<?> panelId = PointFillDetails.class;
    fieldConfigManager = new GraphicPanelFieldManager(panelId);
    FieldConfigFilename field = new FieldConfigFilename(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), null, null, null);
    field.setValue(null, null, null, null, null);
    field.setValue(null, fieldConfigManager, null, null, null);
    field.createUI();
    StyleBuilder styleBuilder = new StyleBuilder();
    Mark marker = styleBuilder.createMark("star");
    field.setValue(null, null, null, null, marker);
    field.setValue(null, fieldConfigManager, null, null, marker);
    File f = null;
    String filename = null;
    try {
        f = File.createTempFile(getClass().getSimpleName(), ".png");
    } catch (IOException e) {
        e.printStackTrace();
    }
    try {
        if ((f != null) && (f.toURI() != null)) {
            if (f.toURI().toURL() != null) {
                filename = f.toURI().toURL().toString();
            }
        }
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
    ExternalGraphicImpl externalGraphic = (ExternalGraphicImpl) styleBuilder.createExternalGraphic(filename, "png");
    field.setValue(null, fieldConfigManager, null, null, externalGraphic);
    if (f != null) {
        f.delete();
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) StyleBuilder(org.geotools.styling.StyleBuilder) Mark(org.geotools.styling.Mark) IOException(java.io.IOException) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) FieldConfigFilename(com.sldeditor.ui.detail.config.symboltype.externalgraphic.FieldConfigFilename) ExternalGraphicImpl(org.geotools.styling.ExternalGraphicImpl) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) PointFillDetails(com.sldeditor.ui.detail.PointFillDetails) File(java.io.File) Test(org.junit.Test)

Example 8 with ExternalGraphicImpl

use of org.geotools.styling.ExternalGraphicImpl in project sldeditor by robward-scisys.

the class FieldConfigTTFTest method testAccept.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.symboltype.ttf.FieldConfigTTF#accept(org.opengis.style.GraphicalSymbol)}.
 */
@Test
public void testAccept() {
    boolean valueOnly = true;
    FieldConfigTTF field = new FieldConfigTTF(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), null, null, null);
    assertFalse(field.accept(null));
    StyleBuilder styleBuilder = new StyleBuilder();
    ExternalGraphicImpl externalGraphic = (ExternalGraphicImpl) styleBuilder.createExternalGraphic("test.tmp", "png");
    assertFalse(field.accept(externalGraphic));
    Mark marker1 = styleBuilder.createMark("triangle");
    assertFalse(field.accept(marker1));
    Mark marker2 = styleBuilder.createMark("ttf://Arial");
    assertTrue(field.accept(marker2));
}
Also used : ExternalGraphicImpl(org.geotools.styling.ExternalGraphicImpl) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) StyleBuilder(org.geotools.styling.StyleBuilder) FieldConfigTTF(com.sldeditor.ui.detail.config.symboltype.ttf.FieldConfigTTF) Mark(org.geotools.styling.Mark) Test(org.junit.Test)

Example 9 with ExternalGraphicImpl

use of org.geotools.styling.ExternalGraphicImpl in project sldeditor by robward-scisys.

the class FieldConfigWindBarbsTest method testSetValue.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.vendor.geoserver.marker.windbarb.FieldConfigWindBarbs#setValue(com.sldeditor.ui.detail.GraphicPanelFieldManager, com.sldeditor.ui.detail.config.FieldConfigSymbolType, org.opengis.style.GraphicalSymbol)}.
 */
@Test
public void testSetValue() {
    boolean valueOnly = true;
    GraphicPanelFieldManager fieldConfigManager = null;
    FieldConfigWindBarbs field = new FieldConfigWindBarbs(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), null, null, null);
    field.setValue(null, null, null, null, null);
    field.setValue(null, fieldConfigManager, null, null, null);
    field.createUI();
    StyleBuilder styleBuilder = new StyleBuilder();
    Mark marker = styleBuilder.createMark("star");
    field.setValue(null, null, null, null, marker);
    field.setValue(null, fieldConfigManager, null, null, marker);
    File f = null;
    String filename = null;
    try {
        f = File.createTempFile(getClass().getSimpleName(), ".png");
    } catch (IOException e) {
        e.printStackTrace();
    }
    try {
        if ((f != null) && (f.toURI() != null)) {
            if (f.toURI().toURL() != null) {
                filename = f.toURI().toURL().toString();
            }
        }
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
    ExternalGraphicImpl externalGraphic = (ExternalGraphicImpl) styleBuilder.createExternalGraphic(filename, "png");
    field.setValue(null, fieldConfigManager, null, null, externalGraphic);
    if (f != null) {
        f.delete();
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) ExternalGraphicImpl(org.geotools.styling.ExternalGraphicImpl) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) StyleBuilder(org.geotools.styling.StyleBuilder) Mark(org.geotools.styling.Mark) FieldConfigWindBarbs(com.sldeditor.ui.detail.vendor.geoserver.marker.windbarb.FieldConfigWindBarbs) IOException(java.io.IOException) File(java.io.File) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) Test(org.junit.Test)

Example 10 with ExternalGraphicImpl

use of org.geotools.styling.ExternalGraphicImpl in project sldeditor by robward-scisys.

the class FieldConfigWKTTest method testAccept.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.FieldConfigWKT#accept(org.opengis.style.GraphicalSymbol)}.
 */
@Test
public void testAccept() {
    boolean valueOnly = true;
    FieldConfigWKT field = new FieldConfigWKT(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), null, null, null);
    assertFalse(field.accept(null));
    StyleBuilder styleBuilder = new StyleBuilder();
    ExternalGraphicImpl externalGraphic = (ExternalGraphicImpl) styleBuilder.createExternalGraphic("test.tmp", "png");
    assertFalse(field.accept(externalGraphic));
    Mark marker1 = styleBuilder.createMark("star");
    assertFalse(field.accept(marker1));
    // CHECKSTYLE:OFF
    Mark marker2 = styleBuilder.createMark("wkt://MULTILINESTRING((-0.25 -0.25, -0.125 -0.25), (0.125 -0.25, 0.25 -0.25), (-0.25 0.25, -0.125 0.25), (0.125 0.25, 0.25 0.25))");
    // CHECKSTYLE:ON
    assertTrue(field.accept(marker2));
}
Also used : ExternalGraphicImpl(org.geotools.styling.ExternalGraphicImpl) FieldConfigWKT(com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.FieldConfigWKT) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) StyleBuilder(org.geotools.styling.StyleBuilder) Mark(org.geotools.styling.Mark) Test(org.junit.Test)

Aggregations

ExternalGraphicImpl (org.geotools.styling.ExternalGraphicImpl)13 Mark (org.geotools.styling.Mark)10 Test (org.junit.Test)10 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)9 StyleBuilder (org.geotools.styling.StyleBuilder)9 File (java.io.File)6 MalformedURLException (java.net.MalformedURLException)6 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)4 IOException (java.io.IOException)4 PointFillDetails (com.sldeditor.ui.detail.PointFillDetails)3 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)3 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)2 FieldConfigColour (com.sldeditor.ui.detail.config.FieldConfigColour)2 FieldConfigSlider (com.sldeditor.ui.detail.config.FieldConfigSlider)2 FieldConfigSymbolType (com.sldeditor.ui.detail.config.FieldConfigSymbolType)2 FieldConfigFilename (com.sldeditor.ui.detail.config.symboltype.externalgraphic.FieldConfigFilename)2 FieldConfigWindBarbs (com.sldeditor.ui.detail.vendor.geoserver.marker.windbarb.FieldConfigWindBarbs)2 FieldConfigWKT (com.sldeditor.ui.detail.vendor.geoserver.marker.wkt.FieldConfigWKT)2 URL (java.net.URL)2 GraphicalSymbol (org.opengis.style.GraphicalSymbol)2