Uhm, maybe I'm way off here. Why not construct a Line2D and use the contains method? I have not thought this through, but that's what I thought about first.