code: private static boolean polylineWithinEnvelope_(Polyline polyline_a,
  			Envelope envelope_b, double tolerance,
  			ProgressTracker progress_tracker) {
  		Envelope2D env_a = new Envelope2D(), env_b = new Envelope2D();
  		polyline_a.queryEnvelope2D(env_a);
  		envelope_b.queryEnvelope2D(env_b);
  
  		if (!envelopeInfContainsEnvelope_(env_b, env_a, tolerance))
  			return false;
  
  		if (env_b.getHeight() <= tolerance && env_b.getWidth() <= tolerance)
  			return false;
  
  		if (env_b.getHeight() <= tolerance || env_b.getWidth() <= tolerance)
  			return envelopeInfContainsEnvelope_(env_b, env_a, tolerance);
  
  		SegmentIterator seg_iter_a = polyline_a.querySegmentIterator();
  		Envelope2D env_b_deflated = new Envelope2D();
  		env_b_deflated.setCoords(env_b);
  		env_b_deflated.inflate(-tolerance, -tolerance);
  
  		boolean b_interior = false;
  		Envelope2D env_segment_a = new Envelope2D();
  		Envelope2D env_inter = new Envelope2D();
  
  		while (seg_iter_a.nextPath()) {
  			while (seg_iter_a.hasNextSegment()) {
  				Segment segment_a = seg_iter_a.nextSegment();
  				segment_a.queryEnvelope2D(env_segment_a);
  
  				if (env_b_deflated.containsExclusive(env_segment_a)) {
  					b_interior = true;
  					continue;
  				}
  
  				env_inter.setCoords(env_b_deflated);
  				env_inter.intersect(env_segment_a);
  
  				if (!env_inter.isEmpty()
  						&& (env_inter.getHeight() > tolerance || env_inter
  								.getWidth() > tolerance))
  					b_interior = true;
  			}
  		}
  
  		return b_interior;
  	}
docs: Returns true if polyline_a is within envelope_b.