Revision 627
org.gvsig.proj/trunk/org.gvsig.proj/org.gvsig.proj.lib/org.gvsig.proj.lib.api/src/main/java/org/gvsig/proj/cts/DefaultIProjection.java | ||
---|---|---|
69 | 69 |
this.crs = crs; |
70 | 70 |
} |
71 | 71 |
|
72 |
@Override |
|
72 | 73 |
public IDatum getDatum() { |
73 | 74 |
return new IDatum() { |
74 | 75 |
|
76 |
@Override |
|
75 | 77 |
public double getEIFlattening() { |
76 | 78 |
return getCoordinateReferenceSystem().getDatum().getEllipsoid() |
77 | 79 |
.getReciprocalFlattening(); |
78 | 80 |
} |
79 | 81 |
|
82 |
@Override |
|
80 | 83 |
public double getESemiMajorAxis() { |
81 | 84 |
return getCoordinateReferenceSystem().getDatum().getEllipsoid() |
82 | 85 |
.getSemiMajorAxis(); |
... | ... | |
85 | 88 |
}; |
86 | 89 |
} |
87 | 90 |
|
91 |
@Override |
|
88 | 92 |
public Point2D createPoint(double x, double y) { |
89 | 93 |
return new Point2D.Double(x, y); |
90 | 94 |
} |
91 | 95 |
|
96 |
@Override |
|
92 | 97 |
public String getAbrev() { |
93 | 98 |
return getCoordinateReferenceSystem().getReference(); |
94 | 99 |
} |
95 | 100 |
|
101 |
@Override |
|
96 | 102 |
public String getFullCode() { |
97 | 103 |
return getCoordinateReferenceSystem().getReference(); |
98 | 104 |
} |
99 | 105 |
|
106 |
@Override |
|
100 | 107 |
public void drawGrid(Graphics2D g, ViewPortData vp) { |
101 | 108 |
throw new UnsupportedOperationException("Not implemented"); |
102 | 109 |
} |
103 | 110 |
|
111 |
@Override |
|
104 | 112 |
public void setGridColor(Color gridColor) { |
105 | 113 |
throw new UnsupportedOperationException("Not implemented"); |
106 | 114 |
} |
107 | 115 |
|
116 |
@Override |
|
108 | 117 |
public Color getGridColor() { |
109 | 118 |
throw new UnsupportedOperationException("Not implemented"); |
110 | 119 |
} |
111 | 120 |
|
121 |
@Override |
|
112 | 122 |
public ICoordTrans getCT(IProjection dest) { |
113 | 123 |
return new DefaultICoordTrans(this, (DefaultIProjection) dest); |
114 | 124 |
} |
115 | 125 |
|
126 |
@Override |
|
116 | 127 |
public Point2D toGeo(Point2D pt) { |
117 | 128 |
CoordinateReferenceSystem geographic = crs.createGeographic(); |
118 | 129 |
|
... | ... | |
124 | 135 |
return new Point2D.Double(coords[0], coords[1]); |
125 | 136 |
} |
126 | 137 |
|
138 |
@Override |
|
127 | 139 |
public Point2D fromGeo(Point2D gPt, Point2D mPt) { |
128 | 140 |
CoordinateReferenceSystem geographic = crs.createGeographic(); |
129 | 141 |
|
... | ... | |
136 | 148 |
return mPt; |
137 | 149 |
} |
138 | 150 |
|
151 |
@Override |
|
139 | 152 |
public double getScale(double minX, double maxX, double width, double dpi) { |
140 | 153 |
double scale = ((maxX - minX) * // metros |
141 | 154 |
(dpi / 2.54 * 100.0)) |
... | ... | |
144 | 157 |
return scale; |
145 | 158 |
} |
146 | 159 |
|
160 |
@Override |
|
147 | 161 |
public Rectangle2D getExtent(Rectangle2D extent, double scale, |
148 | 162 |
double wImage, double hImage, double mapUnits, double distanceUnits, |
149 | 163 |
double dpi) { |
... | ... | |
163 | 177 |
return rec; |
164 | 178 |
} |
165 | 179 |
|
180 |
@Override |
|
166 | 181 |
public boolean isProjected() { |
167 | 182 |
return getCoordinateReferenceSystem().isProjected(); |
168 | 183 |
} |
169 | 184 |
|
185 |
@Override |
|
170 | 186 |
public Object clone() throws CloneNotSupportedException { |
171 | 187 |
DefaultIProjection cloned = (DefaultIProjection) super.clone(); |
172 | 188 |
cloned.crs |
... | ... | |
179 | 195 |
return crs; |
180 | 196 |
} |
181 | 197 |
|
198 |
@Override |
|
182 | 199 |
public String toString() { |
183 | 200 |
return crs.toString(); |
184 | 201 |
} |
185 | 202 |
|
203 |
@Override |
|
186 | 204 |
public String export(String format) { |
187 |
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
|
205 |
return null;
|
|
188 | 206 |
} |
189 | 207 |
|
208 |
@Override |
|
190 | 209 |
public boolean equals(Object obj) { |
191 | 210 |
if (this == obj) { |
192 | 211 |
return true; |
... | ... | |
197 | 216 |
return this.getFullCode().equalsIgnoreCase(((DefaultIProjection) obj).getFullCode()); |
198 | 217 |
} |
199 | 218 |
|
219 |
@Override |
|
200 | 220 |
public int hashCode() { |
201 | 221 |
return this.getFullCode().hashCode(); |
202 | 222 |
} |
org.gvsig.proj/trunk/org.gvsig.proj/org.gvsig.proj.swing/org.gvsig.proj.swing.impl/src/main/java/org/gvsig/proj/swing/impl/DefaultCoordinateReferenceSystemSelectorComponent.java | ||
---|---|---|
26 | 26 |
import java.awt.Dimension; |
27 | 27 |
import java.awt.event.ActionEvent; |
28 | 28 |
import java.awt.event.ActionListener; |
29 |
import java.awt.event.KeyAdapter; |
|
30 |
import java.awt.event.KeyEvent; |
|
29 | 31 |
import javax.swing.JComponent; |
30 | 32 |
import javax.swing.event.ListDataEvent; |
31 | 33 |
import javax.swing.event.ListDataListener; |
34 |
import javax.swing.event.ListSelectionEvent; |
|
35 |
import javax.swing.event.ListSelectionListener; |
|
32 | 36 |
|
33 | 37 |
import org.slf4j.Logger; |
34 | 38 |
import org.slf4j.LoggerFactory; |
... | ... | |
109 | 113 |
codeModel.applyFilter(txtCode.getText()); |
110 | 114 |
} |
111 | 115 |
}); |
116 |
this.txtCode.addKeyListener(new KeyAdapter() { |
|
117 |
|
|
118 |
@Override |
|
119 |
public void keyTyped(KeyEvent e) { |
|
120 |
if( e.getKeyChar()=='\n') { |
|
121 |
codeModel.applyFilter(txtCode.getText()); |
|
122 |
} else if( e.getKeyChar()=='\033') { |
|
123 |
txtCode.setText(""); |
|
124 |
codeModel.applyFilter(""); |
|
125 |
} |
|
126 |
|
|
127 |
super.keyTyped(e); //To change body of generated methods, choose Tools | Templates. |
|
128 |
} |
|
129 |
}); |
|
130 |
|
|
131 |
lstCodes.addListSelectionListener(new ListSelectionListener() { |
|
132 |
|
|
133 |
@Override |
|
134 |
public void valueChanged(ListSelectionEvent e) { |
|
135 |
CoordinateReferenceSystem crs = getSelectedCoordinateReferenceSystem(); |
|
136 |
if( crs == null ) { |
|
137 |
txtDefinition.setText(""); |
|
138 |
} else { |
|
139 |
txtDefinition.setText(crs.getDefinition()); |
|
140 |
} |
|
141 |
} |
|
142 |
}); |
|
112 | 143 |
|
113 | 144 |
} |
114 | 145 |
|
... | ... | |
147 | 178 |
if (crs != null) { |
148 | 179 |
authorityModel.setSelectedAuthority(crs.getAuthorityName()); |
149 | 180 |
this.lstCodes.setSelectedValue(crs.getCode(), true); |
181 |
this.txtDefinition.setText(crs.getDefinition()); |
|
150 | 182 |
} |
151 | 183 |
} |
152 | 184 |
} |
org.gvsig.proj/trunk/org.gvsig.proj/org.gvsig.proj.swing/org.gvsig.proj.swing.impl/src/main/java/org/gvsig/proj/swing/impl/CodeListModel.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
import javax.swing.AbstractListModel; |
29 | 29 |
import javax.swing.ComboBoxModel; |
30 |
import javax.swing.ListModel; |
|
31 | 30 |
import javax.swing.event.ListDataEvent; |
32 | 31 |
import javax.swing.event.ListDataListener; |
33 | 32 |
import org.apache.commons.io.FilenameUtils; |
... | ... | |
41 | 40 |
* |
42 | 41 |
* @author gvSIG Team |
43 | 42 |
*/ |
44 |
public class CodeListModel extends AbstractListModel implements |
|
45 |
ListModel, ListDataListener { |
|
43 |
public class CodeListModel |
|
44 |
extends AbstractListModel |
|
45 |
{ |
|
46 | 46 |
|
47 | 47 |
private static final long serialVersionUID = -5594433634336286602L; |
48 | 48 |
|
... | ... | |
50 | 50 |
private List<String> filteredCodes; |
51 | 51 |
private String filterPattern=null; |
52 | 52 |
|
53 |
private String selectedCode; |
|
54 |
|
|
53 |
// private String selectedCode; |
|
54 |
private AuthorityComboBoxModel authorityModel; |
|
55 |
|
|
55 | 56 |
private final CoordinateReferenceSystemManager manager; |
56 | 57 |
|
57 | 58 |
@SuppressWarnings("LeakingThisInConstructor") |
58 | 59 |
public CodeListModel(CoordinateReferenceSystemManager manager, |
59 |
AuthorityComboBoxModel authorityModel) {
|
|
60 |
AuthorityComboBoxModel theAuthorityModel) {
|
|
60 | 61 |
this.manager = manager; |
61 |
authorityModel.addListDataListener(this); |
|
62 |
this.authorityModel = theAuthorityModel; |
|
63 |
this.authorityModel.addListDataListener(new ListDataListener() { |
|
64 |
|
|
65 |
@Override |
|
66 |
public void intervalAdded(ListDataEvent e) { |
|
67 |
} |
|
68 |
|
|
69 |
@Override |
|
70 |
public void intervalRemoved(ListDataEvent e) { |
|
71 |
} |
|
72 |
|
|
73 |
@Override |
|
74 |
public void contentsChanged(ListDataEvent e) { |
|
75 |
String authority = authorityModel.getSelectedAuthority(); |
|
76 |
updateAuthority(authority); |
|
77 |
} |
|
78 |
}); |
|
62 | 79 |
} |
63 | 80 |
|
64 | 81 |
@Override |
... | ... | |
68 | 85 |
|
69 | 86 |
@Override |
70 | 87 |
public Object getElementAt(int index) { |
71 |
return filteredCodes == null ? null : filteredCodes.get(index); |
|
88 |
if( filteredCodes == null || index <0 || index>this.filteredCodes.size() ) { |
|
89 |
return null; |
|
90 |
} |
|
91 |
return filteredCodes.get(index); |
|
72 | 92 |
} |
73 | 93 |
|
74 |
// @Override |
|
75 |
// public void setSelectedItem(Object anItem) { |
|
76 |
// if ((selectedCode != null && !selectedCode.equals(anItem)) |
|
77 |
// || selectedCode == null && anItem != null) { |
|
78 |
// selectedCode = anItem.toString(); |
|
79 |
// fireContentsChanged(this, -1, -1); |
|
80 |
// } |
|
81 |
// } |
|
82 |
// |
|
83 |
// @Override |
|
84 |
// public Object getSelectedItem() { |
|
85 |
// return getSelectedCode(); |
|
86 |
// } |
|
87 |
// |
|
88 |
// public String getSelectedCode() { |
|
89 |
// return selectedCode; |
|
90 |
// } |
|
91 |
// |
|
92 |
// public void setSelectedCode(String selectedCode) { |
|
93 |
// setSelectedItem(selectedCode); |
|
94 |
// } |
|
95 |
|
|
96 |
@Override |
|
97 |
public void intervalAdded(ListDataEvent e) { |
|
98 |
// Nothing to do |
|
94 |
private void updateAuthority(String authority) { |
|
95 |
allCodes = manager.getCodes(authority); |
|
96 |
this.applyFilter(this.filterPattern); |
|
99 | 97 |
} |
100 |
|
|
101 |
@Override |
|
102 |
public void intervalRemoved(ListDataEvent e) { |
|
103 |
// Nothing to do |
|
104 |
} |
|
105 |
|
|
106 |
@SuppressWarnings("unchecked") |
|
107 |
@Override |
|
108 |
public void contentsChanged(ListDataEvent e) { |
|
109 |
// A new authority has been selected |
|
110 |
if (e.getSource() != null |
|
111 |
&& e.getSource() instanceof AuthorityComboBoxModel) { |
|
112 |
AuthorityComboBoxModel authorityModel = |
|
113 |
(AuthorityComboBoxModel) e.getSource(); |
|
114 |
|
|
115 |
String authority = authorityModel.getSelectedAuthority(); |
|
116 |
selectedCode = null; |
|
117 |
allCodes = manager.getCodes(authority); |
|
118 |
this.applyFilter(this.filterPattern); |
|
119 |
fireContentsChanged(this, -1, -1); |
|
120 |
} |
|
121 |
} |
|
122 | 98 |
|
123 | 99 |
public void applyFilter(String pattern) { |
124 | 100 |
this.filterPattern = pattern; |
... | ... | |
128 | 104 |
if( !this.filterPattern.contains("*") ) { |
129 | 105 |
this.filterPattern = this.filterPattern + "*"; |
130 | 106 |
} |
131 |
this.filteredCodes = new ArrayList<>();
|
|
107 |
List filteredCodes = new ArrayList<>();
|
|
132 | 108 |
for (String code : allCodes) { |
133 | 109 |
if( FilenameUtils.wildcardMatch(code, this.filterPattern, IOCase.INSENSITIVE)) { |
134 |
this.filteredCodes.add(code);
|
|
110 |
filteredCodes.add(code); |
|
135 | 111 |
} |
136 | 112 |
} |
113 |
fireIntervalRemoved(this, 0,this.filteredCodes.size()); |
|
114 |
this.filteredCodes = filteredCodes; |
|
137 | 115 |
} |
138 |
fireContentsChanged(this, -1, -1);
|
|
116 |
fireIntervalAdded(this, 0,this.filteredCodes.size());
|
|
139 | 117 |
} |
140 | 118 |
|
141 | 119 |
} |
Also available in: Unified diff