improving GUI
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -4,7 +4,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>BelegScanner</groupId>
|
<groupId>BelegScanner</groupId>
|
||||||
<artifactId>BelegScanner</artifactId>
|
<artifactId>BelegScanner</artifactId>
|
||||||
<version>0.0.5</version>
|
<version>0.0.6</version>
|
||||||
|
|
||||||
<name>BelegScanner</name>
|
<name>BelegScanner</name>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package de.srsoftware.belegscanner.gui;
|
package de.srsoftware.belegscanner.gui;
|
||||||
|
|
||||||
import java.awt.FlowLayout;
|
import java.awt.FlowLayout;
|
||||||
import java.awt.GridLayout;
|
import java.awt.GridBagConstraints;
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import java.awt.Insets;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FilenameFilter;
|
import java.io.FilenameFilter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -38,8 +40,11 @@ public class DocTable extends JPanel{
|
|||||||
|
|
||||||
public Row(String path) {
|
public Row(String path) {
|
||||||
rows.put(path, this);
|
rows.put(path, this);
|
||||||
add(new JLabel(path));
|
constraints.gridy = rows.size();
|
||||||
add(status = new JLabel("neu"));
|
constraints.gridx = 0;
|
||||||
|
add(new JLabel(path), constraints);
|
||||||
|
constraints.gridx = 1;
|
||||||
|
add(status = new JLabel("neu"),constraints);
|
||||||
|
|
||||||
JPanel buttons = new JPanel();
|
JPanel buttons = new JPanel();
|
||||||
buttons.setLayout(new FlowLayout());
|
buttons.setLayout(new FlowLayout());
|
||||||
@@ -56,7 +61,8 @@ public class DocTable extends JPanel{
|
|||||||
preview.addActionListener(ev -> preview(path));
|
preview.addActionListener(ev -> preview(path));
|
||||||
buttons.add(preview);
|
buttons.add(preview);
|
||||||
|
|
||||||
add(buttons);
|
constraints.gridx = 2;
|
||||||
|
add(buttons,constraints);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Row status(String status) {
|
public Row status(String status) {
|
||||||
@@ -70,15 +76,27 @@ public class DocTable extends JPanel{
|
|||||||
|
|
||||||
private final HashMap<String,Row> rows = new HashMap<>();
|
private final HashMap<String,Row> rows = new HashMap<>();
|
||||||
private HashSet<PreviewListener> previewListeners;
|
private HashSet<PreviewListener> previewListeners;
|
||||||
|
private GridBagConstraints constraints;
|
||||||
|
|
||||||
public DocTable() {
|
public DocTable() {
|
||||||
setLayout(new GridLayout(0, 3));
|
setLayout(new GridBagLayout());
|
||||||
add(new JLabel("Ordner"));
|
constraints = new GridBagConstraints();
|
||||||
add(new JLabel("Status"));
|
constraints.fill = GridBagConstraints.HORIZONTAL;
|
||||||
add(new JLabel("Aktionen"));
|
constraints.insets = new Insets(3, 10, 3, 10);
|
||||||
|
constraints.gridy = 0;
|
||||||
|
constraints.gridx = 0;
|
||||||
|
add(new JLabel("Ordner"),constraints);
|
||||||
|
constraints.gridx = 1;
|
||||||
|
add(new JLabel("Status"),constraints);
|
||||||
|
constraints.gridx = 2;
|
||||||
|
add(new JLabel("Aktionen"),constraints);
|
||||||
previewListeners = new HashSet<>();
|
previewListeners = new HashSet<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void add(String path) {
|
||||||
|
if (!rows.containsKey(path)) new Row(path).status("neu");
|
||||||
|
}
|
||||||
|
|
||||||
public DocTable addPreviewListener(PreviewListener listener) {
|
public DocTable addPreviewListener(PreviewListener listener) {
|
||||||
previewListeners.add(listener);
|
previewListeners.add(listener);
|
||||||
return this;
|
return this;
|
||||||
@@ -90,7 +108,7 @@ public class DocTable extends JPanel{
|
|||||||
if (!folder.exists()) return;
|
if (!folder.exists()) return;
|
||||||
List<String> pdfs = Arrays.asList(folder.list(PDFS));
|
List<String> pdfs = Arrays.asList(folder.list(PDFS));
|
||||||
LOG.debug("PDFs: {}",pdfs);
|
LOG.debug("PDFs: {}",pdfs);
|
||||||
if (!pdfs.isEmpty()) previewListeners.forEach(l -> l.show(Path.of(path,pdfs.get(0)).toString()));
|
if (!pdfs.isEmpty()) previewListeners.forEach(l -> l.show(Path.of(path,pdfs.get(0)).toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void joinDocs(String path) {
|
public void joinDocs(String path) {
|
||||||
@@ -142,9 +160,7 @@ public class DocTable extends JPanel{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(String path) {
|
|
||||||
if (!rows.containsKey(path)) new Row(path).status("neu");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setState(String path, String state) {
|
public void setState(String path, String state) {
|
||||||
Row row = rows.get(path);
|
Row row = rows.get(path);
|
||||||
|
|||||||
@@ -108,12 +108,12 @@ public class MainFrame extends JFrame {
|
|||||||
|
|
||||||
pdfViewer = new SwingController();
|
pdfViewer = new SwingController();
|
||||||
SwingViewBuilder factory = new SwingViewBuilder(pdfViewer);
|
SwingViewBuilder factory = new SwingViewBuilder(pdfViewer);
|
||||||
|
|
||||||
JPanel viewerComponentPanel = factory.buildViewerPanel();
|
JPanel viewerComponentPanel = factory.buildViewerPanel();
|
||||||
|
|
||||||
ComponentKeyBinding.install(pdfViewer, viewerComponentPanel);
|
ComponentKeyBinding.install(pdfViewer, viewerComponentPanel);
|
||||||
// add interactive mouse link annotation support via callback
|
// add interactive mouse link annotation support via callback
|
||||||
pdfViewer.getDocumentViewController().setAnnotationCallback(new org.icepdf.ri.common.MyAnnotationCallback(pdfViewer.getDocumentViewController()));
|
pdfViewer.getDocumentViewController().setAnnotationCallback(new org.icepdf.ri.common.MyAnnotationCallback(pdfViewer.getDocumentViewController()));
|
||||||
|
|
||||||
return viewerComponentPanel;
|
return viewerComponentPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,7 +124,7 @@ public class MainFrame extends JFrame {
|
|||||||
toolbar.addFieldsFor(marks);
|
toolbar.addFieldsFor(marks);
|
||||||
};
|
};
|
||||||
|
|
||||||
private void performScan(String path) {
|
private void performScan(String path, Dimension dimension) {
|
||||||
LOG.debug("performScan({})",path);
|
LOG.debug("performScan({})",path);
|
||||||
toolbar.readyToScan(false);
|
toolbar.readyToScan(false);
|
||||||
File folder = new File(path);
|
File folder = new File(path);
|
||||||
@@ -187,6 +187,8 @@ public class MainFrame extends JFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Path.of(path, raw).toFile().delete();
|
Path.of(path, raw).toFile().delete();
|
||||||
|
docTable.preview(path);
|
||||||
|
|
||||||
String ocr = "page."+timestamp+".ocr.pdf";
|
String ocr = "page."+timestamp+".ocr.pdf";
|
||||||
|
|
||||||
cmd = new Vector<>();
|
cmd = new Vector<>();
|
||||||
@@ -214,11 +216,12 @@ public class MainFrame extends JFrame {
|
|||||||
}
|
}
|
||||||
Path.of(path, pdf).toFile().delete();
|
Path.of(path, pdf).toFile().delete();
|
||||||
docTable.setState(path,"Texterkennung beendet.");
|
docTable.setState(path,"Texterkennung beendet.");
|
||||||
|
docTable.preview(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void scan(ActionEvent ev) {
|
private void scan(ActionEvent ev) {
|
||||||
updateConfig();
|
updateConfig();
|
||||||
new Thread(() -> performScan(patchedPath)).start();
|
new Thread(() -> performScan(patchedPath,dimension)).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setCategory(String category) {
|
private void setCategory(String category) {
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ public class Toolbar extends JPanel {
|
|||||||
|
|
||||||
|
|
||||||
protected void updateDimensions() {
|
protected void updateDimensions() {
|
||||||
|
LOG.debug("updateDimensions()");
|
||||||
try {
|
try {
|
||||||
int w = Integer.parseInt(width.getText().trim());
|
int w = Integer.parseInt(width.getText().trim());
|
||||||
int h = Integer.parseInt(height.getText().trim());
|
int h = Integer.parseInt(height.getText().trim());
|
||||||
@@ -279,6 +280,7 @@ public class Toolbar extends JPanel {
|
|||||||
Integer h = config.get(prefix+"size.h");
|
Integer h = config.get(prefix+"size.h");
|
||||||
LOG.debug("h: {}",h);
|
LOG.debug("h: {}",h);
|
||||||
height.setText(h == null ? Constants.DEFAULT_HEIGHT : h+"");
|
height.setText(h == null ? Constants.DEFAULT_HEIGHT : h+"");
|
||||||
|
updateDimensions();
|
||||||
} else LOG.debug("newCat is empty!");
|
} else LOG.debug("newCat is empty!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user