[brailleblaster] 4 new revisions pushed by brandon....@xxxxxxxxx on 2014-07-03 18:04 GMT

  • From: brailleblaster@xxxxxxxxxxxxxx
  • To: brailleblaster@xxxxxxxxxxxxx
  • Date: Thu, 03 Jul 2014 18:04:15 +0000

4 new revisions:

Revision: 13cb87e2bcb1
Branch:   default
Author:   Brandon Roller <brandon.r.roller@xxxxxxxxx>
Date:     Tue Jun 10 18:16:59 2014 UTC
Log:      Removed unused legacy code
http://code.google.com/p/brailleblaster/source/detail?r=13cb87e2bcb1

Revision: 320616bd6dc4
Branch:   default
Author:   Brandon Roller <brandon.r.roller@xxxxxxxxx>
Date:     Thu Jul  3 16:07:57 2014 UTC
Log: Enhanced performance with large documents/Began re-designing maplist
http://code.google.com/p/brailleblaster/source/detail?r=320616bd6dc4

Revision: 278434910539
Branch:   default
Author:   Brandon Roller <brandon.r.roller@xxxxxxxxx>
Date:     Thu Jul  3 16:14:22 2014 UTC
Log:      Merged branches
http://code.google.com/p/brailleblaster/source/detail?r=278434910539

Revision: 6abde6d6b9f4
Branch:   default
Author:   Brandon Roller <brandon.r.roller@xxxxxxxxx>
Date:     Thu Jul  3 18:02:55 2014 UTC
Log:      Fixed issues with merge
http://code.google.com/p/brailleblaster/source/detail?r=6abde6d6b9f4

==============================================================================
Revision: 13cb87e2bcb1
Branch:   default
Author:   Brandon Roller <brandon.r.roller@xxxxxxxxx>
Date:     Tue Jun 10 18:16:59 2014 UTC
Log:      Removed unused legacy code
http://code.google.com/p/brailleblaster/source/detail?r=13cb87e2bcb1

Deleted:
 /src/main/org/brailleblaster/document/Actions.java
 /src/main/org/brailleblaster/document/DocumentBase.java
 /src/main/org/brailleblaster/document/Semantics.java
 /src/main/org/brailleblaster/document/Styles.java
 /src/main/org/brailleblaster/wordprocessor/UTD.java
Modified:
 /src/main/org/brailleblaster/perspectives/braille/Manager.java

