Changeset 1529


Ignore:
Timestamp:
06/18/20 13:50:48 (4 years ago)
Author:
bnemhaus
Message:

When running the "WriteTree tex" action, the presence of the annotation "@flowwalker" is tested for. If it is present then the flow walker is used!

Location:
trunk/src/org/expeditee
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/agents/WriteTree.java

    r919 r1529  
    6060
    6161                _format = format.trim();
     62               
    6263
    6364                int ind = params.indexOf(" ");
  • trunk/src/org/expeditee/io/DefaultTreeWriter.java

    r1415 r1529  
    2020
    2121import java.io.IOException;
     22import java.util.ArrayList;
    2223import java.util.List;
    2324import java.util.Stack;
     
    4748                try {
    4849                        initialise(toWrite);
    49                         outputTree(toWrite);
     50                        //outputTree(toWrite);
     51                        outputTreeFlowWalkerStyle(toWrite);
    5052
    5153                } catch (IOException ioe) {
     
    184186        }
    185187
     188        protected void outputTreeFlowWalkerStyle(Frame toWrite) {
     189                XGroupItem.doImplicitBoxing = true;
     190                XGroupItem xgroup = new XGroupItem(toWrite, new ArrayList<Item>(toWrite.getAllItems()));
     191                xgroup.repositionOutOfFlowGroups(xgroup);
     192                xgroup.mapInXGroupItemsRecursive(xgroup.getGroupedItemList());
     193               
     194                ArrayList<Item> yxOverlappingItemList = xgroup.getYXOverlappingItemList();
     195               
     196                for(Item i: yxOverlappingItemList) {
     197                        if (i instanceof Text) {
     198                                Text t = (Text) i;
     199                                if (t.isAnnotation()) { continue; }
     200                                Text titleItem = t.getParent().getTitleItem();
     201                                if (t.equals(titleItem)) { continue; }
     202                                if (t.hasLink()) {
     203                                        Frame toWalk = FrameIO.LoadFrame(t.getAbsoluteLink());
     204                                        outputTreeFlowWalkerStyle(toWalk);
     205                                        continue;
     206                                }
     207                                try {
     208                                        this.writeItem(t);
     209                                } catch (IOException e) {
     210                                        System.err.println("DefaultTreeWriter::outputTreeFlowWalkerStyle::IOException while writing item.");
     211                                        System.err.println(e.getMessage());
     212                                }
     213                        }
     214                }
     215        }
     216       
    186217        protected String finaliseTree() throws IOException {
    187218                return "Tree" + finalise();
  • trunk/src/org/expeditee/io/TEXWriter.java

    r919 r1529  
    3232        // may be needed for sectioning commands
    3333        private Text _title = null;
     34        private boolean useFlowWalker = false;
     35       
     36        public String writeTree(Frame toWrite) throws IOException {
     37                try {
     38                        initialise(toWrite);
     39                        if (useFlowWalker) {
     40                                System.err.println("USING FLOW WALKER FOR TEXTWriter");
     41                                outputTreeFlowWalkerStyle(toWrite);
     42                        } else {
     43                                outputTree(toWrite);
     44                        }
     45                } catch (IOException ioe) {
     46                        _running = false;
     47                        throw ioe;
     48                } catch (Exception e) {
     49                        e.printStackTrace();
     50                }
     51                _running = false;
     52                return finaliseTree();
     53        }
    3454
    3555        @Override
    3656        protected void initialise(Frame start, Writer writer) throws IOException {
    3757                _format = ".tex";
     58                Text annotation = start.getAnnotation("flowwalker");
     59                if (annotation != null) {
     60                        useFlowWalker  = true;
     61                }
    3862                super.initialise(start, writer);
    3963        }
     
    104128
    105129        @Override
    106         protected void writeText(Text text) throws IOException {
     130        protected void writeText(Text text) throws IOException {       
    107131                for (String s : text.getTextList()) {
    108132                        _writer.write(s);
Note: See TracChangeset for help on using the changeset viewer.