public class MinchoRenderer extends Renderer{ // 縦棒の幅 double width; // 縦棒に対する横棒の比率 double ratio; // ひらがなの幅 double hiraWidth; // 縦棒の始点の飾り double tateSerif; // 縦棒と横棒の交点の飾り double tateYokoSerif; // 横線の止めの縦線に対する比 double yokoSerif; public static MinchoRenderer hosoMincho= new MinchoRenderer(8.0,0.2,0.35,1.8,1.8,2.4); public static MinchoRenderer chuuMincho= new MinchoRenderer(12.0,0.4,0.6,1.5,1.4,1.8); public MinchoRenderer(double w,double r,double hw, double ts,double tys, double ys){ width=w; ratio=r; hiraWidth=hw; tateSerif=ts; tateYokoSerif=tys; yokoSerif=ys; } static Outline[] tenSample; // 点の描画 public Outline[] ten(Point[] points,ElementAnnotation[] annotations){ if(tenSample==null){ tenSample=new Outline[2]; OutlineComponent[] lc=new OutlineComponent[1]; lc[0]=new Bezier(new Point(80,171),new Point(119,214), new Point(104,256),new Point(136,255)); tenSample[0]=new Outline(lc); lc=new OutlineComponent[1]; lc[0]=new Bezier(new Point(80,171),new Point(155,204), new Point(173,251),new Point(136,255)); tenSample[1]=new Outline(lc); } // これを p0,p1にfitする return line2(points[0],points[1],width); } // 縦棒の描画 public Outline[] tate(Point[] points,ElementAnnotation[] annotations){ return line2(points[0],points[1],width); } // 横棒の描画 public Outline[] yoko(Point[] points,ElementAnnotation[] annotations){ return line2(points[0],points[1],width*ratio); } // 右上 public Outline[] migiue(Point[] points,ElementAnnotation[] annotations){ return curve2(points[0],points[1],points[2], 0.6,0.6, width,0.7*width,0.3*width,0.0); } // 左払い public Outline[] hidari(Point[] points,ElementAnnotation[] annotations){ Point p0=points[0],p1=points[1],p2=points[2]; double w=Math.min(width,0.35*p0.distance(p2)); double len01=p0.distance(p1),len12=p1.distance(p2); double ratio=len01/(len01+len12); double theta=p1.minus(p0).theta(p2.minus(p1)); double s=Math.min(1.0,theta*0.7); double w1=(1-s)*ratio*w+s*w; double r0=Math.max(0.66666,1.0+0.5*(1.0-1.0/ratio)); Point a0=p0. return curve2(points[0],points[1],points[2], 0.6,0.6, width,0.7*width,0.3*width,0.0); } // 右払い public Outline[] migi(Point[] points,ElementAnnotation[] annotations){ return curve2(points[0],points[1],points[2], 0.6,0.6, 0.5*width,0.68*width,1.03*width,1.2*width); } }