diff --git a/src/main/java/org/ntlab/acanthus_server/entities/Stroke.java b/src/main/java/org/ntlab/acanthus_server/entities/Stroke.java index 140d96d..4900751 100644 --- a/src/main/java/org/ntlab/acanthus_server/entities/Stroke.java +++ b/src/main/java/org/ntlab/acanthus_server/entities/Stroke.java @@ -6,11 +6,16 @@ import org.ntlab.acanthus_server.entities.Position; public class Stroke { + private static int i; //strokeNoを数えるためだけ + private int strokeNo; private int pen; private int color; private int thickness; private ArrayList positions = new ArrayList<>(); + public int getStrokeNo() { + return this.strokeNo; + } public int getPen() { return this.pen; } @@ -21,7 +26,13 @@ return this.thickness; } - public void setStrokes(int pen, int color, int thickness) { + //書き始めたらstrokeNoを追加する。 + public void addStrokeNo(){ + this.i++; + this.strokeNo = i; +} + + public void addStrokes(int pen, int color, int thickness) { this.pen = pen; this.color = color; this.thickness = thickness; diff --git a/src/main/java/org/ntlab/acanthus_server/resources/gallery/StrokesRest.java b/src/main/java/org/ntlab/acanthus_server/resources/gallery/StrokesRest.java index cf927d1..e40f80a 100644 --- a/src/main/java/org/ntlab/acanthus_server/resources/gallery/StrokesRest.java +++ b/src/main/java/org/ntlab/acanthus_server/resources/gallery/StrokesRest.java @@ -16,7 +16,7 @@ @Path("/gallery") public class StrokesRest { private ArrayList positions = new ArrayList<>(); - private Stroke Test = new Stroke(); + private ArrayList strokes = new ArrayList<>(); private Gallery gallery = Gallery.getInstance(); /* @@ -29,9 +29,9 @@ @Path("/{aid}/pageMap/0/layers/0/strokes") @GET @Produces(MediaType.APPLICATION_JSON) - public Stroke getStrokeRest(@PathParam("aid") Integer aid) { + public ArrayList getStrokeRest(@PathParam("aid") Integer aid) { var animation = gallery.getAnimationInformation(aid); - return this.Test; + return this.strokes; // if(animation != null) { // return this.Test; // }else{ @@ -54,7 +54,10 @@ public void addStrokes(@PathParam("aid") Integer aid, @FormParam("uid") Integer uid, @FormParam("uidToken") Integer uidToken, @FormParam("pen") Integer pen, @FormParam("color") Integer color, @FormParam("thick") Integer thick) { var animation = gallery.getAnimationInformation(aid); - this.Test.setStrokes(pen, color, thick); + Stroke Test = new Stroke(); + Test.addStrokes(pen, color, thick); + Test.addStrokeNo();//strokeNoを+1する + this.strokes.add(Test); // if(animation != null) { // this.Test.setStrokes(pen, color, thick); // }else{