DIAVIS-wiki

GlyphVector glyph = font.createGlyphVector(new FontRenderContext(new AffineTransform(), false, false), str);
Shape outline = glyph.getGlyphOutline(m);
AffineTransform at = new AffineTransform();
at.translate(x,y);
PathIterator iter = outline.getPathIterator(at);
float coords[] = new float[6]; //取得用、PathIteratorのcurrentSegment()の引数として渡して中に値を入れてもらう。それを解析
int type;
int char_counter = 0;
while ( !iter.isDone() ) {
	/*
	 * 個々の描画セグメントを1つずつ取り出し、その描画方法を特定している点列の座標値を得る。
	 *
	 * 描画方法の種類としては、
	 * 	SEG_MOVETO	(ペンの移動)
	 * 	SEG_LINETO	(線分の描画)
	 * 	SEG_CUBICTO	(3点指定のベジエ曲線の描画)
	 * 	SEG_QUADTO	(2点指定のベジエ曲線の描画)
	 * 	SEG_CLOSE	(最初の点に戻る)
	 * がある。
	 */
	type = iter.currentSegment(coords);
	int z = 0;
	Point p;
	float[] fs = new float[6];
	lists[m].add( new SegmentObject( this, type, coords.clone()) );
	switch ( type ) {
		case PathIterator.SEG_CLOSE:
			paths[m].closePath();
			break;
		case PathIterator.SEG_CUBICTO:
			for ( int i = 0 ; i < 6 ; i+=2 ) {
				fs[i]   = coords[i];
				fs[i+1] = coords[i+1];
				//points.add(new Point3d((int)coords[i],(int)coords[i+1],z));
			}
			paths[m].curveTo(fs[0],fs[1],fs[2],fs[3],fs[4],fs[5]);
			break;
		case PathIterator.SEG_LINETO:
			for ( int i = 0 ; i < 2 ; i+=2 ) {
				fs[i]   = coords[i];
				fs[i+1] = coords[i+1];
			}
			paths[m].lineTo(fs[0],fs[1]);
			break;
		case PathIterator.SEG_MOVETO:
			for ( int i = 0 ; i < 2 ; i+=2 ) {
				fs[i]   = coords[i];
				fs[i+1] = coords[i+1];
			}
			paths[m].moveTo(fs[0],fs[1]);
			break;
		case PathIterator.SEG_QUADTO:
			//System.out.println("QUADTO :");
			for ( int i = 0 ; i < 4 ; i+=2 ) {
				fs[i]   = coords[i];
				fs[i+1] = coords[i+1];
			}
			paths[m].quadTo(fs[0],fs[1],fs[2],fs[3]);
			break;
	}
	iter.next();
トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS