本文整理汇总了Java中java.awt.geom.Line2D.getP1方法的典型用法代码示例。如果您正苦于以下问题:Java Line2D.getP1方法的具体用法?Java Line2D.getP1怎么用?Java Line2D.getP1使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.geom.Line2D
的用法示例。
在下文中一共展示了Line2D.getP1方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPath
import java.awt.geom.Line2D; //导入方法依赖的package包/类
Point2D[] getPath(Line2D l, int dec) {
Point2D p1 = l.getP1();
Point2D p2 = l.getP2();
double dist = map.getZoom()*Math.sqrt(
Math.pow( p1.getX()-p2.getX(),2 ) +
Math.pow( p1.getY()-p2.getY(),2 ));
int npt = (int)Math.ceil( dist/dec);
Projection proj = map.getProjection();
Point2D q1 = proj.getRefXY(p1);
Point2D q2 = proj.getRefXY(p2);
XYZ r1 = XYZ.LonLat_to_XYZ(q1);
XYZ r2 = XYZ.LonLat_to_XYZ(q2);
double angle = Math.acos( r1.dot(r2) )/(npt-1.);
r2 = r1.cross(r2).cross(r1).normalize();
Point2D[] path = new Point2D[npt];
for( int k=0 ; k<npt ; k++) {
double s = Math.sin(k*angle);
double c = Math.cos(k*angle);
XYZ r = r1.times(c).plus( r2.times(s) );
path[k] = r.getLonLat();
}
return path;
}
示例2: getPath
import java.awt.geom.Line2D; //导入方法依赖的package包/类
Point2D[] getPath(Line2D l, int dec) {
/*
if( cb !=null &&
cb.getSelectedItem().toString().startsWith("S") )return getStraightPath(l, dec);
*/
if( profileTypes != null && straightLine.isSelected() )return getStraightPath(l, dec);
Point2D p1 = l.getP1();
Point2D p2 = l.getP2();
double dist = map.getZoom()*Math.sqrt(
Math.pow( p1.getX()-p2.getX(),2 ) +
Math.pow( p1.getY()-p2.getY(),2 ));
int npt = (int)Math.ceil( dist/dec);
Projection proj = map.getProjection();
Point2D q1 = proj.getRefXY(p1);
Point2D q2 = proj.getRefXY(p2);
XYZ r1 = XYZ.LonLat_to_XYZ(q1);
XYZ r2 = XYZ.LonLat_to_XYZ(q2);
double angle = Math.acos( r1.dot(r2) )/(npt-1.);
r2 = r1.cross(r2).cross(r1).normalize();
Point2D[] path = new Point2D[npt];
for( int k=0 ; k<npt ; k++) {
double s = Math.sin(k*angle);
double c = Math.cos(k*angle);
XYZ r = r1.times(c).plus( r2.times(s) );
path[k] = r.getLonLat();
}
//TODO set current pts to path
currentPts = path;
return path;
}
示例3: getStraightPath
import java.awt.geom.Line2D; //导入方法依赖的package包/类
Point2D[] getStraightPath(Line2D l, int dec) {
Point2D p1 = l.getP1();
Point2D p2 = l.getP2();
lastP1 = p1;
lastP2 = p2;
Projection proj = map.getProjection();
double dist = map.getZoom()*Math.sqrt(
Math.pow( p1.getX()-p2.getX(),2 ) +
Math.pow( p1.getY()-p2.getY(),2 ));
int npt = (int)Math.ceil( dist/dec);
if( npt<2 )npt=2;
Point2D[] path = new Point2D[npt];
double dx = (p2.getX()-p1.getX())/(npt-1.);
double dy = (p2.getY()-p1.getY())/(npt-1.);
for( int k=0 ; k<npt ; k++) {
path[k] = proj.getRefXY(new Point2D.Double(
p1.getX() + k*dx,
p1.getY() + k*dy));
}
//TODO set current pts to path
currentPts = path;
return path;
}
示例4: renderLightSource
import java.awt.geom.Line2D; //导入方法依赖的package包/类
private void renderLightSource(final Graphics2D g, final LightSource light, final double longerDimension) {
final Point2D lightCenter = light.getDimensionCenter();
final Area lightArea = new Area(light.getLightShape());
if (light.getLightShapeType().equals(LightSource.RECTANGLE)) {
g.setColor(light.getColor());
g.fill(lightArea);
return;
}
// cut the light area where shadow Boxes are (this simulates light falling
// into and out of rooms)
for (final StaticShadow col : this.environment.getStaticShadows()) {
if (!GeometricUtilities.shapeIntersects(light.getLightShape(), col.getBoundingBox())) {
continue;
}
final Area boxInLight = new Area(col.getBoundingBox());
boxInLight.intersect(lightArea);
final Line2D[] bounds = GeometricUtilities.getLines(col.getBoundingBox());
for (final Line2D line : bounds) {
final Vector2D lineVector = new Vector2D(line.getP1(), line.getP2());
final Vector2D lightVector = new Vector2D(lightCenter, line.getP1());
if (light.getDimensionCenter().getY() < line.getY1() && light.getDimensionCenter().getY() < line.getY2() && col.getBoundingBox().contains(light.getDimensionCenter()) || lineVector.normalVector().dotProduct(lightVector) >= 0) {
continue;
}
final Path2D shadowParallelogram = new Path2D.Double();
final Point2D shadowPoint1 = GeometricUtilities.project(lightCenter, line.getP1(), longerDimension);
final Point2D shadowPoint2 = GeometricUtilities.project(lightCenter, line.getP2(), longerDimension);
// construct a shape from our points
shadowParallelogram.moveTo(line.getP1().getX(), line.getP1().getY());
shadowParallelogram.lineTo(shadowPoint1.getX(), shadowPoint1.getY());
shadowParallelogram.lineTo(shadowPoint2.getX(), shadowPoint2.getY());
shadowParallelogram.lineTo(line.getP2().getX(), line.getP2().getY());
shadowParallelogram.closePath();
final Area shadowArea = new Area(shadowParallelogram);
if (light.getDimensionCenter().getY() < col.getBoundingBox().getMaxY() && !col.getBoundingBox().contains(light.getDimensionCenter())) {
shadowArea.add(boxInLight);
}
shadowArea.intersect(lightArea);
lightArea.subtract(shadowArea);
}
}
final Paint oldPaint = g.getPaint();
// render parts that lie within the shadow with a gradient from the light
// color to transparent
final Area lightRadiusArea = new Area(light.getLightShape());
final Color[] transColors = new Color[] { new Color(light.getColor().getRed(), light.getColor().getGreen(), light.getColor().getBlue(), light.getBrightness()), new Color(light.getColor().getRed(), light.getColor().getGreen(), light.getColor().getBlue(), 0) };
try {
g.setPaint(new RadialGradientPaint(new Point2D.Double(lightRadiusArea.getBounds2D().getCenterX(), lightRadiusArea.getBounds2D().getCenterY()), (float) (lightRadiusArea.getBounds2D().getWidth() / 2), new float[] { 0.0f, 1.00f }, transColors));
} catch (final Exception e) {
g.setColor(light.getColor());
}
g.fill(lightArea);
g.setPaint(oldPaint);
}