=======================================
--- /src/main/org/brailleblaster/document/Actions.java Tue Apr 15 14:34:57 2014 UTC
+++ /dev/null
@@ -1,110 +0,0 @@
-/* BrailleBlaster Braille Transcription Application
-  *
-  * Copyright (C) 2014
-* American Printing House for the Blind, Inc. www.aph.org
-* and
-  * ViewPlus Technologies, Inc. www.viewplus.com
-  * and
-  * Abilitiessoft, Inc. www.abilitiessoft.com
-  * and
-  * American Printing House for the Blind, Inc. www.aph.org www.aph.org
-  *
-  * All rights reserved
-  *
-  * This file may contain code borrowed from files produced by various
-  * Java development teams. These are gratefully acknowledged.
-  *
-  * This file is free software; you can redistribute it and/or modify it
-  * under the terms of the Apache 2.0 License, as given at
-  * http://www.apache.org/licenses/
-  *
-  * This file is distributed in the hope that it will be useful, but
-  * WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
-  * See the Apache 2.0 License for more details.
-  *
-  * You should have received a copy of the Apache 2.0 License along with
-  * this program; see the file LICENSE.
-  * If not, see
-  * http://www.apache.org/licenses/
-  *
-  * Maintained by Keith Creasy <kcreasy@xxxxxxx>, Project Manager
-*/
-
-package org.brailleblaster.document;
-
-import nu.xom.Element;
-
-/**
- * This class contains the actions which can be performed on elements.
- * They are distinct from styles.
- */
-class Actions {
-
-Semantics sm;
-Actions (final Semantics sm) {
-this.sm = sm;
-}
-
-/**
- * The various actions that can be carried out on an xml document, in
- * addition to processing styles.
- */
-enum Action {
-  blankspace,
-  skip,
-  generic,
-  cdata,
-  htmllink,
-  htmltarget,
-  notranslate,
-  pagenum,
-  attrtotext,
-  runninghead,
-  footer,
-  boxline,
-  italic,
-  bold,
-  underline,
-  compbrl,
-  linespacing,
-  blankline,
-  softreturn,
-  brl,
-  music,
-  math,
-  chemistry,
-  graphic
-};
-
-/**
- * Check if an action exists.
- */
-boolean exists (String actionName) {
-  try {
-  Action.valueOf (actionName);
-  } catch (IllegalArgumentException e) {
-  return false;
-  }
-  return true;
-}
-
-/**
- * This method is called to carry out any actions that may be needed
- * before an elemennt is processed. If the action itself processes the
- * element, such as skipping it and its subtree, the method returns
- * false.
- */
-boolean actionBeforeElement (Element element) {
-Action act = Action.valueOf ("blankLine");
-  return true;
-}
-
-/**
- * This method is called after an element and its subtree have been
- * processed to take any action that might be necessary at this point.
- */
-void actionAfterElement() {
-}
-
-}
=======================================
--- /src/main/org/brailleblaster/document/DocumentBase.java Fri Jun 6 08:41:52 2014 UTC
+++ /dev/null
@@ -1,327 +0,0 @@
-/* BrailleBlaster Braille Transcription Application
-  *
-  * Copyright (C) 2014
-* American Printing House for the Blind, Inc. www.aph.org
-* and
-  * ViewPlus Technologies, Inc. www.viewplus.com
-  * and
-  * Abilitiessoft, Inc. www.abilitiessoft.com
-  * and
-  * American Printing House for the Blind, Inc. www.aph.org www.aph.org
-  *
-  * All rights reserved
-  *
-  * This file may contain code borrowed from files produced by various
-  * Java development teams. These are gratefully acknowledged.
-  *
-  * This file is free software; you can redistribute it and/or modify it
-  * under the terms of the Apache 2.0 License, as given at
-  * http://www.apache.org/licenses/
-  *
-  * This file is distributed in the hope that it will be useful, but
-  * WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
-  * See the Apache 2.0 License for more details.
-  *
-  * You should have received a copy of the Apache 2.0 License along with
-  * this program; see the file LICENSE.
-  * If not, see
-  * http://www.apache.org/licenses/
-  *
-  * Maintained by Keith Creasy <kcreasy@xxxxxxx>, Project Manager
-*/
-
-package org.brailleblaster.document;
-
-import org.brailleblaster.BBIni;
-import org.brailleblaster.util.CheckLiblouisutdmlLog;
-import org.liblouis.LibLouisUTDML;
-import nu.xom.Document;
-import nu.xom.Node;
-import nu.xom.Element;
-import nu.xom.Text;
-import nu.xom.Nodes;
-import java.io.InputStream;
-import org.brailleblaster.util.FileUtils;
-
-/**
- * This class gives access to the facilities of the document package,
- * which encapsulates knowledge of the vocabulary of the particular
- * document. Other classes thus deal with an abstraction by calling
- methods in this class. Thus they have no need to worry about the
- * vocabulary of the particular document, unless they are displaying a
- * tree view.
- * See the comment "for views" for fields and methods that can be used
- * in other views.
- * NOTE: Views must use the instance of DocumenBase created when the
- * document was opened.
- */
-public class DocumentBase {
-
-private FileUtils fu = new FileUtils();
-private String fileSep = BBIni.getFileSep();
-private Semantics sm = new Semantics();
-private LibLouisUTDML lutdml = LibLouisUTDML.getInstance();
-
-/**
- * Parse the document and set up the neccessary data structures. This
- * method handles input that does not come from files.
- * @param inputStream a stream of bytes
- * @param configFile The name of a liblouisutdml configuration file
- * @param configSettings additional configuration settings
- */
-public boolean startDocument (InputStream inputStream, String
-configFile,
-String configSettings) throws Exception {
-String fileName = "xxx";
-sm.makeSemantics (fileName);
-return false;
-}
-
-/**
- * Similar to previous method, except that it handles input files
- * explicitly.
- * @param completePath complete path to the file
- */
-public boolean startDocument (String completePath, String configFile,
-String configSettings) throws Exception {
-return setupFromFile (completePath, configFile, configSettings);
-}
-
-/**
- * Save the document, Which contains UTDML and may have been edited, so
- * that work can be resumed.
- * @param completePath Complete path to where the file should be saved
- */
-public void saveWorkingFile (String completePath) {
-int extPos = completePath.lastIndexOf (".") + 1;
-String ext = completePath.substring (extPos);
-if (!ext.equalsIgnoreCase ("utd")) {
-throw new IllegalArgumentException ("File name must end in 'utd'.");
-}
-sm.saveWorkingFile (completePath);
-}
-
-/**
- * Save the document, with all print and Braille edits. <brl> nodes and
- * meta,name,brl are removed.
- * @param completePath the location in which the file is to be saved
- */
-public void saveEnhancedDocument (String completePath) {
-sm.saveEnhancedDocument (completePath);
-}
-
-/**
- * Return the tree created by parsing the document.
- */
-public Document getDocumentTree() {
-return sm.workingDocument;
-}
-
-/**
- * Edit or create a style to be used in the word processor view.
- * @param stylename the name of the style to be edited or created
- */
-public void editCreateStyle (String styleName) {
-Styles.StyleType styleType = sm.st.readStyle (styleName);
-sm.st.editStyle (styleType);
-sm.st.writeStyle (styleType);
-}
-
-public Nodes getNodes (Node node, String xpathExpr) {
-return sm.getNodes (node, xpathExpr);
-}
-
-public Node getContextNode() {
-return null;
-}
-
-/**
- * Render a document with UTDML, then parse the result and set up data
- * structures.. This is for documents that exist as
- * files, either in their own right or as temparary files.
- * @param completePath complete path to the input file
- * @param configFile name of a liblouisutdml configuration file
- * @param configSettings a String containing additional configuration
- settings of the form
- *    setting1 value\n setting2 value\n ...
- */
-private boolean setupFromFile (String completePath, String
-configFile,
-String configSettings) throws Exception {
-String configFileWithPath = fu.findInProgramData
-("liblouisutdml" + fileSep + "lbu_files" + fileSep
-+ configFile);
-String configWithUTD;
-if (configSettings == null) {
-configWithUTD = "formatFor utd\n mode notUC\n";
-} else {
-configWithUTD = configSettings + "formatFor utd\n mode notUC\n";
-}
-String outFile = BBIni.getTempFilesPath() + fileSep +
-"outFile.utd";
-String logFile = BBIni.getLogFilesPath() + fileSep +
-"liblouisutdml.log";
-boolean success = false;
-int extPos = completePath.lastIndexOf (".") + 1;
-String ext = completePath.substring (extPos);
-if (ext.equalsIgnoreCase ("xml")) {
-success = lutdml.translateFile (configFileWithPath, completePath,
-outFile,
-logFile, configWithUTD, 0);
-} else
-if (ext.equalsIgnoreCase ("txt")) {
-success = lutdml.translateTextFile (configFileWithPath, completePath,
-outFile,
-logFile, configWithUTD, 0);
-} else
-if (ext.equalsIgnoreCase ("brf")) {
-success = lutdml.backTranslateFile (configFileWithPath, completePath,
-outFile,
-logFile, configWithUTD, 0);
-} else
-if (ext.equalsIgnoreCase ("utd")) {
-success = sm.makeSemantics (completePath);
-} else {
-throw new IllegalArgumentException
-(completePath + " not .xml, .txt, or .brf");
-}
-new CheckLiblouisutdmlLog().displayLog();
-if (!success) {
-return false;
-}
-success = sm.makeSemantics (outFile);
-return success;
-}
-
-/**
- * for views The following fields provide the abstraction of the
- * document, and the methods provide The means of stepping through the
- * document, seting the fields accordingly. They also provide the means
- * of indicating the start and end of segments of text in a StyledText
- * control and of finding the values of the fields corresponding to a
- * cursor position.
- */
-/**
- * Element that is the principal of these fields.
- */
-public Element element;
-
-/**
- * Text node asociated with this element. WARNING: this field may be
-  * null.
- */
-public Text text;
-/**
- * The name of the style associated with this element.
- */
-public String style;
-
-/**
- * The name of the action associated with this element, may be null.
- */
-public String action;
-
-/**
- * The macro associated with this element, may be null.
- */
-public String macro;
-
-/**
- * Parameters associated with this style, action or macro; may be null.
- */
-public String parameters;
-
-/**
- * Depth to which this style is nested within other styles; document
- * style is 0.
- */
-public int styleNesting;
-
-/**
- * Start of the text in a StyledText control associated with this Text
- * node.
- */
-public int start;
-
-/**
- * Endo f the text in a StyledText control associated with this Text
-  * node.
- */
-public int end;
-
-/**
- * Beginning a set of style fields.
- */
-public boolean newStyle;
-
-/**
- * Inside a style, such as when handling emphasis, math or graphic.
- */
-public boolean insideStyle;
-
-private int nextElemSem;
-
-/**
- * This method begins the process of providing the semantic or abstract
- * information about a document.
- */
-public void startSemantics () {
-nextElemSem = 0;
-next();
-}
-
-private Semantics.ElementSemantics elemSem = null;
-
-/**
- * This method supplies the information for the next significant portion
- * of the document. Note that not all elements are considered as
- * significant.
- */
-public boolean next() {
-if (nextElemSem >= sm.semanticsList.size()) {
-return false;
-}
-elemSem = sm.semanticsList.get(nextElemSem);
-nextElemSem++;
-this.element = elemSem.element;
-Semantics.SemanticEntry semEnt =
-sm.semanticsTable.get(elemSem.semanticsIndex);
-if (semEnt.operation.equalsIgnoreCase ("style")) {
-this.style = semEnt.operand;
-} else {
-this.style = null;
-}
-if (semEnt.operation.equalsIgnoreCase ("action")) {
-this.action = semEnt.operand;
-} else {
-this.action = null;
-}
-if (semEnt.operation.equalsIgnoreCase ("macro")) {
-this.macro = semEnt.operand;
-} else {
-this.macro = null;
-}
-this.parameters = semEnt.parameters;
-this.start = elemSem.start;
-this.end = elemSem.end;
-return true;
-}
-
-/**
- * This method communicates the beginning and end positions of a segment
- * of text in a StyledText control to the underlying semantic or
- * abstract representation.
- */
-public void setLimits (int start, int end) {
-elemSem.start = start;
-elemSem.end = end;
-}
-
-/**
- * This method sets the fields to correspond to a given cursor position.
- */
-public void findPosition (int cursorPos) {
-}
-
-}
=======================================
--- /src/main/org/brailleblaster/document/Semantics.java Tue Apr 15 14:34:57 2014 UTC
+++ /dev/null
@@ -1,609 +0,0 @@
-/* BrailleBlaster Braille Transcription Application
-  *
-  * Copyright (C) 2014
-* American Printing House for the Blind, Inc. www.aph.org
-* and
-  * ViewPlus Technologies, Inc. www.viewplus.com
-  * and
-  * Abilitiessoft, Inc. www.abilitiessoft.com
-  * and
-  * American Printing House for the Blind, Inc. www.aph.org www.aph.org
-  *
-  * All rights reserved
-  *
-  * This file may contain code borrowed from files produced by various
-  * Java development teams. These are gratefully acknowledged.
-  *
-  * This file is free software; you can redistribute it and/or modify it
-  * under the terms of the Apache 2.0 License, as given at
-  * http://www.apache.org/licenses/
-  *
-  * This file is distributed in the hope that it will be useful, but
-  * WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
-  * See the Apache 2.0 License for more details.
-  *
-  * You should have received a copy of the Apache 2.0 License along with
-  * this program; see the file LICENSE.
-  * If not, see
-  * http://www.apache.org/licenses/
-  *
-  * Maintained by Keith Creasy <kcreasy@xxxxxxx>, Project Manager
-*/
-
-package org.brailleblaster.document;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.io.FileOutputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import nu.xom.Builder;
-import nu.xom.Node;
-import nu.xom.Nodes;
-import nu.xom.ParsingException;
-import nu.xom.Serializer;
-import nu.xom.Document;
-import nu.xom.Element;
-import nu.xom.Attribute;
-import org.brailleblaster.BBIni;
-import org.brailleblaster.localization.LocaleHandler;
-import org.brailleblaster.util.Notify;
-import org.brailleblaster.util.FileUtils;
-import java.util.HashMap;
-import java.util.ArrayList;
-
-/**
- * <p>This class provides the means of displaying and editing any
- * flavor of xml.
- * This is accomplished by using a semantic-action file for each type of
- * xml document, such as NIMAS, epub or docbook. Displaying and editing
- * in both the print and Braille windows are covered. No transformations
- * are necessary.</p>
- * <p>Instances of this class may not be reused. A new instance must be
- * created for each document.</p>
- */
-class Semantics {
-
-/**
- * This is the parsed xml document (Containing UTDML). It is available
- * to other classes in this package.
- */
-Document workingDocument;
-
-/**
- * Root element of workingDocument
- */
-private Element rootElement;
-private String rootName;
-
-Styles st;
-Actions act;
-Semantics() {
-workingDocument = null;
-semanticsList = null;
-st = new Styles(this);
-act = new Actions (this);
-}
-
-/**
- * Make the BrailleBlaster document model. The document is parsed and
- * then the makeSemanticsList method is called to build the
- * semanticsList. fileName is the complete path of an xml file
- * containing UTDML. This file is produced by calling the translateFile
- * method in liblouisutdml with "formatFor utd". It will probably be a
- * temporary file.
- * @param fileName: The complete path to a file in which UTDML has been
- * added to the original xml document.
- */
-boolean makeSemantics (String fileName) throws Exception {
-  if (workingDocument != null) {
-  throw new Exception ("Attempt to reuse instance");
-  }
-  File file = new File (fileName);
-Builder parser = new Builder();
-try {
-workingDocument = parser.build (file);
-} catch (ParsingException e) {
-new Notify("Problem processing " + fileName + " See stack trace.");
-e.printStackTrace();
-return false;
-} catch (IOException e) {
-new Notify ("Problem processing " + fileName + " See stack trace.");
-e.printStackTrace();
-return false;
-}
-  rootElement = workingDocument.getRootElement();
-  makeSemanticsTable();
-  if (errorCount > 0) {
-  new Notify (errorMessages + errorCount + " errors found. stop.");
-  errorMessages = null;
-  return false;
-  }
-  if (!haveSemanticFile) {
-  newEntries = true;
-  }
-  makeSemanticsList();
-  outputNewEntries();
-  return true;
-}
-
-/**
- * This is an entry in the SemanticsTable, which is used to control
- * displaying and editing.
- */
-class SemanticEntry {
-  String markup;
-  String operation;
-  String operand;
-  String parameters;
-  Actions.Action action;
-  Styles.StyleType style;
-  String macro;
-
-SemanticEntry (String markup, String operation) {
-this.markup = markup;
-this.operation = operation;
-}
-
-void setOperand (String operand) {
-this.operand = operand;
-}
-
-void setParameters (String parameters) {
-this.parameters = parameters;
-}
-
-void setMacro (String macro) {
-this.macro = macro;
-}
-
-void setStyle (Styles.StyleType style) {
-this.style = style;
-}
-
-void setAction (String action) {
-this.action = Actions.Action.valueOf(action);
-}
-
-}
-
-/**
- * The semantic table. The semantic-action file for the type of document
- * being processed is read and each line is used to create an entry in
- * this table.
- */
-ArrayList<SemanticEntry> semanticsTable = new
-     ArrayList<SemanticEntry>();
-int semanticsCount = 0; // Number of entries in semanticsTable
-SemanticEntry getSemanticEntry (int index) {
-return semanticsTable.get (index);
-}
-
-/**
- * The semanticsLookup hash table has literal markup  in the
- * semanticsTable as keys and the index of entries in the samanticsTable
- * as values.
- */
-HashMap<String, Integer> semanticsLookup = new
-  HashMap<String, Integer>();
-
-private LocaleHandler lh = new LocaleHandler();
-private boolean internetAccessRequired;
-private boolean haveSemanticFile = true;
-private boolean newEntries;
-
-/**
- * Handle the namespaces entries in a semantic-action file. These are
- * needed for evaluating XPath expressions.
- */
-private void handleNamespaces (String nm) {
-}
-
-private int errorCount = 0;
-private String errorMessages = "";
-
-/**
- * Handle error messages.
- * @Param: fileName, name of semantic file.
- *  @lineNumber, line on which the error occurred.
- *   @message, error message.
- */
-private void recordError (String fileName, int lineNumber, String
-message) {
-errorCount++;
-errorMessages = errorMessages + "error: " + fileName + ":" + lineNumber
-+ ": " +
-message + "\n";
-}
-
-private FileUtils fu = new FileUtils();
-private String fileSep = BBIni.getFileSep();
-
-/**
- * Compile a semantic-action file. If an include statement is
- * encountered this method calls itself recursively.
- * @Param: filename.
- */
-private boolean compileFile (String fileName) {
-  String completePath = fu.findInProgramData ("semantics" + fileSep +
-  fileName);
-if (completePath == null) {
-  haveSemanticFile = false;
-  recordError (fileName, 0, "not found");
-  return false;
-  }
-  FileInputStream semFile  = null;
-  BufferedReader br;
-  try {
-  semFile = new FileInputStream (completePath);
-  } catch (FileNotFoundException e) {
-  /* This should not happen, because findInProgramData has already
-  * checked*/
-  }
-  String line;
-  int lineNumber = 0;
-  br = new BufferedReader(new InputStreamReader(semFile));
-  try {
-  while ((line = br.readLine()) != null) {
-   lineNumber++;
-   String[] parts = line.trim().split ("\\s+", 6);
-  if (parts[0].charAt(0) == '#') {
-  continue; //comment
-  }
-  if (parts.length < 2) {
-  recordError (fileName, lineNumber,
-  "at least markup and an operation are required");
-  continue;
-  }
-  if (parts[0].equalsIgnoreCase ("include")) {
-  compileFile (parts[1]);
-  continue;
-  }
-  if (parts[0].equalsIgnoreCase ("newEntries")) {
-  if (parts[1].equalsIgnoreCase ("yes")) {
-  newEntries = true;
-  } else if (parts[1].equalsIgnoreCase ("no")) {
-  newEntries = false;
-  } else {
-  recordError (fileName, lineNumber, "'yes' or 'no' is required.");
-  }
-  continue;
-  }
-  if (parts[0].equalsIgnoreCase ("internetAccessRequired")) {
-  if (parts[1].equalsIgnoreCase ("yes")) {
-  internetAccessRequired = true;
-  } else if (parts[1].equalsIgnoreCase ("no")) {
-  internetAccessRequired = false;
-  } else {
-  recordError (fileName, lineNumber, "'yes' or 'no' is required.");
-  }
-  continue;
-  }
-  SemanticEntry se = new SemanticEntry (parts[0], parts[1]);
-  if (parts.length > 2) {
-  se.setOperand (parts[2]);
-  }
-  if (parts.length > 3) {
-  se.setParameters (parts[3]);
-  }
-  if (se.markup.equalsIgnoreCase (rootName)) {
-  recordError (fileName, lineNumber,
-  "the root element may not be used as markup");
-  continue;
-  }
-  if (!(se.operation.equalsIgnoreCase ("style") ||
-  se.operation.equalsIgnoreCase ("action") || se.operation.equalsIgnoreCase
-  ("macro"))) {
-  recordError (fileName, lineNumber,
-  "There is no semantic operation called "
- + se.operation);
-  continue;
-  }
-  if (se.operation.equalsIgnoreCase ("style")
-  && fu.findInProgramData ("styles" + fileSep +
-  se.operand
-  + ".properties") == null) {
-  recordError (fileName, lineNumber,
-  "There is no style called " + se.operand);
-  continue;
-  }
-  if (se.operation.equalsIgnoreCase ("action") &&
-  !act.exists (se.operand)) {
-  recordError (fileName, lineNumber,
-  "There is no action called " + se.operand);
-  continue;
-  }
-  semanticsTable.add (se);
-  semanticsLookup.put (se.markup, semanticsCount);
-  semanticsCount++;
-  }
-  } catch (IOException e) {
-  new Notify ("Problem reading " + completePath);
-  return false;
-  }
-  try {
-  semFile.close();
-  } catch (IOException e) {
-  return false;
-  }
-  return true;
-}
-
-/**
- * This method takes the root element of workingDocument and
- * concatenates with the path to the semantics directory, and add the
- * ".sem" suffix. The resulting string is then passed to compileFile,
- * which constructs the semanticsTable and the lookupSemantics hasTable.
- */
-private void makeSemanticsTable() {
-  internetAccessRequired = false;
-  newEntries = false;
-  rootName = rootElement.getLocalName();
-  String fileName = rootName + ".bbs";
-  compileFile (fileName);
-}
-
-/**
- * Given the name of a style, find its markup in the semanticsTable. The
- * search is linear. Since there may be more than one set of markup for
- * a style, the semantic-action file must be arranged so that the preferred
- * markup is nearest the beginning.
- */
-String findStyleMarkup (String styleName) {
-  for (int i = 0; i < semanticsCount; i++) {
-  SemanticEntry se = semanticsTable.get(i);
-  if (se.operation.equalsIgnoreCase ("style") &&
-  se.operand.equalsIgnoreCase (styleName))
-  return se.markup;
-  }
-  return null;
-}
-
-/**
- * Given the name of an actgion, find its markup in the semanticsTable.
- * The search is linear. Since there may be more than one set of markup for
- * an action, the semantic-action file must be arranged so that the
- * preferred markup is nearest the beginning.
- */
-String findActionMarkup (String actionName) {
-  for (int i = 0; i < semanticsCount; i++) {
-  SemanticEntry se = semanticsTable.get(i);
-  if (se.operation.equalsIgnoreCase ("action") &&
-  se.operand.equalsIgnoreCase (actionName))
-  return se.markup;
-  }
-  return null;
-}
-
-/**
- * ArrayList for keeping a record of markup not in the semantic-actions
- * file
- */
-private ArrayList<String> newMarkup = new ArrayList<String>();
-
-/**
- * if newEntries = true make a record of any markup that is not listed
- * in the semanticsTable. This information will later be used to make a
- * file containing this
- * information.
- */
-private void recordNewEntries (String markup) {
-if (newEntries) {
-newMarkup.add (markup);
-}
-}
-
-/**
- * If any new entries have been recorded, output them to a file in the
- * user's semantics directory. First sort them so that element names
- * come first, then element,attribute pairs, then
- * element,attribute,attribute,balue triplets.
- */
-private void outputNewEntries() {
-  if (newMarkup.size() == 0) return;
-}
-
-/**
- * This embedded class contains the semantic information for elements
- * whose markup is in the SemanticsTable.
- */
-class ElementSemantics {
-Element element;
-int semanticsIndex;
-int start; // start of text in StyledText.
-int end;
-int depth;
-
-ElementSemantics (Element element, int semanticsIndex) {
-this.element = element;
-this.semanticsIndex = semanticsIndex;
-}
-
-void setStart (int start) {
-this.start = start;
-}
-
-void setEnc (int end) {
-this.end = end;
-}
-
-void setDepth (int depth) {
-this.depth = depth;
-}
-
-}
-
-/**
- * Storage for semantic information.
- */
-ArrayList<ElementSemantics> semanticsList;
-
-/**
- * Make the starting SemanticsList immediately after the document has
- * been parsed and the semanticsTable built.
- */
-private void makeSemanticsList() {
-semanticsList = new ArrayList<ElementSemantics>(1000);
-doXPathExpressions();
-findSemantics (rootElement, -1);
-}
-
-/**
- * Evaluate any Xpath expressions that the semanticsTable may contain
- * and record their nodesets together with the index on the semanticsTable
- * where the XPath expression occurred.
- */
-private void doXPathExpressions() {
-}
-
- /**
- * Walk through the parse tree, depth-first, and add elements with
- * semannticsTable markup to semanticsList.
- */
-private void findSemantics (Node node, int depth) {
-Node newNode;
-Element element;
-String elementName;
-for (int i = 0; i < node.getChildCount(); i++) {
-newNode = node.getChild(i);
-if (!(newNode instanceof Element)) {
-continue;
-}
-element = (Element)newNode;
-int semanticsIndex = hasSemantics(element);
-if (semanticsIndex != -1) {
-SemanticEntry semEnt = semanticsTable.get (semanticsIndex);
-if (semEnt.operation.equalsIgnoreCase ("action") &&
-semEnt.operand.equalsIgnoreCase ("skip")) {
-continue;
-}
-ElementSemantics elementEntry = new ElementSemantics(element,
-semanticsIndex);
-elementEntry.setDepth (depth);
-semanticsList.add (elementEntry);
-}
-elementName = element.getLocalName();
-if (!(elementName.equalsIgnoreCase("brl")
-|| elementName.equalsIgnoreCase("math"))) {
-findSemantics (element, depth++);
-}
-}
-}
-
-/**
- * See if the semanticsTable contains markup for this element,its
- * attributes, and or its attribute values. If so return the index of
- * the entry in the semanticsTable
- * @param element, the element to check
- * @return int the index of the markup in the semanticsTable.
- */
-private int hasSemantics (Element element) {
-  String elementName = element.getLocalName();
-  Attribute attr;
-  String attrName;
-  String attrValue;
-  String key;
-  Integer semanticsTableIndex;
-  int numAttr = element.getAttributeCount();
-  for (int i = 0; i < numAttr; i++) {
-  attr = element.getAttribute(i);
-  attrName = attr.getLocalName();
-  attrValue = attr.getValue();
-  key = elementName + "," + attrName + "," + attrValue;
-  semanticsTableIndex = semanticsLookup.get (key);
-  if (semanticsTableIndex != null) {
-  return semanticsTableIndex.intValue();
-  }
-  else if (newEntries) {
-  recordNewEntries (key);
-  }
-  key = elementName + "," + attrName;
-  semanticsTableIndex = semanticsLookup.get (key);
-  if (semanticsTableIndex != null) {
-  return semanticsTableIndex.intValue();
-  }
-  else if (newEntries) {
-  recordNewEntries (key);
-  }
-  }
-  semanticsTableIndex = semanticsLookup.get (elementName);
-  if (semanticsTableIndex != null) {
-  return semanticsTableIndex.intValue();
-  }
-  else if (newEntries) {
-  recordNewEntries (elementName);
-  }
-  return -1;
-}
-
-/**
- * Revise the semanticsList after an edit.
- * @param startPos: the position at whichh to begin the revision.
- */
-void wReviseSemanticList (int startPos) {
-}
-
-/**
- * Return a nodeset.
- * @param node beginning node
- * @param xpathExpr an XPath expression
- */
-Nodes getNodes (Node node, String xpathExpr) {
-if (node == null) {
-return rootElement.query (xpathExpr);
-} else {
-return node.query (xpathExpr);
-}
-}
-
-/**
- * Save the file with utd markup so that work can be resumed at a later
- * time.
- * @Param fileName: The complete path of the file to which the document
- * is to be saved.
- */
-void saveWorkingFile (String fileName) {
-  FileOutputStream writer = null;
-  try {
-writer = new FileOutputStream(fileName);
-} catch (FileNotFoundException e) {
-new Notify(lh.localValue("cannotOpenFileW") + " " + fileName);
-return;
-}
-Serializer outputDoc = new Serializer(writer);
-try {
-outputDoc.write(workingDocument);
-outputDoc.flush();
-} catch (IOException e) {
-new Notify(lh.localValue("cannotWriteFile"));
-return;
-}
-}
-
-/**
- * Enhance the original document by moving any edited Braille into the
- * original document Remove the <brl> subtrees and the meta,name,utd
- * element.
- * @param fileName: The complete path of the file to which the document
- * is to be saved.
- */
-void saveEnhancedDocument(String fileName) {
-Node node;
-Nodes nodes;
-nodes = rootElement.query ("//meta[@name='brl']");
-node = nodes.get(0);
-node.detach();
-nodes = rootElement.query ("//brl");
-for (int i = 0; i < nodes.size(); i++) {
-node = nodes.get(i);
-node.detach();
-}
-nodes = null;
-saveWorkingFile (fileName);
-}
-
-}
-
=======================================
--- /src/main/org/brailleblaster/document/Styles.java Tue Apr 15 14:34:57 2014 UTC
+++ /dev/null
@@ -1,279 +0,0 @@
-/* BrailleBlaster Braille Transcription Application
-  *
-  * Copyright (C) 2014
-* American Printing House for the Blind, Inc. www.aph.org
-* and
-  * ViewPlus Technologies, Inc. www.viewplus.com
-  * and
-  * Abilitiessoft, Inc. www.abilitiessoft.com
-  * and
-  * American Printing House for the Blind, Inc. www.aph.org www.aph.org
-  *
-  * All rights reserved
-  *
-  * This file may contain code borrowed from files produced by various
-  * Java development teams. These are gratefully acknowledged.
-  *
-  * This file is free software; you can redistribute it and/or modify it
-  * under the terms of the Apache 2.0 License, as given at
-  * http://www.apache.org/licenses/
-  *
-  * This file is distributed in the hope that it will be useful, but
-  * WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
-  * See the Apache 2.0 License for more details.
-  *
-  * You should have received a copy of the Apache 2.0 License along with
-  * this program; see the file LICENSE.
-  * If not, see
-  * http://www.apache.org/licenses/
-  *
-  * Maintained by Keith Creasy <kcreasy@xxxxxxx>, Project Manager
-*/
-
-package org.brailleblaster.document;
-
-import java.util.Properties;
-import java.util.Hashtable;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import nu.xom.Element;
-import org.brailleblaster.BBIni;
-import org.brailleblaster.util.FileUtils;
-import org.brailleblaster.util.Notify;
-import java.io.IOException;
-import java.io.FileNotFoundException;
-
-
-/**
- * This class contains the data structures and mothods used for handling
- * styles.
- * <p>Styles are used in the print window only. The Braille window will
- * already have been
- * formatted by liblouisutdml. The rationale behind the use of styles is
- * that if the print window looks good visually and the correct markup
- * is used in the document, the Braille will also be formatted
- * correctly.</p>
- * <p>Note that BrailleBlaster styles deal with layout. Italic, bold,
- * etc. are dealt with by action methods in the Actions class.</p>
- */
-class Styles {
-Semantics sm;
-Styles (final Semantics sm) {
-this.sm = sm;
-makeStyleTable();
-}
-
-FileUtils fu = new FileUtils();
-String fileSep = BBIni.getFileSep();
-
-  /**
-    * Reserved styles are defined by the developers. If the user
-    * redefines them the changed styles go in her/his directories.
-    */
-String[] reservedStyles = {
-  "document",
-  "para",
-  "heading1",
-  "heading2",
-  "heading3",
-  "heading4",
-  "contentsHeader",
-  "contents1",
-  "contents2",
-  "contents3",
-  "contents4",
-  };
-
-/**
- * The different formats that can be applied to styles.
- */
-enum StyleFormat {
-  inherit,
-  leftJustified,
-  rightJustified,
-  centered,
-  alignColumnsLeft,
-  alignColumnsRight,
-  listColumns,
-  listLines,
-  computerCoded,
-  contents
-};
-
-/**
- * The status items mark the various stages in the processing of a
- * style.
- */
-enum StyleStatus {
-  error,
-  beforeBody,
-  startBody,
-  resumeBody,
-  bodyInterrupted,
-  afterBody,
-};
-
-/**
-  * This embedded class defines the various fields that specify a style.
-  */
-class StyleType {
-  String name = "";
-  int linesBefore = 0;
-  int linesAfter = 0;
-  int leftMargin = 0;
-  int rightMargin= 0;
-  int firstLineIndent = 0;
-  StyleFormat format = StyleFormat.leftJustified;
-}
-
-private Hashtable<String, StyleType> stuleTable = new Hashtable<String,
-StyleType>();
-void makeStyleTable() {
-}
-
-/**
- * This method writes the style as a properties file on
- * userProgramDataPath/styles.
- */
-void writeStyle (StyleType st) {
-  String fileName = BBIni.getUserProgramDataPath() +
-  fileSep + "styles" + fileSep + st.name + ".properties";
-  fu.create (fileName);
-Properties prop = new Properties();
-try {
-prop.load(new FileInputStream(fileName));
-} catch (FileNotFoundException e) {
-new Notify(e.getMessage());
-return;
-} catch (IOException e) {
-new Notify(e.getMessage());
-return;
-}
-  prop.setProperty ("name", st.name);
-  prop.setProperty ("linesBeforee", Integer.toString (st.linesBefore));
-  prop.setProperty ("linesAfter", Integer.toString (st.linesAfter));
-  prop.setProperty ("leftMargin", Integer.toString (st.leftMargin));
-  prop.setProperty ("rightMargin", Integer.toString (st.rightMargin));
-  prop.setProperty ("firstLineIndent",
-  Integer.toString (st.firstLineIndent));
-  prop.setProperty ("format", st.format.toString());
-try {
-prop.store(new FileOutputStream (fileName), null);
-} catch (FileNotFoundException e) {
-new Notify(e.getMessage());
-} catch (IOException e) {
-new Notify(e.getMessage());
-}
-}
-
-/**
- * Read a style from a properties file in programData and create a new
- * instance of StyleType with all fields initialized from the file.
- */
-StyleType readStyle (String styleName) {
-  String fileName = fu.findInProgramData ("styles" + fileSep +
-  styleName
-  + ".properties");
-Properties prop = new Properties();
-try {
-prop.load(new FileInputStream(fileName));
-} catch (FileNotFoundException e) {
-new Notify ("There is no style named " + styleName);
-return null;
-} catch (IOException e) {
-new Notify(e.getMessage());
-return null;
-}
-  StyleType st = new StyleType();
-  st.name = prop.getProperty ("name");
-   st.linesBefore = Integer.parseInt (prop.getProperty ("linesBefore"));
-  st.linesAfter = Integer.parseInt (prop.getProperty ("linesAfter"));
-  st.leftMargin = Integer.parseInt (prop.getProperty ("leftMargin"));
-  st.rightMargin = Integer.parseInt (prop.getProperty ("rightMargin"));
-  st.firstLineIndent = Integer.parseInt (prop.getProperty
-  ("firstLineIndent"));
-  st.format = StyleFormat.valueOf (prop.getProperty ("format"));
-  return st;
-}
-
-/**
- * Edit a StyleType. This is done in a dialog box.
- */
-void editStyle (StyleType st) {
-}
-
-/**
- * An item on the style stack, which is used to handle nested styles. It
- * is an fifo stack.
- */
-private class StyleRecord {
-  StyleType style;
-  StyleStatus status;
-  int depth;
-  StyleFormat curStyleFormat;
-  Element curElement;
-  int curLeftMargin;
-  int curRightMargin;
-  int curFirstLineIndent;
-}
-
-/**
- * Index of the top item on the style stack.
- */
-private int styleTop = -1;
-
-/**
- * The stack array is managed as a fifo stack to handle nested styles.
- * For example, we might push a table style onto the stack in the startStyle
- * method. Each row would then be pushed onto the stack by StartStyle
- * and removed by endStyle. When the last row has been processed, the top of
- * the stack will contain the table style, which is then completed by
- * endStyle.
- */
-private StyleRecord[] stack = new StyleRecord[20];
-
-/**
- * Display a set of radio buttons with style names. Teturn the name of
- * the selected style.
- */
-String pickStyle () {
-return null;
-}
-
-/**
- * Begins the processing of a style and places a strylRecord on the top
- * of the stack. If the element does not have a style it returns false.
- */
-boolean startStyle (Semantics.ElementSemantics es) {
-  Semantics.SemanticEntry se = sm.getSemanticEntry
-  (es.semanticsIndex);
-  if (!se.operation.equals ("style")) {
-  return false;
-  }
-  styleTop++;
-  StyleRecord sr = stack[styleTop];
-  sr.depth = es.depth;
-
-  return true;
-}
-
-/**
- * Completes the processing of the styleRecord on the top of the w
- stack
- * and pops it.
- */
-void endStyle () {
-}
-
-/**
- * During editing this method is called to add a new style element to
- * the parse tree at the current location. The element may be the root of a
- * subtree. For example, its children may be emphasized or MathML
- * expressions or images.
- */
-void applyStyle (Element element) {
-}
-
-}
-
=======================================
--- /src/main/org/brailleblaster/wordprocessor/UTD.java Tue Apr 15 14:34:57 2014 UTC
+++ /dev/null
@@ -1,478 +0,0 @@
-/* BrailleBlaster Braille Transcription Application
-  *
-  * Copyright (C) 2014
-* American Printing House for the Blind, Inc. www.aph.org
-* and
-  * ViewPlus Technologies, Inc. www.viewplus.com
-  * and
-  * Abilitiessoft, Inc. www.abilitiessoft.com
-  * and
-  * American Printing House for the Blind, Inc. www.aph.org www.aph.org
-  *
-  * All rights reserved
-  *
-  * This file may contain code borrowed from files produced by various
-  * Java development teams. These are gratefully acknowledged.
-  *
-  * This file is free software; you can redistribute it and/or modify it
-  * under the terms of the Apache 2.0 License, as given at
-  * http://www.apache.org/licenses/
-  *
-  * This file is distributed in the hope that it will be useful, but
-  * WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
-  * See the Apache 2.0 License for more details.
-  *
-  * You should have received a copy of the Apache 2.0 License along with
-  * this program; see the file LICENSE.
-  * If not, see
-  * http://www.apache.org/licenses/
-  *
-  * Maintained by Keith Creasy <kcreasy@xxxxxxx>, Project Manager
-*/
-
-package org.brailleblaster.wordprocessor;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import nu.xom.Builder;
-import nu.xom.Document;
-import nu.xom.Element;
-import nu.xom.Node;
-import nu.xom.ParsingException;
-import nu.xom.Text;
-
-import org.brailleblaster.perspectives.braille.Manager;
-import org.brailleblaster.util.Notify;
-import org.brailleblaster.BBIni;
-
-/**
- * This class encapsulates handling of the Universal
- * TactileDocument Markup Language (UTDML);
- */
-class UTD {
-
-    int braillePageNumber; //number of braille pages
-    String firstTableName;
-    int dpi; // resolution
-    int paperWidth;
-    int paperHeight;
-    int leftMargin;
-    int rightMargin;
-    int topMargin;
-    int bottomMargin;
-    String currentBraillePageNumber;
-    String currentPrintPageNumber;
-    int[] brlIndex;
-    int brlIndexPos;
-    int[] brlonlyIndex;
-    int brlonlyIndexPos;
-    Node beforeBrlNode;
-    Node beforeBrlonlyNode;
-    private boolean firstPage;
-    private boolean firstLineOnPage;
-    StringBuilder brailleLine = new StringBuilder (1024);
-//  StringBuilder printLine = new StringBuilder (1024);
-    Manager dm;
-    Document doc;
-    boolean utdFound = false;  // FO
-    boolean firstTime;
-    //for threading
-    int numLines;
-    int numPages;
-    int numChars;
-    int bvLineCount;
-    BufferedWriter bufferedWriter = null;
-    static Logger logger;
-
-    UTD (final Manager dm) {
-        this.dm = dm;
-        logger = BBIni.getLogger();
-    }
-
-
- void displayTranslatedFile(String utdFileName, String brailleFileName) {
-        beforeBrlNode = null;
-        beforeBrlonlyNode = null;
-        brlIndex = null;
-        brlIndexPos = 0;
-        brlonlyIndex = null;
-        brlonlyIndexPos = 0;
-        firstPage = true;
-        firstLineOnPage = true;
-        braillePageNumber = 0; //number of braille pages
-        firstTableName = null;
-        dpi = 0; // resolution
-        paperWidth = 0;
-        paperHeight = 0;
-        leftMargin = 0;
-        rightMargin = 0;
-        topMargin = 0;
-        bottomMargin = 0;
-        currentBraillePageNumber = "0";
-        currentPrintPageNumber = "0";
-
-        Builder parser = new Builder();
-        try {
-            doc = parser.build (new File(utdFileName));
-        } catch (ParsingException e) {
-               logger.log(Level.SEVERE, "Malformed document: " + utdFileName);
-            new Notify ("Malformed document");
-            return;
-        }
-        catch (IOException e) {
-// System.out.println("Could not open"+ utdFileName +" because" + e.getMessage()); - logger.log(Level.SEVERE, "Could not open"+ utdFileName +" because" + e.getMessage());
-            new Notify ("Could not open " + utdFileName);
-            return;
-        }
-        final Element rootElement = doc.getRootElement();
-
-
-        try {
-            //Construct the BufferedWriter object
- bufferedWriter = new BufferedWriter(new FileWriter(brailleFileName));
-
-        } catch (FileNotFoundException ex) {
-            ex.printStackTrace();
-        } catch (IOException ex) {
-            ex.printStackTrace();
-        }
-
-
-        //Use threading to keep the control of the window
-
-//        new Thread() {
-//            public void run() {
-              findBrlNodes (rootElement);
-//            }
-//        }
-//        .start();
-           try {
-                  if (bufferedWriter != null) {
-                      bufferedWriter.flush();
-                      bufferedWriter.close();
-                  }
-              } catch (IOException ex) {
-                  ex.printStackTrace();
-           }
-    }
-
-    private void findBrlNodes (Element node) {
-        Node newNode;
-        Element element;
-        String elementName = null;
-        firstTime = true;      // FO
-        for (int i = 0; (i < node.getChildCount()); i++) {
-            newNode = node.getChild(i);
-            if (newNode instanceof Element) {
-                element = (Element)newNode;
-                elementName = element.getLocalName();
-                if (elementName.contentEquals("head")) {
-                       Element utdElement = findUtdMeta(element);
-                       doUtdMeta (utdElement);   // found it
-
-                } else if (elementName.contentEquals("brl")) {
-                    if (i > 0) {
-                        try{
-                            beforeBrlNode = newNode.getChild(i - 1);
-                        }
-                        catch(IndexOutOfBoundsException e ){
- //The brl child, newNode, may not have any grandchild of node - System.err.println("findBrlNodes: a brl Node does not have child, i = "+i );
-                            beforeBrlNode = null;
-                            return;
-                        }
-                    } else {
-                        beforeBrlNode = null;
-                    }
-                        doBrlNode (element);
-
-                } else if (elementName.contentEquals("p") ) {
-
-                       for (int j = 0; j < node.getChildCount(); j++) {
-                               // we need to dig down the element for the 
<brl> elements
-                               Node pNode = node.getChild(j);
-                               Element pElement = (Element)pNode;
-                               for (int k = 0; k < pElement.getChildCount(); 
k++) {
-                                       Node bNode = pElement.getChild(k);
-                                       if (bNode instanceof Element) {
-                                   doBrlNode((Element)bNode);
-                                       }
-                               }
-                       }
-                } else {
-                                       findBrlNodes(element);
-                }
-            }
-
-// if(brailleLine.length() > 4096 || printLine.length() > 4096 | | i == node.getChildCount()-1) { - if(brailleLine.length() > 4096 || i == node.getChildCount()-1) {
-
-               dm.getDisplay().syncExec(new Runnable() {
-                    @Override
-                                       public void run() {
-                       // FO
-                       if (firstTime) {
- dm.getBraille().view.replaceTextRange(0, dm.getBraille().view.getCharCount(),
-                                               brailleLine.toString() );
-                               firstTime = false;
-                       } else {
- dm.getBraille().view.append(brailleLine.toString() );
-                       }
-
-                       try {
-                        bufferedWriter.write(brailleLine.toString());
-                       } catch (IOException e) {
- System.err.println("findBrlNodes IOException: " + e.getMessage());
-                       }
-                       brailleLine.delete (0, brailleLine.length());
-                    }
-                 });
-
-            }
-            /** p elements have their own structure **/
-            if (!(elementName == null)) {
- if (elementName.contentEquals("p")) i = node.getChildCount() + 1;
-            }
-        }  // end for
-    }
-
-
-    private Element findUtdMeta (Element node) {
-       String elementName;
-       String attValue;
-       Element child = null;
-       Node childNode;
-
-       for (int i = 0; i < node.getChildCount(); i++) {
-               childNode = node.getChild(i);
-               if (childNode instanceof Element) {
-                       child = (Element)childNode;
-
-               elementName = child.getLocalName();
-               if (elementName.equals ("meta")) {
-               // FO
-               if (child.getAttribute ("name") == null) {
-                       continue;
-               };
-               attValue = child.getAttributeValue("name");
-               if (attValue.equals ("utd")) {
-                       utdFound = true;
-                       break;
-               }
-               }
-               }
-       }
-       return child;
-    }
-
-    private void doUtdMeta (Element node) {
-        if (braillePageNumber != 0) {
-            return;
-        }
-        String metaContent;
-        metaContent = node.getAttributeValue ("name");
-
-        if (metaContent == null ) {
-               logger.log(Level.INFO, "doUtdMeta: metaContent is null");
-               // System.err.println("doUtdMeta: metaContent is null");
-               dm.setMetaContent(false);
-               return;
-        }
-        if (!(metaContent.equals ("utd"))) {
-            return;
-        }
-
-        dm.setMetaContent(true);
-        metaContent = node.getAttributeValue ("content");
-        String[] keysValues = metaContent.split (" ", 20);
-        for (int i = 0; i < keysValues.length; i++) {
-            String keyValue[] = keysValues[i].split ("=", 2);
-            if (keyValue[0].equals ("braillePageNumber"))
-                braillePageNumber = Integer.parseInt (keyValue[1]);
-            else if (keyValue[0].equals ("firstTableName"))
-                firstTableName = keyValue[1];
-            else if (keyValue[0].equals ("dpi"))
-                dpi = Integer.parseInt (keyValue[1]);
-            else if (keyValue[0].equals ("paperWidth"))
-                paperWidth = Integer.parseInt (keyValue[1]);
-            else if (keyValue[0].equals ("paperHeight"))
-                paperHeight = Integer.parseInt (keyValue[1]);
-            else if (keyValue[0].equals ("leftMargin"))
-                leftMargin = Integer.parseInt (keyValue[1]);
-            else if (keyValue[0].equals ("rightMargin"))
-                rightMargin = Integer.parseInt (keyValue[1]);
-            else if (keyValue[0].equals ("topMargin"))
-                topMargin = Integer.parseInt (keyValue[1]);
-            else if (keyValue[0].equals ("bottomMargin"))
-                bottomMargin = Integer.parseInt (keyValue[1]);
-        }
-    }
-
-    void showLines () {
-        brailleLine.append ("\n");
-    }
-
-    void doBrlNode (Element node) {
-        String tmp = node.getAttributeValue("index");
-        String[] indices = null;
- if(tmp != null) indices = node.getAttributeValue ("index").split (" ", 20000);
-        if (indices != null) {
-            brlIndex = new int[indices.length];
-            for (int i = 0; i < indices.length; i++) {
-                brlIndex[i] = Integer.parseInt (indices[i]);
-            }
-        }
-        brlIndexPos = 0;
-        indices = null;
-        Node newNode;
-        Element element;
-        String elementName;
-        for (int i = 0; i < node.getChildCount(); i++) {
-            newNode = node.getChild(i);
-            if (newNode instanceof Element) {
-                element = (Element)newNode;
-                elementName = element.getLocalName();
-
-                if (elementName.equals ("newpage")) {
-                    //page number is updated in doNewpage
-                    doNewpage (element);
-                } else if (elementName.equals ("newline")) {
-                    numLines++;
-                    doNewline (element);
-                } else if (elementName.equals ("span")) {
-                    doSpanNode (element);
-                } else if (elementName.equals ("graphic")) {
-                    doGraphic (element);
-                }
-            }
-            else if (newNode instanceof Text) {
-                doTextNode (newNode);
-            }
-        }
-        finishBrlNode();
-        brlIndex = null;
-        brlIndexPos = 0;
-    }
-
-    private void doSpanNode (Element node) {
-        String whichSpan = node.getAttributeValue ("class");
-        if (whichSpan.equals ("brlonly")) {
-            doBrlonlyNode (node);
-        }
-        else if (whichSpan.equals ("locked")) {
-            doLockedNode (node);
-        }
-    }
-
-    private void doBrlonlyNode (Element node) {
-        Node newNode;
-        Element element;
-        String elementName;
-        for (int i = 0; i < node.getChildCount(); i++) {
-            newNode = node.getChild(i);
-            if (newNode instanceof Element) {
-                element = (Element)newNode;
-                elementName = element.getLocalName();
-                if (elementName.equals ("brl")) {
-                    insideBrlonly (node);
-                }
-            }
-            else if (newNode instanceof Text) {
-                beforeBrlonlyNode = newNode;
-            }
-        }
-    }
-
-    private void insideBrlonly (Element node) {
-        String tmp = node.getAttributeValue("index");
-        String[] indices = null;
-        if(tmp != null) indices = tmp.split (" ", 20000);
-        if (indices != null) {
-            brlonlyIndex = new int[indices.length];
-            for (int i = 0; i < indices.length; i++) {
-                brlonlyIndex[i] = Integer.parseInt (indices[i]);
-            }
-        }
-        brlonlyIndexPos = 0;
-        indices = null;
-        Node newNode;
-        Element element;
-        String elementName;
-        for (int i = 0; i < node.getChildCount(); i++) {
-            newNode = node.getChild(i);
-            if (newNode instanceof Element) {
-                element = (Element)newNode;
-                elementName = element.getLocalName();
-                if (elementName.equals ("newpage")) {
-                    doNewpage (element);
-                } else if (elementName.equals ("newline")) {
-                    doNewline (element);
-                } else if (elementName.equals ("graphic")) {
-                    doGraphic (element);
-                }
-            }
-            else if (newNode instanceof Text) {
-                doBrlonlyTextNode (newNode);
-            }
-        }
-        brlonlyIndex = null;
-        brlonlyIndexPos = 0;
-    }
-
-    private void doLockedNode (Element node) {
-    }
-
-    private void doNewpage (Element node) {
-        String pageNumber = node.getAttributeValue ("brlnumber");
-        if(pageNumber != null) {
-            currentBraillePageNumber = pageNumber;
-            numPages++;
-        }
-        pageNumber = node.getAttributeValue ("printnumber");
-        if(pageNumber!= null) currentPrintPageNumber =pageNumber;
-        //this may need to be reconsidered
-        firstLineOnPage = true;
-        if (firstPage) {
-            firstPage = false;
-            return;
-        }
-        showLines();
-    }
-
-    private void doNewline (Element node) {
-        String positions = node.getAttributeValue ("xy");
-        if (positions != null) {
-            String[] horVertPos = positions.split (",", 2);
-        }
-        if (firstLineOnPage) {
-            firstLineOnPage = false;
-            return;
-        }
-        showLines();
-    }
-
-    private void doTextNode (Node node) {
-        Text text = (Text)node;
-        brailleLine.append (text.getValue());
-    }
-
-    private void doBrlonlyTextNode (Node node) {
-        Text text = (Text)node;
-        brailleLine.append (text.getValue());
-    }
-
-    private void doGraphic (Element node) {
-    }
-
-    private void finishBrlNode() {
-        return;
-    }
-}
=======================================
--- /src/main/org/brailleblaster/perspectives/braille/Manager.java Tue Jun 10 17:06:30 2014 UTC +++ /src/main/org/brailleblaster/perspectives/braille/Manager.java Tue Jun 10 18:16:59 2014 UTC
@@ -101,7 +101,6 @@
        Control [] tabList;
        BBSemanticsTable styles;
        String documentName = null;
-       private boolean metaContent = false;
        String logFile = "Translate.log";
        String configSettings = null;
        static String recentFileName = null;
@@ -1386,14 +1385,6 @@
        private void setSimBrailleDisplayed(boolean simBrailleDisplayed) {
                this.simBrailleDisplayed = simBrailleDisplayed;
        }
