private void checkHover ( HumanInputEvent < ? > event ) { // Check: editing state, selection (there must be 1 index selected, but not this one): if ( service . getEditingState ( ) == GeometryEditState . DRAGGING && ! service . getIndexStateService ( ) . isSelected ( index ) && service . getIndexStateService ( ) . getSelection ( ) . size ( ) == 1 ) { GeometryIndex selected = service . getIndexStateService ( ) . getSelection ( ) . get ( 0 ) ; // Check: is the selected index of the same type, and is it a neighbor? if ( service . getIndexService ( ) . getType ( index ) == service . getIndexService ( ) . getType ( selected ) ) { // see if there are enough vertices left to delete one: int siblingCount = service . getIndexService ( ) . getSiblingCount ( service . getGeometry ( ) , index ) ; try { String geometryType = service . getIndexService ( ) . getGeometryType ( service . getGeometry ( ) , index ) ; if ( geometryType . equals ( Geometry . LINE_STRING ) ) { if ( siblingCount < 3 ) { return ; // 2 vertices is the minimum for a LineString. } } else if ( geometryType . equals ( Geometry . LINEAR_RING ) ) { if ( siblingCount < 5 ) { return ; // 4 vertices is the minimum for a LinearRing. } } else { throw new IllegalStateException ( "Illegal type of geometry found." ) ; } } catch ( GeometryIndexNotFoundException e ) { throw new IllegalStateException ( e ) ; } if ( ! allowMoreThanNeighbours && ! ( service . getIndexService ( ) . isAdjacent ( service . getGeometry ( ) , index , selected ) ) ) { // only allow neighbours to remove point + hovering over a not-neighbour return ; } // Mark the selected GeometryIndex for deletion: indexToDelete = selected ; if ( ! service . getIndexStateService ( ) . isMarkedForDeletion ( index ) ) { service . getIndexStateService ( ) . markForDeletionBegin ( Collections . singletonList ( index ) ) ; } // Than snap the selected vertex/edge to this one: // if this where omitted, the selected vertex would not overlay index position. if ( service . getIndexService ( ) . getType ( index ) == GeometryIndexType . TYPE_VERTEX ) { try { Coordinate location = service . getIndexService ( ) . getVertex ( service . getGeometry ( ) , index ) ; service . move ( Collections . singletonList ( selected ) , Collections . singletonList ( Collections . singletonList ( location ) ) ) ; event . stopPropagation ( ) ; } catch ( GeometryIndexNotFoundException e ) { logger . log ( Level . WARNING , "Index not found" , e ) ; } catch ( GeometryOperationFailedException e ) { logger . log ( Level . WARNING , "Operation failed" , e ) ; } } } } }
Supports only vertices for now .