mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2026-11-07 19:47:36 +00:00
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0c59c85b28 | ||
|
|
e3a5dee36c | ||
|
|
1805cd7d73 | ||
|
|
513a91b41e | ||
|
|
3f2534b1eb |
No files matched your search
@@ -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
|
||||
|
||||
Reference in new issue
Block a user