Collection<Line2D.Double> cutSegments(Line2D.Double original) { final List<Line2D.Double> result = new ArrayList<Line2D.Double>(); Point2D.Double cur = (Point2D.Double) original.getP1(); final Collection<Point2D.Double> cutPoints = cutPoints(original); for (Point2D.Double inter : cutPoints) { if (cur.equals(inter)) { continue; } result.add(new Line2D.Double(cur, inter)); cur = inter; } if (cur.equals(original.getP2()) == false) { result.add(new Line2D.Double(cur, original.getP2())); } return result; }
final double getMindist(Point2D.Double pt) { double result = Double.MAX_VALUE; for (Point2D p : points.keySet()) { if (pt.equals(p)) { continue; } final double v = p.distance(pt); if (v < 1E-4) { throw new IllegalStateException(); } result = Math.min(result, v); } for (Line2D line : lines) { if (line.getP1().equals(pt) || line.getP2().equals(pt)) { continue; } final double v = line.ptSegDist(pt); if (result < 1E-4) { throw new IllegalStateException("pt=" + pt + " line=" + GeomUtils.toString(line)); } result = Math.min(result, v); } if (result == 0) { throw new IllegalStateException(); } // Log.println("getMindist=" + result); return result; } }
final Vertex v = dijkstra.addVertex(n); vertexes.put(n, v); if (n.getCenter().equals(start)) { vStart.addAdjacencies(v, 0.01); if (n.getCenter().equals(end)) { v.addAdjacencies(vEnd, 0.01); final Neighborhood2 n1 = (Neighborhood2) v1.getData(); final Neighborhood2 n2 = (Neighborhood2) v2.getData(); if (n1.getCenter().equals(n2.getCenter())) { continue;
/** * Returns point on RAY from endpt1 to endpt2 which is closest to this point. * @param original the point considered * @param endpt1 first endpoint of the ray * @param endpt2 second endpoint of the ray * @return point along the line that forms a perpendicular with the original point, or the nearest endpt to that point; or if the endpoints coincide a point at an endpoint */ public static Point2D.Double closestPointOnRay(Point2D.Double original, Point2D.Double endpt1, Point2D.Double endpt2) { if (endpt1.equals(endpt2)) { return new Point2D.Double(endpt1.x, endpt1.y); } double t = t(original, endpt1, endpt2); t = t < 0 ? 0 : t; return new Point2D.Double(endpt1.x + t * (endpt2.x - endpt1.x), endpt1.y + t * (endpt2.y - endpt1.y)); }
@Override public void buildShape(MouseEventDouble mouseevent) { Rectangle2D rectangle = null; if (pts.size() > 1) { if (!getHandlePoint(eHandlePoint.NW.index).equals(getHandlePoint(eHandlePoint.SE.index))) { rectangle = new Rectangle2D.Double(); rectangle.setFrameFromDiagonal(getHandlePoint(eHandlePoint.NW.index), getHandlePoint(eHandlePoint.SE.index)); } } setShape(rectangle, mouseevent); updateLabel(mouseevent, getDefaultView2d(mouseevent)); }
/** * Returns point on line SEGMENT between point1 and point2 which is closest to this point. * @param original the point considered * @param endpt1 first endpoint of the line segment * @param endpt2 second endpoint of the line segment * @return point along the line that forms a perpendicular with the original point, or the nearest endpt to that point; or if the endpoints coincide a point at an endpoint */ public static Point2D.Double closestPointOnSegment(Point2D.Double original, Point2D.Double endpt1, Point2D.Double endpt2) { if (endpt1.equals(endpt2)) { return new Point2D.Double(endpt1.x, endpt1.y); } double t = t(original, endpt1, endpt2); t = t < 0 ? 0 : (t > 1 ? 1 : t); return new Point2D.Double(endpt1.x + t * (endpt2.x - endpt1.x), endpt1.y + t * (endpt2.y - endpt1.y)); }
protected void setSize(Point2D.Double size) { if(size.equals(this.size)) return; this.size = size; setSideLength((int)size.getX());//TODO: Remove sideLength subtextureVectorList.setDimensions(getSizeInCodes()); final int diameterInSubtextures = getDiameterInSubtextures(); setNumNeededSubtextureIDs(diameterInSubtextures*diameterInSubtextures); }//end setSize(...)
protected void setHandlePointList(Point2D.Double ptAnchor, Point2D.Double ptBox) { Point2D.Double pt2 = (ptBox == null && ptAnchor != null) ? ptAnchor : ptBox; Point2D.Double pt1 = (pt2 != null && pt2.equals(ptAnchor)) ? null : ptAnchor; setHandlePoint(0, pt1 == null ? null : (Point2D.Double) pt1.clone()); setHandlePoint(1, pt2 == null ? null : (Point2D.Double) pt2.clone()); buildShape(null); }
protected void updateTool() { ptA = getHandlePoint(0); ptB = getHandlePoint(1); ptC = getHandlePoint(2); ptD = getHandlePoint(3); ptE = getHandlePoint(4); ptF = getHandlePoint(5); lineABvalid = ptA != null && ptB != null && !ptB.equals(ptA); lineCDvalid = ptC != null && ptD != null && !ptC.equals(ptD); }
protected void updateTool() { ptA = getHandlePoint(0); ptB = getHandlePoint(1); lineABvalid = ptA != null && ptB != null && !ptB.equals(ptA); }
@Override public void setBounds(Point2D.Double anchor, Point2D.Double lead) { Point2D.Double oldAnchor = getStartPoint(); Point2D.Double oldLead = getEndPoint(); if (!oldAnchor.equals(anchor) || !oldLead.equals(lead)) { willChange(); setBounds(anchor, lead); changed(); fireUndoableEditHappened(new SetBoundsEdit(this, oldAnchor, oldLead, anchor, lead)); } }
public boolean equals(Object proj) { if (!(proj instanceof RotatedPole)) { return false; } RotatedPole oo = (RotatedPole) proj; return this.getNorthPole().equals(oo.getNorthPole()); }
public boolean equals(Object proj) { if (!(proj instanceof RotatedPole)) { return false; } RotatedPole oo = (RotatedPole) proj; if ((this.getDefaultMapArea() == null) != (oo.defaultMapArea == null)) return false; // common case is that these are null if (this.getDefaultMapArea() != null && !this.defaultMapArea.equals(oo.defaultMapArea)) return false; return this.getNorthPole().equals(oo.getNorthPole()); }
protected void updateTool() { ptA = getHandlePoint(0); ptB = getHandlePoint(1); lineABvalid = ptA != null && ptB != null && !ptB.equals(ptA); }
@Override public boolean equals(Object obj) { final Neighborhood2 other = (Neighborhood2) obj; return angle1 == other.angle1 && angle2 == other.angle2 && center.equals(other.center); }
return super.equals(object);
Point2D.Double l2b = (Point2D.Double) l2.getP2(); if (l1a.equals(l2a) == false && l1a.equals(l2b) == false && l1b.equals(l2a) == false && l1b.equals(l2b) == false) { return true; if (l1a.equals(l2b)) { final Point2D.Double tmp = l2a; l2a = l2b; l2b = tmp; } else if (l2a.equals(l1b)) { final Point2D.Double tmp = l1a; l1a = l1b; l1b = tmp; } else if (l1b.equals(l2b)) { Point2D.Double tmp = l2a; l2a = l2b; assert l1a.equals(l2a);
private boolean isConnectableInternal(Neighborhood2 other) { if (getCenter().equals(other.getCenter())) { throw new IllegalArgumentException("Same center"); } final Line2D.Double seg1 = new Line2D.Double(getCenter(), other.getCenter()); final double angle1 = Singularity2.convertAngle(Singularity2.getAngle(seg1)); final double angle2 = Singularity2.convertAngle(Singularity2.getOppositeAngle(seg1)); assert angle2 == Singularity2.convertAngle(Singularity2.getAngle(new Line2D.Double(other.getCenter(), getCenter()))); if (isInAngleStrict(angle1) && other.isInAngleStrict(angle2)) { return true; } if (isInAngleStrict(angle1) && other.isInAngleLarge(angle2)) { return true; } if (isInAngleLarge(angle1) && other.isInAngleStrict(angle2)) { return true; } if (isAngleLimit(angle1) && other.isAngleLimit(angle2)) { if (is360() || other.is360()) { return true; } final Orientation o1 = getOrientationFrom(angle1); final Orientation o2 = other.getOrientationFrom(angle2); return o1 != o2; } return false; }
@Override public boolean equals(Object obj) { final Neighborhood2 other = (Neighborhood2) obj; return angle1 == other.angle1 && angle2 == other.angle2 && center.equals(other.center); }