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


Java Pair类代码示例

本文整理汇总了Java中org.twak.utils.Pair的典型用法代码示例。如果您正苦于以下问题:Java Pair类的具体用法?Java Pair怎么用?Java Pair使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getLongest

import org.twak.utils.Pair; //导入依赖的package包/类
public Result getLongest() {
	
	List<Double> l = get();
	
	double longest = -Double.MAX_VALUE;
	Pair<Double,Double> longestP = null;
	
	for (Pair<Double, Double> p : new ConsecutiveItPairsGap<>(l)) {
		double length = p.second() - p.first();
		if (length > longest) {
			longest = length;
			longestP = p;
		}
	}
	
	if (longestP == null)
		return new Result<>();
	
	Result out = new Result ( longestP.first(), longestP.second());
	
	for (ET e : things.subSet(new ET(out.min, null), new ET(out.max, null)) )
		out.things.add(e.thing);
	
	return out;
	
}
 
开发者ID:twak,项目名称:chordatlas,代码行数:27,代码来源:RangeMerge.java

示例2: createInitial

import org.twak.utils.Pair; //导入依赖的package包/类
@Override
    protected void createInitial() {
//        createCircularPoints( 5, 200, 200, 150);

        // cross shape:
        Loop<Bar> loop = new Loop();
        edges.add(loop);

        for (Pair<Point2d, Point2d> pair : new ConsecutivePairs<Point2d>(Arrays.asList(
                new Point2d(250, 100),
                new Point2d(350, 100),
                new Point2d(350, 250),
                new Point2d(500, 250),
                new Point2d(500, 350),
                new Point2d(350, 350),
                new Point2d(350, 500),
                new Point2d(250, 500),
                new Point2d(250, 350),
                new Point2d(100, 350),
                new Point2d(100, 250),
                new Point2d(250, 250)), true)) {
            Bar bar = new Bar(pair.first(), pair.second());
            offset.put(bar, Math.random() > 0.5 );
            loop.append(bar);
        }
    }
 
开发者ID:twak,项目名称:campskeleton,代码行数:27,代码来源:PartialOffsetPointEditor.java

示例3: fromPoints

import org.twak.utils.Pair; //导入依赖的package包/类
public static Loop<Edge> fromPoints( List<Point2d> ribbon )
{
    Loop<Edge> loop = new Loop();
    Cache<Point2d, Corner> cache = new Cache<Point2d, Corner>()
    {
        @Override
        public Corner create( Point2d i )
        {
            return new Corner (i.x, i.y);
        }
    };
    for ( Pair<Point2d, Point2d> pair : new ConsecutivePairs<Point2d>( ribbon, true ) )
    {
        loop.append( new Edge( cache.get( pair.first() ), cache.get( pair.second() ) ) );
    }

    return loop;
}
 
开发者ID:twak,项目名称:campskeleton,代码行数:19,代码来源:Edge.java

示例4: setFrom

import org.twak.utils.Pair; //导入依赖的package包/类
public void setFrom (double[][] ptData, Profile[] profs)
{
    points = new LoopL();
    Loop<Bar> loop = new Loop();
    points.add( loop );

    List<Point2d> lPoints = new ArrayList();
    for (double[] dv : ptData) {
        lPoints.add(new Point2d(dv[0], dv[1]));
    }

    int i = 0;
    for (Pair<Point2d, Point2d> pair : new ConsecutivePairs<Point2d>(lPoints, true)) {
        Bar b;
        loop.append(b = new Bar(pair.first(), pair.second()));
        profiles.put(b, profs[i++]);
    }
}
 
开发者ID:twak,项目名称:siteplan,代码行数:19,代码来源:Plan.java

示例5: createCross

