当前位置: 首页>>代码示例>>Java>>正文


Java Point2D.equals方法代码示例

本文整理汇总了Java中java.awt.geom.Point2D.equals方法的典型用法代码示例。如果您正苦于以下问题:Java Point2D.equals方法的具体用法?Java Point2D.equals怎么用?Java Point2D.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.geom.Point2D的用法示例。


在下文中一共展示了Point2D.equals方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getIntersectionPoints

import java.awt.geom.Point2D; //导入方法依赖的package包/类
/**
 * Gets the intersection points.
 *
 * @param line
 *          the line
 * @param rectangle
 *          the rectangle
 * @return the intersection points
 */
public static List<Point2D> getIntersectionPoints(final Line2D line, final Rectangle2D rectangle) {
  final ArrayList<Point2D> intersectionPoints = new ArrayList<>();
  final Line2D[] lines = getLines(rectangle);
  final Line2D topLine = lines[0];
  final Line2D bottomLine = lines[1];
  final Line2D leftLine = lines[2];
  final Line2D rightLine = lines[3];

  // Top line
  final Point2D p1 = getIntersectionPoint(line, topLine);
  if (p1 != null && contains(rectangle, p1)) {
    intersectionPoints.add(p1);
  }

  // Bottom line
  final Point2D p2 = getIntersectionPoint(line, bottomLine);
  if (p2 != null && contains(rectangle, p2) && !intersectionPoints.contains(p2)) {
    intersectionPoints.add(p2);
  }

  // Left side...
  final Point2D p3 = getIntersectionPoint(line, leftLine);
  if (p3 != null && !p3.equals(p1) && !p3.equals(p2) && contains(rectangle, p3) && !intersectionPoints.contains(p3)) {
    intersectionPoints.add(p3);
  }

  // Right side
  final Point2D p4 = getIntersectionPoint(line, rightLine);
  if (p4 != null && !p4.equals(p1) && !p4.equals(p2) && contains(rectangle, p4) && !intersectionPoints.contains(p4)) {
    intersectionPoints.add(p4);
  }

  intersectionPoints.removeAll(Collections.singleton(null));
  return intersectionPoints;
}
 
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:45,代码来源:GeometricUtilities.java

示例2: createUndoableMoveAction

import java.awt.geom.Point2D; //导入方法依赖的package包/类
/**
 * Creates the undoable move action.
 */
