Revision 41400

View differences:

trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/BasicSymbologyExtension.java
24 24
package org.gvsig.app.extension;
25 25

  
26 26
import org.gvsig.andami.IconThemeHelper;
27
import org.gvsig.andami.PluginServices;
28 27
import org.gvsig.andami.plugins.Extension;
29 28
import org.gvsig.andami.preferences.IPreference;
30 29
import org.gvsig.andami.preferences.IPreferenceExtension;
......
38 37
import org.gvsig.app.gui.styling.SimpleFill;
39 38
import org.gvsig.app.gui.styling.SimpleLine;
40 39
import org.gvsig.app.gui.styling.SimpleMarker;
41
import org.gvsig.app.gui.styling.SimpleText;
42
import org.gvsig.app.gui.styling.SymbolEditor;
43 40
import org.gvsig.app.project.documents.view.legend.gui.AttrInTableLabeling;
44 41
import org.gvsig.app.project.documents.view.legend.gui.Categories;
45 42
import org.gvsig.app.project.documents.view.legend.gui.Features;
......
55 52
import org.gvsig.fmap.geom.Geometry;
56 53
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
57 54
import org.gvsig.symbology.swing.SymbologySwingLocator;
55
import org.gvsig.symbology.swing.SymbologySwingManager;
58 56

  
59 57
/**
60 58
 * Extension for enable the symbology. It only installs the core symbology.
......
62 60
 *
63 61
 */
64 62
public class BasicSymbologyExtension extends Extension implements IPreferenceExtension{
65
//	private SymbologyLibrary simbologyLibrary;	
66
//	private SymbologyDefaultImplLibrary simbologyDefaultImplLibrary;
67 63

  
68
	public void initialize() {
69
		// modules for symbol editor
70
		SymbolEditor.addSymbolEditorPanel(SimpleFill.class, Geometry.TYPES.SURFACE);
71
		SymbolEditor.addSymbolEditorPanel(SimpleMarker.class, Geometry.TYPES.POINT);
72
		SymbolEditor.addSymbolEditorPanel(SimpleLine.class, Geometry.TYPES.CURVE);
73
		SymbolEditor.addSymbolEditorPanel(SimpleFill.class, Geometry.TYPES.MULTISURFACE);
74
		SymbolEditor.addSymbolEditorPanel(SimpleMarker.class, Geometry.TYPES.MULTIPOINT);
75
		SymbolEditor.addSymbolEditorPanel(SimpleLine.class, Geometry.TYPES.MULTICURVE);
76
		
77
		//FIXME 
78
		SymbolEditor.addSymbolEditorPanel(PictureMarker.class, Geometry.TYPES.POINT);
79
		SymbolEditor.addSymbolEditorPanel(PictureLine.class, Geometry.TYPES.CURVE);
80
		SymbolEditor.addSymbolEditorPanel(PictureFill.class, Geometry.TYPES.SURFACE);
81
		SymbolEditor.addSymbolEditorPanel(MarkerFill.class, Geometry.TYPES.SURFACE);
64
    public void initialize() {
65
        // modules for symbol editor
66
        SymbologySwingManager symbologySwingManager = SymbologySwingLocator.getSwingManager();
82 67

  
83
		SymbolEditor.addSymbolEditorPanel(PictureMarker.class, Geometry.TYPES.MULTIPOINT);
84
		SymbolEditor.addSymbolEditorPanel(PictureLine.class, Geometry.TYPES.MULTICURVE);
85
		SymbolEditor.addSymbolEditorPanel(PictureFill.class, Geometry.TYPES.MULTISURFACE);
86
		SymbolEditor.addSymbolEditorPanel(MarkerFill.class, Geometry.TYPES.MULTISURFACE);
68
        symbologySwingManager.registerSymbolEditor(SimpleFill.class, Geometry.TYPES.SURFACE);
69
        symbologySwingManager.registerSymbolEditor(SimpleMarker.class, Geometry.TYPES.POINT);
70
        symbologySwingManager.registerSymbolEditor(SimpleLine.class, Geometry.TYPES.CURVE);
71
        symbologySwingManager.registerSymbolEditor(SimpleFill.class, Geometry.TYPES.MULTISURFACE);
72
        symbologySwingManager.registerSymbolEditor(SimpleMarker.class, Geometry.TYPES.MULTIPOINT);
73
        symbologySwingManager.registerSymbolEditor(SimpleLine.class, Geometry.TYPES.MULTICURVE);
87 74

  
88
		// pages
89
		ThemeManagerWindow.addPage(General.class);
90
		ThemeManagerWindow.addPage(LegendManager.class);
91
		ThemeManagerWindow.addPage(LabelingManager.class);
75
        //FIXME 
76
        symbologySwingManager.registerSymbolEditor(PictureMarker.class, Geometry.TYPES.POINT);
77
        symbologySwingManager.registerSymbolEditor(PictureLine.class, Geometry.TYPES.CURVE);
78
        symbologySwingManager.registerSymbolEditor(PictureFill.class, Geometry.TYPES.SURFACE);
79
        symbologySwingManager.registerSymbolEditor(MarkerFill.class, Geometry.TYPES.SURFACE);
92 80

  
93
		ThemeManagerWindow.setTabEnabledForLayer(General.class, FLyrVect.class, true);
94
		ThemeManagerWindow.setTabEnabledForLayer(LegendManager.class, FLyrVect.class, true);
95
		ThemeManagerWindow.setTabEnabledForLayer(LabelingManager.class, FLyrVect.class, true);
96
		// labeling strategies (inverse order to the wanted to be shown)
97
		LabelingManager.addLabelingStrategy(AttrInTableLabeling.class);
81
        symbologySwingManager.registerSymbolEditor(PictureMarker.class, Geometry.TYPES.MULTIPOINT);
82
        symbologySwingManager.registerSymbolEditor(PictureLine.class, Geometry.TYPES.MULTICURVE);
83
        symbologySwingManager.registerSymbolEditor(PictureFill.class, Geometry.TYPES.MULTISURFACE);
84
        symbologySwingManager.registerSymbolEditor(MarkerFill.class, Geometry.TYPES.MULTISURFACE);
98 85

  
99
		// legends available in the legend page
100
		LegendManager.addLegendPage(Quantities.class);
101
		LegendManager.addLegendPage(Features.class);
102
		LegendManager.addLegendPage(Categories.class);
103
		LegendManager.addLegendPage(MultipleAttributes.class);
86
        // legends available 
87
        symbologySwingManager.registerLegendEditor(Quantities.class);
88
        symbologySwingManager.registerLegendEditor(Features.class);
89
        symbologySwingManager.registerLegendEditor(Categories.class);
90
        symbologySwingManager.registerLegendEditor(MultipleAttributes.class);
104 91

  
105
		LegendManager.addLegendPage(SingleSymbol.class);
106
		LegendManager.addLegendPage(VectorialInterval.class);
107
		LegendManager.addLegendPage(VectorialUniqueValue.class);
92
        symbologySwingManager.registerLegendEditor(SingleSymbol.class);
93
        symbologySwingManager.registerLegendEditor(VectorialInterval.class);
94
        symbologySwingManager.registerLegendEditor(VectorialUniqueValue.class);
108 95

  
109
//		LegendManager.addLegendDriver(FMapGVLDriver.class);
110
		registerIcons();
111
	}
112
	
96
        // labeling strategies (inverse order to the wanted to be shown)
97
        symbologySwingManager.registerLabelingEditor(AttrInTableLabeling.class);
98

  
99
        
100
        // pages
101
        ThemeManagerWindow.addPage(General.class);
102
        ThemeManagerWindow.addPage(LegendManager.class);
103
        ThemeManagerWindow.addPage(LabelingManager.class);
104

  
105
        ThemeManagerWindow.setTabEnabledForLayer(General.class, FLyrVect.class, true);
106
        ThemeManagerWindow.setTabEnabledForLayer(LegendManager.class, FLyrVect.class, true);
107
        ThemeManagerWindow.setTabEnabledForLayer(LabelingManager.class, FLyrVect.class, true);
108

  
109
        registerIcons();
110
    }
111

  
113 112
	@Override
114 113
	public void postInitialize() {
115 114
		super.postInitialize();
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/view/legend/gui/ILegendPanel.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 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 3
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
package org.gvsig.app.project.documents.view.legend.gui;
26

  
27
import javax.swing.ImageIcon;
28
import javax.swing.JPanel;
29

  
30
import org.gvsig.fmap.mapcontext.layers.FLayer;
31
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend;
32

  
33

  
34
/**
35
 * @author jaume dominguez faus - jaume.dominguez@iver.es
36
 *
37
 * Este interfaz es el que debe cumplir cualquier panel que empleemos
38
 * para confeccionar una leyenda. Se le pasa una capa para que
39
 * tome su leyenda, y con el m?todo getLegend tomamos la leyenda
40
 * que ha confeccionado el usuario.
41
 */
42
public interface ILegendPanel {
43
	/**
44
	 * Initializes the data required for this legend panel. That is, the layer that
45
	 * will adopt the changes and the current legend that this layer has. If the
46
	 * legend is not the type of legend that this panel manages then it initializes
47
	 * the panel with the default values. In case it is, then the panel should
48
	 * refresh its components with the current values of the Legend.
49
	 * @param lyr,  target layer
50
	 * @param legend, the legend currently applied to lyr
51
	 */
52
	public void setData(FLayer lyr, ILegend legend);
53

  
54
	/**
55
	 * Returns an instance of Legend
56
	 * @return Legend, the legend result of the settings
57
	 */
58
	public ILegend getLegend();
59

  
60
	/**
61
	 * Returns a brief human-readable description about what kind of legend builds this panel
62
	 * @return String with a brief description
63
	 */
64
	public String getDescription();
65

  
66
	/**
67
	 * Returns the icon which should graphically describe what this panel's legend does.
68
	 * @return ImageIcon with the icon to be displayed
69
	 */
70
	public ImageIcon getIcon();
71

  
72
	/**
73
	 * If this panel should appear as a subnode of the legends tree, in other words it is not
74
	 * a first-level node, then this method would return <b>its parent's class</b>. Otherwise, if
75
	 * it is a first-level node, then it will return <b>null</b>.
76
	 * @return String containing the parent's title.
77
	 */
78
	public Class getParentClass();
79

  
80
	/**
81
	 * Returns the title (a human-readable one) of this panel.
82
	 */
83
	public String getTitle();
84

  
85
	/**
86
	 * <p>If this is a complete panel (it is a child node in the legend tree) to set up a legend
87
	 * this method will return a <b>JPanel</b> containing the necessary components. Otherwise, if
88
	 * it is just a classification node (it has children) in the legend tree it will return
89
	 * just <b>null</b>.<br></p>
90
	 *
91
	 * <p>If <b>null</b> is returned, the ILegendPanel that will be shown and selected each time
92
	 * it is selected is the very first child of this parent node.</p>
93
	 */
94
	public JPanel getPanel();
95

  
96
	/**
97
	 * Returns the class of the legend produced by this ILegendPanel.
98
	 */
99
	public Class getLegendClass();
100

  
101
	/**
102
	 * Returns <b>true</b> if this legend is applicable to this layer, <b>false</b> otherwise.
103
	 */
104
	public boolean isSuitableFor(FLayer layer);
105
}
106

  
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/view/legend/gui/ILabelingStrategyPanel.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 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 3
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
package org.gvsig.app.project.documents.view.legend.gui;
25

  
26
import org.gvsig.fmap.mapcontext.layers.FLayer;
27
import org.gvsig.fmap.mapcontext.rendering.legend.styling.ILabelingStrategy;
28

  
29

  
30
/**
31
 * Interface to be implemented for those panels whose purpose is to
32
 * set up labeling strategies.
33
 *
34
 * ILabelingStrategyPanel.java
35
 *
36
 *
37
 * @author jaume dominguez faus - jaume.dominguez@iver.es Jun 13, 2008
38
 *
39
 */
40
public interface ILabelingStrategyPanel {
41
	/**
42
	 * Invoked when de user accepts the settings, the returned value
43
	 * is a always ready-to-work labeling strategy.
44
	 *
45
	 * @return ILabelingStrategy, a labeling strategy completely set up.
46
	 */
47
	public ILabelingStrategy getLabelingStrategy();
48

  
49
	/**
50
	 * Sets the model of the panel. As a general contract, after invoke
51
	 * this method, the panel should be filled with all the values
52
	 * needed and be able to be repainted successfully.
53
	 *
54
	 * @param layer, the layer to whom the labeling strategy is associated.
55
	 * @param str, the current labeling strategy.
56
	 */
57
	public void setModel(FLayer layer, ILabelingStrategy str);
58

  
59
	/**
60
	 * A human-readable localized text to make this strategy easily
61
	 * recognizable among all the available strategies.
62
	 * @return
63
	 */
64
	public String getLabelingStrategyName();
65

  
66
	/**
67
	 * <p>
68
	 * The panel shown in the layer properties dialog is selected through
69
	 * the class of the labeling strategy. This method returns such class.
70
	 * <br>
71
	 * </p>
72
	 * <p>
73
	 * <b>Note</b> that, as a collateral effect, the panel that sets up a labeling strategy
74
	 * can be substituted programatically by other of your wish if
75
	 * you return the same labeling strategy class than the one to
76
	 * be replaced with your new one. The last panel installed, will
77
	 * be the one to be shown.
78
	 * </p>
79
	 * @return Class, the labeling strategy's Class
80
	 */
81
	public Class getLabelingStrategyClass();
82
}
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/view/legend/gui/LabelingManager.java
31 31
import java.awt.event.ActionListener;
32 32
import java.util.ArrayList;
33 33
import java.util.Comparator;
34
import java.util.Hashtable;
35 34
import java.util.Iterator;
35
import java.util.List;
36 36
import java.util.TreeMap;
37 37

  
38 38
import javax.swing.BorderFactory;
......
46 46
import org.gvsig.fmap.mapcontext.layers.FLayer;
47 47
import org.gvsig.fmap.mapcontext.rendering.legend.styling.ILabelable;
48 48
import org.gvsig.fmap.mapcontext.rendering.legend.styling.ILabelingStrategy;
49
import org.gvsig.symbology.swing.SymbologySwingLocator;
50
import org.gvsig.symbology.swing.SymbologySwingManager;
49 51
import org.gvsig.utils.swing.JComboBox;
50 52

  
51 53

  
......
56 58
 */
57 59
public class LabelingManager extends AbstractThemeManagerPage implements ActionListener {
58 60
	private static final long serialVersionUID = 856162295985695717L;
59
	private static ArrayList<Class<? extends ILabelingStrategyPanel>> installedPanels = new ArrayList<Class<? extends ILabelingStrategyPanel>>();
61
//	private static ArrayList<Class<? extends ILabelingStrategyPanel>> installedPanels = new ArrayList<Class<? extends ILabelingStrategyPanel>>();
60 62
	private Comparator<Class<?>> comparator=new Comparator<Class<?>>(){
61 63

  
62 64
		public int compare(Class<?> o1, Class<?> o2) {
......
103 105

  
104 106
	private void initialize() {
105 107
		setLayout(new BorderLayout());
106
		for (Iterator<Class<? extends ILabelingStrategyPanel>> it = installedPanels.iterator(); it.hasNext();) {
107
			try {
108
				ILabelingStrategyPanel pnl = (ILabelingStrategyPanel) it.next().newInstance();
109
				strategyPanels.put(pnl.getLabelingStrategyClass(), pnl);
110
			} catch (Exception e) {
111
				/*
112
				 *  can't happen
113
				 *  this should never happen since instantiation and access exceptions have been
114
				 *	controlled in the addLabelingStrategy method
115
				 */
116
				NotificationManager.addError(e);
117
			}
118

  
108
                SymbologySwingManager symbologySwingManager = SymbologySwingLocator.getSwingManager();
109
    
110
                Iterator<ILabelingStrategyPanel> it = symbologySwingManager.getLabelingEditors().iterator();
111
                while( it.hasNext() ) {
112
                    ILabelingStrategyPanel pnl = it.next();
113
                    strategyPanels.put(pnl.getLabelingStrategyClass(), pnl);
119 114
		}
120 115
		content = new JPanel(new BorderLayout());
121 116
		content.setBorder(BorderFactory.createEtchedBorder());
......
187 182
		return chkApplyLabels;
188 183
	}
189 184

  
185
        /**
186
         * 
187
         * @deprecated use {#SymbolSwingManger.
188
         */
190 189
	public static void addLabelingStrategy(Class<? extends ILabelingStrategyPanel> iLabelingStrategyPanelClass) {
191
		installedPanels.add(iLabelingStrategyPanelClass);
190
            SymbologySwingManager symbologySwingManager = SymbologySwingLocator.getSwingManager();
191
            symbologySwingManager.registerLabelingEditor(iLabelingStrategyPanelClass);
192 192
	}
193 193

  
194 194
	private void setComponentEnabled(Component c, boolean b) {
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/view/legend/gui/LegendManager.java
38 38
import java.util.ArrayList;
39 39
import java.util.Enumeration;
40 40
import java.util.Hashtable;
41
import java.util.Iterator;
41 42
import java.util.List;
42 43
import java.util.prefs.Preferences;
43 44

  
......
83 84
import org.gvsig.fmap.mapcontext.rendering.legend.driver.ILegendWriter;
84 85
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolManager;
85 86
import org.gvsig.i18n.Messages;
87
import org.gvsig.symbology.swing.SymbologySwingLocator;
88
import org.gvsig.symbology.swing.SymbologySwingManager;
86 89
import org.gvsig.tools.ToolsLocator;
87 90
import org.gvsig.tools.persistence.PersistenceManager;
88 91

  
......
101 104
        LoggerFactory.getLogger(LegendManager.class);
102 105
    
103 106
    private static final long serialVersionUID = 7989057553773181019L;
104
    private static ArrayList<Class<? extends ILegendPanel>> legendPool =
105
        new ArrayList<Class<? extends ILegendPanel>>();
107
//    private static ArrayList<Class<? extends ILegendPanel>> legendPool =
108
//        new ArrayList<Class<? extends ILegendPanel>>();
106 109
    // private static ArrayList<Class<? extends IFMapLegendDriver>>
107 110
    // legendDriverPool = new ArrayList<Class<? extends IFMapLegendDriver>>();
108 111

  
......
684 687
     * bug, sorry. Just avoid this case or try to fix it (lol).<br>
685 688
     * </p>
686 689
     * 
687
     * <p>
688
     * <b>Notice</b> that there is no type check so if you add a
689
     * non-ILegendPanel class, you'll have a runtime error later.
690
     * </p>
691
     * 
692 690
     * @param page
693 691
     *            , Class of type ILegendPanel
692
     * @deprecated use SymbologySwingManager.registerLegendEditor
694 693
     */
695
    public static void addLegendPage(
696
        Class<? extends ILegendPanel> iLegendPanelClass) {
697
        if (!legendPool.contains(iLegendPanelClass)) {
698
            legendPool.add(iLegendPanelClass);
699
        }
694
    public static void addLegendPage(Class<? extends ILegendPanel> iLegendPanelClass) {
695
        SymbologySwingManager manager = SymbologySwingLocator.getSwingManager();
696
        manager.registerLegendEditor(iLegendPanelClass);
700 697
    }
701 698

  
702 699
    /**
......
705 702
     */
706 703
    private void fillDialog() {
707 704
        if (empty) {
708
            
709
            Class<?> pageClass = null;
710
            ILegendPanel page = null;
711
            
712
            for (int i = 0; i < legendPool.size(); i++) {
713
                pageClass = (Class<?>) legendPool.get(i);
714
                try {
715
                    page = (ILegendPanel) pageClass.newInstance();
716
                } catch (Exception e) {
717
                    logger.info("Unable to instantiate legend panel.", e);
718
                }
719
                if (page != null && page.isSuitableFor(layer)) {
720
                    pages.put(page.getClass(), page); // this legend can be applied
721
                }
705
            SymbologySwingManager manager = SymbologySwingLocator.getSwingManager();
706
              
707
            Iterator<ILegendPanel> it = manager.getLegendEditors(layer).iterator();
708
            while( it.hasNext() ) {
709
                ILegendPanel page = it.next();
710
                pages.put(page.getClass(), page); 
722 711
            }
723 712
            
724 713
            Enumeration<ILegendPanel> enume = pages.elements();
725 714
            while (enume.hasMoreElements()) {
726
                page = enume.nextElement();
715
                ILegendPanel page = enume.nextElement();
727 716
                doInsertNode(treeModel, page);
728 717
            }
729

  
730 718
            getJTreeLegends().setModel(treeModel);
731 719
            getJTreeLegends().repaint();
732 720
            empty = false;
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.symbology/org.gvsig.symbology.swing/org.gvsig.symbology.swing.impl/src/main/java/org/gvsig/symbology/swing/impl/DefaultSymbologySwingManager.java
3 3
 *
4 4
 * Copyright (C) 2007-2013 gvSIG Association.
5 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 3
9
 * of the License, or (at your option) any later version.
6
 * This program is free software; you can redistribute it and/or modify it under
7
 * the terms of the GNU General Public License as published by the Free Software
8
 * Foundation; either version 3 of the License, or (at your option) any later
9
 * version.
10 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.
11
 * This program is distributed in the hope that it will be useful, but WITHOUT
12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14
 * details.
15 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.
16
 * You should have received a copy of the GNU General Public License along with
17
 * this program; if not, write to the Free Software Foundation, Inc., 51
18
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 19
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
20
 * For any additional information, do not hesitate to contact us at info AT
21
 * gvsig.com, or visit our website www.gvsig.com.
23 22
 */
24 23
package org.gvsig.symbology.swing.impl;
25 24

  
25
import java.util.ArrayList;
26
import java.util.Collections;
27
import java.util.HashMap;
28
import java.util.Iterator;
26 29
import java.util.List;
30
import java.util.Map;
31
import java.util.logging.Level;
27 32

  
28 33
import org.gvsig.app.gui.styling.SymbolEditor;
34
import org.gvsig.app.gui.styling.TypeSymbolEditor;
35
import org.gvsig.app.project.documents.view.legend.gui.ILabelingStrategyPanel;
36
import org.gvsig.app.project.documents.view.legend.gui.ILegendPanel;
37
import org.gvsig.fmap.geom.type.GeometryType;
38
import org.gvsig.fmap.mapcontext.layers.FLayer;
39
import org.gvsig.fmap.mapcontext.rendering.legend.styling.ILabelingStrategy;
29 40
import org.gvsig.gui.ColorTablePainter;
30 41
import org.gvsig.gui.ColorTablesFactory;
31 42
import org.gvsig.gui.DefaultColorTablesFactory;
......
33 44
import org.gvsig.symbology.SymbologyManager;
34 45
import org.gvsig.symbology.swing.SymbologySwingManager;
35 46
import org.gvsig.symbology.swing.SymbologyWindowManager;
47
import org.gvsig.tools.ToolsLocator;
48
import org.gvsig.tools.i18n.I18nManager;
49
import org.slf4j.Logger;
50
import org.slf4j.LoggerFactory;
36 51

  
37 52
/**
38 53
 * Default implementation of the {@link SymbologySwingManager}.
39
 * 
54
 *
40 55
 * @author gvSIG Team
41 56
 * @version $Id$
42 57
 */
43 58
public class DefaultSymbologySwingManager implements
44
    SymbologySwingManager {
59
        SymbologySwingManager {
45 60

  
61
    private static final Logger logger = LoggerFactory.getLogger(DefaultSymbologySwingManager.class);
62

  
46 63
    private SymbologyManager manager;
47
    // private I18nManager i18nmanager = null;
64
    private I18nManager i18nmanager = null;
48 65
    private SymbologyWindowManager windowManager;
49 66
    private ColorTablesFactory colorTablesFactory;
50 67

  
68
    private static Map<Integer, List<Class<? extends TypeSymbolEditor>>> symbolEditorRegistry;
69
    private List<Class<? extends ILegendPanel>> legendEditorRegistry = null;
70
    private List<Class<? extends ILabelingStrategyPanel>> labelingEditorRegistry = null;
71

  
51 72
    public DefaultSymbologySwingManager() {
52 73
        this.manager = SymbologyLocator.getSymbologyManager();
53
        // this.i18nmanager = ToolsLocator.getI18nManager();
54 74
        this.windowManager = new DefaultSymbologyWindowManager();
55
        colorTablesFactory = new DefaultColorTablesFactory();
75
        this.colorTablesFactory = new DefaultColorTablesFactory();
76

  
77
        this.legendEditorRegistry = new ArrayList<Class<? extends ILegendPanel>>();
78
        this.labelingEditorRegistry = new ArrayList<Class<? extends ILabelingStrategyPanel>>();
56 79
    }
57 80

  
58 81
    public SymbologyManager getManager() {
......
60 83
    }
61 84

  
62 85
    public String getTranslation(String key) {
63
        // TODO: add I18nManager usage when org.gvsig.tools.lib 2.1.0 becomes
64
        // available
65
        // return this.i18nmanager.getTranslation(key);
66
        return key;
86
        if (this.i18nmanager == null) {
87
            this.i18nmanager = ToolsLocator.getI18nManager();
88
        }
89
        return this.i18nmanager.getTranslation(key);
67 90
    }
68 91

  
69 92
    public void registerWindowManager(SymbologyWindowManager manager) {
......
73 96
    public SymbologyWindowManager getWindowManager() {
74 97
        return this.windowManager;
75 98
    }
76
    
77
	@SuppressWarnings("rawtypes")
78
	public void addSymbolEditorPanel(Class abstractTypeSymbolEditorPanelClass, int shapeType) {
79
		SymbolEditor.addSymbolEditorPanel(abstractTypeSymbolEditorPanelClass, shapeType);
80
	}
81 99

  
82
	public void setColorTablesFactory(ColorTablesFactory factory) {
83
		colorTablesFactory = factory;
84
	}
100
    public void setColorTablesFactory(ColorTablesFactory factory) {
101
        colorTablesFactory = factory;
102
    }
85 103

  
86
	public List<ColorTablePainter> createColorTables() {
87
		if (colorTablesFactory != null){
88
		    return colorTablesFactory.createColorTables();
89
		}
90
		return null;
91
	}
92
	
93
	public ColorTablesFactory getColorTablesFactory() {
94
		return this.colorTablesFactory;
95
	}
104
    public List<ColorTablePainter> createColorTables() {
105
        if (colorTablesFactory != null) {
106
            return colorTablesFactory.createColorTables();
107
        }
108
        return null;
109
    }
110

  
111
    public ColorTablesFactory getColorTablesFactory() {
112
        return this.colorTablesFactory;
113
    }
114

  
115
    /**
116
     * @deprecated use registerTypeSymbolEditor
117
     */
118
    public void addSymbolEditorPanel(Class abstractTypeSymbolEditorPanelClass, int shapeType) {
119
        Class<? extends TypeSymbolEditor> symbolEditor = abstractTypeSymbolEditorPanelClass;
120
        this.registerSymbolEditor(symbolEditor, shapeType);
121
    }
122

  
123
    public void registerSymbolEditor(Class<? extends TypeSymbolEditor> symbolEditor, int shapeType) {
124
        if (symbolEditorRegistry == null) {
125
            symbolEditorRegistry = new HashMap<Integer, List<Class<? extends TypeSymbolEditor>>>();
126
        }
127

  
128
        Integer key = new Integer(shapeType);
129
        List<Class<? extends TypeSymbolEditor>> l = symbolEditorRegistry.get(key);
130
        if (l == null) {
131
            l = new ArrayList<Class<? extends TypeSymbolEditor>>();
132
        }
133
        l.add(symbolEditor);
134

  
135
        symbolEditorRegistry.put(key, l);
136
    }
137

  
138
    public List<Class<? extends TypeSymbolEditor>> getSymbolEditorClassesByGeometryType(GeometryType geometryType) {
139
        if (symbolEditorRegistry == null) {
140
            return Collections.emptyList();
141
        }
142
        Iterator it = symbolEditorRegistry.keySet().iterator();
143
        while (it.hasNext()) {
144
            int currentType = (Integer) it.next();
145
            if (geometryType.isTypeOf(currentType)) {
146
                return (List) symbolEditorRegistry.get(currentType);
147
            }
148
        }
149
        return Collections.emptyList();
150
    }
151

  
152
    public void registerLegendEditor(Class<? extends ILegendPanel> legendEditor) {
153
        if (this.legendEditorRegistry == null) {
154
            this.legendEditorRegistry = new ArrayList<Class<? extends ILegendPanel>>();
155
        }
156
        if (!this.legendEditorRegistry.contains(legendEditor)) {
157
            this.legendEditorRegistry.add(legendEditor);
158
        }
159
    }
160

  
161
    public List<Class<? extends ILegendPanel>> getLegendEditorClasses() {
162
        return Collections.unmodifiableList(this.legendEditorRegistry);
163
    }
164

  
165
    public List<ILegendPanel> getLegendEditors(FLayer layer) {
166
        List<ILegendPanel> editors = new ArrayList<ILegendPanel>();
167
        Class<? extends ILegendPanel> legendEditorClass = null;
168
        ILegendPanel editor = null;
169

  
170
        for (int i = 0; i < legendEditorRegistry.size(); i++) {
171
            legendEditorClass = legendEditorRegistry.get(i);
172
            try {
173
                editor = null;
174
                editor = (ILegendPanel) legendEditorClass.newInstance();
175
            } catch (Exception e) {
176
                logger.info("Unable to instantiate legend editor.", e);
177
            }
178
            if (editor != null && editor.isSuitableFor(layer)) {
179
                editors.add(editor);
180
            }
181
        }
182
        return editors;
183
    }
184

  
185
    public void registerLabelingEditor(Class<? extends ILabelingStrategyPanel> labelingEditor) {
186
        if (!this.labelingEditorRegistry.contains(labelingEditor)) {
187
            this.labelingEditorRegistry.add(labelingEditor);
188
        }
189
    }
190

  
191
    public List<ILabelingStrategyPanel> getLabelingEditors() {
192
        List<ILabelingStrategyPanel> labelingEditors = new ArrayList<ILabelingStrategyPanel>();
193
        Iterator<Class<? extends ILabelingStrategyPanel>> it = this.labelingEditorRegistry.iterator();
194
        while (it.hasNext()) {
195
            Class<? extends ILabelingStrategyPanel> labelingEditorClass = it.next();
196
            try {
197
                ILabelingStrategyPanel labelingEditor = labelingEditorClass.newInstance();
198
                labelingEditors.add(labelingEditor);
199
            } catch (Exception ex) {
200
                String msg = "Can't create the labeling editor associated to '"+labelingEditorClass.getName()+"'.";
201
                logger.warn(msg,ex);
202
                throw new RuntimeException(msg,ex);
203
            }
204
        }
205
        return labelingEditors;
206
    }
207

  
96 208
}
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.symbology/org.gvsig.symbology.swing/org.gvsig.symbology.swing.api/src/main/java/org/gvsig/app/gui/styling/AbstractTypeSymbolEditor.java
129 129
 * </p>
130 130
 * @author jaume dominguez faus - jaume.dominguez@iver.es
131 131
 */
132
public abstract class AbstractTypeSymbolEditor {
132
public abstract class AbstractTypeSymbolEditor implements TypeSymbolEditor {
133 133
	protected SymbolEditor owner;
134 134
	private boolean applying = false;
135 135

  
136
	/**
137
	 * Produces and returns  the ISymbol according with the user settings.
138
	 *
139
	 * @return XMLEntity defining the ISymbol.
140
	 * @see getSymbolClass() method
141
	 */
142
	public abstract ISymbol getLayer();
143 136

  
144 137
	/**
145 138
	 * Creates a new instance of this type symbol editor panel associated to
......
151 144
		this.owner = owner;
152 145
	}
153 146

  
154
	/**
155
	 * <p>
156
	 * Returns the name of the config tabs that will be shown in the selector combo box.
157
	 * This is typically a human-readable (and also translatable) name for the symbol that
158
	 * this TypeEditorPanel deals with, but maybe you prefer to use any other one.<br>
159
	 * </p>
160
	 * <p>
161
	 * The order of the entries in the combo is alphabetically-based. So you can force a
162
	 * position by defining a name that suits your needs.
163
	 * </p>
164
	 * @return A human-readable text naming this panel
165
	 */
166
	public abstract String getName();
167 147

  
168 148
	/**
169
	 * <p>
170
	 * Due to the complexity that many symbols settings can reach, the SymbolEditorPanel is
171
	 * designed in a tabbed-based fashion. So, you can use as many of pages you want to put
172
	 * your components. This pages are regular JPanels that will be automatically added to
173
	 * the SymbolEditor dialog.<br>
174
	 * </p>
175
	 * <p>
176
	 * In case you need only one page, just return a JPanel array with a length of 1.
177
	 * </p>
178
	 * @return An array of JPanel containing the setting's interface.
179
	 */
180
	public abstract JPanel[] getTabs();
181

  
182
	/**
183
	 * Invoked when the user selects or adds a new layer. This method fills up
184
	 * the components on the right according on the layer properties
185
	 * @param <b>ISymbol</b> layer, the symbol
186
	 */
187
	public abstract void refreshControls(ISymbol layer);
188

  
189
	/**
190 149
	 * This overrided method returns the text shown at the SymbolEditorPanel
191 150
	 * select combobox.
192 151
	 */
......
211 170
		}
212 171
	}
213 172

  
214
	public abstract boolean canManageSymbol(ISymbol symbol);
215
	
216
	/**
217
	 * Returns the editor tools that are handled by this configuration panel.
218
	 * @return <b>EditorTool</b>
219
	 */
220
	public abstract EditorTool[] getEditorTools();
221 173

  
222 174

  
223 175
}
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.symbology/org.gvsig.symbology.swing/org.gvsig.symbology.swing.api/src/main/java/org/gvsig/app/gui/styling/SymbolEditor.java
21 21
 * For any additional information, do not hesitate to contact us
22 22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23 23
 */
24
/* CVS MESSAGES:
25
 *
26
 * $Id: SymbolEditor.java 30892 2009-09-21 12:02:19Z cordinyana $
27
 * $Log$
28
 * Revision 1.22  2007-09-19 15:36:36  jaume
29
 * removed unnecessary imports
30
 *
31
 * Revision 1.21  2007/09/17 09:21:45  jaume
32
 * refactored SymboSelector (added support for multishapedsymbol)
33
 *
34
 * Revision 1.20  2007/08/21 09:32:41  jvidal
35
 * javadoc
36
 *
37
 * Revision 1.19  2007/08/10 06:09:57  jaume
38
 * imports fixed
39
 *
40
 * Revision 1.18  2007/08/10 06:06:05  jaume
41
 * translations and error messages
42
 *
43
 * Revision 1.17  2007/08/03 11:29:13  jaume
44
 * refactored AbstractTypeSymbolEditorPanel class name to AbastractTypeSymbolEditor
45
 *
46
 * Revision 1.16  2007/08/01 13:01:43  jaume
47
 * refactored to be pluggable
48
 *
49
 * Revision 1.15  2007/07/30 12:56:04  jaume
50
 * organize imports, java 5 code downgraded to 1.4 and added PictureFillSymbol
51
 *
52
 * Revision 1.14  2007/07/30 06:59:51  jaume
53
 * finished (maybe) LineFillSymbol
54
 *
55
 * Revision 1.13  2007/07/26 12:28:29  jaume
56
 * maybe finished ArrowMarkerSymbol and ArrowDecoratorStyle
57
 *
58
 * Revision 1.12  2007/07/18 06:56:03  jaume
59
 * continuing with cartographic support
60
 *
61
 * Revision 1.11  2007/07/12 10:43:55  jaume
62
 * *** empty log message ***
63
 *
64
 * Revision 1.10  2007/06/29 13:07:33  jaume
65
 * +PictureLineSymbol
66
 *
67
 * Revision 1.9  2007/05/31 09:36:22  jaume
68
 * *** empty log message ***
69
 *
70
 * Revision 1.8  2007/05/29 15:47:06  jaume
71
 * *** empty log message ***
72
 *
73
 * Revision 1.7  2007/05/09 16:08:14  jaume
74
 * *** empty log message ***
75
 *
76
 * Revision 1.6  2007/05/08 15:44:07  jaume
77
 * *** empty log message ***
78
 *
79
 * Revision 1.5  2007/04/20 07:54:38  jaume
80
 * *** empty log message ***
81
 *
82
 * Revision 1.4  2007/03/28 16:44:08  jaume
83
 * *** empty log message ***
84
 *
85
 * Revision 1.3  2007/03/27 09:49:03  jaume
86
 * *** empty log message ***
87
 *
88
 * Revision 1.2  2007/03/09 11:25:00  jaume
89
 * Advanced symbology (start committing)
90
 *
91
 * Revision 1.1.2.4  2007/02/21 07:35:14  jaume
92
 * *** empty log message ***
93
 *
94
 * Revision 1.1.2.3  2007/02/09 11:00:03  jaume
95
 * *** empty log message ***
96
 *
97
 * Revision 1.1.2.2  2007/02/08 15:43:05  jaume
98
 * some bug fixes in the editor and removed unnecessary imports
99
 *
100
 * Revision 1.1.2.1  2007/01/26 13:49:03  jaume
101
 * *** empty log message ***
102
 *
103
 * Revision 1.1  2007/01/16 11:52:11  jaume
104
 * *** empty log message ***
105
 *
106
 * Revision 1.11  2007/01/10 17:05:05  jaume
107
 * moved to FMap and gvSIG
108
 *
109
 * Revision 1.10  2006/11/13 09:15:23  jaume
110
 * javadoc and some clean-up
111
 *
112
 * Revision 1.9  2006/11/06 17:08:45  jaume
113
 * *** empty log message ***
114
 *
115
 * Revision 1.8  2006/11/06 16:06:52  jaume
116
 * *** empty log message ***
117
 *
118
 * Revision 1.7  2006/11/06 07:33:54  jaume
119
 * javadoc, source style
120
 *
121
 * Revision 1.6  2006/11/02 17:19:28  jaume
122
 * *** empty log message ***
123
 *
124
 * Revision 1.5  2006/10/31 16:16:34  jaume
125
 * *** empty log message ***
126
 *
127
 * Revision 1.4  2006/10/30 19:30:35  jaume
128
 * *** empty log message ***
129
 *
130
 * Revision 1.3  2006/10/29 23:53:49  jaume
131
 * *** empty log message ***
132
 *
133
 * Revision 1.2  2006/10/27 12:41:09  jaume
134
 * GUI
135
 *
136
 * Revision 1.1  2006/10/26 16:31:21  jaume
137
 * GUI
138
 *
139
 *
140
 */
141 24
package org.gvsig.app.gui.styling;
142 25

  
143 26
import java.awt.BorderLayout;
......
151 34
import java.util.Hashtable;
152 35
import java.util.Iterator;
153 36
import java.util.List;
37
import java.util.Map;
154 38
import java.util.TreeSet;
155 39

  
156 40
import javax.swing.BorderFactory;
......
180 64
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
181 65
import org.gvsig.gui.beans.AcceptCancelPanel;
182 66
import org.gvsig.i18n.Messages;
67
import org.gvsig.symbology.swing.SymbologySwingLocator;
68
import org.gvsig.symbology.swing.SymbologySwingManager;
183 69

  
184 70
/**
185 71
 * Creates the panel that is used to control the properties of a symbol in
......
197 83
	private static final Logger LOG =
198 84
	    LoggerFactory.getLogger(SymbolEditor.class);
199 85
	
200
	private static Hashtable editorsByType;
201 86
	private WindowInfo wi;
202 87
	private JPanel pnlWest = null;
203 88
	private JPanel pnlCenter = null;
......
304 189
	 *
305 190
	 */
306 191
	private void initialize() {
307

  
192
                SymbologySwingManager symbologySwingManager = SymbologySwingLocator.getSwingManager();
308 193
		cmbTypeActionListener = new ActionListener() {
309 194
			int prevIndex = -2;
310 195

  
......
357 242

  
358 243

  
359 244
		TreeSet set = new TreeSet(tabComparator);
360
		List editors = getSymbolsByType(shapeType);
245
		List editors = symbologySwingManager.getSymbolEditorClassesByGeometryType(shapeType);
361 246
		Class[] constrLocator = new Class[] {SymbolEditor.class};
362 247
		Object[] constrInitargs = new Object[] { this };
363 248
		for (int i = 0; i < editors.size(); i++) {
......
703 588
		return cmbUnitsReferenceSystem.getSelectedIndex();
704 589
	}
705 590

  
706
	public static void addSymbolEditorPanel(Class abstractTypeSymbolEditorPanelClass, int shapeType) {
707
		if (editorsByType == null) {
708
			editorsByType = new Hashtable();
709
		}
710

  
711
		Integer key = new Integer(shapeType);
712
		ArrayList l = (ArrayList) editorsByType.get(key);
713
		if (l == null) {
714
			l = new ArrayList();
715
		}
716
		l.add(abstractTypeSymbolEditorPanelClass);
717

  
718
		editorsByType.put(key, l);
591
        /**
592
         * @deprecated use SymblogySwingManager
593
         */
594
	public static void addSymbolEditorPanel(Class<? extends TypeSymbolEditor> symbolEditor, int shapeType) {
595
            SymbologySwingManager manager = SymbologySwingLocator.getSwingManager();
596
            manager.registerSymbolEditor(symbolEditor, shapeType);
719 597
	}
720 598
	
599
        /**
600
         * @deprecated use SymblogySwingManager
601
         */
721 602
	private static List getSymbolsByType(GeometryType geometryType){
722
	    Iterator it = editorsByType.keySet().iterator();
723
	    while (it.hasNext()){
724
	        int currentType = (Integer)it.next();
725
	        if (geometryType.isTypeOf(currentType)){
726
	            return (List)editorsByType.get(currentType);
727
	        }
728
	    }
729
	    return new ArrayList();
603
            SymbologySwingManager manager = SymbologySwingLocator.getSwingManager();
604
            return manager.getSymbolEditorClassesByGeometryType(geometryType);
730 605
	}
731 606

  
732 607
	public Object getWindowProfile() {
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.symbology/org.gvsig.symbology.swing/org.gvsig.symbology.swing.api/src/main/java/org/gvsig/app/gui/styling/TypeSymbolEditor.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 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 3
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
package org.gvsig.app.gui.styling;
25

  
26
import javax.swing.JPanel;
27
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
28

  
29

  
30
public interface TypeSymbolEditor {
31

  
32
    boolean canManageSymbol(ISymbol symbol);
33

  
34
    /**
35
     * Returns the editor tools that are handled by this configuration panel.
36
     * @return <b>EditorTool</b>
37
     */
38
    EditorTool[] getEditorTools();
39

  
40
    /**
41
     * Produces and returns  the ISymbol according with the user settings.
42
     *
43
     * @return the ISymbol.
44
     */
45
    ISymbol getLayer();
46

  
47
    /**
48
     * <p>
49
     * Returns the name of the config tabs that will be shown in the selector combo box.
50
     * This is typically a human-readable (and also translatable) name for the symbol that
51
     * this TypeEditorPanel deals with, but maybe you prefer to use any other one.<br>
52
     * </p>
53
     * <p>
54
     * The order of the entries in the combo is alphabetically-based. So you can force a
55
     * position by defining a name that suits your needs.
56
     * </p>
57
     * @return A human-readable text naming this panel
58
     */
59
    String getName();
60

  
61
    /**
62
     * <p>
63
     * Due to the complexity that many symbols settings can reach, the SymbolEditorPanel is
64
     * designed in a tabbed-based fashion. So, you can use as many of pages you want to put
65
     * your components. This pages are regular JPanels that will be automatically added to
66
     * the SymbolEditor dialog.<br>
67
     * </p>
68
     * <p>
69
     * In case you need only one page, just return a JPanel array with a length of 1.
70
     * </p>
71
     * @return An array of JPanel containing the setting's interface.
72
     */
73
    JPanel[] getTabs();
74

  
75
    /**
76
     * Invoked when the user selects or adds a new layer. This method fills up
77
     * the components on the right according on the layer properties
78
     * @param <b>ISymbol</b> layer, the symbol
79
     */
80
    void refreshControls(ISymbol layer);
81
    
82
}
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.symbology/org.gvsig.symbology.swing/org.gvsig.symbology.swing.api/src/main/java/org/gvsig/app/project/documents/view/legend/gui/ILegendPanel.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 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 3
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
package org.gvsig.app.project.documents.view.legend.gui;
26

  
27
import javax.swing.ImageIcon;
28
import javax.swing.JPanel;
29

  
30
import org.gvsig.fmap.mapcontext.layers.FLayer;
31
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend;
32

  
33

  
34
/**
35
 * @author jaume dominguez faus - jaume.dominguez@iver.es
36
 *
37
 * Este interfaz es el que debe cumplir cualquier panel que empleemos
38
 * para confeccionar una leyenda. Se le pasa una capa para que
39
 * tome su leyenda, y con el m?todo getLegend tomamos la leyenda
40
 * que ha confeccionado el usuario.
41
 */
42
public interface ILegendPanel {
43
	/**
44
	 * Initializes the data required for this legend panel. That is, the layer that
45
	 * will adopt the changes and the current legend that this layer has. If the
46
	 * legend is not the type of legend that this panel manages then it initializes
47
	 * the panel with the default values. In case it is, then the panel should
48
	 * refresh its components with the current values of the Legend.
49
	 * @param lyr,  target layer
50
	 * @param legend, the legend currently applied to lyr
51
	 */
52
	public void setData(FLayer lyr, ILegend legend);
53

  
54
	/**
55
	 * Returns an instance of Legend
56
	 * @return Legend, the legend result of the settings
57
	 */
58
	public ILegend getLegend();
59

  
60
	/**
61
	 * Returns a brief human-readable description about what kind of legend builds this panel
62
	 * @return String with a brief description
63
	 */
64
	public String getDescription();
65

  
66
	/**
67
	 * Returns the icon which should graphically describe what this panel's legend does.
68
	 * @return ImageIcon with the icon to be displayed
69
	 */
70
	public ImageIcon getIcon();
71

  
72
	/**
73
	 * If this panel should appear as a subnode of the legends tree, in other words it is not
74
	 * a first-level node, then this method would return <b>its parent's class</b>. Otherwise, if
75
	 * it is a first-level node, then it will return <b>null</b>.
76
	 * @return String containing the parent's title.
77
	 */
78
	public Class getParentClass();
79

  
80
	/**
81
	 * Returns the title (a human-readable one) of this panel.
82
	 */
83
	public String getTitle();
84

  
85
	/**
86
	 * <p>If this is a complete panel (it is a child node in the legend tree) to set up a legend
87
	 * this method will return a <b>JPanel</b> containing the necessary components. Otherwise, if
88
	 * it is just a classification node (it has children) in the legend tree it will return
89
	 * just <b>null</b>.<br></p>
90
	 *
91
	 * <p>If <b>null</b> is returned, the ILegendPanel that will be shown and selected each time
92
	 * it is selected is the very first child of this parent node.</p>
93
	 */
94
	public JPanel getPanel();
95

  
96
	/**
97
	 * Returns the class of the legend produced by this ILegendPanel.
98
	 */
99
	public Class getLegendClass();
100

  
101
	/**
102
	 * Returns <b>true</b> if this legend is applicable to this layer, <b>false</b> otherwise.
103
	 */
104
	public boolean isSuitableFor(FLayer layer);
105
}
106

  
0 107

  
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.symbology/org.gvsig.symbology.swing/org.gvsig.symbology.swing.api/src/main/java/org/gvsig/app/project/documents/view/legend/gui/ILabelingStrategyPanel.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 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 3
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
package org.gvsig.app.project.documents.view.legend.gui;
25

  
26
import org.gvsig.fmap.mapcontext.layers.FLayer;
27
import org.gvsig.fmap.mapcontext.rendering.legend.styling.ILabelingStrategy;
28

  
29

  
30
/**
31
 * Interface to be implemented for those panels whose purpose is to
32
 * set up labeling strategies.
33
 *
34
 * ILabelingStrategyPanel.java
35
 *
36
 *
37
 * @author jaume dominguez faus - jaume.dominguez@iver.es Jun 13, 2008
38
 *
39
 */
40
public interface ILabelingStrategyPanel {
41
	/**
42
	 * Invoked when de user accepts the settings, the returned value
43
	 * is a always ready-to-work labeling strategy.
44
	 *
45
	 * @return ILabelingStrategy, a labeling strategy completely set up.
46
	 */
47
	public ILabelingStrategy getLabelingStrategy();
48

  
49
	/**
50
	 * Sets the model of the panel. As a general contract, after invoke
51
	 * this method, the panel should be filled with all the values
52
	 * needed and be able to be repainted successfully.
53
	 *
54
	 * @param layer, the layer to whom the labeling strategy is associated.
55
	 * @param str, the current labeling strategy.
56
	 */
57
	public void setModel(FLayer layer, ILabelingStrategy str);
58

  
59
	/**
60
	 * A human-readable localized text to make this strategy easily
61
	 * recognizable among all the available strategies.
62
	 * @return
63
	 */
64
	public String getLabelingStrategyName();
65

  
66
	/**
67
	 * <p>
68
	 * The panel shown in the layer properties dialog is selected through
69
	 * the class of the labeling strategy. This method returns such class.
70
	 * <br>
71
	 * </p>
72
	 * <p>
73
	 * <b>Note</b> that, as a collateral effect, the panel that sets up a labeling strategy
74
	 * can be substituted programatically by other of your wish if
75
	 * you return the same labeling strategy class than the one to
76
	 * be replaced with your new one. The last panel installed, will
77
	 * be the one to be shown.
78
	 * </p>
79
	 * @return Class, the labeling strategy's Class
80
	 */
81
	public Class getLabelingStrategyClass();
82
}
0 83

  
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.symbology/org.gvsig.symbology.swing/org.gvsig.symbology.swing.api/src/main/java/org/gvsig/symbology/swing/SymbologySwingManager.java
24 24
package org.gvsig.symbology.swing;
25 25

  
26 26
import java.util.List;
27
import org.gvsig.app.gui.styling.TypeSymbolEditor;
28
import org.gvsig.app.project.documents.view.legend.gui.ILabelingStrategyPanel;
29
import org.gvsig.app.project.documents.view.legend.gui.ILegendPanel;
30
import org.gvsig.fmap.geom.type.GeometryType;
31
import org.gvsig.fmap.mapcontext.layers.FLayer;
27 32

  
28 33
import org.gvsig.gui.ColorTablePainter;
29 34
import org.gvsig.gui.ColorTablesFactory;
......
82 87
    public ColorTablesFactory getColorTablesFactory();
83 88
    
84 89
    public List<ColorTablePainter> createColorTables();
90
    
91
    public void registerSymbolEditor(Class<? extends TypeSymbolEditor> symbolEditor, int shapeType);
92
    
93
    public List<Class<? extends TypeSymbolEditor>> getSymbolEditorClassesByGeometryType(GeometryType geometryType);
94
    
95
    public void registerLegendEditor(Class<? extends ILegendPanel> legendEditor);
96
    
97
    public List<Class<? extends ILegendPanel>> getLegendEditorClasses();
98
    
99
    public List<ILegendPanel> getLegendEditors(FLayer layer);
100
    
101
    public void registerLabelingEditor(Class<? extends ILabelingStrategyPanel> labelingEditor);
102
    
103
    public List<ILabelingStrategyPanel> getLabelingEditors();
85 104
}

Also available in: Unified diff