OSPE_NavigatorFrame.java
8.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
package osp.ui;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.geom.Point2D;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import jsky.catalog.QueryResult;
import jsky.catalog.gui.CatalogNavigator;
import jsky.catalog.gui.CatalogQueryPanel;
import jsky.catalog.gui.CatalogTreeControlPanel;
import jsky.catalog.skycat.SkycatTable;
import jsky.catalog.vo.VoTable;
import jsky.coords.Coordinates;
import jsky.navigator.NavigatorQueryTool;
/**
* Catalog windows To choose some images, some objects to display in the visu
* field.
*
*/
public class OSPE_NavigatorFrame extends JDialog {
private static final long serialVersionUID = 1L;
private VisuPanelNavigatorInterface visuPanel;
private JPanel contentPane;
private CatalogNavigator naviPanel;
private JPanel buttonsPanel;
private JButton buttonAddClose;
private JButton buttonCancel;
public enum TypeNavigator {IMAGE, OBJECT};
private TypeNavigator typeNavigator = null;
/**
*
* @param owner
* @param v
* @param i
* i=1 for Object Menu i=0 for Image Menu
*/
public OSPE_NavigatorFrame(JFrame owner, VisuPanelNavigatorInterface v) {
super(owner);
this.visuPanel = v;
this.buttonsPanel = new JPanel();
buttonsPanel.add(getCancelButton());
buttonsPanel.add(getAddAndCloseButton());
contentPane = new JPanel(new BorderLayout());
contentPane.add(getCatalogNavigator(), BorderLayout.CENTER);
contentPane.add(buttonsPanel, BorderLayout.SOUTH);
setTypeNavigator(TypeNavigator.IMAGE);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
setContentPane(contentPane);
pack();
// setModal(true);
setVisible(true);
}
/**
*
*/
private JButton getAddAndCloseButton() {
if (buttonAddClose == null) {
buttonAddClose = new JButton("Add and Close");
setAlwaysOnTop(true);
buttonAddClose.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (typeNavigator == TypeNavigator.IMAGE) {
addImage();
} else if (typeNavigator == TypeNavigator.OBJECT) {
addObjectAndClose();
}
}
});
}
return buttonAddClose;
}
/**
*
*/
protected void addImage() {
QueryResult qResult = naviPanel.getQueryResult();
if (qResult != null) {
boolean test = false;
do {
try {
Thread.sleep(100);
} catch (InterruptedException e1) {
e1.printStackTrace();
}
test = naviPanel.getQueryComponent() instanceof NavigatorQueryTool;
} while (!test);
NavigatorQueryTool naviQTool = (NavigatorQueryTool) naviPanel.getQueryComponent();
// naviQTool.setFromImage(true,false);
/*
* Outils a utiliser
*
*
* // set the values in the query panel
* CatalogQueryPanel catalogQueryPanel =
* getCatalogQueryPanel(); QueryArgs queryArgs =
* catalogQueryPanel.getQueryArgs();
*
* if (mag != null) {
* queryArgs.setParamValueRange("mag", mag[0],
* mag[1]); }
* catalogQueryPanel.setQueryArgs(queryArgs);
*/
CatalogQueryPanel catQueryPanel =naviQTool.getCatalogQueryPanel();
// QueryArgs qArgs=catQueryPanel.getQueryArgs();
//System.out.println("Query Args : "+qArgs);
JComponent compImage=catQueryPanel.getComponentForLabel("Object");
JTextField compImName= (JTextField) compImage;
String catImage= catQueryPanel.getCatalog().getName();
visuPanel.setNewImageCatalog(catImage);
visuPanel.setNewImageName(compImName.getText());
/*
* JSplitPane spliP1=(JSplitPane)
* naviPanel.getComponent(0);
* System.out.println(i++); queryComponents(spliP1);
* JSplitPane spliP2=(JSplitPane)
* spliP1.getComponent(0); System.out.println(i++);
* queryComponents(spliP2); JPanel jlP=(JPanel)
* spliP1.getComponent(1); System.out.println(i++);
* queryComponents(jlP); JPanel jlP2=(JPanel)
* jlP.getComponent(0); System.out.println(i++);
* queryComponents(jlP2);
*/
visuPanel.addImageFromServerToProject();
}
dispose();
}
/**
*
*/
private JButton getCancelButton() {
if (buttonCancel == null) {
buttonCancel = new JButton("Cancel");
buttonCancel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
naviPanel.unplot();
dispose();
}
});
}
return buttonCancel;
}
/**
* @return
*/
private CatalogNavigator getCatalogNavigator() {
if (naviPanel == null) {
naviPanel = visuPanel.getNavigator();
naviPanel.clear();
naviPanel.clearQueryList();
}
return naviPanel;
}
/**
* Add the objects on the project
*/
protected void addObjectAndClose() {
final QueryResult queryResult = naviPanel.getQueryResult();
int nbCat = visuPanel.getOspeControl().getNbLoadCat();
nbCat++;
String [] tab = new String[5];
visuPanel.getOspeControl().setNbLoadCat(nbCat);
if (queryResult instanceof SkycatTable) {
SkycatTable theSkyCatTable = ((SkycatTable)naviPanel.getQueryResult());
Point2D.Double pos = new Point2D.Double();
int nbrSkyObject = theSkyCatTable.getRowCount();
int prior=3;
for (int i = 0; i < nbrSkyObject; i++) {
Coordinates coordinates = theSkyCatTable.getCoordinates(i);
pos.x = coordinates.getX();
pos.y = coordinates.getY();
String catName=theSkyCatTable.getCatalog().getName();
String numObj=String.valueOf(i);
// visuPanel.addObject(i,nbCat, catName, pos, prior);
visuPanel.addObject(numObj,nbCat, catName, pos, prior);
}
} else if (queryResult instanceof VoTable) {
VoTable theSkyCatTable = ((VoTable) queryResult);
Point2D.Double pos = new Point2D.Double();
int nbrSkyObject = theSkyCatTable.getRowCount();
int prior=0;
for (int i = 0; i < nbrSkyObject; i++) {
Coordinates coordinates = theSkyCatTable.getCoordinates(i);
pos.x = coordinates.getX();
pos.y = coordinates.getY();
String catName=theSkyCatTable.getCatalog().getName();
// visuPanel.addObject(i,nbCat,catName, pos,prior);
String numObj=String.valueOf(i);
// visuPanel.addObject(i,nbCat, catName, pos, prior);
visuPanel.addObject(numObj,nbCat, catName, pos, prior);
}
}
naviPanel.unplot();
dispose();
}
/**
* @return the typeNavigator
*/
public TypeNavigator getTypeNavigator() {
return typeNavigator;
}
/**
* @param typeNavigator the typeNavigator to set
*/
public void setTypeNavigator(TypeNavigator typeNavigator) {
this.typeNavigator = typeNavigator;
if (typeNavigator == TypeNavigator.IMAGE) {
setTitle("Load Image from Server");
buttonAddClose.setText("Add Image and Close");
selectOnlyImage();
} else if (typeNavigator == TypeNavigator.OBJECT){
setTitle("Add Objects from Catalog");
buttonAddClose.setText("Add Objects and Close");
selectOnlyObjects();
}
}
/**
* Select only image catalog
*/
public void selectOnlyImage() {
CatalogTreeControlPanel catalogTreeControlPanel = naviPanel.getCatalogTree().getControlPanel();
if (catalogTreeControlPanel.getCatalogButton().isSelected()){
catalogTreeControlPanel.getCatalogButton().doClick();
}
if (!catalogTreeControlPanel.getImageServerButton().isSelected()){
catalogTreeControlPanel.getImageServerButton().doClick();
}
if (catalogTreeControlPanel.getArchiveButton().isSelected()){
catalogTreeControlPanel.getArchiveButton().doClick();
}
if (catalogTreeControlPanel.getNameServerButton().isSelected()){
catalogTreeControlPanel.getNameServerButton().doClick();
}
}
public void selectOnlyObjects() {
CatalogTreeControlPanel catalogTreeControlPanel = naviPanel.getCatalogTree().getControlPanel();
if (!catalogTreeControlPanel.getCatalogButton().isSelected()){
catalogTreeControlPanel.getCatalogButton().doClick();
}
if (catalogTreeControlPanel.getImageServerButton().isSelected()){
catalogTreeControlPanel.getImageServerButton().doClick();
}
if (catalogTreeControlPanel.getArchiveButton().isSelected()){
catalogTreeControlPanel.getArchiveButton().doClick();
}
if (catalogTreeControlPanel.getNameServerButton().isSelected()){
catalogTreeControlPanel.getNameServerButton().doClick();
}
}
}