mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-04 20:15:28 -04:00
#490: Adobe Path PoC
This commit is contained in:
parent
859b232f64
commit
eec8268eb9
@ -10,16 +10,26 @@ import java.io.IOException;
|
||||
* @deprecated Use {@link AdobePathReader} instead. This class will be removed in a future release.
|
||||
*/
|
||||
public final class AdobePathBuilder {
|
||||
|
||||
private final AdobePathReader delegate;
|
||||
|
||||
public AdobePathBuilder(final byte[] data) {
|
||||
this.delegate = new AdobePathReader(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see AdobePathReader#AdobePathReader(DataInput)
|
||||
*/
|
||||
public AdobePathBuilder(final DataInput data) {
|
||||
this.delegate = new AdobePathReader(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see AdobePathReader#AdobePathReader(byte[])
|
||||
*/
|
||||
public AdobePathBuilder(final byte[] data) {
|
||||
this.delegate = new AdobePathReader(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see AdobePathReader#path()
|
||||
*/
|
||||
public Path2D path() throws IOException {
|
||||
return delegate.path();
|
||||
}
|
||||
|
@ -57,8 +57,8 @@ public final class AdobePathReader {
|
||||
private final DataInput data;
|
||||
|
||||
/**
|
||||
* Creates a path builder that will read its data from a {@code DataInput}, such as an
|
||||
* {@code ImageInputStream}.
|
||||
* Creates a path reader that will read its data from a {@code DataInput},
|
||||
* such as an {@code ImageInputStream}.
|
||||
* The data length is assumed to be a multiple of 26.
|
||||
*
|
||||
* @param data the input to read data from.
|
||||
@ -70,7 +70,7 @@ public final class AdobePathReader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a path builder that will read its data from a {@code byte} array.
|
||||
* Creates a path reader that will read its data from a {@code byte} array.
|
||||
* The array length must be a multiple of 26, and greater than 0.
|
||||
*
|
||||
* @param data the array to read data from.
|
||||
@ -84,14 +84,14 @@ public final class AdobePathReader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the path.
|
||||
* Builds the path by reading from the supplied input.
|
||||
*
|
||||
* @return the path
|
||||
* @throws javax.imageio.IIOException if the input contains a bad path data.
|
||||
* @throws IOException if a general I/O exception occurs during reading.
|
||||
*/
|
||||
public Path2D path() throws IOException {
|
||||
List<List<AdobePathSegment>> subPaths = new ArrayList<List<AdobePathSegment>>();
|
||||
List<List<AdobePathSegment>> subPaths = new ArrayList<>();
|
||||
List<AdobePathSegment> currentPath = null;
|
||||
int currentPathLength = 0;
|
||||
|
||||
@ -110,7 +110,7 @@ public final class AdobePathReader {
|
||||
subPaths.add(currentPath);
|
||||
}
|
||||
|
||||
currentPath = new ArrayList<AdobePathSegment>(segment.length);
|
||||
currentPath = new ArrayList<>(segment.length);
|
||||
currentPathLength = segment.length;
|
||||
}
|
||||
else if (segment.selector == AdobePathSegment.OPEN_SUBPATH_BEZIER_LINKED
|
||||
@ -137,7 +137,7 @@ public final class AdobePathReader {
|
||||
subPaths.add(currentPath);
|
||||
}
|
||||
|
||||
// now we have collected the PathPoints now create a Shape.
|
||||
// We have collected the Path points, now create a Shape
|
||||
return pathToShape(subPaths);
|
||||
}
|
||||
|
||||
@ -199,6 +199,8 @@ public final class AdobePathReader {
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ final class AdobePathSegment {
|
||||
}
|
||||
|
||||
AdobePathSegment(int fillRuleSelector) {
|
||||
this(isTrue(fillRuleSelector == PATH_FILL_RULE_RECORD, fillRuleSelector, "Expected fill rule record (6): %s"),
|
||||
this(isTrue(fillRuleSelector == PATH_FILL_RULE_RECORD || fillRuleSelector == INITIAL_FILL_RULE_RECORD, fillRuleSelector, "Expected fill rule record (6 or 8): %s"),
|
||||
0, -1, -1, -1, -1, -1, -1);
|
||||
}
|
||||
|
||||
@ -190,7 +190,6 @@ final class AdobePathSegment {
|
||||
default:
|
||||
// fall-through
|
||||
}
|
||||
|
||||
return String.format("Pt(pre=(%.3f, %.3f), knot=(%.3f, %.3f), post=(%.3f, %.3f), selector=%s)", cppx, cppy, apx, apy, cplx, cply, SELECTOR_NAMES[selector]);
|
||||
}
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ public final class AdobePathWriter {
|
||||
if (initial.apx != prev.apx || initial.apy != prev.apy) {
|
||||
// TODO: Line back to initial if last anchor point does not equal initial anchor?
|
||||
// subpath.add(new AdobePathSegment(CLOSED_SUBPATH_BEZIER_LINKED, prev.cppy, prev.cppx, prev.apy, prev.apx, 0, 0));
|
||||
System.err.println("FOO!");
|
||||
throw new AssertionError("Not a closed path");
|
||||
}
|
||||
subpath.set(0, new AdobePathSegment(CLOSED_SUBPATH_BEZIER_LINKED, prev.cppy, prev.cppx, initial.apy, initial.apx, initial.cply, initial.cplx));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user