Revision 46299

View differences:

tags/org.gvsig.desktop-2.0.364/license.txt
1
gvSIG. Desktop Geographic Information System.
2

  
3
Copyright (C) 2007-2020 gvSIG Association.
4

  
5
This program is free software; you can redistribute it and/or
6
modify it under the terms of the GNU General Public License
7
as published by the Free Software Foundation; either version 3
8
of the License, or (at your option) any later version.
9

  
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
GNU General Public License for more details.
14

  
15
 You should have received a copy of the GNU General Public License 
16
along with this program. If not, see <https://www.gnu.org/licenses/>. 
17

  
18
For any additional information, do not hesitate to contact us
19
at info AT gvsig.com, or visit our website www.gvsig.com.
tags/org.gvsig.desktop-2.0.364/org.gvsig.desktop.library/org.gvsig.fmap.mapcontext.swing/org.gvsig.fmap.mapcontext.swing.api/pom.xml
1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2
    <modelVersion>4.0.0</modelVersion>
3
    <parent>
4
        <groupId>org.gvsig</groupId>
5
        <artifactId>org.gvsig.fmap.mapcontext.swing</artifactId>
6
        <version>2.0.364</version>
7
      </parent>
8
    <artifactId>org.gvsig.fmap.mapcontext.swing.api</artifactId>
9
    <name>${project.artifactId}</name>
10
    <dependencies>
11
        <dependency>
12
            <groupId>org.gvsig</groupId>
13
            <artifactId>org.gvsig.tools.swing.api</artifactId>
14
            <scope>compile</scope>
15
        </dependency>
16
        <dependency>
17
            <groupId>org.gvsig</groupId>
18
            <artifactId>org.gvsig.raster.lib.buffer.api</artifactId>
19
            <scope>compile</scope>
20
        </dependency>
21
        <dependency>
22
            <groupId>org.gvsig</groupId>
23
            <artifactId>org.gvsig.fmap.dal.api</artifactId>
24
            <scope>compile</scope>
25
        </dependency>
26
        <dependency>
27
            <groupId>org.gvsig</groupId>
28
            <artifactId>org.gvsig.fmap.mapcontext.api</artifactId>
29
            <scope>compile</scope>
30
        </dependency>
31
        <dependency>
32
            <groupId>org.gvsig</groupId>
33
            <artifactId>org.gvsig.raster.swing.buffer.api</artifactId>
34
            <scope>compile</scope>
35
        </dependency>
36
    </dependencies>
37
</project>
tags/org.gvsig.desktop-2.0.364/org.gvsig.desktop.library/org.gvsig.fmap.mapcontext.swing/org.gvsig.fmap.mapcontext.swing.api/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.fmap.mapcontext.raster.swing.MapContextRasterSwingLibrary
tags/org.gvsig.desktop-2.0.364/org.gvsig.desktop.library/org.gvsig.fmap.mapcontext.swing/org.gvsig.fmap.mapcontext.swing.api/src/main/java/org/gvsig/fmap/mapcontext/raster/swing/MapContextRasterSwingLocator.java
1
package org.gvsig.fmap.mapcontext.raster.swing;
2
/* gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright ? 2007-2017 gvSIG Association
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24

  
25

  
26
import org.gvsig.tools.locator.BaseLocator;
27

  
28
/**
29
 * This locator is the entry point for the raster buffer swing library,
30
 *
31
 * @author gvSIG team
32
 * @version $Id$
33
 */
34
public class MapContextRasterSwingLocator extends BaseLocator {
35

  
36
    /**
37
     * Chart swing manager name.
38
     */
39
    public static final String SWING_MANAGER_NAME =
40
        "Mapcontext.raster.swing.manager";
41

  
42
    /**
43
     * Chart swing manager description.
44
     */
45
    public static final String SWING_MANAGER_DESCRIPTION =
46
        "UIManager of MapContext Raster library";
47

  
48
    private static final String LOCATOR_NAME = "Mapcontext.raster.swing.locator";
49

  
50
    /**
51
     * Unique instance.
52
     */
53
    private static final MapContextRasterSwingLocator INSTANCE =
54
        new MapContextRasterSwingLocator();
55

  
56
    /**
57
     * Return the singleton instance.
58
     *
59
     * @return the singleton instance
60
     */
61
    public static MapContextRasterSwingLocator getInstance() {
62
        return INSTANCE;
63
    }
64

  
65
    /**
66
     * Return the Locator's name
67
     *
68
     * @return a String with the Locator's name
69
     */
70
    public final String getLocatorName() {
71
        return LOCATOR_NAME;
72
    }
73

  
74
    /**
75
     * Registers the Class implementing the PersistenceManager interface.
76
     *
77
     * @param clazz
78
     *            implementing the PersistenceManager interface
79
     */
80
    public static void registerSwingManager(
81
        Class<? extends MapContextRasterSwingManager> clazz) {
82
        getInstance().register(SWING_MANAGER_NAME, SWING_MANAGER_DESCRIPTION,
83
            clazz);
84
    }
85

  
86
    /**
87
     * Gets the instance of the {@link ScriptingUIManager} registered.
88
     *
89
     * @return {@link ScriptingUIManager}
90
     */
91
    public static MapContextRasterSwingManager getSwingManager() {
92
        return (MapContextRasterSwingManager) getInstance()
93
            .get(SWING_MANAGER_NAME);
94
    }
95

  
96
}
tags/org.gvsig.desktop-2.0.364/org.gvsig.desktop.library/org.gvsig.fmap.mapcontext.swing/org.gvsig.fmap.mapcontext.swing.api/src/main/java/org/gvsig/fmap/mapcontext/raster/swing/MapContextRasterSwingLibrary.java
1
package org.gvsig.fmap.mapcontext.raster.swing;
2

  
3
/* gvSIG. Desktop Geographic Information System.
4
 *
5
 * Copyright ? 2007-2017 gvSIG Association
6
 *
7
 * This program is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU General Public License
9
 * as published by the Free Software Foundation; either version 2
10
 * of the License, or (at your option) any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 * GNU General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU General Public License
18
 * along with this program; if not, write to the Free Software
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
 * MA  02110-1301, USA.
21
 *
22
 * For any additional information, do not hesitate to contact us
23
 * at info AT gvsig.com, or visit our website www.gvsig.com.
24
 */
