@Override public boolean equals(Object obj) { if (obj instanceof ExplicitBoundsShape) { ExplicitBoundsShape other = (ExplicitBoundsShape) obj; boolean result = shape.equals(other.shape); if (bounds == null) return result & (other.bounds == null); return result & bounds.equals(other.bounds); } else if (obj instanceof Shape) { if (bounds == null) return shape.equals(obj); return false; } return super.equals(obj); }
@Override public boolean equals(Object o) { if (!(o instanceof ImageInfo)) { return false; } ImageInfo ii = (ImageInfo) o; if (width != ii.width || height != ii.height) { return false; } else if (clip != null && ii.clip != null) { return clip.equals(ii.clip); } else if (clip == null && ii.clip == null) { return true; } else { return false; } } }
@Override public boolean equals(Object o) { if (!(o instanceof ImageInfo)) { return false; } ImageInfo ii = (ImageInfo) o; if (width != ii.width || height != ii.height) { return false; } else if (clip != null && ii.clip != null) { return clip.equals(ii.clip); } else if (clip == null && ii.clip == null) { return true; } else { return false; } } }
@Override public boolean equals(Object o) { if (!(o instanceof ImageInfo)) { return false; } ImageInfo ii = (ImageInfo) o; if (width != ii.width || height != ii.height) { return false; } else if (clip != null && ii.clip != null) { return clip.equals(ii.clip); } else if (clip == null && ii.clip == null) { return true; } else { return false; } } }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; SpatialQuadTree<?> that = (SpatialQuadTree<?>) o; if (level != that.level) return false; if (!nodes.equals(that.nodes)) return false; if (!area.equals(that.area)) return false; return layoutModel.equals(that.layoutModel); }
public void testPolygonShape() throws TransformException, FactoryException { GeometryFactory geomFac = new GeometryFactory(); Polygon polygon = makeSamplePolygon(geomFac, 0, 0); LiteShape2 lineShape = new LiteShape2( polygon, ProjectiveTransform.create(new AffineTransform()), new Decimator(ProjectiveTransform.create(new AffineTransform())), false); assertFalse(lineShape.contains(0, 0)); assertTrue(lineShape.contains(100, 100)); assertFalse(lineShape.contains(50, 50, 10, 10)); assertTrue(lineShape.contains(100, 100, 10, 10)); assertTrue(lineShape.contains(new java.awt.Point(70, 90))); assertFalse(lineShape.contains(new java.awt.geom.Rectangle2D.Float(50, 50, 10, 10))); assertTrue(lineShape.getBounds2D().equals(new Rectangle2D.Double(60, 70, 70, 50))); assertTrue(lineShape.getBounds().equals(new java.awt.Rectangle(60, 70, 70, 50))); assertTrue(lineShape.intersects(0, 0, 100, 100)); assertTrue(lineShape.intersects(new Rectangle2D.Double(0, 0, 100, 100))); assertFalse(lineShape.intersects(55, 55, 3, 100)); assertFalse(lineShape.intersects(new Rectangle2D.Double(55, 55, 3, 100))); }
public void testLineShape() throws TransformException, FactoryException { GeometryFactory geomFac = new GeometryFactory(); LineString lineString = makeSampleLineString(geomFac, 0, 0); AffineTransform affineTransform = new AffineTransform(); LiteShape lineShape = new LiteShape(lineString, affineTransform, false); assertFalse(lineShape.contains(0, 0)); assertTrue(lineShape.contains(60, 60)); assertFalse(lineShape.contains(50, 50, 10, 10)); assertTrue(lineShape.contains(new java.awt.Point(60, 60))); assertFalse(lineShape.contains(new java.awt.geom.Rectangle2D.Float(50, 50, 10, 10))); assertTrue(lineShape.getBounds2D().equals(new Rectangle2D.Double(50, 50, 80, 250))); assertTrue(lineShape.getBounds().equals(new java.awt.Rectangle(50, 50, 80, 250))); assertTrue(lineShape.intersects(0, 0, 100, 100)); assertTrue(lineShape.intersects(new Rectangle2D.Double(0, 0, 100, 100))); assertFalse(lineShape.intersects(55, 55, 3, 100)); assertFalse(lineShape.intersects(new Rectangle2D.Double(55, 55, 3, 100))); }
@Override public boolean equals(Object obj) { if (obj instanceof ExplicitBoundsShape) { ExplicitBoundsShape other = (ExplicitBoundsShape) obj; boolean result = shape.equals(other.shape); if (bounds == null) return result & (other.bounds == null); return result & bounds.equals(other.bounds); } else if (obj instanceof Shape) { if (bounds == null) return shape.equals(obj); return false; } return super.equals(obj); }
public void testLineShape2() throws TransformException, FactoryException { GeometryFactory geomFac = new GeometryFactory(); LineString lineString = makeSampleLineString(geomFac, 0, 0); MathTransform transform = ProjectiveTransform.create(new AffineTransform()); Decimator decimator = new Decimator(transform); LiteShape2 lineShape = new LiteShape2(lineString, transform, decimator, false); assertFalse(lineShape.contains(0, 0)); assertTrue(lineShape.contains(60, 60)); assertFalse(lineShape.contains(50, 50, 10, 10)); assertTrue(lineShape.contains(new java.awt.Point(60, 60))); assertFalse(lineShape.contains(new java.awt.geom.Rectangle2D.Float(50, 50, 10, 10))); assertTrue(lineShape.getBounds2D().equals(new Rectangle2D.Double(50, 50, 80, 250))); assertTrue(lineShape.getBounds().equals(new java.awt.Rectangle(50, 50, 80, 250))); assertTrue(lineShape.intersects(0, 0, 100, 100)); assertTrue(lineShape.intersects(new Rectangle2D.Double(0, 0, 100, 100))); assertFalse(lineShape.intersects(55, 55, 3, 100)); assertFalse(lineShape.intersects(new Rectangle2D.Double(55, 55, 3, 100))); }
@Override public void setModelArea(Rectangle2D modelArea) { if (!this.modelArea.equals(modelArea)) { this.modelArea = new Rectangle2D.Double(modelArea.getX(), modelArea.getY(), modelArea.getWidth(), modelArea.getHeight()); fireViewModelChanged(); } }
private boolean checkTransform(Rectangle2D geoArea) { System.out.println("%%%%%%map.checkTransform start"); if (!this.geoArea.equals(geoArea)) { Point2D point1 = getPixelPos(geoArea.getMinY(), geoArea.getMinX()); Point2D point2 = getPixelPos(geoArea.getMaxY(), geoArea.getMaxX()); mapArea.setRect(point1.getX(), point2.getY(), boundingBox.getWidth(), boundingBox.getHeight()); this.geoArea.setRect(geoArea); resetTransform(boundingBox, mapArea); System.out.println("%%%%%%map.checkTransform end 1"); return true; } System.out.println("%%%%%%map.checkTransform end 2"); return false; }
private static boolean imageAreaTest(Shape s1, Object option) { if (s1 == option) return true; if (!(option instanceof Shape)) return false; Shape s2 = (Shape) option; if (s1 == null || s2 == null) return false; if (s1.getClass() != s2.getClass()) return false; if (s1 instanceof RoundRectangle2D) { return s1.getBounds2D().equals(s2.getBounds2D()) && (((RoundRectangle2D) s1).getArcWidth() == ((RoundRectangle2D) s2).getArcWidth()) && (((RoundRectangle2D) s1).getArcHeight() == ((RoundRectangle2D) s2).getArcHeight()); } return s1.equals(s2); } private static boolean insetsTest(Insets[] ins1, Object obj)
private void adaptToModelRectangle(Rectangle2D modelRectangle) { correctBoundsIfNecessary(modelRectangle); if (modelRectangle.getWidth() != 0 && modelRectangle.getHeight() != 0 && !modelRectangle.equals(getFirstFigure().getBounds())) { updateFigure(modelRectangle); updateProperties(modelRectangle); } }
private void adaptToModelRectangle(Rectangle2D modelRectangle) { correctBoundsIfNecessary(modelRectangle); if (modelRectangle.getWidth() != 0 && modelRectangle.getHeight() != 0 && !modelRectangle.equals(getFirstFigure().getBounds())) { updateFigure(modelRectangle); updateProperties(modelRectangle); } }
/** * Compares two ellipses and returns <code>true</code> if they are equal or * both <code>null</code>. * * @param e1 the first ellipse (<code>null</code> permitted). * @param e2 the second ellipse (<code>null</code> permitted). * * @return A boolean. */ public static boolean equal(final Ellipse2D e1, final Ellipse2D e2) { if (e1 == null) { return (e2 == null); } if (e2 == null) { return false; } if (!e1.getFrame().equals(e2.getFrame())) { return false; } return true; }
/** * Compares two ellipses and returns {@code true} if they are equal or * both {@code null}. * * @param e1 the first ellipse ({@code null} permitted). * @param e2 the second ellipse ({@code null} permitted). * * @return A boolean. */ public static boolean equal(Ellipse2D e1, Ellipse2D e2) { if (e1 == null) { return (e2 == null); } if (e2 == null) { return false; } if (!e1.getFrame().equals(e2.getFrame())) { return false; } return true; }
/** * Compares two ellipses and returns <code>true</code> if they are equal or * both <code>null</code>. * * @param e1 the first ellipse (<code>null</code> permitted). * @param e2 the second ellipse (<code>null</code> permitted). * * @return A boolean. */ public static boolean equal(final Ellipse2D e1, final Ellipse2D e2) { if (e1 == null) { return (e2 == null); } if (e2 == null) { return false; } if (!e1.getFrame().equals(e2.getFrame())) { return false; } return true; }
/** * Compares two ellipses and returns <code>true</code> if they are equal or * both <code>null</code>. * * @param e1 the first ellipse (<code>null</code> permitted). * @param e2 the second ellipse (<code>null</code> permitted). * * @return A boolean. */ public static boolean equal(final Ellipse2D e1, final Ellipse2D e2) { if (e1 == null) { return (e2 == null); } if (e2 == null) { return false; } if (!e1.getFrame().equals(e2.getFrame())) { return false; } return true; }
private void checkBounds(InnerNode<?> node) { if (!node.getBounds().equals(getBounds(node.getChildren()))) { log.error("bounds not equal \n{} != \n{}", node.getBounds(), getBounds(node.getChildren())); } }
protected boolean intersectsWithAnyCollisionBox(final ICollisionEntity entity, final Point2D start, final Point2D target) { final List<Rectangle2D> allCollisionBoxes = Game.physics().getAllCollisionBoxes(); final Line2D line = new Line2D.Double(start, target); for (final Rectangle2D collisionBox : allCollisionBoxes) { if (collisionBox.equals(entity.getCollisionBox())) { continue; } // apply a margin for the path calculation in order to take the entities // collision box into consideration final Rectangle2D rectangleWithMargin = this.applyPathMargin(entity, collisionBox); // if the start is in the margin, the margin is not considered when // checking for collision because this will always return true Point2D intersection = GeometricUtilities.getIntersectionPoint(line, rectangleWithMargin.contains(start) ? collisionBox : rectangleWithMargin); if (intersection != null) { return true; } } return false; } }