This is not flex related, I know but since I don't have another blog to post this in, I will put it in this one:) so bare with me. Following my last post which was about implementing track changes in flex side, I decided to get a text comparison algorithm on the server java side to compare two texts and return a merged version with all additions and deletions.
I found a number of character/line comparison algos but the output wasn't that nice and i decided to look for a word by word comparison for change tracking. What I found was a "longest common subsequences algorithm" for Java but it was based on two linked lists or arrays. So decided to complement this with a textutil compare method that receives as a parameters two version of the text and produces a merged copy with deletions wrapped in "[-" & "-]" and additions wrapped in "[+" & "+]".
Thursday, July 30, 2009
Monday, July 27, 2009
Flex TextArea Track Changes, highlight
Last week I was given an assignment to provide highlight effect on certain text ranges in a flex text area. The purpose of this was to first allow a highlighting certain words as spelling mistakes and second to allow highlighting added and deleted text ranges. The spelling checker. The idea of highlighting a text range is not new, its basically finding the position of the first and last character in a range. Getting their boundary rectangles and the reset is just graphics. I developed three basic highlighting effects
1. The normal text background highlight
2. The strike-through highlight
3. The spelling mistake highlight like that of Microsoft word
1. The normal text background highlight
2. The strike-through highlight
3. The spelling mistake highlight like that of Microsoft word
Thursday, July 23, 2009
Text index to Html Index conversion
This week I was working on an enhancement to add highlighting, patterned underline, and strikethrough functionality to the textArea control of flex. I ran into a problem keeping track of the position of the text highlighted when the user edits the content. So I decided to wrap the highlighted text in html tags such as . My problem was that I needed an algorithm to conver text to html index.
After rigourous searching I found Andrei Ionescu post on this. I liked his method but reading through the comments I saw someone saying something about regular expressions and I thought to myself why not use regular expressions to help preprocess the html instead of character parsing.
Eventually I came up with this method and here I post it for anyone interested, feel free to use it.
After rigourous searching I found Andrei Ionescu post on this. I liked his method but reading through the comments I saw someone saying something about regular expressions and I thought to myself why not use regular expressions to help preprocess the html instead of character parsing.
Eventually I came up with this method and here I post it for anyone interested, feel free to use it.
Subscribe to:
Posts (Atom)