25
import org.gvsig.tools.library.AbstractLibrary;
26
import org.gvsig.tools.library.LibraryException;
27
import org.gvsig.tools.locator.ReferenceNotRegisteredException;
28

  
29

  
30

  
31

  
32
/**
33
 * @author fdiaz
34
 *
35
 */
36
public class MapContextRasterSwingLibrary extends AbstractLibrary{
37

  
38
    @Override
39
    public void doRegistration() {
40
        registerAsAPI(MapContextRasterSwingLibrary.class);
41
//        this.require(RasterLibrary.class);
42
//        this.require(BufferLibrary.class);
43
    }
44

  
45
    @Override
46
    protected void doInitialize() throws LibraryException {
47
    }
48

  
49
    @Override
50
    protected void doPostInitialize() throws LibraryException {
51
        // Validate there is any implementation registered.
52
        MapContextRasterSwingManager manager =
53
            MapContextRasterSwingLocator.getSwingManager();
54
        if (manager == null) {
55
            throw new ReferenceNotRegisteredException(
56
                MapContextRasterSwingLocator.SWING_MANAGER_NAME,
57
                MapContextRasterSwingLocator.getInstance());
58
        }
59
    }
60

  
61

  
62
}
tags/org.gvsig.desktop-2.0.364/org.gvsig.desktop.library/org.gvsig.fmap.mapcontext.swing/org.gvsig.fmap.mapcontext.swing.api/src/main/java/org/gvsig/fmap/mapcontext/raster/swing/export/ExportRasterPanel.java
1
package org.gvsig.fmap.mapcontext.raster.swing.export;
2

  
3
import java.nio.Buffer;
4

  
5
import org.gvsig.tools.swing.api.Component;
6

  
7

  
8
public interface ExportRasterPanel extends Component {
9

  
10
//    /**
11
//     * @param layer
12
//     */
13
//    public boolean fetch(FLayer layer);
14

  
15
    /**
16
     * @param buffer
17
     */
18
    public void set(Buffer buffer);
19

  
20
}
tags/org.gvsig.desktop-2.0.364/org.gvsig.desktop.library/org.gvsig.fmap.mapcontext.swing/org.gvsig.fmap.mapcontext.swing.api/src/main/java/org/gvsig/fmap/mapcontext/raster/swing/SelectableBandDescriptorsTableModel.java
1
package org.gvsig.fmap.mapcontext.raster.swing;
2

  
3
import org.gvsig.raster.swing.buffer.SelectableBandsTableModel;
4

  
5

  
6
/**
7
 * @author fdiaz
8
 *
9
 */
10
public interface SelectableBandDescriptorsTableModel extends SelectableBandsTableModel {
11

  
12
}
tags/org.gvsig.desktop-2.0.364/org.gvsig.desktop.library/org.gvsig.fmap.mapcontext.swing/org.gvsig.fmap.mapcontext.swing.api/src/main/java/org/gvsig/fmap/mapcontext/raster/swing/operations/OperationListPanel.java
1
package org.gvsig.fmap.mapcontext.raster.swing.operations;
2

  
3
import java.awt.event.ActionListener;
4

  
5
import javax.swing.event.ListSelectionListener;
6
import javax.swing.event.TableModelListener;
7

  
8
import org.gvsig.raster.lib.buffer.api.operations.OperationFactory;
9
import org.gvsig.raster.lib.buffer.api.operations.OperationList;
10
import org.gvsig.raster.lib.buffer.api.operations.OperationListEntry;
11
import org.gvsig.tools.swing.api.Component;
12

  
13
/**
14
 * @author fdiaz
15
 *
16
 */
17
public interface OperationListPanel extends Component {
18

  
19
    public static String ADD_ACTION_COMMAND = "add_operation_entry";
20
    public static String UPDATE_ACTION_COMMAND = "update_operation_entry";
21
    public static String UP_ACTION_COMMAND = "up_operation_entry";
22
    public static String DOWN_ACTION_COMMAND = "down_operation_entry";
23
    public static String REMOVE_ACTION_COMMAND = "remove_operation_entry";
24

  
25
    /**
26
     * @param operationList
27
     * @return
28
     */
29
    public boolean fetch(OperationList operationList);
30

  
31
    /**
32
     * @param operationList
33
     */
34
    public void set(OperationList operationList);
35

  
36
    /**
37
     * @param layer
38
     * @return
39
     */
40
    public OperationListEntry getSelected();
41

  
42
    /**
43
     * @param listener
44
     */
45
    public void addListSelectionListener(ListSelectionListener listener);
46

  
47
    /**
48
     * @param listener
49
     */
50
    public void addTableModelListener(TableModelListener listener);
51

  
52
    /**
53
     * @param enable
54
     */
55
    public void enableAdd(boolean enable);
56

  
57
    /**
58
     * @param enable
59
     */
60
    public void enableUpdate(boolean enable);
61

  
62
    /**
63
     * @param operationListEntry
64
     */
65
    public void add(OperationListEntry operationListEntry);
66

  
67
    /**
68
     * @param listener
69
     */
70
    void addActionListener(ActionListener listener);
71

  
72
    /**
73
    *
74
    */
75
    public void clearSelection();
76

  
77
    /**
78
     * @param row
79
     */
80
    public void select(int row);
81

  
82
    /**
83
     * @return
84
     */
85
    public int getSelectedRow();
86

  
87
}
tags/org.gvsig.desktop-2.0.364/org.gvsig.desktop.library/org.gvsig.fmap.mapcontext.swing/org.gvsig.fmap.mapcontext.swing.api/src/main/java/org/gvsig/fmap/mapcontext/raster/swing/operations/OperationSelectorPanel.java
1
package org.gvsig.fmap.mapcontext.raster.swing.operations;
2

  
3
import javax.swing.event.ListSelectionListener;
4

  
5
import org.gvsig.raster.lib.buffer.api.operations.OperationFactory;
6
import org.gvsig.tools.swing.api.Component;
7

  
8

  
9

  
10
/**
11
 * @author fdiaz
12
 *
13
 */
