use of com.sldeditor.common.SLDDataInterface in project sldeditor by robward-scisys.
the class VectorTool method importFeatureClass.
/**
* Import feature class.
*
* @param featureClassNode the feature class node
* @return true, if successful
*/
protected boolean importFeatureClass(DatabaseFeatureClassNode featureClassNode) {
if (featureClassNode != null) {
DatabaseClientInterface dbClient = DatabaseConnectionManager.getInstance().getConnectionMap().get(featureClassNode.getConnectionData());
if (dbClient != null) {
ConsoleManager.getInstance().information(this, String.format("%s : %s", Localisation.getString(VectorTool.class, "VectorTool.createSymbol"), featureClassNode.toString()));
SLDDataInterface sldData = vectorReader.createVectorSLDData(featureClassNode.getConnectionData(), featureClassNode.toString());
DataSourcePropertiesInterface dsProperties = SLDEditorFile.getInstance().getDataSource();
DataSourceConnectorInterface dsc = DataSourceConnectorFactory.getDataSource(dbClient.getClass());
dsProperties = dsc.getDataSourceProperties(dbClient.getDBConnectionParams());
dsProperties.setFilename(featureClassNode.toString());
loadSymbol(dsProperties, sldData, featureClassNode.toString(), featureClassNode.getConnectionData().getConnectionName());
}
}
return false;
}
use of com.sldeditor.common.SLDDataInterface in project sldeditor by robward-scisys.
the class VectorTool method importFile.
/**
* Import file.
*
* @param fileTreeNode the file tree node
*/
protected boolean importFile(FileTreeNode fileTreeNode) {
if (fileTreeNode != null) {
File vectorFile = fileTreeNode.getFile();
ConsoleManager.getInstance().information(this, String.format("%s : %s", Localisation.getString(VectorTool.class, "VectorTool.createSymbol"), vectorFile.getAbsolutePath()));
SLDDataInterface sldData = vectorReader.createVectorSLDData(vectorFile);
DataSourcePropertiesInterface dsProperties = SLDEditorFile.getInstance().getDataSource();
DataSourceConnectorInterface dsc = DataSourceConnectorFactory.getDataSource(DataSourceConnector.class);
try {
String vectorFilename = vectorFile.toURI().toURL().toString();
dsProperties = dsc.getDataSourceProperties(DataSourceProperties.encodeFilename(vectorFilename));
} catch (MalformedURLException exceptionObj) {
ConsoleManager.getInstance().exception(VectorTool.class, exceptionObj);
return false;
}
loadSymbol(dsProperties, sldData, vectorFile);
}
return true;
}
use of com.sldeditor.common.SLDDataInterface in project sldeditor by robward-scisys.
the class YSLDTool method setSelectedItems.
/*
* (non-Javadoc)
*
* @see com.sldeditor.tool.ToolInterface#setSelectedItems(java.util.List, java.util.List)
*/
@Override
public void setSelectedItems(List<NodeInterface> nodeTypeList, List<SLDDataInterface> sldDataList) {
this.sldDataList = sldDataList;
if (exportToYSLDButton != null) {
int sldFilesCount = 0;
int ysldFilesCount = 0;
if (sldDataList != null) {
for (SLDDataInterface sldData : sldDataList) {
String fileExtension = ExternalFilenames.getFileExtension(sldData.getSLDFile().getAbsolutePath());
if (fileExtension.compareTo(SLDEditorFile.getSLDFileExtension()) == 0) {
sldFilesCount++;
} else if (fileExtension.compareTo(YSLDTool.YSLD_FILE_EXTENSION) == 0) {
ysldFilesCount++;
}
}
}
exportToYSLDButton.setEnabled(sldFilesCount > 0);
exportToSLDButton.setEnabled(ysldFilesCount > 0);
}
}
use of com.sldeditor.common.SLDDataInterface in project sldeditor by robward-scisys.
the class YSLDTool method exportToSLD.
/**
* Export to SLD.
*/
private void exportToSLD() {
SLDWriterInterface sldWriter = SLDWriterFactory.createWriter(SLDOutputFormatEnum.SLD);
for (SLDDataInterface sldData : sldDataList) {
StyledLayerDescriptor sld = SLDUtils.createSLDFromString(sldData);
String layerName = sldData.getLayerNameWithOutSuffix();
if (sld != null) {
String sldString = sldWriter.encodeSLD(sldData.getResourceLocator(), sld);
String destinationFolder = sldData.getSLDFile().getParent();
File fileToSave = GenerateFilename.findUniqueName(destinationFolder, layerName, SLDEditorFile.getSLDFileExtension());
String sldFilename = fileToSave.getName();
if (fileToSave.exists()) {
ConsoleManager.getInstance().error(this, Localisation.getField(YSLDTool.class, "YSLDTool.destinationAlreadyExists") + " " + sldFilename);
} else {
ConsoleManager.getInstance().information(this, Localisation.getField(YSLDTool.class, "YSLDTool.exportToSLDMsg") + " " + sldFilename);
BufferedWriter out;
try {
out = new BufferedWriter(new FileWriter(fileToSave));
out.write(sldString);
out.close();
} catch (IOException e) {
ConsoleManager.getInstance().exception(this, e);
}
}
}
}
}
use of com.sldeditor.common.SLDDataInterface in project sldeditor by robward-scisys.
the class BatchUpdateFontData method updateFont.
/**
* Update font.
*
* @param sldWriter the sld writer
* @return true, if successful
*/
public boolean updateFont(SLDWriterInterface sldWriter) {
boolean refreshUI = false;
if ((rule != null) && (sldWriter != null)) {
List<Font> fontList = symbolizer.fonts();
Font font = fontList.get(0);
if (isFontNameUpdated()) {
font.getFamily().clear();
font.getFamily().addAll(this.font.getFamily());
}
if (isFontStyleUpdated()) {
font.setStyle(ff.literal(this.font.getStyle()));
}
if (isFontWeightUpdated()) {
font.setWeight(ff.literal(this.font.getWeight()));
}
if (isFontSizeUpdated()) {
font.setSize(ff.literal(this.font.getSize()));
}
String sldContents = sldWriter.encodeSLD(null, this.sld);
SLDDataInterface current = SLDEditorFile.getInstance().getSLDData();
if ((current != null) && (sldData != null)) {
if (((current.getSLDFile() == null) && (sldData.getSLDFile() == null)) || ((current.getSLDFile() != null) && current.getSLDFile().equals(sldData.getSLDFile())) || ((current.getSLDURL() != null) && current.getSLDURL().equals(sldData.getSLDURL()))) {
Symbolizer currentSymbolizer = SLDUtils.findSymbolizer(sld, symbolizer, SelectedSymbol.getInstance().getSld());
if (currentSymbolizer != null) {
if (currentSymbolizer instanceof TextSymbolizer) {
TextSymbolizer textSymbolizer = (TextSymbolizer) currentSymbolizer;
textSymbolizer.fonts().clear();
textSymbolizer.fonts().add(font);
refreshUI = true;
}
}
}
}
sldData.updateSLDContents(sldContents);
setOriginalData(font);
}
return refreshUI;
}
Aggregations