diff --git a/src/main/java/org/ntlab/acanthus_server/entities/Position.java b/src/main/java/org/ntlab/acanthus_server/entities/Position.java index c1004e2..d1c638d 100644 --- a/src/main/java/org/ntlab/acanthus_server/entities/Position.java +++ b/src/main/java/org/ntlab/acanthus_server/entities/Position.java @@ -9,7 +9,6 @@ public class Position { private float x; private float y; - private int strokeNo; public float getX() { return x; @@ -17,18 +16,10 @@ public float getY() { return y; } - public int StrokeNo() { - return strokeNo; - } public void setXY(float x, float y) { this.x = x; this.y = y; } - public void setStrokeNo(int strokeNo) { - this.strokeNo = strokeNo; - System.out.println(this.strokeNo); - } - } 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 d3c350a..bf88d02 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,10 @@ import org.ntlab.acanthus_server.entities.Position; public class Stroke { - private static int strokeNoCount; //strokeNoを数えるためだけ - private int strokeNo = 0; - private int pen; - private int color; - private int thickness; + private int strokeNo; // strokeの番号 + private int pen; // ペンの種類 + private int color; // ペンの色 + private int thickness; // ペンの厚さ private ArrayList positions = new ArrayList<>(); public int getStrokeNo() { @@ -25,38 +24,27 @@ public int getThickness() { return this.thickness; } + + //座標のリストを返す public ArrayList getPositions() { return this.positions; } - //書き始めたらstrokeNoを追加する。 - public void addStrokeNo(){ - this.strokeNo = strokeNoCount; - strokeNoCount++; + // StrokesRestからstrokesのsizeをもらってstrokeNoに入れる + public void setStrokeNo(int strokeNo){ + this.strokeNo = strokeNo; } + // 線に関する情報を追加する public void addStrokes(int pen, int color, int thickness) { this.pen = pen; this.color = color; this.thickness = thickness; } + // 座標を追加する public void addPosition(Position positions) { this.positions.add(positions); } } - - - -// private ArrayList> strokeList = new ArrayList<>(); -// -// public void putStroke(String type, Integer value) { -// this.strokeMap.put(type, value); -// } -// -// public ArrayList> getStrokeRest() { -// this.strokeList.add(this.strokeMap); -// return this.strokeList; -// } -//} 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 8951c51..cb8c362 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 @@ -15,22 +15,21 @@ @Component @Path("/gallery") public class StrokesRest { - private ArrayList positions = new ArrayList<>(); private ArrayList strokes = new ArrayList<>(); private Gallery gallery = Gallery.getInstance(); - /* - * 1ページの1レイヤーに置ける筆跡情報を全て取得します。 - * 成功時のレスポンス:strokeNo{pen, color, thickness, potions{x, y}} - * @PathParam Integer aid 作品ID - * @PathParam Integer pid ページのID 今回は0 - * @PathParam Integer layerNo レイヤーの番号 今回は0 - */ + // _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ + // 1ページの1レイヤーに置ける筆跡情報を全て取得します + // 成功時のレスポンス:strokeNo{pen, color, thickness, potions{x, y}} + // @PathParam Integer aid 作品ID + // @PathParam Integer pid ページのID 今回は0 + // @PathParam Integer layerNo レイヤーの番号 今回は0 @Path("/{aid}/pageMap/0/layers/0/strokes") @GET @Produces(MediaType.APPLICATION_JSON) public ArrayList getStrokeRest(@PathParam("aid") Integer aid) { var animation = gallery.getAnimationInformation(aid); + return this.strokes; // if(animation != null) { // return this.Test; @@ -38,80 +37,72 @@ // throw new WebApplicationException(401); // } } + // _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ - /* - * 何かを書き始めた時strokeNoを取得しペン情報、色情報、太さ情報、座標情報を追加する - * @PathParam Integer aid 作品のID - * @FormParam Integer uid ページのID - * @FormParam Integer uidToken トークン - * @Formparam Integer pen ペン情報 - * @Formparam Integer color 色情報 - * @Formparam Integer thick 太さ情報 - */ + // _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ + // 何かを書き始めた時strokeNoを取得しペン情報、色情報、太さ情報、座標情報を追加する + // StrokeNoは画面に線を書き始めてから離すまで + // StrokeNoは自動で0から順番に名前がつく + // @PathParam Integer aid 作品のID + // @FormParam Integer uid ページのID + // @FormParam Integer uidToken トークン + // @Formparam Integer pen ペン情報 + // @Formparam Integer color 色情報 + // @Formparam Integer thick 太さ情報 @Path("/{aid}/pageMap/0/layers/0/strokes") @POST @Produces(MediaType.APPLICATION_JSON) 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); - Stroke Stroke = new Stroke(); - Stroke.addStrokes(pen, color, thick); - Stroke.addStrokeNo();//strokeNoを+1する - for (int i = 0; i < this.positions.size(); i++) { - if (this.positions.get(i).StrokeNo() == Stroke.getStrokeNo()) { - Stroke.addPosition(this.positions.get(i)); - } - } - - this.strokes.add(Stroke); + Stroke stroke = new Stroke(); + stroke.addStrokes(pen, color, thick); // 線の情報を追加 + stroke.setStrokeNo(strokes.size()); // strokeNoに現在のstrokesのsizeを入れる + this.strokes.add(stroke); // if(animation != null) { // this.Test.setStrokes(pen, color, thick); // }else{ // throw new WebApplicationException(401); // } } + // _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ - /* - * 全座標値を取得する - * @PathParam Integer aid 作品のID - * @PathParam Integer strokeNo 線番号 - */ + // _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ + // 全座標値を取得する + // @PathParam Integer aid 作品のID + // @PathParam Integer strokeNo 線番号 @Path("/{aid}/pageMap/0/layers/0/strokes/{strokeNo}/position") @GET @Produces(MediaType.APPLICATION_JSON) public ArrayList getPositions(@PathParam("aid") Integer aid, @PathParam("strokeNo") Integer strokeNo) { var animation = gallery.getAnimationInformation(aid); - return this.positions; + Stroke stroke = strokes.get(strokeNo); // 指定したstrokeNoのstrokesを呼び出す + return stroke.getPositions(); // 呼び出したstrokesの情報を返す // if(animation != null) { // return this.positions; // }else{ // throw new WebApplicationException(401); // } } + // _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ - /* - * 座標情報の追加 - * @PathParam Integer aid 作品のID - * @FormParam Integer x x座標 - * @FormParam Integer y y座標 - */ + // _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ + // 座標情報の追加 + // @PathParam Integer aid 作品のID + // @FormParam Integer x x座標 + // @FormParam Integer y y座標 @Path("/{aid}/pageMap/0/layers/0/strokes/{strokeNo}/position") @POST @Produces(MediaType.APPLICATION_JSON) public void addPositions(@PathParam("aid") Integer aid, @PathParam("strokeNo") Integer strokeNo, @FormParam("x") Float x, @FormParam("y") Float y) { var animation = gallery.getAnimationInformation(aid); - - - Position Position = new Position(); - - Position.setStrokeNo(strokeNo); - - Position.setXY(x, y); -// stroke.addPosition(Position); - this.positions.add(Position); + Position position = new Position(); + position.setXY(x, y); + Stroke stroke = strokes.get(strokeNo); // 指定したstrokeNoのstrokesを呼び出す + stroke.addPosition(position); // 呼び出したstrokesに座標を追加する // if(animation != null) { // this.Position.setXY(x, y); // this.positions.add(this.Position); @@ -120,4 +111,4 @@ // } } } - + // _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/