3 |
3 |
*/
|
4 |
4 |
package org.gvsig.iver.extensions.coords;
|
5 |
5 |
|
6 |
|
import java.awt.Dimension;
|
|
6 |
import java.awt.event.ActionEvent;
|
|
7 |
import java.awt.event.ActionListener;
|
7 |
8 |
|
8 |
|
import javax.swing.BorderFactory;
|
9 |
|
import javax.swing.border.BevelBorder;
|
10 |
|
|
11 |
9 |
import org.apache.log4j.Logger;
|
|
10 |
import org.gvsig.gui.beans.controls.combolabel.ComboCoords;
|
12 |
11 |
|
13 |
12 |
import com.iver.andami.PluginServices;
|
14 |
13 |
import com.iver.andami.messages.Messages;
|
15 |
14 |
import com.iver.andami.plugins.Extension;
|
16 |
15 |
import com.iver.andami.plugins.IExtension;
|
|
16 |
import com.iver.cit.gvsig.project.documents.ProjectDocument;
|
|
17 |
import com.iver.cit.gvsig.project.documents.view.IProjectView;
|
17 |
18 |
import com.iver.cit.gvsig.project.documents.view.gui.View;
|
18 |
19 |
|
19 |
20 |
/**
|
20 |
21 |
* @author cesar
|
21 |
22 |
*
|
22 |
23 |
*/
|
23 |
|
public class CoordsExtension extends Extension {
|
|
24 |
public class CoordsExtension extends Extension implements ActionListener {
|
24 |
25 |
private Logger logger = PluginServices.getLogger();
|
25 |
26 |
private String CONTROLNAME = "coords";
|
26 |
|
private Label unitsLabel = null;
|
27 |
|
private Label projectionLabel = null;
|
|
27 |
private ComboCoords coordsControl;
|
|
28 |
private String axisText0 = "X = ";
|
|
29 |
private String axisText1 = "Y =";
|
28 |
30 |
|
29 |
31 |
/* (non-Javadoc)
|
30 |
32 |
* @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
|
... | ... | |
36 |
38 |
|
37 |
39 |
if (actionCommand.startsWith("CHANGE_UNITS")){
|
38 |
40 |
System.out.println("CoordsExtension -- CHANGE_UNITS");
|
39 |
|
/* View view = (View)activeWindow;
|
40 |
|
IProjectView model = view.getModel();
|
41 |
|
DistanceUnitsConfig duc=new DistanceUnitsConfig(model);
|
42 |
|
PluginServices.getMDIManager().addWindow(duc);
|
43 |
|
((ProjectDocument)view.getModel()).setModified(true); */
|
|
41 |
View view = (View)activeWindow;
|
|
42 |
IProjectView model = view.getModel();
|
|
43 |
DistanceUnitsConfig duc=new DistanceUnitsConfig(model);
|
|
44 |
PluginServices.getMDIManager().addWindow(duc);
|
44 |
45 |
}
|
45 |
46 |
}
|
46 |
47 |
|
... | ... | |
51 |
52 |
PluginServices.getMainFrame().removeStatusBarLabels(com.iver.cit.gvsig.project.documents.view.gui.View.class);
|
52 |
53 |
|
53 |
54 |
// add the new control
|
54 |
|
org.gvsig.gui.beans.controls.combolabel.ComboCoords combo = new org.gvsig.gui.beans.controls.combolabel.ComboCoords();
|
55 |
|
combo.setName(CONTROLNAME);
|
|
55 |
coordsControl = new org.gvsig.gui.beans.controls.combolabel.ComboCoords();
|
|
56 |
coordsControl.setLabelX(axisText0);
|
|
57 |
coordsControl.setLabelY(axisText1);
|
|
58 |
coordsControl.addActionListener(this);
|
|
59 |
coordsControl.setName(CONTROLNAME);
|
56 |
60 |
try {
|
57 |
|
PluginServices.getMainFrame().addStatusBarControl(getClass().getClassLoader().loadClass(getClass().getName()),combo);
|
58 |
|
PluginServices.getMainFrame().addStatusBarControl(getClass().getClassLoader().loadClass(getClass().getName()),getUnitsLabel());
|
59 |
|
PluginServices.getMainFrame().addStatusBarControl(getClass().getClassLoader().loadClass(getClass().getName()),getProjectionLabel());
|
|
61 |
PluginServices.getMainFrame().addStatusBarControl(getClass().getClassLoader().loadClass(getClass().getName()),coordsControl);
|
|
62 |
PluginServices.getMainFrame().setStatusBarLabels(com.iver.cit.gvsig.project.documents.view.gui.View.class, getLabelSet());
|
60 |
63 |
} catch (ClassNotFoundException e1) {
|
61 |
64 |
logger.error(Messages.getString("Launcher.error_getting_class_loader_for_status_bar_control"), e1);
|
62 |
65 |
}
|
... | ... | |
78 |
81 |
return extension.isVisible();
|
79 |
82 |
}
|
80 |
83 |
|
81 |
|
private Label getLabel(int width) {
|
82 |
|
Label lbl = new Label();
|
83 |
|
lbl.setPreferredSize(new Dimension(width, PluginServices.getMainFrame().getStatusBar().getHeight()-2));
|
84 |
|
lbl.setSize(new Dimension(width, PluginServices.getMainFrame().getStatusBar().getHeight()-2));
|
85 |
|
lbl.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
|
86 |
|
return lbl;
|
|
84 |
private com.iver.andami.plugins.config.generate.Label[] getLabelSet() {
|
|
85 |
com.iver.andami.plugins.config.generate.Label unitsLabel = new com.iver.andami.plugins.config.generate.Label();
|
|
86 |
unitsLabel.setSize(85);
|
|
87 |
unitsLabel.setId("units");
|
|
88 |
com.iver.andami.plugins.config.generate.Label projectionLabel = new com.iver.andami.plugins.config.generate.Label();
|
|
89 |
projectionLabel.setSize(85);
|
|
90 |
projectionLabel.setId("projection");
|
|
91 |
com.iver.andami.plugins.config.generate.Label[] labels = new com.iver.andami.plugins.config.generate.Label[2];
|
|
92 |
labels[0]=unitsLabel;
|
|
93 |
labels[1]=projectionLabel;
|
|
94 |
return labels;
|
87 |
95 |
}
|
88 |
|
|
89 |
|
public Label getUnitsLabel() {
|
90 |
|
if (unitsLabel!=null)
|
91 |
|
return unitsLabel;
|
92 |
|
unitsLabel = getLabel(85);
|
93 |
|
return unitsLabel;
|
|
96 |
|
|
97 |
public void actionPerformed(ActionEvent e) {
|
94 |
98 |
}
|
95 |
99 |
|
96 |
|
public Label getProjectionLabel() {
|
97 |
|
if (projectionLabel!=null)
|
98 |
|
return projectionLabel;
|
99 |
|
projectionLabel = getLabel(85);
|
100 |
|
return projectionLabel;
|
101 |
|
}
|
102 |
100 |
}
|