< prev index next >
modules/javafx.graphics/src/main/java/com/sun/marlin/DTransformingPathConsumer2D.java
Print this page
*** 23,145 ****
* questions.
*/
package com.sun.marlin;
- import com.sun.javafx.geom.PathConsumer2D;
- import com.sun.javafx.geom.Path2D;
- import com.sun.javafx.geom.transform.BaseTransform;
-
- public final class TransformingPathConsumer2D {
! TransformingPathConsumer2D() {
! // used by RendererContext
! }
! // recycled PathConsumer2D instance from wrapPath2d()
! private final Path2DWrapper wp_Path2DWrapper = new Path2DWrapper();
! PathConsumer2D wrapPath2d(Path2D p2d)
! {
! return wp_Path2DWrapper.init(p2d);
}
! // recycled PathConsumer2D instances from deltaTransformConsumer()
private final DeltaScaleFilter dt_DeltaScaleFilter = new DeltaScaleFilter();
private final DeltaTransformFilter dt_DeltaTransformFilter = new DeltaTransformFilter();
! public PathConsumer2D deltaTransformConsumer(PathConsumer2D out,
BaseTransform at)
{
if (at == null) {
return out;
}
! float mxx = (float) at.getMxx();
! float mxy = (float) at.getMxy();
! float myx = (float) at.getMyx();
! float myy = (float) at.getMyy();
! if (mxy == 0f && myx == 0f) {
! if (mxx == 1f && myy == 1f) {
return out;
} else {
return dt_DeltaScaleFilter.init(out, mxx, myy);
}
} else {
return dt_DeltaTransformFilter.init(out, mxx, mxy, myx, myy);
}
}
! // recycled PathConsumer2D instances from inverseDeltaTransformConsumer()
private final DeltaScaleFilter iv_DeltaScaleFilter = new DeltaScaleFilter();
private final DeltaTransformFilter iv_DeltaTransformFilter = new DeltaTransformFilter();
! public PathConsumer2D inverseDeltaTransformConsumer(PathConsumer2D out,
BaseTransform at)
{
if (at == null) {
return out;
}
! float mxx = (float) at.getMxx();
! float mxy = (float) at.getMxy();
! float myx = (float) at.getMyx();
! float myy = (float) at.getMyy();
! if (mxy == 0f && myx == 0f) {
! if (mxx == 1f && myy == 1f) {
return out;
} else {
! return iv_DeltaScaleFilter.init(out, 1.0f/mxx, 1.0f/myy);
}
} else {
! float det = mxx * myy - mxy * myx;
return iv_DeltaTransformFilter.init(out,
myy / det,
-mxy / det,
-myx / det,
mxx / det);
}
}
! static final class DeltaScaleFilter implements PathConsumer2D {
! private PathConsumer2D out;
! private float sx, sy;
DeltaScaleFilter() {}
! DeltaScaleFilter init(PathConsumer2D out,
! float mxx, float myy)
{
this.out = out;
sx = mxx;
sy = myy;
return this; // fluent API
}
@Override
! public void moveTo(float x0, float y0) {
out.moveTo(x0 * sx, y0 * sy);
}
@Override
! public void lineTo(float x1, float y1) {
out.lineTo(x1 * sx, y1 * sy);
}
@Override
! public void quadTo(float x1, float y1,
! float x2, float y2)
{
out.quadTo(x1 * sx, y1 * sy,
x2 * sx, y2 * sy);
}
@Override
! public void curveTo(float x1, float y1,
! float x2, float y2,
! float x3, float y3)
{
out.curveTo(x1 * sx, y1 * sy,
x2 * sx, y2 * sy,
x3 * sx, y3 * sy);
}
--- 23,136 ----
* questions.
*/
package com.sun.marlin;
! import com.sun.javafx.geom.transform.BaseTransform;
! public final class DTransformingPathConsumer2D {
! DTransformingPathConsumer2D() {
! // used by DRendererContext
}
! // recycled DPathConsumer2D instances from deltaTransformConsumer()
private final DeltaScaleFilter dt_DeltaScaleFilter = new DeltaScaleFilter();
private final DeltaTransformFilter dt_DeltaTransformFilter = new DeltaTransformFilter();
! public DPathConsumer2D deltaTransformConsumer(DPathConsumer2D out,
BaseTransform at)
{
if (at == null) {
return out;
}
! double mxx = at.getMxx();
! double mxy = at.getMxy();
! double myx = at.getMyx();
! double myy = at.getMyy();
! if (mxy == 0D && myx == 0D) {
! if (mxx == 1D && myy == 1D) {
return out;
} else {
return dt_DeltaScaleFilter.init(out, mxx, myy);
}
} else {
return dt_DeltaTransformFilter.init(out, mxx, mxy, myx, myy);
}
}
! // recycled DPathConsumer2D instances from inverseDeltaTransformConsumer()
private final DeltaScaleFilter iv_DeltaScaleFilter = new DeltaScaleFilter();
private final DeltaTransformFilter iv_DeltaTransformFilter = new DeltaTransformFilter();
! public DPathConsumer2D inverseDeltaTransformConsumer(DPathConsumer2D out,
BaseTransform at)
{
if (at == null) {
return out;
}
! double mxx = at.getMxx();
! double mxy = at.getMxy();
! double myx = at.getMyx();
! double myy = at.getMyy();
! if (mxy == 0D && myx == 0D) {
! if (mxx == 1D && myy == 1D) {
return out;
} else {
! return iv_DeltaScaleFilter.init(out, 1.0D/mxx, 1.0D/myy);
}
} else {
! double det = mxx * myy - mxy * myx;
return iv_DeltaTransformFilter.init(out,
myy / det,
-mxy / det,
-myx / det,
mxx / det);
}
}
! static final class DeltaScaleFilter implements DPathConsumer2D {
! private DPathConsumer2D out;
! private double sx, sy;
DeltaScaleFilter() {}
! DeltaScaleFilter init(DPathConsumer2D out,
! double mxx, double myy)
{
this.out = out;
sx = mxx;
sy = myy;
return this; // fluent API
}
@Override
! public void moveTo(double x0, double y0) {
out.moveTo(x0 * sx, y0 * sy);
}
@Override
! public void lineTo(double x1, double y1) {
out.lineTo(x1 * sx, y1 * sy);
}
@Override
! public void quadTo(double x1, double y1,
! double x2, double y2)
{
out.quadTo(x1 * sx, y1 * sy,
x2 * sx, y2 * sy);
}
@Override
! public void curveTo(double x1, double y1,
! double x2, double y2,
! double x3, double y3)
{
out.curveTo(x1 * sx, y1 * sy,
x2 * sx, y2 * sy,
x3 * sx, y3 * sy);
}
*** 153,206 ****
public void pathDone() {
out.pathDone();
}
}
! static final class DeltaTransformFilter implements PathConsumer2D {
! private PathConsumer2D out;
! private float mxx, mxy, myx, myy;
DeltaTransformFilter() {}
! DeltaTransformFilter init(PathConsumer2D out,
! float mxx, float mxy,
! float myx, float myy)
{
this.out = out;
this.mxx = mxx;
this.mxy = mxy;
this.myx = myx;
this.myy = myy;
return this; // fluent API
}
@Override
! public void moveTo(float x0, float y0) {
out.moveTo(x0 * mxx + y0 * mxy,
x0 * myx + y0 * myy);
}
@Override
! public void lineTo(float x1, float y1) {
out.lineTo(x1 * mxx + y1 * mxy,
x1 * myx + y1 * myy);
}
@Override
! public void quadTo(float x1, float y1,
! float x2, float y2)
{
out.quadTo(x1 * mxx + y1 * mxy,
x1 * myx + y1 * myy,
x2 * mxx + y2 * mxy,
x2 * myx + y2 * myy);
}
@Override
! public void curveTo(float x1, float y1,
! float x2, float y2,
! float x3, float y3)
{
out.curveTo(x1 * mxx + y1 * mxy,
x1 * myx + y1 * myy,
x2 * mxx + y2 * mxy,
x2 * myx + y2 * myy,
--- 144,197 ----
public void pathDone() {
out.pathDone();
}
}
! static final class DeltaTransformFilter implements DPathConsumer2D {
! private DPathConsumer2D out;
! private double mxx, mxy, myx, myy;
DeltaTransformFilter() {}
! DeltaTransformFilter init(DPathConsumer2D out,
! double mxx, double mxy,
! double myx, double myy)
{
this.out = out;
this.mxx = mxx;
this.mxy = mxy;
this.myx = myx;
this.myy = myy;
return this; // fluent API
}
@Override
! public void moveTo(double x0, double y0) {
out.moveTo(x0 * mxx + y0 * mxy,
x0 * myx + y0 * myy);
}
@Override
! public void lineTo(double x1, double y1) {
out.lineTo(x1 * mxx + y1 * mxy,
x1 * myx + y1 * myy);
}
@Override
! public void quadTo(double x1, double y1,
! double x2, double y2)
{
out.quadTo(x1 * mxx + y1 * mxy,
x1 * myx + y1 * myy,
x2 * mxx + y2 * mxy,
x2 * myx + y2 * myy);
}
@Override
! public void curveTo(double x1, double y1,
! double x2, double y2,
! double x3, double y3)
{
out.curveTo(x1 * mxx + y1 * mxy,
x1 * myx + y1 * myy,
x2 * mxx + y2 * mxy,
x2 * myx + y2 * myy,
*** 216,263 ****
@Override
public void pathDone() {
out.pathDone();
}
}
-
- static final class Path2DWrapper implements PathConsumer2D {
- private Path2D p2d;
-
- Path2DWrapper() {}
-
- Path2DWrapper init(Path2D p2d) {
- this.p2d = p2d;
- return this;
- }
-
- @Override
- public void moveTo(float x0, float y0) {
- p2d.moveTo(x0, y0);
- }
-
- @Override
- public void lineTo(float x1, float y1) {
- p2d.lineTo(x1, y1);
- }
-
- @Override
- public void closePath() {
- p2d.closePath();
- }
-
- @Override
- public void pathDone() {}
-
- @Override
- public void curveTo(float x1, float y1,
- float x2, float y2,
- float x3, float y3)
- {
- p2d.curveTo(x1, y1, x2, y2, x3, y3);
- }
-
- @Override
- public void quadTo(float x1, float y1, float x2, float y2) {
- p2d.quadTo(x1, y1, x2, y2);
- }
- }
}
--- 207,212 ----
< prev index next >