-
-       public boolean isMetaContent() {
-               return metaContent;
-       }
-
-       public void setMetaContent(boolean metaContent) {
-               this.metaContent = metaContent;
-       }

        @Override
        public void restore(WPManager wp) {
@@ -1438,7 +1429,7 @@
        }

        public void setStyleTableFocus(TraverseEvent e){
-               if(this.sm.getStyleTable().isVisible()){
+               if(sm.getStyleTable().isVisible()){
                        e.doit = false;
                        sm.getStyleTable().getTable().setFocus();
                }

==============================================================================
Revision: 320616bd6dc4
Branch:   default
Author:   Brandon Roller <brandon.r.roller@xxxxxxxxx>
Date:     Thu Jul  3 16:07:57 2014 UTC
Log: Enhanced performance with large documents/Began re-designing maplist
http://code.google.com/p/brailleblaster/source/detail?r=320616bd6dc4

Added:
/src/main/org/brailleblaster/perspectives/braille/mapping/elements/AbstractMapElement.java /src/main/org/brailleblaster/perspectives/braille/mapping/elements/BrailleMapElement.java /src/main/org/brailleblaster/perspectives/braille/mapping/elements/PageMapElement.java /src/main/org/brailleblaster/perspectives/braille/mapping/elements/Range.java /src/main/org/brailleblaster/perspectives/braille/mapping/elements/SectionElement.java /src/main/org/brailleblaster/perspectives/braille/mapping/elements/TextMapElement.java
 /src/main/org/brailleblaster/perspectives/braille/mapping/maps/MapList.java
/src/main/org/brailleblaster/perspectives/braille/mapping/maps/Paginator.java /src/main/org/brailleblaster/perspectives/braille/viewInitializer/EPubInitializer.java /src/main/org/brailleblaster/perspectives/braille/viewInitializer/NimasInitializer.java /src/main/org/brailleblaster/perspectives/braille/viewInitializer/ViewFactory.java /src/main/org/brailleblaster/perspectives/braille/viewInitializer/ViewInitializer.java /src/main/org/brailleblaster/perspectives/braille/viewInitializer/WebInitializer.java
Deleted:
 /src/main/org/brailleblaster/abstractClasses/AbstractMapElement.java
/src/main/org/brailleblaster/perspectives/braille/mapping/BrailleMapElement.java
 /src/main/org/brailleblaster/perspectives/braille/mapping/MapList.java
/src/main/org/brailleblaster/perspectives/braille/mapping/PageMapElement.java
 /src/main/org/brailleblaster/perspectives/braille/mapping/Paginator.java
/src/main/org/brailleblaster/perspectives/braille/mapping/TextMapElement.java
Modified:
 /src/main/org/brailleblaster/Subcommands.java
 /src/main/org/brailleblaster/abstractClasses/AbstractView.java
 /src/main/org/brailleblaster/document/BBDocument.java
 /src/main/org/brailleblaster/perspectives/braille/Manager.java
/src/main/org/brailleblaster/perspectives/braille/document/BrailleDocument.java /src/main/org/brailleblaster/perspectives/braille/document/ElementDivider.java
 /src/main/org/brailleblaster/perspectives/braille/messages/Message.java
/src/main/org/brailleblaster/perspectives/braille/stylepanel/StyleManager.java /src/main/org/brailleblaster/perspectives/braille/stylepanel/StyleTable.java
 /src/main/org/brailleblaster/perspectives/braille/views/tree/BBTree.java
 /src/main/org/brailleblaster/perspectives/braille/views/tree/BookTree.java
 /src/main/org/brailleblaster/perspectives/braille/views/tree/XMLTree.java
 /src/main/org/brailleblaster/perspectives/braille/views/wp/BrailleView.java
 /src/main/org/brailleblaster/perspectives/braille/views/wp/TextView.java
 /src/main/org/brailleblaster/perspectives/braille/views/wp/WPView.java

=======================================
--- /dev/null
+++ /src/main/org/brailleblaster/perspectives/braille/mapping/elements/AbstractMapElement.java Thu Jul 3 16:07:57 2014 UTC
@@ -0,0 +1,32 @@
+package org.brailleblaster.perspectives.braille.mapping.elements;
+
+import nu.xom.Element;
+import nu.xom.Node;
+
+public class AbstractMapElement {
+       public int start, end;
+       public Node n;
+
+       public AbstractMapElement(int start, int end, Node n){
+               this.start = start;
+               this.end = end;
+               this.n = n;
+       }
+
+       public AbstractMapElement(Node n){
+               this.n = n;
+       }
+
+       public Element parentElement(){
+               return (Element)n.getParent();
+       }
+
+       public String value(){
+               return n.getValue();
+       }
+
+       public void setOffsets(int start, int end){
+               this.start = start;
+               this.end = end;
+       }
+}
=======================================
--- /dev/null
+++ /src/main/org/brailleblaster/perspectives/braille/mapping/elements/BrailleMapElement.java Thu Jul 3 16:07:57 2014 UTC
@@ -0,0 +1,32 @@
+package org.brailleblaster.perspectives.braille.mapping.elements;
+
+import nu.xom.Element;
+import nu.xom.Node;
+
+
+public class BrailleMapElement extends AbstractMapElement{
+       public boolean pagenum;
+
+       public BrailleMapElement(int start, int end, Node n) {
+               super(start, end, n);
+               pagenum = isPageNum(n);
+       }
+
+       public BrailleMapElement(Node n){
+               super(n);
+       }
+
+       private boolean isPageNum(Node n){
+               Element e = (Element)n.getParent().getParent();
+               if(e.getLocalName().equals("span")){
+                       Element parent = (Element)e.getParent();
+                       if(parent.getLocalName().equals("brl")){
+                               Element grandParent = 
(Element)parent.getParent();
+                               
if(!grandParent.getLocalName().equals("pagenum"))
+                                       return true;
+                       }
+               }
+
+               return false;
+       }
+}
=======================================
--- /dev/null
+++ /src/main/org/brailleblaster/perspectives/braille/mapping/elements/PageMapElement.java Thu Jul 3 16:07:57 2014 UTC
@@ -0,0 +1,35 @@
+package org.brailleblaster.perspectives.braille.mapping.elements;
+
+import nu.xom.Node;
+
+
+public class PageMapElement extends AbstractMapElement {
+
+       public int brailleStart, brailleEnd, index, listIndex;
+       public Node brailleNode;
+
+       public PageMapElement(int start, int end, Node n) {
+               super(start, end, n);
+       }
+
+       public PageMapElement(Node n, int index){
+               super(n);
+               this.index = index;
+               this.listIndex = index;
+       }
+
+       public void setBraillePage(Node n){
+               brailleNode = n;
+       }
+
+       public void setBraillePage(int brailleStart, int brailleEnd, Node n){
+               this.brailleStart = brailleStart;
+               this.brailleEnd = brailleEnd;
+               brailleNode = n;
+       }
+
+       public void setBrailleOffsets(int start, int end){
+               brailleStart = start;
+               brailleEnd = end;
+       }
+}
=======================================
--- /dev/null
+++ /src/main/org/brailleblaster/perspectives/braille/mapping/elements/Range.java Thu Jul 3 16:07:57 2014 UTC
@@ -0,0 +1,9 @@
+package org.brailleblaster.perspectives.braille.mapping.elements;
+
+public class Range {
+       public int section, start;
+       public Range(int section, int start){
+               this.section = section;
+               this.start = start;
+       }
+}
=======================================
--- /dev/null
+++ /src/main/org/brailleblaster/perspectives/braille/mapping/elements/SectionElement.java Thu Jul 3 16:07:57 2014 UTC
@@ -0,0 +1,156 @@
+package org.brailleblaster.perspectives.braille.mapping.elements;
+
+import nu.xom.Element;
+import nu.xom.Node;
+import nu.xom.Text;
+import nu.xom.Comment;
+
+import org.brailleblaster.perspectives.braille.Manager;
+import org.brailleblaster.perspectives.braille.mapping.maps.MapList;
+
+public class SectionElement {
+       Element parent;
+       MapList list;
+       boolean inView;
+       int chars;
+
+       public SectionElement(Manager m, Element e){
+               parent = e;
+               list = new MapList(m);
+               initializeViews(e, m, 0);
+               inView = false;
+       }
+
+       public SectionElement(Manager m, Element e, int index){
+               parent = e;
+               list = new MapList(m);
+               chars = 0;
+               initializeViews(e, m, index);
+               inView = false;
+       }
+
+       protected void initializeViews(Node current, Manager m, int index){
+ if(current instanceof Text && !((Element)current.getParent()).getLocalName().equals("brl") && vaildTextElement(current, current.getValue())){
+                       list.add(new TextMapElement(current));
+                       chars += list.getLast().textLength();
+               }
+
+               for(int i = index; i < current.getChildCount(); i++){
+ if(current.getChild(i) instanceof Comment && ((Comment)current.getChild(i)).getValue().contains("BBBOOKMARK")){
+                               break;
+                       }
+ else if(current.getChild(i) instanceof Element && ((Element)current.getChild(i)).getLocalName().equals("brl")){
+                               initializeBraille(m, current.getChild(i), 
list.getLast());
+                       }
+ else if(current.getChild(i) instanceof Element && ((Element)current.getChild(i)).getLocalName().equals("math")){
+                               //if math is empty skip next brl element
+                               if(validateMath((Element)current.getChild(i)))
+ initializeMathML((Element)current.getChild(i), (Element)current.getChild(i + 1));
+                               else
+                                       i++;
+                       }
+                       else {
+                               if(current.getChild(i) instanceof Element){
+                                       
if(((Element)current.getChild(i)).getLocalName().equals("pagenum")){
+                                               initializePrintPage(m, 
(Element)current.getChild(i));
+                                       }
+                                       else {
+                                               Element currentChild = 
(Element)current.getChild(i);
+                                               
m.getDocument().checkSemantics(currentChild);
+ if(!currentChild.getLocalName().equals("meta") & !currentChild.getAttributeValue("semantics").contains("skip"))
+                                                       
initializeViews(currentChild, m, 0);
+                                       }
+                               }
+                               else if(!(current.getChild(i) instanceof 
Element)) {
+                                       initializeViews(current.getChild(i), m, 
0);
+                               }
+                       }
+               }
+       }
+
+ protected void initializeBraille(Manager m, Node current, TextMapElement t){ + if(current instanceof Text && ((Element)current.getParent()).getLocalName().equals("brl")){
+                       Element grandParent = 
(Element)current.getParent().getParent();
+ if(!(grandParent.getLocalName().equals("span") && m.getDocument().checkAttributeValue(grandParent, "class", "brlonly")))
+                               list.getLast().brailleList.add(new 
BrailleMapElement(current));
+               }
+
+               for(int i = 0; i < current.getChildCount(); i++){
+                       if(current.getChild(i) instanceof Element){
+                               initializeBraille(m, current.getChild(i), t);
+                       }
+                       else {
+                               initializeBraille(m, current.getChild(i), t);
+                       }
+               }
+       }
+
+       protected void initializePrintPage(Manager m, Element page){
+               Node textNode = m.getDocument().findPrintPageNode(page);
+               if(textNode != null){
+                       list.addPrintPage(new PageMapElement(textNode, 
list.size()));
+
+                       Node brailleText = 
m.getDocument().findBraillePageNode(page);
+                       list.getLastPage().setBraillePage(brailleText);
+               }
+       }
+
+       protected void initializeMathML(Element math, Element brl){
+               list.add(new TextMapElement(math));
+       }
+
+       protected boolean validateMath(Element math){
+               int count = math.getChildCount();
+               for(int i = 0; i < count; i++){
+                       if(math.getChild(i) instanceof Text)
+                               return true;
+                       else if(math.getChild(i) instanceof Element){
+                               if(validateMath((Element)math.getChild(i)))
+                                       return true;
+                       }
+               }
+
+               return false;
+       }
+
+       protected boolean vaildTextElement(Node n , String text){
+               Element e = (Element)n.getParent();
+               int index = e.indexOf(n);
+               int length = text.length();
+
+ if(index == e.getChildCount() - 1 || !(e.getChild(index + 1) instanceof Element && ((Element)e.getChild(index + 1)).getLocalName().equals("brl")))
+                       return false;
+
+               for(int i = 0; i < length; i++){
+                       if(text.charAt(i) != '\n' && text.charAt(i) != '\t')
+                               return true;
+               }
+
+               return false;
+       }
+
+       public void setInView(boolean inView){
+               this.inView = inView;
+       }
+
+       public void resetList(){
+               inView = false;
+               list.resetList();
+       }
+
+       public boolean isVisible(){
+               return inView;
+       }
+
+       public MapList getList(){
+               return list;
+       }
+
+       public Element getParent(){
+               return parent;
+       }
+
+       public int getCharCount(){
+               return chars;
+       }
+}
=======================================
--- /dev/null
+++ /src/main/org/brailleblaster/perspectives/braille/mapping/elements/TextMapElement.java Thu Jul 3 16:07:57 2014 UTC
@@ -0,0 +1,47 @@
+package org.brailleblaster.perspectives.braille.mapping.elements;
+
+import java.util.LinkedList;
+
+import nu.xom.Element;
+import nu.xom.Node;
+
+
+public class TextMapElement extends AbstractMapElement {
+       public LinkedList<BrailleMapElement>brailleList;
+
+       public TextMapElement(int start, int end, Node n) {
+               super(start, end, n);
+               this.brailleList = new LinkedList<BrailleMapElement>();
+       }
+
+       public TextMapElement(Node n){
+               super(n);
+               this.brailleList = new LinkedList<BrailleMapElement>();
+       }
+
+       public void setNode(Node n){
+               this.n = n;
+       }
+
+       public String getText(){
+               return n.getValue();
+       }
+
+       public int textLength(){
+               return n.getValue().length();
+       }
+
+       public int brailleLength(){
+               if(brailleList.size() == 0)
+                       return -1;
+               else
+                       return brailleList.getLast().end - 
brailleList.getFirst().start;
+       }
+
+       public boolean isMathML(){
+               if(n instanceof Element)
+                       return true;
+               else
+                       return false;
+       }
+}
=======================================
--- /dev/null
+++ /src/main/org/brailleblaster/perspectives/braille/mapping/maps/MapList.java Thu Jul 3 16:07:57 2014 UTC
@@ -0,0 +1,655 @@
+/* BrailleBlaster Braille Transcription Application
+  *
+  * Copyright (C) 2014
+* American Printing House for the Blind, Inc. www.aph.org
+* and
+  * ViewPlus Technologies, Inc. www.viewplus.com
+  * and
+  * Abilitiessoft, Inc. www.abilitiessoft.com
+  * All rights reserved
+  *
+  * This file may contain code borrowed from files produced by various
+  * Java development teams. These are gratefully acknowledged.
+  *
+  * This file is free software; you can redistribute it and/or modify it
+  * under the terms of the Apache 2.0 License, as given at
+  * http://www.apache.org/licenses/
+  *
+  * This file is distributed in the hope that it will be useful, but
+  * WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
+  * See the Apache 2.0 License for more details.
+  *
+  * You should have received a copy of the Apache 2.0 License along with
+  * this program; see the file LICENSE.txt
+  * If not, see
+  * http://www.apache.org/licenses/
+  *
+  * Maintained by Keith Creasy <kcreasy@xxxxxxx>, Project Manager
+*/
+
+package org.brailleblaster.perspectives.braille.mapping.maps;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+
+import nu.xom.Element;
+import nu.xom.Node;
+import nu.xom.Text;
+
+import org.brailleblaster.perspectives.braille.Manager;
+import org.brailleblaster.perspectives.braille.document.BrailleDocument;
+import org.brailleblaster.perspectives.braille.mapping.elements.BrailleMapElement; +import org.brailleblaster.perspectives.braille.mapping.elements.PageMapElement; +import org.brailleblaster.perspectives.braille.mapping.elements.TextMapElement;
+import org.brailleblaster.perspectives.braille.messages.Message;
+import org.brailleblaster.perspectives.braille.messages.Sender;
+
+public class MapList extends LinkedList<TextMapElement>{
+       private class UpdaterThread extends Thread {
+               private int start;
+               private int end;
+               private int offset, brailleOffset;
+               MapList list;
+
+ private UpdaterThread(MapList list, int start, int end, int offset, int brailleOffset){
+                       this.list = list;
+                       this.start = start;
+                       this.end = end;
+                       this.offset = offset;
+                       this.brailleOffset = brailleOffset;
+               }
+
+               @Override
+               public void run(){
+                       for(int i = start; i < end; i++){
+                               list.get(i).start +=offset;
+                               list.get(i).end += offset;
+
+                               if(hasBraille(i)){
+                                       for(int j = 0; j < 
list.get(i).brailleList.size(); j++){
+                                               
list.get(i).brailleList.get(j).start += brailleOffset;
+                                               
list.get(i).brailleList.get(j).end += brailleOffset;
+                                       }
+                               }
+                       }
+
+               }
+       }
+
+       private static final long serialVersionUID = 1L;
+ private static final int PROCESSORS = Runtime.getRuntime().availableProcessors();
+       Manager dm;
+       private TextMapElement current;
+       private int currentIndex = -1;
+       private int prevEnd, nextStart, prevBraille, nextBraille;
+       private Paginator paginator;
+
+       public MapList(Manager dm){
+               this.dm = dm;
+               paginator = new Paginator();
+       }
+
+       public int findClosest(Message message, int low, int high){
+               int location = (Integer)message.getValue("offset");
+ int nodeIndex = getNodeIndex((TextMapElement)message.getValue("selection"));
+
+               if(location <= this.get(0).start){
+                       return 0;
+               }
+               else if(location >= this.getLast().end){
+                       return this.indexOf(this.getLast());
+               }
+
+               int mid = low  + ((high - low) / 2);
+
+               TextMapElement currentElement = this.get(mid);
+               if(location >= currentElement.start && location <= 
currentElement.end){
+ if(location == currentElement.end && location == this.get(mid + 1).start){
+                               if(checkForSpace(mid)){
+                                       return mid + 1;
+                               }
+
+                               if(mid == nodeIndex)
+                                       return mid;
+                               else if( mid + 1 == nodeIndex)
+                                       return mid + 1;
+                       }
+ else if(location == currentElement.start && location == this.get(mid - 1).end){
+                               if(checkForSpace(mid - 1)){
+                                       return mid;
+                               }
+
+                               if(nodeIndex == mid - 1)
+                                       return mid - 1;
+                               else
+                                       return mid;
+                       }
+                       else{
+                               return mid;
+                       }
+               }
+ else if(location > currentElement.end && location < this.get(mid + 1).start){
+                       if(location - currentElement.end < this.get(mid + 
1).start - location){
+                               return mid;
+                       }
+ else if(location - currentElement.end > this.get(mid + 1).start - location){
+                               return mid + 1;
+                       }
+                       else {
+                               if(mid == nodeIndex)
+                                       return mid;
+                               else if( mid + 1 == nodeIndex)
+                                       return mid + 1;
+                               else
+                                       return mid;
+                       }
+               }
+
+               if(low > high)
+                       return -1;
+               else if(location < this.get(mid).start)
+                       return findClosest(message, low, mid - 1);
+               else
+                       return findClosest(message, mid + 1, high);
+       }
+
+       private boolean checkForSpace(int index){
+               if(this.get(index).n.getValue().length() == 0)
+                       return true;
+
+ char firstChar = this.get(index).value().charAt(this.get(index).n.getValue().length() - 1);
+               String nextElementText = this.get(index + 1).value();
+               if(nextElementText.length() > 0){
+                       char nextChar =  nextElementText.charAt(0);
+                       if( firstChar == ' ' && nextChar != ' '){
+                               return true;
+                       }
+               }
+
+               return false;
+       }
+
+       public int findClosestBraille(Message message){
+               int location = (Integer)message.getValue("offset");
+ int nodeIndex = getNodeIndex((TextMapElement)message.getValue("selection"));
+
+ if(this.getFirst().brailleList.size() > 0 && location <= this.getFirst().brailleList.getFirst().start){
+                       return 0;
+               }
+ else if(this.getLast().brailleList.size() > 0 && location >= this.getLast().brailleList.getLast().end){
+                       return this.indexOf(this.getLast());
+               }
+
+               for(int i = 0; i < this.size(); i++){
+ if(this.get(i).brailleList.size() > 0 && location >= this.get(i).brailleList.getFirst().start && location <= this.get(i).brailleList.getLast().end){
+                               return i;
+                       }
+ else if(this.get(i).brailleList.size() > 0 && this.get(i + 1).brailleList.size() > 0 && location > this.get(i).brailleList.getLast().end && location < this.get(i + 1).brailleList.getFirst().start){ + if(location - this.get(i).brailleList.getLast().end > this.get(i + 1).brailleList.getFirst().start - location){
+                                       return i + 1;
+                               }
+ else if(location - this.get(i).brailleList.getLast().end < this.get(i + 1).brailleList.getFirst().start - location) {
+                                       return i;
+                               }
+                               else {
+                                       if(i == nodeIndex)
+                                               return i;
+                                       else if( i + 1 == nodeIndex)
+                                               return i + 1;
+                                       else
+                                               return i;
+                               }
+                       }
+               }
+               return 0;
+       }
+
+       public void updateOffsets(int index, Message message){
+               paginator.updateOffsets(get(index), message);
+               int offset = (Integer)message.getValue("length");
+ int total = (Integer)message.getValue("newBrailleLength") - (Integer)message.getValue("brailleLength");
+
+               this.get(index).end += offset;
+
+               UpdaterThread [] arr = new UpdaterThread[PROCESSORS];
+               int length = (this.size() - index) / PROCESSORS;
+               int start = index + 1;
+
+               for(int i = 0; i < arr.length; i++){
+                       if(i == arr.length - 1)
+                               arr[i] = new UpdaterThread(this, start, 
this.size(), offset, total);
+                       else
+ arr[i] = new UpdaterThread(this, start, start + length , offset, total);
+
+                       arr[i].start();
+                       start += length;
+               }
+
+               for (int i = 0; i < arr.length; i++) {
+                   try {
+                       arr[i].join();
+                   } catch (InterruptedException e) {
+                               e.printStackTrace();
+                       }
+               }
+       }
+
+
+ public void shiftOffsetsFromIndex(int index, int offset, int brailleOffset, int origPos){
+               paginator.shiftOffsets(origPos, offset, brailleOffset);
+               UpdaterThread [] arr = new UpdaterThread[PROCESSORS];
+               int length = (this.size() - index) / PROCESSORS;
+               int start = index;
+
+               for(int i = 0; i < arr.length; i++){
+                       if(i == arr.length - 1)
+ arr[i] = new UpdaterThread(this, start, this.size(), offset, brailleOffset);
+                       else
+ arr[i] = new UpdaterThread(this, start, start + length , offset, brailleOffset);
+
+                       arr[i].start();
+                       start += length;
+               }
+
+               for (int i = 0; i < arr.length; i++) {
+                   try {
+                               arr[i].join();
+                   } catch (InterruptedException e) {
+                               e.printStackTrace();
+                       }
+               }
+       }
+
+       public void adjustOffsets(int index, Message message){
+               if(message.contains("start")){
+                       this.get(index).start -= 
(Integer)message.getValue("start");
+                       if(this.get(index).brailleList.size() > 0){
+ this.get(index).brailleList.getFirst().start -= (Integer)message.getValue("start");
+                       }
+               }
+
+               if(message.contains("end")){
+                       this.get(index).end += (Integer)message.getValue("end");
+                       if(this.get(index).brailleList.size() > 0)
+ this.get(index).brailleList.getLast().end += (Integer)message.getValue("end");
+               }
+       }
+
+       public void checkList(){
+               if(this.currentIndex != -1){
+                       int index = this.currentIndex;
+                       int next = index + 1;
+                       int previous = index - 1;
+
+                       //if start is equal to next start, then length is zero, 
so remove
+                       if(next < this.size()){
+                               if(this.get(index).start == 
this.get(next).start){
+ Message m = Message.createRemoveNodeMessage(index, this.get(index).textLength());
+                                       System.out.println("Node 1:\t" + 
this.get(index).value());
+                                       System.out.println("Node 2:\t" + 
this.get(next).value());
+                                       dm.dispatch(m);
+                               }
+                       }
+
+ //if previous end + 1 equals next, then current is no longer between two block elements
+                       //or if current length is zero and equal to previous 
end, then delete
+                       if(previous >= 0 && next < this.size()){
+ if((this.get(previous).start + this.get(previous).textLength() + 1 == this.get(next).start && this.get(index).textLength() == 0) + || (this.get(previous).end == this.get(index).start && this.get(index).textLength() == 0)){ + Message m = Message.createRemoveNodeMessage(index, this.get(index).n.getValue().length());
+                                       System.out.println("Node 1:\t" + 
this.get(index).value());
+                                       System.out.println("Node 2:\t" + 
this.get(next).value());
+                                       dm.dispatch(m);
+                               }
+                       }
+
+                       //if last element is length zero and equals previousEnd 
then delete
+ //if document name is null, then it is a new empty document, so do not delete + if(this.size() > 0 && this.get(this.size() - 1).n.getValue().length() == 0){ + if(this.get(this.size() - 1).start == this.prevEnd || (this.get(this.size() - 1).start == 0 && dm.getDocumentName() != null)){ + Message m = Message.createRemoveNodeMessage(this.size() - 1, this.get(this.size() - 1).textLength()); + System.out.println("Node 1:\t" + this.get(this.size() - 1).textLength());
+                                       System.out.println("Node 2:\t none");
+                                       dm.dispatch(m);
+                               }
+                       }
+               }
+       }
+
+       public int getNextBrailleOffset(int index){
+               int i = index + 1;
+               while(i < this.size()){
+ if(this.get(i).brailleList.size() > 0 && this.get(i).brailleList.getFirst().start != -1)
+                               return this.get(i).brailleList.getFirst().start;
+                       i++;
+               }
+
+               i = index - 1;
+               while(i >= 0){
+ if(this.get(i).brailleList.size() > 0 && this.get(i).brailleList.getFirst().start != -1)
+                               return this.get(i).brailleList.getFirst().start;
+               }
+               return 0;
+       }
+
+       public void setCurrent(int index){
+               this.current = this.get(index);
+               this.currentIndex = index;
+
+               if(index > 0)
+                       this.prevEnd = this.get(index -1).end;
+               else
+                       this.prevEnd = -1;
+
+               if(index != this.size() - 1)
+                       this.nextStart = this.get(index + 1).start;
+               else
+                       this.nextStart = -1;
+
+               this.nextBraille = getNextBraille(index);
+               this.prevBraille = getPreviousBraille(index);
+       }
+
+       public TextMapElement getCurrent(){
+               if(this.current == null){
+                       setCurrent(0);
+                       return this.current;
+               }
+               else {
+                       return this.current;
+               }
+       }
+
+       public int getCurrentIndex(){
+               if(this.current == null && size() > 0){
+ Message message = Message.createSetCurrentMessage(null, this.getFirst().start, false);
+                       dm.dispatch(message);
+                       return this.currentIndex;
+               }
+               else if(this.size() == 0){
+                       return -1;
+               }
+               else {
+                       return this.currentIndex;
+               }
+       }
+
+       private int getCurrentBrailleEnd(){
+               if(this.current.brailleList.size() == 0)
+                       return 0;
+               else
+                       return this.current.brailleList.getLast().end;
+       }
+
+       private int getCurrentBrailleOffset(){
+               if(this.current.brailleList.size() == 0)
+                       return 0;
+               else
+                       return this.current.brailleList.getFirst().start;
+       }
+
+       private int getNextBraille(int index){
+               int localIndex = index + 1;
+
+ while(localIndex < this.size() && this.get(localIndex).brailleList.size() == 0)
+                       localIndex++;
+
+               if(localIndex < this.size())
+                       return 
this.get(localIndex).brailleList.getFirst().start;
+
+               return -1;
+       }
+
+       private int getPreviousBraille(int index){
+               int localIndex = index - 1;
+
+               while(localIndex >= 0 && 
this.get(localIndex).brailleList.size() == 0)
+                       localIndex--;
+
+               if(localIndex >= 0)
+                       return this.get(localIndex).brailleList.getLast().end;
+
+               return -1;
+       }
+
+       private ArrayList<BrailleMapElement> getPageRanges(){
+               ArrayList<BrailleMapElement> list = new 
ArrayList<BrailleMapElement>();
+               for(int i = 0; i < this.current.brailleList.size(); i++){
+                       if(this.current.brailleList.get(i).pagenum){
+                               list.add(this.current.brailleList.get(i));
+                       }
+               }
+
+               return list;
+       }
+
+       public void getCurrentNodeData(Message m){
+               if(this.current == null){
+                       int index;
+                       if(m.getValue("sender").equals(Sender.BRAILLE))
+                               index = findClosestBraille(m);
+                       else
+                               index = findClosest(m, 0, this.size() - 1);
+
+                       setCurrent(index);
+               }
+
+               m.put("start", current.start);
+               m.put("end", current.end);
+               m.put("previous", prevEnd);
+               m.put("next", nextStart);
+               m.put("brailleStart", getCurrentBrailleOffset());
+               m.put("brailleEnd", getCurrentBrailleEnd());
+               m.put("nextBrailleStart", nextBraille);
+               m.put("previousBrailleEnd", prevBraille);
+               m.put("pageRanges", getPageRanges());
+               m.put("currentElement", current);
+       }
+
+       public int getNodeIndex(TextMapElement t){
+               return this.indexOf(t);
+       }
+
+       public void incrementCurrent(Message message){
+               if(this.currentIndex < this.size() - 1 && this.currentIndex > 
-1){
+                       setCurrent(this.currentIndex + 1);
+                       getCurrentNodeData(message);
+               }
+               else if(this.currentIndex == -1 && this.size() > 0){
+                       setCurrent(0);
+                       getCurrentNodeData(message);
+               }
+               else {
+                       getCurrentNodeData(message);
+               }
+       }
+
+       public void decrementCurrent(Message message){
+               if(this.currentIndex > 0){
+                       setCurrent(this.currentIndex - 1);
+                       getCurrentNodeData(message);
+               }
+               else if(this.currentIndex == -1 && this.size() > 0){
+                       setCurrent(0);
+                       getCurrentNodeData(message);
+               }
+               else {
+                       getCurrentNodeData(message);
+               }
+       }
+
+       public boolean hasBraille(int index){
+               if(this.size() != 0 && this.get(index).brailleList.size() > 0)
+                       return true;
+               else
+                       return false;
+       }
+
+       @SuppressWarnings("unchecked")
+       public void findTextMapElements(Message message){
+               ArrayList<Text>textList = 
(ArrayList<Text>)message.getValue("nodes");
+ ArrayList<TextMapElement> itemList = (ArrayList<TextMapElement>)message.getValue("itemList");
+
+               int pos = 0;
+               for(int i = 0; i < textList.size(); i++){
+                       for(int j = pos; j < this.size(); j++){
+                               if(textList.get(i).equals(this.get(j).n)){
+                                       itemList.add(this.get(j));
+                                       pos = j + 1;
+                                       break;
+                               }
+                       }
+               }
+       }
+
+ public ArrayList<TextMapElement> findTextMapElements(int index, Element parent, boolean ignoreInlineElement){
+               ArrayList<TextMapElement>list = new ArrayList<TextMapElement>();
+               BrailleDocument doc = dm.getDocument();
+
+               int countDown = index -  1;
+               int countUp = index + 1;
+ while(countDown >= 0 && doc.getParent(this.get(countDown).n, ignoreInlineElement).equals(parent)){
+                       list.add(0, this.get(countDown));
+                       countDown--;
+               }
+
+               list.add(this.get(index));
+
+ while(countUp < this.size() && doc.getParent(this.get(countUp).n, ignoreInlineElement).equals(parent)){
+                       list.add(this.get(countUp));
+                       countUp++;
+               }
+
+               return list;
+       }
+
+ public ArrayList<Integer> findTextMapElementRange(int index, Element parent, boolean ignoreInlineElement){ + if(ignoreInlineElement && parent.getAttributeValue("semantics").contains("action")){
+                       
while(parent.getAttributeValue("semantics").contains("action"))
+                               parent = (Element)parent.getParent();
+               }
+               ArrayList<Integer>list = new ArrayList<Integer>();
+               BrailleDocument doc = dm.getDocument();
+
+               int countDown = index -  1;
+               int countUp = index + 1;
+ while(countDown >= 0 && doc.getParent(this.get(countDown).n, ignoreInlineElement).equals(parent)){
+                       list.add(0, countDown);
+                       countDown--;
+               }
+
+               list.add(index);
+
+ while(countUp < this.size() && doc.getParent(this.get(countUp).n, ignoreInlineElement).equals(parent)){
+                       list.add(countUp);
+                       countUp++;
+               }
+
+               return list;
+       }
+
+       public int findNodeIndex(Node n, int startIndex){
+               for(int i = startIndex; i < this.size(); i++){
+                       if(this.get(i).n.equals(n))
+                               return i;
+               }
+               return -1;
+       }
+
+       public void clearList(){
+               this.clear();
+               paginator.clear();
+               this.current = null;
+               currentIndex = -1;
+       }
+
+       public void resetList(){
+               int size = size();
+               for(int i = 0; i < size; i++){
+                       get(i).setOffsets(0, 0);
+                       for(int j = 0; j < get(i).brailleList.size(); j++){
+                               get(i).brailleList.get(j).setOffsets(0, 0);
+                       }
+               }
+
+               int pageCount = paginator.getSize();
+               for(int i = 0; i < pageCount; i++){
+                       paginator.getPageMapElement(i).setOffsets(0, 0);
+                       paginator.getPageMapElement(i).setBrailleOffsets(0, 0);
+ paginator.getPageMapElement(i).listIndex = paginator.getPageMapElement(i).index;
+               }
+       }
+
+       public void removePage(PageMapElement p){
+               paginator.removePage(p);
+       }
+
+       public PageMapElement getPage(int index){
+               return paginator.getPageMapElement(index);
+       }
+
+       public int getPrintPageStart(int offset){
+               return paginator.getPrintPageStart(offset);
+       }
+
+       public int getPrintPageEnd(int offset){
+               return paginator.getPrintPageEnd(offset);
+       }
+
+       public int getBraillePageStart(int offset){
+               return paginator.getBraillePageStart(offset);
+       }
+
+       public int getBraillePageEnd(int offset){
+               return paginator.getBraillePageEnd(offset);
+       }
+
+       public void addPrintPage(PageMapElement p){
+               paginator.add(p);
+       }
+
+       public void addPrintPage(int index, PageMapElement p){
+               paginator.add(index, p);
+       }
+
+       public PageMapElement getLastPage(){
+               return paginator.getLast();
+       }
+
+       public boolean inPrintPageRange(int offset){
+               return paginator.inPrintPageRange(offset);
+       }
+
+       public boolean inBraillePageRange(int offset){
+               return paginator.inBraillePageRange(offset);
+       }
+
+       public PageMapElement findPage(int offset){
+               return paginator.findPage(offset);
+       }
+
+       public PageMapElement findBraillePage(int offset){
+               return paginator.findBraillePage(offset);
+       }
+
+       public String findCurrentPrintPageValue(int offset){
+               return paginator.findCurrentPrintPageValue(offset);
+       }
+
+       public String findCurrentBraillePageValue(int offset){
+               return paginator.findCurrentBraillePageValue(offset);
+       }
+
+       public int getPageCount(){
+               return paginator.getSize();
+       }
+
+       public boolean contains(Node n){
+               for(int i = 0; i < size(); i++)
+                       if(get(i).n.equals(n))
+                               return true;
+
+               return false;
+       }
+}
=======================================
--- /dev/null
+++ /src/main/org/brailleblaster/perspectives/braille/mapping/maps/Paginator.java Thu Jul 3 16:07:57 2014 UTC
@@ -0,0 +1,231 @@
+package org.brailleblaster.perspectives.braille.mapping.maps;
+
+import java.util.LinkedList;
+
+import org.brailleblaster.perspectives.braille.mapping.elements.PageMapElement; +import org.brailleblaster.perspectives.braille.mapping.elements.TextMapElement;
+import org.brailleblaster.perspectives.braille.messages.Message;
+
+
+public class Paginator {
+       private LinkedList<PageMapElement>list;
+
+       public Paginator(){
+               list = new LinkedList<PageMapElement>();
+       }
+
+       public PageMapElement getPageMapElement(int index){
+               return list.get(index);
+       }
+
+       public PageMapElement getLast(){
+               return list.getLast();
+       }
+
+       public void add(PageMapElement p){
+               list.add(p);
+       }
+
+       public void add(int index, PageMapElement p){
+               list.add(index, p);
+       }
+
+       public boolean inPrintPageRange(int offset){
+               if(list.size() > 0 && searchList(offset, 0, list.size() - 1) != 
-1)
+                       return true;
+               else
+                       return false;
+       }
+
+       public boolean inBraillePageRange(int offset){
+               if(list.size() > 0 && searchBraille(offset, 0, list.size() - 1) 
!= -1)
+                       return true;
+               else
+                       return false;
+       }
+
+       public PageMapElement findPage(int offset){
+               int index= searchList(offset, 0, list.size());
+               if(index != -1)
+                       return list.get(index);
+               else
+                       return null;
+       }
+
+       public String findCurrentPrintPageValue(int offset){
+               if(list.size() == 0)
+                       return null;
+               else{
+                       int pos = findRange(offset, 0, list.size() - 1);
+                       String value = list.get(pos).n.getValue();
+                       return value.substring(value.lastIndexOf("-") + 1);
+               }
+       }
+
+       public String findCurrentBraillePageValue(int offset){
+               if(list.size() == 0)
+                       return null;
+               else{
+                       int pos = findBrailleRange(offset, 0, list.size() - 1);
+                       String value = list.get(pos).n.getValue();
+                       return value.substring(value.lastIndexOf("-") + 1);
+               }
+       }
+
+       private int findRange(int offset, int low, int high){
+               if(low > high)
+                       return -1;
+
+               int mid = low + (high - low) / 2;
+               PageMapElement current = list.get(mid);
+
+               if(mid == 0 && offset < current.start)
+                       return mid;
+               else if(offset < current.start && offset > list.get(mid - 
1).end)
+                       return mid;
+               else if(mid == list.size() - 1 && offset > current.end)
+                       return mid;
+               else if(offset > current.end)
+                       return findRange(offset, mid + 1, high);
+               else if(offset < current.start)
+                       return findRange(offset, low, mid - 1);
+
+               return -1;
+       }
+
+       private int findBrailleRange(int offset, int low, int high){
+               if(low > high)
+                       return -1;
+
+               int mid = low + (high - low) / 2;
+               PageMapElement current = list.get(mid);
+
+               if(mid == 0 && offset < current.brailleStart)
+                       return mid;
+ else if(offset < current.brailleStart && offset > list.get(mid - 1).brailleEnd)
+                       return mid;
+               else if(mid == list.size() - 1 && offset > current.brailleEnd)
+                       return mid;
+               else if(offset > current.brailleEnd)
+                       return findBrailleRange(offset, mid + 1, high);
+               else if(offset < current.brailleStart)
+                       return findBrailleRange(offset, low, mid - 1);
+
+               return -1;
+       }
+
+       private int searchList(int offset, int low, int high){
+               if(low > high)
+                       return -1;
+
+               int mid = low + (high - low) / 2;
+               PageMapElement current = list.get(mid);
+               if(offset >= current.start && offset <= current.end)
+                       return mid;
+               else if(offset < current.start)
+                       return searchList(offset, low, mid - 1);
+               else
+                       return searchList(offset, mid + 1, high);
+       }
+
+       public PageMapElement findBraillePage(int offset){
+               int index= searchBraille(offset, 0, list.size());
+               if(index != -1)
+                       return list.get(index);
+               else
+                       return null;
+       }
+
+       private int searchBraille(int offset, int low, int high){
+               if(low > high)
+                       return -1;
+
+               int mid = low + (high - low) / 2;
+               PageMapElement current = list.get(mid);
+               if(offset >= current.brailleStart && offset <= 
current.brailleEnd)
+                       return mid;
+               else if(offset < current.brailleStart)
+                       return searchBraille(offset, low, mid - 1);
+               else
+                       return searchBraille(offset, mid + 1, high);
+       }
+
+       public void updateOffsets(TextMapElement t, Message message){
+               int textOffset = (Integer)message.getValue("length");
+               int brailleOffset;
+               if(message.contains("newBrailleLength"))
+ brailleOffset = (Integer)message.getValue("newBrailleLength") - (Integer)message.getValue("brailleLength");
+               else
+                       brailleOffset =  (Integer)message.getValue("length");
+
+               for(int i = 0; i < list.size(); i++){
+                       if(list.get(i).start > t.end){
+                               list.get(i).start += textOffset;
+                               list.get(i).end += textOffset;
+
+                               list.get(i).brailleStart += brailleOffset;
+                               list.get(i).brailleEnd += brailleOffset;
+                       }
+               }
+       }
+
+       public void shiftOffsets(int offset, int textOffset, int brailleOffset){
+               for(int i = 0; i < list.size(); i++){
+                       if(list.get(i).start > offset){
+                               list.get(i).start += textOffset;
+                               list.get(i).end += textOffset;
+
+                               list.get(i).brailleStart += brailleOffset;
+                               list.get(i).brailleEnd += brailleOffset;
+                       }
+               }
+       }
+
+       public int getPrintPageStart(int offset){
+               PageMapElement p = findPage(offset);
+
+               if(p != null)
+                       return p.start;
+               else
+                       return -1;
+       }
+
+       public int getPrintPageEnd(int offset){
+               PageMapElement p = findPage(offset);
+
+               if(p != null)
+                       return p.end;
+               else
+                       return -1;
+       }
+
+       public int getBraillePageStart(int offset){
+               PageMapElement p = findBraillePage(offset);
+
+               if(p != null)
+                       return p.brailleStart;
+               else
+                       return -1;
+       }
+
+       public int getBraillePageEnd(int offset){
+               PageMapElement p = findBraillePage(offset);
+
+               if(p != null)
+                       return p.brailleEnd;
+               else
+                       return -1;
+       }
+
+       public void clear(){
+               list.clear();
+       }
+
+       public int getSize(){
+               return list.size();
+       }
+
+       public void removePage(PageMapElement p){
+               list.remove(p);
+       }
+}
=======================================
--- /dev/null
+++ /src/main/org/brailleblaster/perspectives/braille/viewInitializer/EPubInitializer.java Thu Jul 3 16:07:57 2014 UTC
@@ -0,0 +1,76 @@
+package org.brailleblaster.perspectives.braille.viewInitializer;
+
+import java.util.ArrayList;
+
+import nu.xom.Comment;
+import nu.xom.Element;
+
+import org.brailleblaster.perspectives.braille.Manager;
+import org.brailleblaster.perspectives.braille.document.BrailleDocument;
+import org.brailleblaster.perspectives.braille.mapping.elements.SectionElement;
+import org.brailleblaster.perspectives.braille.mapping.maps.MapList;
+import org.brailleblaster.perspectives.braille.views.tree.BBTree;
+import org.brailleblaster.perspectives.braille.views.wp.BrailleView;
+import org.brailleblaster.perspectives.braille.views.wp.TextView;
+
+public class EPubInitializer extends ViewInitializer{
+
+ public EPubInitializer(BrailleDocument doc, TextView text, BrailleView braille, BBTree tree){
+               super(doc, text, braille, tree);
+               sectionList = new ArrayList<SectionElement>();
+       }
+
+       @Override
+       protected void findSections(Manager m, Element e) {
+               int size = e.getChildCount();
+               for(int i = 0; i < size; i++){
+                       if(e.getChild(i) instanceof Comment){
+                               Comment c = (Comment)e.getChild(i);
+                               if(c.getValue().contains("BBBOOKMARK")){
+ sectionList.add(new SectionElement(m, e, e.indexOf(e.getChild(i + 1))));
+                                       i++;
+                                       if(sectionList.get(sectionList.size() - 
1).getList().size() == 0)
+                                               
sectionList.remove(sectionList.size() - 1);
+                               }
+                       }
+                       else if(e.getChild(i) instanceof Element)
+                               findSections(m, (Element)e.getChild(i));
+               }
+       }
+
+       @Override
+       public void initializeViews(Manager m) {
+               findSections(m, document.getRootElement());
+               if(sectionList.size() == 0){
+                       sectionList.add(new SectionElement(m, 
document.getRootElement()));
+                       appendToViews(sectionList.get(0).getList(), 0);
+                       sectionList.get(0).setInView(true);
+               }
+               else {
+                       int i = 0;
+ while(i < sectionList.size() && (text.view.getCharCount() < CHAR_COUNT | | i < 2)){
+                               appendToViews(sectionList.get(i).getList(), 0);
+                               sectionList.get(i).setInView(true);
+                               i++;
+                       }
+               }
+       }
+
+       @Override
+       public MapList getList(Manager m) {
+               if(sectionList.size() > 0 && sectionList.get(0).getList() != 
null)
+                       return makeList(m);
+               else
+                       return  new MapList(m);
+       }
+
+       private MapList makeList(Manager m){
+               viewList = new MapList(m);
+               for(int i = 0; i < sectionList.size(); i++){
+                       if(sectionList.get(i).isVisible())
+                               viewList.addAll(sectionList.get(i).getList());
+               }
+
+               return viewList;
+       }
+}
=======================================
--- /dev/null
+++ /src/main/org/brailleblaster/perspectives/braille/viewInitializer/NimasInitializer.java Thu Jul 3 16:07:57 2014 UTC
@@ -0,0 +1,70 @@
+package org.brailleblaster.perspectives.braille.viewInitializer;
+
+import java.util.ArrayList;
+
+import nu.xom.Element;
+import nu.xom.Elements;
+
+import org.brailleblaster.perspectives.braille.Manager;
+import org.brailleblaster.perspectives.braille.document.BrailleDocument;
+import org.brailleblaster.perspectives.braille.mapping.elements.SectionElement;
+import org.brailleblaster.perspectives.braille.mapping.maps.MapList;
+import org.brailleblaster.perspectives.braille.views.tree.BBTree;
+import org.brailleblaster.perspectives.braille.views.wp.BrailleView;
+import org.brailleblaster.perspectives.braille.views.wp.TextView;
+
+public class NimasInitializer extends ViewInitializer{
+
+ public NimasInitializer(BrailleDocument doc, TextView text, BrailleView braille, BBTree tree){
+               super(doc, text, braille, tree);
+               sectionList = new ArrayList<SectionElement>();
+       }
+
+       protected void findSections(Manager m, Element e){
+               Elements els = e.getChildElements();
+               for(int i = 0; i < els.size(); i++){
+                       if(els.get(i).getLocalName().equals("level1")){
+                               sectionList.add(new SectionElement(m, 
els.get(i)));
+                       }
+                       else
+                               findSections(m, els.get(i));
+               }
+       }
+
+       public void initializeViews(Manager m){
+               findSections(m, document.getRootElement());
+       //      if(sectionList.size() == 0)
+       //              initializeViews(document.getRootElement());
+       //      else {
+               int i = 0;
+               while(i < sectionList.size() && i < 2){
+                       appendToViews(sectionList.get(i).getList(), 0);
+                       sectionList.get(i).setInView(true);
+                       i++;
+               }
+       //      }
+       }
+
+       public MapList getList(Manager m){
+               if(sectionList.size() > 0 && sectionList.get(0).getList() != 
null)
+                       return makeList(m);
+               else
+                       return  new MapList(m);
+       }
+
+       private MapList makeList(Manager m){
+               viewList = new MapList(m);
+               for(int i = 0; i < sectionList.size(); i++){
+                       if(sectionList.get(i).isVisible()){
+                               viewList.addAll(sectionList.get(i).getList());
+                               
viewList.setCurrent(viewList.indexOf(viewList.getCurrent()));
+                               int pageCount = 
sectionList.get(i).getList().getPageCount();
+                               for(int j = 0; j < pageCount; j++){
+                                       
viewList.addPrintPage(sectionList.get(i).getList().getPage(j));
+                               }
+                       }
+               }
+
+               return viewList;
+       }
+}
=======================================
--- /dev/null
+++ /src/main/org/brailleblaster/perspectives/braille/viewInitializer/ViewFactory.java Thu Jul 3 16:07:57 2014 UTC
@@ -0,0 +1,21 @@
+package org.brailleblaster.perspectives.braille.viewInitializer;
+
+import org.brailleblaster.archiver.Archiver;
+import org.brailleblaster.archiver.EPub3Archiver;
+import org.brailleblaster.archiver.TextArchiver;
+import org.brailleblaster.archiver.WebArchiver;
+import org.brailleblaster.perspectives.braille.document.BrailleDocument;
+import org.brailleblaster.perspectives.braille.views.tree.BBTree;
+import org.brailleblaster.perspectives.braille.views.wp.BrailleView;
+import org.brailleblaster.perspectives.braille.views.wp.TextView;
+
+public class ViewFactory {
+ public static ViewInitializer createUpdater(Archiver arch, BrailleDocument doc, TextView text, BrailleView braille, BBTree tree){
+               if(arch instanceof EPub3Archiver)
+                       return new EPubInitializer(doc, text, braille, tree);
+               else if(arch instanceof WebArchiver || arch instanceof 
TextArchiver)
+                       return new WebInitializer(doc, text, braille, tree);
+               else
+                       return new NimasInitializer(doc, text, braille, tree);
+       }
+}
=======================================
--- /dev/null
+++ /src/main/org/brailleblaster/perspectives/braille/viewInitializer/ViewInitializer.java Thu Jul 3 16:07:57 2014 UTC
@@ -0,0 +1,367 @@
+package org.brailleblaster.perspectives.braille.viewInitializer;
+
+import java.util.ArrayList;
+
+import nu.xom.Element;
+
+import org.brailleblaster.perspectives.braille.Manager;
+import org.brailleblaster.perspectives.braille.document.BrailleDocument;
+import org.brailleblaster.perspectives.braille.mapping.elements.SectionElement; +import org.brailleblaster.perspectives.braille.mapping.elements.TextMapElement;
+import org.brailleblaster.perspectives.braille.mapping.maps.MapList;
+import org.brailleblaster.perspectives.braille.views.tree.BBTree;
+import org.brailleblaster.perspectives.braille.views.wp.BrailleView;
+import org.brailleblaster.perspectives.braille.views.wp.TextView;
+
+public abstract class ViewInitializer {
+       protected final int CHAR_COUNT = 5000;
+
+       BrailleDocument document;
+       TextView text;
+       BrailleView braille;
+       BBTree tree;
+       MapList viewList;
+       protected ArrayList<SectionElement>sectionList;
+
+ public ViewInitializer(BrailleDocument doc, TextView text, BrailleView braille, BBTree tree){
+               this.document = doc;
+               this.text = text;
+               this.braille = braille;
+               this.tree = tree;
+       }
+
+       protected void appendToViews(MapList list, int index){
+               int count = list.size();
+               int pageIndex = 0;
+               int pageCount = list.getPageCount();
+
+               for(int i = index; i < count; i++){
+                       if(pageIndex < pageCount){
+
+                               if(list.getPage(pageIndex).listIndex == i){
+                                       
text.addPageNumber(list.getPage(pageIndex), false);
+                                       
braille.addPageNumber(list.getPage(pageIndex), false);
+                                       pageIndex++;
+                               }
+                       }
+                       if(list.get(i).isMathML()){
+                               text.setMathML(list, list.get(i));
+                               braille.setBraille(list.get(i), list, i);
+                       }
+                       else {
+                               text.setText(list.get(i), list, i);
+                               braille.setBraille(list.get(i), list, i);
+                       }
+               }
+
+       }
+
+       protected void prependToViews(MapList list, int index){
+               int count = list.size();
+               int pageIndex = 0;
+               int pageCount = list.getPageCount();
+
+               text.view.setCaretOffset(0);
+               braille.view.setCaretOffset(0);
+
+               for(int i = index; i < count; i++){
+                       if(pageIndex < pageCount){
+                               if(list.getPage(pageIndex).listIndex == i){
+                                       
text.addPageNumber(list.getPage(pageIndex), true);
+                                       
braille.addPageNumber(list.getPage(pageIndex), true);
+                                       pageIndex++;
+                               }
+                       }
+
+                       if(list.get(i).isMathML()){
+                               text.prependMathML(list, list.get(i));
+                               braille.prependBraille(list.get(i), list, i);
+                       }
+                       else {
+                               text.prependText(list.get(i), list, i);
+                               braille.prependBraille(list.get(i), list, i);
+                       }
+
+                       text.view.setCaretOffset(text.getTotal());
+                       braille.view.setCaretOffset(braille.getTotal());
+               }
+       }
+
+       public MapList bufferBackward(){
+               if(sectionList.size() > 1){
+                       removeListeners();
+                       int caretOffset = getCursorOffset();
+
+                       int startPos = findFirst();
+                       int endPos = findLast();
+                       if(startPos != endPos && startPos != 0){
+                               TextMapElement t = viewList.getCurrent();
+                               //Remove elements
+                               
viewList.removeAll(sectionList.get(endPos).getList());
+                               //remove text from views
+
+ replaceTextRange(findEnd(sectionList.get(startPos).getList()), text.view.getCharCount() - findEnd(sectionList.get(startPos).getList()), findBrailleEnd(sectionList.get(startPos).getList()), braille.view.getCharCount() - findBrailleEnd(sectionList.get(startPos).getList()));
+                               removePages(sectionList.get(endPos).getList());
+                               sectionList.get(endPos).resetList();
+
+                               //reset page indexes for elements not removed
+                               int size = sectionList.get(startPos - 
1).getList().size();
+                               for(int j = 0; j < viewList.getPageCount(); j++)
+                                       viewList.getPage(j).listIndex += size;
+
+                               int index = startPos - 1;
+                               do{
+                                       //set start pos to insert
+                                       text.setTotal(0);
+                                       braille.setTotal(0);
+
+                                       //add elements to viewList
+                                       viewList.addAll(0, 
sectionList.get(index).getList());
+
+                                       //add Pages
+                                       int pageCount = 
sectionList.get(index).getList().getPageCount();
+                                       for(int j = 0; j < pageCount; j++)
+ viewList.addPrintPage(j, sectionList.get(index).getList().getPage(j));
+
+                                       //set in view and initialize
+                                       sectionList.get(index).setInView(true);
+                                       size = 
sectionList.get(index).getList().size();
+                                       
prependToViews(sectionList.get(index).getList(), 0);
+                                       int textTotal = text.getTotal();
+                                       int brailleTotal = braille.getTotal();
+                                       for(int i = size; i < viewList.size(); 
i++){
+                                               viewList.get(i).start += 
textTotal;
+                                               viewList.get(i).end += 
textTotal;
+                                               for(int j = 0; j < 
viewList.get(i).brailleList.size(); j++){
+                                                       
viewList.get(i).brailleList.get(j).start += brailleTotal;
+                                                       
viewList.get(i).brailleList.get(j).end += brailleTotal;
+                                               }
+                                       }
+
+                                       for(int i = pageCount; i < 
viewList.getPageCount(); i++){
+                                               viewList.getPage(i).start += 
textTotal;
+                                               viewList.getPage(i).end += 
textTotal;
+                                               
viewList.getPage(i).brailleStart += brailleTotal;
+                                               viewList.getPage(i).brailleEnd 
+= brailleTotal;
+                                       }
+                                       index --;
+                               }       while(index >= 0 && 
text.view.getCharCount() < CHAR_COUNT);
+                               setCursorOffset(t, caretOffset);
+                       }
+                       initializeListeners();
+               }
+               return viewList;
+       }
+
+       public MapList bufferForward(){
+               if(sectionList.size() > 1){
+                       removeListeners();
+                       int caretOffset = getCursorOffset();
+
+                       int startPos = findFirst();
+                       int endPos = findLast();
+                       if(startPos != endPos && endPos != sectionList.size() - 
1){
+                               TextMapElement t = viewList.getCurrent();
+                               
viewList.removeAll(sectionList.get(startPos).getList());
+                               
removePages(sectionList.get(startPos).getList());
+                               int textOffset = 
sectionList.get(startPos).getList().getLast().end;
+ int brailleOffset = sectionList.get(startPos).getList().getLast().brailleList.getLast().end;
+                               replaceTextRange(0, textOffset, 0, 
brailleOffset);
+                               sectionList.get(startPos).resetList();
+                               //int textOffset = viewList.getFirst().start;
+                               //int brailleOffset = 
viewList.getFirst().brailleList.getFirst().start;
+                               for(int i = 0; i < viewList.size(); i++){
+                                       viewList.get(i).start -= textOffset;
+                                       viewList.get(i).end -= textOffset;
+                                       for(int j = 0; j < 
viewList.get(i).brailleList.size(); j++){
+                                               
viewList.get(i).brailleList.get(j).start -= brailleOffset;
+                                               
viewList.get(i).brailleList.get(j).end -= brailleOffset;
+                                       }
+                               }
+
+                               int pageCount = viewList.getPageCount();
+                               for(int j = 0; j < pageCount; j++){
+                                       viewList.getPage(j).start -= textOffset;
+                                       viewList.getPage(j).end -= textOffset;
+                                       viewList.getPage(j).brailleStart -= 
brailleOffset;
+                                       viewList.getPage(j).brailleEnd -= 
brailleOffset;
+                               }
+
+                               int pos = endPos + 1;
+                               do {
+                                       //int index = viewList.size();
+                                       text.setTotal(text.view.getCharCount());
+                                       
braille.setTotal(braille.view.getCharCount());
+                                       
viewList.addAll(sectionList.get(pos).getList());
+                                       pageCount = 
sectionList.get(pos).getList().getPageCount();
+                                       int offset = viewList.size();
+                                       sectionList.get(pos).setInView(true);
+                                       
appendToViews(sectionList.get(pos).getList(), 0);
+                                       for(int j = 0; j < pageCount; j++){
+ sectionList.get(pos).getList().getPage(j).listIndex = offset + sectionList.get(pos).getList().getPage(j).index;
+                                               
viewList.addPrintPage(sectionList.get(pos).getList().getPage(j));
+                                       }
+                                       pos++;
+ }while(pos < sectionList.size() && text.view.getCharCount() < CHAR_COUNT);
+                               setCursorOffset(t, caretOffset);
+                       }
+                       initializeListeners();
+               }
+
+               return viewList;
+       }
+
+
+       public MapList resetViews(int firstIndex) {
+               if(sectionList.size() > 1){
+                       removeListeners();
+                       TextMapElement t = 
sectionList.get(firstIndex).getList().getFirst();
+                       if(firstIndex != 0)
+                               firstIndex--;
+
+                       int startPos = findFirst();
+                       int endPos = findLast();
+                       //if(startPos != endPos && endPos != sectionList.size() 
- 1){
+                       for(int i = startPos; i <= endPos; i++){
+                               
viewList.removeAll(sectionList.get(i).getList());
+                               sectionList.get(i).resetList();
+                               removePages(sectionList.get(i).getList());
+                       }
+
+ replaceTextRange(0, text.view.getCharCount(), 0, braille.view.getCharCount());
+                       text.setTotal(0);
+                       braille.setTotal(0);
+
+                       int i = firstIndex;
+
+                       int totalChars = 0;
+ while(i < sectionList.size() && (i < firstIndex + 2 || totalChars < CHAR_COUNT)){
+                               int offset = viewList.size();
+                               viewList.addAll(sectionList.get(i).getList());
+                               totalChars += sectionList.get(i).getCharCount();
+                               int pageCount = 
sectionList.get(i).getList().getPageCount();
+
+                               for(int j = 0; j < pageCount; j++){
+                                       if(i != firstIndex)
+ sectionList.get(i).getList().getPage(j).listIndex = offset + sectionList.get(i).getList().getPage(j).index;
+                                       else
+ sectionList.get(i).getList().getPage(j).listIndex = sectionList.get(i).getList().getPage(j).index;
+
+                                       
viewList.addPrintPage(sectionList.get(i).getList().getPage(j));
+                               }
+                               sectionList.get(i).setInView(true);
+                               i++;
+                       }
+                       appendToViews(viewList, 0);
+                       if(!viewList.getFirst().equals(t)){
+                               
text.positionScrollbar(text.view.getLineAtOffset(t.start));
+ braille.positionScrollbar(braille.view.getLineAtOffset(t.brailleList.getFirst().start));
+                       }
+                       initializeListeners();
+               }
+               //}
+
+               return viewList;
+       }
+
+ private void replaceTextRange(int textStart, int textLength, int brailleStart, int brailleLength){
+               text.view.replaceTextRange(textStart, textLength, "");
+               braille.view.replaceTextRange(brailleStart, brailleLength, "");
+       }
+
+       private int getCursorOffset(){
+               if(text.view.isFocusControl())
+                       return text.view.getCaretOffset() - 
viewList.getCurrent().start;
+               else if(braille.view.isFocusControl())
+ return braille.view.getCaretOffset() - viewList.getCurrent().brailleList.getFirst().start;
+
+               return 0;
+       }
+
+       private void setCursorOffset(TextMapElement t, int offset){
+               if(text.view.isFocusControl())
+                       text.view.setCaretOffset(t.start + offset);
+               else if(braille.view.isFocusControl())
+                       
braille.view.setCaretOffset(t.brailleList.getFirst().start + offset);
+       }
+
+       private void removeListeners(){
+               text.removeListeners();
+               braille.removeListeners();
+               tree.removeListeners();
+       }
+
+       private void initializeListeners(){
+               text.initializeListeners();
+               braille.initializeListeners();
+               tree.initializeListeners();
+       }
+
+       private int findFirst(){
+               for(int  i = 0; i < sectionList.size(); i++){
+                       if(sectionList.get(i).isVisible())
+                               return i;
+               }
+
+               return -1;
+       }
+
+       private int findLast(){
+               int position = -1;
+               for(int i = 0; i < sectionList.size(); i++){
+                       if(sectionList.get(i).isVisible())
+                               position = i;
+               }
+
+               return position;
+       }
+
+       private void removePages(MapList list){
+               int count = list.getPageCount();
+
+               for(int i = 0; i < count; i++){
+                       viewList.removePage(list.getPage(i));
+                       list.getPage(i).listIndex = list.getPage(i).index;
+               }
+       }
+
+       private int findStart(MapList list){
+ if(list.getPageCount() == 0 || list.getPage(0).start > list.getFirst().start)
+                       return list.getFirst().start;
+               else
+                       return list.getPage(0).start;
+       }
+
+       private int findEnd(MapList list){
+ if(list.getPageCount() == 0 || list.getLastPage().end < list.getLast().end)
+                       return list.getLast().end;
+               else
+                       return list.getLastPage().end;
+       }
+
+       private int findBrailleStart(MapList list){
+ if(list.getPageCount() == 0 || list.getPage(0).brailleStart > list.getFirst().brailleList.getFirst().start)
+                       return  list.getFirst().brailleList.getFirst().start;
+               else
+                       return list.getPage(0).brailleStart;
+       }
+
+       private int findBrailleEnd(MapList list){
+ if(list.getPageCount() == 0 || list.getLastPage().brailleEnd < list.getLast().brailleList.getLast().end)
+                       return list.getLast().brailleList.getLast().end;
+               else
+                       return list.getLastPage().brailleEnd;
+       }
+
+       public ArrayList<SectionElement> getSectionList() {
+               return sectionList;
+       }
+
+       public void resetTree(BBTree tree){
+               this.tree = tree;
+       }
+
+       protected abstract void findSections(Manager m, Element e);
+       public abstract void initializeViews(Manager m);
+       public abstract MapList getList(Manager m);
+}
=======================================
--- /dev/null
+++ /src/main/org/brailleblaster/perspectives/braille/viewInitializer/WebInitializer.java Thu Jul 3 16:07:57 2014 UTC
@@ -0,0 +1,101 @@
+package org.brailleblaster.perspectives.braille.viewInitializer;
+
+import java.util.ArrayList;
+
+import nu.xom.Attribute;
+import nu.xom.Element;
+import nu.xom.Elements;
+import nu.xom.Nodes;
+import nu.xom.Text;
+
+import org.brailleblaster.document.SemanticFileHandler;
+import org.brailleblaster.perspectives.braille.Manager;
+import org.brailleblaster.perspectives.braille.document.BrailleDocument;
+import org.brailleblaster.perspectives.braille.mapping.elements.SectionElement; +import org.brailleblaster.perspectives.braille.mapping.elements.TextMapElement;
+import org.brailleblaster.perspectives.braille.mapping.maps.MapList;
+import org.brailleblaster.perspectives.braille.views.tree.BBTree;
+import org.brailleblaster.perspectives.braille.views.wp.BrailleView;
+import org.brailleblaster.perspectives.braille.views.wp.TextView;
+
+public class WebInitializer extends ViewInitializer{
+
+ public WebInitializer(BrailleDocument doc, TextView text, BrailleView braille, BBTree tree) {
+               super(doc, text, braille, tree);
+               sectionList = new ArrayList<SectionElement>();
+       }
+
+       @Override
+       protected void findSections(Manager m, Element e) {
+               Elements els = e.getChildElements();
+               for(int i = 0; i < els.size(); i++){
+ if(els.get(i).getLocalName().equals("head") || els.get(i).getLocalName().equals("body")){
+                               sectionList.add(new SectionElement(m, 
els.get(i)));
+                               if(sectionList.get(sectionList.size() - 
1).getList().size() == 0)
+                                       sectionList.remove(sectionList.size() - 
1);
+                       }
+                       else
+                               findSections(m, els.get(i));
+               }
+       }
+
+       @Override
+       public void initializeViews(Manager m) {
+               findSections(m, document.getRootElement());
+               if(sectionList.size() == 0){
+                       sectionList.add(new SectionElement(m, 
document.getRootElement()));
+                       appendToViews(sectionList.get(0).getList(), 0);
+                       sectionList.get(0).setInView(true);
+                       if(sectionList.get(0).getList().size() == 0)
+                               formatTemplateDocument(m, 
sectionList.get(0).getList());
+               }
+               else {
+                       int i = 0;
+                       while(i < sectionList.size() && text.view.getCharCount() 
< CHAR_COUNT){
+                               appendToViews(sectionList.get(i).getList(), 0);
+                               sectionList.get(i).setInView(true);
+                               i++;
+                       }
+               }
+       }
+
+       @Override
+       public MapList getList(Manager m) {
+               if(sectionList.size() > 0 && sectionList.get(0).getList() != 
null)
+                       return makeList(m);
+               else
+                       return  new MapList(m);
+       }
+
+       private MapList makeList(Manager m){
+               viewList = new MapList(m);
+               for(int i = 0; i < sectionList.size(); i++){
+                       if(sectionList.get(i).isVisible()){
+                               viewList.addAll(sectionList.get(i).getList());
+                               
viewList.setCurrent(viewList.indexOf(viewList.getCurrent()));
+                       }
+               }
+
+               return viewList;
+       }
+
+       //adds or tracks a text node for a blank document when user starts
+       private void formatTemplateDocument(Manager m, MapList list){
+               Nodes n = document.query("/*[1]/*[2]");
+
+               if(n.get(0).getChildCount() > 0){
+                       if(n.get(0).getChild(0).getChildCount() == 0)
+                               ((Element)n.get(0).getChild(0)).appendChild(new 
Text(""));
+
+                       list.add(new TextMapElement(0, 0, 
n.get(0).getChild(0).getChild(0)));
+               }
+               else {
+ Element p = new Element("p", document.getRootElement().getNamespaceURI()); + SemanticFileHandler sfh = new SemanticFileHandler(m.getArchvier().getCurrentConfig()); + p.addAttribute(new Attribute("semantics","styles," + sfh.getDefault("p")));
+                       p.appendChild(new Text(""));
+                       ((Element)n.get(0)).appendChild(p);
+                       list.add(new TextMapElement(0, 0, 
n.get(0).getChild(0).getChild(0)));
+               }
+       }
+}
=======================================
--- /src/main/org/brailleblaster/abstractClasses/AbstractMapElement.java Fri Sep 6 18:16:34 2013 UTC
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.brailleblaster.abstractClasses;
-
-import nu.xom.Element;
-import nu.xom.Node;
-
-public class AbstractMapElement {
-       public int start, end;
-       public Node n;
-
-       public AbstractMapElement(int start, int end, Node n){
-               this.start = start;
-               this.end = end;
-               this.n = n;
-       }
-
-       public Element parentElement(){
-               return (Element)n.getParent();
-       }
-
-       public String value(){
-               return n.getValue();
-       }
-}
=======================================
--- /src/main/org/brailleblaster/perspectives/braille/mapping/BrailleMapElement.java Fri Oct 11 19:08:46 2013 UTC
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.brailleblaster.perspectives.braille.mapping;
-
-import nu.xom.Element;
-import nu.xom.Node;
-
-import org.brailleblaster.abstractClasses.AbstractMapElement;
-
-public class BrailleMapElement extends AbstractMapElement{
-       public boolean pagenum;
-
-       public BrailleMapElement(int start, int end, Node n) {
-               super(start, end, n);
-               pagenum = isPageNum(n);
-       }
-
-       private boolean isPageNum(Node n){
-               Element e = (Element)n.getParent().getParent();
-               if(e.getLocalName().equals("span")){
-                       Element parent = (Element)e.getParent();
-                       if(parent.getLocalName().equals("brl")){
-                               Element grandParent = 
(Element)parent.getParent();
-                               
if(!grandParent.getLocalName().equals("pagenum"))
-                                       return true;
-                       }
-               }
-
-               return false;
-       }
-}
=======================================
--- /src/main/org/brailleblaster/perspectives/braille/mapping/MapList.java Tue Jun 10 17:06:30 2014 UTC
+++ /dev/null
@@ -1,614 +0,0 @@
-/* BrailleBlaster Braille Transcription Application
-  *
-  * Copyright (C) 2014
-* American Printing House for the Blind, Inc. www.aph.org
-* and
-  * ViewPlus Technologies, Inc. www.viewplus.com
-  * and
-  * Abilitiessoft, Inc. www.abilitiessoft.com
-  * All rights reserved
-  *
-  * This file may contain code borrowed from files produced by various
-  * Java development teams. These are gratefully acknowledged.
-  *
-  * This file is free software; you can redistribute it and/or modify it
-  * under the terms of the Apache 2.0 License, as given at
-  * http://www.apache.org/licenses/
-  *
-  * This file is distributed in the hope that it will be useful, but
-  * WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
-  * See the Apache 2.0 License for more details.
-  *
-  * You should have received a copy of the Apache 2.0 License along with
-  * this program; see the file LICENSE.txt
-  * If not, see
-  * http://www.apache.org/licenses/
-  *
-  * Maintained by Keith Creasy <kcreasy@xxxxxxx>, Project Manager
-*/
-
-package org.brailleblaster.perspectives.braille.mapping;
-
-import java.util.ArrayList;
-import java.util.LinkedList;
-
-import nu.xom.Element;
-import nu.xom.Node;
-import nu.xom.Text;
-
-import org.brailleblaster.perspectives.braille.Manager;
-import org.brailleblaster.perspectives.braille.document.BrailleDocument;
-import org.brailleblaster.perspectives.braille.messages.Message;
-import org.brailleblaster.perspectives.braille.messages.Sender;
-
-public class MapList extends LinkedList<TextMapElement>{
-       private class UpdaterThread extends Thread {
-               private int start;
-               private int end;
-               private int offset, brailleOffset;
-               MapList list;
-
- private UpdaterThread(MapList list, int start, int end, int offset, int brailleOffset){
-                       this.list = list;
-                       this.start = start;
-                       this.end = end;
-                       this.offset = offset;
-                       this.brailleOffset = brailleOffset;
-               }
-
-               @Override
-               public void run(){
-                       for(int i = start; i < end; i++){
-                               list.get(i).start +=offset;
-                               list.get(i).end += offset;
-
-                               if(hasBraille(i)){
-                                       for(int j = 0; j < 
list.get(i).brailleList.size(); j++){
-                                               
list.get(i).brailleList.get(j).start += brailleOffset;
-                                               
list.get(i).brailleList.get(j).end += brailleOffset;
-                                       }
-                               }
-                       }
-
-               }
-       }
-
-       private static final long serialVersionUID = 1L;
- private static final int PROCESSORS = Runtime.getRuntime().availableProcessors();
-       Manager dm;
-       private TextMapElement current;
-       private int currentIndex = -1;
-       private int prevEnd, nextStart, prevBraille, nextBraille;
-       private Paginator paginator;
-
-       public MapList(Manager dm){
-               this.dm = dm;
-               paginator = new Paginator();
-       }
-
-       public int findClosest(Message message, int low, int high){
-               int location = (Integer)message.getValue("offset");
- int nodeIndex = getNodeIndex((TextMapElement)message.getValue("selection"));
-
-               if(location <= this.get(0).start){
-                       return 0;
-               }
-               else if(location >= this.getLast().end){
-                       return this.indexOf(this.getLast());
-               }
-
-               int mid = low  + ((high - low) / 2);
-
-               TextMapElement currentElement = this.get(mid);
-               if(location >= currentElement.start && location <= 
currentElement.end){
- if(location == currentElement.end && location == this.get(mid + 1).start){
-                               if(checkForSpace(mid)){
-                                       return mid + 1;
-                               }
-
-                               if(mid == nodeIndex)
-                                       return mid;
-                               else if( mid + 1 == nodeIndex)
-                                       return mid + 1;
-                       }
- else if(location == currentElement.start && location == this.get(mid - 1).end){
-                               if(checkForSpace(mid - 1)){
-                                       return mid;
-                               }
-
-                               if(nodeIndex == mid - 1)
-                                       return mid - 1;
-                               else
-                                       return mid;
-                       }
-                       else{
-                               return mid;
-                       }
-               }
- else if(location > currentElement.end && location < this.get(mid + 1).start){
-                       if(location - currentElement.end < this.get(mid + 
1).start - location){
-                               return mid;
-                       }
- else if(location - currentElement.end > this.get(mid + 1).start - location){
-                               return mid + 1;
-                       }
-                       else {
-                               if(mid == nodeIndex)
-                                       return mid;
-                               else if( mid + 1 == nodeIndex)
-                                       return mid + 1;
-                               else
-                                       return mid;
-                       }
-               }
-
-               if(low > high)
-                       return -1;
-               else if(location < this.get(mid).start)
-                       return findClosest(message, low, mid - 1);
-               else
-                       return findClosest(message, mid + 1, high);
-       }
-
-       private boolean checkForSpace(int index){
-               if(this.get(index).n.getValue().length() == 0)
-                       return true;
-
- char firstChar = this.get(index).value().charAt(this.get(index).n.getValue().length() - 1);
-               String nextElementText = this.get(index + 1).value();
-               if(nextElementText.length() > 0){
-                       char nextChar =  nextElementText.charAt(0);
-                       if( firstChar == ' ' && nextChar != ' '){
-                               return true;
-                       }
-               }
-
-               return false;
-       }
-
-       public int findClosestBraille(Message message){
-               int location = (Integer)message.getValue("offset");
- int nodeIndex = getNodeIndex((TextMapElement)message.getValue("selection"));
-
- if(this.getFirst().brailleList.size() > 0 && location <= this.getFirst().brailleList.getFirst().start){
-                       return 0;
-               }
- else if(this.getLast().brailleList.size() > 0 && location >= this.getLast().brailleList.getLast().end){
-                       return this.indexOf(this.getLast());
-               }
-
-               for(int i = 0; i < this.size(); i++){
- if(this.get(i).brailleList.size() > 0 && location >= this.get(i).brailleList.getFirst().start && location <= this.get(i).brailleList.getLast().end){
-                               return i;
-                       }
- else if(this.get(i).brailleList.size() > 0 && this.get(i + 1).brailleList.size() > 0 && location > this.get(i).brailleList.getLast().end && location < this.get(i + 1).brailleList.getFirst().start){ - if(location - this.get(i).brailleList.getLast().end > this.get(i + 1).brailleList.getFirst().start - location){
-                                       return i + 1;
-                               }
- else if(location - this.get(i).brailleList.getLast().end < this.get(i + 1).brailleList.getFirst().start - location) {
-                                       return i;
-                               }
-                               else {
-                                       if(i == nodeIndex)
-                                               return i;
-                                       else if( i + 1 == nodeIndex)
-                                               return i + 1;
-                                       else
-                                               return i;
-                               }
-                       }
-               }
-               return 0;
-       }
-
-       public void updateOffsets(int index, Message message){
-               paginator.updateOffsets(get(index), message);
-               int offset = (Integer)message.getValue("length");
- int total = (Integer)message.getValue("newBrailleLength") - (Integer)message.getValue("brailleLength");
-
-               this.get(index).end += offset;
-
-               UpdaterThread [] arr = new UpdaterThread[PROCESSORS];
-               int length = (this.size() - index) / PROCESSORS;
-               int start = index + 1;
-
-               for(int i = 0; i < arr.length; i++){
-                       if(i == arr.length - 1)
-                               arr[i] = new UpdaterThread(this, start, 
this.size(), offset, total);
-                       else
- arr[i] = new UpdaterThread(this, start, start + length , offset, total);
-
-                       arr[i].start();
-                       start += length;
-               }
-
-               for (int i = 0; i < arr.length; i++) {
-                   try {
-                       arr[i].join();
-                   } catch (InterruptedException e) {
-                               e.printStackTrace();
-                       }
-               }
-       }
-
-
- public void shiftOffsetsFromIndex(int index, int offset, int brailleOffset, int origPos){
-               paginator.shiftOffsets(origPos, offset, brailleOffset);
-               UpdaterThread [] arr = new UpdaterThread[PROCESSORS];
-               int length = (this.size() - index) / PROCESSORS;
-               int start = index;
-
-               for(int i = 0; i < arr.length; i++){
-                       if(i == arr.length - 1)
- arr[i] = new UpdaterThread(this, start, this.size(), offset, brailleOffset);
-                       else
- arr[i] = new UpdaterThread(this, start, start + length , offset, brailleOffset);
-
-                       arr[i].start();
-                       start += length;
-               }
-
-               for (int i = 0; i < arr.length; i++) {
-                   try {
-                               arr[i].join();
-                   } catch (InterruptedException e) {
-                               e.printStackTrace();
-                       }
-               }
-       }
-
-       public void adjustOffsets(int index, Message message){
-               if(message.contains("start")){
-                       this.get(index).start -= 
(Integer)message.getValue("start");
-                       if(this.get(index).brailleList.size() > 0){
- this.get(index).brailleList.getFirst().start -= (Integer)message.getValue("start");
-                       }
-               }
-
-               if(message.contains("end")){
-                       this.get(index).end += (Integer)message.getValue("end");
-                       if(this.get(index).brailleList.size() > 0)
- this.get(index).brailleList.getLast().end += (Integer)message.getValue("end");
-               }
-       }
-
-       public void checkList(){
-               if(this.currentIndex != -1){
-                       int index = this.currentIndex;
-                       int next = index + 1;
-                       int previous = index - 1;
-
-                       //if start is equal to next start, then length is zero, 
so remove
-                       if(next < this.size()){
-                               if(this.get(index).start == 
this.get(next).start){
- Message m = Message.createRemoveNodeMessage(index, this.get(index).textLength());
-                                       System.out.println("Node 1:\t" + 
this.get(index).value());
-                                       System.out.println("Node 2:\t" + 
this.get(next).value());
-                                       dm.dispatch(m);
-                               }
-                       }
-
- //if previous end + 1 equals next, then current is no longer between two block elements
-                       //or if current length is zero and equal to previous 
end, then delete
-                       if(previous >= 0 && next < this.size()){
- if((this.get(previous).start + this.get(previous).textLength() + 1 == this.get(next).start && this.get(index).textLength() == 0) - || (this.get(previous).end == this.get(index).start && this.get(index).textLength() == 0)){ - Message m = Message.createRemoveNodeMessage(index, this.get(index).n.getValue().length());
-                                       System.out.println("Node 1:\t" + 
this.get(index).value());
-                                       System.out.println("Node 2:\t" + 
this.get(next).value());
-                                       dm.dispatch(m);
-                               }
-                       }
-
-                       //if last element is length zero and equals previousEnd 
then delete
- //if document name is null, then it is a new empty document, so do not delete - if(this.size() > 0 && this.get(this.size() - 1).n.getValue().length() == 0){ - if(this.get(this.size() - 1).start == this.prevEnd || (this.get(this.size() - 1).start == 0 && dm.getDocumentName() != null)){ - Message m = Message.createRemoveNodeMessage(this.size() - 1, this.get(this.size() - 1).textLength()); - System.out.println("Node 1:\t" + this.get(this.size() - 1).textLength());
-                                       System.out.println("Node 2:\t none");
-                                       dm.dispatch(m);
-                               }
-                       }
-               }
-       }
-
-       public int getNextBrailleOffset(int index){
-               int i = index + 1;
-               while(i < this.size()){
- if(this.get(i).brailleList.size() > 0 && this.get(i).brailleList.getFirst().start != -1)
-                               return this.get(i).brailleList.getFirst().start;
-                       i++;
-               }
-
-               i = index - 1;
-               while(i >= 0){
- if(this.get(i).brailleList.size() > 0 && this.get(i).brailleList.getFirst().start != -1)
-                               return this.get(i).brailleList.getFirst().start;
-               }
-               return 0;
-       }
-
-       public void setCurrent(int index){
-               this.current = this.get(index);
-               this.currentIndex = index;
-
-               if(index > 0)
-                       this.prevEnd = this.get(index -1).end;
-               else
-                       this.prevEnd = -1;
-
-               if(index != this.size() - 1)
-                       this.nextStart = this.get(index + 1).start;
-               else
-                       this.nextStart = -1;
-
-               this.nextBraille = getNextBraille(index);
-               this.prevBraille = getPreviousBraille(index);
-       }
-
-       public TextMapElement getCurrent(){
-               if(this.current == null){
-                       setCurrent(0);
-                       return this.current;
-               }
-               else {
-                       return this.current;
-               }
-       }
-       public int getCurrentIndex(){
-               if(this.current == null && size() > 0){
- Message message = Message.createSetCurrentMessage(null, this.getFirst().start, false);
-                       dm.dispatch(message);
-                       return this.currentIndex;
-               }
-               else if(this.size() == 0){
-                       return -1;
-               }
-               else {
-                       return this.currentIndex;
-               }
-       }
-
-       private int getCurrentBrailleEnd(){
-               if(this.current.brailleList.size() == 0)
-                       return 0;
-               else
-                       return this.current.brailleList.getLast().end;
-       }
-
-       private int getCurrentBrailleOffset(){
-               if(this.current.brailleList.size() == 0)
-                       return 0;
-               else
-                       return this.current.brailleList.getFirst().start;
-       }
-
-       private int getNextBraille(int index){
-               int localIndex = index + 1;
-
- while(localIndex < this.size() && this.get(localIndex).brailleList.size() == 0)
-                       localIndex++;
-
-               if(localIndex < this.size())
-                       return 
this.get(localIndex).brailleList.getFirst().start;
-
-               return -1;
-       }
-
-       private int getPreviousBraille(int index){
-               int localIndex = index - 1;
-
-               while(localIndex >= 0 && 
this.get(localIndex).brailleList.size() == 0)
-                       localIndex--;
-
-               if(localIndex >= 0)
-                       return this.get(localIndex).brailleList.getLast().end;
-
-               return -1;
-       }
-
-       private ArrayList<BrailleMapElement> getPageRanges(){
-               ArrayList<BrailleMapElement> list = new 
ArrayList<BrailleMapElement>();
-               for(int i = 0; i < this.current.brailleList.size(); i++){
-                       if(this.current.brailleList.get(i).pagenum){
-                               list.add(this.current.brailleList.get(i));
-                       }
-               }
-
-               return list;
-       }
-
-       public void getCurrentNodeData(Message m){
-               if(this.current == null){
-                       int index;
-                       if(m.getValue("sender").equals(Sender.BRAILLE))
-                               index = findClosestBraille(m);
-                       else
-                               index = findClosest(m, 0, this.size() - 1);
-
-                       setCurrent(index);
-               }
-
-               m.put("start", current.start);
-               m.put("end", current.end);
-               m.put("previous", prevEnd);
-               m.put("next", nextStart);
-               m.put("brailleStart", getCurrentBrailleOffset());
-               m.put("brailleEnd", getCurrentBrailleEnd());
-               m.put("nextBrailleStart", nextBraille);
-               m.put("previousBrailleEnd", prevBraille);
-               m.put("pageRanges", getPageRanges());
-               m.put("currentElement", current);
-       }
-
-       public int getNodeIndex(TextMapElement t){
-               return this.indexOf(t);
-       }
-
-       public void incrementCurrent(Message message){
-               if(this.currentIndex < this.size() - 1 && this.currentIndex > 
-1){
-                       setCurrent(this.currentIndex + 1);
-                       getCurrentNodeData(message);
-               }
-               else if(this.currentIndex == -1 && this.size() > 0){
-                       setCurrent(0);
-                       getCurrentNodeData(message);
-               }
-               else {
-                       getCurrentNodeData(message);
-               }
-       }
-
-       public void decrementCurrent(Message message){
-               if(this.currentIndex > 0){
-                       setCurrent(this.currentIndex - 1);
-                       getCurrentNodeData(message);
-               }
-               else if(this.currentIndex == -1 && this.size() > 0){
-                       setCurrent(0);
-                       getCurrentNodeData(message);
-               }
-               else {
-                       getCurrentNodeData(message);
-               }
-       }
-
-       public boolean hasBraille(int index){
-               if(this.size() != 0 && this.get(index).brailleList.size() > 0)
-                       return true;
-               else
-                       return false;
-       }
-
-       @SuppressWarnings("unchecked")
-       public void findTextMapElements(Message message){
-               ArrayList<Text>textList = 
(ArrayList<Text>)message.getValue("nodes");
- ArrayList<TextMapElement> itemList = (ArrayList<TextMapElement>)message.getValue("itemList");
-
-               int pos = 0;
-               for(int i = 0; i < textList.size(); i++){
-                       for(int j = pos; j < this.size(); j++){
-                               if(textList.get(i).equals(this.get(j).n)){
-                                       itemList.add(this.get(j));
-                                       pos = j + 1;
-                                       break;
-                               }
-                       }
-               }
-       }
-
- public ArrayList<TextMapElement> findTextMapElements(int index, Element parent, boolean ignoreInlineElement){
-               ArrayList<TextMapElement>list = new ArrayList<TextMapElement>();
-               BrailleDocument doc = dm.getDocument();
-
-               int countDown = index -  1;
-               int countUp = index + 1;
- while(countDown >= 0 && doc.getParent(this.get(countDown).n, ignoreInlineElement).equals(parent)){
-                       list.add(0, this.get(countDown));
-                       countDown--;
-               }
-
-               list.add(this.get(index));
-
- while(countUp < this.size() && doc.getParent(this.get(countUp).n, ignoreInlineElement).equals(parent)){
-                       list.add(this.get(countUp));
-                       countUp++;
-               }
-
-               return list;
-       }
-
- public ArrayList<Integer> findTextMapElementRange(int index, Element parent, boolean ignoreInlineElement){ - if(ignoreInlineElement && parent.getAttributeValue("semantics").contains("action")){
-                       
while(parent.getAttributeValue("semantics").contains("action"))
-                               parent = (Element)parent.getParent();
-               }
-               ArrayList<Integer>list = new ArrayList<Integer>();
-               BrailleDocument doc = dm.getDocument();
-
-               int countDown = index -  1;
-               int countUp = index + 1;
- while(countDown >= 0 && doc.getParent(this.get(countDown).n, ignoreInlineElement).equals(parent)){
-                       list.add(0, countDown);
-                       countDown--;
-               }
-
-               list.add(index);
-
- while(countUp < this.size() && doc.getParent(this.get(countUp).n, ignoreInlineElement).equals(parent)){
-                       list.add(countUp);
-                       countUp++;
-               }
-
-               return list;
-       }
-
-       public int findNodeIndex(Node n, int startIndex){
-               for(int i = startIndex; i < this.size(); i++){
-                       if(this.get(i).n.equals(n))
-                               return i;
-               }
-               return -1;
-       }
-
-       public void clearList(){
-               this.clear();
-               paginator.clear();
-               this.current = null;
-               currentIndex = -1;
-       }
-
-       public int getPrintPageStart(int offset){
-               return paginator.getPrintPageStart(offset);
-       }
-
-       public int getPrintPageEnd(int offset){
-               return paginator.getPrintPageEnd(offset);
-       }
-
-       public int getBraillePageStart(int offset){
-               return paginator.getBraillePageStart(offset);
-       }
-
-       public int getBraillePageEnd(int offset){
-               return paginator.getBraillePageEnd(offset);
-       }
-
-       public void addPrintPage(PageMapElement p){
-               paginator.add(p);
-       }
-
-       public PageMapElement getLastPage(){
-               return paginator.getLast();
-       }
-
-       public boolean inPrintPageRange(int offset){
-               return paginator.inPrintPageRange(offset);
-       }
-
-       public boolean inBraillePageRange(int offset){
-               return paginator.inBraillePageRange(offset);
-       }
-
-       public PageMapElement findPage(int offset){
-               return paginator.findPage(offset);
-       }
-
-       public PageMapElement findBraillePage(int offset){
-               return paginator.findBraillePage(offset);
-       }
-
-       public String findCurrentPrintPageValue(int offset){
-               return paginator.findCurrentPrintPageValue(offset);
-       }
-
-       public String findCurrentBraillePageValue(int offset){
-               return paginator.findCurrentBraillePageValue(offset);
-       }
-
-       public int getPageCount(){
-               return paginator.getSize();
-       }
-}
=======================================
--- /src/main/org/brailleblaster/perspectives/braille/mapping/PageMapElement.java Thu Mar 20 14:27:59 2014 UTC
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.brailleblaster.perspectives.braille.mapping;
-
-import nu.xom.Node;
-
-import org.brailleblaster.abstractClasses.AbstractMapElement;
-
-public class PageMapElement extends AbstractMapElement {
-
-       public int brailleStart, brailleEnd;
-       public Node brailleNode;
-
-       public PageMapElement(int start, int end, Node n) {
-               super(start, end, n);
-       }
-
-       public void setBraillePage(int brailleStart, int brailleEnd, Node n){
-               this.brailleStart = brailleStart;
-               this.brailleEnd = brailleEnd;
-               brailleNode = n;
-       }
-}
=======================================
--- /src/main/org/brailleblaster/perspectives/braille/mapping/Paginator.java Tue Jun 10 17:06:30 2014 UTC
+++ /dev/null
@@ -1,221 +0,0 @@
-package org.brailleblaster.perspectives.braille.mapping;
-
-import java.util.LinkedList;
-
-import org.brailleblaster.perspectives.braille.messages.Message;
-
-
-public class Paginator {
-       private LinkedList<PageMapElement>list;
-
-       public Paginator(){
-               list = new LinkedList<PageMapElement>();
-       }
-
-       public PageMapElement getPageMapElement(int index){
-               return list.get(index);
-       }
-
-       public PageMapElement getLast(){
-               return list.getLast();
-       }
-
-       public void add(PageMapElement p){
-               list.add(p);
-       }
-
-       public boolean inPrintPageRange(int offset){
-               if(list.size() > 0 && searchList(offset, 0, list.size() - 1) != 
-1)
-                       return true;
-               else
-                       return false;
-       }
-
-       public boolean inBraillePageRange(int offset){
-               if(list.size() > 0 && searchBraille(offset, 0, list.size() - 1) 
!= -1)
-                       return true;
-               else
-                       return false;
-       }
-
-       public PageMapElement findPage(int offset){
-               int index= searchList(offset, 0, list.size());
-               if(index != -1)
-                       return list.get(index);
-               else
-                       return null;
-       }
-
-       public String findCurrentPrintPageValue(int offset){
-               if(list.size() == 0)
-                       return null;
-               else{
-                       int pos = findRange(offset, 0, list.size() - 1);
-                       String value = list.get(pos).n.getValue();
-                       return value.substring(value.lastIndexOf("-") + 1);
-               }
-       }
-
-       public String findCurrentBraillePageValue(int offset){
-               if(list.size() == 0)
-                       return null;
-               else{
-                       int pos = findBrailleRange(offset, 0, list.size() - 1);
-                       String value = list.get(pos).n.getValue();
-                       return value.substring(value.lastIndexOf("-") + 1);
-               }
-       }
-
-       private int findRange(int offset, int low, int high){
-               if(low > high)
-                       return -1;
-
-               int mid = low + (high - low) / 2;
-               PageMapElement current = list.get(mid);
-
-               if(mid == 0 && offset < current.start)
-                       return mid;
-               else if(offset < current.start && offset > list.get(mid - 
1).end)
-                       return mid;
-               else if(mid == list.size() - 1 && offset > current.end)
-                       return mid;
-               else if(offset > current.end)
-                       return findRange(offset, mid + 1, high);
-               else if(offset < current.start)
-                       return findRange(offset, low, mid - 1);
-
-               return -1;
-       }
-
-       private int findBrailleRange(int offset, int low, int high){
-               if(low > high)
-                       return -1;
-
-               int mid = low + (high - low) / 2;
-               PageMapElement current = list.get(mid);
-
-               if(mid == 0 && offset < current.brailleStart)
-                       return mid;
- else if(offset < current.brailleStart && offset > list.get(mid - 1).brailleEnd)
-                       return mid;
-               else if(mid == list.size() - 1 && offset > current.brailleEnd)
-                       return mid;
-               else if(offset > current.brailleEnd)
-                       return findBrailleRange(offset, mid + 1, high);
-               else if(offset < current.brailleStart)
-                       return findBrailleRange(offset, low, mid - 1);
-
-               return -1;
-       }
-
-       private int searchList(int offset, int low, int high){
-               if(low > high)
-                       return -1;
-
-               int mid = low + (high - low) / 2;
-               PageMapElement current = list.get(mid);
-               if(offset >= current.start && offset <= current.end)
-                       return mid;
-               else if(offset < current.start)
-                       return searchList(offset, low, mid - 1);
-               else
-                       return searchList(offset, mid + 1, high);
-       }
-
-       public PageMapElement findBraillePage(int offset){
-               int index= searchBraille(offset, 0, list.size());
-               if(index != -1)
-                       return list.get(index);
-               else
-                       return null;
-       }
-
-       private int searchBraille(int offset, int low, int high){
-               if(low > high)
-                       return -1;
-
-               int mid = low + (high - low) / 2;
-               PageMapElement current = list.get(mid);
-               if(offset >= current.brailleStart && offset <= 
current.brailleEnd)
-                       return mid;
-               else if(offset < current.brailleStart)
-                       return searchBraille(offset, low, mid - 1);
-               else
-                       return searchBraille(offset, mid + 1, high);
-       }
-
-       public void updateOffsets(TextMapElement t, Message message){
-               int textOffset = (Integer)message.getValue("length");
-               int brailleOffset;
-               if(message.contains("newBrailleLength"))
- brailleOffset = (Integer)message.getValue("newBrailleLength") - (Integer)message.getValue("brailleLength");
-               else
-                       brailleOffset =  (Integer)message.getValue("length");
-
-               for(int i = 0; i < list.size(); i++){
-                       if(list.get(i).start > t.end){
-                               list.get(i).start += textOffset;
-                               list.get(i).end += textOffset;
-
-                               list.get(i).brailleStart += brailleOffset;
-                               list.get(i).brailleEnd += brailleOffset;
-                       }
-               }
-       }
-
-       public void shiftOffsets(int offset, int textOffset, int brailleOffset){
-               for(int i = 0; i < list.size(); i++){
-                       if(list.get(i).start > offset){
-                               list.get(i).start += textOffset;
-                               list.get(i).end += textOffset;
-
-                               list.get(i).brailleStart += brailleOffset;
-                               list.get(i).brailleEnd += brailleOffset;
-                       }
-               }
-       }
-
-       public int getPrintPageStart(int offset){
-               PageMapElement p = findPage(offset);
-
-               if(p != null)
-                       return p.start;
-               else
-                       return -1;
-       }
-
-       public int getPrintPageEnd(int offset){
-               PageMapElement p = findPage(offset);
-
-               if(p != null)
-                       return p.end;
-               else
-                       return -1;
-       }
-
-       public int getBraillePageStart(int offset){
-               PageMapElement p = findBraillePage(offset);
-
-               if(p != null)
-                       return p.brailleStart;
-               else
-                       return -1;
-       }
-
-       public int getBraillePageEnd(int offset){
-               PageMapElement p = findBraillePage(offset);
-
-               if(p != null)
-                       return p.brailleEnd;
-               else
-                       return -1;
-       }
-
-       public void clear(){
-               list.clear();
-       }
-
-       public int getSize(){
-               return list.size();
-       }
-}
=======================================
--- /src/main/org/brailleblaster/perspectives/braille/mapping/TextMapElement.java Wed Dec 11 17:19:42 2013 UTC
+++ /dev/null
@@ -1,43 +0,0 @@
-package org.brailleblaster.perspectives.braille.mapping;
-
-import java.util.LinkedList;
-
-import nu.xom.Element;
-import nu.xom.Node;
-
-import org.brailleblaster.abstractClasses.AbstractMapElement;
-
-public class TextMapElement extends AbstractMapElement {
-       public LinkedList<BrailleMapElement>brailleList;
-
-       public TextMapElement(int start, int end, Node n) {
-               super(start, end, n);
-               this.brailleList = new LinkedList<BrailleMapElement>();
-       }
-
-       public void setNode(Node n){
-               this.n = n;
-       }
-
-       public String getText(){
-               return n.getValue();
-       }
-
-       public int textLength(){
-               return n.getValue().length();
-       }
-
-       public int brailleLength(){
-               if(brailleList.size() == 0)
-                       return -1;
-               else
-                       return brailleList.getLast().end - 
brailleList.getFirst().start;
-       }
-
-       public boolean isMathML(){
-               if(n instanceof Element)
-                       return true;
-               else
-                       return false;
-       }
-}
=======================================
--- /src/main/org/brailleblaster/Subcommands.java Fri Jun 6 08:41:52 2014 UTC +++ /src/main/org/brailleblaster/Subcommands.java Thu Jul 3 16:07:57 2014 UTC
@@ -35,7 +35,6 @@

 import org.brailleblaster.util.CheckLiblouisutdmlLog;
 import org.brailleblaster.wordprocessor.WPManager;
