本文整理汇总了Java中org.twak.utils.Pair.second方法的典型用法代码示例。如果您正苦于以下问题:Java Pair.second方法的具体用法?Java Pair.second怎么用?Java Pair.second使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.twak.utils.Pair
的用法示例。
在下文中一共展示了Pair.second方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
}
示例3: 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);
}
}
}
示例4: 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;
}
示例5: 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));
}
}
示例6: 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.);
}
示例7: 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 );
}
示例8: 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;
}
示例9: ForcedStep
import org.twak.utils.Pair; //导入方法依赖的package包/类
public ForcedStep(Plan plan)
{
this();
Loop<Bar> line = new Loop();
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 profile = new Profile( 50 );
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, profile );
}
shape.add( line );
// plan.tags.add( this );
plan.addLoop( profile.points.get( 0 ), plan.root, profile );
}
示例10: findRoofLine
import org.twak.utils.Pair; //导入方法依赖的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: geometry
import org.twak.utils.Pair; //导入方法依赖的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 = "?";
}