14
public interface OperationSelectorPanel extends Component {
15

  
16
    /**
17
     * @param layer
18
     * @return
19
     */
20
    public OperationFactory getSelected();
21

  
22
    /**
23
     * @param layer
24
     * @return
25
     */
26
    public void clearSelection();
27

  
28
    /**
29
     * @param listener
30
     */
31
    public void addListSelectionListener(ListSelectionListener listener);
32

  
33
}
tags/org.gvsig.desktop-2.0.364/org.gvsig.desktop.library/org.gvsig.fmap.mapcontext.swing/org.gvsig.fmap.mapcontext.swing.api/src/main/java/org/gvsig/fmap/mapcontext/raster/swing/MapContextRasterSwingManager.java
1
package org.gvsig.fmap.mapcontext.raster.swing;
2
/* gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright ? 2007-2017 gvSIG Association
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24

  
25

  
26
import java.util.List;
27

  
28
import org.gvsig.fmap.dal.raster.BandDescriptor;
29
import org.gvsig.fmap.mapcontext.raster.swing.bands.BandsPanel;
30
import org.gvsig.fmap.mapcontext.raster.swing.export.ExportRasterPanel;
31
import org.gvsig.fmap.mapcontext.raster.swing.operations.OperationListPanel;
32
import org.gvsig.fmap.mapcontext.raster.swing.operations.OperationSelectorPanel;
33
import org.gvsig.fmap.mapcontext.raster.swing.previewer.OneLayerPreviewer;
34
import org.gvsig.fmap.mapcontext.raster.swing.transparency.TransparencyPanel;
35
import org.gvsig.tools.service.Manager;
36

  
37

  
38
/**
39
 *
40
 * @see MapContextRasterSwingManager
41
 * @author gvSIG team
42
 * @version $Id$
43
 */
44
public interface MapContextRasterSwingManager extends Manager{
45

  
46
    /**
47
     * @return
48
     */
49
    public SelectableBandDescriptorsTableModel createSelectableBandDescriptorsTableModel(List<BandDescriptor> descriptors) ;
50

  
51
    /**
52
     * @return
53
     */
54
    public TransparencyPanel createTransparencyPanel();
55

  
56
    /**
57
     * @return
58
     */
59
    public BandsPanel createBandsPanel();
60

  
61

  
62
    /**
63
     * @return
64
     */
65
    public ExportRasterPanel createExportRaster();
66

  
67
    /**
68
     * @return
69
     */
70
    public OneLayerPreviewer createOneLayerPreviewer();
71

  
72
    /**
73
     * @return
74
     */
75
    public OperationListPanel createOperationListPanel();
76

  
77
    /**
78
     * @return
79
     */
80
    OperationSelectorPanel createOperationSelectorPanel();
81

  
82
}
tags/org.gvsig.desktop-2.0.364/org.gvsig.desktop.library/org.gvsig.fmap.mapcontext.swing/org.gvsig.fmap.mapcontext.swing.api/src/main/java/org/gvsig/fmap/mapcontext/raster/swing/bands/BandsPanel.java
1
package org.gvsig.fmap.mapcontext.raster.swing.bands;
2

  
3
import org.gvsig.tools.dispose.Disposable;
4
import org.gvsig.tools.swing.api.Component;
5
import org.gvsig.fmap.mapcontext.layers.FLayer;
6

  
7

  
8

  
9
/**
10
 * @author fdiaz
11
 *
12
 */
13
public interface BandsPanel extends Component, Disposable {
14

  
15
    /**
16
     * @param layer
17
     * @return
18
     */
19
    public boolean fetch(FLayer layer);
20

  
21
    /**
22
     * @param layer
23
     */
24
    public void set(FLayer layer);
25

  
26
}
tags/org.gvsig.desktop-2.0.364/org.gvsig.desktop.library/org.gvsig.fmap.mapcontext.swing/org.gvsig.fmap.mapcontext.swing.api/src/main/java/org/gvsig/fmap/mapcontext/raster/swing/previewer/OneLayerPreviewer.java
1
package org.gvsig.fmap.mapcontext.raster.swing.previewer;
2

  
3
import org.cresques.cts.IProjection;
4

  
5
import org.gvsig.fmap.mapcontext.layers.FLayer;
6
import org.gvsig.tools.dispose.Disposable;
7
import org.gvsig.tools.swing.api.Component;
8

  
9

  
10
/**
11
 * @author fdiaz
12
 *
13
 */
14
public interface OneLayerPreviewer extends Component, Disposable {
15

  
16
    /**
17
     * @param projection
18
     */
19
    public void setProjection(IProjection projection);
20

  
21
    /**
22
     * @param layer
23
     */
24
    public void setLayer(FLayer layer);
25

  
26
    /**
27
     * @return
28
     */
29
    public FLayer getLayer();
30

  
31
}
tags/org.gvsig.desktop-2.0.364/org.gvsig.desktop.library/org.gvsig.fmap.mapcontext.swing/org.gvsig.fmap.mapcontext.swing.api/src/main/java/org/gvsig/fmap/mapcontext/raster/swing/transparency/TransparencyPanel.java
1
package org.gvsig.fmap.mapcontext.raster.swing.transparency;
2

  
3
import java.awt.Color;
4

  
5
import org.gvsig.fmap.mapcontext.layers.FLayer;
6
import org.gvsig.tools.swing.api.Component;
7

  
8

  
9

  
10
/**
11
 * @author fdiaz
12
 *
13
 */
