Commit d5ce50920bf2678d0e9fa5f463e2a7b9cb9be963

Authored by Elodie Bourrec
1 parent 2bc29436
Exists in master

Implement function when selecting object in array, highlight it with a green cro…

…ss and move image to center it in display.
When clic on array ligne when selected => deselecting it in display an recenter image on mask center or on barycenter if no mask.
version diffused - 3.1
bin/Osp_Editor_3.1.jar 0 → 100644
No preview for this file type
src/osp/Image.java
... ... @@ -277,6 +277,7 @@ public class Image extends Observable {
277 277 imCenterWc=new WorldCoords(ra,dec);
278 278 alpha=ra;
279 279 delta=dec;
  280 +
280 281 }
281 282  
282 283 /**
... ...
src/osp/Reader.java
... ... @@ -995,8 +995,10 @@ public class Reader {
995 995  
996 996 for (int i = 0; i < currentImage.getNbrObjects(); i++) {
997 997 SkyObject sk = currentImage.getListObjects().get(i);
998   - if (objectPosition.equals(sk.getPosPix())
999   - || objectPosition.equals(sk.getPosPixRecalc())) {
  998 +// if (objectPosition.equals(sk.getPosPix())
  999 +// || objectPosition.equals(sk.getPosPixRecalc())) {
  1000 + if (objectPosition.equals(sk.getInitPos())
  1001 + || objectPosition.equals(sk.getInitPos())) {
1000 1002 sk.setRef(true);
1001 1003 idObj=sk.getTargetId();
1002 1004 exists = true;
... ...
src/osp/SkyObject.java
... ... @@ -15,12 +15,12 @@ public class SkyObject
15 15 // Attributes
16 16 //-----------
17 17 // Attributes needed to be saved
18   - /** Position in pixels */
19   - private Point2D.Double posPix; // In Image coord
  18 + /** Initial Object Position */
  19 + private Point2D.Double initPos; // In Image coord
20 20 /** Center position in Ra-Dec world Coordinates */
21 21 private WorldCoords objWorldCenter;
22 22 /** Recalculated position in pixels */
23   - private Point2D.Double posPixRecalc; // In Image coord
  23 + private Point2D.Double recalcPos; // In Image coord
24 24 /** Position of recalculated center in Ra-Dec world Coordinates */
25 25 private WorldCoords objWorldRecalc;
26 26  
... ... @@ -40,12 +40,13 @@ public class SkyObject
40 40 private ArrayList<String> properties;
41 41 private String prop;
42 42 /** catalog group number where the object is from when loaded */
43   - private int group=0;
  43 + private int nbcat=0;
44 44 /** Object priority */
45 45 private int priority;
46 46 /* display object color */
47 47 private Color col;
48 48  
  49 + private boolean pointed=false;
49 50  
50 51 // Constructors
51 52 //-----------
... ... @@ -58,29 +59,16 @@ public class SkyObject
58 59 * @param pRecalc Center of the object once recalculated (in image coordinates)
59 60 * @param c Color following priority.
60 61 */
61   - public SkyObject(int n, boolean iR, Point2D.Double p, Point2D.Double pRecalc, Color c)
  62 + public SkyObject(int n, boolean iR, Point2D.Double p, Point2D.Double pRecalc, Color c, boolean pted)
62 63 {
63 64 // System.out.print("SkyObj 1 "+n+" ");
64 65 numIm = n;
65 66 isRef = iR;
66   -
67   - posPix = new Point2D.Double();
68   - setPosPix(p);
69   -
70   -// if (pRecalc!= null)
71   -// {
72   -// System.out.println("SkyObj - pRecal "+pRecalc.getX()+" "+pRecalc.getY());
73   -// setPosPixRecalc(pRecalc);
74   -// c=Color.green;
75   -// }
76   -
  67 + pointed=pted;
  68 + initPos = new Point2D.Double();
  69 + setInitPos(p);
77 70 if (isRef )c=Color.red;
78   - // System.out.println("SkyObj -"+n+" const temp color "+c.toString());
79   - this.setColor(c);
80   -// WorldCoords coords = new WorldCoords(wc.getRA(),wc.getDec());
81   -// setObjWorldCenter(coords);
82   -// setObjWorldRecalc(coords);
83   - // System.out.println("Sk Obj Nw "+n+" "+ p.x +" "+p.y);
  71 + this.setColor(c);
84 72 }
85 73  
86 74  
... ... @@ -105,11 +93,11 @@ public class SkyObject
105 93 targetId = idO;
106 94 numIm=n;
107 95 isRef = iR;
108   - group=fi;
  96 + nbcat=fi;
109 97 prop=props;
110   - posPix = new Point2D.Double();
111   - setPosPix(p);
112   - posPixRecalc = null;
  98 + initPos = new Point2D.Double();
  99 + setInitPos(p);
  100 + recalcPos = null;
113 101 objWorldCenter=new WorldCoords(wc.getRA(),wc.getDec());
114 102 objWorldRecalc=new WorldCoords(0,0);
115 103 priority = prior;
... ... @@ -128,7 +116,6 @@ public class SkyObject
128 116 }
129 117  
130 118 if (isRef )c=Color.RED;
131   -
132 119 setColor(c);
133 120  
134 121 // System.out.println("SkyObj - "+n+ " const Norm color "+c.toString());
... ... @@ -139,10 +126,10 @@ public class SkyObject
139 126 //-----------
140 127 /**
141 128 * Sets the position of the object.
142   - * @param mouse Center of the object
  129 + * @param point : Center of the object
143 130 */
144   - public void setPosPix( Point2D.Double point )
145   - { posPix.x = point.x; posPix.y = point.y; }
  131 + public void setInitPos( Point2D.Double point )
  132 + { initPos.x = point.x; initPos.y = point.y; }