import org.twak.utils.Pair; //导入依赖的package包/类
public static void createCross( Plan plan, Profile profile ) {
	LoopL<Bar> loopl = new LoopL();
	Loop<Bar> loop = new Loop();
	loopl.add( loop );

	List<Point2d> pts = Arrays.asList(
			//            new Point2d (100, 250),
			//            new Point2d (250,250),
			//            new Point2d (250,100),
			//            new Point2d (350,100),
			//            new Point2d (400,600)

			new Point2d( 250, 100 ), new Point2d( 350, 100 ), new Point2d( 350, 250 ), new Point2d( 500, 250 ), new Point2d( 500, 350 ), new Point2d( 350, 350 ), new Point2d( 350, 500 ), new Point2d( 250, 500 ), new Point2d( 250, 350 ), new Point2d( 100, 350 ), new Point2d( 100, 250 ), new Point2d( 250, 250 ) );

	for ( Point2d p : pts )
		p.scale( 0.3 );

	for ( Pair<Point2d, Point2d> pair : new ConsecutivePairs<Point2d>( pts, true ) ) {
		Bar b;
		loop.append( b = new Bar( pair.first(), pair.second() ) );
		plan.profiles.put( b, profile );
	}
	plan.points = loopl;
}
 
开发者ID:twak,项目名称:siteplan,代码行数:25,代码来源:Siteplan.java

示例6: paint

import org.twak.utils.Pair; //导入依赖的package包/类
@Override
			public void paint( Object o, Graphics2D g, PanMouseAdaptor ma ) {
				
				Prof p = (Prof)o;
				
				for (Pair<Point2d, Point2d> line : new ConsecutivePairs<>( p, false )) {
//					g.setColor( Color.black );
					g.drawLine(ma.toX(line.first().x), ma.toY(-line.first().y), ma.toX(line.second().x), ma.toY(-line.second().y));
					PaintThing.setBounds( line.first() );
//					g.setColor( Color.red );
					for (Point2d s : new Point2d[] {line.first(), line.second()}) {
						g.fillOval(ma.toX(s.x) - 4, ma.toY(-s.y) - 4, 8, 8);
					}
				}
			}
 
开发者ID:twak,项目名称:chordatlas,代码行数:16,代码来源:Prof.java

示例7: verticalLength

import org.twak.utils.Pair; //导入依赖的package包/类
protected Double verticalLength( double tol ) {

		double length = 0;
		for (Pair<Point2d, Point2d> pts : new ConsecutiveItPairs<>( this )) {

			Line line = new Line (pts.first(), pts.second());
			
			double angle = line.aTan2();
			if (angle > Mathz.PI2 - tol && angle < Mathz.PI2 + tol)
				length += line.length();
		}
		
		return length;
	}
 
开发者ID:twak,项目名称:chordatlas,代码行数:15,代码来源:Prof.java

示例8: combiner

import org.twak.utils.Pair; //导入依赖的package包/类
@Override
public BinaryOperator<Pair<Point2d, Integer>> combiner() {
	return (a,b) -> new Pair<>(
			new Point2d(a.first().x + b.first().x, b.first().y + b.first().y),
			a.second() + b.second()
				);
}
 
开发者ID:twak,项目名称:chordatlas,代码行数:8,代码来源:Point2DMeanCollector.java

示例9: addCoords

import org.twak.utils.Pair; //导入依赖的package包/类
private void addCoords (Coordinate coords[], MathTransform transform) throws Throwable {
		for (Pair<Coordinate, Coordinate> pair : new ConsecutivePairs<Coordinate>( Arrays.asList( coords ) , true)) {
			
			double 
				x1 = pair.first().x,// - cen.getCoordinate().x, 
				y1 = pair.first().y,// - cen.getCoordinate().y,
				x2 = pair.second().x,// - cen.getCoordinate().x, 
				y2 = pair.second().y;// - cen.getCoordinate().y;

			if (targetCRS != null && transform != null)
			{
				double[] result = new double[] {x1, y1, x2, y2, 0, 0};
				transform.transform( result, 0, result, 0, 2 );
				
				addLine (
						new double[] {result[0], result[1], result[2]}, 
						new double[] {result[3], result[4], result[5]}
						);
				
			}
			else {
				
				addLine(new double[] {x1, y1}, new double[] { x2, y2} );
			}
			
//			GML2Graph.this.result.newLine(new Point2d(x1, y1), new Point2d(x2, y2));
			
		}

	}
 