-import org.brailleblaster.localization.LocaleHandler;
 import org.liblouis.LibLouisUTDML;
 import java.io.Console;
 import org.daisy.printing.PrinterDevice;
@@ -52,14 +51,12 @@

 class Subcommands {
        private Logger logger = BBIni.getLogger();
-       private LocaleHandler lh = new LocaleHandler();
        private LibLouisUTDML louisutdml;
        private CheckLiblouisutdmlLog lbuLog = new CheckLiblouisutdmlLog();
        private String subcommand;
        private String[] subArgs;

        Subcommands(String[] args) {
-               LocaleHandler lh = new LocaleHandler();
                logger = BBIni.getLogger();
                if (!BBIni.haveLiblouisutdml()) {
                        logger.log(Level.SEVERE,
=======================================
--- /src/main/org/brailleblaster/abstractClasses/AbstractView.java Tue Apr 15 14:34:57 2014 UTC +++ /src/main/org/brailleblaster/abstractClasses/AbstractView.java Thu Jul 3 16:07:57 2014 UTC
@@ -123,6 +123,10 @@
        public int getCursorOffset(){
                return cursorOffset;
        }
+
+       public void setTotal(int total){
+               this.total = total;
+       }

        protected abstract void setViewData(Message message);
 }
=======================================
--- /src/main/org/brailleblaster/document/BBDocument.java Fri Jun 6 08:41:52 2014 UTC +++ /src/main/org/brailleblaster/document/BBDocument.java Thu Jul 3 16:07:57 2014 UTC
@@ -96,6 +96,8 @@
                mistranslationList = new ArrayList<String>();
                semHandler = new SemanticFileHandler(dm.getCurrentConfig());
                sm = new SettingsManager(dm.getCurrentConfig());
+ org.liblouis.LibLouis.getInstance().setLogLevel(org.liblouis.LogLevel.OFF); + org.liblouis.LibLouisUTDML.getInstance().setLogLevel(org.liblouis.LogLevel.OFF);
        }

        public BBDocument(Controller dm, Document doc){
@@ -106,6 +108,8 @@
                mistranslationList = new ArrayList<String>();
                semHandler = new SemanticFileHandler(dm.getCurrentConfig());
                sm = new SettingsManager(dm.getCurrentConfig());
+ org.liblouis.LibLouis.getInstance().setLogLevel(org.liblouis.LogLevel.OFF); + org.liblouis.LibLouisUTDML.getInstance().setLogLevel(org.liblouis.LogLevel.OFF);
        }

        public boolean createNewDocument(){
=======================================
--- /src/main/org/brailleblaster/perspectives/braille/Manager.java Tue Jun 10 18:16:59 2014 UTC +++ /src/main/org/brailleblaster/perspectives/braille/Manager.java Thu Jul 3 16:07:57 2014 UTC
@@ -39,17 +39,14 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;

-import nu.xom.Attribute;
 import nu.xom.Document;
 import nu.xom.Element;
 import nu.xom.Node;
-import nu.xom.Nodes;
 import nu.xom.Text;

 import org.brailleblaster.BBIni;
 import org.brailleblaster.archiver.Archiver;
 import org.brailleblaster.archiver.ArchiverFactory;
-import org.brailleblaster.document.SemanticFileHandler;
 import org.brailleblaster.embossers.EmbossersManager;
 import org.brailleblaster.localization.LocaleHandler;
 import org.brailleblaster.perspectives.Controller;
@@ -57,15 +54,19 @@
import org.brailleblaster.perspectives.braille.document.BBSemanticsTable.Styles; import org.brailleblaster.perspectives.braille.document.BBSemanticsTable.StylesType;
 import org.brailleblaster.perspectives.braille.document.BrailleDocument;
-import org.brailleblaster.perspectives.braille.mapping.MapList;
-import org.brailleblaster.perspectives.braille.mapping.PageMapElement;
-import org.brailleblaster.perspectives.braille.mapping.TextMapElement;
+import org.brailleblaster.perspectives.braille.mapping.elements.PageMapElement;
+import org.brailleblaster.perspectives.braille.mapping.elements.Range;
+import org.brailleblaster.perspectives.braille.mapping.elements.SectionElement; +import org.brailleblaster.perspectives.braille.mapping.elements.TextMapElement;
+import org.brailleblaster.perspectives.braille.mapping.maps.MapList;
 import org.brailleblaster.perspectives.braille.messages.BBEvent;
 import org.brailleblaster.perspectives.braille.messages.Message;
 import org.brailleblaster.perspectives.braille.messages.Sender;
import org.brailleblaster.perspectives.braille.spellcheck.SpellCheckManager;
 import org.brailleblaster.perspectives.braille.stylepanel.StyleManager;
 import org.brailleblaster.search.*;
+import org.brailleblaster.perspectives.braille.viewInitializer.ViewFactory;
+import org.brailleblaster.perspectives.braille.viewInitializer.ViewInitializer;
 import org.brailleblaster.perspectives.braille.views.tree.BBTree;
 import org.brailleblaster.perspectives.braille.views.tree.TreeView;
 import org.brailleblaster.perspectives.braille.views.wp.BrailleView;
@@ -96,6 +97,7 @@
        private TextView text;
        private BrailleView braille;
        private BBProgressBar pb;
+       private ViewInitializer vi;
        StyleManager sm;
        FormLayout layout;
        Control [] tabList;
@@ -119,7 +121,6 @@
                fontManager = new FontManager(this);
                styles = new BBSemanticsTable(BBIni.getDefaultConfigFile());
                documentName = docName;
-               list = new MapList(this);
                item = new TabItem(wp.getFolder(), 0);
                group = new Group(wp.getFolder(),SWT.NONE);
                group.setLayout(new FormLayout());
@@ -141,9 +142,11 @@
                else {
                        docCount++;
                        arch = ArchiverFactory.getArchive( templateFile);
+                       vi = ViewFactory.createUpdater(arch, document, text, 
braille, treeView);
+                       //list = vi.getList(this);
                        resetConfiguations();
                        initializeAllViews(docName, templateFile, null);
-                       formatTemplateDocument();
+                       //formatTemplateDocument();
                        setTabTitle(docName);
                }

@@ -158,7 +161,6 @@
                fontManager = new FontManager(this);
                styles = new BBSemanticsTable(arch.getCurrentConfig());
                documentName = arch.getOrigDocPath();
-               list = new MapList(this);
                this.item = item;
                group = new Group(wp.getFolder(),SWT.NONE);
                group.setLayout(new FormLayout());
@@ -176,9 +178,12 @@
                logger = BBIni.getLogger();

                document = new BrailleDocument(this, doc, this.styles);
-
+               vi = ViewFactory.createUpdater(arch, document, text, braille, 
treeView);
+
                group.setRedraw(false);
-               initializeViews(document.getRootElement());
+               vi.initializeViews(this);
+               list = vi.getList(this);
+
                treeView.setRoot(document.getRootElement());
                document.notifyUser();
                text.initializeListeners();
@@ -189,8 +194,8 @@
                text.view.setWordWrap(true);
                braille.view.setWordWrap(true);
                group.setRedraw(true);
-               if(list.size() == 0)
-                       formatTemplateDocument();
+               //if(list.size() == 0)
+               //      formatTemplateDocument();

                if(BBIni.getPlatformName().equals("cocoa"))
                        treeView.getTree().select(treeView.getRoot());
@@ -294,7 +299,9 @@
                                startProgressBar();
                                documentName = fileName;
                                setTabTitle(fileName);
-                               initializeViews(document.getRootElement());
+ vi = ViewFactory.createUpdater(arch, document, text, braille, treeView);
+                               vi.initializeViews(this);
+                               list = vi.getList(this);
                                treeView.setRoot(document.getRootElement());
                                document.notifyUser();
                                text.initializeListeners();
@@ -322,86 +329,6 @@
                        logger.log(Level.SEVERE, "Unforeseen Exception", e);
                }
        }
-
-       private void initializeViews(Node current){
- if(current instanceof Text && !((Element)current.getParent()).getLocalName().equals("brl") && vaildTextElement(current, current.getValue())){
-                       text.setText(current, list);
-               }
-
-               for(int i = 0; i < current.getChildCount(); i++){
- if(current.getChild(i) instanceof Element && ((Element)current.getChild(i)).getLocalName().equals("brl")){
-                               initializeBraille(current.getChild(i), 
list.getLast());
-                       }
- else if(current.getChild(i) instanceof Element && ((Element)current.getChild(i)).getLocalName().equals("math")){
-                               //if math is empty skip next brl element
-                               if(validateMath((Element)current.getChild(i)))
- initializeMathML((Element)current.getChild(i), (Element)current.getChild(i + 1));
-                               else
-                                       i++;
-                       }
-                       else {
-                               if(current.getChild(i) instanceof Element){
-                                       
if(((Element)current.getChild(i)).getLocalName().equals("pagenum")){
-                                               
initializePrintPage((Element)current.getChild(i));
-                                       }
-                                       else {
-                                               Element currentChild = 
(Element)current.getChild(i);
-                                               
document.checkSemantics(currentChild);
- if(!currentChild.getLocalName().equals("meta") & !currentChild.getAttributeValue("semantics").contains("skip"))
-                                                       
initializeViews(currentChild);
-                                       }
-                               }
-                               else if(!(current.getChild(i) instanceof 
Element)) {
-                                       initializeViews(current.getChild(i));
-                               }
-                       }
-               }
-       }
-
-       private void initializeBraille(Node current, TextMapElement t){
- if(current instanceof Text && ((Element)current.getParent()).getLocalName().equals("brl")){
-                       Element grandParent = 
(Element)current.getParent().getParent();
- if(!(grandParent.getLocalName().equals("span") && document.checkAttributeValue(grandParent, "class", "brlonly")))
-                               braille.setBraille(list, current, t);
-               }
-
-               for(int i = 0; i < current.getChildCount(); i++){
-                       if(current.getChild(i) instanceof Element){
-                               initializeBraille(current.getChild(i), t);
-                       }
-                       else {
-                               initializeBraille(current.getChild(i), t);
-                       }
-               }
-       }
-
-       private void initializePrintPage(Element page){
-               Node textNode = document.findPrintPageNode(page);
-               if(textNode != null){
-                       text.addPageNumber(list, textNode);
-
-                       Node brailleText = document.findBraillePageNode(page);
-                       braille.addPageNumber(list, brailleText);
-               }
-       }
-
-       private void initializeMathML(Element math, Element brl){
-               text.setMathML(list, math);
-       }
-
-       private boolean validateMath(Element math){
-               int count = math.getChildCount();
-               for(int i = 0; i < count; i++){
-                       if(math.getChild(i) instanceof Text)
-                               return true;
-                       else if(math.getChild(i) instanceof Element){
-                               if(validateMath((Element)math.getChild(i)))
-                                       return true;
-                       }
-               }
-
-               return false;
-       }

        public void dispatch(Message message){
                switch(message.type){
@@ -448,7 +375,7 @@
                                list.adjustOffsets(list.getCurrentIndex(), 
message);
                                break;
                        case GET_TEXT_MAP_ELEMENTS:
-                               list.findTextMapElements(message);
+                               findTextMapElements(message);
                                break;
                        case UPDATE_SCROLLBAR:
                                handleUpdateScrollbar(message);
@@ -460,6 +387,57 @@
                                break;
                }
        }
+
+       public void checkView(TextMapElement t){
+               if(!list.contains(t))
+                       list = vi.resetViews(getSection(t));
+       }
+
+       public void decrementView(){
+               TextMapElement t = list.getFirst();
+               int section = getSection(t);
+               if(section != 0){
+                       list = vi.resetViews(section);
+                       list.setCurrent(list.indexOf(t) - 1);
+                       text.resetOffsets();
+               }
+       }
+
+       public void incrementView(){
+               TextMapElement t = list.getLast();
+               int section = getSection(t);
+               if(section != vi.getSectionList().size() - 1){
+                       list = vi.resetViews(section + 1);
+                       list.setCurrent(list.indexOf(t) + 1);
+                       text.resetOffsets();
+               }
+       }
+
+       @SuppressWarnings("unchecked")
+       private void findTextMapElements(Message message){
+               ArrayList<Text>textList = 
(ArrayList<Text>)message.getValue("nodes");
+
+               ArrayList<SectionElement>secList = vi.getSectionList();
+               Element e = (Element)textList.get(0).getParent();
+ while(e != null && !e.getLocalName().equals("level1") && !e.getLocalName().equals("body")){
+                       e = (Element)e.getParent();
+               }
+
+               if(secList.size() > 1){
+                       for(int i = 0; i < secList.size(); i++){
+                               if(secList.get(i).getParent().equals(e)){
+                                       if(secList.get(i).isVisible())
+                                               
list.findTextMapElements(message);
+                                       else {
+                                               list = vi.resetViews(i);
+                                               
list.findTextMapElements(message);
+                                       }
+                               }
+                       }
+               }
+               else
+                       list.findTextMapElements(message);
+       }

        private void handleIncrement(Message message){
                list.incrementCurrent(message);
@@ -500,6 +478,7 @@

        private void handleSetCurrent(Message message){
                int index;
+               boolean viewReset = false;
                list.checkList();

                if(message.getValue("isBraille").equals(true)){
@@ -524,11 +503,23 @@
                        resetCursorData();
                }

-               if(treeView.getTree().isFocusControl() && 
!currentElementOnScreen()){
+ if(list.getCurrentIndex() == list.size() - 1 && !vi.getSectionList().get(vi.getSectionList().size() - 1).isVisible()){
+                       list = vi.bufferForward();
+                       list.getCurrentNodeData(message);
+                       viewReset = true;
+               }
+ else if(list.getCurrentIndex() == 0 && !vi.getSectionList().get(0).isVisible() && getSection(list.getCurrent()) != vi.getSectionList().size() - 1){
+                       list = vi.bufferBackward();
+                       list.getCurrentNodeData(message);
+                       viewReset = true;
+               }
+
+ if((treeView.getTree().isFocusControl() && !currentElementOnScreen()) || viewReset){ text.view.setTopIndex(text.view.getLineAtOffset(list.getCurrent().start)); handleUpdateScrollbar(Message.createUpdateScollbarMessage(Sender.TREE, list.getCurrent().start));
                }
        }
+

        private boolean currentElementOnScreen(){
                int viewHeight = text.view.getClientArea().height;
@@ -1019,6 +1010,7 @@
                        boolean textChanged = text.hasChanged;
                        boolean brailleChanged = braille.hasChanged;

+                       int index = getSection(list.getCurrent());
String path = BBIni.getTempFilesPath() + BBIni.getFileSep() + "temp.xml";
                        File f = new File(path);
                        f.createNewFile();
@@ -1051,8 +1043,10 @@
                        text.hasChanged = textChanged;
                        braille.hasChanged = brailleChanged;

-                       if(arch.getOrigDocPath() == null && list.size() == 0)
-                               formatTemplateDocument();
+                       if(index != -1)
+                               vi.resetViews(index);
+                       //if(arch.getOrigDocPath() == null && list.size() == 0)
+                       //      formatTemplateDocument();
                }
                catch (IOException e) {
new Notify("An error occurred while refreshing the document. Please save your work and try again.");
@@ -1066,22 +1060,6 @@
                if(!fu.createXMLFile(document.getDOM(), tempFile))
new Notify("An error occured while saving a temporary file. Please restart brailleblaster");
        }
-
-       private boolean vaildTextElement(Node n , String text){
-               Element e = (Element)n.getParent();
-               int index = e.indexOf(n);
-               int length = text.length();
-
- if(index == e.getChildCount() - 1 || !(e.getChild(index + 1) instanceof Element && ((Element)e.getChild(index + 1)).getLocalName().equals("brl")))
-                       return false;
-
-               for(int i = 0; i < length; i++){
-                       if(text.charAt(i) != '\n' && text.charAt(i) != '\t')
-                               return true;
-               }
-
-               return false;
-       }

        public void toggleAttributeEditor(){
                if(!sm.panelIsVisible()){
@@ -1221,14 +1199,68 @@
        public int indexOf(TextMapElement t){
                return list.indexOf(t);
        }
+
+       public int indexOf(int section, TextMapElement t){
+               if(vi.getSectionList().size() > 1)
+                       return 
vi.getSectionList().get(section).getList().indexOf(t);
+               else
+                       return list.indexOf(t);
+       }
+
+       public int getSection(TextMapElement t){
+               for(int i = 0; i < vi.getSectionList().size(); i++){
+                       if(vi.getSectionList().get(i).getList().contains(t))
+                               return i;
+               }
+
+               return -1;
+       }
+
+       public int getSection(Node n){
+               for(int i = 0; i < vi.getSectionList().size(); i++){
+                       if(vi.getSectionList().get(i).getList().contains(n))
+                               return i;
+               }
+
+               return -1;
+       }
+
+       public int getSection(int section, Node n){
+               for(int i = section; i < vi.getSectionList().size(); i++){
+                       if(vi.getSectionList().get(i).getList().contains(n))
+                               return i;
+               }
+
+               return -1;
+       }
+
+       public Range getRange(int section, int listIndex, Node n){
+               for(int i = section; i < vi.getSectionList().size(); i++){
+ int index = vi.getSectionList().get(i).getList().findNodeIndex(n, listIndex);
+                       if(index != -1)
+                               return new Range(i, index);
+
+                       listIndex = 0;
+               }
+
+               return null;
+       }

        public int findNodeIndex(Node n, int startIndex){
                return list.findNodeIndex(n, startIndex);
        }
+
+       public int findNodeIndex(Node n, int section, int startIndex){
+ return vi.getSectionList().get(section).getList().findNodeIndex(n, startIndex);
+       }

        public TextMapElement getTextMapElement(int index){
                return list.get(index);
        }
+
+       public TextMapElement getTextMapElement(int section, int index){
+               return vi.getSectionList().get(section).getList().get(index);
+       }

        public int getListSize() {
                return list.size();
@@ -1258,6 +1290,7 @@
                treeView.setSelection(list.getCurrent());
                treeView.getTree().getParent().layout();
                treeView.initializeListeners();
+               vi.resetTree(treeView);
                //save latest setting to user settings file
BBIni.getPropertyFileManager().save("tree", treeView.getClass().getCanonicalName().toString());
        }
@@ -1433,25 +1466,5 @@
                        e.doit = false;
                        sm.getStyleTable().getTable().setFocus();
                }
-       }
-
-       //adds or tracks a text node for a blank document when user starts
-       private void formatTemplateDocument(){
-               Nodes n = document.query("/*[1]/*[2]");
-
-               if(n.get(0).getChildCount() > 0){
-                       if(n.get(0).getChild(0).getChildCount() == 0)
-                               ((Element)n.get(0).getChild(0)).appendChild(new 
Text(""));
-
-                       list.add(new TextMapElement(0, 0, 
n.get(0).getChild(0).getChild(0)));
-               }
-               else {
- Element p = new Element("p", document.getRootElement().getNamespaceURI()); - SemanticFileHandler sfh = new SemanticFileHandler(arch.getCurrentConfig()); - p.addAttribute(new Attribute("semantics","styles," + sfh.getDefault("p")));
-                       p.appendChild(new Text(""));
-                       ((Element)n.get(0)).appendChild(p);
-                       list.add(new TextMapElement(0, 0, 
n.get(0).getChild(0).getChild(0)));
-               }
        }
 }
=======================================
--- /src/main/org/brailleblaster/perspectives/braille/document/BrailleDocument.java Mon Jun 2 18:56:58 2014 UTC +++ /src/main/org/brailleblaster/perspectives/braille/document/BrailleDocument.java Thu Jul 3 16:07:57 2014 UTC
@@ -19,9 +19,9 @@
 import org.brailleblaster.BBIni;
 import org.brailleblaster.document.BBDocument;
 import org.brailleblaster.perspectives.braille.Manager;
-import org.brailleblaster.perspectives.braille.mapping.BrailleMapElement;
-import org.brailleblaster.perspectives.braille.mapping.MapList;
-import org.brailleblaster.perspectives.braille.mapping.TextMapElement;
+import org.brailleblaster.perspectives.braille.mapping.elements.BrailleMapElement; +import org.brailleblaster.perspectives.braille.mapping.elements.TextMapElement;
+import org.brailleblaster.perspectives.braille.mapping.maps.MapList;
 import org.brailleblaster.perspectives.braille.messages.Message;
 import org.eclipse.swt.SWT;

@@ -567,7 +567,6 @@
        public void changeSemanticAction(Message m, Element e){
org.brailleblaster.perspectives.braille.document.BBSemanticsTable.Styles style = (org.brailleblaster.perspectives.braille.document.BBSemanticsTable.Styles)m.getValue("Style");
                String name = style.getName();
-               //Element e = (Element)t.n.getParent();
                Attribute attr = e.getAttribute("semantics");
                while(attr.getValue().contains("action")){
                        e = (Element)e.getParent();
=======================================
--- /src/main/org/brailleblaster/perspectives/braille/document/ElementDivider.java Mon Oct 14 14:24:28 2013 UTC +++ /src/main/org/brailleblaster/perspectives/braille/document/ElementDivider.java Thu Jul 3 16:07:57 2014 UTC
@@ -3,8 +3,8 @@
 import java.util.ArrayList;

 import org.brailleblaster.document.SemanticFileHandler;
-import org.brailleblaster.perspectives.braille.mapping.MapList;
-import org.brailleblaster.perspectives.braille.mapping.TextMapElement;
+import org.brailleblaster.perspectives.braille.mapping.elements.TextMapElement;
+import org.brailleblaster.perspectives.braille.mapping.maps.MapList;
 import org.brailleblaster.perspectives.braille.messages.Message;

 import nu.xom.Attribute;
=======================================
--- /src/main/org/brailleblaster/perspectives/braille/messages/Message.java Mon Jun 2 18:56:58 2014 UTC +++ /src/main/org/brailleblaster/perspectives/braille/messages/Message.java Thu Jul 3 16:07:57 2014 UTC
@@ -33,7 +33,7 @@
 import java.util.ArrayList;
 import java.util.HashMap;

-import org.brailleblaster.perspectives.braille.mapping.TextMapElement;
+import org.brailleblaster.perspectives.braille.mapping.elements.TextMapElement;

 import nu.xom.Text;

=======================================
--- /src/main/org/brailleblaster/perspectives/braille/stylepanel/StyleManager.java Tue Apr 15 14:34:57 2014 UTC +++ /src/main/org/brailleblaster/perspectives/braille/stylepanel/StyleManager.java Thu Jul 3 16:07:57 2014 UTC
@@ -40,7 +40,7 @@
 import org.brailleblaster.perspectives.braille.Manager;
 import org.brailleblaster.perspectives.braille.document.BBSemanticsTable;
import org.brailleblaster.perspectives.braille.document.BBSemanticsTable.Styles;
-import org.brailleblaster.perspectives.braille.mapping.TextMapElement;
+import org.brailleblaster.perspectives.braille.mapping.elements.TextMapElement;
 import org.brailleblaster.perspectives.braille.messages.BBEvent;
 import org.brailleblaster.perspectives.braille.messages.Message;
 import org.brailleblaster.util.Notify;
=======================================
--- /src/main/org/brailleblaster/perspectives/braille/stylepanel/StyleTable.java Fri Mar 21 16:51:28 2014 UTC +++ /src/main/org/brailleblaster/perspectives/braille/stylepanel/StyleTable.java Thu Jul 3 16:07:57 2014 UTC
@@ -5,7 +5,7 @@
 import nu.xom.Element;

 import org.brailleblaster.localization.LocaleHandler;
-import org.brailleblaster.perspectives.braille.mapping.TextMapElement;
+import org.brailleblaster.perspectives.braille.mapping.elements.TextMapElement;

 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.KeyAdapter;
=======================================
--- /src/main/org/brailleblaster/perspectives/braille/views/tree/BBTree.java Thu Mar 20 14:27:59 2014 UTC +++ /src/main/org/brailleblaster/perspectives/braille/views/tree/BBTree.java Thu Jul 3 16:07:57 2014 UTC
@@ -3,7 +3,7 @@
 import nu.xom.Element;

 import org.brailleblaster.abstractClasses.BBView;
-import org.brailleblaster.perspectives.braille.mapping.TextMapElement;
+import org.brailleblaster.perspectives.braille.mapping.elements.TextMapElement;
 import org.brailleblaster.perspectives.braille.messages.Message;
 import org.eclipse.swt.widgets.Tree;
 import org.eclipse.swt.widgets.TreeItem;
=======================================
--- /src/main/org/brailleblaster/perspectives/braille/views/tree/BookTree.java Wed Apr 16 22:06:34 2014 UTC +++ /src/main/org/brailleblaster/perspectives/braille/views/tree/BookTree.java Thu Jul 3 16:07:57 2014 UTC
@@ -9,7 +9,8 @@
 import org.brailleblaster.BBIni;
 import org.brailleblaster.perspectives.braille.Manager;
 import org.brailleblaster.perspectives.braille.document.BBSemanticsTable;
-import org.brailleblaster.perspectives.braille.mapping.TextMapElement;
+import org.brailleblaster.perspectives.braille.mapping.elements.Range;
+import org.brailleblaster.perspectives.braille.mapping.elements.TextMapElement;
 import org.brailleblaster.perspectives.braille.messages.Message;
 import org.brailleblaster.perspectives.braille.messages.Sender;
 import org.eclipse.swt.SWT;
@@ -24,28 +25,29 @@
 public class BookTree extends TreeView {
        private class TreeItemData {
                public LinkedList<TextMapElement>list;
-               public int startRange, endRange;
+               public int sectionIndex, startRange, endRange;
                public String heading;

-               public TreeItemData(Element e, int startRange){
+               public TreeItemData(Element e, int sectionIndex, int 
startRange){
                        list = new LinkedList<TextMapElement>();
+                       this.sectionIndex = sectionIndex;
                        this.startRange = startRange;
                        this.endRange = -1;
-                       setDataList(this, e, startRange);
+                       setDataList(this, e, sectionIndex, startRange);
                        heading = getHeading(e);
                }

-               private void setDataList(TreeItemData data, Element e, int 
start){
+ private void setDataList(TreeItemData data, Element e, int section, int start){
                        LinkedList<TextMapElement>list = data.list;
                        int count = e.getChildCount();
                        for(int i = 0; i < count; i++){
                                if(e.getChild(i) instanceof Text){
-                                       int index = 
manager.findNodeIndex(e.getChild(i), start);
+                                       int index = 
manager.findNodeIndex(e.getChild(i), section, start);
                                        if(index != -1)
-                                               
list.add(manager.getTextMapElement(index));
+                                               
list.add(manager.getTextMapElement(section, index));
                                }
else if(e.getChild(i) instanceof Element && !((Element)e.getChild(i)).getLocalName().equals("brl") && table.getSemanticTypeFromAttribute((Element)e.getChild(i)).equals("action"))
-                                       setDataList(data, 
(Element)e.getChild(i), start);
+                                       setDataList(data, 
(Element)e.getChild(i), section, start);
                        }
                }

@@ -85,6 +87,7 @@
                                if(!getLock() && 
tree.getSelection()[0].equals(e.item)){
                                        if(!e.item.equals(root)){
                                                TreeItemData data = 
getItemData((TreeItem)e.item);
+                                               
manager.checkView(data.list.getFirst());
Message m = Message.createSetCurrentMessage(Sender.TREE, data.list.getFirst().start, false);
                                                setCursorOffset(0);
                                                manager.dispatch(m);
@@ -128,7 +131,7 @@
                previousItem = null;
        }

-       public void setTree(Element e, TreeItem item){
+       public void setTree(Element e, TreeItem item){
                Elements els = e.getChildElements();
                for(int i = 0; i < els.size(); i++){
if(table.getKeyFromAttribute(els.get(i)).contains("heading") || table.getKeyFromAttribute(els.get(i)).contains("header")){
@@ -170,12 +173,12 @@

        //Finds text for tree item and sets corresponding data
        private void setNewItemData(TreeItem item, Element e){
-               int start = findIndex(item, e);
+               Range range = findIndex(item, e);

-               if(start != -1){
-                       item.setData(new TreeItemData(e, start));
+               if(range != null && range.start != -1){
+                       item.setData(new TreeItemData(e, range.section, 
range.start));
                        if(previousItem != null){
-                               ((TreeItemData)previousItem.getData()).endRange 
= start - 1;
+                               ((TreeItemData)previousItem.getData()).endRange 
= range.start - 1;
                        }

                        item.setText(formatItemText(getItemData(item),e));
@@ -201,24 +204,30 @@
                return text.trim();
        }

-       private int findIndex(TreeItem item, Element e){
+       private Range findIndex(TreeItem item, Element e){
                int count = e.getChildCount();
                for(int i = 0; i < count; i++){
                        if(e.getChild(i) instanceof Text){
-                               int searchIndex;
+                               int sectionIndex, startIndex;

-                               if(previousItem == null)
-                                       searchIndex = 0;
-                               else
-                                       searchIndex = 
getItemData(previousItem).startRange + 1;
-
-                               return manager.findNodeIndex(e.getChild(i), 
searchIndex);
+                               if(previousItem == null){
+                                       sectionIndex = 0;
+                                       startIndex = 0;
+                               }
+                               else {
+                                       sectionIndex = 
getItemData(previousItem).sectionIndex;
+                                       startIndex = 
getItemData(previousItem).startRange + 1;
+                               }
+
+                               //int section = manager.getSection(searchIndex, 
e.getChild(i));
+                               return manager.getRange(sectionIndex, 
startIndex, e.getChild(i));
+ //return new Range(section, manager.findNodeIndex(e.getChild(i), section, 0));
                        }
else if(e.getChild(i) instanceof Element && !((Element)e.getChild(i)).getLocalName().equals("brl") && !((Element)e.getChild(i)).getLocalName().equals("img") && table.getSemanticTypeFromAttribute((Element)e.getChild(i)).equals("action") && e.getChild(i).getChildCount() != 0)
                                return findIndex(item, (Element)e.getChild(i));
                }

-               return -1;
+               return null;
        }

        @Override
@@ -235,8 +244,9 @@
                        else
                                temp = new TreeItem(root, SWT.None, index + 
offset);

+                       int sectionIndex = getItemData(lastParent).sectionIndex;
                        temp.setText(t.getText());
-                       temp.setData(new TreeItemData(t.parentElement(), 
manager.indexOf(t)));
+ temp.setData(new TreeItemData(t.parentElement(), sectionIndex, manager.indexOf(t)));
                        resetIndexes();
                }
        }
@@ -258,7 +268,7 @@
        public void removeItem(TextMapElement t, Message m) {
                setListenerLock(true);
                int index = manager.indexOf(t);
-               TreeItem item = findRange(manager.indexOf(t));
+               TreeItem item = findRange(manager.getSection(t), 
manager.indexOf(t));

                if(isHeading(t)){
                        LinkedList<TextMapElement> list = 
getItemData(item).list;
@@ -364,7 +374,8 @@
        @Override
        public void setSelection(TextMapElement t) {
                setListenerLock(true);
-               TreeItem item = findRange(manager.indexOf(t));
+               int section = manager.getSection(t);
+               TreeItem item = findRange(section, manager.indexOf(section, t));
                if(item != null){
                        tree.setSelection(item);
                }
@@ -403,22 +414,25 @@
                return (TreeItemData)item.getData();
        }

-       private TreeItem findRange(int index){
-               return searchTree(root, index);
+       private TreeItem findRange(int section, int index){
+               return searchTree(root, section, index);
        }

-       private TreeItem searchTree(TreeItem item, int index){
+       private TreeItem searchTree(TreeItem item, int section, int index){
                TreeItem [] items = item.getItems();

                for(int i = 0; i < items.length; i++){
-                       if(checkItem(items[i], index))
+                       if(checkItem(items[i], section, index))
                                return items[i];
                        else if(i < items.length - 1){
- if(index > getEndRange(items[i]) && index < getStartRange(items[i + 1]))
-                                       return searchTree(items[i], index);
+ if(section == getSection(items[i]) && index > getEndRange(items[i]) && items[i].getItemCount() > 0){
+                                       TreeItem newItem =  
searchTree(items[i], section, index);
+                                       if(newItem != null)
+                                               return newItem;
+                               }
                        }
else if(i == items.length - 1 && index > getStartRange(items[i]) && items[i].getItemCount() > 0) {
-                               return searchTree(items[i], index);
+                               return searchTree(items[i], section, index);
                        }
                }

@@ -446,6 +460,10 @@
                                resetIndexesHelper(item.getItem(i));
                }
        }
+
+       private int getSection(TreeItem item){
+               return ((TreeItemData)item.getData()).sectionIndex;
+       }

        private int getStartRange(TreeItem item){
                return ((TreeItemData)item.getData()).startRange;
@@ -455,9 +473,9 @@
                return ((TreeItemData)item.getData()).endRange;
        }

-       private boolean checkItem(TreeItem item, int index){
+       private boolean checkItem(TreeItem item, int section, int index){
                TreeItemData data = getItemData(item);
- if((index >= data.startRange && index <= data.endRange) || (index >= data.startRange && data.endRange == -1)) + if((data.sectionIndex == section && index >= data.startRange && index <= data.endRange) || (data.sectionIndex == section && index >= data.startRange && data.endRange == -1))
                        return true;
                else
                        return false;
@@ -466,6 +484,12 @@
        @Override
        public void split(Message m) {
                lastParent = tree.getSelection()[0].getParentItem();
+               int section;
+               if(lastParent != null)
+                       section = getItemData(lastParent).sectionIndex;
+               else
+                       section = 0;
+
                TreeItem item = tree.getSelection()[0];
                int firstElementIndex = 
(Integer)m.getValue("firstElementIndex");
                int secondElementIndex = 
(Integer)m.getValue("secondElementIndex");
@@ -477,7 +501,7 @@
                if(isHeading(manager.getTextMapElement(secondElementIndex))){
                        if(!item.equals(root)){
                                
item.setText(manager.getTextMapElement(secondElementIndex).getText());
- item.setData(new TreeItemData(manager.getTextMapElement(secondElementIndex).parentElement(), manager.indexOf(manager.getTextMapElement(secondElementIndex)))); + item.setData(new TreeItemData(manager.getTextMapElement(secondElementIndex).parentElement(), section, manager.indexOf(manager.getTextMapElement(secondElementIndex))));
                        }
                        else {
newTreeItem(manager.getTextMapElement(secondElementIndex), treeIndex, 1);
@@ -492,7 +516,7 @@
                if(isHeading(t)){
                        tree.removeAll();
                        setRoot(manager.getDocument().getRootElement());
-                       TreeItem item = findRange(manager.indexOf(t));
+                       TreeItem item = findRange(manager.getSection(t), 
manager.indexOf(t));

                        tree.setSelection(item);

=======================================
--- /src/main/org/brailleblaster/perspectives/braille/views/tree/XMLTree.java Wed Apr 16 22:06:34 2014 UTC +++ /src/main/org/brailleblaster/perspectives/braille/views/tree/XMLTree.java Thu Jul 3 16:07:57 2014 UTC
@@ -8,7 +8,7 @@
 import nu.xom.Text;

 import org.brailleblaster.perspectives.braille.Manager;
-import org.brailleblaster.perspectives.braille.mapping.TextMapElement;
+import org.brailleblaster.perspectives.braille.mapping.elements.TextMapElement;
 import org.brailleblaster.perspectives.braille.messages.Message;
 import org.brailleblaster.perspectives.braille.messages.Sender;
 import org.eclipse.swt.SWT;
@@ -233,7 +233,7 @@
                Elements els = e.getChildElements();

                for(int i = 0; i < els.size(); i++){
- if(!els.get(i).getLocalName().equals("pagenum") && !els.get(i).getLocalName().equals("brl") && !els.get(i).getAttributeValue("semantics").contains("skip")){ + if(!els.get(i).getLocalName().equals("pagenum") && !els.get(i).getLocalName().equals("brl") && manager.getDocument().checkAttribute(els.get(i), "semantics") && !els.get(i).getAttributeValue("semantics").contains("skip")){
                                TreeItem temp = new TreeItem(item, 0);
                                temp.setText(els.get(i).getLocalName());
                                TreeItemData data = new 
TreeItemData(els.get(i));
@@ -247,7 +247,7 @@
Message message = Message.createGetTextMapElementsMessage(textList, data.textMapList);
                                        manager.dispatch(message);
                                }
-
+
                                textList.clear();
                                temp.setData(data);
                        }
=======================================
--- /src/main/org/brailleblaster/perspectives/braille/views/wp/BrailleView.java Wed Apr 16 22:06:34 2014 UTC +++ /src/main/org/brailleblaster/perspectives/braille/views/wp/BrailleView.java Thu Jul 3 16:07:57 2014 UTC
@@ -41,9 +41,10 @@
 import org.brailleblaster.perspectives.braille.document.BBSemanticsTable;
import org.brailleblaster.perspectives.braille.document.BBSemanticsTable.Styles; import org.brailleblaster.perspectives.braille.document.BBSemanticsTable.StylesType;
-import org.brailleblaster.perspectives.braille.mapping.BrailleMapElement;
-import org.brailleblaster.perspectives.braille.mapping.MapList;
-import org.brailleblaster.perspectives.braille.mapping.TextMapElement;
+import org.brailleblaster.perspectives.braille.mapping.elements.BrailleMapElement; +import org.brailleblaster.perspectives.braille.mapping.elements.PageMapElement; +import org.brailleblaster.perspectives.braille.mapping.elements.TextMapElement;
+import org.brailleblaster.perspectives.braille.mapping.maps.MapList;
 import org.brailleblaster.perspectives.braille.messages.Message;
 import org.brailleblaster.perspectives.braille.messages.Sender;

@@ -191,6 +192,13 @@
                        @Override
                        public void widgetSelected(SelectionEvent e) {
                                checkStatusBar(Sender.BRAILLE);
+                               if(!getLock() & scrollBarPos != 
view.getVerticalBar().getSelection()){
+                                       scrollBarPos = 
view.getVerticalBar().getSelection();
+ if(view.getVerticalBar().getSelection() == (view.getVerticalBar().getMaximum() - view.getVerticalBar().getThumb()))
+                                               manager.incrementView();
+                                       else 
if(view.getVerticalBar().getSelection() == 0)
+                                               manager.decrementView();
+                               }
                        }
                });

@@ -200,7 +208,7 @@
                                checkStatusBar(Sender.BRAILLE);
                        }
                });
-
+               view.addModifyListener(viewMod);
                setListenerLock(false);
        }

@@ -239,6 +247,7 @@

        @Override
        public void removeListeners(){
+               view.removeModifyListener(viewMod);
                view.removeTraverseListener(traverseListener);
                view.removeVerifyKeyListener(verifyListener);
                view.removeFocusListener(focusListener);
@@ -275,6 +284,67 @@
                        this.pageRanges.add(list.get(i));
                }
        }
+
+       public void setBraille(TextMapElement t, MapList list, int index){
+               setListenerLock(true);
+               for(int i = 0; i < t.brailleList.size(); i++){
+ Styles style = stylesTable.makeStylesElement(t.parentElement(), t.brailleList.get(i).n);
+                       Styles prevStyle;
+                       if(list.size() > 1 && index != 0)
+ prevStyle = stylesTable.makeStylesElement(list.get(index - 1).parentElement(),list.get(index - 1).n);
+                       else
+                               prevStyle = null;
+
+                       String textBefore = "";
+                       String text = t.brailleList.get(i).n.getValue();
+                       int textLength = text.length();
+
+                       if(insertNewLine(t.brailleList.get(i).n)){
+                               textBefore = "\n";
+                               spaceBeforeText++;
+                       }
+
+                       view.append(textBefore + text);
+ handleStyle(prevStyle, style, t.brailleList.get(i).n, t.parentElement());
+
+ t.brailleList.get(i).setOffsets(spaceBeforeText + total, spaceBeforeText + total + textLength);
+                       total += spaceBeforeText + textLength + spaceAfterText;
+                       spaceBeforeText = 0;
+                       spaceAfterText = 0;
+               }
+               setListenerLock(false);
+       }
+
+       public void prependBraille(TextMapElement t, MapList list, int index){
+               setListenerLock(true);
+               for(int i = 0; i < t.brailleList.size(); i++){
+ Styles style = stylesTable.makeStylesElement(t.parentElement(), t.brailleList.get(i).n);
+                       Styles prevStyle;
+                       if(list.size() > 1 && index != 0)
+ prevStyle = stylesTable.makeStylesElement(list.get(index - 1).parentElement(),list.get(index - 1).n);
+                       else
+                               prevStyle = null;
+
+                       String textBefore = "";
+                       String text = t.brailleList.get(i).n.getValue();
+                       int textLength = text.length();
+
+                       if(insertNewLine(t.brailleList.get(i).n)){
+                               textBefore = "\n";
+                               spaceBeforeText++;
+                       }
+
+                       view.insert(textBefore + text);
+ handleStyle(prevStyle, style, t.brailleList.get(i).n, t.parentElement());
+
+ t.brailleList.get(i).setOffsets(spaceBeforeText + total, spaceBeforeText + total + textLength);
+                       total += spaceBeforeText + textLength + spaceAfterText;
+                       spaceBeforeText = 0;
+                       spaceAfterText = 0;
+                       view.setCaretOffset(total);
+               }
+               setListenerLock(false);
+       }

        public void setBraille(MapList list, Node n, TextMapElement t){
                setListenerLock(true);
@@ -867,12 +937,18 @@
        }

        @Override
-       public void addPageNumber(MapList list, Node node) {
-               String text = node.getValue();
-               view.append("\n" + text);
+       public void addPageNumber(PageMapElement p, boolean insert) {
+               String text = p.brailleNode.getValue();
+
                spaceBeforeText++;
+               if(insert){
+                       view.insert("\n" + text);
+                       view.setCaretOffset(spaceBeforeText + text.length() + 
total);
+               }
+               else
+                       view.append("\n" + text);

- list.getLastPage().setBraillePage(spaceBeforeText + total, spaceBeforeText + total + text.length(), node); + p.setBrailleOffsets(spaceBeforeText + total, spaceBeforeText + total + text.length());
                total += spaceBeforeText + text.length();
                spaceBeforeText = 0;
        }
=======================================
--- /src/main/org/brailleblaster/perspectives/braille/views/wp/TextView.java Tue Jun 10 14:54:43 2014 UTC +++ /src/main/org/brailleblaster/perspectives/braille/views/wp/TextView.java Thu Jul 3 16:07:57 2014 UTC
@@ -42,9 +42,9 @@
 import org.brailleblaster.perspectives.braille.document.BBSemanticsTable;
import org.brailleblaster.perspectives.braille.document.BBSemanticsTable.Styles; import org.brailleblaster.perspectives.braille.document.BBSemanticsTable.StylesType;
-import org.brailleblaster.perspectives.braille.mapping.MapList;
-import org.brailleblaster.perspectives.braille.mapping.PageMapElement;
-import org.brailleblaster.perspectives.braille.mapping.TextMapElement;
+import org.brailleblaster.perspectives.braille.mapping.elements.PageMapElement; +import org.brailleblaster.perspectives.braille.mapping.elements.TextMapElement;
+import org.brailleblaster.perspectives.braille.mapping.maps.MapList;
 import org.brailleblaster.perspectives.braille.messages.Message;
 import org.brailleblaster.perspectives.braille.messages.Sender;
 import org.brailleblaster.util.Notify;
@@ -180,11 +180,11 @@
                                                Message m;
int origLength = getString(currentStart, view.getCaretOffset() - currentStart).length();
                                                if(view.getCaretOffset() == 
currentEnd)
-                                                       m = 
Message.createInsertNodeMessage(true, false, true,"p");
+                                                       m = 
Message.createInsertNodeMessage(true, false, true, "p");
                                                else if(view.getCaretOffset() 
== currentStart)
-                                                       m = 
Message.createInsertNodeMessage(true, true, false,"p");
+                                                       m = 
Message.createInsertNodeMessage(true, true, false, "p");
                                                else
-                                                       m = 
Message.createInsertNodeMessage(true, false, false,"p");
+                                                       m = 
Message.createInsertNodeMessage(true, false, false, "p");

                                                m.put("originalLength", 
origLength);
                                                m.put("length", originalEnd - 
originalStart);
@@ -228,8 +228,7 @@
                                        e.doit = false;
else if((e.keyCode == SWT.DEL && manager.inPrintPageRange(view.getCaretOffset())) || (selectionLength <= 0 && e.keyCode == SWT.DEL && manager.inPrintPageRange(view.getCaretOffset() + 1)))
                                        e.doit = false;
-
-
+
                                if(selectionLength > 0)
                                        saveStyleState(selectionStart);
                                else
@@ -345,6 +344,14 @@
                        @Override
                        public void widgetSelected(SelectionEvent e) {
                                checkStatusBar(Sender.TEXT);
+
+                               if(!getLock() & scrollBarPos != 
view.getVerticalBar().getSelection()){
+                                       scrollBarPos = 
view.getVerticalBar().getSelection();
+ if(view.getVerticalBar().getSelection() == (view.getVerticalBar().getMaximum() - view.getVerticalBar().getThumb()))
+                                               manager.incrementView();
+                                       else 
if(view.getVerticalBar().getSelection() == 0)
+                                               manager.decrementView();
+                               }
                        }
                });

@@ -412,13 +419,14 @@
                                checkStatusBar(Sender.TEXT);
                        }
                });
-
+               view.addModifyListener(viewMod);
                setListenerLock(false);
        }

        @Override
        public void removeListeners(){
                if(selectionListener != null) {
+                       view.removeModifyListener(viewMod);
                        view.removeSelectionListener(selectionListener);
                        view.removeExtendedModifyListener(modListener);
                        view.removeTraverseListener(traverseListener);
@@ -537,9 +545,8 @@
                originalStart = currentStart;
                originalEnd = currentEnd;

-               if(currentStart < view.getCharCount()){
+               if(currentStart < view.getCharCount())
                        range = getStyleRange();
-               }

                currentElement = 
(TextMapElement)message.getValue("currentElement");
                
sendStatusBarUpdate(view.getLineAtOffset(view.getCaretOffset()));
@@ -570,31 +577,55 @@
                if(offset < currentStart || offset > currentEnd)
                        setCurrent(view.getCaretOffset());
        }
-
-       public void setText(Node n, MapList list){
-               Styles style = 
stylesTable.makeStylesElement((Element)n.getParent(), n);
+
+       public void setText(TextMapElement t, MapList list, int index){
+               Styles style = stylesTable.makeStylesElement(t.parentElement(), 
t.n);
                Styles prevStyle;
-               if(list.size() > 0)
- prevStyle = stylesTable.makeStylesElement(list.getLast().parentElement(),list.getLast().n);
+               if(list.size() > 0 && index != 0)
+ prevStyle = stylesTable.makeStylesElement(list.get(index - 1).parentElement(), list.get(index - 1).n);
                else
                        prevStyle = null;

-               String newText = appendToView(n, true);
+               String newText = appendToView(t.n, true);
                int textLength = newText.length();

                view.append(newText);
-               handleStyle(prevStyle, style, n, newText);
+               handleStyle(prevStyle, style, t.n, newText);

- list.add(new TextMapElement(spaceBeforeText + total, spaceBeforeText + total + textLength,n)); + t.setOffsets(spaceBeforeText + total, spaceBeforeText + total + textLength);
                total += spaceBeforeText + textLength + spaceAfterText;

                spaceAfterText = 0;
                spaceBeforeText = 0;
                view.setCaretOffset(0);
-               words += getWordCount(n.getValue());
+               words += getWordCount(t.getText());
        }

-       public void setMathML(MapList list, Element math){
+       public void prependText(TextMapElement t, MapList list, int index){
+               Styles style = stylesTable.makeStylesElement(t.parentElement(), 
t.n);
+               Styles prevStyle;
+               if(list.size() > 0 && index != 0)
+ prevStyle = stylesTable.makeStylesElement(list.get(index - 1).parentElement(), list.get(index - 1).n);
+               else
+                       prevStyle = null;
+
+               String newText = insertToView(t.n, true);
+               int textLength = newText.length();
+
+               view.insert(newText);
+               handleStyle(prevStyle, style, t.n, newText);
+
+ t.setOffsets(spaceBeforeText + total, spaceBeforeText + total + textLength);
+               total += spaceBeforeText + textLength + spaceAfterText;
+
+               spaceAfterText = 0;
+               spaceBeforeText = 0;
+               view.setCaretOffset(total);
+               words += getWordCount(t.getText());
+       }
+
+       public void setMathML(MapList list, TextMapElement t){
+               Element math = (Element)t.n;
Styles style = stylesTable.makeStylesElement((Element)math.getParent(), math);
                Styles prevStyle;
                int length = 1;
@@ -624,6 +655,7 @@

Image image = ImageCreator.createImage(view.getDisplay(), math, getFontHeight());
                view.append(" ");
+
                setImageStyleRange(image, total, length);
                handleStyle(prevStyle, style, math, " ");

@@ -637,11 +669,74 @@
                                length++;
                        }
                }
+
+               StyleRange s = view.getStyleRangeAtOffset(spaceBeforeText + 
total);
+               setFontStyleRange(s.start, length, s);
+
+ t.setOffsets(spaceBeforeText + total, spaceBeforeText + (total + length) + spaceAfterText);
+               total += spaceBeforeText + length + spaceAfterText;
+               spaceAfterText = 0;
+               spaceBeforeText = 0;
+       }
+
+       public void prependMathML(MapList list, TextMapElement t){
+               Element math = (Element)t.n;
+ Styles style = stylesTable.makeStylesElement((Element)math.getParent(), math);
+               Styles prevStyle;
+               int length = 1;
+
+               if(list.size() > 0)
+ prevStyle = stylesTable.makeStylesElement(list.getLast().parentElement(),list.getLast().n);
+               else
+                       prevStyle = null;
+
+               int index = math.getParent().indexOf(math);
+               Element brl = (Element)math.getParent().getChild(index + 1);
+
+               if(brl.getChild(0) instanceof Element){
+                       
if(((Element)brl.getChild(0)).getLocalName().equals("newpage")){
+ if(brl.getChild(1) instanceof Element && ((Element)brl.getChild(1)).getLocalName().equals("newline")){
+                                       view.insert("\n");
+                                       total++;
+                                       view.setCaretOffset(total);
+                               }
+                       }
+                       else {
+                               
if(((Element)brl.getChild(0)).getLocalName().equals("newline")){
+                                       view.insert("\n");
+                                       total++;
+                                       view.setCaretOffset(total);
+                               }
+                       }
+               }
+
+ Image image = ImageCreator.createImage(view.getDisplay(), math, getFontHeight());
+               view.insert(" ");
+               view.setCaretOffset(total + 1);
+
+               setImageStyleRange(image, total, length);
+               handleStyle(prevStyle, style, math, " ");
+
+               if(spaceBeforeText > 0)
+                       view.setCaretOffset(view.getCaretOffset() + 
spaceBeforeText);
+
+               for(int i = 1; i < brl.getChildCount(); i++){
+ if(i == 1 && brl.getChild(i) instanceof Element && ((Element)brl.getChild(i)).getLocalName().equals("newline") && !(brl.getChild(0) instanceof Element)){
+                               view.insert("\n");
+                               length++;
+                               view.setCaretOffset(view.getCaretOffset() + 1);
+                       }
+ else if(i > 1 && brl.getChild(i) instanceof Element && ((Element)brl.getChild(i)).getLocalName().equals("newline")){
+                               view.insert("\n");
+                               length++;
+                               view.setCaretOffset(view.getCaretOffset() + 1);
+                       }
+               }

                StyleRange s = view.getStyleRangeAtOffset(spaceBeforeText + 
total);
                setFontStyleRange(s.start, length, s);

- list.add(new TextMapElement(spaceBeforeText + total, spaceBeforeText + (total + length) + spaceAfterText, math)); + t.setOffsets(spaceBeforeText + total, spaceBeforeText + (total + length) + spaceAfterText);
                total += spaceBeforeText + length + spaceAfterText;
                spaceAfterText = 0;
                spaceBeforeText = 0;
@@ -800,6 +895,93 @@
                                        text.append(n.getValue());
                                        spaceBeforeText++;
                                }
+                               else {
+                                       text.append(n.getValue());
+                               }
+                       }
+                       else {
+                               text.append(n.getValue());
+                       }
+               }
+               catch(StringIndexOutOfBoundsException e){
+ new Notify("An error occured while translating. Be aware the this may affect cursor accurarcy and other translations in the document. The document is most likely not be suitable for editing. Check the logs for details"); + logger.log(Level.SEVERE, "Index Error:\t" + n.getParent().toXML().toString(), e);
+                       text.append(n.getValue().substring(start));
+               }
+
+               return text.toString();
+       }
+
+       private String insertToView(Node n, boolean append){
+               StringBuilder text = new StringBuilder();
+               Element brl = getBrlNode(n);
+               int start = 0;
+               int end = 0;
+               int totalLength = 0;
+
+               try {
+                       if(brl != null){
+                               int[] indexes = getIndexArray(brl);
+                               if(indexes != null){
+                                       for(int i = 0; i < brl.getChildCount(); 
i++){
+                                               if(isText(brl.getChild(i))){
+ if(i > 0 && ((Element)brl.getChild(i - 1)).getLocalName().equals("newline")){
+                                                               String brltext 
= brl.getChild(i).getValue();
+                                                               totalLength += 
brltext.length();
+                                                               end = 
indexes[totalLength - 1];
+                                                               if(totalLength 
== indexes.length){
+                                                                       if(start == 0 
&& append){
+                                                                               
view.insert("\n");
+                                                                               
text.append(n.getValue().substring(start));
+                                                                               
spaceBeforeText++;
+                                                                               
view.setCaretOffset(view.getCaretOffset() + 1);
+                                                                       }
+                                                                       else 
if(start == 0){
+                                                                               
text.append(n.getValue().substring(start));
+                                                                       }
+                                                                       else {
+                                                                               
text.append("\n" + n.getValue().substring(start));
+                                                                       }
+                                                               }
+                                                               else{
+                                                                   end += 
indexes[totalLength] - end;
+                                                                       if(start == 0 
&& append){
+                                                                               
view.insert("\n");
+                                                                               
text.append(n.getValue().substring(start, end));
+                                                                               
spaceBeforeText++;
+                                                                               
view.setCaretOffset(view.getCaretOffset() + 1);
+                                                                       }
+                                                                       else 
if(start == 0){
+                                                                               
text.append(n.getValue().substring(start, end));
+                                                                       }
+                                                                       else{
+                                                                               
text.append("\n" + n.getValue().substring(start, end));
+                                                                       }
+                                                               }
+                                                               start = end;
+                                                       }
+                                                       else {
+                                                               String brltext 
= brl.getChild(i).getValue();
+                                                               totalLength += 
brltext.length();
+                                                               end = 
indexes[totalLength - 1];
+                                                               if(totalLength 
== indexes.length){
+                                                                       
text.append(n.getValue().substring(start));
+                                                               }
+                                                               else{
+                                                                       end += 
indexes[totalLength] - end;
+                                                                       
text.append(n.getValue().substring(start, end));
+                                                               }
+                                                               start = end;
+                                                       }
+                                               }
+                                       }
+                               }
+                               else if(append){
+                                       view.insert("\n");
+                                       text.append(n.getValue());
+                                       spaceBeforeText++;
+                                       
view.setCaretOffset(view.getCaretOffset() + 1);
+                               }
                                else {
                                        text.append(n.getValue());
                                }
@@ -1541,13 +1723,19 @@
        }

        @Override
-       public void addPageNumber(MapList list, Node node){
-               String text = node.getValue();
+       public void addPageNumber(PageMapElement p, boolean insert){
+               String text = p.n.getValue();

-               view.append("\n" + text);
                spaceBeforeText++;

- list.addPrintPage(new PageMapElement(spaceBeforeText + total, spaceBeforeText + total + text.length(), node));
+               if(insert){
+                       view.insert("\n" + text);
+                       view.setCaretOffset(spaceBeforeText + text.length() + 
total);
+               }
+               else
+                       view.append("\n" + text);
+
+ p.setOffsets(spaceBeforeText + total, spaceBeforeText + total + text.length());
                total += spaceBeforeText + text.length();
                spaceBeforeText = 0;
        }
@@ -1564,4 +1752,10 @@
                textChanged = false;
                setListenerLock(false);
        }
+
+       public void resetOffsets(){
+ Message m = Message.createGetCurrentMessage(Sender.TEXT, view.getCaretOffset());
+               manager.dispatch(m);
+               setViewData(m);
+       }
 }
=======================================
--- /src/main/org/brailleblaster/perspectives/braille/views/wp/WPView.java Wed Apr 16 22:06:34 2014 UTC +++ /src/main/org/brailleblaster/perspectives/braille/views/wp/WPView.java Thu Jul 3 16:07:57 2014 UTC
@@ -9,7 +9,7 @@
 import org.brailleblaster.perspectives.braille.document.BBSemanticsTable;
import org.brailleblaster.perspectives.braille.document.BBSemanticsTable.Styles; import org.brailleblaster.perspectives.braille.document.BBSemanticsTable.StylesType;
-import org.brailleblaster.perspectives.braille.mapping.MapList;
+import org.brailleblaster.perspectives.braille.mapping.elements.PageMapElement;
 import org.brailleblaster.perspectives.braille.messages.Message;
 import org.brailleblaster.perspectives.braille.messages.Sender;
 import org.eclipse.swt.SWT;
@@ -28,9 +28,10 @@
        protected BBSemanticsTable stylesTable;
        protected static int currentAlignment;
        public static int currentLine;
-       protected static int topIndex;
+       protected static int topIndex, scrollBarPos;
        public StyledText view;
        protected int charWidth;
+       protected ModifyListener viewMod;

public WPView(Manager manager, Group group, int left, int right, int top, int bottom, BBSemanticsTable table){
                super(manager, group);
@@ -40,18 +41,17 @@
                this.stylesTable = table;
                view = new StyledText(group, SWT.BORDER | SWT.H_SCROLL | 
SWT.V_SCROLL);
                setLayout(view, left, right, top, bottom);
-               view.addModifyListener(viewMod);
+               // Better use a ModifyListener to set the change flag.
+               viewMod = new ModifyListener() {
+                       @Override
+                       public void modifyText(ModifyEvent e) {
+                               hasChanged = true;
+                       }
+               };
+               scrollBarPos = 0;
        }

-       // Better use a ModifyListener to set the change flag.
-       ModifyListener viewMod = new ModifyListener() {
-               @Override
-               public void modifyText(ModifyEvent e) {
-                       hasChanged = true;
-               }
-       };
-
-       public abstract void addPageNumber(MapList list, Node node);
+       public abstract void addPageNumber(PageMapElement p, boolean insert);
        @Override
        protected abstract void setViewData(Message message);

@@ -154,6 +154,7 @@
                        return null;
                }
        }
+
//saves alignment, used when updating text since alignment info is removed with previous text is deleted and new translation is inserted
        protected void saveStyleState(int start){
                int line = this.view.getLineAtOffset(start);
@@ -321,4 +322,8 @@
                setLayout(view, left, right, top, bottom);
                view.getParent().layout();
        }
+
+       public int getTotal(){
+               return total;
+       }
 }

==============================================================================
Revision: 278434910539
Branch:   default
Author:   Brandon Roller <brandon.r.roller@xxxxxxxxx>
Date:     Thu Jul  3 16:14:22 2014 UTC
Log:      Merged branches
http://code.google.com/p/brailleblaster/source/detail?r=278434910539

Modified:
 /src/main/org/brailleblaster/perspectives/braille/Manager.java
 /src/main/org/brailleblaster/perspectives/braille/views/wp/BrailleView.java
 /src/main/org/brailleblaster/perspectives/braille/views/wp/TextView.java

=======================================
--- /src/main/org/brailleblaster/perspectives/braille/Manager.java Thu Jul 3 16:07:57 2014 UTC +++ /src/main/org/brailleblaster/perspectives/braille/Manager.java Thu Jul 3 16:14:22 2014 UTC
@@ -76,7 +76,6 @@
 import org.brailleblaster.printers.PrintersManager;
 import org.brailleblaster.util.Notify;
 import org.brailleblaster.util.PropertyFileManager;
-import org.brailleblaster.util.YesNoChoice;
 import org.brailleblaster.wordprocessor.BBFileDialog;
 import org.brailleblaster.wordprocessor.BBStatusBar;
 import org.brailleblaster.wordprocessor.FontManager;
@@ -330,6 +329,26 @@
                }
        }

+                               //Added to handle brl for side bar
+ if (((Element)current.getChild(i).getParent()).getLocalName().equals("sidebar"))
+                               {
+ text.setBRLOnlyText(list, "\n",((Element)current.getChild(i).getParent()));
+                                       
braille.setBRLOnlyBraille(list,current.getChild(i));
+
+
+                               }
+                               else
+                               {
+                                       initializeBraille(current.getChild(i), 
list.getLast());
+                               }
+                       }
+
+                       //Added this part for side bar
+ else if(current.getChild(i) instanceof Element && ((Element)current.getChild(i)).getLocalName().equals("sidebar")){
+                                    initializeViews(current.getChild(i));
+
+
+                       }
        public void dispatch(Message message){
                switch(message.type){
                        case INCREMENT:
@@ -877,12 +896,6 @@

        @Override
        public void close() {
- if (!BBIni.debugging() && (text.hasChanged || braille.hasChanged || arch.getDocumentEdited())) {
-                       YesNoChoice ync = new 
YesNoChoice(lh.localValue("hasChanged"));
-                       if (ync.result == SWT.YES) {
-                               fileSave();
-                       }
-               }
                dispose();
                item.dispose();
                fontManager.disposeFonts();
@@ -1467,4 +1480,9 @@
                        sm.getStyleTable().getTable().setFocus();
                }
        }
+       }
+
+       @Override
+       public boolean documentHasBeenEdited(){
+               return text.hasChanged || braille.hasChanged || 
arch.getDocumentEdited();
 }
=======================================
--- /src/main/org/brailleblaster/perspectives/braille/views/wp/BrailleView.java Thu Jul 3 16:07:57 2014 UTC +++ /src/main/org/brailleblaster/perspectives/braille/views/wp/BrailleView.java Thu Jul 3 16:14:22 2014 UTC
@@ -42,12 +42,11 @@
import org.brailleblaster.perspectives.braille.document.BBSemanticsTable.Styles; import org.brailleblaster.perspectives.braille.document.BBSemanticsTable.StylesType; import org.brailleblaster.perspectives.braille.mapping.elements.BrailleMapElement; -import org.brailleblaster.perspectives.braille.mapping.elements.PageMapElement;
+import org.brailleblaster.perspectives.braille.mapping.BrlOnlyMapElement;
import org.brailleblaster.perspectives.braille.mapping.elements.TextMapElement;
 import org.brailleblaster.perspectives.braille.mapping.maps.MapList;
 import org.brailleblaster.perspectives.braille.messages.Message;
 import org.brailleblaster.perspectives.braille.messages.Sender;
-
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.custom.CaretEvent;
 import org.eclipse.swt.custom.CaretListener;
@@ -350,7 +349,7 @@
                setListenerLock(true);
                Styles style = stylesTable.makeStylesElement(t.parentElement(), 
n);
                Styles prevStyle;
-               if(list.size() > 1)
+               if(list.size() > 1 && list.get(list.size() - 2).n!=null)
prevStyle = stylesTable.makeStylesElement(list.get(list.size() - 2).parentElement(),list.get(list.size() - 2).n);
                else
                        prevStyle = null;
@@ -952,4 +951,13 @@
                total += spaceBeforeText + text.length();
                spaceBeforeText = 0;
        }
+
+       public void setBRLOnlyBraille(MapList list, Node child) {
+               String brailleSidebar="\n"+child.getValue();
+               view.append(brailleSidebar);
+ list.getLast().brailleList.add(new BrailleMapElement(total, total + brailleSidebar.length(), child));
+               total += brailleSidebar.length();
+
+
+       }
 }
=======================================
--- /src/main/org/brailleblaster/perspectives/braille/views/wp/TextView.java Thu Jul 3 16:07:57 2014 UTC +++ /src/main/org/brailleblaster/perspectives/braille/views/wp/TextView.java Thu Jul 3 16:14:22 2014 UTC
@@ -42,9 +42,10 @@
 import org.brailleblaster.perspectives.braille.document.BBSemanticsTable;
import org.brailleblaster.perspectives.braille.document.BBSemanticsTable.Styles; import org.brailleblaster.perspectives.braille.document.BBSemanticsTable.StylesType; -import org.brailleblaster.perspectives.braille.mapping.elements.PageMapElement; -import org.brailleblaster.perspectives.braille.mapping.elements.TextMapElement;
-import org.brailleblaster.perspectives.braille.mapping.maps.MapList;
+import org.brailleblaster.perspectives.braille.mapping.BrlOnlyMapElement;
+import org.brailleblaster.perspectives.braille.mapping.MapList;
+import org.brailleblaster.perspectives.braille.mapping.PageMapElement;
+import org.brailleblaster.perspectives.braille.mapping.TextMapElement;
 import org.brailleblaster.perspectives.braille.messages.Message;
 import org.brailleblaster.perspectives.braille.messages.Sender;
 import org.brailleblaster.util.Notify;
@@ -581,7 +582,7 @@
        public void setText(TextMapElement t, MapList list, int index){
                Styles style = stylesTable.makeStylesElement(t.parentElement(), 
t.n);
                Styles prevStyle;
-               if(list.size() > 0 && index != 0)
+               if(list.size() > 0 && index != 0 && list.getLast().n != null)
prevStyle = stylesTable.makeStylesElement(list.get(index - 1).parentElement(), list.get(index - 1).n);
                else
                        prevStyle = null;
@@ -1758,4 +1759,12 @@
                manager.dispatch(m);
                setViewData(m);
        }
+
+       public void setBRLOnlyText(MapList list, String text, Element element) {
+               view.append(text);
+ list.add(new BrlOnlyMapElement(total, total + text.length(), null,element));
+               total += text.length();
+
+       }
+
 }

==============================================================================
Revision: 6abde6d6b9f4
Branch:   default
Author:   Brandon Roller <brandon.r.roller@xxxxxxxxx>
Date:     Thu Jul  3 18:02:55 2014 UTC
Log:      Fixed issues with merge
http://code.google.com/p/brailleblaster/source/detail?r=6abde6d6b9f4

Modified:
 /src/main/org/brailleblaster/perspectives/braille/Manager.java
/src/main/org/brailleblaster/perspectives/braille/mapping/BrlOnlyMapElement.java /src/main/org/brailleblaster/perspectives/braille/mapping/elements/SectionElement.java /src/main/org/brailleblaster/perspectives/braille/viewInitializer/ViewInitializer.java /src/main/org/brailleblaster/perspectives/braille/viewInitializer/WebInitializer.java
 /src/main/org/brailleblaster/perspectives/braille/views/wp/BrailleView.java
 /src/main/org/brailleblaster/perspectives/braille/views/wp/TextView.java

=======================================
--- /src/main/org/brailleblaster/perspectives/braille/Manager.java Thu Jul 3 16:14:22 2014 UTC +++ /src/main/org/brailleblaster/perspectives/braille/Manager.java Thu Jul 3 18:02:55 2014 UTC
@@ -329,26 +329,6 @@
                }
        }