146 133  
147 134 /**
148 135 * Sets the recalculated position of the object.
... ... @@ -151,9 +138,9 @@ public class SkyObject
151 138 public void setPosPixRecalc( Point2D.Double point )
152 139 {
153 140 if (point == null)
154   - posPixRecalc = null;
  141 + recalcPos = null;
155 142 else
156   - posPixRecalc = new Point2D.Double(point.x, point.y);
  143 + recalcPos = new Point2D.Double(point.x, point.y);
157 144 }
158 145  
159 146 /**
... ... @@ -172,31 +159,33 @@ public class SkyObject
172 159 }
173 160  
174 161 /**
175   - * Returns the actual position of the center of the object. If the center has been
  162 + * Returns the actual position of the center of the object in image coords. If the center has been
176 163 * recalculated, returns the recalculated position.
177 164 * @return Center of the object.
178 165 */
179 166 public Point2D.Double getPosition()
180 167 {
181   - if (posPixRecalc != null)
  168 + if (recalcPos != null)
182 169 {
183   - return posPixRecalc;
  170 + return recalcPos;
184 171 }
185 172 else
186   - return posPix;
  173 + return initPos;
187 174 }
188 175  
189 176 /**
190   - * Returns the original position of the object
191   - * (position before any recalculation).
192   - * @return Initial center of the object
  177 + * Returns the object position in pixel (screen position)
  178 + *
  179 + * @return pixel position object center
193 180 */
194   - public Point2D.Double getPosPix() { return posPix; }
  181 + public Point2D.Double getInitPos() { return initPos; }
  182 + public Point2D.Double getPosPix() { return initPos; }
195 183 /**
196   - * Returns the recalculated position of the object.
  184 + * Returns the recalculated position of the object.(Image coords)
197 185 * @return Recalculated center of the object
198 186 */
199   - public Point2D.Double getPosPixRecalc() { return posPixRecalc; }
  187 + public Point2D.Double getecalcPos() { return recalcPos; }
  188 + public Point2D.Double getPosPixRecalc() { return recalcPos; }