private void createUndoableMoveAction() {
	if (this.nodesMovedOldPositions!=null) {
		if (this.nodesMovedOldPositions.size()>0) {
			// --- Get selected GraphNodes ----------
			Set<GraphNode> nodesSelected = this.getVisViewer().getPickedVertexState().getPicked();
			if (this.nodesMovedOldPositions.size()==nodesSelected.size()) {
				for (GraphNode node : nodesSelected) {
					Point2D pointCurrent = new Point2D.Double(node.getPosition().getX(), node.getPosition().getY());
					Point2D pointStored  = this.nodesMovedOldPositions.get(node.getId());
					if (pointCurrent.equals(pointStored)==false) {
						this.basicGraphGUI.getGraphEnvironmentController().getNetworkModelAdapter().setGraphNodesMoved(this.getVisViewer(), this.nodesMovedOldPositions);
						break;
					}
				} // end for
				
			} else {
				// --- Should never happen ------------
				this.basicGraphGUI.getGraphEnvironmentController().getNetworkModelAdapter().setGraphNodesMoved(this.getVisViewer(), this.nodesMovedOldPositions);
			}
		}
		this.nodesMovedOldPositions = null;
	}
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:27,代码来源:GraphEnvironmentMousePlugin.java

示例3: version2LabelVector

import java.awt.geom.Point2D; //导入方法依赖的package包/类
/**
 * Creates an edge vector from a list of points. The edge vector is the
 * vector from the first to the last point, if they are distinct; otherwise,
 * it is the average of the edge points; if that yields <code>(0,0)</code>,
 * the edge vector is given by {@link #DEFAULT_EDGE_VECTOR}.
 *
 * @param points the list of points; should not be empty
 * @param isLoop flag indicating that the underlying edge is a loop
 * @see EdgeView#getLabelVector()
 */
private static Point2D version2LabelVector(List<Point2D> points, boolean isLoop) {
    Point2D result = null;
    // first try a vector from the first to the last point
    Point2D begin = points.get(0);
    Point2D end = points.get(points.size() - 1);
    if (!(isLoop || begin.equals(end))) {
        double dx = end.getX() - begin.getX();
        double dy = end.getY() - begin.getY();
        result = new Point2D.Double(dx, dy);
    } else if (points.size() > 0) {
        // the first and last point coincide; try taking the max of all
        // points
        double sumX = 0;
        double sumY = 0;
        for (Point2D point : points) {
            sumX += point.getX() - begin.getX();
            sumY += point.getY() - begin.getY();
        }
        // double the average (why? don't know; see
        // EdgeView#getLabelVector())
        int n = points.size() / 2;
        result = new Point2D.Double(sumX / n, sumY / n);
    }
    if (result == null || result.getX() == 0 && result.getY() == 0) {
        // nothing worked
        result = DEFAULT_EDGE_VECTOR;
    }
    return result;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:40,代码来源:LayoutIO.java

示例4: getIntersectionPoint

import java.awt.geom.Point2D; //导入方法依赖的package包/类
/**
 * Intersects.
 *
 * @param line
 *          the line
 * @param rectangle
 *          the rectangle
 * @return the point2 d
 */
public static Point2D getIntersectionPoint(final Line2D line, final Rectangle2D rectangle) {
  final List<Point2D> intersectionPoints = getIntersectionPoints(line, rectangle);
  for (final Point2D p : intersectionPoints) {
    if (p != null && !p.equals(line.getP1()) && contains(rectangle, p)) {
      return p;
    }
  }
  return null;
}
 
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:19,代码来源:GeometricUtilities.java

示例5: compareTo

import java.awt.geom.Point2D; //导入方法依赖的package包/类
/**
 * Compares this object with the specified object for order, based on
 * the outlier's point.
 *
 * @param   o the Object to be compared.
 * @return  a negative integer, zero, or a positive integer as this object
 *      is less than, equal to, or greater than the specified object.
 *
 */
public int compareTo(Object o) {
    Outlier outlier = (Outlier) o;
    Point2D p1 = getPoint();
    Point2D p2 = outlier.getPoint();
    if (p1.equals(p2)) {
        return 0;
    } 
    else if ((p1.getX() < p2.getX()) || (p1.getY() < p2.getY())) {
        return -1;
    } 
    else {
        return 1;
    } 
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:24,代码来源:Outlier.java

示例6: compareTo

import java.awt.geom.Point2D; //导入方法依赖的package包/类
/**
 * Compares this object with the specified object for order, based on
 * the outlier's point.
 *
 * @param   o the Object to be compared.
 * @return A negative integer, zero, or a positive integer as this object
 *      is less than, equal to, or greater than the specified object.
 *
 */
public int compareTo(Object o) {
    Outlier outlier = (Outlier) o;
    Point2D p1 = getPoint();
    Point2D p2 = outlier.getPoint();
    if (p1.equals(p2)) {
        return 0;
    } 
    else if ((p1.getX() < p2.getX()) || (p1.getY() < p2.getY())) {
        return -1;
    } 
    else {
        return 1;
    } 
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:24,代码来源:Outlier.java

示例7: testGetCurrentPoint

import java.awt.geom.Point2D; //导入方法依赖的package包/类
static void testGetCurrentPoint(Path2D pathA, Path2D pathB) {
    final Point2D ptA = pathA.getCurrentPoint();
    final Point2D ptB = pathA.getCurrentPoint();
    if (((ptA == null) && (ptB != null))
        || ((ptA != null) && !ptA.equals(ptB)))
    {
        throw new IllegalStateException("getCurrentPoint() are not equals ["
            + ptA + "|" + ptB + "] !");
    }
    log("testGetCurrentPoint: passed.");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:Path2DCopyConstructor.java

示例8: startsNotAt

import java.awt.geom.Point2D; //导入方法依赖的package包/类
private static boolean startsNotAt(Point2D startLocation, List<Point2D> points) {
	return !startLocation.equals(firstLocation(points));
}
 
开发者ID:mobitopp,项目名称:connection-scan,代码行数:4,代码来源:RoutePoints.java

示例9: endsNotAt

import java.awt.geom.Point2D; //导入方法依赖的package包/类
private static boolean endsNotAt(Point2D endLocation, List<Point2D> points) {
	return !endLocation.equals(lastLocation(points));
}
 
开发者ID:mobitopp,项目名称:connection-scan,代码行数:4,代码来源:RoutePoints.java

示例10: LinearGradientPaint

import java.awt.geom.Point2D; //导入方法依赖的package包/类
/**
 * Constructs a {@code LinearGradientPaint}.
 *
 * @param start the gradient axis start {@code Point2D} in user space
 * @param end the gradient axis end {@code Point2D} in user space
 * @param fractions numbers ranging from 0.0 to 1.0 specifying the
 *                  distribution of colors along the gradient
 * @param colors array of colors corresponding to each fractional value
 * @param cycleMethod either {@code NO_CYCLE}, {@code REFLECT},
 *                    or {@code REPEAT}
 * @param colorSpace which color space to use for interpolation,
 *                   either {@code SRGB} or {@code LINEAR_RGB}
 * @param gradientTransform transform to apply to the gradient
 *
 * @throws NullPointerException
 * if one of the points is null,
 * or {@code fractions} array is null,
 * or {@code colors} array is null,
 * or {@code cycleMethod} is null,
 * or {@code colorSpace} is null,
 * or {@code gradientTransform} is null
 * @throws IllegalArgumentException
 * if start and end points are the same points,
 * or {@code fractions.length != colors.length},
 * or {@code colors} is less than 2 in size,
 * or a {@code fractions} value is less than 0.0 or greater than 1.0,
 * or the {@code fractions} are not provided in strictly increasing order
 */
@ConstructorProperties({ "startPoint", "endPoint", "fractions", "colors", "cycleMethod", "colorSpace", "transform" })
public LinearGradientPaint(Point2D start, Point2D end,
                           float[] fractions, Color[] colors,
                           CycleMethod cycleMethod,
                           ColorSpaceType colorSpace,
                           AffineTransform gradientTransform)
{
    super(fractions, colors, cycleMethod, colorSpace, gradientTransform);

    // check input parameters
    if (start == null || end == null) {
        throw new NullPointerException("Start and end points must be" +
                                       "non-null");
    }

    if (start.equals(end)) {
        throw new IllegalArgumentException("Start point cannot equal" +
                                           "endpoint");
    }

    // copy the points...
    this.start = new Point2D.Double(start.getX(), start.getY());
    this.end = new Point2D.Double(end.getX(), end.getY());
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:53,代码来源:LinearGradientPaint.java

示例11: isDefaultLabelPosition

import java.awt.geom.Point2D; //导入方法依赖的package包/类
/**
 * Indicates whether a given label position is the default position.
 * @param labelPosition the label position to be tested
 * @return <code>true</code> if <code>labelPosition</code> is the
 *         default label position
 */
static public boolean isDefaultLabelPosition(Point2D labelPosition) {
    return labelPosition == null || labelPosition.equals(defaultLabelPosition);
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:10,代码来源:JEdgeLayout.java


注:本文中的java.awt.geom.Point2D.equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。