swing - java split Styleddocument into two -


i have defaultstyleddocument formatted text inside. have function, splits content (as plaintext) pattern-matcher.

i need function, generates splitted output new complete defaultstyleddocuments

defaultstyleddocument doc = new defaultstyleddocument(); functions.loadrtftodocument(rtftext, doc); //rtftext rtf-string  pattern pattern = pattern.compile("^((\\s*)•)", pattern.multiline); matcher matcher = pattern.matcher(plaintext); while(matcher.find()){     int start = matcher.start();     int end = matcher.end();     defaultstyleddocument target = new defaultstyleddocument();     //fill target styled text (from start end) } 

it's not trivial task. imagine start position found in mid of nested table , end position in mid of ordered list placed after base table.

for simplest cas when have paragaraphs , texts in document can go through paragraph elements asking start , end offsets , compare matcher's offsets. if paragraph suits range go through paragraph element's childrent (text elements). each text element suits given range call insertstring() in target document passing text , attributes text element.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -