Java Code Examples for java.awt.geom.Ellipse2D#intersects()

The following examples show how to use java.awt.geom.Ellipse2D#intersects() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PrecisionRecallMetric1.java    From swcv with MIT License 4 votes vote down vote up
public boolean close(Ellipse2D elip, SWCRectangle rect2)
{
    return elip.intersects(rect2.getX(), rect2.getY(), rect2.getWidth(), rect2.getHeight());
}
 
Example 2
Source File: ProximityMetric.java    From swcv with MIT License 4 votes vote down vote up
private boolean close(LayoutResult layout, Word first, Word second, List<Word> words)
{
    SWCRectangle rect1 = layout.getWordPosition(first);
    SWCRectangle rect2 = layout.getWordPosition(second);

    if (rect1 == null || rect2 == null)
        return false;

    if (touching(rect1, rect2))
        return true; // proximities should be a superset of adjacencies

    double c_x = rect1.getX() + rect1.getX() - rect1.getCenterX();
    double c_y = rect1.getY() + rect1.getY() - rect1.getCenterY();

    double e_width = rect1.getWidth() * 2;
    double e_height = rect1.getHeight() * 2;

    Ellipse2D elip = new Ellipse2D.Double(c_x, c_y, e_width, e_height);

    boolean inRange = elip.intersects(rect2.getX(), rect2.getY(), rect2.getWidth(), rect2.getHeight());

    // case: word 2 is not within the ellipse surrounding word 1
    if (!inRange)
        return false;

    // line connecting the two close words
    Line2D connection = new Line2D.Double(rect1.getCenterX(), rect1.getCenterY(), rect2.getCenterX(), rect2.getCenterY());

    // check for a word between our two "close" words
    // TODO: this could be more efficient, since only words that are close might have the possibility of intersection
    for (Word w : words)
    {

        // dont check collisions with the close words
        if (w.equals(first) || w.equals(second))
            continue;

        SWCRectangle tmpRect = layout.getWordPosition(w);

        // see if our line intersects any of the words
        if (connection.intersects(tmpRect.getX(), tmpRect.getY(), tmpRect.getWidth(), tmpRect.getHeight()))
            return false;
    }

    return true;

}
 
Example 3
Source File: PrecisionRecallMetric2.java    From swcv with MIT License 4 votes vote down vote up
public boolean close(Ellipse2D elip, SWCRectangle rect2)
{
    return elip.intersects(rect2.getX(), rect2.getY(), rect2.getWidth(), rect2.getHeight());
}