开发者ID:twak,项目名称:chordatlas,代码行数:31,代码来源:GMLReader.java

示例10: NaturalStepShip

import org.twak.utils.Pair; //导入依赖的package包/类
public NaturalStepShip( Plan plan )
    {
//        Plan plan = CampSkeleton.instance.plan;

        Loop<Bar>shapeLoop = new Loop();
        this.shape.add( shapeLoop );

        Profile
            profile1 = plan.createNewProfile(null),
            profile2 = plan.createNewProfile(null);

        Point2d[] coords = new Point2d[] {
            new Point2d (-200,0), new Point2d (50,0), new Point2d (50,-20), new Point2d (250,-20), new Point2d (250,0), new Point2d (500, 0) };

        Profile[] profs = new Profile[] {
            profile1, profile2, profile2, profile2, profile1
        };

        int i = 0;
        for ( Pair<Point2d, Point2d> pair : new ConsecutiveItPairs<Point2d>( Arrays.asList( coords ) ) )
        {
            Bar b = new Bar (pair.first(), pair.second());
            shapeLoop.append( b );

            plan.profiles.put( b, profs[i++] ); 
        }

        Siteplan.instance.profileListChanged();
        
        Loop<Double> speedLoop = new Loop();
        this.speeds.add(speedLoop);
        speedLoop.append(0.);
        speedLoop.append(-6.);
        speedLoop.append(-3.);
        speedLoop.append(-6.);
        speedLoop.append(0.);
    }
 
开发者ID:twak,项目名称:siteplan,代码行数:38,代码来源:NaturalStepShip.java

示例11: NaturalStep

import org.twak.utils.Pair; //导入依赖的package包/类
public NaturalStep(Plan plan)
    {
        super(plan, "natural square step");

        Loop<Bar> line = new Loop();

        Profile profile1 = new Profile( 50 );
        Profile profile2 = new Profile( 50 );
        
        Point2d[] coords = new Point2d[] {
            new Point2d (0,0), new Point2d (50,0), new Point2d (50,-20), new Point2d (250,-20), new Point2d (250,0), new Point2d (300, 0) };

        Profile[] profs = new Profile[] {
            profile1, profile2, profile1, profile2, profile1
        };

        int i = 0;
        for ( Pair<Point2d, Point2d> pair : new ConsecutiveItPairs<Point2d>( Arrays.asList( coords ) ) )
        {
            Bar b = new Bar (pair.first(), pair.second());
            line.append( b );

            plan.profiles.put( b, profs[i++] );
        }

        shape.add( line );

//        plan.tags.add( this );
        plan.addLoop( profile1.points.get( 0 ), plan.root, profile1 );
        plan.addLoop( profile2.points.get( 0 ), plan.root, profile2 );
    }
 
开发者ID:twak,项目名称:siteplan,代码行数:32,代码来源:NaturalStep.java

示例12: Profile

import org.twak.utils.Pair; //导入依赖的package包/类
public Profile(List<Point2d> pts) {

        Loop<Bar> loop;
        points.add( loop = new Loop<>() );
        
        for ( Pair<Point2d, Point2d> pt : new ConsecutiveItPairs<Point2d> (pts) )
        	loop.append( new Bar ( pt.first(), pt.second() ) );
    }
 
开发者ID:twak,项目名称:siteplan,代码行数:9,代码来源:Profile.java

示例13: createfourSqaures

