当前位置: 首页>>代码示例>>Java>>正文


Java FlatteningPathIterator.currentSegment方法代码示例

本文整理汇总了Java中java.awt.geom.FlatteningPathIterator.currentSegment方法的典型用法代码示例。如果您正苦于以下问题:Java FlatteningPathIterator.currentSegment方法的具体用法?Java FlatteningPathIterator.currentSegment怎么用?Java FlatteningPathIterator.currentSegment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.geom.FlatteningPathIterator的用法示例。


在下文中一共展示了FlatteningPathIterator.currentSegment方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: describeShapeDetail

import java.awt.geom.FlatteningPathIterator; //导入方法依赖的package包/类
/**
 * Utility method that iterates over a Shape object and prints out the
 * points. The flattening is used for a FlatteningPathIterator, controlling
 * the scope of the path traversal.
 */
public static void describeShapeDetail(Shape shape, double flattening) {
    PathIterator pi2 = shape.getPathIterator(null);
    FlatteningPathIterator pi = new FlatteningPathIterator(pi2, flattening);
    double[] coords = new double[6];
    int pointCount = 0;

    Debug.output(" -- start describeShapeDetail with flattening[" + flattening + "]");
    while (!pi.isDone()) {
        int type = pi.currentSegment(coords);
        Debug.output(" Shape point [" + type + "] (" + (pointCount++) + ") " + coords[0] + ", "
                + coords[1]);
        pi.next();
    }

    Debug.output(" -- end (" + pointCount + ")");
}
 
开发者ID:d2fn,项目名称:passage,代码行数:22,代码来源:BasicGeometry.java

示例2: detectCollision

import java.awt.geom.FlatteningPathIterator; //导入方法依赖的package包/类
/**
 * Determines, whether or not a given point p is in an epsilon-neighbourhood
 * for the cubic curve.
 */
public boolean detectCollision(Point p) {
	if (arrowLinkCurve == null)
		return false;
	Rectangle2D rec = getControlPoint(p);
	// flatten the curve and test for intersection (bug fix, fc, 16.1.2004).
	FlatteningPathIterator pi = new FlatteningPathIterator(
			arrowLinkCurve.getPathIterator(null),
			MAXIMAL_RECTANGLE_SIZE_FOR_COLLISION_DETECTION / 4, 10/*
																 * =maximal
																 * 2^10=1024
																 * points.
																 */);
	double oldCoordinateX = 0, oldCoordinateY = 0;
	while (pi.isDone() == false) {
		double[] coordinates = new double[6];
		int type = pi.currentSegment(coordinates);
		switch (type) {
		case PathIterator.SEG_LINETO:
			if (rec.intersectsLine(oldCoordinateX, oldCoordinateY,
					coordinates[0], coordinates[1]))
				return true;
			/*
			 * this case needs the same action as the next case, thus no
			 * "break"
			 */
		case PathIterator.SEG_MOVETO:
			oldCoordinateX = coordinates[0];
			oldCoordinateY = coordinates[1];
			break;
		case PathIterator.SEG_QUADTO:
		case PathIterator.SEG_CUBICTO:
		case PathIterator.SEG_CLOSE:
		default:
			break;
		}
		pi.next();
	}
	return false;
}
 
开发者ID:iwabuchiken,项目名称:freemind_1.0.0_20140624_214725,代码行数:44,代码来源:ArrowLinkView.java

示例3: shape2polyCoords

import java.awt.geom.FlatteningPathIterator; //导入方法依赖的package包/类
/**
 * Convert AWT shape to image map coordinates.
 * 
 * @param shape
 * @return
 */
private String shape2polyCoords( Shape shape )
{
	if ( shape == null )
	{
		return null;
	}

	ArrayList<Double> al = new ArrayList<Double>( );

	FlatteningPathIterator pitr = new FlatteningPathIterator( shape.getPathIterator( null ),
			1 );
	double[] data = new double[6];

	while ( !pitr.isDone( ) )
	{
		int type = pitr.currentSegment( data );

		switch ( type )
		{
			case PathIterator.SEG_MOVETO :
				al.add( new Double( data[0] ) );
				al.add( new Double( data[1] ) );
				break;
			case PathIterator.SEG_LINETO :
				al.add( new Double( data[0] ) );
				al.add( new Double( data[1] ) );
				break;
			case PathIterator.SEG_QUADTO :
				al.add( new Double( data[0] ) );
				al.add( new Double( data[1] ) );
				al.add( new Double( data[2] ) );
				al.add( new Double( data[3] ) );
				break;
			case PathIterator.SEG_CUBICTO :
				al.add( new Double( data[0] ) );
				al.add( new Double( data[1] ) );
				al.add( new Double( data[2] ) );
				al.add( new Double( data[3] ) );
				al.add( new Double( data[4] ) );
				al.add( new Double( data[5] ) );
				break;
			case PathIterator.SEG_CLOSE :
				break;
		}

		pitr.next( );
	}

	if ( al.size( ) == 0 )
	{
		return null;
	}

	StringBuffer sb = new StringBuffer( );

	for ( int i = 0; i < al.size( ); i++ )
	{
		Double db = al.get( i );
		if ( i > 0 )
		{
			sb.append( "," ); //$NON-NLS-1$
		}
		sb.append( (int) translateCoor( db.doubleValue( ) ) );
	}

	return sb.toString( );
}
 
开发者ID:eclipse,项目名称:birt,代码行数:74,代码来源:ImageMapEmitter.java

示例4: shape2polyCoords

import java.awt.geom.FlatteningPathIterator; //导入方法依赖的package包/类
private int[] shape2polyCoords( Shape shape )
{
	if ( shape == null )
	{
		return null;
	}

	ArrayList<Integer> al = new ArrayList<Integer>( );

	FlatteningPathIterator pitr = new FlatteningPathIterator( shape.getPathIterator( null ),
			1 );
	double[] data = new double[6];

	while ( !pitr.isDone( ) )
	{
		int type = pitr.currentSegment( data );

		switch ( type )
		{
			case PathIterator.SEG_MOVETO :
				al.add( (int) data[0] );
				al.add( (int) data[1] );
				break;
			case PathIterator.SEG_LINETO :
				al.add( (int) data[0] );
				al.add( (int) data[1] );
				break;
			case PathIterator.SEG_QUADTO :
				al.add( (int) data[0] );
				al.add( (int) data[1] );
				al.add( (int) data[2] );
				al.add( (int) data[3] );
				break;
			case PathIterator.SEG_CUBICTO :
				al.add( (int) data[0] );
				al.add( (int) data[1] );
				al.add( (int) data[2] );
				al.add( (int) data[3] );
				al.add( (int) data[4] );
				al.add( (int) data[5] );
				break;
			case PathIterator.SEG_CLOSE :
				break;
		}

		pitr.next( );
	}

	if ( al.size( ) == 0 )
	{
		return null;
	}

	int[] coords = new int[al.size( )];

	for ( int i = 0; i < al.size( ); i++ )
	{
		coords[i] = al.get( i );
	}
	return coords;
}
 
开发者ID:eclipse,项目名称:birt,代码行数:62,代码来源:RegionAction.java


注:本文中的java.awt.geom.FlatteningPathIterator.currentSegment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。