Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extAnnotations / src / com / iver / cit / gvsig / project / documents / view / legend / preferences / Annotation_Preferences.java @ 28610

History | View | Annotate | Download (4.79 KB)

1
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib��ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41

    
42
package com.iver.cit.gvsig.project.documents.view.legend.preferences;
43

    
44
import java.awt.Color;
45
import java.awt.Font;
46
import java.awt.GridBagConstraints;
47
import java.awt.Insets;
48

    
49
import javax.swing.ImageIcon;
50
import javax.swing.JLabel;
51
import javax.swing.JPanel;
52
import javax.swing.JTextField;
53

    
54
import com.iver.andami.PluginServices;
55
import com.iver.andami.preferences.AbstractPreferencePage;
56
import com.iver.andami.preferences.StoreException;
57
import com.iver.cit.gvsig.fmap.layers.Annotation_Mapping;
58
import com.iver.cit.gvsig.gui.panels.ColorChooserPanel;
59
import com.iver.cit.gvsig.project.documents.view.gui.FontOptions;
60
import com.iver.cit.gvsig.project.documents.view.tool.gui.TextPropertiesPanel;
61
import com.iver.utiles.swing.JComboBox;
62
/**
63
 *  Default configuration page.
64
 *  <b><b>
65
 *  Here the user can establish what settings wants to use by default annotations.
66
 *
67
 *
68
 * @author Vicente Caballero Navarro
69
 */
70
public class Annotation_Preferences extends AbstractPreferencePage {
71

    
72

    
73
        protected String id;
74
        private ImageIcon icon;
75
        private JTextField txtDefaultText;
76
        private JComboBox cmbDefaultTypeFont;
77
        private JComboBox cmbDefaultStyleFont;
78
        private JTextField txtDefaultRotate;
79
        private JTextField txtDefaultHeight;
80
        private ColorChooserPanel jccDefaultColor;
81
        private TextPropertiesPanel panel = null;
82
        
83

    
84
        /**
85
         * Creates a new panel containing View preferences settings.
86
         *
87
         */
88
        public Annotation_Preferences() {
89
                super();
90
                id = this.getClass().getName();
91
        }
92

    
93
        public void initializeValues() {
94
                getPanel(); // init UI
95
                txtDefaultText.setText(Annotation_Mapping.DEFAULTTEXT);
96
                panel.setFontType(Annotation_Mapping.DEFAULTTYPEFONT);
97
                panel.setFontStyle(Annotation_Mapping.DEFAULTSTYLEFONT);
98
                panel.setTextHeight(Annotation_Mapping.DEFAULTHEIGHT);
99
                Color color=new Color(Annotation_Mapping.DEFAULTCOLOR);
100
                panel.setColor(color);
101
                panel.setRotation(Annotation_Mapping.DEFAULTROTATE);                
102
        }
103

    
104
        public String getID() {
105
                return id;
106
        }
107

    
108
        public String getTitle() {
109
                return PluginServices.getText(this, "annotation_preferences");
110
        }
111

    
112
        public JPanel getPanel() {
113
                        if (panel==null) {
114
                                addComponent(new JLabel(PluginServices.getText(this,"text")),
115
                                                txtDefaultText = new JTextField(), GridBagConstraints.BOTH, new Insets(4,0,4,8));
116
                                panel = new TextPropertiesPanel();
117
                                addComponent(panel);
118
                        }
119
                        return this;
120
        }
121

    
122
        public void storeValues() throws StoreException {
123
                Color fontColor=panel.getColor();
124
                String text=txtDefaultText.getText();
125
                String fontType = panel.getFontType();
126
                int fontStyle = panel.getFontStyle();
127
                int fontHeight =  (int) panel.getTextHeight();
128
                int fontRotate= (int) panel.getRotation();
129
                Annotation_Mapping.storeValues(fontColor,text,fontType,fontStyle,fontHeight,fontRotate);
130
        }
131

    
132

    
133
        public void initializeDefaults() {
134
                String fontType=FontOptions.ARIAL;
135
                int fontStyle=Font.PLAIN;
136
                int fontHeight=10;
137
                Color fontColor=Color.black;
138
                int fontRotate=0;
139
                String text="";
140

    
141
                panel.setFontType(fontType);
142
                panel.setFontStyle(fontStyle);
143
                panel.setTextHeight(fontHeight);
144
                panel.setColor(fontColor);
145
                panel.setRotation(fontRotate);
146
                txtDefaultText.setText(text);
147
                
148
                Annotation_Mapping.DEFAULTCOLOR=fontColor.getRGB();
149
                Annotation_Mapping.DEFAULTTEXT=text;
150
                Annotation_Mapping.DEFAULTTYPEFONT=fontType;
151
                Annotation_Mapping.DEFAULTSTYLEFONT=fontStyle;
152
                Annotation_Mapping.DEFAULTHEIGHT=fontHeight;
153
                Annotation_Mapping.DEFAULTROTATE=fontRotate;
154
        }
155

    
156
        public ImageIcon getIcon() {
157
                if (icon==null)
158
                        icon=PluginServices.getIconTheme().get("annotation-properties");
159
                return icon;
160
        }
161

    
162
        public boolean isValueChanged() {
163
                return super.hasChanged();
164
        }
165

    
166
        public void setChangesApplied() {
167
                setChanged(false);
168
        }
169
}