-                               //Added to handle brl for side bar
- if (((Element)current.getChild(i).getParent()).getLocalName().equals("sidebar"))
-                               {
- text.setBRLOnlyText(list, "\n",((Element)current.getChild(i).getParent()));
-                                       
braille.setBRLOnlyBraille(list,current.getChild(i));
-
-
-                               }
-                               else
-                               {
-                                       initializeBraille(current.getChild(i), 
list.getLast());
-                               }
-                       }
-
-                       //Added this part for side bar
- else if(current.getChild(i) instanceof Element && ((Element)current.getChild(i)).getLocalName().equals("sidebar")){
-                                    initializeViews(current.getChild(i));
-
-
-                       }
        public void dispatch(Message message){
                switch(message.type){
                        case INCREMENT:
@@ -1479,10 +1459,10 @@
                        e.doit = false;
                        sm.getStyleTable().getTable().setFocus();
                }
-       }
        }

        @Override
        public boolean documentHasBeenEdited(){
                return text.hasChanged || braille.hasChanged || 
arch.getDocumentEdited();
+       }
 }
=======================================
--- /src/main/org/brailleblaster/perspectives/braille/mapping/BrlOnlyMapElement.java Tue Jul 1 19:25:42 2014 UTC +++ /src/main/org/brailleblaster/perspectives/braille/mapping/BrlOnlyMapElement.java Thu Jul 3 18:02:55 2014 UTC
@@ -1,5 +1,7 @@
 package org.brailleblaster.perspectives.braille.mapping;

