diff --git a/src/main/java/org/ntlab/acanthus_server/resources/gallery/LayersRest.java b/src/main/java/org/ntlab/acanthus_server/resources/gallery/LayersRest.java index e0a00e8..0b601a6 100644 --- a/src/main/java/org/ntlab/acanthus_server/resources/gallery/LayersRest.java +++ b/src/main/java/org/ntlab/acanthus_server/resources/gallery/LayersRest.java @@ -28,13 +28,8 @@ @GET @Produces(MediaType.APPLICATION_JSON) public Integer getLayers(@PathParam("aid") Integer aid, @PathParam("pid") Integer pid) { - var pages = gallery.getAnimationByAid(aid).getPages(); - for (var p : pages) { - if (!p.getPid().equals(pid)) continue; - return p.getLayers().size(); - } - - throw new WebApplicationException(404); + var pages = gallery.getAnimationByAid(aid).getPageMap(); + return pages.get(pid).getLayers().size(); } @@ -47,9 +42,7 @@ @POST @Produces(MediaType.APPLICATION_JSON) public Integer addLayer(@PathParam("aid") Integer aid, @PathParam("pid") Integer pid) { - var layerSize = 4; - var pages = gallery.getAnimationByAid(aid).getPages(); - var page = (Page) null; + var pages = gallery.getAnimationByAid(aid).getPageMap(); for (var p : pages) { if (!p.getPid().equals(pid)) continue; @@ -71,12 +64,8 @@ @GET @Produces(MediaType.APPLICATION_JSON) public Integer getStrokeNo(@PathParam("aid") Integer aid, @PathParam("pid") Integer pid, @PathParam("layerNo") Integer layerNo) { - var pages = gallery.getAnimationByAid(aid).getPages(); - var strokes = new ArrayList(); - for (var p : pages) { - if (pid.equals(p.getPid())) - strokes = p.getLayers().get(layerNo).getStrokes(); - } + var pages = gallery.getAnimationByAid(aid).getPageMap(); + var strokes = pages.get(pid).getLayers().get(layerNo).getStrokes(); if (strokes == null) return null; return (strokes.size() - 1); 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 0a66e85..52a8e4d 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 @@ -17,7 +17,8 @@ @Path("/gallery") public class StrokesRest { private final Gallery gallery = Gallery.getInstance(); - + private int srstrokeSize=0; + private int srstrokeNo=0; // _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ // 1ページの1レイヤーに置ける筆跡情報を全て取得します // 成功時のレスポンス:strokeNo{pen, color, thickness, potions{x, y}} @@ -45,6 +46,7 @@ // @PathParam Integer pid ページのID // @PathParam Integer layerNo レイヤーの番号 // @FormParam Integer uid ページのID + // @FormParam Integer StrokeNo ストロークのID uid+数字 // @FormParam Integer uidToken トークン // @FormParam Integer pen ペン情報 // @FormParam Integer color 色情報 @@ -52,8 +54,8 @@ @Path("/{aid}/pageMap/{pid}/layers/{layerNo}/strokes") @POST @Produces(MediaType.APPLICATION_JSON) - public Integer addStrokes(@PathParam("aid") Integer aid, @PathParam("pid") Integer pid, @PathParam("layerNo") Integer layerNo, - @FormParam("uid") Integer uid, @FormParam("uidToken") String uidToken, @FormParam("pen") Integer pen, + public String addStrokes(@PathParam("aid") Integer aid, @PathParam("pid") Integer pid, @PathParam("layerNo") Integer layerNo, + @FormParam("uid") Integer uid, @FormParam("strokeNo") Integer strokeNo, @FormParam("uidToken") String uidToken, @FormParam("pen") Integer pen, @FormParam("color") Integer color, @FormParam("thick") Integer thick) { var pages = gallery.getAnimationByAid(aid).getPages(); var strokes = new ArrayList(); @@ -65,9 +67,14 @@ var stroke = new Stroke(); stroke.addStrokes(pen, color, thick); // 線の情報を追加 strokes.add(stroke); - stroke.setStrokeNo(strokes.size() - 1); // strokeNoに現在のstrokesのsizeを入れる + stroke.setStrokeNo(strokeNo); // strokeNoに現在のstrokesのsizeを入れる +// if(animation != null) { +// this.Test.setStrokes(pen, color, thick); +// }else{ +// throw new WebApplicationException(401); +// } - return stroke.getStrokeNo(); + return "OK!"; } // 画像URLを返す @@ -179,7 +186,7 @@ @Path("/{aid}/pageMap/{pid}/layers/{layerNo}/strokes/{strokeNo}/positions") @POST @Produces(MediaType.APPLICATION_JSON) - public Integer addPosition(@FormParam("positionNo") Integer positionNo, @PathParam("aid") Integer aid, @PathParam("pid") Integer pid, @PathParam("strokeNo") Integer strokeNo, + public String addPosition(@FormParam("positionNo") Integer positionNo, @PathParam("aid") Integer aid, @PathParam("pid") Integer pid, @PathParam("strokeNo") Integer strokeNo, @PathParam("layerNo") Integer layerNo, @FormParam("x") Float x, @FormParam("y") Float y) { var pages = gallery.getAnimationByAid(aid).getPages(); @@ -191,14 +198,26 @@ var position = new Position(); position.setXY(positionNo, x, y); - strokes.get(strokeNo).addPosition(position); // 呼び出したstrokesに座標を追加する + if(srstrokeNo==strokeNo){ + strokes.get(srstrokeSize).addPosition(position); + }else { + for(int i = 0; i < strokes.size(); i++){ + if(strokes.get(i).getStrokeNo()==strokeNo) + { + srstrokeNo=strokes.get(i).getStrokeNo(); + srstrokeSize=i; + strokes.get(i).addPosition(position); + } + } + } + // strokes.get(strokeNo).addPosition(position); // 呼び出したstrokesに座標を追加する // if(animation != null) { -//// this.Position.setXY(x, y); -//// this.positions.add(this.Position); -//// }else{ -//// throw new WebApplicationException(401); -//// } - return strokes.get(strokeNo).getPositions().size(); +////// this.Position.setXY(x, y); +////// this.positions.add(this.Position); +////// }else{ +////// throw new WebApplicationException(401); +////// } + return "OK"; } }