From cb78b5c6782f14a699f90bd5621cd3656a1e02ea Mon Sep 17 00:00:00 2001 From: fred ross-perry Date: Thu, 14 Jul 2016 16:05:15 -0700 Subject: java - move fitz sources into a 'src' subfolder. --- platform/java/Makefile | 12 +- platform/java/Makejar | 4 +- .../java/com/artifex/mupdf/fitz/Annotation.java | 24 --- platform/java/com/artifex/mupdf/fitz/Buffer.java | 39 ----- .../java/com/artifex/mupdf/fitz/ColorSpace.java | 45 ------ platform/java/com/artifex/mupdf/fitz/Context.java | 28 ---- platform/java/com/artifex/mupdf/fitz/Cookie.java | 21 --- platform/java/com/artifex/mupdf/fitz/Device.java | 104 ------------- .../java/com/artifex/mupdf/fitz/DisplayList.java | 32 ---- .../com/artifex/mupdf/fitz/DisplayListDevice.java | 10 -- platform/java/com/artifex/mupdf/fitz/Document.java | 52 ------- .../com/artifex/mupdf/fitz/DocumentWriter.java | 27 ---- .../java/com/artifex/mupdf/fitz/DrawDevice.java | 10 -- platform/java/com/artifex/mupdf/fitz/Font.java | 40 ----- platform/java/com/artifex/mupdf/fitz/Image.java | 42 ------ platform/java/com/artifex/mupdf/fitz/Link.java | 19 --- platform/java/com/artifex/mupdf/fitz/Matrix.java | 163 --------------------- .../java/com/artifex/mupdf/fitz/NativeDevice.java | 47 ------ platform/java/com/artifex/mupdf/fitz/Outline.java | 17 --- .../java/com/artifex/mupdf/fitz/PDFDocument.java | 57 ------- .../java/com/artifex/mupdf/fitz/PDFObject.java | 155 -------------------- platform/java/com/artifex/mupdf/fitz/Page.java | 43 ------ platform/java/com/artifex/mupdf/fitz/Path.java | 64 -------- .../java/com/artifex/mupdf/fitz/PathWalker.java | 9 -- platform/java/com/artifex/mupdf/fitz/Pixmap.java | 83 ----------- platform/java/com/artifex/mupdf/fitz/Point.java | 30 ---- platform/java/com/artifex/mupdf/fitz/Rect.java | 77 ---------- platform/java/com/artifex/mupdf/fitz/RectI.java | 80 ---------- platform/java/com/artifex/mupdf/fitz/Shade.java | 17 --- .../java/com/artifex/mupdf/fitz/StrokeState.java | 55 ------- .../com/artifex/mupdf/fitz/StructuredText.java | 21 --- platform/java/com/artifex/mupdf/fitz/Text.java | 43 ------ .../java/com/artifex/mupdf/fitz/TextWalker.java | 6 - .../com/artifex/mupdf/fitz/TryLaterException.java | 8 - platform/java/mupdf_native.c | 2 +- .../src/com/artifex/mupdf/fitz/Annotation.java | 24 +++ .../java/src/com/artifex/mupdf/fitz/Buffer.java | 39 +++++ .../src/com/artifex/mupdf/fitz/ColorSpace.java | 45 ++++++ .../java/src/com/artifex/mupdf/fitz/Context.java | 28 ++++ .../java/src/com/artifex/mupdf/fitz/Cookie.java | 21 +++ .../java/src/com/artifex/mupdf/fitz/Device.java | 104 +++++++++++++ .../src/com/artifex/mupdf/fitz/DisplayList.java | 32 ++++ .../com/artifex/mupdf/fitz/DisplayListDevice.java | 10 ++ .../java/src/com/artifex/mupdf/fitz/Document.java | 52 +++++++ .../src/com/artifex/mupdf/fitz/DocumentWriter.java | 27 ++++ .../src/com/artifex/mupdf/fitz/DrawDevice.java | 10 ++ platform/java/src/com/artifex/mupdf/fitz/Font.java | 40 +++++ .../java/src/com/artifex/mupdf/fitz/Image.java | 42 ++++++ platform/java/src/com/artifex/mupdf/fitz/Link.java | 19 +++ .../java/src/com/artifex/mupdf/fitz/Matrix.java | 163 +++++++++++++++++++++ .../src/com/artifex/mupdf/fitz/NativeDevice.java | 47 ++++++ .../java/src/com/artifex/mupdf/fitz/Outline.java | 17 +++ .../src/com/artifex/mupdf/fitz/PDFDocument.java | 57 +++++++ .../java/src/com/artifex/mupdf/fitz/PDFObject.java | 155 ++++++++++++++++++++ platform/java/src/com/artifex/mupdf/fitz/Page.java | 43 ++++++ platform/java/src/com/artifex/mupdf/fitz/Path.java | 64 ++++++++ .../src/com/artifex/mupdf/fitz/PathWalker.java | 9 ++ .../java/src/com/artifex/mupdf/fitz/Pixmap.java | 83 +++++++++++ .../java/src/com/artifex/mupdf/fitz/Point.java | 30 ++++ platform/java/src/com/artifex/mupdf/fitz/Rect.java | 77 ++++++++++ .../java/src/com/artifex/mupdf/fitz/RectI.java | 80 ++++++++++ .../java/src/com/artifex/mupdf/fitz/Shade.java | 17 +++ .../src/com/artifex/mupdf/fitz/StrokeState.java | 55 +++++++ .../src/com/artifex/mupdf/fitz/StructuredText.java | 21 +++ platform/java/src/com/artifex/mupdf/fitz/Text.java | 43 ++++++ .../src/com/artifex/mupdf/fitz/TextWalker.java | 6 + .../com/artifex/mupdf/fitz/TryLaterException.java | 8 + .../mupdf/fitz/android/AndroidDrawDevice.java | 25 ++++ 68 files changed, 1502 insertions(+), 1477 deletions(-) delete mode 100644 platform/java/com/artifex/mupdf/fitz/Annotation.java delete mode 100644 platform/java/com/artifex/mupdf/fitz/Buffer.java delete mode 100644 platform/java/com/artifex/mupdf/fitz/ColorSpace.java delete mode 100644 platform/java/com/artifex/mupdf/fitz/Context.java delete mode 100644 platform/java/com/artifex/mupdf/fitz/Cookie.java delete mode 100644 platform/java/com/artifex/mupdf/fitz/Device.java delete mode 100644 platform/java/com/artifex/mupdf/fitz/DisplayList.java delete mode 100644 platform/java/com/artifex/mupdf/fitz/DisplayListDevice.java delete mode 100644 platform/java/com/artifex/mupdf/fitz/Document.java delete mode 100644 platform/java/com/artifex/mupdf/fitz/DocumentWriter.java delete mode 100644 platform/java/com/artifex/mupdf/fitz/DrawDevice.java delete mode 100644 platform/java/com/artifex/mupdf/fitz/Font.java delete mode 100644 platform/java/com/artifex/mupdf/fitz/Image.java delete mode 100644 platform/java/com/artifex/mupdf/fitz/Link.java delete mode 100644 platform/java/com/artifex/mupdf/fitz/Matrix.java delete mode 100644 platform/java/com/artifex/mupdf/fitz/NativeDevice.java delete mode 100644 platform/java/com/artifex/mupdf/fitz/Outline.java delete mode 100644 platform/java/com/artifex/mupdf/fitz/PDFDocument.java delete mode 100644 platform/java/com/artifex/mupdf/fitz/PDFObject.java delete mode 100644 platform/java/com/artifex/mupdf/fitz/Page.java delete mode 100644 platform/java/com/artifex/mupdf/fitz/Path.java delete mode 100644 platform/java/com/artifex/mupdf/fitz/PathWalker.java delete mode 100644 platform/java/com/artifex/mupdf/fitz/Pixmap.java delete mode 100644 platform/java/com/artifex/mupdf/fitz/Point.java delete mode 100644 platform/java/com/artifex/mupdf/fitz/Rect.java delete mode 100644 platform/java/com/artifex/mupdf/fitz/RectI.java delete mode 100644 platform/java/com/artifex/mupdf/fitz/Shade.java delete mode 100644 platform/java/com/artifex/mupdf/fitz/StrokeState.java delete mode 100644 platform/java/com/artifex/mupdf/fitz/StructuredText.java delete mode 100644 platform/java/com/artifex/mupdf/fitz/Text.java delete mode 100644 platform/java/com/artifex/mupdf/fitz/TextWalker.java delete mode 100644 platform/java/com/artifex/mupdf/fitz/TryLaterException.java create mode 100644 platform/java/src/com/artifex/mupdf/fitz/Annotation.java create mode 100644 platform/java/src/com/artifex/mupdf/fitz/Buffer.java create mode 100644 platform/java/src/com/artifex/mupdf/fitz/ColorSpace.java create mode 100644 platform/java/src/com/artifex/mupdf/fitz/Context.java create mode 100644 platform/java/src/com/artifex/mupdf/fitz/Cookie.java create mode 100644 platform/java/src/com/artifex/mupdf/fitz/Device.java create mode 100644 platform/java/src/com/artifex/mupdf/fitz/DisplayList.java create mode 100644 platform/java/src/com/artifex/mupdf/fitz/DisplayListDevice.java create mode 100644 platform/java/src/com/artifex/mupdf/fitz/Document.java create mode 100644 platform/java/src/com/artifex/mupdf/fitz/DocumentWriter.java create mode 100644 platform/java/src/com/artifex/mupdf/fitz/DrawDevice.java create mode 100644 platform/java/src/com/artifex/mupdf/fitz/Font.java create mode 100644 platform/java/src/com/artifex/mupdf/fitz/Image.java create mode 100644 platform/java/src/com/artifex/mupdf/fitz/Link.java create mode 100644 platform/java/src/com/artifex/mupdf/fitz/Matrix.java create mode 100644 platform/java/src/com/artifex/mupdf/fitz/NativeDevice.java create mode 100644 platform/java/src/com/artifex/mupdf/fitz/Outline.java create mode 100644 platform/java/src/com/artifex/mupdf/fitz/PDFDocument.java create mode 100644 platform/java/src/com/artifex/mupdf/fitz/PDFObject.java create mode 100644 platform/java/src/com/artifex/mupdf/fitz/Page.java create mode 100644 platform/java/src/com/artifex/mupdf/fitz/Path.java create mode 100644 platform/java/src/com/artifex/mupdf/fitz/PathWalker.java create mode 100644 platform/java/src/com/artifex/mupdf/fitz/Pixmap.java create mode 100644 platform/java/src/com/artifex/mupdf/fitz/Point.java create mode 100644 platform/java/src/com/artifex/mupdf/fitz/Rect.java create mode 100644 platform/java/src/com/artifex/mupdf/fitz/RectI.java create mode 100644 platform/java/src/com/artifex/mupdf/fitz/Shade.java create mode 100644 platform/java/src/com/artifex/mupdf/fitz/StrokeState.java create mode 100644 platform/java/src/com/artifex/mupdf/fitz/StructuredText.java create mode 100644 platform/java/src/com/artifex/mupdf/fitz/Text.java create mode 100644 platform/java/src/com/artifex/mupdf/fitz/TextWalker.java create mode 100644 platform/java/src/com/artifex/mupdf/fitz/TryLaterException.java create mode 100644 platform/java/src/com/artifex/mupdf/fitz/android/AndroidDrawDevice.java (limited to 'platform/java') diff --git a/platform/java/Makefile b/platform/java/Makefile index 32d08dd7..1762c512 100644 --- a/platform/java/Makefile +++ b/platform/java/Makefile @@ -29,9 +29,9 @@ $(MUPDF_CORE) : $(MAKE) -C ../.. OUT=build/java XCFLAGS=-fPIC build=release libs endif -LIBRARY_JAVA_SOURCES := $(sort $(wildcard com/artifex/mupdf/fitz/*.java)) +LIBRARY_JAVA_SOURCES := $(sort $(wildcard src/com/artifex/mupdf/fitz/*.java)) LIBRARY_JAVA_OBJECTS := $(LIBRARY_JAVA_SOURCES:%.java=%.class) -LIBRARY_JAVA_CLASSES := $(subst com/artifex/mupdf/fitz/,com.artifex.mupdf.fitz.,$(LIBRARY_JAVA_SOURCES:%.java=%)) +LIBRARY_JAVA_CLASSES := $(subst src/com/artifex/mupdf/fitz/,com.artifex.mupdf.fitz.,$(LIBRARY_JAVA_SOURCES:%.java=%)) $(LIBRARY_JAVA_OBJECTS) : $(LIBRARY_JAVA_SOURCES) javac -source 1.7 -target 1.7 $^ @@ -40,7 +40,7 @@ EXAMPLE_JAVA_SOURCES := $(sort $(wildcard example/*.java)) EXAMPLE_JAVA_OBJECTS := $(EXAMPLE_JAVA_SOURCES:%.java=%.class) $(EXAMPLE_JAVA_OBJECTS) : $(EXAMPLE_JAVA_SOURCES) - javac -source 1.7 -target 1.7 $^ + javac -source 1.7 -target 1.7 -classpath .:src $^ libmupdf.jar : $(LIBRARY_JAVA_OBJECTS) rm -f $@ @@ -48,7 +48,7 @@ libmupdf.jar : $(LIBRARY_JAVA_OBJECTS) mupdf_native.h : $(LIBRARY_JAVA_OBJECTS) rm -f $@ - javah -o $@ $(LIBRARY_JAVA_CLASSES) + javah -classpath .:src -o $@ $(LIBRARY_JAVA_CLASSES) mupdf_native.o : mupdf_native.c mupdf_native.h $(CC) -g -o $@ -c $< -fPIC -Wall -Wextra -Wno-unused-parameter -I ../../include \ @@ -58,10 +58,10 @@ $(MUPDF_JAVA) : mupdf_native.o $(MUPDF_CORE) $(CC) -shared -o $(MUPDF_JAVA) $^ $(JAVA_LIBS) viewer: $(MUPDF_JAVA) $(EXAMPLE_JAVA_OBJECTS) - LD_LIBRARY_PATH=. java example.Viewer + LD_LIBRARY_PATH=. java -classpath .:src example.Viewer clean: - rm -f com/artifex/mupdf/fitz/*.class + rm -f src/com/artifex/mupdf/fitz/*.class rm -f example/*.class rm -f mupdf_native.o rm -f $(MUPDF_JAVA) diff --git a/platform/java/Makejar b/platform/java/Makejar index 3f98127a..74d7503c 100644 --- a/platform/java/Makejar +++ b/platform/java/Makejar @@ -1,3 +1,3 @@ default: - javac -source 1.7 -target 1.7 com/artifex/mupdf/fitz/*.java - jar cf libmupdf.jar com/artifex/mupdf/fitz/*.class + javac -source 1.7 -target 1.7 src/com/artifex/mupdf/fitz/*.java + jar cf libmupdf.jar src/com/artifex/mupdf/fitz/*.class diff --git a/platform/java/com/artifex/mupdf/fitz/Annotation.java b/platform/java/com/artifex/mupdf/fitz/Annotation.java deleted file mode 100644 index 855ff5a1..00000000 --- a/platform/java/com/artifex/mupdf/fitz/Annotation.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.artifex.mupdf.fitz; - -public class Annotation -{ - private long pointer; - - protected native void finalize(); - - public void destroy() { - finalize(); - pointer = 0; - } - - private Annotation(long p) { - pointer = p; - } - - 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 deleted file mode 100644 index 7f23b062..00000000 --- a/platform/java/com/artifex/mupdf/fitz/Buffer.java +++ /dev/null @@ -1,39 +0,0 @@ -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/ColorSpace.java b/platform/java/com/artifex/mupdf/fitz/ColorSpace.java deleted file mode 100644 index b7822161..00000000 --- a/platform/java/com/artifex/mupdf/fitz/ColorSpace.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.artifex.mupdf.fitz; - -public class ColorSpace -{ - private long pointer; - - protected native void finalize(); - - public void destroy() { - finalize(); - pointer = 0; - } - - private ColorSpace(long p) { - pointer = p; - } - - private static native long nativeDeviceGray(); - private static native long nativeDeviceRGB(); - private static native long nativeDeviceBGR(); - private static native long nativeDeviceCMYK(); - - protected static ColorSpace fromPointer(long p) { - if (p == DeviceGray.pointer) return DeviceGray; - if (p == DeviceRGB.pointer) return DeviceRGB; - if (p == DeviceBGR.pointer) return DeviceBGR; - if (p == DeviceCMYK.pointer) return DeviceCMYK; - return new ColorSpace(p); - } - - public static ColorSpace DeviceGray = new ColorSpace(nativeDeviceGray()); - public static ColorSpace DeviceRGB = new ColorSpace(nativeDeviceRGB()); - public static ColorSpace DeviceBGR = new ColorSpace(nativeDeviceBGR()); - public static ColorSpace DeviceCMYK = new ColorSpace(nativeDeviceCMYK()); - - public native int getNumberOfComponents(); - - public String toString() { - if (this == DeviceGray) return "DeviceGray"; - if (this == DeviceRGB) return "DeviceRGB"; - if (this == DeviceBGR) return "DeviceBGR"; - if (this == DeviceCMYK) return "DeviceCMYK"; - return "ColorSpace(" + getNumberOfComponents() + ")"; - } -} diff --git a/platform/java/com/artifex/mupdf/fitz/Context.java b/platform/java/com/artifex/mupdf/fitz/Context.java deleted file mode 100644 index 3614e65f..00000000 --- a/platform/java/com/artifex/mupdf/fitz/Context.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.artifex.mupdf.fitz; - -// This class handles the loading of the MuPDF shared library, together -// with the ThreadLocal magic to get the required context. -// -// The only publicly accessible method here is Context.setStoreSize, which -// sets the store size to use. This must be called before any other MuPDF -// function. -public class Context -{ - private static boolean inited = false; - private static native int initNative(); - - public static void init() { - if (!inited) { - inited = true; - System.loadLibrary("mupdf_java"); - if (initNative() < 0) - throw new RuntimeException("cannot initialize mupdf library"); - } - } - - static { init(); } - - // FIXME: We should support the store size being changed dynamically. - // This requires changes within the MuPDF core. - //public native static void setStoreSize(long newSize); -} diff --git a/platform/java/com/artifex/mupdf/fitz/Cookie.java b/platform/java/com/artifex/mupdf/fitz/Cookie.java deleted file mode 100644 index f866f99e..00000000 --- a/platform/java/com/artifex/mupdf/fitz/Cookie.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.artifex.mupdf.fitz; - -public class Cookie -{ - private long pointer; - - protected native void finalize(); - - public void destroy() { - finalize(); - pointer = 0; - } - - private native long newNative(); - - public Cookie() { - pointer = newNative(); - } - - public native void abort(); -} diff --git a/platform/java/com/artifex/mupdf/fitz/Device.java b/platform/java/com/artifex/mupdf/fitz/Device.java deleted file mode 100644 index 295226fe..00000000 --- a/platform/java/com/artifex/mupdf/fitz/Device.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.artifex.mupdf.fitz; - -public class Device -{ - protected long pointer; - - protected native void finalize(); - - public void destroy() { - finalize(); - pointer = 0; - } - - private native long newNative(); - - protected Device() { - pointer = newNative(); - } - - protected Device(long p) { - pointer = p; - } - - /* An accessor for device hints */ - public native int getHints(); - public native void enableDeviceHints(int hints); - public native void disableDeviceHints(int hints); - - /* To implement your own device in Java, you should define your own - * class that extends Device, and override as many of the following - * functions as is appropriate. For example: - * - * class ImageTraceDevice extends Device - * { - * void fillImage(Image img, Matrix ctx, float alpha) { - * System.out.println("Image!"); - * } - * }; - */ - - public void close() {} - public void fillPath(Path path, boolean evenOdd, Matrix ctm, ColorSpace cs, float color[], float alpha) {} - public void strokePath(Path path, StrokeState stroke, Matrix ctm, ColorSpace cs, float color[], float alpha) {} - public void clipPath(Path path, boolean evenOdd, Matrix ctm) {} - public void clipStrokePath(Path path, StrokeState stroke, Matrix ctm) {} - public void fillText(Text text, Matrix ctm, ColorSpace cs, float color[], float alpha) {} - public void strokeText(Text text, StrokeState stroke, Matrix ctm, ColorSpace cs, float color[], float alpha) {} - public void clipText(Text text, Matrix ctm) {} - public void clipStrokeText(Text text, StrokeState stroke, Matrix ctm) {} - public void ignoreText(Text text, Matrix ctm) {} - public void fillShade(Shade shd, Matrix ctm, float alpha) {} - public void fillImage(Image img, Matrix ctm, float alpha) {} - public void fillImageMask(Image img, Matrix ctm, ColorSpace cs, float color[], float alpha) {} - public void clipImageMask(Image img, Matrix ctm) {} - public void popClip() {} - public void beginMask(Rect area, boolean luminosity, ColorSpace cs, float bc[]) {} - public void endMask() {} - public void beginGroup(Rect area, boolean isolated, boolean knockout, int blendmode, float alpha) {} - public void endGroup() {} - public int beginTile(Rect area, Rect view, float xstep, float ystep, Matrix ctm, int id) { return 0; } - public void endTile() {} - - /* Flags */ - public static final int FZ_DEVFLAG_MASK = 1; - public static final int FZ_DEVFLAG_COLOR = 2; - public static final int FZ_DEVFLAG_UNCACHEABLE = 4; - public static final int FZ_DEVFLAG_FILLCOLOR_UNDEFINED = 8; - public static final int FZ_DEVFLAG_STROKECOLOR_UNDEFINED = 16; - public static final int FZ_DEVFLAG_STARTCAP_UNDEFINED = 32; - public static final int FZ_DEVFLAG_DASHCAP_UNDEFINED = 64; - public static final int FZ_DEVFLAG_ENDCAP_UNDEFINED = 128; - public static final int FZ_DEVFLAG_LINEJOIN_UNDEFINED = 256; - public static final int FZ_DEVFLAG_MITERLIMIT_UNDEFINED = 512; - public static final int FZ_DEVFLAG_LINEWIDTH_UNDEFINED = 1024; - - /* PDF 1.4 -- standard separable */ - public static final int FZ_BLEND_NORMAL = 0; - public static final int FZ_BLEND_MULTIPLY = 1; - public static final int FZ_BLEND_SCREEN = 2; - public static final int FZ_BLEND_OVERLAY = 3; - public static final int FZ_BLEND_DARKEN = 4; - public static final int FZ_BLEND_LIGHTEN = 5; - public static final int FZ_BLEND_COLOR_DODGE = 6; - public static final int FZ_BLEND_COLOR_BURN = 7; - public static final int FZ_BLEND_HARD_LIGHT = 8; - public static final int FZ_BLEND_SOFT_LIGHT = 9; - public static final int FZ_BLEND_DIFFERENCE = 10; - public static final int FZ_BLEND_EXCLUSION = 11; - - /* PDF 1.4 -- standard non-separable */ - public static final int FZ_BLEND_HUE = 12; - public static final int FZ_BLEND_SATURATION = 13; - public static final int FZ_BLEND_COLOR = 14; - public static final int FZ_BLEND_LUMINOSITY = 15; - - /* For packing purposes */ - public static final int FZ_BLEND_MODEMASK = 15; - public static final int FZ_BLEND_ISOLATED = 16; - public static final int FZ_BLEND_KNOCKOUT = 32; - - /* Device hints */ - public static final int FZ_IGNORE_IMAGE = 1; - public static final int FZ_IGNORE_SHADE = 2; -} diff --git a/platform/java/com/artifex/mupdf/fitz/DisplayList.java b/platform/java/com/artifex/mupdf/fitz/DisplayList.java deleted file mode 100644 index 3e822eea..00000000 --- a/platform/java/com/artifex/mupdf/fitz/DisplayList.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.artifex.mupdf.fitz; - -public class DisplayList -{ - private long pointer; - - protected native void finalize(); - - public void destroy() { - finalize(); - pointer = 0; - } - - private native long newNative(); - - public 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) { - run(dev, ctm, null, cookie); - } -} diff --git a/platform/java/com/artifex/mupdf/fitz/DisplayListDevice.java b/platform/java/com/artifex/mupdf/fitz/DisplayListDevice.java deleted file mode 100644 index c7f7c935..00000000 --- a/platform/java/com/artifex/mupdf/fitz/DisplayListDevice.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.artifex.mupdf.fitz; - -public final class DisplayListDevice extends NativeDevice -{ - private static native long newNative(DisplayList list); - - public DisplayListDevice(DisplayList list) { - super(newNative(list)); - } -} diff --git a/platform/java/com/artifex/mupdf/fitz/Document.java b/platform/java/com/artifex/mupdf/fitz/Document.java deleted file mode 100644 index 89e3013b..00000000 --- a/platform/java/com/artifex/mupdf/fitz/Document.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.artifex.mupdf.fitz; - -public class Document -{ - static { - Context.init(); - } - - public static final String META_FORMAT = "format"; - public static final String META_ENCRYPTION = "encryption"; - public static final String META_INFO_AUTHOR = "info:Author"; - public static final String META_INFO_TITLE = "info:Title"; - - private long pointer; - - protected native void finalize(); - - public void destroy() { - finalize(); - pointer = 0; - } - - private native long newNativeWithPath(String filename); - private native long newNativeWithBuffer(byte buffer[], String magic); - // private native long newNativeWithRandomAccessFile(RandomAccessFile file, String magic); - - public Document(String filename) { - pointer = newNativeWithPath(filename); - } - - public Document(byte buffer[], String magic) { - pointer = newNativeWithBuffer(buffer, magic); - } - - private Document(long p) { - pointer = p; - } - - public native boolean needsPassword(); - public native boolean authenticatePassword(String password); - - public native int countPages(); - 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 deleted file mode 100644 index dce9d73d..00000000 --- a/platform/java/com/artifex/mupdf/fitz/DocumentWriter.java +++ /dev/null @@ -1,27 +0,0 @@ -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/DrawDevice.java b/platform/java/com/artifex/mupdf/fitz/DrawDevice.java deleted file mode 100644 index e022be10..00000000 --- a/platform/java/com/artifex/mupdf/fitz/DrawDevice.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.artifex.mupdf.fitz; - -public final class DrawDevice extends NativeDevice -{ - private static native long newNative(Pixmap pixmap); - - public DrawDevice(Pixmap pixmap) { - super(newNative(pixmap)); - } -} diff --git a/platform/java/com/artifex/mupdf/fitz/Font.java b/platform/java/com/artifex/mupdf/fitz/Font.java deleted file mode 100644 index 5101a6ac..00000000 --- a/platform/java/com/artifex/mupdf/fitz/Font.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.artifex.mupdf.fitz; - -public class Font -{ - private long pointer; - - protected native void finalize(); - - public void destroy() { - finalize(); - pointer = 0; - } - - private native long newNative(String name, int index); - - private Font(long p) { - pointer = p; - } - - public Font(String name, int index) { - pointer = newNative(name, index); - } - - public Font(String name) { - pointer = newNative(name, 0); - } - - public native String getName(); - - public native int encodeCharacter(int unicode); - public native float advanceGlyph(int glyph, boolean wmode); - - public float advanceGlyph(int glyph) { - return advanceGlyph(glyph, false); - } - - public String toString() { - return "Font(" + getName() + ")"; - } -} diff --git a/platform/java/com/artifex/mupdf/fitz/Image.java b/platform/java/com/artifex/mupdf/fitz/Image.java deleted file mode 100644 index 4d2f7eb5..00000000 --- a/platform/java/com/artifex/mupdf/fitz/Image.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.artifex.mupdf.fitz; - -public class Image -{ - private long pointer; - - protected native void finalize(); - - public void destroy() { - finalize(); - pointer = 0; - } - - private native long newNativeFromPixmap(Pixmap pixmap); - private native long newNativeFromFile(String filename); - - private Image(long p) { - pointer = p; - } - - public Image(Pixmap pixmap) { - pointer = newNativeFromPixmap(pixmap); - } - - public Image(String filename) { - pointer = newNativeFromFile(filename); - } - - public native int getWidth(); - public native int getHeight(); - public native int getXResolution(); - public native int getYResolution(); - - public native ColorSpace getColorSpace(); - public native int getNumberOfComponents(); - public native int getBitsPerComponent(); - public native boolean getImageMask(); - public native boolean getInterpolate(); - public native Image getMask(); - - public native Pixmap toPixmap(); -} diff --git a/platform/java/com/artifex/mupdf/fitz/Link.java b/platform/java/com/artifex/mupdf/fitz/Link.java deleted file mode 100644 index 0ecd8307..00000000 --- a/platform/java/com/artifex/mupdf/fitz/Link.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.artifex.mupdf.fitz; - -public class Link -{ - private long pointer; - - protected native void finalize(); - - public void destroy() { - finalize(); - pointer = 0; - } - - private Link(long p) { - pointer = p; - } - - public native Link getNext(); -} diff --git a/platform/java/com/artifex/mupdf/fitz/Matrix.java b/platform/java/com/artifex/mupdf/fitz/Matrix.java deleted file mode 100644 index 80da84fc..00000000 --- a/platform/java/com/artifex/mupdf/fitz/Matrix.java +++ /dev/null @@ -1,163 +0,0 @@ -package com.artifex.mupdf.fitz; - -public class Matrix -{ - public float a, b, c, d, e, f; - - public Matrix(float a, float b, float c, float d, float e, float f) { - this.a = a; - this.b = b; - this.c = c; - this.d = d; - this.e = e; - this.f = f; - } - - public Matrix(float a, float b, float c, float d) { - this(a, b, c, d, 0, 0); - } - - public Matrix(float a, float d) { - this(a, 0, 0, d, 0, 0); - } - - public Matrix(float a) { - this(a, 0, 0, a, 0, 0); - } - - public Matrix() { - this(1, 0, 0, 1, 0, 0); - } - - public Matrix(Matrix one, Matrix two) { - a = one.a * two.a + one.b * two.c; - b = one.a * two.b + one.b * two.d; - c = one.c * two.a + one.d * two.c; - d = one.c * two.b + one.d * two.d; - e = one.e * two.a + one.f * two.c + two.e; - f = one.e * two.b + one.f * two.d + two.f; - } - - public Matrix concat(Matrix m) { - float a = this.a * m.a + this.b * m.c; - float b = this.a * m.b + this.b * m.d; - float c = this.c * m.a + this.d * m.c; - float d = this.c * m.b + this.d * m.d; - float e = this.e * m.a + this.f * m.c + m.e; - this.f = this.e * m.b + this.f * m.d + m.f; - - this.a = a; - this.b = b; - this.c = c; - this.d = d; - this.e = e; - - return this; - } - - public Matrix scale(float sx, float sy) { - a *= sx; - b *= sx; - c *= sy; - d *= sy; - return this; - } - - public Matrix scale(float s) { - return scale(s, s); - } - - public Matrix translate(float tx, float ty) { - e += tx * a + ty * c; - f += tx * b + ty * d; - return this; - } - - public Matrix rotate(float degrees) { - while (degrees < 0) - degrees += 360; - while (degrees >= 360) - degrees -= 360; - - if (Math.abs(0 - degrees) < 0.0001) { - // Nothing to do - } else if (Math.abs(90 - degrees) < 0.0001) { - float save_a = a; - float save_b = b; - a = c; - b = d; - c = -save_a; - d = -save_b; - } else if (Math.abs(180 - degrees) < 0.0001) { - a = -a; - b = -b; - c = -c; - d = -d; - } else if (Math.abs(270 - degrees) < 0.0001) { - float save_a = a; - float save_b = b; - a = -c; - b = -d; - c = save_a; - d = save_b; - } else { - float sin = (float)Math.sin(degrees * Math.PI / 180.0); - float cos = (float)Math.cos(degrees * Math.PI / 180.0); - float save_a = a; - float save_b = b; - a = cos * save_a + sin * c; - b = cos * save_b + sin * d; - c = -sin * save_a + cos * c; - d = -sin * save_b + cos * d; - } - return this; - } - - public String toString() { - return "[" + a + " " + b + " " + c + " " + d + " " + e + " " + f + "]"; - } - - public static Matrix Identity() { - return new Matrix(1, 0, 0, 1, 0, 0); - } - - public static Matrix Scale(float x) { - return new Matrix(x, 0, 0, x, 0, 0); - } - - public static Matrix Scale(float x, float y) { - return new Matrix(x, 0, 0, y, 0, 0); - } - - public static Matrix Translate(float x, float y) { - return new Matrix(1, 0, 0, 1, x, y); - } - - public static Matrix Rotate(float degrees) { - float sin, cos; - - while (degrees < 0) - degrees += 360; - while (degrees >= 360) - degrees -= 360; - - if (Math.abs(0 - degrees) < 0.0001) { - sin = 0; - cos = 1; - } else if (Math.abs(90 - degrees) < 0.0001) { - sin = 1; - cos = 0; - } else if (Math.abs(180 - degrees) < 0.0001) { - sin = 0; - cos = -1; - } else if (Math.abs(270 - degrees) < 0.0001) { - sin = -1; - cos = 0; - } else { - sin = (float)Math.sin(degrees * Math.PI / 180.0); - cos = (float)Math.cos(degrees * Math.PI / 180.0); - } - - return new Matrix(cos, sin, -sin, cos, 0, 0); - } -} diff --git a/platform/java/com/artifex/mupdf/fitz/NativeDevice.java b/platform/java/com/artifex/mupdf/fitz/NativeDevice.java deleted file mode 100644 index 0d2b9159..00000000 --- a/platform/java/com/artifex/mupdf/fitz/NativeDevice.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.artifex.mupdf.fitz; - -public class NativeDevice extends Device -{ - private long nativeInfo; - private Object nativeResource; - - protected native void finalize(); - - public void destroy() { - super.destroy(); - nativeInfo = 0; - nativeResource = null; - } - - protected NativeDevice(long p) { - super(p); - } - - public native final void close(); - - public native final void fillPath(Path path, boolean evenOdd, Matrix ctm, ColorSpace cs, float color[], float alpha); - public native final void strokePath(Path path, StrokeState stroke, Matrix ctm, ColorSpace cs, float color[], float alpha); - public native final void clipPath(Path path, boolean evenOdd, Matrix ctm); - public native final void clipStrokePath(Path path, StrokeState stroke, Matrix ctm); - - public native final void fillText(Text text, Matrix ctm, ColorSpace cs, float color[], float alpha); - public native final void strokeText(Text text, StrokeState stroke, Matrix ctm, ColorSpace cs, float color[], float alpha); - public native final void clipText(Text text, Matrix ctm); - public native final void clipStrokeText(Text text, StrokeState stroke, Matrix ctm); - public native final void ignoreText(Text text, Matrix ctm); - - public native final void fillShade(Shade shd, Matrix ctm, float alpha); - public native final void fillImage(Image img, Matrix ctm, float alpha); - public native final void fillImageMask(Image img, Matrix ctm, ColorSpace cs, float color[], float alpha); - public native final void clipImageMask(Image img, Matrix ctm); - - public native final void popClip(); - - public native final void beginMask(Rect rect, boolean luminosity, ColorSpace cs, float bc[]); - public native final void endMask(); - public native final void beginGroup(Rect rect, boolean isolated, boolean knockout, int blendmode, float alpha); - public native final void endGroup(); - - public native final int beginTile(Rect area, Rect view, float xstep, float ystep, Matrix ctm, int id); - public native final void endTile(); -} diff --git a/platform/java/com/artifex/mupdf/fitz/Outline.java b/platform/java/com/artifex/mupdf/fitz/Outline.java deleted file mode 100644 index 98a11b79..00000000 --- a/platform/java/com/artifex/mupdf/fitz/Outline.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.artifex.mupdf.fitz; - -public class Outline -{ - private long pointer; - - protected native void finalize(); - - public void destroy() { - finalize(); - pointer = 0; - } - - private Outline(long p) { - pointer = p; - } -} diff --git a/platform/java/com/artifex/mupdf/fitz/PDFDocument.java b/platform/java/com/artifex/mupdf/fitz/PDFDocument.java deleted file mode 100644 index 58a3e3a6..00000000 --- a/platform/java/com/artifex/mupdf/fitz/PDFDocument.java +++ /dev/null @@ -1,57 +0,0 @@ -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 deleted file mode 100644 index f2e926f2..00000000 --- a/platform/java/com/artifex/mupdf/fitz/PDFObject.java +++ /dev/null @@ -1,155 +0,0 @@ -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 deleted file mode 100644 index 64fe4030..00000000 --- a/platform/java/com/artifex/mupdf/fitz/Page.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.artifex.mupdf.fitz; - -public class Page -{ - private long pointer; - private Annotation nativeAnnots[]; - - protected native void finalize(); - - public void destroy() { - finalize(); - pointer = 0; - nativeAnnots = null; - } - - private Page(long p) { - pointer = p; - nativeAnnots = null; - } - - public native Rect getBounds(); - - public native Pixmap toPixmap(Matrix ctm, ColorSpace cs, boolean alpha); - - public native void run(Device dev, Matrix ctm, Cookie cookie); - public native void runPageContents(Device dev, Matrix ctm, Cookie cookie); - public native Annotation[] getAnnotations(); - - public void run(Device dev, Matrix ctm) { - run(dev, ctm, null); - } - - // FIXME: Later - public native Link[] getLinks(); - - // 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 deleted file mode 100644 index 455dce69..00000000 --- a/platform/java/com/artifex/mupdf/fitz/Path.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.artifex.mupdf.fitz; - -public class Path implements PathWalker -{ - private long pointer; - - protected native void finalize(); - - public void destroy() { - finalize(); - pointer = 0; - } - - private native long newNative(); - private native long cloneNative(); - - public Path() { - pointer = newNative(); - } - - private Path(long p) { - pointer = p; - } - - public Path(Path old) { - pointer = old.cloneNative(); - } - - public native Point currentPoint(); - - public native void moveTo(float x, float y); - public native void lineTo(float x, float y); - 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) { - moveTo(xy.x, xy.y); - } - - public void lineTo(Point xy) { - lineTo(xy.x, xy.y); - } - - public void curveTo(Point c1, Point c2, Point e) { - curveTo(c1.x, c1.y, c2.x, c2.y, e.x, e.y); - } - - public void curveToV(Point c, Point e) { - curveToV(c.x, c.y, e.x, e.y); - } - - public void curveToY(Point c, Point e) { - curveToY(c.x, c.y, e.x, e.y); - } - - public native void transform(Matrix mat); - - public native Rect getBounds(StrokeState stroke, Matrix ctm); - - public native void walk(PathWalker walker); -} diff --git a/platform/java/com/artifex/mupdf/fitz/PathWalker.java b/platform/java/com/artifex/mupdf/fitz/PathWalker.java deleted file mode 100644 index 66d1b49b..00000000 --- a/platform/java/com/artifex/mupdf/fitz/PathWalker.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.artifex.mupdf.fitz; - -public interface PathWalker -{ - public void moveTo(float x, float y); - public void lineTo(float x, float y); - public void curveTo(float cx1, float cy1, float cx2, float cy2, float ex, float ey); - public void closePath(); -} diff --git a/platform/java/com/artifex/mupdf/fitz/Pixmap.java b/platform/java/com/artifex/mupdf/fitz/Pixmap.java deleted file mode 100644 index 52432fea..00000000 --- a/platform/java/com/artifex/mupdf/fitz/Pixmap.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.artifex.mupdf.fitz; - -public class Pixmap -{ - private long pointer; - - protected native void finalize(); - - public void destroy() { - finalize(); - pointer = 0; - } - - private native long newNative(ColorSpace cs, int x, int y, int w, int h, boolean alpha); - - private Pixmap(long p) { - pointer = p; - } - - public Pixmap(ColorSpace cs, int x, int y, int w, int h, boolean alpha) { - pointer = newNative(cs, x, y, w, h, alpha); - } - - public Pixmap(ColorSpace cs, int x, int y, int w, int h) { - this(cs, x, y, w, h, false); - } - - public Pixmap(ColorSpace cs, int w, int h, boolean alpha) { - this(cs, 0, 0, w, h, alpha); - } - - public Pixmap(ColorSpace cs, int w, int h) { - this(cs, 0, 0, w, h, false); - } - - public Pixmap(ColorSpace cs, Rect rect, boolean alpha) { - this(cs, (int)rect.x0, (int)rect.y0, (int)(rect.x1 - rect.x0), (int)(rect.y1 - rect.y0), alpha); - } - - public Pixmap(ColorSpace cs, Rect rect) { - this(cs, rect, false); - } - - public native void clear(); - public native void clearWithValue(int value); - - public native void saveAsPNG(String filename); - - public native int getX(); - public native int getY(); - public native int getWidth(); - public native int getHeight(); - public native int getStride(); - public native int getNumberOfComponents(); - 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() + - " x=" + getX() + - " y=" + getY() + - " n=" + getNumberOfComponents() + - " alpha=" + getAlpha() + - " cs=" + getColorSpace() + - ")"; - } -} diff --git a/platform/java/com/artifex/mupdf/fitz/Point.java b/platform/java/com/artifex/mupdf/fitz/Point.java deleted file mode 100644 index b32198bc..00000000 --- a/platform/java/com/artifex/mupdf/fitz/Point.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.artifex.mupdf.fitz; - -public class Point -{ - public float x; - public float y; - - public Point(float x, float y) { - this.x = x; - this.y = y; - } - - public Point(Point p) { - this.x = p.x; - this.y = p.y; - } - - public String toString() { - return "[" + x + " " + y + "]"; - } - - public Point transform(Matrix tm) { - float old_x = this.x; - - this.x = old_x * tm.a + y * tm.c + tm.e; - this.y = old_x * tm.b + y * tm.d + tm.f; - - return this; - } -} diff --git a/platform/java/com/artifex/mupdf/fitz/Rect.java b/platform/java/com/artifex/mupdf/fitz/Rect.java deleted file mode 100644 index 819646e8..00000000 --- a/platform/java/com/artifex/mupdf/fitz/Rect.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.artifex.mupdf.fitz; - -public class Rect -{ - public float x0; - public float y0; - public float x1; - public float y1; - - public Rect(float x0, float y0, float x1, float y1) { - this.x0 = x0; - this.y0 = y0; - this.x1 = x1; - this.y1 = y1; - } - - public Rect(Rect r) { - this(r.x0, r.y0, r.x1, r.y1); - } - - public Rect(RectI r) { - this(r.x0, r.y0, r.x1, r.y1); - } - - public String toString() { - return "[" + x0 + " " + y0 + " " + x1 + " " + y1 + "]"; - } - - public Rect transform(Matrix tm) { - float ax0 = x0 * tm.a; - float ax1 = x1 * tm.a; - - if (ax0 > ax1) { - float t = ax0; - ax0 = ax1; - ax1 = t; - } - - float cy0 = y0 * tm.c; - float cy1 = y1 * tm.c; - - if (cy0 > cy1) { - float t = cy0; - cy0 = cy1; - cy1 = t; - } - ax0 += cy0 + tm.e; - ax1 += cy1 + tm.e; - - float bx0 = x0 * tm.b; - float bx1 = x1 * tm.b; - - if (bx0 > bx1) { - float t = bx0; - bx0 = bx1; - bx1 = t; - } - - float dy0 = y0 * tm.d; - float dy1 = y1 * tm.d; - - if (dy0 > dy1) { - float t = dy0; - dy0 = dy1; - dy1 = t; - } - bx0 += dy0 + tm.f; - bx1 += dy1 + tm.f; - - x0 = ax0; - x1 = ax1; - y0 = bx0; - y1 = bx1; - - return this; - } -} diff --git a/platform/java/com/artifex/mupdf/fitz/RectI.java b/platform/java/com/artifex/mupdf/fitz/RectI.java deleted file mode 100644 index 8e46a3f2..00000000 --- a/platform/java/com/artifex/mupdf/fitz/RectI.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.artifex.mupdf.fitz; - -public class RectI -{ - public int x0; - public int y0; - public int x1; - public int y1; - - public RectI(int x0, int y0, int x1, int y1) { - this.x0 = x0; - this.y0 = y0; - this.x1 = x1; - this.y1 = y1; - } - - public RectI(RectI r) { - this(r.x0, r.y0, r.x1, r.y1); - } - - public RectI(Rect r) { - this.x0 = (int)Math.floor(r.x0); - this.y0 = (int)Math.ceil(r.y0); - this.x1 = (int)Math.floor(r.x1); - this.y1 = (int)Math.ceil(r.y1); - } - - public String toString() { - return "[" + x0 + " " + y0 + " " + x1 + " " + y1 + "]"; - } - - public RectI transform(Matrix tm) { - float ax0 = x0 * tm.a; - float ax1 = x1 * tm.a; - - if (ax0 > ax1) { - float t = ax0; - ax0 = ax1; - ax1 = t; - } - - float cy0 = y0 * tm.c; - float cy1 = y1 * tm.c; - - if (cy0 > cy1) { - float t = cy0; - cy0 = cy1; - cy1 = t; - } - ax0 += cy0 + tm.e; - ax1 += cy1 + tm.e; - - float bx0 = x0 * tm.b; - float bx1 = x1 * tm.b; - - if (bx0 > bx1) { - float t = bx0; - bx0 = bx1; - bx1 = t; - } - - float dy0 = y0 * tm.d; - float dy1 = y1 * tm.d; - - if (dy0 > dy1) { - float t = dy0; - dy0 = dy1; - dy1 = t; - } - bx0 += dy0 + tm.f; - bx1 += dy1 + tm.f; - - x0 = (int)Math.floor(ax0); - x1 = (int)Math.ceil(ax1); - y0 = (int)Math.floor(bx0); - y1 = (int)Math.ceil(bx1); - - return this; - } -} diff --git a/platform/java/com/artifex/mupdf/fitz/Shade.java b/platform/java/com/artifex/mupdf/fitz/Shade.java deleted file mode 100644 index 35182cb8..00000000 --- a/platform/java/com/artifex/mupdf/fitz/Shade.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.artifex.mupdf.fitz; - -public class Shade -{ - private long pointer; - - protected native void finalize(); - - public void destroy() { - finalize(); - pointer = 0; - } - - private Shade(long p) { - pointer = p; - } -} diff --git a/platform/java/com/artifex/mupdf/fitz/StrokeState.java b/platform/java/com/artifex/mupdf/fitz/StrokeState.java deleted file mode 100644 index 7f333f76..00000000 --- a/platform/java/com/artifex/mupdf/fitz/StrokeState.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.artifex.mupdf.fitz; - -public class StrokeState -{ - public static final int FZ_LINECAP_BUTT = 0; - public static final int FZ_LINECAP_ROUND = 1; - public static final int FZ_LINECAP_SQUARE = 2; - public static final int FZ_LINECAP_TRIANGLE = 3; - - public static final int FZ_LINEJOIN_MITER = 0; - public static final int FZ_LINEJOIN_ROUND = 1; - public static final int FZ_LINEJOIN_BEVEL = 2; - public static final int FZ_LINEJOIN_MITER_XPS = 3; - - private long pointer; - - protected native void finalize(); - - public void destroy() { - finalize(); - pointer = 0; - } - - private native long newNative(int startCap, int dashCap, int endCap, int lineJoin, float lineWidth, float miterLimit, - float dashPhase, float dash[]); - - // Private constructor for the C to use. Any objects created by the - // C are done for purposes of calling back to a java device, and - // should therefore be considered const. This is fine as we don't - // currently provide mechanisms for changing individual elements - // of the StrokeState. - private StrokeState(long p) { - pointer = p; - } - - public StrokeState(int startCap, int endCap, int lineJoin, float lineWidth, float miterLimit) { - pointer = newNative(startCap, 0, endCap, lineJoin, lineWidth, miterLimit, 0, null); - } - - public StrokeState(int startCap, int dashCap, int endCap, int lineJoin, float lineWidth, float miterLimit, - float dashPhase, float dash[]) { - pointer = newNative(startCap, dashCap, endCap, lineJoin, lineWidth, miterLimit, dashPhase, dash); - } - - public native void adjustRectForStroke(Rect rect, Matrix ctm); - - public native int getStartCap(); - public native int getDashCap(); - public native int getEndCap(); - public native int getLineJoin(); - public native float getLineWidth(); - public native float getMiterLimit(); - public native float getDashPhase(); - public native float[] getDashes(); -} diff --git a/platform/java/com/artifex/mupdf/fitz/StructuredText.java b/platform/java/com/artifex/mupdf/fitz/StructuredText.java deleted file mode 100644 index 0f3549d5..00000000 --- a/platform/java/com/artifex/mupdf/fitz/StructuredText.java +++ /dev/null @@ -1,21 +0,0 @@ -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); -} diff --git a/platform/java/com/artifex/mupdf/fitz/Text.java b/platform/java/com/artifex/mupdf/fitz/Text.java deleted file mode 100644 index 5bbe8abe..00000000 --- a/platform/java/com/artifex/mupdf/fitz/Text.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.artifex.mupdf.fitz; - -public class Text implements TextWalker -{ - private long pointer; - - protected native void finalize(); - - public void destroy() { - finalize(); - pointer = 0; - } - - private native long newNative(); - private native long cloneNative(Text old); - - private Text(long p) { - pointer = p; - } - - public Text(Text old) { - pointer = cloneNative(old); - } - - public Text() { - pointer = newNative(); - } - - public native void showGlyph(Font font, Matrix trm, int glyph, int unicode, boolean wmode); - public native void showString(Font font, Matrix trm, String str, boolean wmode); - - public native Rect getBounds(StrokeState stroke, Matrix ctm); - - public void showGlyph(Font font, Matrix trm, int glyph, int unicode) { - showGlyph(font, trm, glyph, unicode, false); - } - - public void showString(Font font, Matrix trm, String str) { - showString(font, trm, str, false); - } - - public native void walk(TextWalker walker); -} diff --git a/platform/java/com/artifex/mupdf/fitz/TextWalker.java b/platform/java/com/artifex/mupdf/fitz/TextWalker.java deleted file mode 100644 index 911c19bc..00000000 --- a/platform/java/com/artifex/mupdf/fitz/TextWalker.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.artifex.mupdf.fitz; - -public interface TextWalker -{ - public void showGlyph(Font font, Matrix trm, int glyph, int unicode, boolean wmode); -} diff --git a/platform/java/com/artifex/mupdf/fitz/TryLaterException.java b/platform/java/com/artifex/mupdf/fitz/TryLaterException.java deleted file mode 100644 index e2d1b88e..00000000 --- a/platform/java/com/artifex/mupdf/fitz/TryLaterException.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.artifex.mupdf.fitz; - -public class TryLaterException extends Exception -{ - TryLaterException(String message) { - super(message); - } -} diff --git a/platform/java/mupdf_native.c b/platform/java/mupdf_native.c index ef9a04b8..e960cb5c 100644 --- a/platform/java/mupdf_native.c +++ b/platform/java/mupdf_native.c @@ -2245,7 +2245,7 @@ static void androidDrawDevice_unlock(JNIEnv *env, NativeDeviceInfo *info) } JNIEXPORT jlong JNICALL -FUN(AndroidDrawDevice_newNative)(JNIEnv *env, jclass self, jobject jbitmap, jint pageX0, jint pageY0, jint pageX1, jint pageY1, jint patchX0, jint patchY0, jint patchX1, jint patchY1) +FUN(android_AndroidDrawDevice_newNative)(JNIEnv *env, jclass self, jobject jbitmap, jint pageX0, jint pageY0, jint pageX1, jint pageY1, jint patchX0, jint patchY0, jint patchX1, jint patchY1) { fz_context *ctx = get_context(env); AndroidBitmapInfo info; diff --git a/platform/java/src/com/artifex/mupdf/fitz/Annotation.java b/platform/java/src/com/artifex/mupdf/fitz/Annotation.java new file mode 100644 index 00000000..855ff5a1 --- /dev/null +++ b/platform/java/src/com/artifex/mupdf/fitz/Annotation.java @@ -0,0 +1,24 @@ +package com.artifex.mupdf.fitz; + +public class Annotation +{ + private long pointer; + + protected native void finalize(); + + public void destroy() { + finalize(); + pointer = 0; + } + + private Annotation(long p) { + pointer = p; + } + + 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/src/com/artifex/mupdf/fitz/Buffer.java b/platform/java/src/com/artifex/mupdf/fitz/Buffer.java new file mode 100644 index 00000000..7f23b062 --- /dev/null +++ b/platform/java/src/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/src/com/artifex/mupdf/fitz/ColorSpace.java b/platform/java/src/com/artifex/mupdf/fitz/ColorSpace.java new file mode 100644 index 00000000..b7822161 --- /dev/null +++ b/platform/java/src/com/artifex/mupdf/fitz/ColorSpace.java @@ -0,0 +1,45 @@ +package com.artifex.mupdf.fitz; + +public class ColorSpace +{ + private long pointer; + + protected native void finalize(); + + public void destroy() { + finalize(); + pointer = 0; + } + + private ColorSpace(long p) { + pointer = p; + } + + private static native long nativeDeviceGray(); + private static native long nativeDeviceRGB(); + private static native long nativeDeviceBGR(); + private static native long nativeDeviceCMYK(); + + protected static ColorSpace fromPointer(long p) { + if (p == DeviceGray.pointer) return DeviceGray; + if (p == DeviceRGB.pointer) return DeviceRGB; + if (p == DeviceBGR.pointer) return DeviceBGR; + if (p == DeviceCMYK.pointer) return DeviceCMYK; + return new ColorSpace(p); + } + + public static ColorSpace DeviceGray = new ColorSpace(nativeDeviceGray()); + public static ColorSpace DeviceRGB = new ColorSpace(nativeDeviceRGB()); + public static ColorSpace DeviceBGR = new ColorSpace(nativeDeviceBGR()); + public static ColorSpace DeviceCMYK = new ColorSpace(nativeDeviceCMYK()); + + public native int getNumberOfComponents(); + + public String toString() { + if (this == DeviceGray) return "DeviceGray"; + if (this == DeviceRGB) return "DeviceRGB"; + if (this == DeviceBGR) return "DeviceBGR"; + if (this == DeviceCMYK) return "DeviceCMYK"; + return "ColorSpace(" + getNumberOfComponents() + ")"; + } +} diff --git a/platform/java/src/com/artifex/mupdf/fitz/Context.java b/platform/java/src/com/artifex/mupdf/fitz/Context.java new file mode 100644 index 00000000..3614e65f --- /dev/null +++ b/platform/java/src/com/artifex/mupdf/fitz/Context.java @@ -0,0 +1,28 @@ +package com.artifex.mupdf.fitz; + +// This class handles the loading of the MuPDF shared library, together +// with the ThreadLocal magic to get the required context. +// +// The only publicly accessible method here is Context.setStoreSize, which +// sets the store size to use. This must be called before any other MuPDF +// function. +public class Context +{ + private static boolean inited = false; + private static native int initNative(); + + public static void init() { + if (!inited) { + inited = true; + System.loadLibrary("mupdf_java"); + if (initNative() < 0) + throw new RuntimeException("cannot initialize mupdf library"); + } + } + + static { init(); } + + // FIXME: We should support the store size being changed dynamically. + // This requires changes within the MuPDF core. + //public native static void setStoreSize(long newSize); +} diff --git a/platform/java/src/com/artifex/mupdf/fitz/Cookie.java b/platform/java/src/com/artifex/mupdf/fitz/Cookie.java new file mode 100644 index 00000000..f866f99e --- /dev/null +++ b/platform/java/src/com/artifex/mupdf/fitz/Cookie.java @@ -0,0 +1,21 @@ +package com.artifex.mupdf.fitz; + +public class Cookie +{ + private long pointer; + + protected native void finalize(); + + public void destroy() { + finalize(); + pointer = 0; + } + + private native long newNative(); + + public Cookie() { + pointer = newNative(); + } + + public native void abort(); +} diff --git a/platform/java/src/com/artifex/mupdf/fitz/Device.java b/platform/java/src/com/artifex/mupdf/fitz/Device.java new file mode 100644 index 00000000..295226fe --- /dev/null +++ b/platform/java/src/com/artifex/mupdf/fitz/Device.java @@ -0,0 +1,104 @@ +package com.artifex.mupdf.fitz; + +public class Device +{ + protected long pointer; + + protected native void finalize(); + + public void destroy() { + finalize(); + pointer = 0; + } + + private native long newNative(); + + protected Device() { + pointer = newNative(); + } + + protected Device(long p) { + pointer = p; + } + + /* An accessor for device hints */ + public native int getHints(); + public native void enableDeviceHints(int hints); + public native void disableDeviceHints(int hints); + + /* To implement your own device in Java, you should define your own + * class that extends Device, and override as many of the following + * functions as is appropriate. For example: + * + * class ImageTraceDevice extends Device + * { + * void fillImage(Image img, Matrix ctx, float alpha) { + * System.out.println("Image!"); + * } + * }; + */ + + public void close() {} + public void fillPath(Path path, boolean evenOdd, Matrix ctm, ColorSpace cs, float color[], float alpha) {} + public void strokePath(Path path, StrokeState stroke, Matrix ctm, ColorSpace cs, float color[], float alpha) {} + public void clipPath(Path path, boolean evenOdd, Matrix ctm) {} + public void clipStrokePath(Path path, StrokeState stroke, Matrix ctm) {} + public void fillText(Text text, Matrix ctm, ColorSpace cs, float color[], float alpha) {} + public void strokeText(Text text, StrokeState stroke, Matrix ctm, ColorSpace cs, float color[], float alpha) {} + public void clipText(Text text, Matrix ctm) {} + public void clipStrokeText(Text text, StrokeState stroke, Matrix ctm) {} + public void ignoreText(Text text, Matrix ctm) {} + public void fillShade(Shade shd, Matrix ctm, float alpha) {} + public void fillImage(Image img, Matrix ctm, float alpha) {} + public void fillImageMask(Image img, Matrix ctm, ColorSpace cs, float color[], float alpha) {} + public void clipImageMask(Image img, Matrix ctm) {} + public void popClip() {} + public void beginMask(Rect area, boolean luminosity, ColorSpace cs, float bc[]) {} + public void endMask() {} + public void beginGroup(Rect area, boolean isolated, boolean knockout, int blendmode, float alpha) {} + public void endGroup() {} + public int beginTile(Rect area, Rect view, float xstep, float ystep, Matrix ctm, int id) { return 0; } + public void endTile() {} + + /* Flags */ + public static final int FZ_DEVFLAG_MASK = 1; + public static final int FZ_DEVFLAG_COLOR = 2; + public static final int FZ_DEVFLAG_UNCACHEABLE = 4; + public static final int FZ_DEVFLAG_FILLCOLOR_UNDEFINED = 8; + public static final int FZ_DEVFLAG_STROKECOLOR_UNDEFINED = 16; + public static final int FZ_DEVFLAG_STARTCAP_UNDEFINED = 32; + public static final int FZ_DEVFLAG_DASHCAP_UNDEFINED = 64; + public static final int FZ_DEVFLAG_ENDCAP_UNDEFINED = 128; + public static final int FZ_DEVFLAG_LINEJOIN_UNDEFINED = 256; + public static final int FZ_DEVFLAG_MITERLIMIT_UNDEFINED = 512; + public static final int FZ_DEVFLAG_LINEWIDTH_UNDEFINED = 1024; + + /* PDF 1.4 -- standard separable */ + public static final int FZ_BLEND_NORMAL = 0; + public static final int FZ_BLEND_MULTIPLY = 1; + public static final int FZ_BLEND_SCREEN = 2; + public static final int FZ_BLEND_OVERLAY = 3; + public static final int FZ_BLEND_DARKEN = 4; + public static final int FZ_BLEND_LIGHTEN = 5; + public static final int FZ_BLEND_COLOR_DODGE = 6; + public static final int FZ_BLEND_COLOR_BURN = 7; + public static final int FZ_BLEND_HARD_LIGHT = 8; + public static final int FZ_BLEND_SOFT_LIGHT = 9; + public static final int FZ_BLEND_DIFFERENCE = 10; + public static final int FZ_BLEND_EXCLUSION = 11; + + /* PDF 1.4 -- standard non-separable */ + public static final int FZ_BLEND_HUE = 12; + public static final int FZ_BLEND_SATURATION = 13; + public static final int FZ_BLEND_COLOR = 14; + public static final int FZ_BLEND_LUMINOSITY = 15; + + /* For packing purposes */ + public static final int FZ_BLEND_MODEMASK = 15; + public static final int FZ_BLEND_ISOLATED = 16; + public static final int FZ_BLEND_KNOCKOUT = 32; + + /* Device hints */ + public static final int FZ_IGNORE_IMAGE = 1; + public static final int FZ_IGNORE_SHADE = 2; +} diff --git a/platform/java/src/com/artifex/mupdf/fitz/DisplayList.java b/platform/java/src/com/artifex/mupdf/fitz/DisplayList.java new file mode 100644 index 00000000..3e822eea --- /dev/null +++ b/platform/java/src/com/artifex/mupdf/fitz/DisplayList.java @@ -0,0 +1,32 @@ +package com.artifex.mupdf.fitz; + +public class DisplayList +{ + private long pointer; + + protected native void finalize(); + + public void destroy() { + finalize(); + pointer = 0; + } + + private native long newNative(); + + public 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) { + run(dev, ctm, null, cookie); + } +} diff --git a/platform/java/src/com/artifex/mupdf/fitz/DisplayListDevice.java b/platform/java/src/com/artifex/mupdf/fitz/DisplayListDevice.java new file mode 100644 index 00000000..c7f7c935 --- /dev/null +++ b/platform/java/src/com/artifex/mupdf/fitz/DisplayListDevice.java @@ -0,0 +1,10 @@ +package com.artifex.mupdf.fitz; + +public final class DisplayListDevice extends NativeDevice +{ + private static native long newNative(DisplayList list); + + public DisplayListDevice(DisplayList list) { + super(newNative(list)); + } +} diff --git a/platform/java/src/com/artifex/mupdf/fitz/Document.java b/platform/java/src/com/artifex/mupdf/fitz/Document.java new file mode 100644 index 00000000..89e3013b --- /dev/null +++ b/platform/java/src/com/artifex/mupdf/fitz/Document.java @@ -0,0 +1,52 @@ +package com.artifex.mupdf.fitz; + +public class Document +{ + static { + Context.init(); + } + + public static final String META_FORMAT = "format"; + public static final String META_ENCRYPTION = "encryption"; + public static final String META_INFO_AUTHOR = "info:Author"; + public static final String META_INFO_TITLE = "info:Title"; + + private long pointer; + + protected native void finalize(); + + public void destroy() { + finalize(); + pointer = 0; + } + + private native long newNativeWithPath(String filename); + private native long newNativeWithBuffer(byte buffer[], String magic); + // private native long newNativeWithRandomAccessFile(RandomAccessFile file, String magic); + + public Document(String filename) { + pointer = newNativeWithPath(filename); + } + + public Document(byte buffer[], String magic) { + pointer = newNativeWithBuffer(buffer, magic); + } + + private Document(long p) { + pointer = p; + } + + public native boolean needsPassword(); + public native boolean authenticatePassword(String password); + + public native int countPages(); + 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/src/com/artifex/mupdf/fitz/DocumentWriter.java b/platform/java/src/com/artifex/mupdf/fitz/DocumentWriter.java new file mode 100644 index 00000000..dce9d73d --- /dev/null +++ b/platform/java/src/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/src/com/artifex/mupdf/fitz/DrawDevice.java b/platform/java/src/com/artifex/mupdf/fitz/DrawDevice.java new file mode 100644 index 00000000..e022be10 --- /dev/null +++ b/platform/java/src/com/artifex/mupdf/fitz/DrawDevice.java @@ -0,0 +1,10 @@ +package com.artifex.mupdf.fitz; + +public final class DrawDevice extends NativeDevice +{ + private static native long newNative(Pixmap pixmap); + + public DrawDevice(Pixmap pixmap) { + super(newNative(pixmap)); + } +} diff --git a/platform/java/src/com/artifex/mupdf/fitz/Font.java b/platform/java/src/com/artifex/mupdf/fitz/Font.java new file mode 100644 index 00000000..5101a6ac --- /dev/null +++ b/platform/java/src/com/artifex/mupdf/fitz/Font.java @@ -0,0 +1,40 @@ +package com.artifex.mupdf.fitz; + +public class Font +{ + private long pointer; + + protected native void finalize(); + + public void destroy() { + finalize(); + pointer = 0; + } + + private native long newNative(String name, int index); + + private Font(long p) { + pointer = p; + } + + public Font(String name, int index) { + pointer = newNative(name, index); + } + + public Font(String name) { + pointer = newNative(name, 0); + } + + public native String getName(); + + public native int encodeCharacter(int unicode); + public native float advanceGlyph(int glyph, boolean wmode); + + public float advanceGlyph(int glyph) { + return advanceGlyph(glyph, false); + } + + public String toString() { + return "Font(" + getName() + ")"; + } +} diff --git a/platform/java/src/com/artifex/mupdf/fitz/Image.java b/platform/java/src/com/artifex/mupdf/fitz/Image.java new file mode 100644 index 00000000..4d2f7eb5 --- /dev/null +++ b/platform/java/src/com/artifex/mupdf/fitz/Image.java @@ -0,0 +1,42 @@ +package com.artifex.mupdf.fitz; + +public class Image +{ + private long pointer; + + protected native void finalize(); + + public void destroy() { + finalize(); + pointer = 0; + } + + private native long newNativeFromPixmap(Pixmap pixmap); + private native long newNativeFromFile(String filename); + + private Image(long p) { + pointer = p; + } + + public Image(Pixmap pixmap) { + pointer = newNativeFromPixmap(pixmap); + } + + public Image(String filename) { + pointer = newNativeFromFile(filename); + } + + public native int getWidth(); + public native int getHeight(); + public native int getXResolution(); + public native int getYResolution(); + + public native ColorSpace getColorSpace(); + public native int getNumberOfComponents(); + public native int getBitsPerComponent(); + public native boolean getImageMask(); + public native boolean getInterpolate(); + public native Image getMask(); + + public native Pixmap toPixmap(); +} diff --git a/platform/java/src/com/artifex/mupdf/fitz/Link.java b/platform/java/src/com/artifex/mupdf/fitz/Link.java new file mode 100644 index 00000000..0ecd8307 --- /dev/null +++ b/platform/java/src/com/artifex/mupdf/fitz/Link.java @@ -0,0 +1,19 @@ +package com.artifex.mupdf.fitz; + +public class Link +{ + private long pointer; + + protected native void finalize(); + + public void destroy() { + finalize(); + pointer = 0; + } + + private Link(long p) { + pointer = p; + } + + public native Link getNext(); +} diff --git a/platform/java/src/com/artifex/mupdf/fitz/Matrix.java b/platform/java/src/com/artifex/mupdf/fitz/Matrix.java new file mode 100644 index 00000000..80da84fc --- /dev/null +++ b/platform/java/src/com/artifex/mupdf/fitz/Matrix.java @@ -0,0 +1,163 @@ +package com.artifex.mupdf.fitz; + +public class Matrix +{ + public float a, b, c, d, e, f; + + public Matrix(float a, float b, float c, float d, float e, float f) { + this.a = a; + this.b = b; + this.c = c; + this.d = d; + this.e = e; + this.f = f; + } + + public Matrix(float a, float b, float c, float d) { + this(a, b, c, d, 0, 0); + } + + public Matrix(float a, float d) { + this(a, 0, 0, d, 0, 0); + } + + public Matrix(float a) { + this(a, 0, 0, a, 0, 0); + } + + public Matrix() { + this(1, 0, 0, 1, 0, 0); + } + + public Matrix(Matrix one, Matrix two) { + a = one.a * two.a + one.b * two.c; + b = one.a * two.b + one.b * two.d; + c = one.c * two.a + one.d * two.c; + d = one.c * two.b + one.d * two.d; + e = one.e * two.a + one.f * two.c + two.e; + f = one.e * two.b + one.f * two.d + two.f; + } + + public Matrix concat(Matrix m) { + float a = this.a * m.a + this.b * m.c; + float b = this.a * m.b + this.b * m.d; + float c = this.c * m.a + this.d * m.c; + float d = this.c * m.b + this.d * m.d; + float e = this.e * m.a + this.f * m.c + m.e; + this.f = this.e * m.b + this.f * m.d + m.f; + + this.a = a; + this.b = b; + this.c = c; + this.d = d; + this.e = e; + + return this; + } + + public Matrix scale(float sx, float sy) { + a *= sx; + b *= sx; + c *= sy; + d *= sy; + return this; + } + + public Matrix scale(float s) { + return scale(s, s); + } + + public Matrix translate(float tx, float ty) { + e += tx * a + ty * c; + f += tx * b + ty * d; + return this; + } + + public Matrix rotate(float degrees) { + while (degrees < 0) + degrees += 360; + while (degrees >= 360) + degrees -= 360; + + if (Math.abs(0 - degrees) < 0.0001) { + // Nothing to do + } else if (Math.abs(90 - degrees) < 0.0001) { + float save_a = a; + float save_b = b; + a = c; + b = d; + c = -save_a; + d = -save_b; + } else if (Math.abs(180 - degrees) < 0.0001) { + a = -a; + b = -b; + c = -c; + d = -d; + } else if (Math.abs(270 - degrees) < 0.0001) { + float save_a = a; + float save_b = b; + a = -c; + b = -d; + c = save_a; + d = save_b; + } else { + float sin = (float)Math.sin(degrees * Math.PI / 180.0); + float cos = (float)Math.cos(degrees * Math.PI / 180.0); + float save_a = a; + float save_b = b; + a = cos * save_a + sin * c; + b = cos * save_b + sin * d; + c = -sin * save_a + cos * c; + d = -sin * save_b + cos * d; + } + return this; + } + + public String toString() { + return "[" + a + " " + b + " " + c + " " + d + " " + e + " " + f + "]"; + } + + public static Matrix Identity() { + return new Matrix(1, 0, 0, 1, 0, 0); + } + + public static Matrix Scale(float x) { + return new Matrix(x, 0, 0, x, 0, 0); + } + + public static Matrix Scale(float x, float y) { + return new Matrix(x, 0, 0, y, 0, 0); + } + + public static Matrix Translate(float x, float y) { + return new Matrix(1, 0, 0, 1, x, y); + } + + public static Matrix Rotate(float degrees) { + float sin, cos; + + while (degrees < 0) + degrees += 360; + while (degrees >= 360) + degrees -= 360; + + if (Math.abs(0 - degrees) < 0.0001) { + sin = 0; + cos = 1; + } else if (Math.abs(90 - degrees) < 0.0001) { + sin = 1; + cos = 0; + } else if (Math.abs(180 - degrees) < 0.0001) { + sin = 0; + cos = -1; + } else if (Math.abs(270 - degrees) < 0.0001) { + sin = -1; + cos = 0; + } else { + sin = (float)Math.sin(degrees * Math.PI / 180.0); + cos = (float)Math.cos(degrees * Math.PI / 180.0); + } + + return new Matrix(cos, sin, -sin, cos, 0, 0); + } +} diff --git a/platform/java/src/com/artifex/mupdf/fitz/NativeDevice.java b/platform/java/src/com/artifex/mupdf/fitz/NativeDevice.java new file mode 100644 index 00000000..0d2b9159 --- /dev/null +++ b/platform/java/src/com/artifex/mupdf/fitz/NativeDevice.java @@ -0,0 +1,47 @@ +package com.artifex.mupdf.fitz; + +public class NativeDevice extends Device +{ + private long nativeInfo; + private Object nativeResource; + + protected native void finalize(); + + public void destroy() { + super.destroy(); + nativeInfo = 0; + nativeResource = null; + } + + protected NativeDevice(long p) { + super(p); + } + + public native final void close(); + + public native final void fillPath(Path path, boolean evenOdd, Matrix ctm, ColorSpace cs, float color[], float alpha); + public native final void strokePath(Path path, StrokeState stroke, Matrix ctm, ColorSpace cs, float color[], float alpha); + public native final void clipPath(Path path, boolean evenOdd, Matrix ctm); + public native final void clipStrokePath(Path path, StrokeState stroke, Matrix ctm); + + public native final void fillText(Text text, Matrix ctm, ColorSpace cs, float color[], float alpha); + public native final void strokeText(Text text, StrokeState stroke, Matrix ctm, ColorSpace cs, float color[], float alpha); + public native final void clipText(Text text, Matrix ctm); + public native final void clipStrokeText(Text text, StrokeState stroke, Matrix ctm); + public native final void ignoreText(Text text, Matrix ctm); + + public native final void fillShade(Shade shd, Matrix ctm, float alpha); + public native final void fillImage(Image img, Matrix ctm, float alpha); + public native final void fillImageMask(Image img, Matrix ctm, ColorSpace cs, float color[], float alpha); + public native final void clipImageMask(Image img, Matrix ctm); + + public native final void popClip(); + + public native final void beginMask(Rect rect, boolean luminosity, ColorSpace cs, float bc[]); + public native final void endMask(); + public native final void beginGroup(Rect rect, boolean isolated, boolean knockout, int blendmode, float alpha); + public native final void endGroup(); + + public native final int beginTile(Rect area, Rect view, float xstep, float ystep, Matrix ctm, int id); + public native final void endTile(); +} diff --git a/platform/java/src/com/artifex/mupdf/fitz/Outline.java b/platform/java/src/com/artifex/mupdf/fitz/Outline.java new file mode 100644 index 00000000..98a11b79 --- /dev/null +++ b/platform/java/src/com/artifex/mupdf/fitz/Outline.java @@ -0,0 +1,17 @@ +package com.artifex.mupdf.fitz; + +public class Outline +{ + private long pointer; + + protected native void finalize(); + + public void destroy() { + finalize(); + pointer = 0; + } + + private Outline(long p) { + pointer = p; + } +} diff --git a/platform/java/src/com/artifex/mupdf/fitz/PDFDocument.java b/platform/java/src/com/artifex/mupdf/fitz/PDFDocument.java new file mode 100644 index 00000000..58a3e3a6 --- /dev/null +++ b/platform/java/src/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/src/com/artifex/mupdf/fitz/PDFObject.java b/platform/java/src/com/artifex/mupdf/fitz/PDFObject.java new file mode 100644 index 00000000..f2e926f2 --- /dev/null +++ b/platform/java/src/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/src/com/artifex/mupdf/fitz/Page.java b/platform/java/src/com/artifex/mupdf/fitz/Page.java new file mode 100644 index 00000000..64fe4030 --- /dev/null +++ b/platform/java/src/com/artifex/mupdf/fitz/Page.java @@ -0,0 +1,43 @@ +package com.artifex.mupdf.fitz; + +public class Page +{ + private long pointer; + private Annotation nativeAnnots[]; + + protected native void finalize(); + + public void destroy() { + finalize(); + pointer = 0; + nativeAnnots = null; + } + + private Page(long p) { + pointer = p; + nativeAnnots = null; + } + + public native Rect getBounds(); + + public native Pixmap toPixmap(Matrix ctm, ColorSpace cs, boolean alpha); + + public native void run(Device dev, Matrix ctm, Cookie cookie); + public native void runPageContents(Device dev, Matrix ctm, Cookie cookie); + public native Annotation[] getAnnotations(); + + public void run(Device dev, Matrix ctm) { + run(dev, ctm, null); + } + + // FIXME: Later + public native Link[] getLinks(); + + // 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/src/com/artifex/mupdf/fitz/Path.java b/platform/java/src/com/artifex/mupdf/fitz/Path.java new file mode 100644 index 00000000..455dce69 --- /dev/null +++ b/platform/java/src/com/artifex/mupdf/fitz/Path.java @@ -0,0 +1,64 @@ +package com.artifex.mupdf.fitz; + +public class Path implements PathWalker +{ + private long pointer; + + protected native void finalize(); + + public void destroy() { + finalize(); + pointer = 0; + } + + private native long newNative(); + private native long cloneNative(); + + public Path() { + pointer = newNative(); + } + + private Path(long p) { + pointer = p; + } + + public Path(Path old) { + pointer = old.cloneNative(); + } + + public native Point currentPoint(); + + public native void moveTo(float x, float y); + public native void lineTo(float x, float y); + 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) { + moveTo(xy.x, xy.y); + } + + public void lineTo(Point xy) { + lineTo(xy.x, xy.y); + } + + public void curveTo(Point c1, Point c2, Point e) { + curveTo(c1.x, c1.y, c2.x, c2.y, e.x, e.y); + } + + public void curveToV(Point c, Point e) { + curveToV(c.x, c.y, e.x, e.y); + } + + public void curveToY(Point c, Point e) { + curveToY(c.x, c.y, e.x, e.y); + } + + public native void transform(Matrix mat); + + public native Rect getBounds(StrokeState stroke, Matrix ctm); + + public native void walk(PathWalker walker); +} diff --git a/platform/java/src/com/artifex/mupdf/fitz/PathWalker.java b/platform/java/src/com/artifex/mupdf/fitz/PathWalker.java new file mode 100644 index 00000000..66d1b49b --- /dev/null +++ b/platform/java/src/com/artifex/mupdf/fitz/PathWalker.java @@ -0,0 +1,9 @@ +package com.artifex.mupdf.fitz; + +public interface PathWalker +{ + public void moveTo(float x, float y); + public void lineTo(float x, float y); + public void curveTo(float cx1, float cy1, float cx2, float cy2, float ex, float ey); + public void closePath(); +} diff --git a/platform/java/src/com/artifex/mupdf/fitz/Pixmap.java b/platform/java/src/com/artifex/mupdf/fitz/Pixmap.java new file mode 100644 index 00000000..52432fea --- /dev/null +++ b/platform/java/src/com/artifex/mupdf/fitz/Pixmap.java @@ -0,0 +1,83 @@ +package com.artifex.mupdf.fitz; + +public class Pixmap +{ + private long pointer; + + protected native void finalize(); + + public void destroy() { + finalize(); + pointer = 0; + } + + private native long newNative(ColorSpace cs, int x, int y, int w, int h, boolean alpha); + + private Pixmap(long p) { + pointer = p; + } + + public Pixmap(ColorSpace cs, int x, int y, int w, int h, boolean alpha) { + pointer = newNative(cs, x, y, w, h, alpha); + } + + public Pixmap(ColorSpace cs, int x, int y, int w, int h) { + this(cs, x, y, w, h, false); + } + + public Pixmap(ColorSpace cs, int w, int h, boolean alpha) { + this(cs, 0, 0, w, h, alpha); + } + + public Pixmap(ColorSpace cs, int w, int h) { + this(cs, 0, 0, w, h, false); + } + + public Pixmap(ColorSpace cs, Rect rect, boolean alpha) { + this(cs, (int)rect.x0, (int)rect.y0, (int)(rect.x1 - rect.x0), (int)(rect.y1 - rect.y0), alpha); + } + + public Pixmap(ColorSpace cs, Rect rect) { + this(cs, rect, false); + } + + public native void clear(); + public native void clearWithValue(int value); + + public native void saveAsPNG(String filename); + + public native int getX(); + public native int getY(); + public native int getWidth(); + public native int getHeight(); + public native int getStride(); + public native int getNumberOfComponents(); + 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() + + " x=" + getX() + + " y=" + getY() + + " n=" + getNumberOfComponents() + + " alpha=" + getAlpha() + + " cs=" + getColorSpace() + + ")"; + } +} diff --git a/platform/java/src/com/artifex/mupdf/fitz/Point.java b/platform/java/src/com/artifex/mupdf/fitz/Point.java new file mode 100644 index 00000000..b32198bc --- /dev/null +++ b/platform/java/src/com/artifex/mupdf/fitz/Point.java @@ -0,0 +1,30 @@ +package com.artifex.mupdf.fitz; + +public class Point +{ + public float x; + public float y; + + public Point(float x, float y) { + this.x = x; + this.y = y; + } + + public Point(Point p) { + this.x = p.x; + this.y = p.y; + } + + public String toString() { + return "[" + x + " " + y + "]"; + } + + public Point transform(Matrix tm) { + float old_x = this.x; + + this.x = old_x * tm.a + y * tm.c + tm.e; + this.y = old_x * tm.b + y * tm.d + tm.f; + + return this; + } +} diff --git a/platform/java/src/com/artifex/mupdf/fitz/Rect.java b/platform/java/src/com/artifex/mupdf/fitz/Rect.java new file mode 100644 index 00000000..819646e8 --- /dev/null +++ b/platform/java/src/com/artifex/mupdf/fitz/Rect.java @@ -0,0 +1,77 @@ +package com.artifex.mupdf.fitz; + +public class Rect +{ + public float x0; + public float y0; + public float x1; + public float y1; + + public Rect(float x0, float y0, float x1, float y1) { + this.x0 = x0; + this.y0 = y0; + this.x1 = x1; + this.y1 = y1; + } + + public Rect(Rect r) { + this(r.x0, r.y0, r.x1, r.y1); + } + + public Rect(RectI r) { + this(r.x0, r.y0, r.x1, r.y1); + } + + public String toString() { + return "[" + x0 + " " + y0 + " " + x1 + " " + y1 + "]"; + } + + public Rect transform(Matrix tm) { + float ax0 = x0 * tm.a; + float ax1 = x1 * tm.a; + + if (ax0 > ax1) { + float t = ax0; + ax0 = ax1; + ax1 = t; + } + + float cy0 = y0 * tm.c; + float cy1 = y1 * tm.c; + + if (cy0 > cy1) { + float t = cy0; + cy0 = cy1; + cy1 = t; + } + ax0 += cy0 + tm.e; + ax1 += cy1 + tm.e; + + float bx0 = x0 * tm.b; + float bx1 = x1 * tm.b; + + if (bx0 > bx1) { + float t = bx0; + bx0 = bx1; + bx1 = t; + } + + float dy0 = y0 * tm.d; + float dy1 = y1 * tm.d; + + if (dy0 > dy1) { + float t = dy0; + dy0 = dy1; + dy1 = t; + } + bx0 += dy0 + tm.f; + bx1 += dy1 + tm.f; + + x0 = ax0; + x1 = ax1; + y0 = bx0; + y1 = bx1; + + return this; + } +} diff --git a/platform/java/src/com/artifex/mupdf/fitz/RectI.java b/platform/java/src/com/artifex/mupdf/fitz/RectI.java new file mode 100644 index 00000000..8e46a3f2 --- /dev/null +++ b/platform/java/src/com/artifex/mupdf/fitz/RectI.java @@ -0,0 +1,80 @@ +package com.artifex.mupdf.fitz; + +public class RectI +{ + public int x0; + public int y0; + public int x1; + public int y1; + + public RectI(int x0, int y0, int x1, int y1) { + this.x0 = x0; + this.y0 = y0; + this.x1 = x1; + this.y1 = y1; + } + + public RectI(RectI r) { + this(r.x0, r.y0, r.x1, r.y1); + } + + public RectI(Rect r) { + this.x0 = (int)Math.floor(r.x0); + this.y0 = (int)Math.ceil(r.y0); + this.x1 = (int)Math.floor(r.x1); + this.y1 = (int)Math.ceil(r.y1); + } + + public String toString() { + return "[" + x0 + " " + y0 + " " + x1 + " " + y1 + "]"; + } + + public RectI transform(Matrix tm) { + float ax0 = x0 * tm.a; + float ax1 = x1 * tm.a; + + if (ax0 > ax1) { + float t = ax0; + ax0 = ax1; + ax1 = t; + } + + float cy0 = y0 * tm.c; + float cy1 = y1 * tm.c; + + if (cy0 > cy1) { + float t = cy0; + cy0 = cy1; + cy1 = t; + } + ax0 += cy0 + tm.e; + ax1 += cy1 + tm.e; + + float bx0 = x0 * tm.b; + float bx1 = x1 * tm.b; + + if (bx0 > bx1) { + float t = bx0; + bx0 = bx1; + bx1 = t; + } + + float dy0 = y0 * tm.d; + float dy1 = y1 * tm.d; + + if (dy0 > dy1) { + float t = dy0; + dy0 = dy1; + dy1 = t; + } + bx0 += dy0 + tm.f; + bx1 += dy1 + tm.f; + + x0 = (int)Math.floor(ax0); + x1 = (int)Math.ceil(ax1); + y0 = (int)Math.floor(bx0); + y1 = (int)Math.ceil(bx1); + + return this; + } +} diff --git a/platform/java/src/com/artifex/mupdf/fitz/Shade.java b/platform/java/src/com/artifex/mupdf/fitz/Shade.java new file mode 100644 index 00000000..35182cb8 --- /dev/null +++ b/platform/java/src/com/artifex/mupdf/fitz/Shade.java @@ -0,0 +1,17 @@ +package com.artifex.mupdf.fitz; + +public class Shade +{ + private long pointer; + + protected native void finalize(); + + public void destroy() { + finalize(); + pointer = 0; + } + + private Shade(long p) { + pointer = p; + } +} diff --git a/platform/java/src/com/artifex/mupdf/fitz/StrokeState.java b/platform/java/src/com/artifex/mupdf/fitz/StrokeState.java new file mode 100644 index 00000000..7f333f76 --- /dev/null +++ b/platform/java/src/com/artifex/mupdf/fitz/StrokeState.java @@ -0,0 +1,55 @@ +package com.artifex.mupdf.fitz; + +public class StrokeState +{ + public static final int FZ_LINECAP_BUTT = 0; + public static final int FZ_LINECAP_ROUND = 1; + public static final int FZ_LINECAP_SQUARE = 2; + public static final int FZ_LINECAP_TRIANGLE = 3; + + public static final int FZ_LINEJOIN_MITER = 0; + public static final int FZ_LINEJOIN_ROUND = 1; + public static final int FZ_LINEJOIN_BEVEL = 2; + public static final int FZ_LINEJOIN_MITER_XPS = 3; + + private long pointer; + + protected native void finalize(); + + public void destroy() { + finalize(); + pointer = 0; + } + + private native long newNative(int startCap, int dashCap, int endCap, int lineJoin, float lineWidth, float miterLimit, + float dashPhase, float dash[]); + + // Private constructor for the C to use. Any objects created by the + // C are done for purposes of calling back to a java device, and + // should therefore be considered const. This is fine as we don't + // currently provide mechanisms for changing individual elements + // of the StrokeState. + private StrokeState(long p) { + pointer = p; + } + + public StrokeState(int startCap, int endCap, int lineJoin, float lineWidth, float miterLimit) { + pointer = newNative(startCap, 0, endCap, lineJoin, lineWidth, miterLimit, 0, null); + } + + public StrokeState(int startCap, int dashCap, int endCap, int lineJoin, float lineWidth, float miterLimit, + float dashPhase, float dash[]) { + pointer = newNative(startCap, dashCap, endCap, lineJoin, lineWidth, miterLimit, dashPhase, dash); + } + + public native void adjustRectForStroke(Rect rect, Matrix ctm); + + public native int getStartCap(); + public native int getDashCap(); + public native int getEndCap(); + public native int getLineJoin(); + public native float getLineWidth(); + public native float getMiterLimit(); + public native float getDashPhase(); + public native float[] getDashes(); +} diff --git a/platform/java/src/com/artifex/mupdf/fitz/StructuredText.java b/platform/java/src/com/artifex/mupdf/fitz/StructuredText.java new file mode 100644 index 00000000..0f3549d5 --- /dev/null +++ b/platform/java/src/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); +} diff --git a/platform/java/src/com/artifex/mupdf/fitz/Text.java b/platform/java/src/com/artifex/mupdf/fitz/Text.java new file mode 100644 index 00000000..5bbe8abe --- /dev/null +++ b/platform/java/src/com/artifex/mupdf/fitz/Text.java @@ -0,0 +1,43 @@ +package com.artifex.mupdf.fitz; + +public class Text implements TextWalker +{ + private long pointer; + + protected native void finalize(); + + public void destroy() { + finalize(); + pointer = 0; + } + + private native long newNative(); + private native long cloneNative(Text old); + + private Text(long p) { + pointer = p; + } + + public Text(Text old) { + pointer = cloneNative(old); + } + + public Text() { + pointer = newNative(); + } + + public native void showGlyph(Font font, Matrix trm, int glyph, int unicode, boolean wmode); + public native void showString(Font font, Matrix trm, String str, boolean wmode); + + public native Rect getBounds(StrokeState stroke, Matrix ctm); + + public void showGlyph(Font font, Matrix trm, int glyph, int unicode) { + showGlyph(font, trm, glyph, unicode, false); + } + + public void showString(Font font, Matrix trm, String str) { + showString(font, trm, str, false); + } + + public native void walk(TextWalker walker); +} diff --git a/platform/java/src/com/artifex/mupdf/fitz/TextWalker.java b/platform/java/src/com/artifex/mupdf/fitz/TextWalker.java new file mode 100644 index 00000000..911c19bc --- /dev/null +++ b/platform/java/src/com/artifex/mupdf/fitz/TextWalker.java @@ -0,0 +1,6 @@ +package com.artifex.mupdf.fitz; + +public interface TextWalker +{ + public void showGlyph(Font font, Matrix trm, int glyph, int unicode, boolean wmode); +} diff --git a/platform/java/src/com/artifex/mupdf/fitz/TryLaterException.java b/platform/java/src/com/artifex/mupdf/fitz/TryLaterException.java new file mode 100644 index 00000000..e2d1b88e --- /dev/null +++ b/platform/java/src/com/artifex/mupdf/fitz/TryLaterException.java @@ -0,0 +1,8 @@ +package com.artifex.mupdf.fitz; + +public class TryLaterException extends Exception +{ + TryLaterException(String message) { + super(message); + } +} diff --git a/platform/java/src/com/artifex/mupdf/fitz/android/AndroidDrawDevice.java b/platform/java/src/com/artifex/mupdf/fitz/android/AndroidDrawDevice.java new file mode 100644 index 00000000..2be2ae59 --- /dev/null +++ b/platform/java/src/com/artifex/mupdf/fitz/android/AndroidDrawDevice.java @@ -0,0 +1,25 @@ +package com.artifex.mupdf.fitz.android; + +import android.graphics.Bitmap; + +import com.artifex.mupdf.fitz.NativeDevice; +import com.artifex.mupdf.fitz.RectI; + +public final class AndroidDrawDevice extends NativeDevice +{ + // NOT static. + private native long newNative(Bitmap bitmap, int pageX0, int pageY0, int pageX1, int pageY1, int patchX0, int patchY0, int patchX1, int patchY1); + + // Construction + public AndroidDrawDevice(Bitmap bitmap, int pageX0, int pageY0, int pageX1, int pageY1, int patchX0, int patchY0, int patchX1, int patchY1) + { + super(0); + pointer = newNative(bitmap, pageX0, pageY0, pageX1, pageY1, patchX0, patchY0, patchX1, patchY1); + } + + public AndroidDrawDevice(Bitmap bitmap, RectI page, RectI patch) + { + super(0); + pointer = newNative(bitmap, page.x0, page.y0, page.x1, page.y1, patch.x0, patch.y0, patch.x1, patch.y1); + } +} -- cgit v1.2.3