summaryrefslogtreecommitdiff
path: root/platform/java/com/artifex
diff options
context:
space:
mode:
Diffstat (limited to 'platform/java/com/artifex')
-rw-r--r--platform/java/com/artifex/mupdf/fitz/Annotation.java28
-rw-r--r--platform/java/com/artifex/mupdf/fitz/AwtDrawDevice.java12
-rw-r--r--platform/java/com/artifex/mupdf/fitz/ColorSpace.java59
-rw-r--r--platform/java/com/artifex/mupdf/fitz/Context.java16
-rw-r--r--platform/java/com/artifex/mupdf/fitz/Cookie.java27
-rw-r--r--platform/java/com/artifex/mupdf/fitz/Device.java189
-rw-r--r--platform/java/com/artifex/mupdf/fitz/DisplayList.java29
-rw-r--r--platform/java/com/artifex/mupdf/fitz/DisplayListDevice.java14
-rw-r--r--platform/java/com/artifex/mupdf/fitz/Document.java72
-rw-r--r--platform/java/com/artifex/mupdf/fitz/DrawDevice.java10
-rw-r--r--platform/java/com/artifex/mupdf/fitz/Font.java25
-rw-r--r--platform/java/com/artifex/mupdf/fitz/Image.java42
-rw-r--r--platform/java/com/artifex/mupdf/fitz/Link.java26
-rw-r--r--platform/java/com/artifex/mupdf/fitz/Matrix.java158
-rw-r--r--platform/java/com/artifex/mupdf/fitz/NativeDevice.java (renamed from platform/java/com/artifex/mupdf/fitz/CDevice.java)41
-rw-r--r--platform/java/com/artifex/mupdf/fitz/Outline.java19
-rw-r--r--platform/java/com/artifex/mupdf/fitz/Page.java37
-rw-r--r--platform/java/com/artifex/mupdf/fitz/Path.java77
-rw-r--r--platform/java/com/artifex/mupdf/fitz/PathWalker.java (renamed from platform/java/com/artifex/mupdf/fitz/PathProcessor.java)4
-rw-r--r--platform/java/com/artifex/mupdf/fitz/Pixmap.java60
-rw-r--r--platform/java/com/artifex/mupdf/fitz/Point.java13
-rw-r--r--platform/java/com/artifex/mupdf/fitz/Rect.java34
-rw-r--r--platform/java/com/artifex/mupdf/fitz/RectI.java29
-rw-r--r--platform/java/com/artifex/mupdf/fitz/Shade.java25
-rw-r--r--platform/java/com/artifex/mupdf/fitz/StrokeState.java45
-rw-r--r--platform/java/com/artifex/mupdf/fitz/Text.java52
-rw-r--r--platform/java/com/artifex/mupdf/fitz/TextWalker.java6
-rw-r--r--platform/java/com/artifex/mupdf/fitz/TryLaterException.java3
28 files changed, 570 insertions, 582 deletions
diff --git a/platform/java/com/artifex/mupdf/fitz/Annotation.java b/platform/java/com/artifex/mupdf/fitz/Annotation.java
index 6e6dd1c1..5f652246 100644
--- a/platform/java/com/artifex/mupdf/fitz/Annotation.java
+++ b/platform/java/com/artifex/mupdf/fitz/Annotation.java
@@ -2,26 +2,20 @@ package com.artifex.mupdf.fitz;
public class Annotation
{
- // Private data
- private long nativeAnnot = 0;
+ private long pointer;
- // Construction
- private Annotation(long ptr)
- {
- nativeAnnot = ptr;
- }
-
- // Operation
- public native void run(Device dev, Matrix ctm, Cookie cookie);
-
- // FIXME: Write accessors
+ protected native void finalize();
- // Destruction
- public void destroy()
- {
+ public void destroy() {
finalize();
- nativeAnnot = 0;
+ pointer = 0;
}
- protected native void finalize();
+ private Annotation(long p) {
+ pointer = p;
+ }
+
+ public native void run(Device dev, Matrix ctm, Cookie cookie);
+
+ private native long advance();
}
diff --git a/platform/java/com/artifex/mupdf/fitz/AwtDrawDevice.java b/platform/java/com/artifex/mupdf/fitz/AwtDrawDevice.java
deleted file mode 100644
index 4e6fb33d..00000000
--- a/platform/java/com/artifex/mupdf/fitz/AwtDrawDevice.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package com.artifex.mupdf.fitz;
-
-public final class AwtDrawDevice extends CDevice
-{
- // Construction
- public AwtDrawDevice(int rgba[], int width, int height)
- {
- nativeDevice = newNative(rgba, width, height);
- }
-
- private native long newNative(int rgba[], int width, int height);
-}
diff --git a/platform/java/com/artifex/mupdf/fitz/ColorSpace.java b/platform/java/com/artifex/mupdf/fitz/ColorSpace.java
index cad952c0..b7822161 100644
--- a/platform/java/com/artifex/mupdf/fitz/ColorSpace.java
+++ b/platform/java/com/artifex/mupdf/fitz/ColorSpace.java
@@ -2,33 +2,44 @@ package com.artifex.mupdf.fitz;
public class ColorSpace
{
- // Private data
- private long nativeColorSpace;
-
- // Statics
- public static ColorSpace DeviceGray = new ColorSpace(newDeviceGray());
- public static ColorSpace DeviceRGB = new ColorSpace(newDeviceRGB());
- public static ColorSpace DeviceCMYK = new ColorSpace(newDeviceCMYK());
-
- private static native long newDeviceGray();
- private static native long newDeviceRGB();
- private static native long newDeviceCMYK();
-
- // Construction
- private ColorSpace(long l)
- {
- nativeColorSpace = l;
- }
+ private long pointer;
- // Accessors
- public native int getNumComponents();
+ protected native void finalize();
- // Destruction
- public final void destroy()
- {
+ public void destroy() {
finalize();
- nativeColorSpace = 0;
+ pointer = 0;
+ }
+
+ private ColorSpace(long p) {
+ pointer = p;
}
- protected final native void finalize();
+ 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
index 1baafb01..3614e65f 100644
--- a/platform/java/com/artifex/mupdf/fitz/Context.java
+++ b/platform/java/com/artifex/mupdf/fitz/Context.java
@@ -8,12 +8,20 @@ package com.artifex.mupdf.fitz;
// function.
public class Context
{
- // Load our native library
- static
- {
- System.loadLibrary("mupdf");
+ 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
index b6761b42..f866f99e 100644
--- a/platform/java/com/artifex/mupdf/fitz/Cookie.java
+++ b/platform/java/com/artifex/mupdf/fitz/Cookie.java
@@ -2,29 +2,20 @@ package com.artifex.mupdf.fitz;
public class Cookie
{
- // Private data
- private long nativeCookie = 0;
+ private long pointer;
- // Construction
- public Cookie()
- {
- nativeCookie = newNative();
+ protected native void finalize();
+
+ public void destroy() {
+ finalize();
+ pointer = 0;
}
private native long newNative();
- // Operation
- public native void abort();
-
- //FIXME: Cookie accessors
-
- // Destruction
- protected native void finalize();
-
- public void destroy()
- {
- finalize();
- nativeCookie = 0;
+ 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
index 366022e9..c8bf23d4 100644
--- a/platform/java/com/artifex/mupdf/fitz/Device.java
+++ b/platform/java/com/artifex/mupdf/fitz/Device.java
@@ -1,7 +1,66 @@
package com.artifex.mupdf.fitz;
-public abstract class Device
+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 beginPage(Rect rect, Matrix ctm) {}
+ public void endPage() {}
+ 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, Rect rect, boolean evenOdd, Matrix ctm) {}
+ public void clipStrokePath(Path path, Rect rect, 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 shade, 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, Rect rect, Matrix ctm) {}
+ public void popClip() {}
+ public void beginMask(Rect rect, boolean luminosity, ColorSpace cs, float bc[]) {}
+ public void endMask() {}
+ public void beginGroup(Rect rect, 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;
@@ -40,133 +99,7 @@ public abstract class Device
public static final int FZ_BLEND_ISOLATED = 16;
public static final int FZ_BLEND_KNOCKOUT = 32;
- /* To implement your own device in Java, you should define your own
- * class that extends this one, 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) {
- * Debug.Log("Image!");
- * }
- * };
- *
- * There is no constructor here, as no one will ever construct a
- * Device without subclassing.
- */
-
- /* Everything under here is private implementation details.
- * Ideally we'd like to hide these from prying eyes, but Java doesn't
- * allow that.
- */
-
+ /* Device hints */
public static final int FZ_IGNORE_IMAGE = 1;
public static final int FZ_IGNORE_SHADE = 2;
-
- /* None of our device functions do anything. Anyone interested will
- * override them in a subclass either in Java, or (as a subclass of
- * CDevice) in C.
- */
- public void beginPage(Rect rect, Matrix ctm)
- {
- }
-
- public void endPage()
- {
- }
-
- public void fillPath(Path path, int even_odd, Matrix ctm, ColorSpace cs, float color[], float alpha)
- {
- }
-
- public void strokePath(long ctx, Path path, StrokeState stroke, Matrix ctm, ColorSpace cs, float color[], float alpha)
- {
- }
-
- public void clipPath(Path path, Rect rect, int even_odd, Matrix ctm)
- {
- }
-
- public void clipStrokePath(Path path, Rect rect, 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 shade, 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, Rect rect, Matrix ctm)
- {
- }
-
- public void popClip()
- {
- }
-
- public void beginMask(Rect rect, int luminosity, ColorSpace cs, float bc[])
- {
- }
-
- public void endMask()
- {
- }
-
- public void beginGroup(Rect rect, int isolated, int 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()
- {
- }
-
- /* An accessor for device hints */
- final native int getHints();
- final native void enableDeviceHints(int hints);
- final native void disableDeviceHints(int hints);
-
- // Destruction
- public void destroy()
- {
- }
-
- // Private data.
- // All java devices MUST leave this as 0.
- protected long nativeDevice;
}
diff --git a/platform/java/com/artifex/mupdf/fitz/DisplayList.java b/platform/java/com/artifex/mupdf/fitz/DisplayList.java
index 8a2515e4..3f36fa3d 100644
--- a/platform/java/com/artifex/mupdf/fitz/DisplayList.java
+++ b/platform/java/com/artifex/mupdf/fitz/DisplayList.java
@@ -2,31 +2,24 @@ package com.artifex.mupdf.fitz;
public class DisplayList
{
- // Private data
- protected long nativeDisplayList;
+ protected long pointer;
- // Constructions
- public DisplayList()
- {
- nativeDisplayList = newNative();
+ protected native void finalize();
+
+ public void destroy() {
+ finalize();
+ pointer = 0;
}
private native long newNative();
- // Operation
+ public DisplayList() {
+ pointer = newNative();
+ }
+
public native void run(Device device, Matrix ctm, Rect scissor, Cookie cookie);
- public void run(Device device, Matrix ctm, Cookie cookie)
- {
+ public void run(Device device, Matrix ctm, Cookie cookie) {
run(device, ctm, null, cookie);
}
-
- // Destruction
- public void destroy()
- {
- finalize();
- nativeDisplayList = 0;
- }
-
- protected native void finalize();
}
diff --git a/platform/java/com/artifex/mupdf/fitz/DisplayListDevice.java b/platform/java/com/artifex/mupdf/fitz/DisplayListDevice.java
index de3142dc..c7f7c935 100644
--- a/platform/java/com/artifex/mupdf/fitz/DisplayListDevice.java
+++ b/platform/java/com/artifex/mupdf/fitz/DisplayListDevice.java
@@ -1,14 +1,10 @@
package com.artifex.mupdf.fitz;
-import android.graphics.Bitmap;
-
-public final class DisplayListDevice extends CDevice
+public final class DisplayListDevice extends NativeDevice
{
- // Construction
- public DisplayListDevice(DisplayList list)
- {
- nativeDevice = newNative(list);
- }
+ private static native long newNative(DisplayList list);
- private 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
index 8c3136df..efa2a425 100644
--- a/platform/java/com/artifex/mupdf/fitz/Document.java
+++ b/platform/java/com/artifex/mupdf/fitz/Document.java
@@ -1,60 +1,44 @@
package com.artifex.mupdf.fitz;
-import java.lang.ref.WeakReference;
-
public class Document
{
- // Private data
- private long nativeDocument = 0;
-
- // Construction
- public Document(String filename) throws Exception
- {
- nativeDocument = newNative(filename);
- if (nativeDocument == 0)
- throw(new Exception("Failed to load Document"));
- }
- private native final long newNative(String filename);
-
- // FIXME: Should support opening java streams and from byte buffers etc.
- // Streams would need to be seekable.
- public Document(byte buffer[], String magic) throws Exception
- {
- nativeDocument = 0;//newFromBufferNative(buffer, magic);
- if (nativeDocument == 0)
- throw(new Exception("Failed to load Document"));
+ static {
+ Context.init();
}
- //private native final long newFromBufferNative(byte buffer[], String magic);
- //public Document(SeekableStream stream, String magic) throws Exception
- //{
- // nativeDocument = newFromStreamNative(stream, magic);
- // if (nativeDocument == 0)
- // throw(new Exception("Failed to load Document"));
- //}
- //private native final long newFromBufferNative(SeekableStream stream, String magic);
+ 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";
- // Operation
- public native boolean needsPassword();
+ protected long pointer;
- public native boolean authenticatePassword(String password);
+ protected native void finalize();
- public native int countPages();
+ public void destroy() {
+ finalize();
+ pointer = 0;
+ }
- public native Page getPage(int n);
+ private native long newNativeWithPath(String filename);
+ private native long newNativeWithBuffer(byte buffer[], String magic);
+ // private native long newNativeWithRandomAccessFile(RandomAccessFile file, String magic);
- public native String getFileFormat();
+ public Document(String filename) {
+ pointer = newNativeWithPath(filename);
+ }
- public native boolean isUnencryptedPDF();
+ public Document(byte buffer[], String magic) {
+ pointer = newNativeWithBuffer(buffer, magic);
+ }
- public native Outline getOutline();
+ public native boolean needsPassword();
+ public native boolean authenticatePassword(String password);
- // Destruction
- public void destroy()
- {
- finalize();
- nativeDocument = 0;
- }
+ public native int countPages();
+ public native Page loadPage(int number);
+ public native Outline loadOutline();
+ public native String getMetaData(String key);
- protected native void finalize();
+ public native boolean isUnencryptedPDF();
}
diff --git a/platform/java/com/artifex/mupdf/fitz/DrawDevice.java b/platform/java/com/artifex/mupdf/fitz/DrawDevice.java
new file mode 100644
index 00000000..e022be10
--- /dev/null
+++ b/platform/java/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/com/artifex/mupdf/fitz/Font.java b/platform/java/com/artifex/mupdf/fitz/Font.java
index 7630dfa5..5b9cd8c5 100644
--- a/platform/java/com/artifex/mupdf/fitz/Font.java
+++ b/platform/java/com/artifex/mupdf/fitz/Font.java
@@ -2,21 +2,22 @@ package com.artifex.mupdf.fitz;
public class Font
{
- // Private data
- private long nativeFont;
+ private long pointer;
- // Construction
- private Font(long font)
- {
- nativeFont = font;
- }
+ protected native void finalize();
- // Destruction
- public void destroy()
- {
+ public void destroy() {
finalize();
- nativeFont = 0;
+ pointer = 0;
}
- protected native void finalize();
+ private Font(long p) {
+ pointer = p;
+ }
+
+ public native String getName();
+
+ 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
index a736ce5f..4964053e 100644
--- a/platform/java/com/artifex/mupdf/fitz/Image.java
+++ b/platform/java/com/artifex/mupdf/fitz/Image.java
@@ -1,40 +1,23 @@
package com.artifex.mupdf.fitz;
-import android.graphics.Bitmap;
public class Image
{
- // Private data
- private long nativeImage = 0;
+ private long pointer;
- // Construction
- Image(Bitmap bm) throws Exception
- {
- if (bm == null)
- throw new Exception("null Bitmap passed to Image");
- nativeImage = newFromBitmapNative(bm, null);
- }
+ protected native void finalize();
- Image(Bitmap bm, Image mask) throws Exception
- {
- if (bm == null)
- throw new Exception("null Bitmap passed to Image");
- nativeImage = newFromBitmapNative(bm, mask);
+ public void destroy() {
+ finalize();
+ pointer = 0;
}
- private native final long newFromBitmapNative(Bitmap bm, Image mask);
-
- // 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.
- private Image(long l)
- {
- nativeImage = l;
+ private Image(long p) {
+ pointer = p;
}
- // Accessors
public native int getWidth();
public native int getHeight();
- public native int getNumComponents();
+ public native int getNumberOfComponents();
public native int getBitsPerComponent();
public native int getXResolution();
public native int getYResolution();
@@ -44,13 +27,4 @@ public class Image
// FIXME: Get data back?
// FIXME: Create images from data or java streams?
-
- // Destruction
- public void destroy()
- {
- finalize();
- nativeImage = 0;
- }
-
- protected native void finalize();
}
diff --git a/platform/java/com/artifex/mupdf/fitz/Link.java b/platform/java/com/artifex/mupdf/fitz/Link.java
index 7c63fcf9..0ecd8307 100644
--- a/platform/java/com/artifex/mupdf/fitz/Link.java
+++ b/platform/java/com/artifex/mupdf/fitz/Link.java
@@ -2,26 +2,18 @@ package com.artifex.mupdf.fitz;
public class Link
{
- // Private data
- private long nativeLink = 0;
+ private long pointer;
- // Construction
- private Link(long l)
- {
- nativeLink = l;
- }
-
- // Operation
- public native Link getNext();
-
- //FIXME: Accessors
+ protected native void finalize();
- // Destruction
- public void destroy()
- {
+ public void destroy() {
finalize();
- nativeLink = 0;
+ pointer = 0;
}
- protected native void finalize();
+ 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
index ede57ccc..80da84fc 100644
--- a/platform/java/com/artifex/mupdf/fitz/Matrix.java
+++ b/platform/java/com/artifex/mupdf/fitz/Matrix.java
@@ -2,15 +2,9 @@ package com.artifex.mupdf.fitz;
public class Matrix
{
- public float a;
- public float b;
- public float c;
- public float d;
- public float e;
- public float f;
-
- public Matrix(float a, float b, float c, float d, float e, float f)
- {
+ 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;
@@ -19,28 +13,32 @@ public class Matrix
this.f = f;
}
- public Matrix(float a, float d)
- {
- this.a = a;
- this.b = 0;
- this.c = 0;
- this.d = d;
- this.e = 0;
- this.f = 0;
+ public Matrix(float a, float b, float c, float d) {
+ this(a, b, c, d, 0, 0);
}
- public Matrix(float a)
- {
- this.a = a;
- this.b = 0;
- this.c = 0;
- this.d = a;
- this.e = 0;
- this.f = 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)
- {
+ 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;
@@ -56,4 +54,110 @@ public class Matrix
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/CDevice.java b/platform/java/com/artifex/mupdf/fitz/NativeDevice.java
index 3bfe9c70..6786688f 100644
--- a/platform/java/com/artifex/mupdf/fitz/CDevice.java
+++ b/platform/java/com/artifex/mupdf/fitz/NativeDevice.java
@@ -1,23 +1,33 @@
package com.artifex.mupdf.fitz;
-public abstract class CDevice extends Device
+public class NativeDevice extends Device
{
- // Private data
- private Object nativeResource = null;
- protected long nativeInfo = 0;
+ 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);
+ }
- // Operation
public native final void beginPage(Rect rect, Matrix ctm);
public native final void endPage();
- public native final void fillPath(Path path, int even_odd, Matrix ctm, ColorSpace cs, float color[], float alpha);
+ 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, Rect rect, int even_odd, Matrix ctm);
+ public native final void clipPath(Path path, Rect rect, boolean evenOdd, Matrix ctm);
public native final void clipStrokePath(Path path, Rect rect, 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, int accumulate);
+ 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);
@@ -28,22 +38,11 @@ public abstract class CDevice extends Device
public native final void popClip();
- public native final void beginMask(Rect rect, int luminosity, ColorSpace cs, float bc[]);
+ 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, int isolated, int knockout, int blendmode, float alpha);
+ 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();
-
- // Destruction
- public final void destroy()
- {
- finalize();
- nativeDevice = 0;
- nativeResource = null;
- nativeInfo = 0;
- }
-
- protected native final void finalize();
}
diff --git a/platform/java/com/artifex/mupdf/fitz/Outline.java b/platform/java/com/artifex/mupdf/fitz/Outline.java
index 1b808d7f..98a11b79 100644
--- a/platform/java/com/artifex/mupdf/fitz/Outline.java
+++ b/platform/java/com/artifex/mupdf/fitz/Outline.java
@@ -2,21 +2,16 @@ package com.artifex.mupdf.fitz;
public class Outline
{
- // Private data
- private long nativeOutline = 0;
+ private long pointer;
- // Construction
- private Outline(long out)
- {
- nativeOutline = out;
- }
+ protected native void finalize();
- // Destruction
- public void destroy()
- {
+ public void destroy() {
finalize();
- nativeOutline = 0;
+ pointer = 0;
}
- protected native void finalize();
+ private Outline(long p) {
+ pointer = p;
+ }
}
diff --git a/platform/java/com/artifex/mupdf/fitz/Page.java b/platform/java/com/artifex/mupdf/fitz/Page.java
index 46d598ee..befbe1c7 100644
--- a/platform/java/com/artifex/mupdf/fitz/Page.java
+++ b/platform/java/com/artifex/mupdf/fitz/Page.java
@@ -2,36 +2,37 @@ package com.artifex.mupdf.fitz;
public class Page
{
- // Private data
- private long nativePage = 0;
+ private long pointer;
private Annotation nativeAnnots[];
- // Construction
- private Page(long page)
- {
- nativePage = page;
+ protected native void finalize();
+
+ public void destroy() {
+ finalize();
+ pointer = 0;
+ nativeAnnots = null;
+ }
+
+ private Page(long p) {
+ pointer = p;
nativeAnnots = null;
}
- // Operation
- public native Rect bound();
+ public native Rect getBounds();
+
+ public native Pixmap toPixmap(Matrix ctm, ColorSpace colorspace);
+
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);
-
- // Destruction
- public void destroy()
- {
- finalize();
- nativePage = 0;
- nativeAnnots = null;
- }
-
- protected native void finalize();
}
diff --git a/platform/java/com/artifex/mupdf/fitz/Path.java b/platform/java/com/artifex/mupdf/fitz/Path.java
index 17257f10..fa925bab 100644
--- a/platform/java/com/artifex/mupdf/fitz/Path.java
+++ b/platform/java/com/artifex/mupdf/fitz/Path.java
@@ -1,82 +1,63 @@
package com.artifex.mupdf.fitz;
-public class Path implements PathProcessor
+public class Path implements PathWalker
{
- // Private data
- private long nativePath = 0;
+ private long pointer;
- // Construction
- public Path()
- {
- nativePath = newNative();
+ protected native void finalize();
+
+ public void destroy() {
+ finalize();
+ pointer = 0;
}
private native long newNative();
+ private native long cloneNative();
- private Path(long path)
- {
- nativePath = path;
+ public Path() {
+ pointer = newNative();
}
- public Path(Path old)
- {
- nativePath = clone(old);
+ private Path(long p) {
+ pointer = p;
}
- private native long clone(Path old);
+ public Path(Path old) {
+ pointer = old.cloneNative();
+ }
- // Operation
public native Point currentPoint();
- public void moveTo(Point xy)
- {
+ 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 closePath();
+
+ public void moveTo(Point xy) {
moveTo(xy.x, xy.y);
}
- public native void moveTo(float x, float y);
-
- public void lineTo(Point xy)
- {
+ public void lineTo(Point xy) {
lineTo(xy.x, xy.y);
}
- public native void lineTo(float x, float y);
-
- public void curveTo(Point c1, Point c2, Point e)
- {
+ public void curveTo(Point c1, Point c2, Point e) {
curveTo(c1.x, c1.y, c2.x, c2.y, e.x, e.y);
}
- public native void curveTo(float cx1, float cy1, float cx2, float cy2, float ex, float ey);
-
- public void curveToV(Point c, Point e)
- {
+ public void curveToV(Point c, Point e) {
curveToV(c.x, c.y, e.x, e.y);
}
- public native void curveToV(float cx, float cy, float ex, float ey);
-
- public void curveToY(Point c, Point e)
- {
+ public void curveToY(Point c, Point e) {
curveToY(c.x, c.y, e.x, e.y);
}
- public native void curveToY(float cx, float cy, float ex, float ey);
-
- public native void close();
-
public native void transform(Matrix mat);
- public native Rect bound(StrokeState stroke, Matrix ctm);
-
- public native void process(PathProcessor proc);
-
- // Destruction
- public void destroy()
- {
- finalize();
- nativePath = 0;
- }
+ public native Rect getBounds(StrokeState stroke, Matrix ctm);
- protected native void finalize();
+ public native void walk(PathWalker walker);
}
diff --git a/platform/java/com/artifex/mupdf/fitz/PathProcessor.java b/platform/java/com/artifex/mupdf/fitz/PathWalker.java
index 71d03c50..66d1b49b 100644
--- a/platform/java/com/artifex/mupdf/fitz/PathProcessor.java
+++ b/platform/java/com/artifex/mupdf/fitz/PathWalker.java
@@ -1,9 +1,9 @@
package com.artifex.mupdf.fitz;
-public interface PathProcessor
+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 close();
+ public void closePath();
}
diff --git a/platform/java/com/artifex/mupdf/fitz/Pixmap.java b/platform/java/com/artifex/mupdf/fitz/Pixmap.java
new file mode 100644
index 00000000..61c833ff
--- /dev/null
+++ b/platform/java/com/artifex/mupdf/fitz/Pixmap.java
@@ -0,0 +1,60 @@
+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);
+
+ private Pixmap(long p) {
+ pointer = p;
+ }
+
+ public Pixmap(ColorSpace colorspace, int x, int y, int w, int h) {
+ pointer = newNative(colorspace, x, y, w, h);
+ }
+
+ public Pixmap(ColorSpace colorspace, int w, int h) {
+ this(colorspace, 0, 0, w, h);
+ }
+
+ public Pixmap(ColorSpace colorspace, Rect rect) {
+ this(colorspace, (int)rect.x0, (int)rect.y0, (int)(rect.x1 - rect.x0), (int)(rect.y1 - rect.y0));
+ }
+
+ public native void clear();
+ public native void clearWithValue(int value);
+
+ public native void saveAsPNG(String filename, boolean saveAlpha);
+
+ 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 ColorSpace getColorSpace();
+ public native byte[] getSamples();
+ public native int[] getPixels(); /* only valid for RGB or BGR pixmaps */
+
+ public void clear(int value) {
+ clearWithValue(value);
+ }
+
+ public String toString() {
+ return "Pixmap(w=" + getWidth() +
+ " h=" + getHeight() +
+ " x=" + getX() +
+ " y=" + getY() +
+ " n=" + getNumberOfComponents() +
+ " cs=" + getColorSpace() +
+ ")";
+ }
+}
diff --git a/platform/java/com/artifex/mupdf/fitz/Point.java b/platform/java/com/artifex/mupdf/fitz/Point.java
index 08989dd7..b32198bc 100644
--- a/platform/java/com/artifex/mupdf/fitz/Point.java
+++ b/platform/java/com/artifex/mupdf/fitz/Point.java
@@ -5,20 +5,21 @@ public class Point
public float x;
public float y;
- public Point(float x, float y)
- {
+ public Point(float x, float y) {
this.x = x;
this.y = y;
}
- public Point(Point p)
- {
+ public Point(Point p) {
this.x = p.x;
this.y = p.y;
}
- public Point transform(Matrix tm)
- {
+ 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;
diff --git a/platform/java/com/artifex/mupdf/fitz/Rect.java b/platform/java/com/artifex/mupdf/fitz/Rect.java
index eb9138cf..819646e8 100644
--- a/platform/java/com/artifex/mupdf/fitz/Rect.java
+++ b/platform/java/com/artifex/mupdf/fitz/Rect.java
@@ -7,29 +7,30 @@ public class Rect
public float x1;
public float y1;
- public Rect(float x0, float y0, float x1, 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.x0 = r.x0;
- this.y0 = r.y0;
- this.x1 = r.x1;
- this.y1 = r.y1;
+ public Rect(Rect r) {
+ this(r.x0, r.y0, r.x1, r.y1);
}
- public Rect transform(Matrix tm)
- {
+ 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)
- {
+ if (ax0 > ax1) {
float t = ax0;
ax0 = ax1;
ax1 = t;
@@ -38,8 +39,7 @@ public class Rect
float cy0 = y0 * tm.c;
float cy1 = y1 * tm.c;
- if (cy0 > cy1)
- {
+ if (cy0 > cy1) {
float t = cy0;
cy0 = cy1;
cy1 = t;
@@ -50,8 +50,7 @@ public class Rect
float bx0 = x0 * tm.b;
float bx1 = x1 * tm.b;
- if (bx0 > bx1)
- {
+ if (bx0 > bx1) {
float t = bx0;
bx0 = bx1;
bx1 = t;
@@ -60,8 +59,7 @@ public class Rect
float dy0 = y0 * tm.d;
float dy1 = y1 * tm.d;
- if (dy0 > dy1)
- {
+ if (dy0 > dy1) {
float t = dy0;
dy0 = dy1;
dy1 = t;
diff --git a/platform/java/com/artifex/mupdf/fitz/RectI.java b/platform/java/com/artifex/mupdf/fitz/RectI.java
index 1f91c778..8e46a3f2 100644
--- a/platform/java/com/artifex/mupdf/fitz/RectI.java
+++ b/platform/java/com/artifex/mupdf/fitz/RectI.java
@@ -7,29 +7,33 @@ public class RectI
public int x1;
public int y1;
- public RectI(int x0, int y0, int x1, 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(Rect r)
- {
+ 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 RectI transform(Matrix tm)
- {
+ 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)
- {
+ if (ax0 > ax1) {
float t = ax0;
ax0 = ax1;
ax1 = t;
@@ -38,8 +42,7 @@ public class RectI
float cy0 = y0 * tm.c;
float cy1 = y1 * tm.c;
- if (cy0 > cy1)
- {
+ if (cy0 > cy1) {
float t = cy0;
cy0 = cy1;
cy1 = t;
@@ -50,8 +53,7 @@ public class RectI
float bx0 = x0 * tm.b;
float bx1 = x1 * tm.b;
- if (bx0 > bx1)
- {
+ if (bx0 > bx1) {
float t = bx0;
bx0 = bx1;
bx1 = t;
@@ -60,8 +62,7 @@ public class RectI
float dy0 = y0 * tm.d;
float dy1 = y1 * tm.d;
- if (dy0 > dy1)
- {
+ if (dy0 > dy1) {
float t = dy0;
dy0 = dy1;
dy1 = t;
diff --git a/platform/java/com/artifex/mupdf/fitz/Shade.java b/platform/java/com/artifex/mupdf/fitz/Shade.java
index bfadebc7..35182cb8 100644
--- a/platform/java/com/artifex/mupdf/fitz/Shade.java
+++ b/platform/java/com/artifex/mupdf/fitz/Shade.java
@@ -2,27 +2,16 @@ package com.artifex.mupdf.fitz;
public class Shade
{
- // Private data
- private long nativeShade = 0;
+ private long pointer;
- // Construction
- // 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.
- private Shade(long l)
- {
- nativeShade = l;
- }
-
- // FIXME: Constructors for the different types of shade
- // FIXME: Accessors for shade data
+ protected native void finalize();
- // Destruction
- public void destroy()
- {
+ public void destroy() {
finalize();
- nativeShade = 0;
+ pointer = 0;
}
- protected native void finalize();
+ 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
index 2f2fcf96..7f333f76 100644
--- a/platform/java/com/artifex/mupdf/fitz/StrokeState.java
+++ b/platform/java/com/artifex/mupdf/fitz/StrokeState.java
@@ -1,7 +1,5 @@
package com.artifex.mupdf.fitz;
-import android.graphics.Rect;
-
public class StrokeState
{
public static final int FZ_LINECAP_BUTT = 0;
@@ -14,36 +12,38 @@ public class StrokeState
public static final int FZ_LINEJOIN_BEVEL = 2;
public static final int FZ_LINEJOIN_MITER_XPS = 3;
- // Private data
- private long nativeStroke;
+ private long pointer;
- // Construction
- StrokeState(int startCap, int endCap, int lineJoin, float lineWidth, float miterLimit)
- {
- nativeStroke = newNative(startCap, 0, endCap, lineJoin, lineWidth, miterLimit, 0, null);
- }
+ protected native void finalize();
- StrokeState(int startCap, int dashCap, int endCap, int lineJoin, float lineWidth, float miterLimit, float dashPhase, float dash[])
- {
- nativeStroke = newNative(startCap, dashCap, endCap, lineJoin, lineWidth, miterLimit, dashPhase, dash);
+ 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 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 l)
- {
- nativeStroke = l;
+ 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);
}
- // Operation
public native void adjustRectForStroke(Rect rect, Matrix ctm);
- // Accessors
public native int getStartCap();
public native int getDashCap();
public native int getEndCap();
@@ -52,13 +52,4 @@ public class StrokeState
public native float getMiterLimit();
public native float getDashPhase();
public native float[] getDashes();
-
- // Destruction
- public void destroy()
- {
- finalize();
- nativeStroke = 0;
- }
-
- protected native void finalize();
}
diff --git a/platform/java/com/artifex/mupdf/fitz/Text.java b/platform/java/com/artifex/mupdf/fitz/Text.java
index eada4635..d5d9a836 100644
--- a/platform/java/com/artifex/mupdf/fitz/Text.java
+++ b/platform/java/com/artifex/mupdf/fitz/Text.java
@@ -1,46 +1,34 @@
package com.artifex.mupdf.fitz;
-public class Text
+public class Text implements TextWalker
{
- // Private data
- private long nativeText = 0;
- private boolean isConst = false;
-
- // Cloning
- public Text(Text old)
- {
- nativeText = cloneNative(old);
+ private long pointer;
+
+ protected native void finalize();
+
+ public void destroy() {
+ finalize();
+ pointer = 0;
}
+ private native long newNative();
private native long cloneNative(Text old);
- //public Text(Font font, Matrix trm, int wmode)
- //{
- // nativeText = newNative(font, trm, wmode);
- //}
-
- // Private method used for creating Text entries for a
- // device implemented in java. These entries should be
- // immutable.
- private Text(long ptr)
- {
- nativeText = ptr;
- isConst = true;
+ private Text(long p) {
+ pointer = p;
}
- // Operation
- public native Rect bound(StrokeState stroke, Matrix ctm);
+ public Text(Text old) {
+ pointer = cloneNative(old);
+ }
- //public native void add(int gid, int ucs, float x, float y);
+ public Text() {
+ pointer = newNative();
+ }
- // FIXME: Write accessors
+ public native void showGlyph(Font font, boolean vertical, Matrix trm, int glyph, int unicode);
- // Destruction
- public void destroy()
- {
- finalize();
- nativeText = 0;
- }
+ public native Rect getBounds(StrokeState stroke, Matrix ctm);
- protected native void finalize();
+ 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
new file mode 100644
index 00000000..99d3e150
--- /dev/null
+++ b/platform/java/com/artifex/mupdf/fitz/TextWalker.java
@@ -0,0 +1,6 @@
+package com.artifex.mupdf.fitz;
+
+public interface TextWalker
+{
+ public void showGlyph(Font font, boolean vertical, Matrix trm, int glyph, int unicode);
+}
diff --git a/platform/java/com/artifex/mupdf/fitz/TryLaterException.java b/platform/java/com/artifex/mupdf/fitz/TryLaterException.java
index 644c6af1..e2d1b88e 100644
--- a/platform/java/com/artifex/mupdf/fitz/TryLaterException.java
+++ b/platform/java/com/artifex/mupdf/fitz/TryLaterException.java
@@ -2,8 +2,7 @@ package com.artifex.mupdf.fitz;
public class TryLaterException extends Exception
{
- TryLaterException(String message)
- {
+ TryLaterException(String message) {
super(message);
}
}