diff --git a/src/main/java/cit/PureATN/KeyEvent_on_Note.java b/src/main/java/cit/PureATN/KeyEvent_on_Note.java new file mode 100644 index 0000000..643fad0 --- /dev/null +++ b/src/main/java/cit/PureATN/KeyEvent_on_Note.java @@ -0,0 +1,105 @@ +package cit.PureATN; + +import java.awt.event.KeyListener; + +import org.piccolo2d.PCanvas; +import org.piccolo2d.activities.PTransformActivity; +import org.piccolo2d.util.PBounds; + +import java.awt.event.KeyEvent; + +public class KeyEvent_on_Note implements KeyListener { + + PCanvas canvas; + + public KeyEvent_on_Note(PCanvas _canvas) { + canvas = _canvas; + canvas.requestFocus(); + } + + public void keyTyped(KeyEvent e) { + } + + public void keyReleased(KeyEvent e) { + } + + public void keyPressed(KeyEvent e) { + System.out.println("keyCode=" + e.getKeyCode() + " keyChar [" + e.getKeyChar() + "]"); + if (e.getKeyCode() == 27) {// ESC + PTransformActivity ta = canvas.getCamera().animateViewToCenterBounds(canvas.getLayer().getFullBounds(), + true, 1000); + // ta.setStartTime(0); + } + if (e.getKeyCode() == KeyEvent.VK_ENTER || e.getKeyCode() == KeyEvent.VK_F || e.getKeyCode() == KeyEvent.VK_R + || e.getKeyCode() == KeyEvent.VK_M) { + // if (zrh.selection != null){ + // if (zrh.pressN != null && zrh.pressN instanceof Sheet){ + // Sheet s = (Sheet)zrh.pressN; + // s.collect(zrh.selection, e.getKeyCode()); + // } + // if (zrh.pressN != null && zrh.pressN instanceof SSGroup){ //SSGRoup + // だったら,シートに変換 + // SSGroup ssg = (SSGroup)zrh.pressN; + // ssg.sheet.collect(zrh.selection, e.getKeyCode()); + // } + // } + // zrh.dismissRegionLater(); + } + if (e.getKeyCode() == KeyEvent.VK_Z) { + // System.out.println("SimpleATN zoomLevel = "+getZoomLevel()); + } + if (e.getKeyCode() == KeyEvent.VK_A || e.getKeyCode() == KeyEvent.VK_0) { + // // addNote(); + // for(int i=0;i<7;i++){ + // sheetVisibleMode[i]=2; + // } + // sheetVisibleToolbuttons.updateStatus(); + // setSheetVisible(-1, 2); + } + if (e.getKeyCode() == KeyEvent.VK_F11) { + // menutoolbar.getButton("Full Screen").doClick(); + } + + // 範囲選択中なら... + // if (zrh.isDragging() && zrh.selection != null){ + // if (KeyEvent.VK_1 <= e.getKeyCode() && e.getKeyCode() <= KeyEvent.VK_5){ + // //領域フィルタに追加 + // if (zrh.pressN != null && zrh.pressN instanceof Sheet){ + // Sheet s = (Sheet)zrh.pressN; + // ConfigWindow.configWin.filter.addRegionFilter(s, zrh.selection, + // e.getKeyCode()); + // } + // if (zrh.pressN != null && zrh.pressN instanceof SSGroup){ //SSGRoup + // だったら,シートに変換 + // SSGroup ssg = (SSGroup)zrh.pressN; + // // ssg.sheet.collect(zrh.selection, e.getKeyCode()); + // ConfigWindow.configWin.filter.addRegionFilter(ssg.sheet, zrh.selection, + // e.getKeyCode()); + // } + // zrh.dismissRegionLater(); + // } + // } else { + // if (KeyEvent.VK_1 <= e.getKeyCode() && e.getKeyCode() <= KeyEvent.VK_6){ + // } + // } + // PBounds pb = getCanvas().getCamera().getViewBounds(); + // int keyCode = e.getKeyCode(); + // if (keyCode == 38) {// 上 + // pb.moveBy(0, -pb.getHeight()); + // zoomToBounds(pb,1000,"KeyPan"); + // } + // if (keyCode == 37) {// 左 + // pb.moveBy(-pb.getWidth(),0); + // zoomToBounds(pb,1000,"KeyPan"); + // } + // if (keyCode == 39) {// 右 + // pb.moveBy(pb.getWidth(),0); + // zoomToBounds(pb,1000,"KeyPan"); + // } + // if (keyCode == 40) {// 下 + // pb.moveBy(0,pb.getHeight()); + // zoomToBounds(pb,1000,"KeyPan"); + // } + // } + } +} diff --git a/src/main/java/cit/PureATN/Note.java b/src/main/java/cit/PureATN/Note.java index 118cf9c..1ff26d7 100644 --- a/src/main/java/cit/PureATN/Note.java +++ b/src/main/java/cit/PureATN/Note.java @@ -24,7 +24,7 @@ public static PInputEventFilter disablemask = new PInputEventFilter(0); public static Note theapp; // The Application -public DPenReceiver dPenReceiver; + public DPenReceiver dPenReceiver; public Note() { this(null); @@ -35,7 +35,7 @@ public Note(final PCanvas aCanvas) { super("Note", false, aCanvas); setSize(650, 800); - setLocation(10,10); + setLocation(10, 10); dPenReceiver = new DPenReceiver(this); } @@ -44,7 +44,8 @@ super.initialize(); // らくがき用マウスイベント - // final PBasicInputEventHandler squiggleEventHandler = createSSSquiggleEventHandler(); + // final PBasicInputEventHandler squiggleEventHandler = + // createSSSquiggleEventHandler(); final PBasicInputEventHandler squiggleEventHandler = createSquiggleEventHandler(); squiggleEventHandler.setEventFilter(new PInputEventFilter(InputEvent.BUTTON1_MASK)); getCanvas().removeInputEventListener(getCanvas().getPanEventHandler()); @@ -54,11 +55,13 @@ final PMouseWheelZoomEventHandler mouseWheelZoomEventHandler = new PMouseWheelZoomEventHandler(); getCanvas().addInputEventListener(mouseWheelZoomEventHandler); - // pan - // final MyPPanEventHandler panEventHandler = new MyPPanEventHandler(getCanvas()); - // panEventHandler.setEventFilter(disablemask); - // getCanvas().addInputEventListener(panEventHandler); + // pan + // final MyPPanEventHandler panEventHandler = new + // MyPPanEventHandler(getCanvas()); + // panEventHandler.setEventFilter(disablemask); + // getCanvas().addInputEventListener(panEventHandler); + getCanvas().addKeyListener( new KeyEvent_on_Note( getCanvas() ) ); layer = getCanvas().getLayer(); @@ -68,52 +71,51 @@ } // public PBasicInputEventHandler createSSSquiggleEventHandler() { - // return new PBasicInputEventHandler() { + // return new PBasicInputEventHandler() { - // protected ShortStroke squiggle; - // int dragCount = 0; - // Point2D pressP; + // protected ShortStroke squiggle; + // int dragCount = 0; + // Point2D pressP; - // public void mousePressed(final PInputEvent aEvent) { - // pressP = aEvent.getPositionRelativeTo(layer); - // dragCount = 0; - // } - // public void mouseDragged(final PInputEvent aEvent) { - // dragCount++; - // if (squiggle == null) { - // squiggle = new ShortStroke(); - - // squiggle.penid = 1; - // squiggle.paperid = 1; - // squiggle.time = System.currentTimeMillis(); - // squiggle.addPoint(pressP); - // squiggle.applyTempPtsToAry(); - // squiggle.moveTo( pressP.getX(), pressP.getY() ); - // squiggle.setTransparency(0.7f); - // // squiggle.rebuildStroke(); - - // layer.addChild(squiggle); - - // } else { - // Point2D inkp = aEvent.getPositionRelativeTo(layer); - // squiggle.addPoint(inkp); - // squiggle.lineTo( inkp.getX(),inkp.getY()); - // } - // } - // public void mouseReleased(final PInputEvent aEvent) { - - // if (dragCount < 3){ - - // } else { - - // squiggle.play(300); - // squiggle = null; - // } - // } - - // }; + // public void mousePressed(final PInputEvent aEvent) { + // pressP = aEvent.getPositionRelativeTo(layer); + // dragCount = 0; + // } + // public void mouseDragged(final PInputEvent aEvent) { + // dragCount++; + // if (squiggle == null) { + // squiggle = new ShortStroke(); + + // squiggle.penid = 1; + // squiggle.paperid = 1; + // squiggle.time = System.currentTimeMillis(); + // squiggle.addPoint(pressP); + // squiggle.applyTempPtsToAry(); + // squiggle.moveTo( pressP.getX(), pressP.getY() ); + // squiggle.setTransparency(0.7f); + // // squiggle.rebuildStroke(); + + // layer.addChild(squiggle); + + // } else { + // Point2D inkp = aEvent.getPositionRelativeTo(layer); + // squiggle.addPoint(inkp); + // squiggle.lineTo( inkp.getX(),inkp.getY()); + // } + // } + // public void mouseReleased(final PInputEvent aEvent) { + + // if (dragCount < 3){ + + // } else { + + // squiggle.play(300); + // squiggle = null; + // } // } + // }; + // } public PBasicInputEventHandler createSquiggleEventHandler() { return new PDragSequenceEventHandler() { @@ -127,8 +129,9 @@ squiggle = new ShortStroke(); layer.addChild(squiggle); - squiggle.startDrag_on_draw(p.getX(), p.getY()); - // squiggle.setStroke(new BasicStroke((float) (3 / e.getCamera().getViewScale()))); + squiggle.startDrag_on_draw(p.getX(), p.getY()); + // squiggle.setStroke(new BasicStroke((float) (3 / + // e.getCamera().getViewScale()))); layer.repaint(); } @@ -148,14 +151,12 @@ public void updateSquiggle(final PInputEvent aEvent) { final Point2D p = aEvent.getPosition(); - squiggle.drag_on_draw( p.getX(), p.getY()); + squiggle.drag_on_draw(p.getX(), p.getY()); layer.repaint(); } }; } - - public static void main(final String[] args) { new Note(); } diff --git a/src/main/java/cit/PureATN/ShortStroke.java b/src/main/java/cit/PureATN/ShortStroke.java index 6c48c2d..a5d40c4 100644 --- a/src/main/java/cit/PureATN/ShortStroke.java +++ b/src/main/java/cit/PureATN/ShortStroke.java @@ -4,13 +4,7 @@ import java.awt.Shape; import java.awt.geom.GeneralPath; import java.awt.geom.Point2D; -import java.io.BufferedOutputStream; -import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; -import java.io.FileNotFoundException; -import java.io.IOException; import java.io.Serializable; -import java.lang.reflect.Field; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; @@ -19,14 +13,13 @@ import java.util.StringTokenizer; import java.util.Vector; -import org.piccolo2d.PNode; import org.piccolo2d.activities.PActivity; import org.piccolo2d.nodes.PPath; import org.piccolo2d.util.PBounds; /** - * 生徒の筆記(1ストローク)モデル + * 生徒の筆記(1ストローク)モデル Zoom可能な画面に表示するためのクラス * @author miuramo * */ @@ -34,7 +27,7 @@ private static final long serialVersionUID = 5928762332664417016L; //TODO: 筆記解析をするならtrue - public transient static boolean doAssess = false; + // public transient static boolean doAssess = false; public float[] sx; public float[] sy; @@ -49,8 +42,8 @@ public transient long id; public transient ArrayList tempPts; - public transient PNode ink; - public transient Point2D startp; + // public transient PNode ink; + // public transient Point2D startp; public transient Shape full; // transient Event_onSS event_onss = null; @@ -78,9 +71,9 @@ return s.substring(0,s.length()-1); } - public transient int interval; - public transient Thread playthread; - public transient boolean playing; + // public transient int interval; + // public transient Thread playthread; + // public transient boolean playing; //for playing public transient ArrayList shapel; @@ -128,7 +121,7 @@ setStroke(getCachedBasicStroke(width)); time = _time; setTransparency(0.7f); - playing = false; + // playing = false; } // startDragのまえに、layer.addChildしておく public void startDrag_on_draw(double px, double py){ @@ -153,7 +146,6 @@ } } - public Color getColor(){ return ShortStroke.getColor(color); } @@ -182,21 +174,22 @@ } public synchronized void run() { - playing = true; - reset(); - ink.addChild(this); - moveTo(sx[0], sy[0]); - for (int i = 1; i < sx.length; i++) { - lineTo(sx[i], sy[i]); - ink.repaintFrom(getBoundsReference(), this); - try { - Thread.sleep(interval); - } catch (InterruptedException e) { - e.printStackTrace(); - } - if (!playing) - return; - } + // playing = true; + // reset(); + // ink.addChild(this); + // moveTo(sx[0], sy[0]); + // for (int i = 1; i < sx.length; i++) { + // lineTo(sx[i], sy[i]); + // ink.repaintFrom(getBoundsReference(), this); + // try { + // Thread.sleep(interval); + // } catch (InterruptedException e) { + // e.printStackTrace(); + // } + // if (!playing) + // return; + // } + // removeFromParent(); // ink.addChild(this); // ink.repaintFrom(getBoundsReference(), this); @@ -204,30 +197,30 @@ // if (SnailServer.server.recognizeCB.isSelected()) // note.recognize(this); // note.student.afterAddDBStroke(note, this); - stop(); + // stop(); } - public void suspend() { - synchronized (playthread) { - try { - playthread.wait(); // プロセスを休止する - } catch (InterruptedException e) { - } - } - } + // public void suspend() { + // synchronized (playthread) { + // try { + // playthread.wait(); // プロセスを休止する + // } catch (InterruptedException e) { + // } + // } + // } - public synchronized void resume() { - playthread.notify(); - } + // public synchronized void resume() { + // playthread.notify(); + // } - public void stop() { - if (playing) - playing = false; - if (playthread != null) - playthread = null; - // ink.repaint(); - } + // public void stop() { + // if (playing) + // playing = false; + // if (playthread != null) + // playthread = null; + // // ink.repaint(); + // } public synchronized PPath genStroke(String protocol, float inkscale) { return genStroke_old(protocol, inkscale); @@ -339,16 +332,16 @@ // return this; } - public void calcMetrics(){ - if (dist < 0){ //初期値は-1なので。はじめてかどうかのチェック - lengthInPixel(); - maxspeedInPixel(); - varspeedInPixel(); - angle(); - ramer(); - log(); - } - } + // public void calcMetrics(){ + // // if (dist < 0){ //初期値は-1なので。はじめてかどうかのチェック + // // // lengthInPixel(); + // // // maxspeedInPixel(); + // // // varspeedInPixel(); + // // // angle(); + // // // ramer(); + // // // log(); + // // } + // } // public void exportBySieve(){ //TODO: // calcMetrics(); // FileReadWriter.buffer.add(var_ramer+","+num_choten+","+num_choten2+","+ramer+","+penid+","+time+","+ppd+","+pts+","+dist); @@ -370,8 +363,8 @@ // //System.out.println(penid+" "+paperid+" count "+sx.length+" len "+length+" avg "+avgspeed+" var "+varspeed+" max "+maxspeed+" td "+timediff); // //太さと色を設定 // } - public void exportBySieveAverage(){ //TODO: - calcMetrics(); + // public void exportBySieveAverage(){ //TODO: + // calcMetrics(); /* * FileReadWriter.buffer.add(id+","+time+","+sbackid+","+penid+","+paperid+","+ sx.length+","+length+","+avgspeed+","+varspeed+","+varspeed2+","+maxspeed+","+timediff+","+timed+","+ @@ -389,7 +382,7 @@ // //System.out.println(penid+" "+paperid+" count "+sx.length+" len "+length+" avg "+avgspeed+" var "+varspeed+" max "+maxspeed+" td "+timediff); //太さと色を設定 - } + // } public synchronized PPath rebuildStroke() { setStroke(getCachedBasicStroke(width)); @@ -468,56 +461,56 @@ * @param sy Y座標配列 * @return DB格納用バイトデータ */ - public byte[] getXYBytes() { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - BufferedOutputStream bos; - DataOutputStream dos; - try { - bos = new BufferedOutputStream(baos); - dos = new DataOutputStream(bos); +// public byte[] getXYBytes() { +// ByteArrayOutputStream baos = new ByteArrayOutputStream(); +// BufferedOutputStream bos; +// DataOutputStream dos; +// try { +// bos = new BufferedOutputStream(baos); +// dos = new DataOutputStream(bos); - dos.writeInt(sx.length); - for (int i = 0; i < sx.length; i++) { - dos.writeFloat(sx[i]); - } - for (int i = 0; i < sy.length; i++) { - dos.writeFloat(sy[i]); - } - dos.close(); - bos.close(); - baos.close(); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - return baos.toByteArray(); - } - public byte[] getPseudoPPBytes() { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - BufferedOutputStream bos; - DataOutputStream dos; - try { - bos = new BufferedOutputStream(baos); - dos = new DataOutputStream(bos); +// dos.writeInt(sx.length); +// for (int i = 0; i < sx.length; i++) { +// dos.writeFloat(sx[i]); +// } +// for (int i = 0; i < sy.length; i++) { +// dos.writeFloat(sy[i]); +// } +// dos.close(); +// bos.close(); +// baos.close(); +// } catch (FileNotFoundException e) { +// e.printStackTrace(); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// return baos.toByteArray(); +// } +// public byte[] getPseudoPPBytes() { +// ByteArrayOutputStream baos = new ByteArrayOutputStream(); +// BufferedOutputStream bos; +// DataOutputStream dos; +// try { +// bos = new BufferedOutputStream(baos); +// dos = new DataOutputStream(bos); - dos.writeInt(sx.length); - for (int i = 0; i < sx.length; i++) { - dos.writeShort(128); - } - dos.close(); - bos.close(); - baos.close(); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - return baos.toByteArray(); - } - public void debugPrint() { -// System.out.println("SSDebug "+penid+" "+paperid+" "+new Date(time)); - } +// dos.writeInt(sx.length); +// for (int i = 0; i < sx.length; i++) { +// dos.writeShort(128); +// } +// dos.close(); +// bos.close(); +// baos.close(); +// } catch (FileNotFoundException e) { +// e.printStackTrace(); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// return baos.toByteArray(); +// } +// public void debugPrint() { +// // System.out.println("SSDebug "+penid+" "+paperid+" "+new Date(time)); +// } public ShortStroke clone(){ ShortStroke newss = new ShortStroke(); @@ -546,7 +539,7 @@ } public void play(int _interval /* PNode _ink, PNode _redink, Note n*/) { - if (playing) return; + // if (playing) return; // this.prepareStrokeList(_ink); // for(TimePlayPath tpp: strokelist){ // // tpp.snip.setTransparency(0.0f); @@ -555,15 +548,15 @@ // ink = _ink; // redink = _redink; // note = n; - interval = _interval; - playthread = new Thread(this); + // interval = _interval; + // playthread = new Thread(this); - playthread.start(); - try { - playthread.join(); - } catch (InterruptedException e) { - e.printStackTrace(); - } + // playthread.start(); + // try { + // playthread.join(); + // } catch (InterruptedException e) { + // e.printStackTrace(); + // } } // 現在の形状をリストに追加 @@ -606,290 +599,290 @@ return sx.length; } //TODO: - public transient double[] speedary; - public transient double[] speedary2; - public transient double dist = -1; - public transient double length2; - public transient double avgspeed; - public transient double avgspeed2; - public transient double varspeed; - public transient double varspeed2; - public transient double maxspeed; - public transient ShortStroke previous; - public transient long timediff; - public transient long timed; - public transient double[] angleary ; - public transient double[] angleary2 ; - public transient double[] angleary3 ; - public transient int num_choten = 0;//90度以上の点の数 - public transient int num_choten2 = 0;//90度以上の点の数 ノイズ除去ver - public transient double sumangle, avgangle; - public transient double varangle; - public transient int ramer; - public transient double choten1_var; - public transient double choten1_avg; - public transient double choten2_var; - public transient double choten2_avg; - public transient int kukan2; - public transient double var_oreten; - public transient double var_ramer; - public transient double ramerthre; - public transient double ppd, pps,ppr; - public transient double pts, dbltime; + // public transient double[] speedary; + // public transient double[] speedary2; + // public transient double dist = -1; + // public transient double length2; + // public transient double avgspeed; + // public transient double avgspeed2; + // public transient double varspeed; + // public transient double varspeed2; + // public transient double maxspeed; + // public transient ShortStroke previous; + // public transient long timediff; + // public transient long timed; + // public transient double[] angleary ; + // public transient double[] angleary2 ; + // public transient double[] angleary3 ; + // public transient int num_choten = 0;//90度以上の点の数 + // public transient int num_choten2 = 0;//90度以上の点の数 ノイズ除去ver + // public transient double sumangle, avgangle; + // public transient double varangle; + // public transient int ramer; + // public transient double choten1_var; + // public transient double choten1_avg; + // public transient double choten2_var; + // public transient double choten2_avg; + // public transient int kukan2; + // public transient double var_oreten; + // public transient double var_ramer; + // public transient double ramerthre; + // public transient double ppd, pps,ppr; + // public transient double pts, dbltime; - public int pos; //水井筆記のpos - public String tag; + // public int pos; //水井筆記のpos + // public String tag; - public void print_metrics2(){ - String a[] = new String[]{"var_ramer","ppd","pts","length", "current_begin"}; - for(String fn: a){ - Field f = null; - try { - f = ShortStroke.class.getField(fn); - } catch (NoSuchFieldException e) { - e.printStackTrace(); - } catch (SecurityException e) { - e.printStackTrace(); - } +// public void print_metrics2(){ +// String a[] = new String[]{"var_ramer","ppd","pts","length", "current_begin"}; +// for(String fn: a){ +// Field f = null; +// try { +// f = ShortStroke.class.getField(fn); +// } catch (NoSuchFieldException e) { +// e.printStackTrace(); +// } catch (SecurityException e) { +// e.printStackTrace(); +// } - try { - System.out.println(fn+" : "+f.get(this)); - } catch (IllegalArgumentException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - } - System.out.println(""); - } - public void print_metrics(){ - ShortStroke clone = this.clone(); - clone.calcMetrics(); - String a[] = new String[]{"ramerthre","varspeed2","numrammer","var_ramer", "length"}; - for(String fn: a){ - Field f = null; - try { - f = ShortStroke.class.getField(fn); - } catch (NoSuchFieldException e) { - e.printStackTrace(); - } catch (SecurityException e) { - e.printStackTrace(); - } +// try { +// System.out.println(fn+" : "+f.get(this)); +// } catch (IllegalArgumentException e) { +// e.printStackTrace(); +// } catch (IllegalAccessException e) { +// e.printStackTrace(); +// } +// } +// System.out.println(""); +// } +// public void print_metrics(){ +// ShortStroke clone = this.clone(); +// clone.calcMetrics(); +// String a[] = new String[]{"ramerthre","varspeed2","numrammer","var_ramer", "length"}; +// for(String fn: a){ +// Field f = null; +// try { +// f = ShortStroke.class.getField(fn); +// } catch (NoSuchFieldException e) { +// e.printStackTrace(); +// } catch (SecurityException e) { +// e.printStackTrace(); +// } - try { - System.out.println(fn+" : "+f.get(clone)); - } catch (IllegalArgumentException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - } - System.out.println("size : "+clone.sx.length); - for(double d: clone.speedary) System.out.print(d+" "); - System.out.println(""); - } - private void log() { - var_oreten = varspeed /( Math.log10(num_choten2+2)); - var_ramer = varspeed / (Math.log10(ramer+2)); - ppd = sx.length/dist; - pps = sx.length/(ramerthre*5); - ppr = sx.length/(ramer+1); - pts = sx.length; - dbltime = (double)(time - 1360901083972L)/1000; -// System.out.println("Math.log10 = "+Math.log10(numrammer+2)); - } +// try { +// System.out.println(fn+" : "+f.get(clone)); +// } catch (IllegalArgumentException e) { +// e.printStackTrace(); +// } catch (IllegalAccessException e) { +// e.printStackTrace(); +// } +// } +// System.out.println("size : "+clone.sx.length); +// for(double d: clone.speedary) System.out.print(d+" "); +// System.out.println(""); +// } +// private void log() { +// var_oreten = varspeed /( Math.log10(num_choten2+2)); +// var_ramer = varspeed / (Math.log10(ramer+2)); +// ppd = sx.length/dist; +// pps = sx.length/(ramerthre*5); +// ppr = sx.length/(ramer+1); +// pts = sx.length; +// dbltime = (double)(time - 1360901083972L)/1000; +// // System.out.println("Math.log10 = "+Math.log10(numrammer+2)); +// } - private void ramer() { - float minx=java.lang.Float.MAX_VALUE,maxx=java.lang.Float.MIN_VALUE,miny=java.lang.Float.MAX_VALUE,maxy=java.lang.Float.MIN_VALUE; - for(int i=0;i maxx) maxx = sx[i]; - if (sy[i] < miny) miny = sy[i]; - if (sy[i] > maxy) maxy = sy[i]; - } - double w = maxx-minx; - double h = maxy-miny; - ramerthre = (w > h) ? w/5 : h/5; - //TODO: ramer = Rammer.getRammerPoints(sx, sy, (float)ramerthre).size()-2; - } +// private void ramer() { +// float minx=java.lang.Float.MAX_VALUE,maxx=java.lang.Float.MIN_VALUE,miny=java.lang.Float.MAX_VALUE,maxy=java.lang.Float.MIN_VALUE; +// for(int i=0;i maxx) maxx = sx[i]; +// if (sy[i] < miny) miny = sy[i]; +// if (sy[i] > maxy) maxy = sy[i]; +// } +// double w = maxx-minx; +// double h = maxy-miny; +// ramerthre = (w > h) ? w/5 : h/5; +// //TODO: ramer = Rammer.getRammerPoints(sx, sy, (float)ramerthre).size()-2; +// } - private void angle() { - if (sx.length > 2) { - angleary = new double[sx.length-2]; - num_choten = 0; - //1または2か所の合計で80以上曲がっている折れ点の数を数える。 - double prev_angle = -1.0; - boolean isprev_choten = false; - for(int i=0;i -0.17) { - num_choten++; - isprev_choten = true; - } - else if ((cos + prev_angle > -1.53) && isprev_choten==false) {//(cos > -0.8) && (prev_angle > -0.8) - num_choten++; - isprev_choten = true; - } else { - isprev_choten = false; - } - sumangle += cos; - prev_angle = cos; - } - } - // 初めの二つの角度について除外 - if(sx.length > 4){ - angleary2 = new double[sx.length-4]; - double prev_angle2 = -1.0; - boolean isprev_choten2 = false; - num_choten2 = 0; - for(int i=0;i -0.17) { - num_choten2++; - isprev_choten2 = true; - } - else if ((cos2 + prev_angle2 > -1.53) && isprev_choten2==false) {//(cos > -0.8) && (prev_angle > -0.8) - num_choten2++; - isprev_choten2 = true; - } else { - isprev_choten2 = false; - } - prev_angle2 = cos2; - } - //折れ点の数をノイズ分ひく - if(angleary2.length > 0){ - if(angleary2[angleary2.length-1] > -0.17 && speedary[speedary.length-1] < 1.0){ - num_choten2--; - } - } - if(angleary2.length > 1){ - if(angleary2[angleary2.length-2] > -0.17 && (speedary[speedary.length-1]+speedary[speedary.length-2]) < 2.0){ - num_choten2--; - } - } - } - } +// private void angle() { +// if (sx.length > 2) { +// angleary = new double[sx.length-2]; +// num_choten = 0; +// //1または2か所の合計で80以上曲がっている折れ点の数を数える。 +// double prev_angle = -1.0; +// boolean isprev_choten = false; +// for(int i=0;i -0.17) { +// num_choten++; +// isprev_choten = true; +// } +// else if ((cos + prev_angle > -1.53) && isprev_choten==false) {//(cos > -0.8) && (prev_angle > -0.8) +// num_choten++; +// isprev_choten = true; +// } else { +// isprev_choten = false; +// } +// sumangle += cos; +// prev_angle = cos; +// } +// } +// // 初めの二つの角度について除外 +// if(sx.length > 4){ +// angleary2 = new double[sx.length-4]; +// double prev_angle2 = -1.0; +// boolean isprev_choten2 = false; +// num_choten2 = 0; +// for(int i=0;i -0.17) { +// num_choten2++; +// isprev_choten2 = true; +// } +// else if ((cos2 + prev_angle2 > -1.53) && isprev_choten2==false) {//(cos > -0.8) && (prev_angle > -0.8) +// num_choten2++; +// isprev_choten2 = true; +// } else { +// isprev_choten2 = false; +// } +// prev_angle2 = cos2; +// } +// //折れ点の数をノイズ分ひく +// if(angleary2.length > 0){ +// if(angleary2[angleary2.length-1] > -0.17 && speedary[speedary.length-1] < 1.0){ +// num_choten2--; +// } +// } +// if(angleary2.length > 1){ +// if(angleary2[angleary2.length-2] > -0.17 && (speedary[speedary.length-1]+speedary[speedary.length-2]) < 2.0){ +// num_choten2--; +// } +// } +// } +// } - public void setPreviousSS(ShortStroke pre){ - if (pre == null) return; - if (pre.penid != this.penid) return; - // if (pre.paperid != this.paperid) return; - if (pre.id == this.id-1) { - previous = pre; - timediff = this.time - previous.time; - long pretime = ((previous.sx.length-1)*1000)/75; - timed = timediff - pretime; - } - } - //筆記のパスの長さ(これをgetSteps()で割ったら平均速度になる) - public double lengthInPixel(){ - double len = 0; - double len2 = 0; - if (sx.length>1){ - speedary = new double[sx.length-1]; - for(int i=1;i 3) { - speedary2 = new double[sx.length-3]; - for(int i=3;i 4 ) { - for(int i=0;i 1){ +// public void setPreviousSS(ShortStroke pre){ +// if (pre == null) return; +// if (pre.penid != this.penid) return; +// // if (pre.paperid != this.paperid) return; +// if (pre.id == this.id-1) { +// previous = pre; +// timediff = this.time - previous.time; +// long pretime = ((previous.sx.length-1)*1000)/75; +// timed = timediff - pretime; +// } +// } +// //筆記のパスの長さ(これをgetSteps()で割ったら平均速度になる) +// public double lengthInPixel(){ +// double len = 0; +// double len2 = 0; +// if (sx.length>1){ +// speedary = new double[sx.length-1]; +// for(int i=1;i 3) { +// speedary2 = new double[sx.length-3]; +// for(int i=3;i 4 ) { +// for(int i=0;i 1){ - if(angleary3[angleary3.length-1] > -0.17 && speedary[speedary.length-1] < 1.0){ -// System.out.println("ts"); - len2 = len2 - speedary2[speedary2.length-1]; - kukan2 = kukan2 - 1; - } - } - if(angleary3.length > 2){ - if(angleary3[angleary3.length-2] > -0.17 && (speedary[speedary.length-1]+speedary[speedary.length-2]) < 2.0){ - len2 = len2 - speedary2[speedary2.length-1] - speedary2[speedary2.length-2]; - kukan2 = kukan2 - 2; - } - } - } - dist = len; - length2 = len2; - return len; - } +// if(angleary3[angleary3.length-1] > -0.17 && speedary[speedary.length-1] < 1.0){ +// // System.out.println("ts"); +// len2 = len2 - speedary2[speedary2.length-1]; +// kukan2 = kukan2 - 1; +// } +// } +// if(angleary3.length > 2){ +// if(angleary3[angleary3.length-2] > -0.17 && (speedary[speedary.length-1]+speedary[speedary.length-2]) < 2.0){ +// len2 = len2 - speedary2[speedary2.length-1] - speedary2[speedary2.length-2]; +// kukan2 = kukan2 - 2; +// } +// } +// } +// dist = len; +// length2 = len2; +// return len; +// } - public double maxspeedInPixel(){ //最大瞬間速度 - double len = 0; - double tmp = 0; - if (sx.length >1){ - if (speedary == null) lengthInPixel(); - for(int i=0;i1){ +// if (speedary == null) lengthInPixel(); +// for(int i=0;i1){ - if (speedary == null) lengthInPixel(); - avgspeed = dist/speedary.length; //平均速度 - for(int i=0;i3){ +// if (sx.length >1){ +// if (speedary == null) lengthInPixel(); +// avgspeed = dist/speedary.length; //平均速度 +// for(int i=0;i3){ - if (speedary2 == null) lengthInPixel(); - avgspeed2 = length2/kukan2;//平均速度 - for(int i=0;i