3 new revisions: Revision: 6fab6c13215d Branch: default Author: Sahel "sahel.mastoureshgh@xxxxxxxxx" Date: Wed Jul 23 14:45:44 2014 UTC Log: Adding nimas template http://code.google.com/p/brailleblaster/source/detail?r=6fab6c13215d Revision: 62f6277f0a66 Branch: default Author: Sahel "sahel.mastoureshgh@xxxxxxxxx" Date: Thu Jul 24 19:01:54 2014 UTC Log: Change Nimas Archiver to return one Document at the time http://code.google.com/p/brailleblaster/source/detail?r=62f6277f0a66 Revision: 140c3de5cf05 Branch: default Author: Sahel "sahel.mastoureshgh@xxxxxxxxx" Date: Thu Jul 24 19:10:40 2014 UTC Log: Commited changes before merge http://code.google.com/p/brailleblaster/source/detail?r=140c3de5cf05 ============================================================================== Revision: 6fab6c13215d Branch: default Author: Sahel "sahel.mastoureshgh@xxxxxxxxx" Date: Wed Jul 23 14:45:44 2014 UTC Log: Adding nimas template http://code.google.com/p/brailleblaster/source/detail?r=6fab6c13215d Added: /dist/programData/xmlTemplates/nimasTemplate.xml Modified: /src/main/org/brailleblaster/perspectives/braille/Manager.java /src/main/org/brailleblaster/perspectives/braille/views/wp/TextView.java ======================================= --- /dev/null+++ /dist/programData/xmlTemplates/nimasTemplate.xml Wed Jul 23 14:45:44 2014 UTC
@@ -0,0 +1,19 @@+<!DOCTYPE dtbook PUBLIC "-//NISO//DTD dtbook 2005-3//EN" "http://www.daisy.org/z3986/2005/dtbook-2005-3.dtd";>
++<dtbook xmlns="http://www.daisy.org/z3986/2005/dtbook/"; version="2005-3" xml:lang="En-US">
+<head> +</head> +<book> + <frontmatter> + + </frontmatter> + + <bodymatter> + + </bodymatter> + + <rearmatter> + + </rearmatter> +</book> +</dtbook> =======================================--- /src/main/org/brailleblaster/perspectives/braille/Manager.java Thu Jul 17 20:03:48 2014 UTC +++ /src/main/org/brailleblaster/perspectives/braille/Manager.java Wed Jul 23 14:45:44 2014 UTC
@@ -1199,6 +1199,16 @@ else return null; } + /*** + * Return all elements that selected in text + * @param offset + * @return + */ + public ArrayList<TextMapElement> getElementSelected(int strat, int end){ + + return null; + + } public TextMapElement getElementInBrailleRange(int offset){ Message m = new Message(null); =======================================--- /src/main/org/brailleblaster/perspectives/braille/views/wp/TextView.java Mon Jul 21 19:30:53 2014 UTC +++ /src/main/org/brailleblaster/perspectives/braille/views/wp/TextView.java Wed Jul 23 14:45:44 2014 UTC
@@ -103,6 +103,8 @@ private PaintObjectListener paintObjListener; private int originalStart, originalEnd; private TextMapElement currentElement; + int startSelection; + int endSelection;public TextView (Manager manager, Group documentWindow, BBSemanticsTable table) { super (manager, documentWindow, LEFT_MARGIN, RIGHT_MARGIN, TOP_MARGIN, BOTTOM_MARGIN, table);
@@ -117,7 +119,15 @@ view.addSelectionListener(selectionListener = new SelectionAdapter(){ @Override public void widgetSelected(SelectionEvent e) { + selectionArray = view.getSelectionRanges(); + //Added this part for start and end of text selection + for (int i = 0; i < selectionArray.length-1; i++) { + startSelection=selectionArray[i]; + endSelection=selectionArray[i]+selectionArray[i+1]; + + System.out.println(startSelection+" "+endSelection); + } if(selectionArray[1] > 0){ setSelection(selectionArray[0], selectionArray[1]); currentChar = ' '; ============================================================================== Revision: 62f6277f0a66 Branch: default Author: Sahel "sahel.mastoureshgh@xxxxxxxxx" Date: Thu Jul 24 19:01:54 2014 UTC Log: Change Nimas Archiver to return one Document at the time http://code.google.com/p/brailleblaster/source/detail?r=62f6277f0a66 Modified: /src/main/org/brailleblaster/archiver/Archiver.java /src/main/org/brailleblaster/archiver/EPub3Archiver.java /src/main/org/brailleblaster/archiver/NimasArchiver.java /src/main/org/brailleblaster/perspectives/braille/Manager.java /src/main/org/brailleblaster/perspectives/braille/views/wp/TextView.java/src/main/org/brailleblaster/perspectives/imageDescriber/ImageDescriberController.java /src/main/org/brailleblaster/perspectives/imageDescriber/views/ImageDescriberView.java
/src/main/org/brailleblaster/perspectives/webView/WebViewController.java /src/main/org/brailleblaster/perspectives/webView/webViewBrowser.java =======================================--- /src/main/org/brailleblaster/archiver/Archiver.java Mon May 12 19:44:36 2014 UTC +++ /src/main/org/brailleblaster/archiver/Archiver.java Thu Jul 24 19:01:54 2014 UTC
@@ -32,12 +32,24 @@ import java.io.FileInputStream; import java.io.IOException; +import java.util.ArrayList; import java.util.Properties; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +import nu.xom.converters.DOMConverter; + import org.brailleblaster.BBIni; import org.brailleblaster.document.BBDocument; import org.brailleblaster.util.FileUtils; import org.brailleblaster.util.Notify; +import org.brailleblaster.util.Zipper; +import org.w3c.dom.DOMImplementation; +import org.w3c.dom.Document; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.NodeList;//////////////////////////////////////////////////////////////////////////////////
// Archiver gives methods for opening/handling particular document types. @@ -54,6 +66,26 @@ protected String currentConfig; protected boolean documentEdited; + + protected String opfFilePath = null; + protected Document opfDoc = null; + protected ArrayList<String> spineList = null; + NodeList manifestElements; + NodeList spineElements; + + // Every file that makes our epub doc. + ArrayList<String> epubFileList = null; + + // Number of images in each file that makes up our document.+ // For every spine element we have, we're going to count the number of images
+ // in that file. This helps with image traversal. + ArrayList<Integer> numImages = null; + + // Index of current file we're looking at in the browser. + // Current file we're to load using the spine as a reference. + // Spine is in .opf file in epub. + int curSpineFileIdx = 0; +//////////////////////////////////////////////////////////////////////////////////
// Constructor. Stores path to document to prepare. Archiver(String docToPrepare) @@ -63,6 +95,9 @@ workingDocPath = originalDocPath; zippedPath = ""; documentEdited = false; + opfFilePath = null; + epubFileList = new ArrayList<String>(); + numImages = new ArrayList<Integer>(); } // Get-er for original document path. @@ -94,6 +129,7 @@ // // Appropriate strings to pass so far are: epub, nimas, public String getAutoCfg(String settingStr) { + // Init and load properties. Properties props = new Properties(); try { @@ -111,8 +147,10 @@ // If we made it here, there was no setting by that name. return null; + } // getAutoCfg() + // lic void copySemanticsFile(String public void copySemanticsFile(String tempSemFile, String savedFilePath) { FileUtils fu = new FileUtils(); @@ -140,4 +178,306 @@ public abstract Archiver saveAs(BBDocument doc, String path, String ext);+ ////////////////////////////////////////////////////////////////////////////////// + // Returns path to opf file if we found one with a prior call to findOPF().
+ public String getOPFPath() { + return opfFilePath; + } // getOPF() ++ //////////////////////////////////////////////////////////////////////////////////
+ // Traverses the list of upzipped files and attempts to find an opf + // file. + // + // Notes: zipper must have already been used to unzip an archive. + // String is the path to the opf file. We also store it. + // Get it with getOPF(). + public String findOPF(Zipper zipper) + { + // Get paths to all unzipped files. + ArrayList<String> unzippedPaths = zipper.getUnzippedFilePaths(); + + // Find the .opf file. + for(int curFile = 0; curFile < unzippedPaths.size(); curFile++) + { + // Does this file have an .opf extension? + if(unzippedPaths.get(curFile).toLowerCase().endsWith(".opf") == true) + { + // Found it! + return unzippedPaths.get(curFile).toLowerCase(); + + } // If ends with opf + + } // for(int curFile... + + // Couldn't find it. + return null; + + } // findOPF() ++ //////////////////////////////////////////////////////////////////////////////////
+ // Uses opf file to build a list of files used by the book/document. + public ArrayList<String> parseOPFFile(String _opfPath) + { + // Build factory, and parse the opf. + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder; + try {+ factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd";, false); + factory.setNamespaceAware(true); // Needed, just in case manifest/spine are in a namespace.
+ builder = factory.newDocumentBuilder(); + opfDoc = builder.parse(opfFilePath); + } catch (Exception e) { e.printStackTrace(); } + + // Grab the spine elements and manifest elements. + manifestElements = opfDoc.getElementsByTagNameNS("*", "item"); + spineElements = opfDoc.getElementsByTagNameNS("*", "itemref"); + + // Filepath to current document. + String curDocFilePath = null; ++ // Loop through the spine and find the items in the manifest that we need.
+ for(int curSP = 0; curSP < spineElements.getLength(); curSP++) + { + // Get the attributes for this spine element. + NamedNodeMap spineAtts = spineElements.item(curSP).getAttributes(); + + // Get the ID of the item we need from the manifest. + String fileID = spineAtts.getNamedItem("idref").getNodeValue(); + + // Get the file path from the manifest.+ curDocFilePath = opfFilePath.substring( 0, opfFilePath.lastIndexOf(BBIni.getFileSep()) ) + BBIni.getFileSep();
+ curDocFilePath += findHrefById(fileID).replace("/", BBIni.getFileSep()); + + // Add this path to the list of document paths. + epubFileList.add(curDocFilePath); + } + + // Return list. + return epubFileList; + + } // buildOPF() + + ///////////////////////////////////////////////////////////////////////// + // Finds the manifest element using the given id, + // and returns the href attribute value. + String findHrefById(String id) + { + // Loop through the manifest items and find the file with this ID. + for(int curMan = 0; curMan < manifestElements.getLength(); curMan++) + { + // Get the attributes for this manifest item. + NamedNodeMap manAtts = manifestElements.item(curMan).getAttributes(); ++ // If this manifest item has the id we're looking for, time to open a file.
+ if( manAtts.getNamedItem("id").getNodeValue().compareTo(id) == 0 ) + {+ // Get value of href; this is our local file path to the file. Return it.
+ return manAtts.getNamedItem("href").getNodeValue(); + + } // if manifestItem ID == fileID... + + } // for(int curMan... + + // Couldn't find it. + return null; + + } // findHrefById() ++ ///////////////////////////////////////////////////////////////////////////////////////////
+ // Takes in a document(W3C) and adds its image count to the list. + public void addToNumImgsList(Document addMe) + {+ // Create space big enough to hold our image integers if we haven't done so already.
+ if(numImages == null) + numImages = new ArrayList<Integer>(); + + // Grab all <img> elements. + NodeList imgElements = addMe.getElementsByTagName("img"); + + // Add this value to the list. + numImages.add(imgElements.getLength()); + } ++ ///////////////////////////////////////////////////////////////////////////////////////////
+ // Takes in a document(XOM) and adds its image count to the list. + public void addToNumImgsList(nu.xom.Document addMe) + { + // Convert to DOM. + Document w3cDoc = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + DOMImplementation impl = builder.getDOMImplementation(); + w3cDoc = DOMConverter.convert(addMe, impl); + } + catch(Exception e) { e.printStackTrace(); } ++ // Create space big enough to hold our image integers if we haven't done so already.
+ if(numImages == null) + numImages = new ArrayList<Integer>(); + + // Grab all <img> elements. + NodeList imgElements = w3cDoc.getElementsByTagName("img"); + + // Add this value to the list. + numImages.add(imgElements.getLength()); + } ++ ///////////////////////////////////////////////////////////////////////////////////////////
+ // Returns the list of documents that make up this book. + public ArrayList<String> getSpine() { + return epubFileList; + }+ ///////////////////////////////////////////////////////////////////////////////////////////
+ // Returns a path from a particular spine element. + public String getSpineFilePath(int idx) { + if(epubFileList != null) + if(epubFileList.size() > 0) + return epubFileList.get(idx); + return null; + } + + ////////////////////////////////////////////////////////////////////// + // Returns list of image counts for files in spine. + public ArrayList<Integer> getImgCountList() { + return numImages; + } + + ////////////////////////////////////////////////////////////////////// + // Return number of spine elements. + public int getNumSpineElements() + { + // Returns size of spine list. + return getSpine().size(); + + } // getNumSpineElements() + + ////////////////////////////////////////////////////////////////////// + // If working with an epub document, returns current spine file. + public String getCurSpineFilePath() + { + // Get current spine file path. + return getSpineFilePath(curSpineFileIdx); + + } // getCurSpineFile() + + ////////////////////////////////////////////////////////////////////// + // Returns the current spine index. + public int getCurSpineIdx() { + return curSpineFileIdx; + } // getCurSpineIdx() + + ////////////////////////////////////////////////////////////////////// + // Converts image index to a local index, in reference to + // a page. + // + // For example: We could be on the 56th image, but it could be the + // second image in this particular spine element/page. + // + // Returns -1 if we can't find it, or if there isn't a supported + // archiver. + public int getImageIndexInSpinePage(int imageIndex) + { + // Get image counts for spine. + ArrayList<Integer> imgCntList = getImgCountList(); + + // Current image index in the spine we're testing against. + int curImgIdx = 0; + + // Add up the spine/image counts + for(int curS = 0; curS < curSpineFileIdx; curS++) + curImgIdx += imgCntList.get(curS); + + // Is this image index within range of this particular spine element?+ if( imageIndex >= curImgIdx && imageIndex < curImgIdx + imgCntList.get(curSpineFileIdx) )
+ { + // Move to the spine element that we've found. + return imageIndex - curImgIdx; + + } // if( within range ) + + // If we're here, we couldn't find the spine or image. Return failure. + return -1; + } + + ////////////////////////////////////////////////////////////////////// + // Takes an image index, and finds the spine file + // that contains this image. + public String setSpineFileWithImgIndex(int imgIndex) + { + + // Get image counts for spine. + ArrayList<Integer> imgCntList = getImgCountList(); + + // Current image index in the spine we're testing against. + int curImgIdx = 0; ++ // Loop through the spine/image counts, until we find one that contains this image.
+ for(int curS = 0; curS < imgCntList.size(); curS++) + { + // Is this image index within range of this particular spine element?+ if( imgIndex >= curImgIdx && imgIndex < curImgIdx + imgCntList.get(curS) )
+ { + // Move to the spine element that we've found. + return gotoSpineFilePath(curS); + + } // if( within range ) + + // Move forward with the index. + curImgIdx += imgCntList.get(curS); + + } // for(curS) ++ // If we make it here, we couldn't find that particular spine file/element.
+ return null; + + } // setSpineFileWithImgIndex() + + ////////////////////////////////////////////////////////////////////// + // Moves to a specific spine file using an index into the list. + public String gotoSpineFilePath(int idx) + { + // Go to next file path. + curSpineFileIdx = idx; + // If we've gone too far, wrap around. + if(curSpineFileIdx >= getSpine().size()) + curSpineFileIdx = 0; + if(curSpineFileIdx < 0 ) + curSpineFileIdx = getSpine().size() - 1; + + // Return the current spine file path. + return getSpineFilePath(curSpineFileIdx); + + } // gotoSpineFilePath() + + ////////////////////////////////////////////////////////////////////// + // Moves index to current file to the next one we see in the spine. + public String nextSpineFilePath() + { + // Go to next file path. + curSpineFileIdx++; + // If we've gone too far, wrap around. + if(curSpineFileIdx >= getSpine().size()) + curSpineFileIdx = 0; + + // Return the current spine file path. + return getSpineFilePath(curSpineFileIdx); + + } // nextSpineFile() + + ////////////////////////////////////////////////////////////////////// + // Moves index to current file to the previous one we see in the spine. + public String prevSpineFilePath() + { + // Go to previous file path. + curSpineFileIdx--; + // If we've gone too far, wrap around. + if(curSpineFileIdx < 0 ) + curSpineFileIdx = getSpine().size() - 1; + + // Return the current spine file path. + return getSpineFilePath(curSpineFileIdx); + + } // prevSpineFile() + } // class Archiver =======================================--- /src/main/org/brailleblaster/archiver/EPub3Archiver.java Thu Jul 17 18:48:06 2014 UTC +++ /src/main/org/brailleblaster/archiver/EPub3Archiver.java Thu Jul 24 19:01:54 2014 UTC
@@ -72,9 +72,6 @@ // Path to .opf file. String opfPath; - // Manifest and spine elements. - NodeList manifestElements; - NodeList spineElements; // The main document we'll be appending to. Document mainDoc = null; @@ -85,74 +82,84 @@ // Opf document. Document opfDoc = null; - // Every file that makes our epub doc. - ArrayList<String> epubFileList = null; - // The last bookmark we were at. String bkMarkStr = null; - // Number of images in each file that makes up our document.- // For every spine element we have, we're going to count the number of images
- // in that file. This helps with image traversal. - ArrayList<Integer> numImages = null; - - EPub3Archiver(String docToPrepare) { + public EPub3Archiver(String docToPrepare) { super(docToPrepare); - open(); + open(null); currentConfig = getAutoCfg("epub"); filterNames = new String[] {"EPUB", "BRF", "UTDML"}; filterExtensions = new String[] {"*.epub","*.brf", "*.utd"}; } + + // Also takes path to opf file. Assumes document is already unzipped. +// public EPub3Archiver(String docToPrepare, String _opfPath) { +// super(docToPrepare); +// open(_opfPath); +// currentConfig = getAutoCfg("epub"); +// filterNames = new String[] {"EPUB", "BRF", "UTDML"}; +// filterExtensions = new String[] {"*.epub","*.brf", "*.utd"}; +// }//////////////////////////////////////////////////////////////////////////////////
// - private String open() { + private String open(String _opath) { // Init variables. mainDoc = null; mainBodyElement = null; mainHtmlElement = null; opfDoc = null; - epubFileList = new ArrayList<String>(); // First things first, we have to unzip the EPub doc. ///////// // Unzip. - // Create unzipper. - Zipper zpr = new Zipper(); - - // Unzip. - String sep = BBIni.getFileSep();- String nameStr = originalDocPath.substring(originalDocPath.lastIndexOf(sep) + 1, originalDocPath.length()); - String outPath = BBIni.getTempFilesPath() + sep + nameStr.substring( 0, nameStr.lastIndexOf(".") ) + sep;
- zpr.Unzip( originalDocPath, outPath ); + // Get ready to unzip. + Zipper zpr = null; + // If zipped. + if( _opath == null ) { + // Create unzipper. + zpr = new Zipper(); + + // Unzip. + String sep = BBIni.getFileSep();+ String nameStr = originalDocPath.substring(originalDocPath.lastIndexOf(sep) + 1, originalDocPath.length()); + String outPath = BBIni.getTempFilesPath() + sep + nameStr.substring( 0, nameStr.lastIndexOf(".") ) + sep;
+ zpr.Unzip( originalDocPath, outPath ); + } // Unzip. ///////// // Get ready to look for the opf file. - opfPath = null; + opfPath = _opath; - // Get paths to all unzipped files. - ArrayList<String> unzippedPaths = zpr.getUnzippedFilePaths(); - // Find the .opf file. - for(int curFile = 0; curFile < unzippedPaths.size(); curFile++) - { - // Does this file have an .opf extension? - if(unzippedPaths.get(curFile).toLowerCase().endsWith(".opf") == true) + // If zipped. + if( opfPath == null ) { + // Get paths to all unzipped files. + ArrayList<String> unzippedPaths = zpr.getUnzippedFilePaths(); + + // Find the .opf file. + for(int curFile = 0; curFile < unzippedPaths.size(); curFile++) { - // Found it! - opfPath = unzippedPaths.get(curFile).toLowerCase(); + // Does this file have an .opf extension? + if(unzippedPaths.get(curFile).toLowerCase().endsWith(".opf") == true) + { + // Found it! + opfPath = unzippedPaths.get(curFile).toLowerCase(); + + // Found it, take a break. + break; + + } // If ends with opf - // Found it, take a break. - break; - - } // If ends with opf + } // for(int curFile... - } // for(int curFile... + } // if( opfPath == null ) // If we couldn't find the opf file, no point in continuing. if(opfPath == null) @@ -326,32 +333,6 @@ return null; } // open() - - ///////////////////////////////////////////////////////////////////////// - // Finds the manifest element using the given id, - // and returns the href attribute value. - String findHrefById(String id) - { - // Loop through the manifest items and find the file with this ID. - for(int curMan = 0; curMan < manifestElements.getLength(); curMan++) - { - // Get the attributes for this manifest item. - NamedNodeMap manAtts = manifestElements.item(curMan).getAttributes(); -- // If this manifest item has the id we're looking for, time to open a file.
- if( manAtts.getNamedItem("id").getNodeValue().compareTo(id) == 0 ) - {- // Get value of href; this is our local file path to the file. Return it.
- return manAtts.getNamedItem("href").getNodeValue(); - - } // if manifestItem ID == fileID... - - } // for(int curMan... - - // Couldn't find it. - return null; - - } // findHrefById() @Override public void save(BBDocument doc, String path) @@ -447,37 +428,7 @@ } // save()- ///////////////////////////////////////////////////////////////////////////////////////////
- // Takes in a document and adds its image count to the list. - public void addToNumImgsList(Document addMe) - {- // Create space big enough to hold our image integers if we haven't done so already.
- if(numImages == null) - numImages = new ArrayList<Integer>(); - - // Grab all <img> elements. - NodeList imgElements = addMe.getElementsByTagName("img"); - - // Add this value to the lsit. - numImages.add(imgElements.getLength()); - }- ///////////////////////////////////////////////////////////////////////////////////////////
- // Returns list of image counts for documents in the spine. - public ArrayList<Integer> getImgCounts() { - return numImages; - } -- ///////////////////////////////////////////////////////////////////////////////////////////
- // Returns the list of documents that make up this book. - public ArrayList<String> getSpine() { - return epubFileList; - }- ///////////////////////////////////////////////////////////////////////////////////////////
- // Returns a path from a particular spine element. - public String getSpineFilePath(int idx) { - return epubFileList.get(idx); - }///////////////////////////////////////////////////////////////////////////////////////////
// Simple message box for alerts and messages to user. =======================================--- /src/main/org/brailleblaster/archiver/NimasArchiver.java Thu Jul 3 15:55:25 2014 UTC +++ /src/main/org/brailleblaster/archiver/NimasArchiver.java Thu Jul 24 19:01:54 2014 UTC
@@ -30,13 +30,25 @@ package org.brailleblaster.archiver; +import java.io.BufferedOutputStream; import java.io.File; import java.io.FileNotFoundException; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStream; +import java.io.OutputStreamWriter; import java.io.PrintWriter; +import java.io.StringWriter; import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Set; import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.stream.StreamSource; import nu.xom.Attribute; import nu.xom.Builder; @@ -47,6 +59,7 @@ import nu.xom.ParsingException; import nu.xom.ValidityException; import nu.xom.XPathContext; +import nu.xom.converters.DOMConverter; import nu.xom.xslt.XSLException; import nu.xom.xslt.XSLTransform; @@ -55,19 +68,28 @@ import org.brailleblaster.util.FileUtils; import org.brailleblaster.util.Notify; import org.brailleblaster.util.Zipper; +import org.w3c.dom.DOMImplementation;//////////////////////////////////////////////////////////////////////////////////
// Prepares Nimas Archive for opening. public class NimasArchiver extends Archiver { + Set <String> allPaths; + + NimasArchiver(String docToPrepare) { super(docToPrepare); if(docToPrepare.endsWith(".zip")) unzip(docToPrepare); + // Segment the single NIMAS file. This will make rendering + // faster in certain perspectives. + writeNimasSegments(); + currentConfig = getAutoCfg("nimas"); // Nimas document. filterNames = new String[] {"XML", "XML Zip", "BRF", "UTDML"}; filterExtensions = new String[] {"*.xml", "*.zip", "*.brf", "*.utd"}; + allPaths=new HashSet<String>(); } @Override @@ -171,6 +193,30 @@ arch.save(doc, path); return arch; } + + /*** + * Write to the disk once at time if the file is not there already + * @param index + * @return + */ + public String wrtieToDisk(int index){ + // Build string path.+ String outPath = workingDocPath.substring(0, workingDocPath.lastIndexOf(BBIni.getFileSep())) + BBIni.getFileSep() + Integer.toString(index) + ".xml";
+ if(!(allPaths.contains(Integer.toString(index)))){ + + Document curDoc=manageNimas(index); + // Create file utility for saving our xml files. + FileUtils fu = new FileUtils(); + + // Write file. + fu.createXMLFile( curDoc, outPath ); + allPaths.add(Integer.toString(index)); + } + + return outPath; + + + } /*** * Get partition nimas book* @return ArrayList of Document which each entry of an array includes a nimas book
@@ -179,7 +225,7 @@ { ArrayList<Document> allDocs =new ArrayList<Document>(); //Read xml template- String sourcePath = BBIni.getProgramDataPath() + BBIni.getFileSep() + "xmlTemplates" + BBIni.getFileSep() + "dtbook.xml"; + String sourcePath = BBIni.getProgramDataPath() + BBIni.getFileSep() + "xmlTemplates" + BBIni.getFileSep() + "nimasTemplate.xml";
File temp = new File(sourcePath); //get all level1 element Nodes allNode=getLevel1(); @@ -192,6 +238,28 @@ return allDocs; } + /*** + * Get partition nimas book+ * @return ArrayList of Document which each entry of an array includes a nimas book
+ */ + public Document manageNimas(int index) + { + Document currentDoc =null; + //Read xml template+ String sourcePath = BBIni.getProgramDataPath() + BBIni.getFileSep() + "xmlTemplates" + BBIni.getFileSep() + "nimasTemplate.xml";
+ File temp = new File(sourcePath); + //get all level1 element + Nodes allNode=getLevel1(); + if (index<allNode.size()){ + Node node=allNode.get(index); + currentDoc=breakDocument(temp,node); + + } + + return currentDoc; + + } + /** * Create an empty Document * @param tempfile @@ -236,13 +304,12 @@ * @param context * @return */ - Nodes getXpath (String qeuery, Document doc,nu.xom.XPathContext context ) - { - Nodes result = doc.query(qeuery,context); - return result; -+ Nodes getXpath (String qeuery, Document doc,nu.xom.XPathContext context ) {
+ return doc.query(qeuery,context); } + + /** * Add Node to template * @param addedNode @@ -251,9 +318,9 @@ Document breakDocument(File temp,Node addedNode){ Document tempDoc=createDocument(temp); nu.xom.XPathContext contextTemp=getConetxt(tempDoc); - Nodes frontmatter =getXpath ("//dtb:frontmatter", tempDoc ,contextTemp ); - Nodes bodymatter =getXpath ("//dtb:bodymatter", tempDoc ,contextTemp ); - Nodes rearmatter =getXpath ("//dtb:rearmatter", tempDoc ,contextTemp );+ Nodes frontmatter = getXpath ("//dtb:frontmatter", tempDoc ,contextTemp );
+ Nodes bodymatter = getXpath ("//dtb:bodymatter", tempDoc ,contextTemp ); + Nodes rearmatter = getXpath ("//dtb:rearmatter", tempDoc ,contextTemp ); Element front = null; Element body = null; Element rear = null; @@ -290,23 +357,22 @@ }/////////////////////////////////////////////////////////////////////////////
- // Converts our nimas xml to multiple xhtml files. EPUB Conversion! - public String convertToEPUB() + // Writes segmented NIMAS documents to disc and returns a list of their + // paths. + public ArrayList<String> writeNimasSegments() { // Grab list of documents after breaking them up by level1's. ArrayList<Document> docs = manageNimas(); // Create file utility for saving our xml files. FileUtils fu = new FileUtils(); - - // Xml builder. - Builder builder = new Builder(); // Path to xsl file. Add three slashes to avoid BS.String xslPath = "file:///" + BBIni.getProgramDataPath() + BBIni.getFileSep() + "xsl" + BBIni.getFileSep() + "dtb2005html.xsl";
- - // Build the xsl document. +// +// // Build the xsl document. Document xslDoc = null; + Builder builder = new Builder(); try { xslDoc = builder.build(xslPath); } catch (ValidityException e1) { e1.printStackTrace(); } catch (ParsingException e1) { e1.printStackTrace(); } @@ -317,17 +383,24 @@ try { xslt = new XSLTransform(xslDoc); } catch (XSLException e1) { e1.printStackTrace(); } - // Loop through the documents + // Loop through the documents, write to file, count images in each. for(int curDoc = 0; curDoc < docs.size(); curDoc++) { - // Finally transform the document. + // Finally transform the document. Nodes newDocNodes = null; try { newDocNodes = xslt.transform( docs.get(curDoc) ); } catch (XSLException e) { e.printStackTrace(); } - Document transformedDoc = xslt.toDocument(newDocNodes); + Document transformedDoc = XSLTransform.toDocument(newDocNodes); // Build string path.String outPath = workingDocPath.substring(0, workingDocPath.lastIndexOf(BBIni.getFileSep())) + BBIni.getFileSep() + Integer.toString(curDoc) + ".xhtml";
+ + // Add path to list. + epubFileList.add(outPath); + + // Count the images in this document. + addToNumImgsList(docs.get(curDoc)); + // Write file. fu.createXMLFile( transformedDoc, outPath ); // fu.createXMLFile( docs.get(curDoc), outPath ); @@ -335,14 +408,14 @@ } // for(int curDoc... // Create the opf file. - return _createOPF(docs); + return epubFileList; - } // convertToEPUB() + } // writeNimasSegments()/////////////////////////////////////////////////////////////////////////////
// Helper: Uses list created with manageNimas() to create an OPF file for // EPUB conversion. - private String _createOPF(ArrayList<Document> docs) + private String _createOPFFromDocs(ArrayList<Document> docs) { // Create root package element. Element root = new Element("package"); @@ -389,6 +462,6 @@ // Return path to our shiny, new opf. return opfPath; - } // _createOPF() + } // _createOPFFromDocs() } // class NimasArchiver =======================================--- /src/main/org/brailleblaster/perspectives/braille/Manager.java Wed Jul 23 14:45:44 2014 UTC +++ /src/main/org/brailleblaster/perspectives/braille/Manager.java Thu Jul 24 19:01:54 2014 UTC
@@ -36,6 +36,8 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; +import java.util.HashSet; +import java.util.Set; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -190,7 +192,6 @@ group.setRedraw(true); //if(list.size() == 0) // formatTemplateDocument(); - if(BBIni.getPlatformName().equals("cocoa")) treeView.getTree().select(treeView.getRoot()); } @@ -806,51 +807,90 @@ else braille.positionScrollbar(text.view.getTopIndex()); } - - private void handleUpdateStyle(Message message){ - if(document.getDOM() != null && text.view.getText().length() > 0){ - group.setRedraw(false); - Element parent = document.getParent(list.getCurrent().n, true); + /*** + * + * @param current + * @param message + * @return + */ + private Element parentStyle(TextMapElement current, Message message) { + Element parent = document.getParent(current.n, true);+ message.put("previousStyle", styles.get(styles.getKeyFromAttribute(parent)));
+ document.changeSemanticAction(message, current.parentElement()); + message.put("style", styles.get(styles.getKeyFromAttribute(parent))); + return parent;- message.put("previousStyle", styles.get(styles.getKeyFromAttribute(parent))); - document.changeSemanticAction(message, list.getCurrent().parentElement());
- message.put("style", styles.get(styles.getKeyFromAttribute(parent))); + } + /*** + * Handle style if user choose + * @param message + */ + private void handleUpdateStyle(Message message) { + if (document.getDOM() != null && text.view.getText().length() > 0) { + group.setRedraw(false); + Element parent = parentStyle(list.getCurrent(), message);ArrayList<TextMapElement> itemList = list.findTextMapElements(list.getCurrentIndex(), parent, true);
+ adjustStyle(itemList, message); + + } else + new Notify(lh.localValue("nothingToApply")); + } + /*** + * + * @param start + * @param end + * @param message + */ + private void handleStyleSelected(int start,int end,Message message){ - int start = list.indexOf(itemList.get(0)); - int end = list.indexOf(itemList.get(itemList.size() - 1)); - int origPos = list.get(list.getNodeIndex(itemList.get(0))).start; - if(start > 0){ - message.put("prev", list.get(start - 1).end);- message.put("braillePrev", list.get(start - 1).brailleList.getLast().end);
- } - else { - message.put("prev", -1); - message.put("braillePrev", -1); - } - - if(end < list.size() - 1){ - message.put("next", list.get(end + 1).start);- message.put("brailleNext", list.get(end + 1).brailleList.getFirst().start);
- } - else { - message.put("next", -1); - message.put("brailleNext", -1); - } - - text.adjustStyle(message, itemList); - braille.adjustStyle(message, itemList); - - if(message.contains("linesBeforeOffset"))- list.shiftOffsetsFromIndex(start, (Integer)message.getValue("linesBeforeOffset"), (Integer)message.getValue("linesBeforeOffset"), origPos); - if(message.contains("linesAfterOffset") && list.size() > 1 && end < list.size() - 1) - list.shiftOffsetsFromIndex(end + 1, (Integer)message.getValue("linesAfterOffset"), (Integer)message.getValue("linesAfterOffset"), origPos);
+ + Set<TextMapElement> itemSet = getElementSelected(start, end); + adjustStyle( (ArrayList<TextMapElement>) itemSet,message); + } + /*** + * Adjust style of elements in the list base on previous and next element + * @param itemList : all selected items which we want style to be applied + * @param message : passing information regarding styles + */ - treeView.adjustItemStyle(list.getCurrent()); - group.setRedraw(true);+ private void adjustStyle(ArrayList<TextMapElement> itemList, Message message) {
+ int start = list.indexOf(itemList.get(0)); + int end = list.indexOf(itemList.get(itemList.size() - 1)); + int origPos = list.get(list.getNodeIndex(itemList.get(0))).start; + if (start > 0) { + message.put("prev", list.get(start - 1).end); + message.put("braillePrev", + list.get(start - 1).brailleList.getLast().end); + } else { + message.put("prev", -1); + message.put("braillePrev", -1); } - else - new Notify(lh.localValue("nothingToApply")); + + if (end < list.size() - 1) { + message.put("next", list.get(end + 1).start); + message.put("brailleNext", + list.get(end + 1).brailleList.getFirst().start); + } else { + message.put("next", -1); + message.put("brailleNext", -1); + } + + text.adjustStyle(message, itemList); + braille.adjustStyle(message, itemList); + + if (message.contains("linesBeforeOffset")) + list.shiftOffsetsFromIndex(start, + (Integer) message.getValue("linesBeforeOffset"), + (Integer) message.getValue("linesBeforeOffset"), origPos); + if (message.contains("linesAfterOffset") && list.size() > 1 + && end < list.size() - 1) + list.shiftOffsetsFromIndex(end + 1, + (Integer) message.getValue("linesAfterOffset"), + (Integer) message.getValue("linesAfterOffset"), origPos); + + treeView.adjustItemStyle(list.getCurrent()); + group.setRedraw(true); + } public void saveAs(){ @@ -1201,15 +1241,22 @@ } /*** * Return all elements that selected in text - * @param offset - * @return + * @param start :start location of where text selected + * @param end: where selection ended + * @return: Set of all element where in selection */ - public ArrayList<TextMapElement> getElementSelected(int strat, int end){ - - return null; - + public Set<TextMapElement> getElementSelected(int start, int end) { + Set<TextMapElement> elementSelectedSet = new HashSet<TextMapElement>(); + for (int j = start; j < end; j++) { + TextMapElement t = getElementInRange(start); + if (t != null) { + elementSelectedSet.add(t); + System.out.println(t.getText()); + } + } + return elementSelectedSet; } - + public TextMapElement getElementInBrailleRange(int offset){ Message m = new Message(null); m.put("offset", offset); =======================================--- /src/main/org/brailleblaster/perspectives/braille/views/wp/TextView.java Wed Jul 23 14:45:44 2014 UTC +++ /src/main/org/brailleblaster/perspectives/braille/views/wp/TextView.java Thu Jul 24 19:01:54 2014 UTC
@@ -126,8 +126,9 @@ startSelection=selectionArray[i]; endSelection=selectionArray[i]+selectionArray[i+1]; - System.out.println(startSelection+" "+endSelection); + } + System.out.println(startSelection+" "+endSelection); if(selectionArray[1] > 0){ setSelection(selectionArray[0], selectionArray[1]); currentChar = ' '; =======================================--- /src/main/org/brailleblaster/perspectives/imageDescriber/ImageDescriberController.java Thu Jul 17 19:46:53 2014 UTC +++ /src/main/org/brailleblaster/perspectives/imageDescriber/ImageDescriberController.java Thu Jul 24 19:01:54 2014 UTC
@@ -69,11 +69,6 @@ // Helps with managing and manipulating images. ImageHelper imgHelper; - // Index of current file we're looking at in the browser. - // Current file we're to load using the spine as a reference. - // Spine is in .opf file in epub. - int curSpineFileIdx = 0; -///////////////////////////////////////////////////////////////////////////////////////////
// Constructor.public ImageDescriberController(WPManager wordProcesserManager, String fileName) {
@@ -136,7 +131,7 @@ // If we have a Nimas file, convert to epub then push along to BB. // if(arch instanceof NimasArchiver) { -// ((NimasArchiver)(arch)).convertToEPUB();+// arch = new EPub3Archiver(fileName, ((NimasArchiver)(arch)).convertToEPUB() );
// } // if(arch instanceof NimasArchiver) //////////////// @@ -405,201 +400,6 @@ public Archiver getArchiver() { return arch; } - - ////////////////////////////////////////////////////////////////////// - // Returns list of image counts for files in spine. - // Returns null if there is no list. Don't call - // unless working with EPUB3 for now. - public ArrayList<Integer> getImgCountList() { - if(arch != null) - if(arch instanceof EPub3Archiver) - return ((EPub3Archiver)arch).getImgCounts(); - - return null; - } - - ////////////////////////////////////////////////////////////////////// - // Return number of spine elements. - public int getNumSpineElements() - { - // If there is an archiver, and this archiver - // represents a multi-file document, return number of spine elements. - if(arch != null) - if(arch instanceof EPub3Archiver) - return ((EPub3Archiver)arch).getSpine().size(); - - // This isn't a multi-file document. Return 0. - return 0; - - } // getNumSpineElements() - - ////////////////////////////////////////////////////////////////////// - // If working with an epub document, returns current spine file. - public String getCurSpineFilePath() - { - // Get current spine file path. - if(arch != null) - if(arch instanceof EPub3Archiver) - return ((EPub3Archiver)arch).getSpineFilePath(curSpineFileIdx); - - // If we get here, there is no spine path to return. - return null; - - } // getCurSpineFile() - - ////////////////////////////////////////////////////////////////////// - // Returns the current spine index. - public int getCurSpineIdx() { - return curSpineFileIdx; - } // getCurSpineIdx() - - ////////////////////////////////////////////////////////////////////// - // Converts image index to a local index, in reference to - // a page. - // - // For example: We could be on the 56th image, but it could be the - // second image in this particular spine element/page. - // - // Returns -1 if we can't find it, or if there isn't a supported - // archiver. - public int getImageIndexInSpinePage(int imageIndex) - { - // Make sure there is an archiver. - if(arch == null) - return -1; - if(arch instanceof EPub3Archiver == false) - return -1; - - // Save some typing. - EPub3Archiver ep3Arch = ((EPub3Archiver)arch); - - // Get image counts for spine. - ArrayList<Integer> imgCntList = ep3Arch.getImgCounts(); - - // Current image index in the spine we're testing against. - int curImgIdx = 0; - - // Add up the spine/image counts - for(int curS = 0; curS < curSpineFileIdx; curS++) - curImgIdx += imgCntList.get(curS); - - // Is this image index within range of this particular spine element?- if( imageIndex >= curImgIdx && imageIndex < curImgIdx + imgCntList.get(curSpineFileIdx) )
- { - // Move to the spine element that we've found. - return imageIndex - curImgIdx; - - } // if( within range ) - - // If we're here, we couldn't find the spine or image. Return failure. - return -1; - } - - ////////////////////////////////////////////////////////////////////// - // Takes an image index, and finds the spine file - // that contains this image. - public String setSpineFileWithImgIndex(int imgIndex) - { - // Make sure there is an archiver. - if(arch == null) - return null; - if(arch instanceof EPub3Archiver == false) - return null; - - // Save some typing. - EPub3Archiver ep3Arch = ((EPub3Archiver)arch); - - // Get image counts for spine. - ArrayList<Integer> imgCntList = ep3Arch.getImgCounts(); - - // Current image index in the spine we're testing against. - int curImgIdx = 0; -- // Loop through the spine/image counts, until we find one that contains this image.
- for(int curS = 0; curS < imgCntList.size(); curS++) - { - // Is this image index within range of this particular spine element?- if( imgIndex >= curImgIdx && imgIndex < curImgIdx + imgCntList.get(curS) )
- { - // Move to the spine element that we've found. - return gotoSpineFilePath(curS); - - } // if( within range ) - - // Move forward with the index. - curImgIdx += imgCntList.get(curS); - - } // for(curS) -- // If we make it here, we couldn't find that particular spine file/element.
- return null; - - } // setSpineFileWithImgIndex() - - ////////////////////////////////////////////////////////////////////// - // Moves to a specific spine file using an index into the list. - public String gotoSpineFilePath(int idx) - { - // Make sure there is an archiver. - if(arch == null) - return null; - if(arch instanceof EPub3Archiver == false) - return null; - - // Go to next file path. - curSpineFileIdx = idx; - // If we've gone too far, wrap around. - if(curSpineFileIdx >= ((EPub3Archiver)arch).getSpine().size()) - curSpineFileIdx = 0; - if(curSpineFileIdx < 0 ) - curSpineFileIdx = ((EPub3Archiver)arch).getSpine().size() - 1; - - // Return the current spine file path. - return ((EPub3Archiver)arch).getSpineFilePath(curSpineFileIdx); - - } // gotoSpineFilePath() - - ////////////////////////////////////////////////////////////////////// - // Moves index to current file to the next one we see in the spine. - public String nextSpineFilePath() - { - // Make sure there is an archiver. - if(arch == null) - return null; - if(arch instanceof EPub3Archiver == false) - return null; - - // Go to next file path. - curSpineFileIdx++; - // If we've gone too far, wrap around. - if(curSpineFileIdx >= ((EPub3Archiver)arch).getSpine().size()) - curSpineFileIdx = 0; - - // Return the current spine file path. - return ((EPub3Archiver)arch).getSpineFilePath(curSpineFileIdx); - - } // nextSpineFile() - - ////////////////////////////////////////////////////////////////////// - // Moves index to current file to the previous one we see in the spine. - public String prevSpineFilePath() - { - // Make sure there is an archiver. - if(arch == null) - return null; - if(arch instanceof EPub3Archiver == false) - return null; - - // Go to previous file path. - curSpineFileIdx--; - // If we've gone too far, wrap around. - if(curSpineFileIdx < 0 ) - curSpineFileIdx = ((EPub3Archiver)arch).getSpine().size() - 1; - - // Return the current spine file path. - return ((EPub3Archiver)arch).getSpineFilePath(curSpineFileIdx); - - } // prevSpineFile() ///////////////////////////////////////////////////////////////// // Returns the image desciber "document" @@ -645,14 +445,14 @@ idv.setTextBox(imgDesc.getCurDescription()); idv.setAltBox(imgDesc.getCurElmAttribute("alt")); - if(arch != null){ - if( arch instanceof EPub3Archiver ) - idv.enableBrowserNavButtons(); - else - idv.disableBrowserNavButtons(); - } - else - idv.disableBrowserNavButtons(); +// if(arch != null){ +// if( arch instanceof EPub3Archiver ) +// idv.enableBrowserNavButtons(); +// else +// idv.disableBrowserNavButtons(); +// } +// else +// idv.disableBrowserNavButtons(); // if(file.endsWith(".zip")){ // openZipFile(file); // } =======================================--- /src/main/org/brailleblaster/perspectives/imageDescriber/views/ImageDescriberView.java Mon Jul 7 19:26:22 2014 UTC +++ /src/main/org/brailleblaster/perspectives/imageDescriber/views/ImageDescriberView.java Thu Jul 24 19:01:54 2014 UTC
@@ -111,7 +111,7 @@ int imgIndex = idd.getImageDescriber().getCurrentElementIndex(); // Is it time to move to another page/chapter? - String newPath = idd.setSpineFileWithImgIndex(imgIndex); + String newPath = idd.getArchiver().setSpineFileWithImgIndex(imgIndex); // If the page needs to move/change, update. // Otherwise, don't move the page yet. @@ -144,7 +144,7 @@ int imgIndex = idd.getImageDescriber().getCurrentElementIndex(); // Is it time to move to another page/chapter? - String newPath = idd.setSpineFileWithImgIndex(imgIndex); + String newPath = idd.getArchiver().setSpineFileWithImgIndex(imgIndex); // If the page needs to move/change, update. // Otherwise, don't move the page yet. @@ -248,15 +248,15 @@ public void widgetSelected(SelectionEvent e) { // Previous page. - curBrowserFilePath = idd.prevSpineFilePath(); + curBrowserFilePath = idd.getArchiver().prevSpineFilePath(); // Grab image count list. - ArrayList<Integer> imgCntList = idd.getImgCountList(); + ArrayList<Integer> imgCntList = idd.getArchiver().getImgCountList(); // Count images in each page until we get to the first one // on the current page/chapter. int curImgIdx = 0; - for(int curP = 0; curP < idd.getCurSpineIdx(); curP++) + for(int curP = 0; curP < idd.getArchiver().getCurSpineIdx(); curP++) curImgIdx += imgCntList.get(curP); // Set current image. @@ -279,15 +279,15 @@ public void widgetSelected(SelectionEvent e) { // Move to next page. - curBrowserFilePath = idd.nextSpineFilePath(); + curBrowserFilePath = idd.getArchiver().nextSpineFilePath(); // Grab image count list. - ArrayList<Integer> imgCntList = idd.getImgCountList(); + ArrayList<Integer> imgCntList = idd.getArchiver().getImgCountList(); // Count images in each page until we get to the first one // on the current page/chapter. int curImgIdx = 0; - for(int curP = 0; curP < idd.getCurSpineIdx(); curP++) + for(int curP = 0; curP < idd.getArchiver().getCurSpineIdx(); curP++) curImgIdx += imgCntList.get(curP); // Set current image. @@ -610,8 +610,8 @@ // If we're dealing with a multi-file document, // get the index on the PAGE!!!! - if(idd.getNumSpineElements() > 0) - imgIdx = idd.getImageIndexInSpinePage(imgIdx); + if(idd.getArchiver().getNumSpineElements() > 0) + imgIdx = idd.getArchiver().getImageIndexInSpinePage(imgIdx); // Get the index of the current element. String indexStr = Integer.toString( imgIdx ); @@ -724,8 +724,8 @@ { // If there are spine paths, that means there are multiple // files to load, and we don't need to create an html file(EPUB). - if(idd.getCurSpineFilePath() != null) { - curBrowserFilePath = idd.getCurSpineFilePath(); + if(idd.getArchiver().getCurSpineFilePath() != null) { + curBrowserFilePath = idd.getArchiver().getCurSpineFilePath(); return; } @@ -759,8 +759,8 @@ {// If there are spine paths, then this is more than likely an EPUB document.
// Nothing to delete. - if(idd.getCurSpineFilePath() != null) { - curBrowserFilePath = idd.getCurSpineFilePath(); + if(idd.getArchiver().getCurSpineFilePath() != null) { + curBrowserFilePath = idd.getArchiver().getCurSpineFilePath(); return; } =======================================--- /src/main/org/brailleblaster/perspectives/webView/WebViewController.java Thu Jul 17 19:46:53 2014 UTC +++ /src/main/org/brailleblaster/perspectives/webView/WebViewController.java Thu Jul 24 19:01:54 2014 UTC
@@ -2,6 +2,7 @@ import java.io.File; import java.io.IOException; +import java.util.ArrayList; import nu.xom.Document; @@ -123,8 +124,8 @@ if(arch instanceof NimasArchiver) { isEpub=false; - //((NimasArchiver)arch).manageNimas(); + currentPath=((NimasArchiver)arch).wrtieToDisk(index); //Converter c= new Converter((NimasArchiver)arch); str=copyFile(currentPath); } =======================================--- /src/main/org/brailleblaster/perspectives/webView/webViewBrowser.java Fri Jun 6 17:12:14 2014 UTC +++ /src/main/org/brailleblaster/perspectives/webView/webViewBrowser.java Thu Jul 24 19:01:54 2014 UTC
@@ -84,7 +84,7 @@ public void showBraille(int chapter) { - + if(webc.isEpub==true){ // listen to when the page load in browser browser.addProgressListener(new ProgressListener() { public void changed(ProgressEvent event) { @@ -112,6 +112,7 @@ }); browser.setUrl(webc.getBraille(chapter)); + } } @@ -122,6 +123,7 @@ * @param index */ public void showContents(int index){ + if(webc.isEpub==true){ if (index> webc.getSize()-1) { index=0; @@ -173,7 +175,7 @@ "}"; - + // listen to when the page load in browser browser.addProgressListener(new ProgressListener() { public void changed(ProgressEvent event) { @@ -189,6 +191,7 @@ } }); + } browser.setUrl(webc.getChapter(index)); @@ -213,9 +216,13 @@ { index=index-1; if (lockBraille==true) + { showContents(index); + } else + { showBraille(index); + } } // go to next page, chapter @@ -223,9 +230,13 @@ { index=index+1; if (lockBraille==true) + { showContents(index); + } else + { showBraille(index); + } } ============================================================================== Revision: 140c3de5cf05 Branch: default Author: Sahel "sahel.mastoureshgh@xxxxxxxxx" Date: Thu Jul 24 19:10:40 2014 UTC Log: Commited changes before merge http://code.google.com/p/brailleblaster/source/detail?r=140c3de5cf05 Modified: /src/main/org/brailleblaster/archiver/NimasArchiver.java =======================================--- /src/main/org/brailleblaster/archiver/NimasArchiver.java Thu Jul 24 19:01:54 2014 UTC +++ /src/main/org/brailleblaster/archiver/NimasArchiver.java Thu Jul 24 19:10:40 2014 UTC
@@ -74,6 +74,7 @@ // Prepares Nimas Archive for opening. public class NimasArchiver extends Archiver { + Set <String> allPaths; @@ -217,27 +218,7 @@ } - /*** - * Get partition nimas book- * @return ArrayList of Document which each entry of an array includes a nimas book
- */ - public ArrayList<Document> manageNimas() - { - ArrayList<Document> allDocs =new ArrayList<Document>(); - //Read xml template- String sourcePath = BBIni.getProgramDataPath() + BBIni.getFileSep() + "xmlTemplates" + BBIni.getFileSep() + "nimasTemplate.xml";
- File temp = new File(sourcePath); - //get all level1 element - Nodes allNode=getLevel1(); - for (int i=0;i<allNode.size();i++){ - Node node=allNode.get(i); - allDocs.add(breakDocument(temp,node)); - - } - - return allDocs; - - } + /*** * Get partition nimas book* @return ArrayList of Document which each entry of an array includes a nimas book
@@ -259,6 +240,7 @@ return currentDoc; } + /** * Create an empty Document @@ -308,6 +290,26 @@ return doc.query(qeuery,context); } + + /*** + * Get partition nimas book+ * @return ArrayList of Document which each entry of an array includes a nimas book
+ */ + public ArrayList<Document> manageNimas() + { + ArrayList<Document> allDocs = new ArrayList<Document>(); + //Read xml template+ String sourcePath = BBIni.getProgramDataPath() + BBIni.getFileSep() + "xmlTemplates" + BBIni.getFileSep() + "nimasTemplate.xml";
+ File temp = new File(sourcePath); + //get all level1 element + Nodes allNode = getLevel1(); + for (int i = 0; i < allNode.size(); i++){ + allDocs.add( breakDocument(temp, allNode.get(i)) ); + } + + return allDocs; + + } /**