use of com.sldeditor.common.LoadSLDInterface in project sldeditor by robward-scisys.
the class RasterTool method createUI.
/**
* Creates the ui.
*/
private void createUI() {
rasterPanel = new JPanel();
FlowLayout flowLayout = (FlowLayout) rasterPanel.getLayout();
flowLayout.setVgap(0);
flowLayout.setHgap(0);
rasterPanel.setBorder(BorderFactory.createTitledBorder(Localisation.getString(RasterTool.class, "RasterTool.title")));
//
// Import raster
//
importRasterButton = new ToolButton(Localisation.getString(RasterTool.class, "RasterTool.import"), "tool/importraster.png");
rasterPanel.add(importRasterButton);
importRasterButton.setEnabled(false);
importRasterButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if ((nodeTypeList != null) && (nodeTypeList.size() == 1)) {
if (sldEditorInterface != null) {
FileTreeNode fileTreeNode = (FileTreeNode) nodeTypeList.get(0);
File rasterFile = fileTreeNode.getFile();
ConsoleManager.getInstance().information(this, String.format("%s : %s", Localisation.getString(RasterTool.class, "RasterTool.createSymbol"), rasterFile.getAbsolutePath()));
SLDDataInterface sldData = rasterReader.createRasterSLDData(rasterFile);
// Raster file
DataSourcePropertiesInterface dsProperties = SLDEditorFile.getInstance().getDataSource();
DataSourceConnectorInterface dsc = DataSourceConnectorFactory.getDataSource(DataSourceConnector.class);
dsProperties = dsc.getDataSourceProperties(DataSourceProperties.encodeFilename(rasterFile.getAbsolutePath()));
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(rasterFile.getParent());
LoadSLDInterface loadSLD = sldEditorInterface.getLoadSLDInterface();
loadSLD.loadSLDString(selectedFiles);
}
}
}
});
//
// Set data source
//
dataSourceButton = new ToolButton(Localisation.getString(RasterTool.class, "RasterTool.dataSource"), "tool/setdatasource.png");
rasterPanel.add(dataSourceButton);
dataSourceButton.setEnabled(false);
dataSourceButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if ((nodeTypeList != null) && (nodeTypeList.size() == 1)) {
if (sldEditorInterface != null) {
FileTreeNode fileTreeNode = (FileTreeNode) nodeTypeList.get(0);
File rasterFile = fileTreeNode.getFile();
ConsoleManager.getInstance().information(this, String.format("%s : %s", Localisation.getString(RasterTool.class, "RasterTool.setDataSource"), rasterFile.getAbsolutePath()));
// Raster file
DataSourceConnectorInterface dsc = DataSourceConnectorFactory.getDataSource(DataSourceConnector.class);
String rasterFilename = null;
try {
rasterFilename = rasterFile.toURI().toURL().toString();
} catch (MalformedURLException exceptionObj) {
ConsoleManager.getInstance().exception(RasterTool.class, exceptionObj);
return;
}
DataSourcePropertiesInterface dsProperties = dsc.getDataSourceProperties(DataSourceProperties.encodeFilename(rasterFilename));
SLDEditorFile.getInstance().setDataSource(dsProperties);
DataSourceInterface dataSource = DataSourceFactory.createDataSource(null);
if (dataSource != null) {
dataSource.connect(rasterFilename, SLDEditorFile.getInstance(), null);
}
}
}
}
});
rasterPanel.setPreferredSize(new Dimension(PANEL_WIDTH, ToolPanel.TOOL_PANEL_HEIGHT));
}
use of com.sldeditor.common.LoadSLDInterface 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);
}
Aggregations