Skip to content

Commit fcd2173

Browse files
committed
shift choose on ellipse -> highlight right table row
1 parent d6399b4 commit fcd2173

4 files changed

Lines changed: 21 additions & 11 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
### TODO:
44
- [x] basic functions
55
- [x] ask for prefix and suffix when load imglist
6-
- [ ] shift choose on ellipse -> hightlight right table row
6+
- [x] shift choose on ellipse -> hightlight right table row
77
- [ ] click on right table row(if static) -> enlarge stroke
88
- [ ] click on right table row(if non-static) -> set as activated ellipse
99
- [x] load imglist -> disable load img button

src/hk/microos/frames/MainFrame.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public class MainFrame extends JFrame {
6969
private JButton btnReadImageList;
7070

7171
private int leftTableSelectedRow = -1;
72+
7273
private HashMap<String, MyImage> pathImgPair = null;
7374
private HashMap<String, ArrayList<Ellipse>> pathStaticElpsesPair = null;
7475
private JButton btnReadAnnotations;
@@ -283,7 +284,7 @@ void setRightPanelCoords(MyImage mim) {
283284
// 2 load drawn ellipse into the table
284285
coordListTH.fillRightTable(mim.getStaticElpsesStrings(), mim.getElpsesStrings());
285286
}
286-
287+
287288
void updateImagePanelSize(MyImage mim) {
288289
if (defaultScrollW == -1)
289290
defaultScrollW = scrollPanel.getWidth();
@@ -341,7 +342,6 @@ void fillImageNameTable() {
341342
void testTable() {
342343
System.out.println(imgListTH.getTable().hashCode() == imgNameTable.hashCode());
343344
}
344-
345345
void loadAnnotList() {
346346
if (pathImgPair == null) {
347347
// no images loaded, abort
@@ -458,7 +458,7 @@ public void marksLoadAnnotationUpdate() {
458458
setRightPanelCoords(null);
459459
}
460460

461-
public void marksUpdatedAtSelected(MyImage mim) {
461+
public void marksUpdatedAtSelectedImage(MyImage mim) {
462462

463463
if (leftTableSelectedRow == -1) {
464464
System.err.println("marking on non-loaded image?");

src/hk/microos/frames/MyImagePanel.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,10 @@ public void paint(Graphics g) {
104104
drawStaticEllipses(g2d);
105105
}
106106
}
107-
107+
private int getStaticEllipsesCount(){
108+
ArrayList<Ellipse> es = mImg.getEllipseStatic();
109+
return es == null? 0 : es.size();
110+
}
108111
public void drawStaticEllipses(Graphics2D g2d) {
109112
AffineTransform old = g2d.getTransform();
110113
// -----------------------------------------//
@@ -126,8 +129,6 @@ public void drawStaticEllipses(Graphics2D g2d) {
126129

127130

128131

129-
130-
131132
g2d.setColor(Color.black);
132133
g2d.setStroke(bs);
133134
g2d.draw(ed);
@@ -248,19 +249,24 @@ public void drawElps(Graphics2D g2d, ArrayList<Ellipse> elpses) {
248249
public void updateStatus() {
249250
ll = null;
250251
waitLastPoint = false;
251-
if (unfinished.size() == 2) {
252+
int unfinishedSize = unfinished.size();
253+
if (unfinishedSize== 2) {
252254
waitLastPoint = true;
253255
ll = new LinearLine(unfinished.get(0), unfinished.get(1));
254256
}
255-
if (unfinished.size() == 3) {
257+
if (unfinishedSize == 3) {
256258
Ellipse e = new Ellipse(unfinished.get(0), unfinished.get(1), this.projPoint);
257259
e.setOffsetForTableDisplay(this.minX, this.minY);
258260
mImg.addElps(e);
259261
Flags.numNewEllipse ++;
260262
unfinished = new ArrayList<>();
261263
this.activedEllipseIdx = mImg.getElpses().size() - 1;
264+
265+
}
266+
mainFrame.marksUpdatedAtSelectedImage(this.mImg);
267+
if(unfinishedSize == 3){
268+
mainFrame.coordListTH.rightPanelSetSelectedLine(this.activedEllipseIdx+getStaticEllipsesCount());
262269
}
263-
mainFrame.marksUpdatedAtSelected(this.mImg);
264270
repaint();
265271
}
266272

@@ -277,6 +283,7 @@ public void activateClosest(int x, int y) {
277283
}
278284
Point_ p = new Point_(x, y);
279285
this.activedEllipseIdx = findTheClosestEllipse(p);
286+
mainFrame.coordListTH.rightPanelSetSelectedLine(this.activedEllipseIdx+getStaticEllipsesCount());
280287
this.repaint();
281288
}
282289

src/hk/microos/tools/TableHelper.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,10 @@ public void setSelectedRow(int row) {
146146
return;
147147
this.table.getSelectionModel().setSelectionInterval(row, row);
148148
}
149-
149+
public void rightPanelSetSelectedLine(int finalIndex){
150+
this.setSelectedRow(finalIndex);
151+
152+
}
150153
public int getRowIndexOfValue(String v) {
151154
if (rowStringList == null)
152155
return -1;

0 commit comments

Comments
 (0)