diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2016-02-22 15:00:29 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2016-02-29 16:03:34 +0100 |
commit | 7609158e702ece6e182b19cec8b0192b1af598e8 (patch) | |
tree | d6611bc8243a457b2fe90bfebd72454e93601288 /platform/java/Viewer.java | |
parent | e1716629fd92f4580e6b213dc7be54b4935f09f9 (diff) | |
download | mupdf-7609158e702ece6e182b19cec8b0192b1af598e8.tar.xz |
jni: Various cleanups.
jni: Various cleanups.
Fix gcc and clang warnings.
Android specific functions are guarded by HAVE_ANDROID define.
The java guts of the android stuff is removed for now, to be added back in later.
Set up a makefile and simple tests to build for desktop java.
Rerig device classes to: Device, NativeDevice, JavaDevice and DrawDevice.
Add Pixmap class.
Regularize naming.
General cleanups and abbreviate naming.
Use to_JavaClass and from_JavaClass rather than
fz_mupdf_struct_from_JavaClass and JavaClass_from_fz_mupdf_struct.
Check for exceptions thrown by java devices and path processor.
Tweak constructors and finalizers to remove the JavaDevice subclass.
Use toString when rethrowing java exceptions as fitz exceptions.
Diffstat (limited to 'platform/java/Viewer.java')
-rw-r--r-- | platform/java/Viewer.java | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/platform/java/Viewer.java b/platform/java/Viewer.java new file mode 100644 index 00000000..e0d6290b --- /dev/null +++ b/platform/java/Viewer.java @@ -0,0 +1,67 @@ +import com.artifex.mupdf.fitz.*; +import java.awt.Frame; +import java.awt.Label; +import java.awt.BorderLayout; +import java.awt.event.*; + +public class Viewer extends Frame implements WindowListener +{ + protected Document doc; + protected PageCanvas pageCanvas; + protected Label pageLabel; + protected int count; + + public Viewer(Document doc_) { + super("MuPDF"); + + this.doc = doc_; + this.count = doc.countPages(); + + setSize(600, 900); + + pageCanvas = new PageCanvas(doc.loadPage(1144)); + pageLabel = new Label("page " + 1); + + add(pageLabel, BorderLayout.NORTH); + add(pageCanvas, BorderLayout.CENTER); + + addWindowListener(this); + + { + Page page = doc.loadPage(0); + Device dev = new Device() { + public void beginPage(Rect r, Matrix m) { + System.out.println("beginPage " + r + m); + } + public void fillText(Text text, Matrix ctm, ColorSpace cs, float color[], float alpha) { + System.out.println("fillText " + text); + text.walk(new TextWalker() { + public void showGlyph(Font f, boolean v, Matrix m, int g, int c) { + System.out.println(f + " " + m + " " + g + " " + (char)c); + } + }); + } + }; + page.run(dev, new Matrix(), null); + } + } + + // WindowListener + + public void windowClosing(WindowEvent event) { + System.exit(0); + } + + public void windowActivated(WindowEvent event) { } + public void windowDeactivated(WindowEvent event) { } + public void windowIconified(WindowEvent event) { } + public void windowDeiconified(WindowEvent event) { } + public void windowOpened(WindowEvent event) { } + public void windowClosed(WindowEvent event) { } + + public static void main(String[] args) { + Document doc = new Document("pdfref17.pdf"); + Viewer app = new Viewer(doc); + app.setVisible(true); + } +} |