200 189  
201 190 /**
202 191 * Returns the number of the object for project image
... ... @@ -273,7 +262,7 @@ public class SkyObject
273 262 public boolean isCenterRecalc ()
274 263 {
275 264 boolean err=false;
276   - if (posPixRecalc != null)
  265 + if (recalcPos != null)
277 266 {
278 267 Color c = new Color(0, 255, 0);
279 268 this.setColor(c);
... ... @@ -337,11 +326,29 @@ public void setColor(Color col) {
337 326 }
338 327  
339 328 /**
  329 + * Flag if the object is pointed in objects array and higlighted with different color and form
  330 + * @param flg : boolean true if it's choosen/ false otherwise.
  331 + */
  332 +public void setPointed( boolean flg)
  333 +{
  334 + pointed=flg;
  335 +
  336 +//System.out.println("skyOb setPointed "+flg);
  337 +}
  338 +/**
  339 + * get the flag if the object is pointed in objects array
  340 + * @return pointed (boolean)
  341 + */
  342 +public boolean getPointed()
  343 +{
  344 + return pointed;
  345 +}
  346 +/**
340 347 * Get the catalog group where the object is from
341 348 * @return int group
342 349 */
343 350 public int getGroup() {
344   - return group;
  351 + return nbcat;
345 352 }
346 353  
347 354 }
... ...
src/osp/ui/OSPE_AboutBoxPanel.java
... ... @@ -23,7 +23,7 @@ public class OSPE_AboutBoxPanel extends JDialog {
23 23 /** Product name */
24 24 private String product = "OSP Editor";
25 25 /** Current version */
26   - private String version = "version 3.0 - June 28th 2019";
  26 + private String version = "version 3.1 - Sept 2019";
27 27 /** Copyright information */
28 28 private String copyright = "Copyright (c)";
29 29 /** Comments */
... ...
src/osp/ui/OSPE_MainFrame.java
... ... @@ -50,6 +50,7 @@ StatusInterface, AccessMenuInterface, AccessSlitMenuInterface {
50 50  
51 51 protected Reader theReader;
52 52 protected Writer theWriter;
  53 +
53 54  
54 55 private OspeControl ospeControl;
55 56 /**
... ... @@ -71,6 +72,7 @@ StatusInterface, AccessMenuInterface, AccessSlitMenuInterface {
71 72 getMenu().setControl(ospeControl);
72 73 getToolBar().setControl(ospeControl);
73 74 getSelectPanel().setControl(ospeControl);
  75 + tableurPanel.setVisuPanel(visuPanel);
74 76 fov.addObserver(ospeControl);
75 77 setName("OSPE_MainFrame");
76 78 setDefaultLookAndFeelDecorated(false);
... ... @@ -152,10 +154,10 @@ StatusInterface, AccessMenuInterface, AccessSlitMenuInterface {
152 154 public TableurPanel getTableurPanel() {
153 155 if (tableurPanel == null) {
154 156 int defNbCol;
155   - TableurModel tableurModel = new TableurModel(visuPanel);
  157 + TableurModel tableurModel = new TableurModel();
156 158 defNbCol = tableurModel.getColumnCount();
157 159 int[] defColSize = tableurModel.getColSize();
158   - tableurPanel = new TableurPanel(tableurModel,visuPanel, defColSize);
  160 + tableurPanel = new TableurPanel(tableurModel, defColSize);
159 161 }
160 162 return tableurPanel;
161 163 }
... ... @@ -183,6 +185,7 @@ StatusInterface, AccessMenuInterface, AccessSlitMenuInterface {
183 185 public OSPE_VisuPanel getVisuPanel() {
184 186 if (visuPanel == null){
185 187 visuPanel = new OSPE_VisuPanel(this, this, fov, theWriter, getTableurPanel());
  188 + tableurPanel=getTableurPanel();
186 189 visuPanel.setBorder(BorderFactory.createEtchedBorder());
187 190  
188 191 }
... ...
src/osp/ui/OSPE_SelectPanel.java
... ... @@ -503,7 +503,11 @@ public class OSPE_SelectPanel extends JPanel implements Observer{
503 503 public void enableValidateAndGenerateButton(boolean maskValidated) {}
504 504 @Override
505 505 public OSPE_NavigatorImageDisplay getNavigatorImageDisplay() {
506   - return null;
  506 + return null;}
  507 + @Override
  508 + public void setImageAtObjectPosition(int idObj) {
  509 + // TODO Auto-generated method stub
  510 +
507 511 }
508 512 });
509 513 JFrame frame = new JFrame();
... ...
src/osp/ui/OSPE_VisuPanel.java
... ... @@ -5,6 +5,7 @@ import java.awt.Color;
5 5 import java.awt.Cursor;
6 6 import java.awt.Dimension;
7 7 import java.awt.FlowLayout;
  8 +import java.awt.Graphics;
8 9 import java.awt.GridLayout;
9 10 import java.awt.Point;
10 11 import java.awt.event.ActionEvent;
... ... @@ -29,7 +30,6 @@ import java.util.List;
29 30 import java.util.Observable;
30 31 import java.util.Observer;
31 32  
32   -import javax.media.jai.PlanarImage;
33 33 import javax.swing.BorderFactory;
34 34 import javax.swing.BoxLayout;
35 35 import javax.swing.JButton;
... ... @@ -51,8 +51,6 @@ import javax.swing.border.LineBorder;
51 51 import javax.swing.event.ChangeEvent;
52 52 import javax.swing.event.ChangeListener;
53 53  
54   -import org.omg.CosNaming._NamingContextImplBase;
55   -
56 54 import nom.tam.fits.FitsException;
57 55 import jsky.catalog.gui.CatalogNavigator;
58 56 import jsky.coords.DMS;
... ... @@ -175,6 +173,8 @@ public class OSPE_VisuPanel extends JPanel implements Observer,
175 173 private CanvasFigure canevasT2 = null;
176 174 private CanvasFigure canevasT3 = null;
177 175 private CanvasFigure canevasT4 = null;
  176 + private CanvasFigure canvasTo1 = null;
  177 + private CanvasFigure canvasTo2 = null;
178 178 private CanvasFigure canevasM = null;
179 179 private CanvasFigure[] canevasSpectre = new CanvasFigure[Mask._NBRSLITS_];
180 180  
... ... @@ -182,6 +182,7 @@ public class OSPE_VisuPanel extends JPanel implements Observer,
182 182 private AffineTransform at2 = new AffineTransform();
183 183  
184 184 public boolean isFromSlitComboBox = false;
  185 + private CanvasFigure canvasObject;
185 186 private List<CanvasFigure> listCanvasObjects1;
186 187 private List<CanvasFigure> listCanvasObjects2;
187 188 private List<CanvasFigure> listCanvasObjects3;
... ... @@ -189,8 +190,10 @@ public class OSPE_VisuPanel extends JPanel implements Observer,
189 190 private CanvasFigure canvasBary;
190 191  
191 192 public float lWidth=1;
192   -
193   -
  193 + private SkyObject objChoosen;
  194 + private int idObjChoosen=-1;
  195 + private int idLastObjChoosen=-1;
  196 +
194 197 Color[] colorTab={Color.RED, Color.ORANGE, Color.PINK, Color.MAGENTA, Color.LIGHT_GRAY};
195 198 int nbColor=0;
196 199 Color objColor=colorTab[nbColor];
... ... @@ -1097,7 +1100,7 @@ public class OSPE_VisuPanel extends JPanel implements Observer,
1097 1100 return addObjectMenuItem;
1098 1101 }
1099 1102  
1100   - /**
  1103 + /** Menu option :
1101 1104 * Centering image at the mouse position
1102 1105 * @return
1103 1106 */
... ... @@ -1109,11 +1112,28 @@ public class OSPE_VisuPanel extends JPanel implements Observer,
1109 1112 @Override
1110 1113 public void actionPerformed(ActionEvent evt)
1111 1114 {
  1115 + //** used for later traitement *//
  1116 + if (fov.getSelectedImage() >= 0)
  1117 + {
  1118 + /** Image center is in image coords */
  1119 + centerImage.x = fov.getCurrentImage().getCenter().getX();
  1120 + centerImage.y = fov.getCurrentImage().getCenter().getY();
  1121 +
  1122 + if (fov.getCurrentImage().getSelectedMask() >= 0) {
  1123 + // Set the new display coord of the mask - User Coord
  1124 + maskDisplayCenter.x = fov.getCurrentImage().getCurrentMask().getCenter().getX();
  1125 + maskDisplayCenter.y = fov.getCurrentImage().getCurrentMask().getCenter().getY();
  1126 +
  1127 + }
  1128 + }
1112 1129 mouseGeneralPopupMenu.setVisible(false);
1113   - icc.screenToCanvasCoords(mousePosition, false);
1114   - fov.getCurrentImage().setCenter(mousePosition);
1115   - fov.getCurrentImage().update();
  1130 +
  1131 + Point2D.Double newOrig = new Point2D.Double(mousePosition.x, mousePosition.y);
  1132 + icc.screenToCanvasCoords(newOrig, false);
1116 1133  
  1134 + fov.getCurrentImage().setCenter(newOrig);
  1135 + fov.getCurrentImage().update();
  1136 +
1117 1137 }
1118 1138 });
1119 1139 return newCenterImageItem;
... ... @@ -1285,6 +1305,7 @@ public class OSPE_VisuPanel extends JPanel implements Observer,
1285 1305 // int objectId = getTheNearObjectid(currentImage);
1286 1306  
1287 1307 int objectId = getNearObjectid(currentImage);
  1308 +//System.out.println("Visu onNavClicR - objectID "+objectId);