14
public interface TransparencyPanel extends Component {
15

  
16
    /**
17
     * Fetch the layer with the panel's values.
18
     *
19
     * @param layer
20
     * @return
21
     */
22
    public boolean fetch(FLayer layer);
23

  
24
    /**
25
     * Sets the layer
26
     *
27
     * @param layer
28
     */
29
    public void set(FLayer layer);
30

  
31
    /**
32
     * Sets the color.
33
     * @param color
34
     */
35
    public void setColor(Color color);
36

  
37
}
0 38

  
tags/org.gvsig.desktop-2.0.364/org.gvsig.desktop.library/org.gvsig.fmap.mapcontext.swing/pom.xml
1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2
    <modelVersion>4.0.0</modelVersion>
3
    <parent>
4
        <groupId>org.gvsig</groupId>
5
        <artifactId>org.gvsig.desktop.library</artifactId>
6
        <version>2.0.364</version>
7
      </parent>
8
    <groupId>org.gvsig</groupId>
9
    <artifactId>org.gvsig.fmap.mapcontext.swing</artifactId>
10
    <packaging>pom</packaging>
11
    <name>${project.artifactId}</name>
12
    <modules>
13
        <module>org.gvsig.fmap.mapcontext.swing.api</module>
14
        <module>org.gvsig.fmap.mapcontext.swing.impl</module>
15
    </modules>
16
</project>
tags/org.gvsig.desktop-2.0.364/org.gvsig.desktop.library/org.gvsig.fmap.mapcontext.swing/org.gvsig.fmap.mapcontext.swing.impl/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.fmap.mapcontext.raster.swing.impl.DefaultMapContextRasterSwingLibrary
tags/org.gvsig.desktop-2.0.364/org.gvsig.desktop.library/org.gvsig.fmap.mapcontext.swing/org.gvsig.fmap.mapcontext.swing.impl/src/main/java/org/gvsig/fmap/mapcontext/raster/swing/impl/operations/OperationSelectorPanelView.java
1
package org.gvsig.fmap.mapcontext.raster.swing.impl.operations;
2

  
3
import java.awt.BorderLayout;
4
import java.awt.ComponentOrientation;
5
import java.awt.Container;
6
import java.awt.Dimension;
7

  
8
import javax.swing.Box;
9
import javax.swing.ImageIcon;
10
import javax.swing.JList;
11
import javax.swing.JPanel;
12
import javax.swing.JScrollPane;
13

  
14
import com.jgoodies.forms.layout.CellConstraints;
15
import com.jgoodies.forms.layout.FormLayout;
16

  
17

  
18
public class OperationSelectorPanelView extends JPanel
19
{
20
   JList lstOperations = new JList();
21

  
22
   /**
23
    * Default constructor
24
    */
25
   public OperationSelectorPanelView()
26
   {
27
      initializePanel();
28
   }
29

  
30
   /**
31
    * Adds fill components to empty cells in the first row and first column of the grid.
32
    * This ensures that the grid spacing will be the same as shown in the designer.
33
    * @param cols an array of column indices in the first row where fill components should be added.
34
    * @param rows an array of row indices in the first column where fill components should be added.
35
    */
36
   void addFillComponents( Container panel, int[] cols, int[] rows )
37
   {
38
      Dimension filler = new Dimension(10,10);
39

  
40
      boolean filled_cell_11 = false;
41
      CellConstraints cc = new CellConstraints();
42
      if ( cols.length > 0 && rows.length > 0 )
43
      {
44
         if ( cols[0] == 1 && rows[0] == 1 )
45
         {
46
            /** add a rigid area  */
47
            panel.add( Box.createRigidArea( filler ), cc.xy(1,1) );
48
            filled_cell_11 = true;
49
         }
50
      }
51

  
52
      for( int index = 0; index < cols.length; index++ )
53
      {
54
         if ( cols[index] == 1 && filled_cell_11 )
55
         {
56
            continue;
57
         }
58
         panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) );
59
      }
60

  
61
      for( int index = 0; index < rows.length; index++ )
62
      {
63
         if ( rows[index] == 1 && filled_cell_11 )
64
         {
65
            continue;
66
         }
67
         panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) );
68
      }
69

  
70
   }
71

  
72
   /**
73
    * Helper method to load an image file from the CLASSPATH
74
    * @param imageName the package and name of the file to load relative to the CLASSPATH
75
    * @return an ImageIcon instance with the specified image file
76
    * @throws IllegalArgumentException if the image resource cannot be loaded.
77
    */
78
   public ImageIcon loadImage( String imageName )
79
   {
80
      try
81
      {
82
         ClassLoader classloader = getClass().getClassLoader();
83
         java.net.URL url = classloader.getResource( imageName );
84
         if ( url != null )
85
         {
86
            ImageIcon icon = new ImageIcon( url );
87
            return icon;
88
         }
89
      }
90
      catch( Exception e )
91
      {
92
         e.printStackTrace();
93
      }
94
      throw new IllegalArgumentException( "Unable to load image: " + imageName );
95
   }
96

  
97
   /**
98
    * Method for recalculating the component orientation for
99
    * right-to-left Locales.
100
    * @param orientation the component orientation to be applied
101
    */
102
   public void applyComponentOrientation( ComponentOrientation orientation )
103
   {
104
      // Not yet implemented...
105
      // I18NUtils.applyComponentOrientation(this, orientation);
106
      super.applyComponentOrientation(orientation);
107
   }
108

  
109
   public JPanel createPanel()
110
   {
111
      JPanel jpanel1 = new JPanel();
112
      FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE","CENTER:2DLU:NONE,CENTER:DEFAULT:GROW(1.0),CENTER:2DLU:NONE");
113
      CellConstraints cc = new CellConstraints();
114
      jpanel1.setLayout(formlayout1);
115

  
116
      lstOperations.setName("lstOperations");
117
      lstOperations.setToolTipText("_operations_selector");
118
      JScrollPane jscrollpane1 = new JScrollPane();
119
      jscrollpane1.setViewportView(lstOperations);
120
      jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
121
      jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
122
      jpanel1.add(jscrollpane1,new CellConstraints(2,2,1,1,CellConstraints.FILL,CellConstraints.FILL));
123

  
124
      addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3 });
