當前位置: 首頁>>代碼示例>>Java>>正文


Java Line2D.getP1方法代碼示例

本文整理匯總了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;
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:24,代碼來源:SurveyPlannerSelector.java

示例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;
	}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:33,代碼來源:GMAProfile.java

示例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;
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:29,代碼來源:GMAProfile.java

示例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);
}
 
開發者ID:gurkenlabs,項目名稱:litiengine,代碼行數:63,代碼來源:AmbientLight.java


注:本文中的java.awt.geom.Line2D.getP1方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。