1288 1309 rigthMouseClick(e, currentImage, currentMask, objectId);
1289 1310  
1290 1311 }
... ... @@ -1428,7 +1449,8 @@ public class OSPE_VisuPanel extends JPanel implements Observer,
1428 1449 originPointer.setLocation(e.getX(), e.getY());
1429 1450  
1430 1451 //** used for later traitement *//
1431   - if (fov.getSelectedImage() >= 0) {
  1452 + if (fov.getSelectedImage() >= 0)
  1453 + {
1432 1454 centerImage.x = fov.getCurrentImage().getCenter().getX();
1433 1455 centerImage.y = fov.getCurrentImage().getCenter().getY();
1434 1456  
... ... @@ -1492,11 +1514,7 @@ public class OSPE_VisuPanel extends JPanel implements Observer,
1492 1514 public void updateByHand()
1493 1515 {
1494 1516 setProjectLabel();
1495   - eraseSpectra();
1496   - eraseMask();
1497   - eraseAllObjects();
1498   - eraseBary();
1499   - eraseTableur();
  1517 + eraseVisu();
1500 1518 checkSelectedImage();
1501 1519  
1502 1520 if (fov.getSelectedImage() >= 0)
... ... @@ -1536,6 +1554,17 @@ public class OSPE_VisuPanel extends JPanel implements Observer,
1536 1554 }
1537 1555  
1538 1556 /**
  1557 + * Erase all graphic components
  1558 + */
  1559 + public void eraseVisu() {
  1560 + eraseSpectra();
  1561 + eraseMask();
  1562 + eraseAllObjects();
  1563 + eraseBary();
  1564 + eraseTableur();
  1565 + }
  1566 +
  1567 + /**
1539 1568 * @param enabled
1540 1569 */
1541 1570 private void enableCompo(final boolean enabled) {
... ... @@ -1721,10 +1750,6 @@ public class OSPE_VisuPanel extends JPanel implements Observer,
1721 1750 navigatorImageDisplay.setScale(imScale);
1722 1751  
1723 1752 Point2D.Double newOrig = new Point2D.Double();
1724   -// newOrig.x = currentImage.getCenter().getX() * currentImage.getScale()
1725   -// - navigatorImageDisplay.getWidth() / 2.0;
1726   -// newOrig.y = currentImage.getCenter().getY() * currentImage.getScale()
1727   -// - navigatorImageDisplay.getHeight() / 2.0;
1728 1753 newOrig.x = imCenter.getX() * imScale
1729 1754 - navigatorImageDisplay.getWidth() / 2.0;
1730 1755 newOrig.y = imCenter.getY() * imScale
... ... @@ -1811,7 +1836,7 @@ public class OSPE_VisuPanel extends JPanel implements Observer,
1811 1836 else
1812 1837 tableData[i][4] = String.valueOf(affectedSlit + 1);
1813 1838 } else
1814   - tableData[i][5] = "none";
  1839 + tableData[i][4] = "none";
1815 1840 }
1816 1841 tableurPanel.getModel().fillTableModelPerso(tableData);
1817 1842 //tableurPanel.getModel().setnewData(currentImage.getListObjects());
... ... @@ -2097,6 +2122,8 @@ public class OSPE_VisuPanel extends JPanel implements Observer,
2097 2122 divaImageGraphics.add(canevasT4);
2098 2123 }
2099 2124  
  2125 +
  2126 +
2100 2127 /**
2101 2128 * Displaying joined slits when selected (TBC)
2102 2129 * @param currentMask : displayed mask
... ... @@ -2377,7 +2404,7 @@ public class OSPE_VisuPanel extends JPanel implements Observer,
2377 2404 * : Point2D mouse position
2378 2405 * @param n_win
2379 2406 * : window dimensions to calculate the new centroid position
2380   - * @return new centroid
  2407 + * @return new centroid in image coord
2381 2408 */
2382 2409  
2383 2410 private Point2D.Double computeCentroid(Point2D.Double point, int n_win) {
... ... @@ -2434,7 +2461,7 @@ public class OSPE_VisuPanel extends JPanel implements Observer,
2434 2461 yc = iy;
2435 2462 }
2436 2463  
2437   - return new Point2D.Double(xc, yc);
  2464 + return new Point2D.Double(xc, yc); // In Image Coords
2438 2465 }
2439 2466  
2440 2467 /**
... ... @@ -2445,6 +2472,8 @@ public class OSPE_VisuPanel extends JPanel implements Observer,
2445 2472 for (int i = listCanvasObjects1.size() - 1; i >= 0; i--) {
2446 2473 eraseObject(i);
2447 2474 }
  2475 + erasePointedObject();
  2476 +
2448 2477 }
2449 2478  
2450 2479 /**
... ... @@ -2476,11 +2505,10 @@ public class OSPE_VisuPanel extends JPanel implements Observer,
2476 2505 */
2477 2506 public void plotObject(int i) {
2478 2507 SkyObject sk = fov.getCurrentImage().getListObjects().get(i);
2479   -//System.out.print(("visu Plot Obj"+sk.getNum()+" -"));
2480   -
2481   - SkyObject tempObject = new SkyObject(-1, sk.isRef(), sk.getPosPix(), sk.getPosPixRecalc(),sk.getColor());
2482   -
2483 2508  
  2509 +// SkyObject tempObject = new SkyObject(-1, sk.isRef(), sk.getPosPix(), sk.getPosPixRecalc(),sk.getColor());
  2510 + SkyObject tempObject = new SkyObject(-1, sk.isRef(), sk.getInitPos(), sk.getPosPixRecalc(),sk.getColor(), sk.getPointed());
  2511 +//System.out.println(" ref "+sk.isRef()+" "+ sk.getInitPos().x+" "+sk.getInitPos().y);
2484 2512 //SkyObject tempObject = new SkyObject(-1, sk.isRef(), sk.getSrc(), sk.getCatLibFrom(), sk.getPosPix(),
2485 2513 // sk.getObjWorldCenter(), sk.getPosPixRecalc(), sk.getPriority());
2486 2514  
... ... @@ -2490,16 +2518,33 @@ public class OSPE_VisuPanel extends JPanel implements Observer,
2490 2518 tempObject.setObjWorldCenter(tempPosition);
2491 2519 }
2492 2520  
2493   - if (tempObject.isRef())
2494   - {
  2521 + if (tempObject.getPointed())
  2522 + {
  2523 + Color col=Color.GREEN;
  2524 + drawCrossOnPointedObject(tempObject.getPosition().x, tempObject.getPosition().y, col);
  2525 + }
  2526 +
  2527 + if (tempObject.isRef())
  2528 + {
2495 2529 drawCrossOnObject(i,tempObject);
2496   - }
2497   - else
2498   - {
  2530 + }
  2531 + else
  2532 + {
2499 2533 drawSquareAroundObject(i, tempObject);
2500   - }
  2534 + }
  2535 +
