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


Java Line2D.ptSegDistSq方法代碼示例

本文整理匯總了Java中java.awt.geom.Line2D.ptSegDistSq方法的典型用法代碼示例。如果您正苦於以下問題:Java Line2D.ptSegDistSq方法的具體用法?Java Line2D.ptSegDistSq怎麽用?Java Line2D.ptSegDistSq使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.geom.Line2D的用法示例。


在下文中一共展示了Line2D.ptSegDistSq方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isHitAt

import java.awt.geom.Line2D; //導入方法依賴的package包/類
/**
 * Returns whether a specified local location is a part of the connection widget. It checks whether the location is
 * close to the control-points-based path (up to 4px from the line),
 * close to the anchors (defined by AnchorShape) or
 * close to the control points (PointShape).
 * @param localLocation the local locaytion
 * @return true, if the location is a part of the connection widget
 */
public boolean isHitAt (Point localLocation) {
    if (! super.isHitAt (localLocation))
            return false;

    List<Point> controlPoints = getControlPoints ();
    for (int i = 0; i < controlPoints.size () - 1; i++) {
        Point point1 = controlPoints.get (i);
        Point point2 = controlPoints.get (i + 1);
        double dist = Line2D.ptSegDistSq (point1.x, point1.y, point2.x, point2.y, localLocation.x, localLocation.y);
        if (dist < HIT_DISTANCE_SQUARE)
            return true;
    }

    return getControlPointHitAt (localLocation) >= 0;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:ConnectionWidget.java

示例2: getEdgeDistanceFromNode

import java.awt.geom.Line2D; //導入方法依賴的package包/類
/**
 * This method calculates the energy of the distance between Cells and
 * Edges. This version of the edge distance cost calculates the energy
 * cost from a specified <strong>node</strong>. The distance cost to all
 * unconnected edges is calculated and the total returned.
 * 
 * @param i the index of the node in the array <code>v</code>
 * @return the total edge distance energy of the node
 */
protected double getEdgeDistanceFromNode(int i)
{
	double energy = 0.0;
	// This function is only performed during fine tuning for performance
	if (isOptimizeEdgeDistance && isFineTuning)
	{
		int[] edges = v[i].relevantEdges;
		for (int j = 0; j < edges.length; j++)
		{
			// Note that the distance value is squared
			double distSquare = Line2D.ptSegDistSq(v[e[edges[j]].source].x,
					v[e[edges[j]].source].y, v[e[edges[j]].target].x,
					v[e[edges[j]].target].y, v[i].x, v[i].y);

			distSquare -= v[i].radiusSquared;

			// prevents from dividing with Zero. No Math.abs() call
			// for performance
			if (distSquare < minDistanceLimitSquared)
			{
				distSquare = minDistanceLimitSquared;
			}

			// Only bother with the divide if the node and edge are
			// fairly close together
			if (distSquare < maxDistanceLimitSquared)
			{
				energy += edgeDistanceCostFactor / distSquare;
			}
		}
	}
	return energy;
}
 
開發者ID:GDSRS,項目名稱:TrabalhoFinalEDA2,代碼行數:43,代碼來源:mxOrganicLayout.java

示例3: getEdgeDistanceFromEdge

import java.awt.geom.Line2D; //導入方法依賴的package包/類
/**
 * This method calculates the energy of the distance between Cells and
 * Edges. This version of the edge distance cost calculates the energy
 * cost from a specified <strong>edge</strong>. The distance cost to all
 * unconnected nodes is calculated and the total returned.
 * 
 * @param i the index of the edge in the array <code>e</code>
 * @return the total edge distance energy of the edge
 */
protected double getEdgeDistanceFromEdge(int i)
{
	double energy = 0.0;
	// This function is only performed during fine tuning for performance
	if (isOptimizeEdgeDistance && isFineTuning)
	{
		for (int j = 0; j < v.length; j++)
		{
			// Don't calculate for connected nodes
			if (e[i].source != j && e[i].target != j)
			{
				double distSquare = Line2D.ptSegDistSq(v[e[i].source].x,
						v[e[i].source].y, v[e[i].target].x,
						v[e[i].target].y, v[j].x, v[j].y);

				distSquare -= v[j].radiusSquared;

				// prevents from dividing with Zero. No Math.abs() call
				// for performance
				if (distSquare < minDistanceLimitSquared)
					distSquare = minDistanceLimitSquared;

				// Only bother with the divide if the node and edge are
				// fairly close together
				if (distSquare < maxDistanceLimitSquared)
				{
					energy += edgeDistanceCostFactor / distSquare;
				}
			}
		}
	}
	return energy;
}
 
開發者ID:GDSRS,項目名稱:TrabalhoFinalEDA2,代碼行數:43,代碼來源:mxOrganicLayout.java

示例4: getEdgeDistanceFromNode

import java.awt.geom.Line2D; //導入方法依賴的package包/類
/**
 * This method calculates the energy of the distance between Cells and Edges. This version of the
 * edge distance cost calculates the energy cost from a specified <strong>node</strong>. The
 * distance cost to all unconnected edges is calculated and the total returned.
 * 
 * @param i the index of the node in the array <code>v</code>
 * @return the total edge distance energy of the node
 */
protected double getEdgeDistanceFromNode(int i) {
  double energy = 0.0;
  // This function is only performed during fine tuning for performance
  if (isOptimizeEdgeDistance && isFineTuning) {
    int[] edges = v[i].relevantEdges;
    for (int j = 0; j < edges.length; j++) {
      // Note that the distance value is squared
      double distSquare = Line2D.ptSegDistSq(v[e[edges[j]].source].x, v[e[edges[j]].source].y,
          v[e[edges[j]].target].x, v[e[edges[j]].target].y, v[i].x, v[i].y);

      distSquare -= v[i].radiusSquared;

      // prevents from dividing with Zero. No Math.abs() call
      // for performance
      if (distSquare < minDistanceLimitSquared) {
        distSquare = minDistanceLimitSquared;
      }

      // Only bother with the divide if the node and edge are
      // fairly close together
      if (distSquare < maxDistanceLimitSquared) {
        energy += edgeDistanceCostFactor / distSquare;
      }
    }
  }
  return energy;
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:36,代碼來源:mxOrganicLayout.java

示例5: getEdgeDistanceFromEdge

import java.awt.geom.Line2D; //導入方法依賴的package包/類
/**
 * This method calculates the energy of the distance between Cells and Edges. This version of the
 * edge distance cost calculates the energy cost from a specified <strong>edge</strong>. The
 * distance cost to all unconnected nodes is calculated and the total returned.
 * 
 * @param i the index of the edge in the array <code>e</code>
 * @return the total edge distance energy of the edge
 */
protected double getEdgeDistanceFromEdge(int i) {
  double energy = 0.0;
  // This function is only performed during fine tuning for performance
  if (isOptimizeEdgeDistance && isFineTuning) {
    for (int j = 0; j < v.length; j++) {
      // Don't calculate for connected nodes
      if (e[i].source != j && e[i].target != j) {
        double distSquare = Line2D.ptSegDistSq(v[e[i].source].x, v[e[i].source].y,
            v[e[i].target].x, v[e[i].target].y, v[j].x, v[j].y);

        distSquare -= v[j].radiusSquared;

        // prevents from dividing with Zero. No Math.abs() call
        // for performance
        if (distSquare < minDistanceLimitSquared)
          distSquare = minDistanceLimitSquared;

        // Only bother with the divide if the node and edge are
        // fairly close together
        if (distSquare < maxDistanceLimitSquared) {
          energy += edgeDistanceCostFactor / distSquare;
        }
      }
    }
  }
  return energy;
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:36,代碼來源:mxOrganicLayout.java

示例6: getFlatnessSq

import java.awt.geom.Line2D; //導入方法依賴的package包/類
public static double getFlatnessSq(float coords[], int offset) {
    return Line2D.ptSegDistSq(coords[offset + 0], coords[offset + 1],
                              coords[offset + 4], coords[offset + 5],
                              coords[offset + 2], coords[offset + 3]);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:6,代碼來源:Test7047069.java


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