+import org.brailleblaster.perspectives.braille.mapping.elements.TextMapElement;
+
 import nu.xom.Element;
 import nu.xom.Node;

=======================================
--- /src/main/org/brailleblaster/perspectives/braille/mapping/elements/SectionElement.java Thu Jul 3 16:07:57 2014 UTC +++ /src/main/org/brailleblaster/perspectives/braille/mapping/elements/SectionElement.java Thu Jul 3 18:02:55 2014 UTC
@@ -40,7 +40,16 @@
                                break;
                        }
else if(current.getChild(i) instanceof Element && ((Element)current.getChild(i)).getLocalName().equals("brl")){
-                               initializeBraille(m, current.getChild(i), 
list.getLast());
+                               //Added to handle brl for side bar
+ if (((Element)current.getChild(i).getParent()).getLocalName().equals("sidebar"))
+                               {
+ //text.setBRLOnlyText(list, "\n",((Element)current.getChild(i).getParent()));
+                                       
//braille.setBRLOnlyBraille(list,current.getChild(i));
+                               }
+                               else
+                               {
+                                       initializeBraille(m, 
current.getChild(i), list.getLast());
+                               }
                        }
else if(current.getChild(i) instanceof Element && ((Element)current.getChild(i)).getLocalName().equals("math")){
                                //if math is empty skip next brl element
@@ -49,6 +58,10 @@
                                else
                                        i++;
                        }