2501 2536 }
2502   -
  2537 +
  2538 + /**
  2539 + * Erase the canvaObj
  2540 + */
  2541 + public void erasePointedObject() {
  2542 + if (canvasTo1 != null)
  2543 + divaImageGraphics.remove(canvasTo1);
  2544 + if (canvasTo2 != null)
  2545 + divaImageGraphics.remove(canvasTo2);
  2546 + }
  2547 +
2503 2548 /**
2504 2549 * Draw a blue square around the object
2505 2550 * @param i : id object
... ... @@ -2536,6 +2581,23 @@ public class OSPE_VisuPanel extends JPanel implements Observer,
2536 2581 }
2537 2582  
2538 2583 /**
  2584 + * To draw a cross at the given coordinates .
  2585 + * (used for mask center)
  2586 + * @param x : x coordinate of the cross center
  2587 + * @param y : y coordinate of the cross center
  2588 + * @param co : drawing color
  2589 + * lWidth : line thickness
  2590 + */
  2591 + private void drawCrossOnPointedObject(double x, double y, Color co) {
  2592 + canvasTo1 = divaImageGraphics.makeFigure(new Line2D.Double(x - 10,
  2593 + y, x + 10, y), co, co, lWidth+2);
  2594 + divaImageGraphics.add(canvasTo1);
  2595 + canvasTo2 = divaImageGraphics.makeFigure(new Line2D.Double(x,
  2596 + y - 10, x, y + 10), co, co, lWidth+2);
  2597 + divaImageGraphics.add(canvasTo2);
  2598 + }
  2599 +
  2600 + /**
2539 2601 * Draw cross on the object
2540 2602 * @param i : id object
2541 2603 * @param sk : Sky object
... ... @@ -2584,6 +2646,10 @@ public class OSPE_VisuPanel extends JPanel implements Observer,
2584 2646 plotObject(i);
2585 2647 }
2586 2648 //System.out.println("");
  2649 +// if (idObjChoosen> -1)
  2650 +// {
  2651 +// erasePointedObject();
  2652 +// }
2587 2653 plotBary(fov.getTheBrain().getBary());
2588 2654  
2589 2655 }
... ... @@ -2633,11 +2699,11 @@ public class OSPE_VisuPanel extends JPanel implements Observer,
2633 2699 /**
2634 2700 * Add an object on image
2635 2701 *
2636   - * @param type : type of the object (if it came from catalog, local cat or manually)
2637   - * @param props : Libelle of where it comes from (catalog name, ...) or properties when it come from local catalog
2638   - * @param c : coordinates of the object in image coordinates.<br>
2639   - * For the objects from catalog or from local import,
2640   - * the position is converted from world to image.
  2702 + * @param type : object source type (if it came from server's catalog or local cat, it's a number. When choosen manually (-1))
  2703 + * @param props : Libelle of where it comes from (catalog name, ...) or properties when it comes from local catalog
  2704 + * @param c : coordinates of the object in image coordinates system.<br>
  2705 + * For objects from catalog or from local import,
  2706 + * the position is converted from world to image coords
2641 2707 * @param priority : object priority, when it's set.
2642 2708 * Set object world coordinates.
2643 2709 *
... ... @@ -2940,14 +3006,14 @@ public class OSPE_VisuPanel extends JPanel implements Observer,
2940 3006  
2941 3007  
2942 3008 /**
2943   - * Action when mouse left button clic on image with a mask
  3009 + * Action when mouse left button clic on image (with a mask or not)
2944 3010 * @param e : mouse event
2945 3011 * @param currentImage
2946 3012 * @param currentMask
2947 3013 */
2948 3014 private void onNavigatorImageDisplayleftMouseClick(MouseEvent e,
2949 3015 final Image currentImage, final Mask currentMask) {
2950   -//System.out.print(("Visu mouse left clic "));
  3016 +//System.out.print(("Visu mouse left clic - mask "));
2951 3017 //printTheMousePosition(e.getX(),e.getY());
2952 3018  
2953 3019  
... ... @@ -3029,7 +3095,6 @@ public class OSPE_VisuPanel extends JPanel implements Observer,
3029 3095  
3030 3096 //System.out.println("visu Clic2 "+is+" P2 "+p2.x+" "+p2.y+" "+s.getWcPosCenter().getRA()+" "+s.getWcPosCenter().getDec());
3031 3097  
3032   -
3033 3098 currentMask.update();
3034 3099 }
3035 3100 slitCombo.setSelectedIndex(selSlit);
... ... @@ -3625,8 +3690,8 @@ public class OSPE_VisuPanel extends JPanel implements Observer,
3625 3690 return;
3626 3691 }
3627 3692 }// Fi a mask is on the image and move or turn activated.
3628   -
3629   - /**Calculate the new position of the image center in screen coord. */
  3693 +
  3694 + /**Calculate the new position of the image center in canvas coord. */
