summaryrefslogtreecommitdiff
path: root/platform/java/com
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@gmail.com>2016-07-13 03:13:51 +0800
committerSebastian Rasmussen <sebras@gmail.com>2016-07-15 02:19:54 +0800
commit48b7d735af8b5e38e6930df4174187e7f88d9b8d (patch)
treed7d56609430d4a37bff75d14bea0ed7ce6f306bd /platform/java/com
parent9f3f059c93a98715aa00f37d1ab1e3868fc1fb0f (diff)
downloadmupdf-48b7d735af8b5e38e6930df4174187e7f88d9b8d.tar.xz
Adding missing JNI interfaces.
Some objects get their interfaces expanded or the entire object is added both corresponding to what was already present in the mujs interface. Some interfaces, e.g. Buffer.writeLines() has been adapted to suit Java.
Diffstat (limited to 'platform/java/com')
-rw-r--r--platform/java/com/artifex/mupdf/fitz/Annotation.java3
-rw-r--r--platform/java/com/artifex/mupdf/fitz/Buffer.java39
-rw-r--r--platform/java/com/artifex/mupdf/fitz/DisplayList.java7
-rw-r--r--platform/java/com/artifex/mupdf/fitz/Document.java8
-rw-r--r--platform/java/com/artifex/mupdf/fitz/DocumentWriter.java27
-rw-r--r--platform/java/com/artifex/mupdf/fitz/Image.java1
-rw-r--r--platform/java/com/artifex/mupdf/fitz/PDFDocument.java57
-rw-r--r--platform/java/com/artifex/mupdf/fitz/PDFObject.java155
-rw-r--r--platform/java/com/artifex/mupdf/fitz/Page.java5
-rw-r--r--platform/java/com/artifex/mupdf/fitz/Path.java1
-rw-r--r--platform/java/com/artifex/mupdf/fitz/Pixmap.java9
-rw-r--r--platform/java/com/artifex/mupdf/fitz/StructuredText.java21
12 files changed, 333 insertions, 0 deletions
diff --git a/platform/java/com/artifex/mupdf/fitz/Annotation.java b/platform/java/com/artifex/mupdf/fitz/Annotation.java
index 5f652246..855ff5a1 100644
--- a/platform/java/com/artifex/mupdf/fitz/Annotation.java
+++ b/platform/java/com/artifex/mupdf/fitz/Annotation.java
@@ -16,6 +16,9 @@ public class Annotation
}
public native void run(Device dev, Matrix ctm, Cookie cookie);
+ public native Pixmap toPixmap(Matrix ctm, ColorSpace colorspace, boolean alpha);
+ public native Rect getBounds();
+ public native DisplayList toDisplayList();
private native long advance();
}
diff --git a/platform/java/com/artifex/mupdf/fitz/Buffer.java b/platform/java/com/artifex/mupdf/fitz/Buffer.java
new file mode 100644
index 00000000..7f23b062
--- /dev/null
+++ b/platform/java/com/artifex/mupdf/fitz/Buffer.java
@@ -0,0 +1,39 @@
+package com.artifex.mupdf.fitz;
+
+public class Buffer
+{
+ static {
+ Context.init();
+ }
+
+ public static final int DEFAULT_BUFFER_SIZE = 1024;
+
+ private long pointer;
+
+ protected native void finalize();
+
+ public void destroy() {
+ finalize();
+ pointer = 0;
+ }
+
+ private native long newNativeBuffer(int n);
+
+ public Buffer(int n) {
+ pointer = newNativeBuffer(n);
+ }
+
+ public Buffer() {
+ pointer = newNativeBuffer(DEFAULT_BUFFER_SIZE);
+ }
+
+ public native int getLength();
+ public native void writeByte(byte b);
+ public native void writeBytes(byte[] bs);
+ public native void writeBuffer(Buffer buf);
+ public native void writeRune(int rune);
+ public native void writeLine(String line);
+ public native void writeLines(String... lines);
+
+ public native void save(String filename);
+}
diff --git a/platform/java/com/artifex/mupdf/fitz/DisplayList.java b/platform/java/com/artifex/mupdf/fitz/DisplayList.java
index 1933f9ae..3e822eea 100644
--- a/platform/java/com/artifex/mupdf/fitz/DisplayList.java
+++ b/platform/java/com/artifex/mupdf/fitz/DisplayList.java
@@ -17,6 +17,13 @@ public class DisplayList
pointer = newNative();
}
+ private DisplayList(long p) {
+ pointer = p;
+ }
+
+ public native Pixmap toPixmap(Matrix ctm, ColorSpace colorspace, boolean alpha);
+ public native Rect[] search(String needle);
+
public native void run(Device dev, Matrix ctm, Rect scissor, Cookie cookie);
public void run(Device dev, Matrix ctm, Cookie cookie) {
diff --git a/platform/java/com/artifex/mupdf/fitz/Document.java b/platform/java/com/artifex/mupdf/fitz/Document.java
index 22d2f9bf..89e3013b 100644
--- a/platform/java/com/artifex/mupdf/fitz/Document.java
+++ b/platform/java/com/artifex/mupdf/fitz/Document.java
@@ -32,6 +32,10 @@ public class Document
pointer = newNativeWithBuffer(buffer, magic);
}
+ private Document(long p) {
+ pointer = p;
+ }
+
public native boolean needsPassword();
public native boolean authenticatePassword(String password);
@@ -39,6 +43,10 @@ public class Document
public native Page loadPage(int number);
public native Outline loadOutline();
public native String getMetaData(String key);
+ public native boolean isReflowable();
+ public native void layout(float width, float height, float em);
public native boolean isUnencryptedPDF();
+
+ public native PDFDocument toPDFDocument();
}
diff --git a/platform/java/com/artifex/mupdf/fitz/DocumentWriter.java b/platform/java/com/artifex/mupdf/fitz/DocumentWriter.java
new file mode 100644
index 00000000..dce9d73d
--- /dev/null
+++ b/platform/java/com/artifex/mupdf/fitz/DocumentWriter.java
@@ -0,0 +1,27 @@
+package com.artifex.mupdf.fitz;
+
+public class DocumentWriter
+{
+ static {
+ Context.init();
+ }
+
+ private long pointer;
+
+ protected native void finalize();
+
+ public void destroy() {
+ finalize();
+ pointer = 0;
+ }
+
+ private native long newNativeDocumentWriter(String filename, String format, String options);
+
+ public DocumentWriter(String filename, String format, String options) {
+ pointer = newNativeDocumentWriter(filename, format, options);
+ }
+
+ public native Device beingPage(Rect mediabox);
+ public native void endPage(Device device);
+ public native void close();
+}
diff --git a/platform/java/com/artifex/mupdf/fitz/Image.java b/platform/java/com/artifex/mupdf/fitz/Image.java
index a9eb2ffa..4d2f7eb5 100644
--- a/platform/java/com/artifex/mupdf/fitz/Image.java
+++ b/platform/java/com/artifex/mupdf/fitz/Image.java
@@ -31,6 +31,7 @@ public class Image
public native int getXResolution();
public native int getYResolution();
+ public native ColorSpace getColorSpace();
public native int getNumberOfComponents();
public native int getBitsPerComponent();
public native boolean getImageMask();
diff --git a/platform/java/com/artifex/mupdf/fitz/PDFDocument.java b/platform/java/com/artifex/mupdf/fitz/PDFDocument.java
new file mode 100644
index 00000000..58a3e3a6
--- /dev/null
+++ b/platform/java/com/artifex/mupdf/fitz/PDFDocument.java
@@ -0,0 +1,57 @@
+package com.artifex.mupdf.fitz;
+
+public class PDFDocument
+{
+ static {
+ Context.init();
+ }
+
+ private long pointer;
+
+ protected native void finalize();
+
+ public void destroy() {
+ finalize();
+ pointer = 0;
+ }
+
+ private PDFDocument(long p) {
+ pointer = p;
+ }
+
+ public native Document toDocument();
+
+ public native int countPages();
+ public native PDFObject findPage(int at);
+
+ public native PDFObject getTrailer();
+ public native int countObjects();
+
+ public native PDFObject newNull();
+ public native PDFObject newBoolean(boolean b);
+ public native PDFObject newInteger(int i);
+ public native PDFObject newReal(float f);
+ public native PDFObject newString(String s);
+ public native PDFObject newName(String name);
+ public native PDFObject newIndirect(int num, int gen);
+ public native PDFObject newArray();
+ public native PDFObject newDictionary();
+
+ public native PDFObject addObject(PDFObject obj);
+ public native PDFObject createObject();
+ public native void deleteObject(int i);
+
+ public native PDFObject addStream(Buffer buf);
+
+ public native PDFObject addPage(Rect mediabox, int rotate, PDFObject resources, Buffer contents);
+ public native void insertPage(int at, PDFObject page);
+ public native void deletePage(int at);
+ public native PDFObject addImage(Image image);
+ public native PDFObject addSimpleFont(Font font);
+ public native PDFObject addFont(Font font);
+ public native void save(String filename, String options);
+
+ public void deleteObject(PDFObject obj) {
+ deleteObject(obj.toIndirect());
+ }
+}
diff --git a/platform/java/com/artifex/mupdf/fitz/PDFObject.java b/platform/java/com/artifex/mupdf/fitz/PDFObject.java
new file mode 100644
index 00000000..f2e926f2
--- /dev/null
+++ b/platform/java/com/artifex/mupdf/fitz/PDFObject.java
@@ -0,0 +1,155 @@
+package com.artifex.mupdf.fitz;
+
+public class PDFObject
+{
+ static {
+ Context.init();
+ }
+
+ private long pointer;
+
+ protected native void finalize();
+
+ public void destroy() {
+ finalize();
+ pointer = 0;
+ }
+
+ private PDFObject(long p) {
+ pointer = p;
+ }
+
+ public native boolean isIndirect();
+ public native boolean isNull();
+ public native boolean isBoolean();
+ public native boolean isInteger();
+ public native boolean isReal();
+ public native boolean isNumber();
+ public native boolean isString();
+ public native boolean isName();
+ public native boolean isArray();
+ public native boolean isDictionary();
+ public native boolean isStream();
+
+ public native boolean toBoolean();
+ public native int toInteger();
+ public native float toFloat();
+ public native byte[] toByteString();
+ public native int toIndirect();
+ public native String toString(boolean tight);
+
+ public String toString() {
+ return toString(false);
+ }
+
+ public native PDFObject resolve();
+
+ public native byte[] readStream();
+ public native byte[] readRawStream();
+
+ public native PDFObject getArray(int index);
+ public native PDFObject getDictionary(String name);
+
+ public PDFObject get(int index) {
+ return getArray(index);
+ }
+
+ public PDFObject get(String name) {
+ return getDictionary(name);
+ }
+
+ public native void putArrayBoolean(int index, boolean b);
+ public native void putArrayInteger(int index, int i);
+ public native void putArrayFloat(int index, float f);
+ public native void putArrayString(int index, String str);
+ public native void putArrayPDFObject(int index, PDFObject obj);
+
+ public native void putDictionaryStringBoolean(String name, boolean b);
+ public native void putDictionaryStringInteger(String name, int i);
+ public native void putDictionaryStringFloat(String name, float f);
+ public native void putDictionaryStringString(String name, String str);
+ public native void putDictionaryStringPDFObject(String name, PDFObject obj);
+
+ public native void putDictionaryPDFObjectBoolean(PDFObject name, boolean b);
+ public native void putDictionaryPDFObjectInteger(PDFObject name, int i);
+ public native void putDictionaryPDFObjectFloat(PDFObject name, float f);
+ public native void putDictionaryPDFObjectString(PDFObject name, String str);
+ public native void putDictionaryPDFObjectPDFObject(PDFObject name, PDFObject obj);
+
+
+ public void put(int index, boolean b) {
+ putArrayBoolean(index, b);
+ }
+
+ public void put(int index, int i) {
+ putArrayInteger(index, i);
+ }
+
+ public void put(int index, float f) {
+ putArrayFloat(index, f);
+ }
+
+ public void put(int index, String s) {
+ putArrayString(index, s);
+ }
+
+ public void put(int index, PDFObject obj) {
+ putArrayPDFObject(index, obj);
+ }
+
+ public void put(String name, boolean b) {
+ putDictionaryStringBoolean(name, b);
+ }
+
+ public void put(String name, int i) {
+ putDictionaryStringInteger(name, i);
+ }
+
+ public void put(String name, float f) {
+ putDictionaryStringFloat(name, f);
+ }
+
+ public void put(String name, String str) {
+ putDictionaryStringString(name, str);
+ }
+
+ public void put(String name, PDFObject obj) {
+ putDictionaryStringPDFObject(name, obj);
+ }
+
+ public void put(PDFObject name, boolean b) {
+ putDictionaryPDFObjectBoolean(name, b);
+ }
+
+ public void put(PDFObject name, int i) {
+ putDictionaryPDFObjectInteger(name, i);
+ }
+
+ public void put(PDFObject name, float f) {
+ putDictionaryPDFObjectFloat(name, f);
+ }
+
+ public void put(PDFObject name, String str) {
+ putDictionaryPDFObjectString(name, str);
+ }
+
+ public void put(PDFObject name, PDFObject obj) {
+ putDictionaryPDFObjectPDFObject(name, obj);
+ }
+
+ public native void deleteArray(int index);
+ public native void deleteDictionaryString(String name);
+ public native void deleteDictionaryPDFObject(PDFObject name);
+
+ public void delete(int index) {
+ deleteArray(index);
+ }
+
+ public void delete(String name) {
+ deleteDictionaryString(name);
+ }
+
+ public void delete(PDFObject name) {
+ deleteDictionaryPDFObject(name);
+ }
+}
diff --git a/platform/java/com/artifex/mupdf/fitz/Page.java b/platform/java/com/artifex/mupdf/fitz/Page.java
index 71f39857..64fe4030 100644
--- a/platform/java/com/artifex/mupdf/fitz/Page.java
+++ b/platform/java/com/artifex/mupdf/fitz/Page.java
@@ -35,4 +35,9 @@ public class Page
// FIXME: Later. Much later.
//fz_transition *fz_page_presentation(fz_document *doc, fz_page *page, float *duration);
+
+ public native DisplayList toDisplayList(boolean no_annotations);
+ public native StructuredText toStructuredText();
+
+ public native Rect[] search(String needle);
}
diff --git a/platform/java/com/artifex/mupdf/fitz/Path.java b/platform/java/com/artifex/mupdf/fitz/Path.java
index fa925bab..455dce69 100644
--- a/platform/java/com/artifex/mupdf/fitz/Path.java
+++ b/platform/java/com/artifex/mupdf/fitz/Path.java
@@ -33,6 +33,7 @@ public class Path implements PathWalker
public native void curveTo(float cx1, float cy1, float cx2, float cy2, float ex, float ey);
public native void curveToV(float cx, float cy, float ex, float ey);
public native void curveToY(float cx, float cy, float ex, float ey);
+ public native void rect(int x1, int y1, int x2, int y2);
public native void closePath();
public void moveTo(Point xy) {
diff --git a/platform/java/com/artifex/mupdf/fitz/Pixmap.java b/platform/java/com/artifex/mupdf/fitz/Pixmap.java
index ac14e95c..52432fea 100644
--- a/platform/java/com/artifex/mupdf/fitz/Pixmap.java
+++ b/platform/java/com/artifex/mupdf/fitz/Pixmap.java
@@ -55,12 +55,21 @@ public class Pixmap
public native boolean getAlpha();
public native ColorSpace getColorSpace();
public native byte[] getSamples();
+ public native byte getSamples(int x, int y, int n);
public native int[] getPixels(); /* only valid for RGBA or BGRA pixmaps */
+ public native int getXResolution();
+ public native int getYResolution();
public void clear(int value) {
clearWithValue(value);
}
+ public Rect getBounds() {
+ int x = getX();
+ int y = getY();
+ return new Rect(x, y, x + getWidth(), y+ getHeight());
+ }
+
public String toString() {
return "Pixmap(w=" + getWidth() +
" h=" + getHeight() +
diff --git a/platform/java/com/artifex/mupdf/fitz/StructuredText.java b/platform/java/com/artifex/mupdf/fitz/StructuredText.java
new file mode 100644
index 00000000..0f3549d5
--- /dev/null
+++ b/platform/java/com/artifex/mupdf/fitz/StructuredText.java
@@ -0,0 +1,21 @@
+package com.artifex.mupdf.fitz;
+
+public class StructuredText
+{
+ private long pointer;
+
+ protected native void finalize();
+
+ public void destroy() {
+ finalize();
+ pointer = 0;
+ }
+
+ private StructuredText(long p) {
+ pointer = p;
+ }
+
+ public native Rect[] search(String needle);
+ public native Rect[] highlight(Rect rect);
+ public native String copy(Rect rect);
+}