use of com.sldeditor.ui.detail.config.symboltype.externalgraphic.FieldConfigFilename in project sldeditor by robward-scisys.
the class FieldConfigFilenameTest method testGetFill.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.symboltype.externalgraphic.FieldConfigFilename#getFill(org.opengis.style.GraphicFill, com.sldeditor.ui.detail.GraphicPanelFieldManager)}.
*/
@Test
public void testGetFill() {
boolean valueOnly = true;
FieldConfigFilename field = new FieldConfigFilename(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), null, null, null);
GraphicFill graphicFill = null;
GraphicPanelFieldManager fieldConfigManager = null;
assertNull(field.getFill(graphicFill, fieldConfigManager));
Class<?> panelId = PointFillDetails.class;
FieldIdEnum colourFieldId = FieldIdEnum.FILL_COLOUR;
FieldConfigColour colourField = new FieldConfigColour(new FieldConfigCommonData(panelId, colourFieldId, "", false));
colourField.createUI();
String expectedColourValue = "#012345";
colourField.setTestValue(FieldIdEnum.UNKNOWN, expectedColourValue);
double expectedOpacityValue = 0.72;
FieldConfigSlider opacityField = new FieldConfigSlider(new FieldConfigCommonData(panelId, colourFieldId, "", false));
opacityField.createUI();
opacityField.populateField(expectedOpacityValue);
FieldConfigBase symbolSelectionField = new FieldConfigSymbolType(new FieldConfigCommonData(panelId, colourFieldId, "", false));
symbolSelectionField.createUI();
fieldConfigManager = new GraphicPanelFieldManager(panelId);
fieldConfigManager.add(colourFieldId, colourField);
FieldIdEnum opacityFieldId = FieldIdEnum.OVERALL_OPACITY;
fieldConfigManager.add(opacityFieldId, opacityField);
FieldIdEnum symbolSelectionFieldId = FieldIdEnum.SYMBOL_TYPE;
fieldConfigManager.add(symbolSelectionFieldId, symbolSelectionField);
field.createUI();
StyleBuilder styleBuilder = new StyleBuilder();
graphicFill = styleBuilder.createGraphic();
Fill actualValue = field.getFill(graphicFill, fieldConfigManager);
assertTrue(actualValue.getOpacity().toString().compareTo(String.valueOf(expectedOpacityValue)) == 0);
}
use of com.sldeditor.ui.detail.config.symboltype.externalgraphic.FieldConfigFilename in project sldeditor by robward-scisys.
the class FieldConfigFilenameTest method testGetValue.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.symboltype.externalgraphic.FieldConfigFilename#getValue(com.sldeditor.ui.detail.GraphicPanelFieldManager, org.opengis.filter.expression.Expression, boolean, boolean)}.
*/
@Test
public void testGetValue() {
boolean valueOnly = true;
FieldConfigFilename field = new FieldConfigFilename(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), null, null, null);
assertNull(field.getValue(null, null, false, false));
field.createUI();
List<GraphicalSymbol> actualValue = field.getValue(null, null, false, false);
assertFalse(actualValue.isEmpty());
}
use of com.sldeditor.ui.detail.config.symboltype.externalgraphic.FieldConfigFilename in project sldeditor by robward-scisys.
the class FieldConfigFilenameTest method testSetVisible.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.symboltype.externalgraphic.FieldConfigFilename#setVisible(boolean)}.
*/
@Test
public void testSetVisible() {
boolean valueOnly = true;
FieldConfigFilename field = new FieldConfigFilename(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), null, null, null);
boolean expectedValue = true;
field.setVisible(expectedValue);
field.createUI();
expectedValue = false;
field.setVisible(expectedValue);
}
use of com.sldeditor.ui.detail.config.symboltype.externalgraphic.FieldConfigFilename 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();
}
}
use of com.sldeditor.ui.detail.config.symboltype.externalgraphic.FieldConfigFilename in project sldeditor by robward-scisys.
the class FieldConfigFilenameTest method testSetEnabled.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.symboltype.externalgraphic.FieldConfigFilename#internal_setEnabled(boolean)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.symboltype.externalgraphic.FieldConfigFilename#isEnabled()}.
*/
@Test
public void testSetEnabled() {
// Value only, no attribute/expression dropdown
boolean valueOnly = true;
FieldConfigFilename field = new FieldConfigFilename(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), null, null, null);
// Text field will not have been created
boolean expectedValue = true;
field.internal_setEnabled(expectedValue);
assertTrue(field.isEnabled());
// Create text field
field.createUI();
field.createUI();
assertTrue(field.isEnabled());
expectedValue = false;
field.internal_setEnabled(expectedValue);
assertTrue(field.isEnabled());
// Has attribute/expression dropdown
valueOnly = false;
FieldConfigFilename field2 = new FieldConfigFilename(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), null, null, null);
// Text field will not have been created
expectedValue = true;
field2.internal_setEnabled(expectedValue);
assertTrue(field2.isEnabled());
// Create text field
field2.createUI();
assertEquals(expectedValue, field2.isEnabled());
expectedValue = false;
field2.internal_setEnabled(expectedValue);
assertTrue(field2.isEnabled());
}
Aggregations