use of com.sldeditor.common.SLDDataInterface in project sldeditor by robward-scisys.
the class VectorTool method loadSymbol.
/**
* Load symbol.
*
* @param dsProperties the ds properties
* @param sldData the sld data
* @param vectorFilename the vector filename
* @param folder the folder
*/
private void loadSymbol(DataSourcePropertiesInterface dsProperties, SLDDataInterface sldData, String vectorFilename, String folder) {
// Vector file
SLDEditorFile.getInstance().setSLDData(sldData);
SLDEditorFile.getInstance().setDataSource(dsProperties);
// Clear the data change flag
SLDEditorFile.getInstance().fileOpenedSaved();
// Load sld
List<SLDDataInterface> sldFilesToLoad = new ArrayList<SLDDataInterface>();
sldFilesToLoad.add(sldData);
SelectedFiles selectedFiles = new SelectedFiles();
selectedFiles.setSldData(sldFilesToLoad);
selectedFiles.setFolderName(folder);
LoadSLDInterface loadSLD = sldEditorInterface.getLoadSLDInterface();
loadSLD.loadSLDString(selectedFiles);
}
use of com.sldeditor.common.SLDDataInterface in project sldeditor by robward-scisys.
the class YSLDTool method exportToYSLD.
/**
* Export to YSLD.
*/
private void exportToYSLD() {
SLDWriterInterface ysldWriter = SLDWriterFactory.createWriter(SLDOutputFormatEnum.YSLD);
for (SLDDataInterface sldData : sldDataList) {
StyledLayerDescriptor sld = SLDUtils.createSLDFromString(sldData);
String layerName = sldData.getLayerNameWithOutSuffix();
if (sld != null) {
String sldString = ysldWriter.encodeSLD(sldData.getResourceLocator(), sld);
String destinationFolder = sldData.getSLDFile().getParent();
File fileToSave = GenerateFilename.findUniqueName(destinationFolder, layerName, YSLDTool.YSLD_FILE_EXTENSION);
String ysldFilename = fileToSave.getName();
if (fileToSave.exists()) {
ConsoleManager.getInstance().error(this, Localisation.getField(YSLDTool.class, "YSLDTool.destinationAlreadyExists") + " " + ysldFilename);
} else {
ConsoleManager.getInstance().information(this, Localisation.getField(YSLDTool.class, "YSLDTool.exportToYSLDMsg") + " " + ysldFilename);
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 MapBoxTool 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(MapBoxTool.class, "MapBoxTool.destinationAlreadyExists") + " " + sldFilename);
} else {
ConsoleManager.getInstance().information(this, Localisation.getField(MapBoxTool.class, "MapBoxTool.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 BatchUpdateFontPanel method populate.
/**
* Populate the dialog.
*
* @param sldDataList the sld data list
*/
public void populate(List<SLDDataInterface> sldDataList) {
List<BatchUpdateFontData> fontDataList = new ArrayList<BatchUpdateFontData>();
for (SLDDataInterface sldData : sldDataList) {
List<BatchUpdateFontData> fontSLDDataList = BatchUpdateFontUtils.containsFonts(sldData);
if ((fontSLDDataList != null) && !fontSLDDataList.isEmpty()) {
fontDataList.addAll(fontSLDDataList);
}
}
dataModel.loadData(fontDataList);
}
use of com.sldeditor.common.SLDDataInterface in project sldeditor by robward-scisys.
the class DatabaseInputTest method testDatabaseInput.
/**
* Test method for {@link com.sldeditor.extension.filesystem.database.DatabaseInput#DatabaseInput(com.sldeditor.common.ToolSelectionInterface)}.
*/
@Test
public void testDatabaseInput() {
DatabaseInput input = new DatabaseInput(ToolManager.getInstance());
input.readPropertyFile();
FSTree tree = new FSTree();
DefaultMutableTreeNode rootNode;
try {
rootNode = new DefaultMutableTreeNode("Root");
DefaultTreeModel model = new DefaultTreeModel(rootNode);
input.populate(tree, model, rootNode);
List<SLDDataInterface> sldDataList = input.open(null);
assertNull(sldDataList);
DatabaseConnection connection1 = DatabaseConnectionFactory.createGeoPackage();
String featureClassName = "test feature class";
DatabaseFeatureClassNode fcTreeNode = new DatabaseFeatureClassNode(input, connection1, featureClassName);
Map<String, String> connectionDataMap = new HashMap<String, String>();
connectionDataMap.put(GeoPkgDataStoreFactory.DATABASE.key, "test.gpkg");
connection1.setConnectionDataMap(connectionDataMap);
// Try with no known database connections
SelectedFiles actualSLDContents = input.getSLDContents(fcTreeNode);
assertNotNull(actualSLDContents);
assertTrue(actualSLDContents.isDataSource());
// Add some database connections
input.addNewConnection(connection1);
DatabaseConnection connection2 = DatabaseConnectionFactory.createGeoPackage();
Map<String, String> connectionDataMap2 = new HashMap<String, String>();
connectionDataMap2.put(GeoPkgDataStoreFactory.DATABASE.key, "test2.gpkg");
connection2.setConnectionDataMap(connectionDataMap2);
input.addNewConnection(connection2);
input.addNewConnection(null);
List<SLDDataInterface> sldDataContentsList = input.getSLDContents(fcTreeNode).getSldData();
assertEquals(0, sldDataContentsList.size());
// Try saving a null object
assertFalse(input.save(null));
// Check how many connections we have
assertEquals(2, input.getConnectionDetails().size());
} catch (SecurityException e) {
e.printStackTrace();
fail(e.getMessage());
}
}
Aggregations