/** Handle DocumentChange event. If the change affect this Part, fire * the PROP_TEXT event. */ void handleDocumentChange(DocumentEvent p0) { if (p0.getType().equals(DocumentEvent.EventType.INSERT)) { if ((p0.getOffset() >= previousOffset) && (p0.getOffset() < (previousOffset + getLength()))) { firePropertyChange(Annotatable.PROP_TEXT, null, null); } } if (p0.getType().equals(DocumentEvent.EventType.REMOVE)) { if ( ((p0.getOffset() >= previousOffset) && (p0.getOffset() < (previousOffset + getLength()))) || ((p0.getOffset() < previousOffset) && ((p0.getOffset() + p0.getLength()) > previousOffset)) ) { length = limitLength(length); firePropertyChange(Annotatable.PROP_TEXT, null, null); } } if ( (p0.getType().equals(DocumentEvent.EventType.INSERT) || p0.getType().equals(DocumentEvent.EventType.REMOVE)) && (p0.getOffset() < previousOffset) ) { firePropertyChange(Line.Part.PROP_COLUMN, null, null); } previousOffset = position.getOffset(); } }
public Part(Line line, PositionRef position, int length) { this.position = position; this.line = line; previousOffset = position.getOffset(); this.length = limitLength(length); }