@@ -73,17 +73,19 @@ public void setLiveXY(double x, double y) {
7373 this .perpendicularConstrainY = y ;
7474 this .repaint ();
7575 }
76- private void setOffset (double [] offset ){
76+
77+ private void setOffset (double [] offset ) {
7778 this .minX = offset [0 ];
7879 this .minY = offset [1 ];
7980 this .maxX = offset [2 ];
8081 this .maxY = offset [3 ];
8182 }
83+
8284 public void paint (Graphics g ) {
8385 super .paint (g );
8486 if (mImg != null ) {
8587 setOffset (UniversalTool .getOffset (mImg ));
86- g .drawImage (mImg .getImage (), (int )this .minX , (int )this .minY , this );
88+ g .drawImage (mImg .getImage (), (int ) this .minX , (int ) this .minY , this );
8789
8890 Graphics2D g2d = (Graphics2D ) g ;
8991
@@ -104,10 +106,12 @@ public void paint(Graphics g) {
104106 drawStaticEllipses (g2d );
105107 }
106108 }
107- private int getStaticEllipsesCount (){
109+
110+ private int getStaticEllipsesCount () {
108111 ArrayList <Ellipse > es = mImg .getEllipseStatic ();
109- return es == null ? 0 : es .size ();
112+ return es == null ? 0 : es .size ();
110113 }
114+
111115 public void drawStaticEllipses (Graphics2D g2d ) {
112116 AffineTransform old = g2d .getTransform ();
113117 // -----------------------------------------//
@@ -117,25 +121,21 @@ public void drawStaticEllipses(Graphics2D g2d) {
117121 int i = 0 ;
118122 for (Ellipse e : staticEllipses ) {
119123 e = e .offset (minX , minY );
120- BasicStroke bs = UniversalTool .getPreferableStroke (Math .max (e .major , e .minor )* 2 );
124+ BasicStroke bs = UniversalTool .getPreferableStroke (Math .max (e .major , e .minor ) * 2 );
121125
122-
123126 // do rotation
124127 g2d .rotate (e .angle , e .x , e .y );
125128 // draw elps
126129
127-
128130 Ellipse2D .Double ed = e .getErectedEllipse2D ();
129-
130-
131-
131+
132132 g2d .setColor (Color .black );
133133 g2d .setStroke (bs );
134134 g2d .draw (ed );
135-
135+
136136 g2d .setColor (Color .yellow );
137- g2d .setStroke (new BasicStroke (bs .getLineWidth ()/ 2 ));
138-
137+ g2d .setStroke (new BasicStroke (bs .getLineWidth () / 2 ));
138+
139139 g2d .draw (ed );
140140
141141 // reset transform
@@ -210,8 +210,7 @@ public void drawElps(Graphics2D g2d, ArrayList<Ellipse> elpses) {
210210
211211 int i = 0 ;
212212 for (Ellipse e : elpses ) {
213-
214-
213+
215214 ArrayList <Point_ > keyPoints = e .getKeyPoints ();
216215 BasicStroke bs = UniversalTool .getPreferableStroke (Math .max (e .major , e .minor ));
217216
@@ -225,7 +224,7 @@ public void drawElps(Graphics2D g2d, ArrayList<Ellipse> elpses) {
225224 } else {
226225 g2d .setColor (Color .GREEN );
227226 }
228-
227+
229228 Ellipse2D .Double ed = e .getErectedEllipse2D ();
230229 g2d .draw (ed );
231230
@@ -239,7 +238,7 @@ public void drawElps(Graphics2D g2d, ArrayList<Ellipse> elpses) {
239238 g2d .setColor (Color .red );
240239 }
241240 for (Point_ p : keyPoints ) {
242-
241+
243242 g2d .fill (UniversalTool .getPointOval (p , 2.2 * bs .getLineWidth ()));
244243 }
245244 i ++;
@@ -250,22 +249,22 @@ public void updateStatus() {
250249 ll = null ;
251250 waitLastPoint = false ;
252251 int unfinishedSize = unfinished .size ();
253- if (unfinishedSize == 2 ) {
252+ if (unfinishedSize == 2 ) {
254253 waitLastPoint = true ;
255254 ll = new LinearLine (unfinished .get (0 ), unfinished .get (1 ));
256255 }
257256 if (unfinishedSize == 3 ) {
258257 Ellipse e = new Ellipse (unfinished .get (0 ), unfinished .get (1 ), this .projPoint );
259258 e .setOffsetForTableDisplay (this .minX , this .minY );
260259 mImg .addElps (e );
261- Flags .numNewEllipse ++;
260+ Flags .numNewEllipse ++;
262261 unfinished = new ArrayList <>();
263262 this .activedEllipseIdx = mImg .getElpses ().size () - 1 ;
264-
263+
265264 }
266265 mainFrame .marksUpdatedAtSelectedImage (this .mImg );
267- if (unfinishedSize == 3 ){
268- mainFrame .coordListTH .rightPanelSetSelectedLine (this .activedEllipseIdx + getStaticEllipsesCount ());
266+ if (unfinishedSize == 3 ) {
267+ mainFrame .coordListTH .rightPanelSetSelectedLine (this .activedEllipseIdx + getStaticEllipsesCount ());
269268 }
270269 repaint ();
271270 }
@@ -277,13 +276,14 @@ public void addUnfinishedPoint(Point_ p) {
277276 }
278277
279278 public void activateClosest (int x , int y ) {
280- //if found that we still have jobs to be done OR no ellipse can be deleted --> abort
279+ // if found that we still have jobs to be done OR no ellipse can be
280+ // deleted --> abort
281281 if (unfinished .size () != 0 || mImg .getElpses ().size () == 0 ) {
282282 return ;
283283 }
284284 Point_ p = new Point_ (x , y );
285285 this .activedEllipseIdx = findTheClosestEllipse (p );
286- mainFrame .coordListTH .rightPanelSetSelectedLine (this .activedEllipseIdx + getStaticEllipsesCount ());
286+ mainFrame .coordListTH .rightPanelSetSelectedLine (this .activedEllipseIdx + getStaticEllipsesCount ());
287287 this .repaint ();
288288 }
289289
@@ -293,7 +293,7 @@ public void removeActived() {
293293 unfinished .remove (unfinished .size () - 1 );
294294
295295 } else {
296- Flags .numNewEllipse --;
296+ Flags .numNewEllipse --;
297297 ArrayList <Ellipse > elpses = mImg .getElpses ();
298298 if (elpses .size () != 0 && this .activedEllipseIdx != -1 ) {
299299 Ellipse e = elpses .remove (this .activedEllipseIdx );
@@ -321,6 +321,16 @@ public int findTheClosestEllipse(Point_ p) {
321321 return minIdx ;
322322 }
323323
324+ public void setActivatedIndex (int rowIdx ) {
325+ rowIdx -= getStaticEllipsesCount ();
326+ if (rowIdx >= 0 && unfinished .size () == 0 ) {
327+ activedEllipseIdx = rowIdx ;
328+ this .repaint ();
329+ }else {
330+ activedEllipseIdx = -1 ;
331+ }
332+ }
333+
324334 public void reset () {
325335 if (!isInited ())
326336 return ;
0 commit comments