mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-23 00:13:16 +00:00
Merge pull request #33 from lacerta-doc/feature/add_doc_proc_missing
DocumentProcessorの不足しているメソッドを実装する(1)
This commit is contained in:
commit
217f096a38
|
@ -7,9 +7,9 @@ public interface DocumentProcessor {
|
|||
// ページ操作
|
||||
void addNewPageToLast(Bitmap bitmap) throws Exception;
|
||||
void addNewPagesToLast(Bitmap[] bitmaps) throws Exception;
|
||||
void addNewPageAfterIndex(Bitmap bitmap, int index);
|
||||
void addNewPageBeforeIndex(Bitmap bitmap, int index);
|
||||
void removePageAtIndex(int index);
|
||||
void addNewPageAfterIndex(Bitmap bitmap, int index) throws Exception;
|
||||
void addNewPageBeforeIndex(Bitmap bitmap, int index) throws Exception;
|
||||
void removePageAtIndex(int index) throws Exception;
|
||||
|
||||
// 更新
|
||||
void updatePageAtIndex(Bitmap bitmap, int index);
|
||||
|
|
|
@ -118,14 +118,45 @@ public class DocumentProcessorImpl implements DocumentProcessor{
|
|||
} // TODO-rca: 効率悪いので改善する
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNewPageAfterIndex(Bitmap bitmap, int index) {
|
||||
|
||||
// Internal
|
||||
// Indexを振り直す
|
||||
private ArrayList<XmlMetaPageModel> reIndexPages(ArrayList<XmlMetaPageModel> pages) {
|
||||
logger.debug("reIndexPages", "called"); // TODO-rca: 効率化
|
||||
ArrayList<XmlMetaPageModel> newPages = new ArrayList<>();
|
||||
for (int i = 0; i < pages.size(); i++) {
|
||||
XmlMetaPageModel xmlMetaPageModel = pages.get(i);
|
||||
xmlMetaPageModel.setIndex(i + 1);
|
||||
newPages.add(xmlMetaPageModel);
|
||||
}
|
||||
return newPages;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNewPageBeforeIndex(Bitmap bitmap, int index) {
|
||||
public void addNewPageAfterIndex(Bitmap bitmap, int index) throws Exception {
|
||||
logger.debug("addNewPageAfterIndex", "called");
|
||||
String filename = UUID.randomUUID().toString() + ".png"; // TODO-rca: 拡張子を動的にする
|
||||
|
||||
this.fileManager.getNewInstance().createDirectoryIfNotExist(DEFAULT_SAVE_DIR).resolve(DEFAULT_SAVE_DIR).saveBitmap(bitmap, filename);
|
||||
|
||||
XmlMetaPageModel xmlMetaPageModel = new XmlMetaPageModel();
|
||||
xmlMetaPageModel.setFilename(filename);
|
||||
xmlMetaPageModel.setIndex(index + 1);
|
||||
xmlMetaModel.getPages().add(index, xmlMetaPageModel);
|
||||
xmlMetaModel.setPages(reIndexPages(xmlMetaModel.getPages()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNewPageBeforeIndex(Bitmap bitmap, int index) throws Exception {
|
||||
logger.debug("addNewPageBeforeIndex", "called");
|
||||
String filename = UUID.randomUUID().toString() + ".png"; // TODO-rca: 拡張子を動的にする
|
||||
|
||||
this.fileManager.getNewInstance().createDirectoryIfNotExist(DEFAULT_SAVE_DIR).resolve(DEFAULT_SAVE_DIR).saveBitmap(bitmap, filename);
|
||||
|
||||
XmlMetaPageModel xmlMetaPageModel = new XmlMetaPageModel();
|
||||
xmlMetaPageModel.setFilename(filename);
|
||||
xmlMetaPageModel.setIndex(index);
|
||||
xmlMetaModel.getPages().add(index - 1, xmlMetaPageModel);
|
||||
xmlMetaModel.setPages(reIndexPages(xmlMetaModel.getPages()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue
Block a user