Revision 28610
trunk/extensions/extAnnotations/src/com/iver/cit/gvsig/project/documents/view/legend/preferences/Annotation_Preferences.java | ||
---|---|---|
43 | 43 |
|
44 | 44 |
import java.awt.Color; |
45 | 45 |
import java.awt.Font; |
46 |
import java.awt.GridBagLayout; |
|
46 |
import java.awt.GridBagConstraints; |
|
47 |
import java.awt.Insets; |
|
47 | 48 |
|
48 | 49 |
import javax.swing.ImageIcon; |
49 | 50 |
import javax.swing.JLabel; |
50 | 51 |
import javax.swing.JPanel; |
51 | 52 |
import javax.swing.JTextField; |
52 |
import javax.swing.border.TitledBorder; |
|
53 | 53 |
|
54 | 54 |
import com.iver.andami.PluginServices; |
55 | 55 |
import com.iver.andami.preferences.AbstractPreferencePage; |
... | ... | |
57 | 57 |
import com.iver.cit.gvsig.fmap.layers.Annotation_Mapping; |
58 | 58 |
import com.iver.cit.gvsig.gui.panels.ColorChooserPanel; |
59 | 59 |
import com.iver.cit.gvsig.project.documents.view.gui.FontOptions; |
60 |
import com.iver.cit.gvsig.project.documents.view.tool.gui.TextPropertiesPanel; |
|
60 | 61 |
import com.iver.utiles.swing.JComboBox; |
61 | 62 |
/** |
62 | 63 |
* Default configuration page. |
... | ... | |
77 | 78 |
private JTextField txtDefaultRotate; |
78 | 79 |
private JTextField txtDefaultHeight; |
79 | 80 |
private ColorChooserPanel jccDefaultColor; |
80 |
// private JSlider jsDefaultColorAlpha;
|
|
81 |
private static boolean panelStarted = false; |
|
81 |
private TextPropertiesPanel panel = null;
|
|
82 |
|
|
82 | 83 |
|
83 | 84 |
/** |
84 | 85 |
* Creates a new panel containing View preferences settings. |
... | ... | |
90 | 91 |
} |
91 | 92 |
|
92 | 93 |
public void initializeValues() { |
93 |
if (!panelStarted) getPanel(); |
|
94 |
|
|
94 |
getPanel(); // init UI |
|
95 | 95 |
txtDefaultText.setText(Annotation_Mapping.DEFAULTTEXT); |
96 |
cmbDefaultTypeFont.setSelectedItem(Annotation_Mapping.DEFAULTTYPEFONT);
|
|
97 |
String style=FontOptions.getFontStyles()[Annotation_Mapping.DEFAULTSTYLEFONT];
|
|
98 |
cmbDefaultStyleFont.setSelectedItem(style);
|
|
96 |
panel.setFontType(Annotation_Mapping.DEFAULTTYPEFONT);
|
|
97 |
panel.setFontStyle(Annotation_Mapping.DEFAULTSTYLEFONT);
|
|
98 |
panel.setTextHeight(Annotation_Mapping.DEFAULTHEIGHT);
|
|
99 | 99 |
Color color=new Color(Annotation_Mapping.DEFAULTCOLOR); |
100 |
jccDefaultColor.setColor(color); |
|
101 |
jccDefaultColor.setAlpha(color.getAlpha()); |
|
102 |
txtDefaultHeight.setText(String.valueOf(Annotation_Mapping.DEFAULTHEIGHT)); |
|
103 |
txtDefaultRotate.setText(String.valueOf(Annotation_Mapping.DEFAULTROTATE)); |
|
100 |
panel.setColor(color); |
|
101 |
panel.setRotation(Annotation_Mapping.DEFAULTROTATE); |
|
104 | 102 |
} |
105 | 103 |
|
106 | 104 |
public String getID() { |
... | ... | |
112 | 110 |
} |
113 | 111 |
|
114 | 112 |
public JPanel getPanel() { |
115 |
if (panelStarted) return this; |
|
116 |
panelStarted = true; |
|
117 |
|
|
118 |
// just a separator |
|
119 |
addComponent(new JLabel(" ")); |
|
120 |
|
|
121 |
addComponent(new JLabel(PluginServices.getText(this,"change_options_of_annotations"))); |
|
122 |
|
|
123 |
JPanel optionsPanel = new JPanel(); |
|
124 |
optionsPanel.setBorder(new TitledBorder(PluginServices.getText(this, "options.annotations"))); |
|
125 |
optionsPanel.setLayout(new GridBagLayout()); |
|
126 |
|
|
127 |
addComponent(new JLabel(PluginServices.getText(this,"text")), |
|
128 |
txtDefaultText = new JTextField()); |
|
129 |
|
|
130 |
addComponent(new JLabel(PluginServices.getText(this,"fonttype")), |
|
131 |
cmbDefaultTypeFont = new JComboBox()); |
|
132 |
String[] types=FontOptions.getFontTypes(); |
|
133 |
for (int i=0;i<types.length;i++){ |
|
134 |
cmbDefaultTypeFont.addItem(types[i]); |
|
135 |
} |
|
136 |
cmbDefaultTypeFont.setSelectedItem(FontOptions.ARIAL); |
|
137 |
addComponent(new JLabel(PluginServices.getText(this,"fontstyle")), |
|
138 |
cmbDefaultStyleFont = new JComboBox()); |
|
139 |
String[] styles=FontOptions.getFontStyles(); |
|
140 |
for (int i=0;i<styles.length;i++){ |
|
141 |
cmbDefaultStyleFont.addItem(styles[i]); |
|
142 |
} |
|
143 |
cmbDefaultStyleFont.setSelectedItem(FontOptions.PLAIN); |
|
144 |
addComponent(new JLabel(PluginServices.getText(this,"fontheight")), |
|
145 |
txtDefaultHeight = new JTextField()); |
|
146 |
|
|
147 |
addComponent(new JLabel(PluginServices.getText(this,"fontrotate")), |
|
148 |
txtDefaultRotate = new JTextField()); |
|
149 |
|
|
150 |
addComponent(new JLabel(PluginServices.getText(this,"fontcolor")), |
|
151 |
jccDefaultColor = new ColorChooserPanel()); |
|
152 |
// jsDefaultColorAlpha = new JSlider()); |
|
153 |
|
|
154 |
//addComponent(optionsPanel); |
|
155 |
addComponent(new JLabel(" ")); |
|
156 |
|
|
157 |
initializeValues(); |
|
158 |
return this; |
|
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; |
|
159 | 120 |
} |
160 | 121 |
|
161 | 122 |
public void storeValues() throws StoreException { |
162 |
Color fontColor=jccDefaultColor.getColor();
|
|
123 |
Color fontColor=panel.getColor();
|
|
163 | 124 |
String text=txtDefaultText.getText(); |
164 |
String fontType=(String)cmbDefaultTypeFont.getSelectedItem(); |
|
165 |
int fontStyle=cmbDefaultStyleFont.getSelectedIndex(); |
|
166 |
int fontHeight=Integer.parseInt(txtDefaultHeight.getText()); |
|
167 |
int fontRotate=Integer.parseInt(txtDefaultRotate.getText()); |
|
168 |
|
|
125 |
String fontType = panel.getFontType(); |
|
126 |
int fontStyle = panel.getFontStyle(); |
|
127 |
int fontHeight = (int) panel.getTextHeight(); |
|
128 |
int fontRotate= (int) panel.getRotation(); |
|
169 | 129 |
Annotation_Mapping.storeValues(fontColor,text,fontType,fontStyle,fontHeight,fontRotate); |
170 | 130 |
} |
171 | 131 |
|
172 | 132 |
|
173 | 133 |
public void initializeDefaults() { |
174 |
Color fontColor=Color.black; |
|
175 |
String text=""; |
|
176 | 134 |
String fontType=FontOptions.ARIAL; |
177 | 135 |
int fontStyle=Font.PLAIN; |
178 | 136 |
int fontHeight=10; |
137 |
Color fontColor=Color.black; |
|
179 | 138 |
int fontRotate=0; |
139 |
String text=""; |
|
180 | 140 |
|
181 |
jccDefaultColor.setColor(fontColor); |
|
182 |
// jsDefaultColorAlpha.setValue(fontColor.getAlpha()); |
|
183 |
|
|
141 |
panel.setFontType(fontType); |
|
142 |
panel.setFontStyle(fontStyle); |
|
143 |
panel.setTextHeight(fontHeight); |
|
144 |
panel.setColor(fontColor); |
|
145 |
panel.setRotation(fontRotate); |
|
184 | 146 |
txtDefaultText.setText(text); |
185 |
cmbDefaultTypeFont.setSelectedItem(fontType); |
|
186 |
cmbDefaultStyleFont.setSelectedItem(FontOptions.PLAIN); |
|
187 |
txtDefaultHeight.setText(String.valueOf(fontHeight)); |
|
188 |
txtDefaultRotate.setText(String.valueOf(fontRotate)); |
|
189 |
|
|
147 |
|
|
190 | 148 |
Annotation_Mapping.DEFAULTCOLOR=fontColor.getRGB(); |
191 | 149 |
Annotation_Mapping.DEFAULTTEXT=text; |
192 | 150 |
Annotation_Mapping.DEFAULTTYPEFONT=fontType; |
Also available in: Unified diff