DividerPolygon (int inlayOffset) { int delta = (myEnd2 - myStart2) - (myEnd1 - myStart1); if (delta == 0) return this; if (myStart2 == myEnd1 && myEnd1 == myEnd2) { //correspond to the last line DELETED change (e.g. last line deleted) return new DividerPolygon(myStart1, myStart2 - (myEnd2 - myStart1), myEnd1, myEnd2, myFillColor, myBorderColor, myDottedBorder); } else if (myEnd1 == myEnd2 && myStart1 == myEnd1) { //correspond to the last line INSERTED change (e.g. added new lines after last line) return new DividerPolygon(myStart1 - (myEnd2 - myStart2), myStart2, myEnd1, myEnd2, myFillColor, myBorderColor, myDottedBorder); } if (delta < 0) { int startDelta = myStart2 == myEnd2 ? 0 : -delta; int endDelta = myStart2 == myEnd2 ? -delta : 0; return new DividerPolygon(myStart1, myStart2 - startDelta + inlayOffset, myEnd1, myEnd2 + endDelta + inlayOffset, myFillColor, myBorderColor, myDottedBorder); } else { int startDelta = myStart1 == myEnd1 ? 0 : delta; int endDelta = myStart1 == myEnd1 ? delta : 0; int firstLineOffset = (myStart1 == myEnd1 && myStart2 == 0) ? -1 : 0; return new DividerPolygon(myStart1 - startDelta + firstLineOffset + inlayOffset, myStart2, myEnd1 + endDelta + firstLineOffset + inlayOffset, myEnd2, myFillColor, myBorderColor, myDottedBorder); } }