Revision 23749 branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/primitive/GeneralPathX.java
GeneralPathX.java | ||
---|---|---|
59 | 59 |
import java.awt.geom.Point2D; |
60 | 60 |
import java.awt.geom.Rectangle2D; |
61 | 61 |
import java.io.Serializable; |
62 |
import java.lang.reflect.InvocationTargetException; |
|
63 |
import java.lang.reflect.Method; |
|
62 | 64 |
import java.util.ArrayList; |
63 | 65 |
|
64 | 66 |
import org.cresques.cts.ICoordTrans; |
... | ... | |
103 | 105 |
*/ |
104 | 106 |
private static final long serialVersionUID = 1L; |
105 | 107 |
|
108 |
private static Method crossingsForPath = null; |
|
109 |
|
|
106 | 110 |
/** |
107 | 111 |
* An even-odd winding rule for determining the interior of |
108 | 112 |
* a path. |
... | ... | |
635 | 639 |
return false; |
636 | 640 |
} |
637 | 641 |
// int cross = sun.awt.geom.Curve.pointCrossingsForPath(getPathIterator(null), x, y); |
638 |
int cross = Curve.crossingsForPath(getPathIterator(null), x, y); |
|
642 |
// int cross = Curve.crossingsForPath(getPathIterator(null), x, y); |
|
643 |
int cross = curveCrossingsForPath(getPathIterator(null), x, y); |
|
639 | 644 |
if (windingRule == WIND_NON_ZERO) { |
640 | 645 |
return (cross != 0); |
641 | 646 |
} else { |
... | ... | |
643 | 648 |
} |
644 | 649 |
} |
645 | 650 |
|
651 |
private static int curveCrossingsForPath(PathIterator pathIterator, double x, double y) { |
|
652 |
|
|
653 |
if( crossingsForPath == null ) { |
|
654 |
Class curve = sun.awt.geom.Curve.class; |
|
655 |
|
|
656 |
try { |
|
657 |
crossingsForPath = curve.getMethod("pointCrossingsForPath", new Class[] { PathIterator.class, double.class, double.class }); |
|
658 |
} catch (SecurityException e) { |
|
659 |
throw new RuntimeException(e); |
|
660 |
} catch (NoSuchMethodException e) { |
|
661 |
try { |
|
662 |
crossingsForPath = curve.getMethod("crossingsForPath", new Class[] { PathIterator.class, double.class, double.class }); |
|
663 |
} catch (SecurityException e1) { |
|
664 |
throw new RuntimeException(e); |
|
665 |
} catch (NoSuchMethodException e1) { |
|
666 |
throw new RuntimeException(e); |
|
667 |
} |
|
668 |
} |
|
669 |
} |
|
670 |
try { |
|
671 |
return ((Integer) crossingsForPath.invoke(Curve.class, pathIterator, x,y)).intValue(); |
|
672 |
} catch (IllegalArgumentException e) { |
|
673 |
throw new RuntimeException(e); |
|
674 |
} catch (IllegalAccessException e) { |
|
675 |
throw new RuntimeException(e); |
|
676 |
} catch (InvocationTargetException e) { |
|
677 |
throw new RuntimeException(e); |
|
678 |
} |
|
679 |
} |
|
680 |
|
|
646 | 681 |
/** |
647 | 682 |
* Tests if the specified <code>Point2D</code> is inside the boundary |
648 | 683 |
* of this <code>Shape</code>. |
Also available in: Unified diff