public TextViewerBuffer readFile(SimpleFont font, int fontSize, int width) throws FileNotFoundException, NullPointerException { TextViewerBuffer mBuffer = null; VirtualFile file = mFile; String charset = mCharset; if (file == null) { throw new NullPointerException("kyoro text --1--"); } if (!file.getBase().canRead() || !file.getBase().exists() || !file.getBase().isFile()) { throw new FileNotFoundException("kyoro text --2--" + file.getBase().getAbsolutePath()); } try { MyBreakText mBreakText = new MyBreakText(font); mBreakText.getSimpleFont().setFontSize(fontSize); mBreakText.getSimpleFont().setAntiAlias(true); mBreakText.setBufferWidth(width); int cash2 = (int) (mBreakText.getWidth() * 2 / 6); mBuffer = new TextViewerBuffer(2000, cash2, mBreakText, file, charset); } catch (FileNotFoundException e) { FileNotFoundException fnfe = new FileNotFoundException("--3--"); fnfe.setStackTrace(e.getStackTrace()); throw fnfe; } finally { } return mBuffer; }
public void save(int unpatchedPosition, int patchedPositon, AddLine line) throws FaileSaveException { // android.util.Log.v("kiyo","save add #A#"+unpatchedPosition +","+ patchedPositon +"," + // line); int start = mPrevUnpatchedPosition + line.begin(); // unpatchedPosition + line.begin(); // int end = start + line.length(); try { long beginPointer = 0; long endPointer = 0; if (start < mTarget.getNumberOfStockedElement()) { KyoroString insertedLine = mTarget.get(start); beginPointer = insertedLine.getBeginPointer(); endPointer = insertedLine.getEndPointer(); } else { KyoroString insertedLine = mTarget.get(mTarget.getNumberOfStockedElement() - 1); beginPointer = insertedLine.getEndPointer(); endPointer = insertedLine.getEndPointer(); } // android.util.Log.v("kiyo","save add #B-1#"); // for (int lineLocation = 0; lineLocation < end; lineLocation++) { for (int lineLocation = 0; lineLocation < line.length(); lineLocation++) { String encodedData = encodeAddLine(beginPointer, endPointer, line.get(lineLocation).toString()); mVFile.addChunk(encodedData.getBytes("utf8")); } // android.util.Log.v("kiyo","save add #B-2#"); } catch (Exception e) { e.printStackTrace(); throw new FaileSaveException(); } // android.util.Log.v("kiyo","save add #C#"); }
public void save(int unpatchedPosition, int patchedPositon, DeleteLine line) throws FaileSaveException { int start = mPrevUnpatchedPosition + line.begin(); int end = start + line.length(); try { for (int location = start; location < end; location++) { KyoroString deletedLine = mTarget.get(location); long beginPointer = deletedLine.getBeginPointer(); long endPointer = deletedLine.getEndPointer(); // android.util.Log.v("kiyo","location:"+location+"," // +beginPointer+","+endPointer+","+deletedLine); String encodedData = encodeDeleteLine(beginPointer, endPointer); mVFile.addChunk(encodedData.getBytes("utf8")); } } catch (Exception e) { e.printStackTrace(); throw new FaileSaveException(); } }
public BufferBuilder(File file) { mFile = VirtualFile.createReadOnly(file); }