import org.twak.utils.Pair; //导入依赖的package包/类
public static LoopL<Bar> createfourSqaures( Plan plan, Profile profile ) {
	LoopL<Bar> loopl = new LoopL();

	List<Point2d> pts = Arrays.asList(
			//            new Point2d (100, 250),
			//            new Point2d (250,250),
			//            new Point2d (250,100),
			//            new Point2d (350,100),
			//            new Point2d (400,600)

			new Point2d( 0, 0 ), new Point2d( -50, 0 ), new Point2d( -50, -50 ), new Point2d( 0, -50 ) );

	//         for (Point2d p : pts)
	//             p.scale( 0.3 );

	List<List<Point2d>> stp = new ArrayList();

	for ( Point2d offset : new Point2d[] { new Point2d( 0, 150 ), new Point2d( 0, -150 ), new Point2d( 150, 0 ), new Point2d( -150, 0 ) } ) {
		List<Point2d> t = new ArrayList();
		stp.add( t );

		for ( Point2d pt : pts )
			t.add( new Point2d( offset.x + pt.x, offset.y + pt.y ) );
	}

	for ( List<Point2d> pts2 : stp ) {
		Loop<Bar> loop = new Loop();
		loopl.add( loop );

		for ( Pair<Point2d, Point2d> pair : new ConsecutivePairs<Point2d>( pts2, true ) ) {
			Bar b;
			loop.append( b = new Bar( pair.first(), pair.second() ) );
			plan.profiles.put( b, profile );
		}
	}

	return loopl;
}
 
开发者ID:twak,项目名称:siteplan,代码行数:39,代码来源:Siteplan.java

示例14: getResults

import org.twak.utils.Pair; //导入依赖的package包/类
public List<Result<T>> getResults() {

		List<Result<T>> out = new ArrayList();
		
		int seen = 0;
		
		for (Pair<Double, Double> p : new ConsecutiveItPairsGap<>(get())) {
			
			Result r = new Result ( p.first(), p.second());
			out.add ( r );
			
			for (ET e : things.subSet(new ET(r.min, null), new ET(r.max, null)) ) {
				r.things.add(e.thing);
				seen++;
			}
		}
		
		return out;
	}
 
开发者ID:twak,项目名称:chordatlas,代码行数:20,代码来源:RangeMerge.java

示例15: tube

import org.twak.utils.Pair; //导入依赖的package包/类
public static void tube (MeshBuilder out, 
			Collection<LinearForm3D> before, Collection<LinearForm3D> after, 
			Line3d line, LinearForm3D left, LinearForm3D right, CrossGen gen ) {
		
		if (angle ( before, line) < 0.1 || angle ( after, line ) < 0.1 )
			return; // too pointy to touch
		
		Point3d middle = line.fromPPram( 0.5 );
		
		Vector3d along = line.dir();
		along.normalize();
		Vector3d nAlong = new Vector3d (along);
		nAlong.negate();
		
		Vector3d o1 = left.normal(), u1 = new Vector3d();
		u1.cross( along, o1 );
		
		Frame frame = Mathz.buildFrame ( o1, u1, along, middle);
		
		Vector3d u2 = right.normal();
		u2.cross( u2, along );
//		u2.add( middle );
		
		Vector2d leftDir = Mathz.toXY ( frame, u1 );
		Vector2d rightDir = Mathz.toXY ( frame, u2 );
		
		List<Point3d> profilePts = gen.gen( leftDir, rightDir ).stream().
				map( p -> Mathz.fromXY( frame, p ) ).collect( Collectors.toList() );
		
		List<LinearForm3D> dummy = new ArrayList<>();
		
		for (Pair <Point3d, Point3d> pair : new ConsecutivePairs<Point3d>( profilePts, true ) ) {
			
			Point3d 
					f1 = clip ( pair.first (), along , after , dummy ),
					f2 = clip ( pair.second(), along , after , dummy ),
					b1 = clip ( pair.first (), nAlong, before, dummy ),
					b2 = clip ( pair.second(), nAlong, before, dummy );

			out.add (f2, f1, b1, b2);
		}
		
//		cap( out, after ,  along, profilePts, true  );
//		cap( out, before, nAlong, profilePts, false );
	}
 
开发者ID:twak,项目名称:chordatlas,代码行数:46,代码来源:Tube.java


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