Changes between Version 9 and Version 10 of TEXT_CHAIN_AUTO_R0


Ignore:
Timestamp:
12/01/09 18:35:57 (15 years ago)
Author:
mira
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TEXT_CHAIN_AUTO_R0

    v9 v10  
    4646  * Paste some text in the already created autochain. -> New pages with frames should be added after the last, because the text is overflowing. 
    4747= Design = 
    48 ^(Describe your design here.)^ 
     48 
     49In org.sophie2.main.func.text.chaining package add a new enum ChainingMode containing different modes of the chaining: [[BR]] 
     50 - NO_CHAINING - The representation of no chain mode. [[BR]] 
     51 - AUTO_CHAINING - The representation of auto-chaining mode. [[BR]] 
     52 - MANUAL_CHAINING - The representation of manual chaining mode. [[BR]]  
     53The KEY_CHAIN_MODE should be holding value from this enum. [[BR]] [[BR]] 
     54 
     55The chaing hud elements would no longer be of the ResourceH class, since there are two special elements to add - for turning on and off auto-chainig. Create  
     56 
     57a class ChainHudElement in org.sophie2.main.func.text.chaining package that holds a ResourceRefR4 and a String representation of the object. It would be  
     58 
     59immutable. There will be two special elements holding NONE-REF and the strings "AUTO-CHAIN" and "NO CHAIN". Other elements should not be created withh NONE  
     60 
     61resource ref. So the constructor should be private and there will be a create method to validate the given refs. [[BR]] [[BR]] 
     62 
     63In TextChainingLogic::ON_CHAIN_TEXT_FRAME check what elements was choosen and if it is with none ref change HeadTextFrameR4.KEY_CHAIN_MODE corespondingly,  
     64 
     65otherwise chain the frame pointed by the resource ref held in the element to the head of the current frame. This hsould always change the chain mode to  
     66 
     67manual. [[BR]][[BR]] 
     68 
     69In org.sophie2.main.app.commons.util package create a util class named TemplateUtil. It will contain helper methods for the page and frame templating and for  
     70 
     71the creating of new templates. There is a difference in code of templating those elements since the templating of sub elements is not yet final.[[BR]] 
     72 - createTemplate - creates a template from a given element view. It should check whether it is page or frame.[[BR]] 
     73 - applyPageTemplate - apply given template to the given page. That is - set all keys to null, except the sub-entries one. [[BR]]  
     74 - applyFrameTemplate -  Set all given templated keys to null. If it is setting the main-resource, change the kind corespondingly.[[BR]][[BR]] 
     75 
     76Write better dryRun method in the HotLayout class that takes in mind the number of chianed areas in the last page. It should also check if there are extra  
     77 
     78pages and return -1.[[BR]][[BR]] 
     79 
     80In TextChainHud change the existing TextChainComboBox class to extend BoundComboBox<ChainHudElement> and change the addFrames method to get a list of  
     81 
     82ChainHudElements constructed by the resource ref of the frame and its name (for string representation). Remove the AutoChain button and all its  
     83 
     84logic.[[BR]][[BR]] 
     85 
     86The TextChainUtils should be quite extended to hold the helper methods used by the chaing logic. Some of them are moved from the TextChainingLogic. The  
     87 
     88method used for auto-chaining will be called reflowText. It would get a head frame view as argument and basically handle all auto-fitting of its text flow  
     89 
     90(creatin, deletion of pages). It should get all frame views in this head frame`s chain. Then it gets the number of frames on the last page and runs the  
     91 
     92HotLayout.dryrun method with them. If the result is 0 - there is nothing more to do. If the result is -1 this means that the last page is empty. There should  
     93 
     94be a ceparate method that hamdles the deletion of extra pages. Its name should be reduceChain. If the result is an positive int this is the number of pages  
     95 
     96exactly as the first one to be added. This should be done by the method expandChain.[[BR]] 
     97 
     98 * expandChain - The chain should be expanded with pages that use templates made from the last page in the current chain and children that use templates made  
     99 
     100from the children of the last page`s children. The last page should also be made to use this template so that wnem it is changd it chanes just like the  
     101 
     102others in the chain. Those templates are added to the library just like regular ones. There are some x-cases:[[BR]] 
     103 - When there is another auto-chain in the page - the new frames are made the next in their chain. [[BR]] 
     104 - If there is an head frame (that is not autochained) its copy uses the same text resource. [[BR]] 
     105 - when there is a tail frame (or head frame that is auto-chained), its copy is the next in the chain of the source. Its chain order is also placing it  
     106 
     107before any other frame of this chain.[[BR]] 
     108 
     109 * reduceChain - Checks all pages starting from the last one for pages that are all templated. This means that their templated keys should be templated and  
     110 
     111all their children should also be templated. Also all of its tail text frames should be empty. If such page is found it is deleted. If there is no more an  
     112 
     113empty page in the end of the chain the job is done, otherwise we continue looking ofr pages to remove from the previous page.   [[BR]][[BR]] 
     114 
     115There will be needed some helper methods:[[BR]] 
     116 - TEXT_VIEW_COMP - Comparator for thext views. It compares views from the same chain by their chain-order strings.  
     117 - isAllPageTemplated - checks if all the templatable keys from the given page along with the keys of it's subelements(frames) are in TEMPLATE mode. This is  
     118 
     119not the best way to see whther the whole page is templated but it would do before implementatin of the sub-elements templating.[[BR]] 
     120 - isPageTemplated - checks if all the templatable keys(for now except sub-entries) are in TEMPLATE mode, i.e. are their raw values null. [[BR]] 
     121and others.[[BR]] 
     122 - ... 
     123 
     124In HeadTextFrameView in the class textFlow used for a the resource property with the same name crate a class named ReflowThread. Its run method will be quite  
     125 
     126simple. It should sleep for a second and then invoke later in the event dispatching thread the method TextChainUtils.reflowText giving it this  
     127 
     128HeadTextFrameView object. he Headin getTextLayout method that extends Thread and delays the invoking of the TextChainUtils.reflowText method. Now the only  
     129 
     130thing that is left is to start the thread and this will happen every time the method getTextLayout() is called on an autochained head view. It would check if  
     131 
     132there is a thread runing and if not - strat one. Otherwise its job is done. For optimization there may be a check whether the text flow is going to be the  
     133 
     134same as the last time the thread was called. [[BR]][[BR]] 
     135 
     136There will be some additional fixes of bugs in the current chainig logic: [[BR]] 
     137 
     138Now the logic assumes that in a chain there are never same chain orders. But this is not always this way. when there are same chain orders the order of the  
     139 
     140pages and the z order are taken in consideration. Also this is the reason why the getChainedFrames() helper method can not return a map - since there is not  
     141 
     142always a single TailFrameH corresponding to a chain order. [[BR]]  
     143The logic of the two buttons for unchain (previous and next) should be unified. There will be a common method splitChain that they will use. It would make  
     144 
     145the given frame - head of a new chain and all after it would be chained to it. It could use the same text resource as the previous one or get a new empty  
     146 
     147one. This should be specified by an flag argument. [[BR]] 
     148This method will also be used when deleting pages. Its logic was broken if deleting from the button but it was ok if deleting by 'del' or backspace. The  
     149 
     150delete page button should have the same event as the others (its source should be the PagePreviewPalette). Now before the page is deleted the chains that  
     151 
     152start in it are split to the first frame that is not in this page.  [[BR]][[BR]] 
     153 
     154Also there are a couple of bugs in the base functionality of the resources. [[BR]] 
     155First one is in the ModelResourceChanger. When an key is set to null and get in the same auto-action the get returns wrong value - the old one from the  
     156 
     157model. This could only be found while developing and I don`t think there is an ticket for it.[[BR]] 
     158 
     159The other one is in the modify method of the ResourceModel. The problem occures when creating template from templated frame. There is an exception thrown but  
     160 
     161there is no ticket also. It this case the values of some of the keys are already null and there is no need for them to be set to null but their 'locked-key's  
     162 
     163are still set to false. The moidfy method relies on the fact that when modifing a node corresponding to a key there are chanes meant for it if the sub map of  
     164 
     165chanes for entries whose keys start with this key is not empty. This is not true for the case of templated keys though since their locked keys idd start  
     166 
     167exactly the same as their ids. This method hsould not rely on such assumptions. [[BR]]   
     168  
     169  
    49170 
    50171= Implementation =