125
      return jpanel1;
126
   }
127

  
128
   /**
129
    * Initializer
130
    */
131
   protected void initializePanel()
132
   {
133
      setLayout(new BorderLayout());
134
      add(createPanel(), BorderLayout.CENTER);
135
   }
136

  
137

  
138
}
tags/org.gvsig.desktop-2.0.364/org.gvsig.desktop.library/org.gvsig.fmap.mapcontext.swing/org.gvsig.fmap.mapcontext.swing.impl/src/main/java/org/gvsig/fmap/mapcontext/raster/swing/impl/operations/OperationFactoryCellRenderer.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2017 gvSIG Association
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.fmap.mapcontext.raster.swing.impl.operations;
24

  
25
import java.awt.Component;
26

  
27
import javax.swing.DefaultListCellRenderer;
28
import javax.swing.JList;
29

  
30
import org.gvsig.raster.lib.buffer.api.operations.OperationFactory;
31

  
32

  
33
/**
34
 * @author fdiaz
35
 *
36
 */
37
public class OperationFactoryCellRenderer extends DefaultListCellRenderer {
38

  
39
    @Override
40
    public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected,
41
        boolean cellHasFocus) {
42
        Component cellComponent = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
43
        OperationFactory factory = ((OperationFactory) value);
44
        setText(factory.getName());
45

  
46
        return cellComponent;
47
    }
48

  
49
}
tags/org.gvsig.desktop-2.0.364/org.gvsig.desktop.library/org.gvsig.fmap.mapcontext.swing/org.gvsig.fmap.mapcontext.swing.impl/src/main/java/org/gvsig/fmap/mapcontext/raster/swing/impl/operations/OperationListPanelController.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2017 gvSIG Association
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.fmap.mapcontext.raster.swing.impl.operations;
24

  
25
import java.awt.event.ActionEvent;
26
import java.awt.event.ActionListener;
27
import java.util.Iterator;
28
import java.util.Locale;
29

  
30
import javax.swing.JComponent;
31
import javax.swing.ListSelectionModel;
32
import javax.swing.event.ListSelectionEvent;
33
import javax.swing.event.ListSelectionListener;
34
import javax.swing.event.TableModelListener;
35
import javax.swing.table.DefaultTableColumnModel;
36
import javax.swing.table.TableColumn;
37
import javax.swing.table.TableColumnModel;
38

  
39
import org.slf4j.Logger;
40
import org.slf4j.LoggerFactory;
41

  
42
import org.gvsig.fmap.mapcontext.raster.swing.operations.OperationListPanel;
43
import org.gvsig.raster.lib.buffer.api.operations.OperationList;
44
import org.gvsig.raster.lib.buffer.api.operations.OperationListEntry;
45
import org.gvsig.tools.ToolsLocator;
46
import org.gvsig.tools.i18n.I18nManager;
47
import org.gvsig.tools.swing.api.ToolsSwingLocator;
48
import org.gvsig.tools.swing.icontheme.IconTheme;
49

  
50
/**
51
 * @author fdiaz
52
 *
53
 */
54
public class OperationListPanelController extends OperationListPanelView implements OperationListPanel {
55

  
56
    /**
57
     *
58
     */
59
    private static final long serialVersionUID = 938628147696863910L;
60
    @SuppressWarnings("unused")
61
    private static final Logger LOG = LoggerFactory.getLogger(OperationListPanelController.class);
62

  
63
    /**
64
     * @param factories
65
     */
66
    @SuppressWarnings("unchecked")
67
    public OperationListPanelController() {
68
        translate();
69
        initializeComponents();
70
    }
71

  
72
    private void initializeComponents() {
73
        // this.btnAdd.addActionListener(this);
74
        this.btnAdd.setActionCommand(this.ADD_ACTION_COMMAND);
75
        this.btnUpdate.setActionCommand(this.UPDATE_ACTION_COMMAND);
76
        this.btnRemove.setActionCommand(this.REMOVE_ACTION_COMMAND);
77
        this.btnRemove.addActionListener(new ActionListener() {
78

  
79
            @Override
80
            public void actionPerformed(ActionEvent e) {
81
                OperationListTableModel model = (OperationListTableModel) tblOperationList.getModel();
82
                int selectedRow = tblOperationList.getSelectedRow();
83
                int index = selectedRow;
84
                model.removeElementAt(tblOperationList.getSelectedRow());
85
                if (index >= tblOperationList.getRowCount()) {
86
                    index = tblOperationList.getRowCount() - 1;
87
                }
88
                if (index >= 0) {
89
                    tblOperationList.getSelectionModel().setSelectionInterval(index, index);
90
                }
91
            }
92
        });
93

  
94
        this.btnUp.setActionCommand(this.UP_ACTION_COMMAND);
95
        this.btnUp.addActionListener(new ActionListener() {
96

  
97
            @Override
98
            public void actionPerformed(ActionEvent e) {
99
                OperationListTableModel model = (OperationListTableModel) tblOperationList.getModel();
100
                int selectedRow = tblOperationList.getSelectedRow();
101
                int index = selectedRow;
102
                if (selectedRow > 0) {
103
                    index--;
104
                }
105
                model.up(selectedRow);
106
                tblOperationList.getSelectionModel().setSelectionInterval(index, index);
107
            }
108
        });
109
        this.btnUp.setActionCommand(this.DOWN_ACTION_COMMAND);
110
        this.btnDown.addActionListener(new ActionListener() {
111

  
112
            @Override
113
            public void actionPerformed(ActionEvent e) {
114
                OperationListTableModel model = (OperationListTableModel) tblOperationList.getModel();
115
                int selectedRow = tblOperationList.getSelectedRow();
116
                int index = selectedRow;
117
                if (selectedRow < tblOperationList.getRowCount()) {
118
                    index++;
119
                }
120
                model.down(selectedRow);
121
                tblOperationList.getSelectionModel().setSelectionInterval(index, index);
122
            }
123
        });
124

  
125
        btnUp.setEnabled(false);
126
        btnDown.setEnabled(false);
127
        btnUpdate.setEnabled(false);
128

  
129
        IconTheme iconTheme = ToolsSwingLocator.getIconThemeManager().getCurrent();
130
        this.btnAdd.setIcon(iconTheme.get("add-operation-icon"));
131
        this.btnRemove.setIcon(iconTheme.get("remove-operation-icon"));
132
        this.btnUp.setIcon(iconTheme.get("up-operation-icon"));
133
        this.btnDown.setIcon(iconTheme.get("down-operation-icon"));
134
        this.btnUpdate.setIcon(iconTheme.get("update-operation-icon"));
135

  
136
        tblOperationList.setRowSelectionAllowed(true);
137
        tblOperationList.setColumnSelectionAllowed(false);
138
        tblOperationList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
139
        OperationListTableModel model = new OperationListTableModel();
140
        tblOperationList.setModel(model);
141

  
142
        tblOperationList.setColumnModel(new DefaultTableColumnModel());
143
        TableColumnModel columnModel = tblOperationList.getColumnModel();
144
        columnModel.setColumnSelectionAllowed(false);
145
        for (int i = 0; i < model.getColumnCount(); i++) {
146
            TableColumn tableColumn = new TableColumn(i);
147
            tableColumn.setIdentifier(model.getColumnName(i));
148
            tableColumn.setHeaderValue(model.getColumnName(i));
149
            columnModel.addColumn(tableColumn);
150
        }
151

  
152
        columnModel.getColumn(0).setCellRenderer(new OperationEntryNameCellRenderer());
153

  
154
        tblOperationList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
155

  
156
            @Override
157
            public void valueChanged(ListSelectionEvent e) {
158
                int selectedRow = tblOperationList.getSelectedRow();
159
                btnUp.setEnabled(selectedRow >= 0);
160
                btnDown.setEnabled(selectedRow >= 0);
161
                btnUpdate.setEnabled(selectedRow >= 0);
162
                btnRemove.setEnabled(selectedRow >= 0);
163
            }
164
        });
165
    }
166

  
167
    private void translate() {
168
        I18nManager i18nManager = ToolsLocator.getI18nManager();
169
        btnAdd.setText(""); // i18nManager.getTranslation(btnAdd.getText()));
170
        btnAdd.setToolTipText(i18nManager.getTranslation(btnAdd.getToolTipText()));
171
        btnRemove.setText(""); // i18nManager.getTranslation(btnRemove.getText()));
172
        btnRemove.setToolTipText(i18nManager.getTranslation(btnRemove.getToolTipText()));
173
        btnUp.setText(""); // i18nManager.getTranslation(btnUp.getText()));
174
        btnUp.setToolTipText(i18nManager.getTranslation(btnUp.getToolTipText()));
175
        btnDown.setText(""); // i18nManager.getTranslation(btnDown.getText()));
176
        btnDown.setToolTipText(i18nManager.getTranslation(btnDown.getToolTipText()));
177
        btnUpdate.setText(""); // i18nManager.getTranslation(btnAdd.getText()));
178
        btnUpdate.setToolTipText(i18nManager.getTranslation(btnAdd.getToolTipText()));
179
    }
180

  
181
    /**
182
     * @param locale
183
     *
184
     */
185
    public void setLocate(Locale locale) {
186
        Locale l = super.getLocale();
187
        if (!l.equals(locale)) {
188
            translate();
189
        }
190
        super.setLocale(locale);
191
    }
192

  
193
    /**
194
     * @param operationList
195
     */
196
    @SuppressWarnings("unchecked")
197
    public void set(OperationList operationList) {
198
        addOperations(operationList);
199
    }
200

  
201
    /**
202
     * @param colorInterpretation
203
     * @param store
204
     * @param model
205
     */
206
    private void addOperations(OperationList operationList) {
207
        OperationListTableModel model = ((OperationListTableModel) tblOperationList.getModel());
208
        for (Iterator iterator = operationList.iterator(); iterator.hasNext();) {
209
            OperationListEntry operationListEntry = (OperationListEntry) iterator.next();
210
            try {
211
                model.add((OperationListEntry) operationListEntry.clone());
212
            } catch (CloneNotSupportedException e) {
213
                LOG.warn("Can't clone operation list entry", e);
214
            }
215
            model.fireTableDataChanged();
216
        }
217
    }
218

  
219
    /**
220
     * @param layer
221
     */
222
    public boolean fetch(OperationList operationList) {
223
        OperationListTableModel model = (OperationListTableModel) tblOperationList.getModel();
224
        for (int i = 0; i < model.getRowCount(); i++) {
225
            OperationListEntry entry = model.getElementAt(i);
226
            try {
227
                operationList.add((OperationListEntry) entry.clone());
228
            } catch (CloneNotSupportedException e) {
229
                LOG.warn("Can't get the operation list.");
230
                return false;
231
            }
232
        }
233
        return true;
234
    }
235

  
236
    @Override
237
    public JComponent asJComponent() {
238
        return this;
239
    }
240

  
241
    @Override
242
    public void addListSelectionListener(ListSelectionListener listener) {
243
        tblOperationList.getSelectionModel().addListSelectionListener(listener);
244
    }
245

  
246
    @Override
247
    public void addTableModelListener(TableModelListener listener) {
248
        tblOperationList.getModel().addTableModelListener(listener);
249
    }
250

  
251
    @Override
