Search in sources :

Example 1 with LoadSLDInterface

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));
}
Also used : DataSourceConnector(com.sldeditor.datasource.connector.instance.DataSourceConnector) JPanel(javax.swing.JPanel) MalformedURLException(java.net.MalformedURLException) FlowLayout(java.awt.FlowLayout) LoadSLDInterface(com.sldeditor.common.LoadSLDInterface) ToolButton(com.sldeditor.tool.ToolButton) ActionEvent(java.awt.event.ActionEvent) Dimension(java.awt.Dimension) DataSourcePropertiesInterface(com.sldeditor.common.DataSourcePropertiesInterface) FileTreeNode(com.sldeditor.datasource.extension.filesystem.node.file.FileTreeNode) DataSourceInterface(com.sldeditor.datasource.DataSourceInterface) ActionListener(java.awt.event.ActionListener) SLDDataInterface(com.sldeditor.common.SLDDataInterface) SelectedFiles(com.sldeditor.common.filesystem.SelectedFiles) DataSourceConnectorInterface(com.sldeditor.common.DataSourceConnectorInterface) ArrayList(java.util.ArrayList) List(java.util.List) SLDEditorFile(com.sldeditor.datasource.SLDEditorFile) File(java.io.File)

Example 2 with LoadSLDInterface

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);
}
Also used : LoadSLDInterface(com.sldeditor.common.LoadSLDInterface) SLDDataInterface(com.sldeditor.common.SLDDataInterface) SelectedFiles(com.sldeditor.common.filesystem.SelectedFiles) ArrayList(java.util.ArrayList)

Aggregations

LoadSLDInterface (com.sldeditor.common.LoadSLDInterface)2 SLDDataInterface (com.sldeditor.common.SLDDataInterface)2 SelectedFiles (com.sldeditor.common.filesystem.SelectedFiles)2 ArrayList (java.util.ArrayList)2 DataSourceConnectorInterface (com.sldeditor.common.DataSourceConnectorInterface)1 DataSourcePropertiesInterface (com.sldeditor.common.DataSourcePropertiesInterface)1 DataSourceInterface (com.sldeditor.datasource.DataSourceInterface)1 SLDEditorFile (com.sldeditor.datasource.SLDEditorFile)1 DataSourceConnector (com.sldeditor.datasource.connector.instance.DataSourceConnector)1 FileTreeNode (com.sldeditor.datasource.extension.filesystem.node.file.FileTreeNode)1 ToolButton (com.sldeditor.tool.ToolButton)1 Dimension (java.awt.Dimension)1 FlowLayout (java.awt.FlowLayout)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 File (java.io.File)1 MalformedURLException (java.net.MalformedURLException)1 List (java.util.List)1 JPanel (javax.swing.JPanel)1