use of com.sldeditor.ui.widgets.ValueComboBoxData in project sldeditor by robward-scisys.
the class CoordManagerTest method testGetInstance.
/**
* Test method for {@link com.sldeditor.common.coordinate.CoordManager#getInstance()}.
* Test method for {@link com.sldeditor.common.coordinate.CoordManager#getCRSList()}.
* Test method for {@link com.sldeditor.common.coordinate.CoordManager#getCRSCode(org.opengis.referencing.crs.CoordinateReferenceSystem)}.
* Test method for {@link com.sldeditor.common.coordinate.CoordManager#getWGS84()}.
*
* @throws NoSuchAuthorityCodeException the no such authority code exception
* @throws FactoryException the factory exception
*/
@Test
public void testGetInstance() throws NoSuchAuthorityCodeException, FactoryException {
CoordManager.getInstance().populateCRSList();
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
List<ValueComboBoxData> crsList = CoordManager.getInstance().getCRSList();
assertTrue(crsList.size() > 0);
CoordinateReferenceSystem crs = CoordManager.getInstance().getCRS(null);
assertNull(crs);
crs = CoordManager.getInstance().getWGS84();
assertTrue(crs != null);
String code = CoordManager.getInstance().getCRSCode(null);
assertTrue(code.compareTo("") == 0);
code = CoordManager.getInstance().getCRSCode(crs);
assertTrue(code.compareTo("EPSG:4326") == 0);
String projectedCRSCode = "EPSG:27700";
CoordinateReferenceSystem projectedCRS = CRS.decode(projectedCRSCode);
code = CoordManager.getInstance().getCRSCode(projectedCRS);
assertTrue(code.compareTo(projectedCRSCode) == 0);
}
use of com.sldeditor.ui.widgets.ValueComboBoxData in project sldeditor by robward-scisys.
the class ColourRampPanel method createTopPanel.
/**
* Creates the top panel.
*/
private void createTopPanel() {
final UndoActionInterface undoObj = this;
JPanel topPanel = new JPanel();
topPanel.setPreferredSize(new Dimension(BasePanel.FIELD_PANEL_WIDTH, BasePanel.WIDGET_HEIGHT));
topPanel.setLayout(null);
panel.add(topPanel, BorderLayout.NORTH);
List<ValueComboBoxData> dataList = populateColourRamps(false);
rampComboBox = new ValueComboBox();
rampComboBox.initialiseSingle(dataList);
rampComboBox.setBounds(BasePanel.WIDGET_X_START, 0, BasePanel.WIDGET_EXTENDED_WIDTH, BasePanel.WIDGET_HEIGHT);
topPanel.add(rampComboBox);
rampComboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (!isPopulating()) {
Integer newValueObj = rampComboBox.getSelectedIndex();
UndoManager.getInstance().addUndoEvent(new UndoEvent(undoObj, FieldIdEnum.COLOUR_RAMP_COLOUR, oldColourRampIndex, newValueObj));
oldColourRampIndex = newValueObj;
}
}
});
reverseCheckbox = new JCheckBox(Localisation.getString(ColourRampConfigPanel.class, "ColourRampPanel.reverse"));
reverseCheckbox.setBounds(rampComboBox.getX() + rampComboBox.getWidth() + 20, 0, BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT);
reverseCheckbox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
boolean isSelected = reverseCheckbox.isSelected();
Boolean oldValueObj = Boolean.valueOf(!isSelected);
Boolean newValueObj = Boolean.valueOf(isSelected);
UndoManager.getInstance().addUndoEvent(new UndoEvent(undoObj, FieldIdEnum.COLOUR_RAMP_REVERSE, oldValueObj, newValueObj));
reverseColourRamp(isSelected);
}
});
topPanel.add(reverseCheckbox);
}
use of com.sldeditor.ui.widgets.ValueComboBoxData in project sldeditor by robward-scisys.
the class CoordManager method getCRSCode.
/**
* Gets the CRS code.
*
* @param coordinateReferenceSystem the coordinate reference system
* @return the CRS code
*/
public String getCRSCode(CoordinateReferenceSystem coordinateReferenceSystem) {
ReferenceIdentifier identifier = null;
if (coordinateReferenceSystem != null) {
Set<ReferenceIdentifier> indentifierList = coordinateReferenceSystem.getIdentifiers();
if (indentifierList != null) {
if (indentifierList.iterator().hasNext()) {
identifier = indentifierList.iterator().next();
}
}
}
String code = NOT_SET_CRS;
if (identifier != null) {
ValueComboBoxData data = crsMap.get(identifier.toString());
if (data != null) {
code = data.getKey();
}
}
return code;
}
use of com.sldeditor.ui.widgets.ValueComboBoxData in project sldeditor by robward-scisys.
the class CoordManager method populateCRSList.
/**
* Populate crs list.
*/
public void populateCRSList() {
if (isPopulated()) {
Runnable runnable = () -> {
VendorOptionVersion vendorOptionVersion = VendorOptionManager.getInstance().getDefaultVendorOptionVersion();
ValueComboBoxData notSetValue = new ValueComboBoxData(NOT_SET_CRS, Localisation.getString(CoordManager.class, "common.notSet"), vendorOptionVersion);
crsDataList.add(notSetValue);
Hints hints = null;
for (AuthorityFactory factory : ReferencingFactoryFinder.getCRSAuthorityFactories(hints)) {
String authorityCode = NOT_SET_CRS;
Citation citation = factory.getAuthority();
if (citation != null) {
@SuppressWarnings("unchecked") Collection<Identifier> identifierList = (Collection<Identifier>) citation.getIdentifiers();
authorityCode = identifierList.iterator().next().getCode();
}
Set<String> codeList;
try {
codeList = factory.getAuthorityCodes(CoordinateReferenceSystem.class);
for (String code : codeList) {
String fullCode = String.format("%s:%s", authorityCode, code);
String descriptionText = factory.getDescriptionText(code).toString();
String text = String.format("%s - %s", fullCode, descriptionText);
ValueComboBoxData value = new ValueComboBoxData(fullCode, text, vendorOptionVersion);
crsDataList.add(value);
crsMap.put(fullCode, value);
}
} catch (NoSuchAuthorityCodeException e) {
// ConsoleManager.getInstance().exception(this, e);
} catch (FactoryException e) {
ConsoleManager.getInstance().exception(this, e);
}
}
};
Thread thread = new Thread(runnable);
thread.start();
}
}
use of com.sldeditor.ui.widgets.ValueComboBoxData in project sldeditor by robward-scisys.
the class StrokeDetails method getStroke.
/**
* Gets the stroke.
*
* @return the stroke
*/
public Stroke getStroke() {
Expression join = fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_LINE_JOIN);
Expression lineCap = fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_LINE_CAP);
Expression offset = fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_OFFSET);
Expression strokeWidth = fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_WIDTH);
ValueComboBoxData symbolTypeValue = fieldConfigVisitor.getComboBox(FieldIdEnum.STROKE_STYLE);
Expression symbolType = null;
if (symbolTypeValue != null) {
symbolType = getFilterFactory().literal(symbolTypeValue.getKey());
}
List<Float> dashList = createDashArray(fieldConfigVisitor.getText(FieldIdEnum.STROKE_DASH_ARRAY));
float[] dashes = convertDashListToArray(dashList);
FieldConfigBase fdmFillColour = fieldConfigManager.get(FieldIdEnum.STROKE_FILL_COLOUR);
FieldConfigColour colourField = (FieldConfigColour) fdmFillColour;
Expression fillColour = colourField.getColourExpression();
Expression opacity = fieldConfigVisitor.getExpression(FieldIdEnum.OVERALL_OPACITY);
boolean isLine = true;
if (symbolTypeValue != null) {
isLine = (symbolTypeValue.getKey().compareTo(SOLID_LINE_KEY) == 0);
}
boolean fillColourEnabled = isPanelEnabled(GroupIdEnum.FILLCOLOUR);
boolean strokeColourEnabled = isPanelEnabled(GroupIdEnum.STROKECOLOUR);
Stroke stroke = null;
if (isLine) {
opacity = fieldConfigVisitor.getExpression(FieldIdEnum.LINE_FILL_OPACITY);
stroke = getStyleFactory().stroke(fillColour, opacity, strokeWidth, join, lineCap, dashes, offset);
} else {
stroke = getStyleFactory().getDefaultStroke();
AnchorPoint anchorPoint = getStyleFactory().anchorPoint(fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_SYMBOL_ANCHOR_POINT_H), fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_SYMBOL_ANCHOR_POINT_V));
// default so it doesn't appear in the SLD
if (DetailsUtilities.isSame(defaultAnchorPoint, anchorPoint)) {
anchorPoint = null;
}
Displacement displacement = getStyleFactory().displacement(fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_SYMBOL_DISPLACEMENT_X), fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_SYMBOL_DISPLACEMENT_Y));
// so it doesn't appear in the SLD
if (DetailsUtilities.isSame(defaultDisplacement, displacement)) {
displacement = null;
}
List<GraphicalSymbol> symbols = symbolTypeFactory.getValue(this.fieldConfigManager, symbolType, fillColourEnabled, strokeColourEnabled, selectedFillPanelId);
Expression initalGap = fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_SYMBOL_INITIAL_GAP);
Expression gap = fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_SYMBOL_GAP);
Expression rotation = fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_SYMBOL_ANGLE);
Expression symbolSize = fieldConfigVisitor.getExpression(FieldIdEnum.STROKE_SYMBOL_SIZE);
GraphicStroke graphicStroke = getStyleFactory().graphicStroke(symbols, opacity, symbolSize, rotation, anchorPoint, displacement, initalGap, gap);
boolean overallOpacity = symbolTypeFactory.isOverallOpacity(PointSymbolizer.class, selectedFillPanelId);
if (overallOpacity) {
stroke.setOpacity(opacity);
}
stroke.setGraphicStroke(graphicStroke);
stroke.setWidth(strokeWidth);
}
return stroke;
}
Aggregations