252
    public OperationListEntry getSelected() {
253
        int selectedRow = tblOperationList.getSelectedRow();
254
        OperationListTableModel model = (OperationListTableModel) tblOperationList.getModel();
255
        if (selectedRow >= 0 && selectedRow < model.getRowCount()) {
256
            return model.getElementAt(selectedRow);
257
        }
258
        return null;
259
    }
260

  
261
    @Override
262
    public void enableAdd(boolean enable) {
263
        this.btnAdd.setEnabled(enable);
264
    }
265

  
266
    @Override
267
    public void enableUpdate(boolean enable) {
268
        this.btnUpdate.setEnabled(enable);
269
    }
270

  
271
    @Override
272
    public void add(OperationListEntry operationListEntry) {
273
        OperationListTableModel operationListTableModel = (OperationListTableModel) tblOperationList.getModel();
274
        operationListTableModel.add(operationListEntry);
275
        tblOperationList.getSelectionModel().setSelectionInterval(tblOperationList.getRowCount() - 1,
276
            tblOperationList.getRowCount() - 1);
277
    }
278

  
279
    @Override
280
    public void addActionListener(ActionListener listener) {
281
        btnAdd.addActionListener(listener);
282
        btnUpdate.addActionListener(listener);
283
        btnUp.addActionListener(listener);
284
        btnDown.addActionListener(listener);
285
        btnRemove.addActionListener(listener);
286
    }
287

  
288
    @Override
289
    public void clearSelection() {
290
        tblOperationList.clearSelection();
291
    }
292

  
293
    @Override
294
    public void select(int row) {
295
        tblOperationList.getSelectionModel().setSelectionInterval(row, row);
296
    }
297

  
298
    @Override
299
    public int getSelectedRow() {
300
        return tblOperationList.getSelectedRow();
301
    }
302

  
303
}
tags/org.gvsig.desktop-2.0.364/org.gvsig.desktop.library/org.gvsig.fmap.mapcontext.swing/org.gvsig.fmap.mapcontext.swing.impl/src/main/java/org/gvsig/fmap/mapcontext/raster/swing/impl/operations/OperationListTableModel.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2017 gvSIG Association
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.fmap.mapcontext.raster.swing.impl.operations;
24

  
25
import javax.swing.table.AbstractTableModel;
26

  
27
import org.slf4j.Logger;
28
import org.slf4j.LoggerFactory;
29

  
30
import org.gvsig.raster.lib.buffer.api.BufferLocator;
31
import org.gvsig.raster.lib.buffer.api.OperationManager;
32
import org.gvsig.raster.lib.buffer.api.operations.OperationList;
33
import org.gvsig.raster.lib.buffer.api.operations.OperationListEntry;
34
import org.gvsig.tools.ToolsLocator;
35
import org.gvsig.tools.i18n.I18nManager;
36

  
37

  
38

  
39
/**
40
 * @author fdiaz
41
 *
42
 */
43
public class OperationListTableModel extends AbstractTableModel {
44

  
45
    /**
46
     *
47
     */
48
    private static final long serialVersionUID = 5993288441174158255L;
49
    private static final Logger LOG = LoggerFactory.getLogger(OperationListTableModel.class);
50

  
51
    private static final int COLUMNS = 2;
52

  
53
    private static final int COLUMN_OPERATION = 0;
54
    private static final int COLUMN_IS_ACTIVE = 1;
55

  
56

  
57

  
58
    private OperationList operationList;
59

  
60
    /**
61
     *
62
     */
63
    public OperationListTableModel() {
64
        operationList = ((OperationManager)BufferLocator.getBufferManager()).createOperationList();
65
    }
66

  
67
    @Override
68
    public int getRowCount() {
69
        return operationList.size();
70
    }
71

  
72
    @Override
73
    public int getColumnCount() {
74
        return COLUMNS;
75
    }
76

  
77
    @Override
78
    public Object getValueAt(int rowIndex, int columnIndex) {
79
        OperationListEntry entry = operationList.get(rowIndex);
80
        switch (columnIndex) {
81
        case COLUMN_OPERATION:
82
            return entry.getOperation();
83
        case COLUMN_IS_ACTIVE:
84
            return entry.isActive();
85
        }
86
        return null;
87
    }
88

  
89
    @Override
90
    public String getColumnName(int column) {
91
        I18nManager i18nManager = ToolsLocator.getI18nManager();
92
        switch (column) {
93
        case COLUMN_OPERATION:
94
            return i18nManager.getTranslation("_operation");
95
        case COLUMN_IS_ACTIVE:
96
            return i18nManager.getTranslation("_active");
97
        }
98
        return null;
99
    }
100

  
101
    @Override
102
    public boolean isCellEditable(int rowIndex, int columnIndex) {
103
        if(columnIndex==COLUMN_IS_ACTIVE){
104
            return true;
105
        }
106
        return false;
107
    }
108

  
109
    @Override
110
    public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
111
        if (rowIndex < operationList.size()) {
112
            if (columnIndex < COLUMNS) {
113
                switch (columnIndex) {
114
                case COLUMN_IS_ACTIVE:
115
                    if (aValue == null) {
116
                        operationList.get(rowIndex).setActive(false);
117
                        break;
118
                    }
119
                    if (!(aValue instanceof Boolean)) {
120
                        throw new IllegalArgumentException("The object '" + aValue.toString() + "' must be a Boolean.");
121
                    }
122
                    operationList.get(rowIndex).setActive((Boolean) aValue);
123
                    this.fireTableDataChanged();
124
                    break;
125
                default:
126
                    super.setValueAt(aValue, rowIndex, columnIndex);
127
                    break;
128
                }
129
            }
130
            fireTableDataChanged();
131
        }
132
    }
133

  
134
    /**
135
     * @param rasterStoreBand
136
     */
137
    public void add(OperationListEntry operationListEntry) {
138
        operationList.add(operationListEntry);
139
        fireTableDataChanged();
140
    }
141

  
142
    /**
143
     * @param selectedRow
144
     */
145
    public void removeElementAt(int selectedRow) {
146
        operationList.remove(selectedRow);
147
        fireTableDataChanged();
148
    }
