Revision 1942 org.gvsig.legend.aggregate/trunk/org.gvsig.legend.aggregate/org.gvsig.legend.aggregate.swing/org.gvsig.legend.aggregate.swing.impl/src/main/java/org/gvsig/legend/aggregate/swing/impl/DefaultAggregateLegendEditor.java
DefaultAggregateLegendEditor.java | ||
---|---|---|
2 | 2 |
package org.gvsig.legend.aggregate.swing.impl; |
3 | 3 |
|
4 | 4 |
import java.awt.Dimension; |
5 |
import java.awt.Font; |
|
5 | 6 |
import java.awt.event.ActionEvent; |
6 | 7 |
import java.awt.event.ActionListener; |
7 | 8 |
import java.awt.event.ItemEvent; |
... | ... | |
34 | 35 |
import org.gvsig.tools.i18n.I18nManager; |
35 | 36 |
import org.gvsig.tools.swing.api.ColorChooserController; |
36 | 37 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
38 |
import org.gvsig.tools.swing.api.windowmanager.Dialog; |
|
37 | 39 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
38 | 40 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager_v2; |
39 | 41 |
import org.gvsig.tools.swing.icontheme.IconTheme; |
42 |
import org.jfree.ui.FontChooserPanel; |
|
40 | 43 |
|
41 | 44 |
|
42 | 45 |
public class DefaultAggregateLegendEditor extends DefaultAggregateLegendEditorView implements AggregateLegendEditor { |
... | ... | |
50 | 53 |
private ColorChooserController outlineColor; |
51 | 54 |
private ColorChooserController fillColor; |
52 | 55 |
private ColorChooserController textColor; |
56 |
private Font font; |
|
53 | 57 |
|
54 | 58 |
public DefaultAggregateLegendEditor() { |
55 | 59 |
this.legendClass = AggregateLegendLocator.getAggregateLegendManager().getLegendClass(); |
... | ... | |
152 | 156 |
this.fillColor.set(this.legend.getFillColor()); |
153 | 157 |
this.textColor.set(this.legend.getTextColor()); |
154 | 158 |
this.chkShowBounds.setSelected(this.legend.isShowBounds()); |
155 |
this.txtTextFont.setText(this.legend.getFont().getFontName()); |
|
159 |
this.font = this.legend.getFont(); |
|
160 |
this.txtTextFont.setText(getFontLabel(font)); |
|
156 | 161 |
if( this.legend.getLabelStyle()!=null ) { |
157 | 162 |
this.txtStyle.setText(this.legend.getLabelStyle().getDescription()); |
158 | 163 |
} |
... | ... | |
195 | 200 |
legend.setTextColor(this.textColor.get()); |
196 | 201 |
legend.setShowBounds(this.chkShowBounds.isSelected()); |
197 | 202 |
legend.setLabelStyle(this.style); |
203 |
legend.setFont(this.font); |
|
198 | 204 |
Operation operation = (Operation) this.cboOperation.getSelectedItem(); |
199 | 205 |
if( operation!=null ) { |
200 | 206 |
operation = operation.clone(); |
... | ... | |
249 | 255 |
} |
250 | 256 |
|
251 | 257 |
private void showFontChooser() { |
258 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
259 |
WindowManager_v2 winmgr = (WindowManager_v2) ToolsSwingLocator.getWindowManager(); |
|
252 | 260 |
|
261 |
final FontChooserPanel fontChooser = new FontChooserPanel(font); |
|
262 |
// fontChooser.setPreferredSize(new Dimension(500,350)); |
|
263 |
final Dialog dialog = winmgr.createDialog( |
|
264 |
fontChooser, |
|
265 |
i18n.getTranslation("_Select_font"), |
|
266 |
null, |
|
267 |
WindowManager_v2.BUTTONS_OK_CANCEL |
|
268 |
); |
|
269 |
dialog.addActionListener(new ActionListener() { |
|
270 |
@Override |
|
271 |
public void actionPerformed(ActionEvent e) { |
|
272 |
if( dialog.getAction() == WindowManager_v2.BUTTONS_OK ) { |
|
273 |
font = fontChooser.getSelectedFont(); |
|
274 |
txtTextFont.setText(getFontLabel(font)); |
|
275 |
} |
|
276 |
} |
|
277 |
}); |
|
278 |
dialog.show(WindowManager.MODE.DIALOG); |
|
253 | 279 |
} |
280 |
|
|
281 |
private String getFontLabel(Font font) { |
|
282 |
StringBuilder b = new StringBuilder(); |
|
283 |
b.append(font.getFontName()); |
|
284 |
b.append(", "); |
|
285 |
b.append(font.getSize()); |
|
286 |
return b.toString(); |
|
287 |
} |
|
254 | 288 |
|
255 | 289 |
@Override |
256 | 290 |
public String getDescription() { |
Also available in: Unified diff