use of org.geotools.styling.Font in project sldeditor by robward-scisys.
the class FieldConfigFontPreviewTest method testGenerateExpression.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.font.FieldConfigFontPreview#generateExpression()}. Test
* method for
* {@link com.sldeditor.ui.detail.config.font.FieldConfigFontPreview#populateExpression(java.lang.Object, org.opengis.filter.expression.Expression)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.font.FieldConfigFontPreview#populateField(org.geotools.styling.Font)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.font.FieldConfigFontPreview#setTestValue(com.sldeditor.ui.detail.config.FieldId, java.lang.String)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.font.FieldConfigFontPreview#getStringValue()}.
*/
@Test
public void testGenerateExpression() {
boolean valueOnly = true;
FieldConfigFontPreview field = new FieldConfigFontPreview(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly));
field.setTestValue(FieldIdEnum.UNKNOWN, (String) null);
field.populateField((String) null);
field.populateField((Font) null);
field.populateExpression((Font) null);
String expectedValue = fontFamilies[0];
field.createUI();
field.populateField(expectedValue);
String actualValue = field.getStringValue();
assertNotNull(actualValue);
field.setTestValue(FieldIdEnum.UNKNOWN, expectedValue);
actualValue = field.getStringValue();
assertNotNull(actualValue);
StyleBuilder styleBuilder = new StyleBuilder();
Font f1 = styleBuilder.createFont(expectedValue, false, true, 24.0);
field.populateField(f1);
assertNotNull(field.getStringValue());
Font f2 = styleBuilder.createFont(expectedValue, true, true, 24.0);
field.populateField(f2);
assertNotNull(field.getStringValue());
Font f3 = styleBuilder.createFont(expectedValue, true, false, 24.0);
field.populateField(f3);
assertNotNull(field.getStringValue());
Font f4 = styleBuilder.createFont(expectedValue, false, false, 24.0);
field.populateField(f4);
assertNotNull(field.getStringValue());
}
use of org.geotools.styling.Font in project sldeditor by robward-scisys.
the class FieldConfigFontTest method testGenerateExpression.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.font.FieldConfigFont#generateExpression()}. Test method
* for
* {@link com.sldeditor.ui.detail.config.font.FieldConfigFont#populateField(org.geotools.styling.Font)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.font.FieldConfigFont#setTestValue(com.sldeditor.ui.detail.config.FieldId, java.lang.String)}.
* Test method for {@link com.sldeditor.ui.detail.config.font.FieldConfigFont#getFont()}. Test
* method for
* {@link com.sldeditor.ui.detail.config.font.FieldConfigFont#populateExpression(java.lang.Object, org.opengis.filter.expression.Expression)}.
* Test method for {@link com.sldeditor.ui.detail.config.font.FieldConfigFont#getStringValue()}.
*/
@Test
public void testGenerateExpression() {
boolean valueOnly = true;
FieldConfigFont field = new FieldConfigFont(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly));
field.setTestValue(FieldIdEnum.UNKNOWN, (String) null);
field.populateField((String) null);
field.populateField((Font) null);
field.populateExpression((Font) null);
String expectedValue = fontFamilies[0];
field.createUI();
field.populateField(expectedValue);
String actualValue = field.getStringValue();
assertTrue(expectedValue.compareTo(actualValue) == 0);
field.setTestValue(FieldIdEnum.UNKNOWN, expectedValue);
actualValue = field.getStringValue();
assertTrue(expectedValue.compareTo(actualValue) == 0);
StyleBuilder styleBuilder = new StyleBuilder();
Font f1 = styleBuilder.createFont(expectedValue, false, true, 24.0);
field.populateField(f1);
actualValue = field.getStringValue();
assertTrue(expectedValue.compareTo(actualValue) == 0);
}
use of org.geotools.styling.Font in project sldeditor by robward-scisys.
the class FontDetails method updateSymbol.
/**
* Update symbol.
*/
private void updateSymbol() {
//
// Font
//
Font font = extractFont();
// Any changes made to the font details need to be reflected
// back to the FieldConfigFontPreview field
fieldConfigVisitor.populateFontField(FieldIdEnum.FONT_PREVIEW, font);
}
use of org.geotools.styling.Font in project sldeditor by robward-scisys.
the class FontDetails method populate.
/**
* Populate.
*
* @param fontList the font list
*/
public void populate(List<Font> fontList) {
boolean emptyList = (fontList == null) || fontList.isEmpty();
boolean showMultipleCheckbox = (fontList != null) && (fontList.size() > 1);
MultipleFont multipleFont = new MultipleFont();
multipleFont.parseList(fontList);
Font font = multipleFont.getFont();
FieldConfigBase fieldConfig = fieldConfigManager.get(FieldIdEnum.FONT_FAMILY);
if (fieldConfig != null) {
if (emptyList) {
fieldConfig.showOptionField(false);
fieldConfig.setEnabled(false);
} else {
fieldConfig.setEnabled(true);
fieldConfigVisitor.populateFontField(FieldIdEnum.FONT_FAMILY, font);
fieldConfig.showOptionField(showMultipleCheckbox);
boolean isSelected = !font.getFamily().isEmpty();
fieldConfig.setOptionFieldValue(isSelected);
}
}
populateField(emptyList, showMultipleCheckbox, FieldIdEnum.FONT_WEIGHT, font.getWeight());
populateField(emptyList, showMultipleCheckbox, FieldIdEnum.FONT_STYLE, font.getStyle());
populateField(emptyList, showMultipleCheckbox, FieldIdEnum.FONT_SIZE, font.getSize());
fieldConfigVisitor.populateFontField(FieldIdEnum.FONT_PREVIEW, font);
}
use of org.geotools.styling.Font in project sldeditor by robward-scisys.
the class MultipleFont method parseList.
/**
* Parses the list.
*
* @param entries the entries
*/
public void parseList(List<Font> entries) {
familyMultipleValue = true;
styleMultipleValue = true;
weightMultipleValue = true;
sizeMultipleValue = true;
if ((entries == null) || entries.isEmpty()) {
firstEntry = null;
familyMultipleValue = false;
styleMultipleValue = false;
weightMultipleValue = false;
sizeMultipleValue = false;
} else {
firstEntry = entries.get(0);
String fontFamilyValue = firstEntry.getFamily().get(0).toString();
String styleValue = firstEntry.getStyle().toString();
String weightValue = firstEntry.getWeight().toString();
String sizeValue = firstEntry.getSize().toString();
for (Font entry : entries) {
if (fontFamilyValue.compareTo(entry.getFamily().get(0).toString()) != 0) {
familyMultipleValue = false;
}
if (styleValue.compareTo(entry.getStyle().toString()) != 0) {
styleMultipleValue = false;
}
if (weightValue.compareTo(entry.getWeight().toString()) != 0) {
weightMultipleValue = false;
}
if (sizeValue.compareTo(entry.getSize().toString()) != 0) {
sizeMultipleValue = false;
}
}
}
}
Aggregations