[brailleblaster] push by john.bo...@xxxxxxxxxxxxxxxxx - added newcode/Actions.java. on 2012-10-30 11:49 GMT

  • From: brailleblaster@xxxxxxxxxxxxxx
  • To: brailleblaster@xxxxxxxxxxxxx
  • Date: Tue, 30 Oct 2012 11:49:22 +0000

Revision: 62fb5ca651dd
Branch:   default
Author:   John Boyer <john.boyer@xxxxxxxxxxxxxxxxx>
Date:     Tue Oct 30 04:47:58 2012
Log:      added newcode/Actions.java.
http://code.google.com/p/brailleblaster/source/detail?r=62fb5ca651dd

Added:
 /src/main/org/brailleblaster/newcode/Actions.java
Modified:
 /src/main/org/brailleblaster/newcode/Semantics.java
 /src/main/org/brailleblaster/newcode/Styles.java

=======================================
--- /dev/null
+++ /src/main/org/brailleblaster/newcode/Actions.java Tue Oct 30 04:47:58 2012
@@ -0,0 +1,107 @@
+/* BrailleBlaster Braille Transcription Application
+  *
+  * Copyright (C) 2010, 2012
+  * ViewPlus Technologies, Inc. www.viewplus.com
+  * and
+  * Abilitiessoft, Inc. www.abilitiessoft.com
+  * and
+  * American Printing House for the Blind, Inc. www.aph.org
+  *
+  * All rights reserved
+  *
+  * This file may contain code borrowed from files produced by various
+  * Java development teams. These are gratefully acknoledged.
+  *
+  * 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 John J. Boyer john.boyer@xxxxxxxxxxxxxxxxx
+*/
+
+package newcode;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import nu.xom.Builder;
+import nu.xom.Node;
+import nu.xom.ParsingException;
+import nu.xom.Serializer;
+import nu.xom.Document;
+import nu.xom.Element;
+import nu.xom.Text;
+import nu.xom.Attribute;
+import org.brailleblaster.BBIni;
+import org.brailleblaster.localization.LocaleHandler;
+import org.brailleblaster.util.Notify;
+import org.brailleblaster.util.YesNoChoice;
+import java.util.Hashtable;
+
+/**
+ * This class contains the actions which can be performed on elements.
+ * They are distinct from styles.
+ */
+public class Actions {
+
+/**
+ * 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,
+  attrToText,
+  runningHead,
+  footer,
+  boxLine,
+  italic,
+  bold,
+  underline,
+  compbrl,
+  lineSpacing,
+  blankLine,
+  softReturn,
+  newPage,
+  brl,
+  music,
+  math,
+  chemistry,
+  graphic
+};
+
+/**
+ * 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.
+ */
+public boolean actionBeforeElement (Element element) {
+  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.
+ */
+public void actionAfterElement() {
+}
+
+}
=======================================
--- /src/main/org/brailleblaster/newcode/Semantics.java Mon Oct 29 14:29:31 2012 +++ /src/main/org/brailleblaster/newcode/Semantics.java Tue Oct 30 04:47:58 2012
@@ -61,37 +61,6 @@
  */
 public class Semantics {

-/**
- * 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,
-  attrToText,
-  runningHead,
-  footer,
-  boxLine,
-  italic,
-  bold,
-  underline,
-  compbrl,
-  lineSpacing,
-  blankLine,
-  softReturn,
-  newPage,
-  brl,
-  music,
-  math,
-  chemistry,
-  graphic
-};
-
  /**
  * This is an entry in the SemanticTable, which is used to control
  * displaying and editing.
@@ -101,7 +70,7 @@
   String operation;
   String operand;
   String parameters;
-  Action action;
+  Actions.Action action;
   Styles.StyleType style;
   String macro;
 }
=======================================
--- /src/main/org/brailleblaster/newcode/Styles.java Fri Oct 26 07:59:31 2012 +++ /src/main/org/brailleblaster/newcode/Styles.java Tue Oct 30 04:47:58 2012
@@ -32,6 +32,7 @@
 package newcode;

 import nu.xom.Element;
+
 /**
  * This class contains the data structures and mothods used for handling
  *styles.
@@ -43,7 +44,7 @@
  * correctly.<p>

  * <p>Note that BrailleBlaster styles deal with layout. Italic, bold,
- * etc. are dealt with by action methods in the Semantic class.</p>
+ * etc. are dealt with by action methods in the Semantics class.</p>
 */

 public class Styles {
@@ -77,6 +78,7 @@
   "contents9",
   "contents10"
   };
+
 /**
  * The different formats that can be applied to styles.
  */
@@ -94,7 +96,7 @@
 };

 /**
- * The status items mark the various stages in the procession of a
+ * The status items mark the various stages in the processing of a
  * style.
  */
 enum StyleStatus {
@@ -106,6 +108,9 @@
   afterBody,
 };

+/**
+  * This embedded class defines the various fields that specify a style.
+  */
 class StyleType {
   int linesBefore;
   int linesAfter;
@@ -120,7 +125,10 @@
   boolean newPageAfter;
 }

-class StyleRecord {
+/**
+ * An item on the style stack, which is used to handle nested styles.
+ */
+private class StyleRecord {
   StyleType style;
   StyleStatus status;
   StyleFormat curStyleFormat;
@@ -138,16 +146,30 @@
  * the stack will contain the table style, which is then completed by
  * endStyle.
  */
-StyleRecord[] stack = new StyleRecord[20];
+private StyleRecord[] stack = new StyleRecord[20];

+/**
+ * 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.
+ */
 public boolean startStyle (Element element) {
   return true;
 }

+/**
+ * Completes the processing of the styleRecord on the top of the stack
+ and pops it.
+ */
 public void endStyle () {
 }

-public void applyStyle (String style, String text) {
+/**
+ * During editing this method is called to add a new 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.
+ */
+public void applyStyle (String style, Element element) {
 }

 }

Other related posts:

  • » [brailleblaster] push by john.bo...@xxxxxxxxxxxxxxxxx - added newcode/Actions.java. on 2012-10-30 11:49 GMT - brailleblaster