Skip to content

Commit

Permalink
Fix ObjectModel#clone to include polygon
Browse files Browse the repository at this point in the history
  • Loading branch information
kinhong committed Apr 7, 2020
1 parent a0fc5e6 commit b2f96d4
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import java.util.List;
import java.util.stream.Collectors;

@XmlRootElement(name = "object")
@XmlType(propOrder = {"name", "pose", "truncated", "difficult", "boundBox", "polygon"})
Expand Down Expand Up @@ -125,6 +126,9 @@ public Object clone() {
ObjectModel model = new ObjectModel();
model.setName(name);
model.setBoundBox((BoundBox)boundBox.clone());
if (polygon != null) {
model.setPolygon(polygon.stream().collect(Collectors.toList()));
}
return model;
}
}
11 changes: 1 addition & 10 deletions app/src/main/java/com/easymobo/openlabeler/tag/HintTag.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,12 @@

public class HintTag extends TagBase
{
private HintModel model;

public HintTag(ImageView imageView, Translate translate, Scale scale, Rotate rotate, HintModel model) {
this.model = model;
init(imageView.getImage(), translate, scale, rotate);

init(imageView.getImage(), translate, scale, rotate, model);
name.setText(String.format("%s (%.2f)", model.getName(), model.getScore()));
name.setMouseTransparent(true);
}

@Override
public HintModel getModel() {
return model;
}

@Override
public ObjectProperty<Color> strokeColorProperty() {
return Settings.hintStrokeColorProperty;
Expand Down
10 changes: 1 addition & 9 deletions app/src/main/java/com/easymobo/openlabeler/tag/ObjectTag.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,14 @@

public class ObjectTag extends TagBase
{
private ObjectModel model;
private String action;

private ReadOnlyObjectWrapper<Image> thumbProperty = new ReadOnlyObjectWrapper();
private ReadOnlyObjectWrapper<Color> strokeColorProperty = new ReadOnlyObjectWrapper();
private ReadOnlyObjectWrapper<Color> fillColorProperty = new ReadOnlyObjectWrapper();

public ObjectTag(ImageView imageView, Translate translate, Scale scale, Rotate rotate, ObjectModel model) {
this.model = model;
init(imageView.getImage(), translate, scale, rotate);

init(imageView.getImage(), translate, scale, rotate, model);
name.setText(model.getName());
name.textProperty().addListener((observable, oldValue, newValue) -> {
model.setName(newValue);
Expand Down Expand Up @@ -97,11 +94,6 @@ protected void onMouseClicked(MouseEvent me) {
Settings.recentNamesProperty.addName(label);
}

@Override
public ObjectModel getModel() {
return model;
}

public String getAction() {
return action;
}
Expand Down
9 changes: 7 additions & 2 deletions app/src/main/java/com/easymobo/openlabeler/tag/TagBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public abstract class TagBase extends Group
@FXML
protected Label name;

private ObjectModel model;
protected ShapeItem shapeItem;

static final double HANDLE_SIZE = 8;
Expand Down Expand Up @@ -76,10 +77,11 @@ public TagBase() {
}
}

public void init(Image image, Translate translate, Scale scale, Rotate rotate) {
public void init(Image image, Translate translate, Scale scale, Rotate rotate, ObjectModel model) {
this.imageDim = new Dimension2D(image.getWidth(), image.getHeight());
this.translate = translate;
this.scale = scale;
this.model = model;

shapeItem = createShapeItem();
var shape = shapeItem.toShape();
Expand Down Expand Up @@ -143,7 +145,10 @@ private DoubleBinding getNameTranslateYProperty(Rotate rotate) {
return translate.yProperty().add(anchor.multiply(scale.yProperty()));
}

public abstract ObjectModel getModel();
public ObjectModel getModel() {
return model;
}

public abstract ReadOnlyObjectProperty<Color> strokeColorProperty();
public abstract ReadOnlyObjectProperty<Color> fillColorProperty();

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/resources/fxml/OpenLabeler.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
</MenuItem>
</items>
</Menu>
<Menu text="%menu.view" visible="">
<Menu text="%menu.view">
<items>
<MenuItem fx:id="miZoomOut" onAction="#onZoomOut" text="%menu.zoomOut"/>
<MenuItem fx:id="miZoomIn" onAction="#onZoomIn" text="%menu.zoomIn"/>
Expand Down

0 comments on commit b2f96d4

Please sign in to comment.