package be.cytomine.client.abst; import be.cytomine.client.*; import java.util.*; import org.json.simple.*; import java.util.Date; import java.util.List; import java.util.Map; import be.cytomine.client.RoiAnnotation; import be.cytomine.client.Server; import org.json.simple.JSONObject; /** * An region of interest on a picture * * @author ClientBuilder (Loïc Rollus) * @version 0.1 * * DO NOT EDIT THIS FILE. THIS IS CODE IS BUILD AUTOMATICALY. ALL CHANGE WILL BE LOST AFTER NEXT GENERATION. * * IF YOU WANT TO EDIT A DOMAIN FILE (change method, add property,...), JUST EDIT THE CHILD FILE “YourDomain.java” instead of this file “AbstractYourDomain.java”. I WON'T BE CLEAR IF IT ALREADY EXIST. * */ public abstract class AbstractRoiAnnotation extends AbstractDomain { /** * The full class name of the domain * */ protected String clazz; /** * The domain id * */ protected Long id; /** * The date of the domain creation * */ protected Date created; /** * The date of the domain modification * */ protected Date updated; /** * When domain was removed from Cytomine * */ protected Date deleted; /** * The WKT of the annotation form * */ protected String location; /** * The image id of the annotation * */ protected Long image; /** * The geometry compression rate used to simplify the annotation (during creation) * */ protected Double geometryCompression; /** * The project id of the annotation * */ protected Long project; /** * Undefined * */ protected Object container; /** * User id that created this annotation * */ protected Long user; /** * The number of comments added by a user on this annotation * */ protected Long nbComments; /** * The annotation form area * */ protected Double area; /** * The annotation unit used for perimeter (pixels=0,mm=2,) * */ protected Integer perimeterUnit; /** * The annotation unit used for area (pixels²=1,micron²=3) * */ protected Integer areaUnit; /** * The annotation form perimeter * */ protected Double perimeter; /** * X,Y coord of the annotation centroid * */ protected Map centroid; /** * List of term id mapped with this annotation * */ protected List term; /** * The similarity rate for this annotation compare to another annotation (from retrieval) * */ protected Double similarity; /** * The reliability value estimated by the software for the mapping between annotation and term * */ protected Double rate; /** * The id of the term map with this annotation by a the software * */ protected Long idTerm; /** * The id of the real term (corresponding to the term add by a real user) * */ protected Long idExpectedTerm; /** * URL to get the annotation crop * */ protected String cropURL; /** * URL to get a small annotation crop (<256px) * */ protected String smallCropURL; /** * URL to go to the annotation on the image * */ protected String url; /** * URL to go to the image * */ protected String imageURL; /** * True if annotation has at least one review * */ protected Boolean reviewed; /** * * @return * The full class name of the domain */ public String getClazz() throws Exception { return clazz; } /** * * @return * The domain id */ public Long getId() throws Exception { return id; } /** * * @return * The date of the domain creation */ public Date getCreated() throws Exception { return created; } /** * * @return * The date of the domain modification */ public Date getUpdated() throws Exception { return updated; } /** * * @return * When domain was removed from Cytomine */ public Date getDeleted() throws Exception { return deleted; } /** * * @return * The WKT of the annotation form */ public String getLocation() throws Exception { return location; } /** * * @param location * The WKT of the annotation form */ public void setLocation(String location) throws Exception { this.location = location; } /** * * @return * The image id of the annotation */ public Long getImage() throws Exception { return image; } /** * * @param image * The image id of the annotation */ public void setImage(Long image) throws Exception { this.image = image; } /** * * @return * The geometry compression rate used to simplify the annotation (during creation) */ public Double getGeometryCompression() throws Exception { return geometryCompression; } /** * * @param geometryCompression * The geometry compression rate used to simplify the annotation (during creation) */ public void setGeometryCompression(Double geometryCompression) throws Exception { this.geometryCompression = geometryCompression; } /** * * @return * The project id of the annotation */ public Long getProject() throws Exception { return project; } /** * * @param project * The project id of the annotation */ public void setProject(Long project) throws Exception { this.project = project; } /** * * @return * Undefined */ public Object getContainer() throws Exception { return container; } /** * * @param container * Undefined */ public void setContainer(Object container) throws Exception { this.container = container; } /** * * @return * User id that created this annotation */ public Long getUser() throws Exception { return user; } /** * * @param user * User id that created this annotation */ public void setUser(Long user) throws Exception { this.user = user; } /** * * @return * The number of comments added by a user on this annotation */ public Long getNbComments() throws Exception { return nbComments; } /** * * @return * The annotation form area */ public Double getArea() throws Exception { return area; } /** * * @return * The annotation unit used for perimeter (pixels=0,mm=2,) */ public Integer getPerimeterUnit() throws Exception { return perimeterUnit; } /** * * @return * The annotation unit used for area (pixels²=1,micron²=3) */ public Integer getAreaUnit() throws Exception { return areaUnit; } /** * * @return * The annotation form perimeter */ public Double getPerimeter() throws Exception { return perimeter; } /** * * @return * X,Y coord of the annotation centroid */ public Map getCentroid() throws Exception { return centroid; } /** * * @return * List of term id mapped with this annotation */ public List getTerm() throws Exception { return term; } /** * * @param term * List of term id mapped with this annotation */ public void setTerm(List term) throws Exception { this.term = term; } /** * * @return * The similarity rate for this annotation compare to another annotation (from retrieval) */ public Double getSimilarity() throws Exception { return similarity; } /** * * @return * The reliability value estimated by the software for the mapping between annotation and term */ public Double getRate() throws Exception { return rate; } /** * * @return * The id of the term map with this annotation by a the software */ public Long getIdTerm() throws Exception { return idTerm; } /** * * @return * The id of the real term (corresponding to the term add by a real user) */ public Long getIdExpectedTerm() throws Exception { return idExpectedTerm; } /** * * @return * URL to get the annotation crop */ public String getCropURL() throws Exception { return cropURL; } /** * * @return * URL to get a small annotation crop (<256px) */ public String getSmallCropURL() throws Exception { return smallCropURL; } /** * * @return * URL to go to the annotation on the image */ public String getUrl() throws Exception { return url; } /** * * @return * URL to go to the image */ public String getImageURL() throws Exception { return imageURL; } /** * * @return * True if annotation has at least one review */ public Boolean getReviewed() throws Exception { return reviewed; } public void build(String location, Long image, Long project, Long user) throws Exception { this.location=location; this.image=image; this.project=project; this.user=user; } public void build(JSONObject json) throws Exception { this.clazz =JSONUtils.extractJSONString(json.get("class")); this.id =JSONUtils.extractJSONLong(json.get("id")); this.created =JSONUtils.extractJSONDate(json.get("created")); this.updated =JSONUtils.extractJSONDate(json.get("updated")); this.deleted =JSONUtils.extractJSONDate(json.get("deleted")); this.location =JSONUtils.extractJSONString(json.get("location")); this.image =JSONUtils.extractJSONLong(json.get("image")); this.geometryCompression =JSONUtils.extractJSONDouble(json.get("geometryCompression")); this.project =JSONUtils.extractJSONLong(json.get("project")); this.container =JSONUtils.extractJSONObject(json.get("container")); this.user =JSONUtils.extractJSONLong(json.get("user")); this.nbComments =JSONUtils.extractJSONLong(json.get("nbComments")); this.area =JSONUtils.extractJSONDouble(json.get("area")); this.perimeterUnit =JSONUtils.extractJSONInteger(json.get("perimeterUnit")); this.areaUnit =JSONUtils.extractJSONInteger(json.get("areaUnit")); this.perimeter =JSONUtils.extractJSONDouble(json.get("perimeter")); this.centroid =JSONUtils.extractJSONMap(json.get("centroid")); this.term =JSONUtils.extractJSONList(json.get("term")); this.similarity =JSONUtils.extractJSONDouble(json.get("similarity")); this.rate =JSONUtils.extractJSONDouble(json.get("rate")); this.idTerm =JSONUtils.extractJSONLong(json.get("idTerm")); this.idExpectedTerm =JSONUtils.extractJSONLong(json.get("idExpectedTerm")); this.cropURL =JSONUtils.extractJSONString(json.get("cropURL")); this.smallCropURL =JSONUtils.extractJSONString(json.get("smallCropURL")); this.url =JSONUtils.extractJSONString(json.get("url")); this.imageURL =JSONUtils.extractJSONString(json.get("imageURL")); this.reviewed =JSONUtils.extractJSONBoolean(json.get("reviewed")); } public JSONObject toJSON() throws Exception { JSONObject json=new JSONObject(); json.put("class",JSONUtils.formatJSON(this.clazz)); json.put("id",JSONUtils.formatJSON(this.id)); json.put("created",JSONUtils.formatJSON(this.created)); json.put("updated",JSONUtils.formatJSON(this.updated)); json.put("deleted",JSONUtils.formatJSON(this.deleted)); json.put("location",JSONUtils.formatJSON(this.location)); json.put("image",JSONUtils.formatJSON(this.image)); json.put("geometryCompression",JSONUtils.formatJSON(this.geometryCompression)); json.put("project",JSONUtils.formatJSON(this.project)); json.put("container",JSONUtils.formatJSON(this.container)); json.put("user",JSONUtils.formatJSON(this.user)); json.put("nbComments",JSONUtils.formatJSON(this.nbComments)); json.put("area",JSONUtils.formatJSON(this.area)); json.put("perimeterUnit",JSONUtils.formatJSON(this.perimeterUnit)); json.put("areaUnit",JSONUtils.formatJSON(this.areaUnit)); json.put("perimeter",JSONUtils.formatJSON(this.perimeter)); json.put("centroid",JSONUtils.formatJSON(this.centroid)); json.put("term",JSONUtils.formatJSON(this.term)); json.put("similarity",JSONUtils.formatJSON(this.similarity)); json.put("rate",JSONUtils.formatJSON(this.rate)); json.put("idTerm",JSONUtils.formatJSON(this.idTerm)); json.put("idExpectedTerm",JSONUtils.formatJSON(this.idExpectedTerm)); json.put("cropURL",JSONUtils.formatJSON(this.cropURL)); json.put("smallCropURL",JSONUtils.formatJSON(this.smallCropURL)); json.put("url",JSONUtils.formatJSON(this.url)); json.put("imageURL",JSONUtils.formatJSON(this.imageURL)); json.put("reviewed",JSONUtils.formatJSON(this.reviewed)); return json; } public static RoiAnnotation get(Server server, Long id) throws Exception { String path = "/api/roiannotation/{id}.json?"; path = path.replace("{id}",id+""); JSONObject json = server.doGET(path); RoiAnnotation domain = new RoiAnnotation(); domain.build(json); return domain; } public static Object crop(Server server, Long id, Integer max_size, Integer zoom, Boolean draw) throws Exception { throw new Exception("Not yet implemented"); } public void add(Server server) throws Exception { String path = "/api/roiannotation.json?"; JSONObject json = server.doPOST(path,this.toJSON()); this.build((JSONObject)json.get("roiannotation")); } public void delete(Server server) throws Exception { String path = "/api/roiannotation/{id}.json?"; path = path.replace("{id}",getId()+""); server.doDELETE(path); build(new JSONObject()); } public void edit(Server server) throws Exception { String path = "/api/roiannotation/{id}.json?"; path = path.replace("{id}",getId()+""); JSONObject json = server.doPUT(path,this.toJSON()); this.build((JSONObject)json.get("roiannotation")); } }