本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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]);
}