本文整理汇总了Java中org.twak.utils.collections.ConsecutivePairs类的典型用法代码示例。如果您正苦于以下问题:Java ConsecutivePairs类的具体用法?Java ConsecutivePairs怎么用?Java ConsecutivePairs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConsecutivePairs类属于org.twak.utils.collections包,在下文中一共展示了ConsecutivePairs类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createInitial
import org.twak.utils.collections.ConsecutivePairs; //导入依赖的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);
}
}
示例2: fromPoints
import org.twak.utils.collections.ConsecutivePairs; //导入依赖的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;
}
示例3: setFrom
import org.twak.utils.collections.ConsecutivePairs; //导入依赖的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++]);
}
}
示例4: createCross
import org.twak.utils.collections.ConsecutivePairs; //导入依赖的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;
}
示例5: paint
import org.twak.utils.collections.ConsecutivePairs; //导入依赖的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);
}
}
}
示例6: addCoords
import org.twak.utils.collections.ConsecutivePairs; //导入依赖的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));
}
}
示例7: createfourSqaures
import org.twak.utils.collections.ConsecutivePairs; //导入依赖的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;
}
示例8: tube
import org.twak.utils.collections.ConsecutivePairs; //导入依赖的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 );
}
示例9: createInitial
import org.twak.utils.collections.ConsecutivePairs; //导入依赖的package包/类
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 ))
{
loop.append( new Bar( pair.first(), pair.second() ) );
}
// F-shape
// 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, 100),
// new Point2d (600, 100),
// new Point2d (600, 250),
// new Point2d (700, 250),
// new Point2d (700, 350),
// new Point2d (100, 350),
// new Point2d (100, 250),
// new Point2d (250,250)
// ), true ))
// {
// loop.append( new Bar( pair.first(), pair.second() ) );
// }
}
示例10: findRoofLine
import org.twak.utils.collections.ConsecutivePairs; //导入依赖的package包/类
public Point2d findRoofLine() {
double nonVertRun = 0;
Line up = new Line( 0, 0, 0, 1 );
Point2d runStart = null;
for ( Pair<Point2d, Point2d> line : new ConsecutivePairs<>( this, false ) ) {
Line l = new Line( line.first(), line.second() );
double angle = l.absAngle( up );
if ( angle > Math.PI / 6 && angle < Math.PI ) {
if ( nonVertRun == 0 )
runStart = l.start;
nonVertRun += l.length();
} else {
if (nonVertRun > 2 && runStart != null)
return runStart;
nonVertRun = 0;
}
}
return runStart == null ? get(size()-1) : runStart;
}
示例11: length
import org.twak.utils.collections.ConsecutivePairs; //导入依赖的package包/类
public double length() {
double out = 0;
for (Pair<Point2d, Point2d> line : new ConsecutivePairs<>( this, false ))
out += new Line (line.first(), line.second()).length();
return out;
}
示例12: getDistance
import org.twak.utils.collections.ConsecutivePairs; //导入依赖的package包/类
@Override
public double getDistance( Point2d pt ) {
double dist = Double.MAX_VALUE;
for (Pair<Point2d,Point2d> pts : new ConsecutivePairs<Point2d> ( Arrays.asList( points() ), true))
dist = Math.min (dist, new Line( pts.first(), pts.second() ).distance(pt, true));
if (contains( pt ))
return 0;
return dist;
}
示例13: minHullAngle
import org.twak.utils.collections.ConsecutivePairs; //导入依赖的package包/类
private double minHullAngle() { // very sharp, and very concave angles return high values
if (hull.size() <= 1)
return 0;
double min = Double.MAX_VALUE;
for (Pair <Line,Line> a : new ConsecutivePairs<>(hull, false))
min = Math.min(min, Anglez.dist ( a.first().aTan2(), a.second().aTan2() ) );
return min;
}
示例14: geometry
import org.twak.utils.collections.ConsecutivePairs; //导入依赖的package包/类
@Override
public void geometry(Geometry arg0) {
if (arg0 == null || arg0.getArea() < 80)
return;
// TODO Auto-generated method stub
if (count != 0) {
System.out.println(arg0.getGeometryType());
try {
Point cen = arg0.getCentroid();
Coordinate latLong = new Coordinate();
JTS.transform(cen.getCoordinate(), latLong, transform);
System.out.println(" ************************* " + count + " " + featureName);
System.out.println("in EPSG:27700 " + cen);
System.out.println("lat long " + latLong);
URL url = new URL("https://maps.googleapis.com/maps/api/staticmap?center="+latLong.x+","+latLong.y+"&zoom=20&size=640x640&maptype=satellite&format=png32&key=AIzaSyDYAQH5nMlF0vEfdIg0seTiGUIcRbLNeI4");
URLConnection connection = url.openConnection();
InputStream is = connection.getInputStream();
//
BufferedImage image = ImageIO.read(is);// new BufferedImage( 640,640, BufferedImage.TYPE_3BYTE_BGR );
// BufferedImage image = new BufferedImage( 640,640, BufferedImage.TYPE_3BYTE_BGR );
Graphics2D g2 = (Graphics2D) image.getGraphics();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
double scale = 11f;
int imageCenX = image.getWidth () >> 1,
imageCenY = image.getHeight() >> 1;
g2.setColor(Color.red);
g2.setStroke(new BasicStroke(2f));
for (Pair<Coordinate, Coordinate> pair : new ConsecutivePairs<Coordinate>( Arrays.asList( arg0.getCoordinates() ), 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;
x1 *= scale; x2 *= scale; y1 *= scale; y2 *= scale;
g2.draw( new Line2D.Double(x1 + imageCenX, - y1 + imageCenY, x2 + imageCenX, - y2 +imageCenY) );
}
g2.drawString( HeightsToRedis.getHeight(featureName) +"m below roof", 5, 15 );
g2.drawString( HeightsToRedis.getRoof(featureName) +"m including roof", 5, 30 );
g2.drawString( latLong.x + ", " + latLong.y + " location ", 5, 45 );
g2.dispose();
ImageIO.write(image, "png", new FileOutputStream ( String.format( "/home/twak/data/footprints/center%04d.png", count )) );
is.close();
if (count > 1000)
System.exit(0);
} catch (Throwable e) {
e.printStackTrace();
System.exit(0);
}
}
count++;
featureName = "?";
}