149

  
150
    public OperationListEntry getElementAt(int selectedRow) {
151
        return operationList.get(selectedRow);
152
    }
153

  
154
    /**
155
     * @param selectedRow
156
     */
157
    public void up(int selectedRow) {
158
        if(selectedRow>0){
159
            OperationListEntry operationListEntry = operationList.remove(selectedRow);
160
            operationList.add(selectedRow-1, operationListEntry);
161
            fireTableDataChanged();
162
        }
163
    }
164

  
165
    /**
166
     * @param selectedRow
167
     */
168
    public void down(int selectedRow) {
169
        if(selectedRow<operationList.size()){
170
            OperationListEntry operationListEntry = operationList.remove(selectedRow);
171
            operationList.add(selectedRow+1, operationListEntry);
172
            fireTableDataChanged();
173
        }
174
    }
175

  
176
    @Override
177
    public Class<?> getColumnClass(int col) {
178
        if (col == COLUMN_IS_ACTIVE) {
179
            return Boolean.class;
180
        }
181
        return super.getColumnClass(col);
182
    }
183

  
184
}
tags/org.gvsig.desktop-2.0.364/org.gvsig.desktop.library/org.gvsig.fmap.mapcontext.swing/org.gvsig.fmap.mapcontext.swing.impl/src/main/java/org/gvsig/fmap/mapcontext/raster/swing/impl/operations/OperationSelectorPanelController.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2017 gvSIG Association
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.fmap.mapcontext.raster.swing.impl.operations;
24

  
25
import java.util.Iterator;
26
import java.util.List;
27
import java.util.Locale;
28

  
29
import javax.swing.DefaultListModel;
30
import javax.swing.JComponent;
31
import javax.swing.ListSelectionModel;
32
import javax.swing.event.ListSelectionEvent;
33
import javax.swing.event.ListSelectionListener;
34

  
35
import org.slf4j.Logger;
36
import org.slf4j.LoggerFactory;
37

  
38
import org.gvsig.fmap.mapcontext.raster.swing.operations.OperationSelectorPanel;
39
import org.gvsig.raster.lib.buffer.api.BufferLocator;
40
import org.gvsig.raster.lib.buffer.api.operations.OperationFactory;
41
import org.gvsig.tools.ToolsLocator;
42
import org.gvsig.tools.i18n.I18nManager;
43

  
44
/**
45
 * @author fdiaz
46
 *
47
 */
48
public class OperationSelectorPanelController extends OperationSelectorPanelView implements OperationSelectorPanel,
49
    ListSelectionListener {
50

  
51
    /**
52
     *
53
     */
54
    private static final long serialVersionUID = -419078249858416625L;
55
    @SuppressWarnings("unused")
56
    private static final Logger LOG = LoggerFactory.getLogger(OperationSelectorPanelController.class);
57
//    private List<OperationFactory> factories;
58

  
59
    /**
60
     *
61
     */
62
    @SuppressWarnings("unchecked")
63
    public OperationSelectorPanelController() {
64
        translate();
65
        initializeComponents();
66
    }
67

  
68
    private void initializeComponents() {
69
        lstOperations.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
70

  
71
        lstOperations.getSelectionModel().addListSelectionListener(this);
72

  
73
        DefaultListModel<OperationFactory> model = new DefaultListModel<OperationFactory>();
74
        List<OperationFactory> factories = BufferLocator.getOperationManager().getOperationFactories();
75
        for (Iterator iterator = factories.iterator(); iterator.hasNext();) {
76
            OperationFactory operationFactory = (OperationFactory) iterator.next();
77
            model.addElement(operationFactory);
78
        }
79
        lstOperations.setModel(model);
80
        lstOperations.setCellRenderer(new OperationFactoryCellRenderer());
81
    }
82

  
83
    private void translate() {
84
        I18nManager i18nManager = ToolsLocator.getI18nManager();
85
        lstOperations.setToolTipText(i18nManager.getTranslation(lstOperations.getToolTipText()));
86
    }
87

  
88
    /**
89
     * @param locale
90
     *
91
     */
92
    public void setLocate(Locale locale) {
93
        Locale l = super.getLocale();
94
        if (!l.equals(locale)) {
95
            translate();
96
        }
97
        super.setLocale(locale);
98
    }
99

  
100
    @Override
101
    public JComponent asJComponent() {
102
        return this;
103
    }
104

  
105
    @Override
106
    public void valueChanged(ListSelectionEvent e) {
107

  
108
    }
109

  
110
    @Override
111
    public OperationFactory getSelected() {
112
        return (OperationFactory) lstOperations.getSelectedValue();
113
    }
114

  
115
    @Override
116
    public void addListSelectionListener(ListSelectionListener listener) {
117
        lstOperations.getSelectionModel().addListSelectionListener(listener);
118
    }
119

  
120
    @Override
121
    public void clearSelection() {
122
        lstOperations.clearSelection();
123
    }
124
}
tags/org.gvsig.desktop-2.0.364/org.gvsig.desktop.library/org.gvsig.fmap.mapcontext.swing/org.gvsig.fmap.mapcontext.swing.impl/src/main/java/org/gvsig/fmap/mapcontext/raster/swing/impl/operations/OperationListPanelView.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2

  
3
<object classname="com.jeta.forms.store.memento.FormPackage">
4
 <at name="fileversion">
5
  <object classname="com.jeta.forms.store.memento.FormsVersion2">
6
   <at name="major">2</at>
7
   <at name="minor">0</at>
8
   <at name="sub">0</at>
9
  </object>
10
 </at>
11
 <at name="form">
12
  <object classname="com.jeta.forms.store.memento.FormMemento">
13
   <super classname="com.jeta.forms.store.memento.ComponentMemento">
14
    <at name="cellconstraints">
15
     <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
16
      <at name="column">1</at>
17
      <at name="row">1</at>
18
      <at name="colspan">1</at>
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff