public virtual int CompareTo(LocationTextExtractionStrategy.ITextChunkLocation other) { if (this == other) { return(0); } // not really needed, but just in case LineSegment mySegment = new LineSegment(startLocation, endLocation); LineSegment otherSegment = new LineSegment(other.GetStartLocation(), other.GetEndLocation()); if (other.GetStartLocation().Equals(other.GetEndLocation()) && mySegment.ContainsSegment(otherSegment) || startLocation.Equals(endLocation) && otherSegment.ContainsSegment(mySegment)) { // Return 0 to save order due to stable sort. This handles situation of mark glyphs that have zero width return(0); } int result; result = iText.IO.Util.JavaUtil.IntegerCompare(OrientationMagnitude(), other.OrientationMagnitude()); if (result != 0) { return(result); } result = iText.IO.Util.JavaUtil.IntegerCompare(DistPerpendicular(), other.DistPerpendicular()); if (result != 0) { return(result); } return(iText.IO.Util.JavaUtil.FloatCompare(DistParallelStart(), other.DistParallelStart())); }
internal virtual void PrintDiagnostics() { System.Console.Out.WriteLine("Text (@" + location.GetStartLocation() + " -> " + location.GetEndLocation() + "): " + text); System.Console.Out.WriteLine("orientationMagnitude: " + location.OrientationMagnitude()); System.Console.Out.WriteLine("distPerpendicular: " + location.DistPerpendicular()); System.Console.Out.WriteLine("distParallel: " + location.DistParallelStart()); }
public virtual bool IsAtWordBoundary(LocationTextExtractionStrategy.ITextChunkLocation previous) { if (GetCharSpaceWidth() < 0.1f) { return(false); } // In case a text chunk is of zero length, this probably means this is a mark character, // and we do not actually want to insert a space in such case if (startLocation.Equals(endLocation) || previous.GetEndLocation().Equals(previous.GetStartLocation())) { return(false); } float dist = DistanceFromEndOf(previous); return(dist < -GetCharSpaceWidth() || dist > GetCharSpaceWidth() / 2.0f); }