[brailleblaster] [brailleblaster.newdesign] push by RandomCh...@xxxxxxxxx - More Describer Funcs on 2013-07-25 21:29 GMT

  • From: brailleblaster@xxxxxxxxxxxxxx
  • To: brailleblaster@xxxxxxxxxxxxx
  • Date: Thu, 25 Jul 2013 21:29:34 +0000

Revision: 93e55e58437a
Branch:   default
Author:   cmyers@xxxxxxxxxxxxxxxxx
Date:     Thu Jul 25 15:35:57 2013
Log:      More Describer Funcs
http://code.google.com/p/brailleblaster/source/detail?r=93e55e58437a&repo=newdesign

Modified:
 /src/main/org/brailleblaster/imagedescriber/ImageDescriber.java

=======================================
--- /src/main/org/brailleblaster/imagedescriber/ImageDescriber.java Thu Jul 25 14:00:58 2013 +++ /src/main/org/brailleblaster/imagedescriber/ImageDescriber.java Thu Jul 25 15:35:57 2013
@@ -62,7 +62,7 @@
                curElement = -1;

                // Fill list of <img>'s.
-               FillImgList(rootElement);
+               fillImgList(rootElement);

                // Get size of <img> list.
                numImgElms = imgList.size();
@@ -71,14 +71,20 @@
                if(numImgElms > 0)
                        curElement = 0;

-               for(int asdf = 0; asdf < numImgElms; asdf++)
-                       System.out.println( 
imgList.get(asdf).getAttributeValue("src") );
+               for( int asdf = 0; asdf < numImgElms; asdf++ ) {
+                       if( hasImgGrpParent(imgList.get(asdf)) == false) {
+                               wrapInImgGrp(imgList.get(asdf));
+ System.out.println( imgList.get(asdf).getLocalName() + " has been wrapped!" );
+//                     System.out.println( 
imgList.get(asdf).getAttribute("src") );
+                       }
+//                     imgList.get(asdf).getAttribute("src").setValue("Rubber 
Chicken");
+               }

        } // ImageDescriber(BBDocument document)

///////////////////////////////////////////////////////////////////////////
        // Searches forward in the xml tree for an element named <img>
-       public Element NextImageElement()
+       public Element nextImageElement()
        {
                // Make sure there are images.
                if(numImgElms == 0)
@@ -96,7 +102,7 @@

///////////////////////////////////////////////////////////////////////////
        // Searches backward in the xml tree for an element named <img>
-       public Element PrevImageElement()
+       public Element prevImageElement()
        {
                // Make sure there are images.
                if(numImgElms == 0)
@@ -114,7 +120,7 @@

///////////////////////////////////////////////////////////////////////////
        // Recursively moves through xml tree and adds <img> nodes to list.
-       public void FillImgList(Element e)
+       public void fillImgList(Element e)
        {
                // Is this element an <img>?
                if( e.getLocalName().compareTo("img") == 0 )
@@ -125,8 +131,40 @@

                // Get their children, and so on.
                for(int curChild = 0; curChild < childElms.size(); curChild++)
-                       FillImgList( childElms.get(curChild) );
+                       fillImgList( childElms.get(curChild) );

        } // FillImgList(Element e)
+
+ ///////////////////////////////////////////////////////////////////////////
+       // Returns true if the current image has an <imggroup> parent.
+       // False otherwise.
+       public boolean hasImgGrpParent(Element e)
+       {
+               // If the parent is <imggroup>, return true.
+ if( ((nu.xom.Element)(e.getParent())).getLocalName().compareTo("imggroup") == 0 )
+                       return true;
+               else
+                       return false;
+
+       } // HasImgGrpParent(Element e)
+
+ ///////////////////////////////////////////////////////////////////////////
+       // Encapsulates given element into <imggroup>, and adds
+       // <prodnote> in the group with it.
+       public void wrapInImgGrp(Element e)
+       {
+               // Create all elements.
+               Element imgGrpElm = new Element("imggroup");
+               Element prodElm = new Element("prodnote");
+               Element copyElm = (nu.xom.Element)e.copy();
+
+               // Arrange child hierarchy.
+               imgGrpElm.appendChild(prodElm);
+               imgGrpElm.appendChild(copyElm);
+
+               // Replace given element with this updated one.
+               e = imgGrpElm;
+
+       } // wrapInImgGrp(Element e)

 } // public class ImageDescriber {

Other related posts:

  • » [brailleblaster] [brailleblaster.newdesign] push by RandomCh...@xxxxxxxxx - More Describer Funcs on 2013-07-25 21:29 GMT - brailleblaster