@Override public boolean equals( final Object obj ) { return obj instanceof Line && Line.equals( this, ( Line ) obj ); }
@Override public int hashCode() { return Line.hashCode( this ); }
/** * Computes a hash code for a line. The hash code value is based on the * endpoint positions. * * @param line * The line for which to compute the hash code. * @return Hash code of the line. */ static int hashCode( final Line line ) { int result = 119; for ( int i = 0; i < line.numDimensions(); i++ ) result += 53 * line.endpointOne().getDoublePosition( i ) + 91 * line.endpointTwo().getDoublePosition( i ); return result + 5; }
/** * Determines whether two lines describe the same region. * <p> * Two lines are equal iff they have the same dimensionality and endpoints. * </p> * * @param line1 * The first line to compare. * @param line2 * The second line to compare. * @return True iff the lines describe the same region. */ public static boolean equals( final Line line1, final Line line2 ) { if ( line1 == null && line2 == null ) return true; return line1 != null && line2 != null && Masks.sameTypesAndDimensions( line1, line2 ) && // Util.locationsEqual( line1.endpointOne(), line2.endpointOne() ) && // Util.locationsEqual( line1.endpointTwo(), line2.endpointTwo() ); } }
@Override public ij.gui.Line convert(final Line mask) { final RealLocalizable ptOne = mask.endpointOne(); final RealLocalizable ptTwo = mask.endpointTwo(); return new ij.gui.Line(ptOne.getDoublePosition(0), ptOne.getDoublePosition( 1), ptTwo.getDoublePosition(0), ptTwo.getDoublePosition(1)); } }
@Override public int hashCode() { return Line.hashCode(this); }
@Override public boolean equals(final Object obj) { return obj instanceof Line && Line.equals(this, (Line) obj); }