+                       //Added this part for side bar
+ else if(current.getChild(i) instanceof Element && ((Element)current.getChild(i)).getLocalName().equals("sidebar")){
+                                    initializeViews(current.getChild(i), m, 0);
+                       }
                        else {
                                if(current.getChild(i) instanceof Element){
                                        
if(((Element)current.getChild(i)).getLocalName().equals("pagenum")){
=======================================
--- /src/main/org/brailleblaster/perspectives/braille/viewInitializer/ViewInitializer.java Thu Jul 3 16:07:57 2014 UTC +++ /src/main/org/brailleblaster/perspectives/braille/viewInitializer/ViewInitializer.java Thu Jul 3 18:02:55 2014 UTC
@@ -324,7 +324,7 @@
                        list.getPage(i).listIndex = list.getPage(i).index;
                }
        }
-
+       /*
        private int findStart(MapList list){
if(list.getPageCount() == 0 || list.getPage(0).start > list.getFirst().start)
                        return list.getFirst().start;
@@ -332,19 +332,20 @@
                        return list.getPage(0).start;
        }

+       private int findBrailleStart(MapList list){
+ if(list.getPageCount() == 0 || list.getPage(0).brailleStart > list.getFirst().brailleList.getFirst().start)
+                       return  list.getFirst().brailleList.getFirst().start;
+               else
+                       return list.getPage(0).brailleStart;
+       }
+       */
+
        private int findEnd(MapList list){
if(list.getPageCount() == 0 || list.getLastPage().end < list.getLast().end)
                        return list.getLast().end;
                else
                        return list.getLastPage().end;
        }
-
-       private int findBrailleStart(MapList list){
- if(list.getPageCount() == 0 || list.getPage(0).brailleStart > list.getFirst().brailleList.getFirst().start)
-                       return  list.getFirst().brailleList.getFirst().start;
-               else
-                       return list.getPage(0).brailleStart;
-       }

        private int findBrailleEnd(MapList list){
if(list.getPageCount() == 0 || list.getLastPage().brailleEnd < list.getLast().brailleList.getLast().end)
=======================================
--- /src/main/org/brailleblaster/perspectives/braille/viewInitializer/WebInitializer.java Thu Jul 3 16:07:57 2014 UTC +++ /src/main/org/brailleblaster/perspectives/braille/viewInitializer/WebInitializer.java Thu Jul 3 18:02:55 2014 UTC
@@ -91,7 +91,7 @@
                }
                else {
Element p = new Element("p", document.getRootElement().getNamespaceURI()); - SemanticFileHandler sfh = new SemanticFileHandler(m.getArchvier().getCurrentConfig()); + SemanticFileHandler sfh = new SemanticFileHandler(m.getArchiver().getCurrentConfig()); p.addAttribute(new Attribute("semantics","styles," + sfh.getDefault("p")));
                        p.appendChild(new Text(""));
                        ((Element)n.get(0)).appendChild(p);
=======================================
--- /src/main/org/brailleblaster/perspectives/braille/views/wp/BrailleView.java Thu Jul 3 16:14:22 2014 UTC +++ /src/main/org/brailleblaster/perspectives/braille/views/wp/BrailleView.java Thu Jul 3 18:02:55 2014 UTC
@@ -42,6 +42,7 @@
import org.brailleblaster.perspectives.braille.document.BBSemanticsTable.Styles; import org.brailleblaster.perspectives.braille.document.BBSemanticsTable.StylesType; import org.brailleblaster.perspectives.braille.mapping.elements.BrailleMapElement; +import org.brailleblaster.perspectives.braille.mapping.elements.PageMapElement;
 import org.brailleblaster.perspectives.braille.mapping.BrlOnlyMapElement;
import org.brailleblaster.perspectives.braille.mapping.elements.TextMapElement;
 import org.brailleblaster.perspectives.braille.mapping.maps.MapList;
@@ -289,7 +290,7 @@
                for(int i = 0; i < t.brailleList.size(); i++){
Styles style = stylesTable.makeStylesElement(t.parentElement(), t.brailleList.get(i).n);
                        Styles prevStyle;
-                       if(list.size() > 1 && index != 0)
+                       if(list.size() > 1 && index != 0 &&  list.get(index - 
1).n!=null)
prevStyle = stylesTable.makeStylesElement(list.get(index - 1).parentElement(),list.get(index - 1).n);
                        else
                                prevStyle = null;
@@ -957,7 +958,5 @@
                view.append(brailleSidebar);
list.getLast().brailleList.add(new BrailleMapElement(total, total + brailleSidebar.length(), child));
                total += brailleSidebar.length();
-
-
        }
 }
=======================================
--- /src/main/org/brailleblaster/perspectives/braille/views/wp/TextView.java Thu Jul 3 16:14:22 2014 UTC +++ /src/main/org/brailleblaster/perspectives/braille/views/wp/TextView.java Thu Jul 3 18:02:55 2014 UTC
@@ -43,9 +43,9 @@
import org.brailleblaster.perspectives.braille.document.BBSemanticsTable.Styles; import org.brailleblaster.perspectives.braille.document.BBSemanticsTable.StylesType;
 import org.brailleblaster.perspectives.braille.mapping.BrlOnlyMapElement;
-import org.brailleblaster.perspectives.braille.mapping.MapList;
-import org.brailleblaster.perspectives.braille.mapping.PageMapElement;
-import org.brailleblaster.perspectives.braille.mapping.TextMapElement;
+import org.brailleblaster.perspectives.braille.mapping.maps.MapList;
+import org.brailleblaster.perspectives.braille.mapping.elements.PageMapElement; +import org.brailleblaster.perspectives.braille.mapping.elements.TextMapElement;
 import org.brailleblaster.perspectives.braille.messages.Message;
 import org.brailleblaster.perspectives.braille.messages.Sender;
 import org.brailleblaster.util.Notify;
@@ -582,7 +582,7 @@
        public void setText(TextMapElement t, MapList list, int index){
                Styles style = stylesTable.makeStylesElement(t.parentElement(), 
t.n);
                Styles prevStyle;
-               if(list.size() > 0 && index != 0 && list.getLast().n != null)
+               if(list.size() > 0 && index != 0 && list.get(index - 1).n != 
null)
prevStyle = stylesTable.makeStylesElement(list.get(index - 1).parentElement(), list.get(index - 1).n);
                else
                        prevStyle = null;
@@ -1764,7 +1764,5 @@
                view.append(text);
list.add(new BrlOnlyMapElement(total, total + text.length(), null,element));
                total += text.length();
-
        }
-
 }

Other related posts:

  • » [brailleblaster] 4 new revisions pushed by brandon....@xxxxxxxxx on 2014-07-03 18:04 GMT - brailleblaster