3630 3695 Point2D.Double tmpImage = new Point2D.Double();
3631 3696 tmpImage.setLocation(centerImage.getX() + dX, centerImage.getY() + dY);
3632 3697 if (tmpImage.x < 0.0)
... ... @@ -3683,6 +3748,58 @@ public class OSPE_VisuPanel extends JPanel implements Observer,
3683 3748 currentImage=fov.getCurrentImage();
3684 3749 }
3685 3750 }
  3751 +
  3752 + /**
  3753 + * Centering image at the choosen object position and hightlight the object
  3754 + * @return
  3755 + */
  3756 +
  3757 + public void setImageAtObjectPosition(int param)
  3758 + {
  3759 + Point2D.Double newOrig=new Point2D.Double(0.0,0.0);
  3760 + erasePointedObject();
  3761 + objChoosen=fov.getCurrentImage().getObject(param);
  3762 + idObjChoosen=param;
  3763 + if (objChoosen.getPointed())
  3764 + {
  3765 + objChoosen.setPointed(false);
  3766 + tableurPanel.razTableSelect();
  3767 + if (fov.getCurrentImage().getSelectedMask()>=0)
  3768 + {
  3769 + newOrig = new Point2D.Double(0.0,0.0);
  3770 + newOrig = new Point2D.Double(fov.getCurrentMaskOfCurrentImage().getCenter().x, fov.getCurrentMaskOfCurrentImage().getCenter().y);
  3771 + icc.userToCanvasCoords(newOrig, false);
  3772 + }
  3773 + else
  3774 + {
  3775 + // set display center at bary point
  3776 + newOrig.setLocation(fov.getTheBrain().getBary().x, fov.getTheBrain().getBary().y);
  3777 + icc.imageToCanvasCoords(newOrig, false);
  3778 + }
  3779 +
  3780 + }
  3781 + else objChoosen.setPointed(true);
  3782 +
  3783 + if (objChoosen.getPointed())
  3784 + {
  3785 +//System.out.print("Visu setImageAtObjPos idObj "+idObjChoosen+" Last id "+idLastObjChoosen);
  3786 + if ((idLastObjChoosen > -1) && (idLastObjChoosen!= idObjChoosen))
  3787 + {
  3788 + fov.getCurrentImage().getObject(idLastObjChoosen).setPointed(false);
  3789 + }
  3790 + idLastObjChoosen=idObjChoosen;
  3791 +//System.out.println(" chg Last id "+idLastObjChoosen);
  3792 + WorldCoords wc=objChoosen.getObjWorldCenter();
  3793 + newOrig = new Point2D.Double(wc.getX(), wc.getY());
  3794 + icc.worldToCanvasCoords(newOrig, false);
  3795 + }
  3796 + fov.getCurrentImage().setCenter(newOrig);
  3797 + fov.getCurrentImage().update();
  3798 + eraseAllObjects();
  3799 + plotAllObjects();
  3800 +
  3801 + }
  3802 +
3686 3803 /**
3687 3804 * testing the mouse position and the various conversions
3688 3805 * @param x : X screen coord
... ... @@ -3723,7 +3840,7 @@ System.out.println(&quot; Canva x: &quot;+ptTmp.x+&quot; y: &quot;+ptTmp.y);
3723 3840 icc.screenToWorldCoords(ptTmp3, false);
3724 3841 WorldCoords wcTmp= getWorldCoords(ptTmp.getX(),ptTmp.getY());
3725 3842 //System.out.print(" xdeg: "+wcTmp.getRaDeg()+" ydeg: "+wcTmp.getDecDeg());
3726   -System.out.println(" x: "+wcTmp.getRA()+" y: "+wcTmp.getDec()+" x: "+wcTmp.getRaDeg()+" y: "+wcTmp.getDecDeg());
  3843 +//System.out.println(" x: "+wcTmp.getRA()+" y: "+wcTmp.getDec()+" x: "+wcTmp.getRaDeg()+" y: "+wcTmp.getDecDeg());
3727 3844  
3728 3845 //Mask m=fov.getCurrentMaskOfCurrentImage();
3729 3846 //System.out.println(" mask Om : "+m.getOmega());
... ...
src/osp/ui/OSPE_VisuPanelInterface.java
... ... @@ -16,4 +16,6 @@ public interface OSPE_VisuPanelInterface {
16 16 void enableValidateAndGenerateButton(boolean maskValidated);
17 17  
18 18 OSPE_NavigatorImageDisplay getNavigatorImageDisplay();
  19 +
  20 + void setImageAtObjectPosition(int idObj);
19 21 }
... ...
src/osp/ui/OspeControl.java
... ... @@ -384,6 +384,9 @@ public class OspeControl implements ToolBarActionInterface, Observer{
384 384 visuPanel.searchButton.setEnabled(false);
385 385 visuPanel.writeButton.setEnabled(false);
386 386  
  387 + visuPanel.eraseVisu();
  388 + visuPanel.repaint();
  389 +
387 390 getMainFrame().setStatusBarText(Color.blue, "INFO: Project closed");
388 391 menuBar.disableMenuForClosedProject();
389 392  
... ... @@ -489,16 +492,23 @@ public class OspeControl implements ToolBarActionInterface, Observer{
489 492 resetNavigatorImageDisplay();
490 493 navigatorImageDisplay.setImage(fitsImage);
491 494  
492   - Point2D.Double cCenter = new Point2D.Double((navigatorImageDisplay.getWidth() / 2.0 + navigatorImageDisplay
493   - .getOrigin().getX()) / navigatorImageDisplay.getScale(), (navigatorImageDisplay.getHeight() / 2.0 + navigatorImageDisplay
494   - .getOrigin().getY()) / navigatorImageDisplay.getScale());
495   -
  495 + /** CCenter in canvas coord
  496 + * NavigatorImageDisplay Origin is in canvas coords */
  497 + double xc=(navigatorImageDisplay.getWidth() / 2.0 + navigatorImageDisplay
  498 + .getOrigin().getX()) / navigatorImageDisplay.getScale();
  499 + double yc=(navigatorImageDisplay.getHeight() / 2.0 + navigatorImageDisplay
  500 + .getOrigin().getY()) / navigatorImageDisplay.getScale();
  501 +// Point2D.Double cCenter = new Point2D.Double((navigatorImageDisplay.getWidth() / 2.0 + navigatorImageDisplay
  502 +// .getOrigin().getX()) / navigatorImageDisplay.getScale(), (navigatorImageDisplay.getHeight() / 2.0 + navigatorImageDisplay
  503 +// .getOrigin().getY()) / navigatorImageDisplay.getScale());
  504 + Point2D.Double cCenter = new Point2D.Double(xc,yc);
  505 +//System.out.println("Ctrl - addImage "+xc+" "+yc);
496 506 String imName=null;
497 507 String imCatName="Local File";
498 508 if (visuPanel.getNewImageCatalog() != "Local File")
499 509 {
500 510 imCatName=visuPanel.getNewImageCatalog();
501   - visuPanel.setNewImageCatalog("Local File");
  511 + visuPanel.setNewImageCatalog(imCatName);
502 512  
503 513 if (visuPanel.getNewImageName() != null)
504 514 {
... ... @@ -528,6 +538,8 @@ public class OspeControl implements ToolBarActionInterface, Observer{
528 538 WorldCoords imCenterHMS=visuPanel.getWorldCoords(cCenter.getX(),cCenter.getY());
529 539 image.setAlpha(imCenterHMS.getRA());
530 540 image.setDelta(imCenterHMS.getDec());
  541 + image.setAlpha(imCenterHMS.getRaDeg());
  542 + image.setDelta(imCenterHMS.getDecDeg());
531 543 }
532 544  
533 545 /**
... ... @@ -1716,7 +1728,7 @@ WorldCoords wc = new WorldCoords(ptM.x,ptM.y);
1716 1728 }
1717 1729  
1718 1730 DecimalFormat nf;
1719   - nf = new DecimalFormat("000.00000");
  1731 + nf = new DecimalFormat("000.000");
1720 1732 nf.setRoundingMode(RoundingMode.HALF_EVEN);
1721 1733  
1722 1734 tab[i][0]=String.valueOf((int)idSlit);
... ...
src/osp/utils/TableurModel.java
... ... @@ -6,7 +6,6 @@ import java.util.List;
6 6 import javax.swing.table.AbstractTableModel;
7 7  
8 8 import osp.SkyObject;
9   -import osp.ui.OSPE_VisuPanel;
10 9  
11 10 public class TableurModel extends AbstractTableModel {
12 11  
... ... @@ -33,13 +32,12 @@ public class TableurModel extends AbstractTableModel {
33 32  
34 33  
35 34 private Object[][] donnees;
36   - private OSPE_VisuPanel vPanel;
  35 +// private OSPE_VisuPanel vPanel;
37 36  
38 37 /**
39 38 * Constructor
40 39 */
41   - public TableurModel(OSPE_VisuPanel vPanel) {
42   - this.vPanel = vPanel;
  40 + public TableurModel() {
43 41 attributeNumCol();
44 42 Object[][] objectsData = new Object[0][NB_COL];
45 43 fillTableModelPerso(objectsData);
... ... @@ -54,8 +52,8 @@ public class TableurModel extends AbstractTableModel {
54 52 * @param colEditable2
55 53 * @param colType2
56 54 */
57   - public TableurModel(OSPE_VisuPanel visuPanel, String[] colString2, boolean[] colEditable2,
58   - String[] colType2) {
  55 +// public TableurModel(OSPE_VisuPanel visuPanel, String[] colString2, boolean[] colEditable2,
  56 + public TableurModel(String[] colString2, boolean[] colEditable2,String[] colType2) {
59 57 // TODO Auto-generated constructor stub
60 58 Object[][] objectsData = new Object[0][NB_COL];
61 59 fillTableModelPerso(objectsData);
... ...
src/osp/utils/TableurPanel.java
... ... @@ -11,11 +11,14 @@ import javax.swing.JOptionPane;
11 11 import javax.swing.JPanel;
12 12 import javax.swing.JScrollPane;
13 13 import javax.swing.JTable;
  14 +import javax.swing.ListSelectionModel;
14 15 import javax.swing.SwingConstants;
  16 +import javax.swing.event.ListSelectionEvent;
  17 +import javax.swing.event.ListSelectionListener;
15 18 import javax.swing.table.DefaultTableCellRenderer;
16 19  
17   -import osp.ui.OSPE_NavigatorImageDisplay;
18   -import osp.ui.OSPE_VisuPanel;
  20 +import osp.ui.OSPE_VisuPanelInterface;
  21 +
19 22 import java.awt.event.MouseEvent;
20 23 import java.awt.event.MouseListener;
21 24  
... ... @@ -23,19 +26,19 @@ public class TableurPanel extends JPanel implements Observer {
23 26 private static final long serialVersionUID = 1L;
24 27  
25 28 private JTable table;
26   - private OSPE_NavigatorImageDisplay navigatorDisplay;
27   - private static OSPE_VisuPanel visuPanel;
  29 + //private OSPE_NavigatorImageDisplay navigatorDisplay;
  30 + private OSPE_VisuPanelInterface visuPanel;
28 31  
29 32 private TableurModel tableurModel;
30 33 private int sel, num, id, ref, ra, dec, nbcat, prior, slit;
31 34 private int[] colSize=null;
32   -
33   - public TableurPanel(TableurModel tableurModel, OSPE_VisuPanel vPanel, int[] colSize)
  35 + private int idRow=0;
  36 +
  37 + public TableurPanel(TableurModel tableurModel, int[] colSize)
34 38 {
35 39  
36 40 this.tableurModel = tableurModel;
37   - visuPanel=vPanel;
38   -
  41 +
39 42 this.colSize = colSize;
40 43 this.setPreferredSize(new Dimension(800, 100));
41 44 this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
... ... @@ -55,97 +58,55 @@ public class TableurPanel extends JPanel implements Observer {
55 58 table.getColumn(columnName).setMinWidth(colSize[i]);
56 59 table.getColumn(columnName).setMaxWidth(colSize[i]);
57 60 table.getColumn(columnName).setPreferredWidth(colSize[i]);
58   -//System.out.println("tabPan colsize "+i+" "+colSize[i]);
59 61 }
60 62 }
61   -
62   -// this.tableurModel = tableurModel;
63   -// visuPanel=vPanel;
64   -// attributeNumCol();
65   -//
66   -// this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
67   -//
68   -// table = new JTable(tableurModel);
69   -// table.setColumnSelectionAllowed(true);
70   -// table.setRowSelectionAllowed(true);
71   -// table.setSelectionBackground(Color.GREEN);
72   -// table.setAutoCreateRowSorter(true);
73   -// DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
74   -// centerRenderer.setHorizontalAlignment( SwingConstants.CENTER );
75   -// table.getColumnModel().getColumn(sel).setPreferredWidth(tableurModel.getSizecol(sel));
76   -// table.getColumnModel().getColumn(id).setPreferredWidth(tableurModel.getSizecol(id));
77   -// table.getColumnModel().getColumn(id).setCellRenderer( centerRenderer );
78   -// table.getColumnModel().getColumn(ref).setPreferredWidth(tableurModel.getSizecol(ref));
79   -// table.getColumnModel().getColumn(prior).setPreferredWidth(tableurModel.getSizecol(prior));
80   -// table.getColumnModel().getColumn(prior).setCellRenderer( centerRenderer );
81   -// table.getColumnModel().getColumn(slit).setPreferredWidth(tableurModel.getSizecol(slit));
82   -// table.getColumnModel().getColumn(slit).setCellRenderer( centerRenderer );
83   -
  63 +
84 64 table.setAutoCreateRowSorter(true);
85 65 JScrollPane scroll = new JScrollPane(table);
86 66 this.add(scroll);
87   -
88   - /*table.getModel().addTableModelListener(new TableModelListener() {
89   -
90   - public void tableChanged(TableModelEvent e) {
91   - if (e.getType() == TableModelEvent.UPDATE)
92   - {
93   - int row = e.getFirstRow();
94   - int column = e.getColumn();
95   -
96   - int viewRowIndex = table.convertRowIndexToView(row);
97   - TableurModel model = (TableurModel)e.getSource();
98   - Boolean value = (Boolean)model.getValueAt(1, 1);
99   -
100   - System.out.println(value);
101   - System.out.println(viewRowIndex);
102   - System.out.println(column);
103   - }
104   - }
105   - });*/
106   -
  67 +
107 68 table.addMouseListener(new MouseListener() {
108   - @Override
109   - public void mousePressed(MouseEvent evt)
110   - {
111   - int row = table.getSelectedRow();
112   - int col = table.getSelectedColumn();
113   - //System.out.println("TabPan mousList L"+row+" C "+col);
114   -
115   -
116   - switch (col)
117   - {
118   - case 3:
119   -
120   - }
121   -
122   -
123   - }
124   -
  69 +
125 70 @Override
126   - public void mouseClicked(MouseEvent arg0) {
  71 + public void mouseReleased(MouseEvent e) {
127 72 // TODO Auto-generated method stub
128 73  
129 74 }
130   -
  75 +
131 76 @Override
132   - public void mouseEntered(MouseEvent arg0) {
  77 + public void mousePressed(MouseEvent e) {
133 78 // TODO Auto-generated method stub
134 79  
135 80 }
136   -
  81 +
137 82 @Override
138   - public void mouseExited(MouseEvent arg0) {
  83 + public void mouseExited(MouseEvent e) {
139 84 // TODO Auto-generated method stub
140 85  
141 86 }
142   -
  87 +
143 88 @Override
144   - public void mouseReleased(MouseEvent arg0) {
  89 + public void mouseEntered(MouseEvent e) {
145 90 // TODO Auto-generated method stub
146 91  
147 92 }
148   - });
  93 +
  94 + @Override
  95 + /**
  96 + * when clic on object array row, get the object selected.
  97 + */
  98 + public void mouseClicked(MouseEvent e) {
  99 + // TODO Auto-generated method stub
  100 + int a = table.getSelectedRow();
  101 + if (a>=0)
  102 + {
  103 + getObject(a);
  104 + idRow=a;
  105 + table.changeSelection(a, 0, false, false);
  106 + }
  107 + }
  108 + });
  109 +
149 110 }
150 111  
151 112 public void updateByHand() {
... ... @@ -156,7 +117,34 @@ public class TableurPanel extends JPanel implements Observer {
156 117 public void update(Observable arg0, Object arg1) {
157 118 updateByHand();
158 119 }
  120 +
  121 + public OSPE_VisuPanelInterface getVisuPanel()
  122 + {
  123 + return visuPanel;
  124 + }
159 125  
  126 + public void setVisuPanel(OSPE_VisuPanelInterface vPanel)
  127 + {
  128 + visuPanel=vPanel;
  129 + }
  130 +
  131 + /**
  132 + * get the object selected on array and set it on image.
  133 + * @param selectedRow : object id.
  134 + */
  135 + private void getObject(int rowNb) {
  136 +// System.out.println("tabPan rowNb "+rowNb);
  137 +
  138 + visuPanel.setImageAtObjectPosition(rowNb);
  139 +
  140 + }
  141 +
  142 + public void razTableSelect() {
  143 + // TODO Auto-generated method stub
  144 + table.changeSelection(idRow, 0, true, false);
  145 + }
  146 +
  147 +
160 148 public void selectCorrespondingRow(int object_id) {
161 149 table.clearSelection();
162 150 for (int row = 0; row < table.getRowCount(); row++) {
... ... @@ -203,10 +191,8 @@ public class TableurPanel extends JPanel implements Observer {
203 191 int[] colSize = { 30, 30,valMaxCol, valMaxCol, valMaxCol, valMaxCol, valMaxCol, 30 };
204 192 JFrame frame = new JFrame();
205 193 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
206   - frame.getContentPane().add(new TableurPanel(new TableurModel(visuPanel,colString, colEditable, colType), null, colSize));
  194 + frame.getContentPane().add(new TableurPanel(new TableurModel(colString, colEditable, colType), colSize));
207 195 frame.setVisible(true);
208 196 frame.pack();
209 197 }
210   -
211   -
212   - }
213 198 \ No newline at end of file
  199 +}
214 200 \ No newline at end of file
... ...