下面列出了java.awt.geom.Path2D#intersects ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
static void testIntersect(Path2D pathA, Path2D pathB) {
boolean resA = pathA.intersects(rect2d);
boolean resB = pathB.intersects(rect2d);
if (resA != resB) {
throw new IllegalStateException("Intersects(rect2d) are not equals ["
+ resA + "|" + resB + "] !");
}
resA = pathA.intersects(1.0, 2.0, 13.0, 17.0);
resB = pathB.intersects(1.0, 2.0, 13.0, 17.0);
if (resA != resB) {
throw new IllegalStateException("Intersects(doubles) are not equals ["
+ resA + "|" + resB + "] !");
}
log("testIntersect: passed.");
}
static void testIntersect(Path2D pathA, Path2D pathB) {
boolean resA = pathA.intersects(rect2d);
boolean resB = pathB.intersects(rect2d);
if (resA != resB) {
throw new IllegalStateException("Intersects(rect2d) are not equals ["
+ resA + "|" + resB + "] !");
}
resA = pathA.intersects(1.0, 2.0, 13.0, 17.0);
resB = pathB.intersects(1.0, 2.0, 13.0, 17.0);
if (resA != resB) {
throw new IllegalStateException("Intersects(doubles) are not equals ["
+ resA + "|" + resB + "] !");
}
log("testIntersect: passed.");
}
static void testIntersect(Path2D pathA, Path2D pathB) {
boolean resA = pathA.intersects(rect2d);
boolean resB = pathB.intersects(rect2d);
if (resA != resB) {
throw new IllegalStateException("Intersects(rect2d) are not equals ["
+ resA + "|" + resB + "] !");
}
resA = pathA.intersects(1.0, 2.0, 13.0, 17.0);
resB = pathB.intersects(1.0, 2.0, 13.0, 17.0);
if (resA != resB) {
throw new IllegalStateException("Intersects(doubles) are not equals ["
+ resA + "|" + resB + "] !");
}
log("testIntersect: passed.");
}
static void testIntersect(Path2D pathA, Path2D pathB) {
boolean resA = pathA.intersects(rect2d);
boolean resB = pathB.intersects(rect2d);
if (resA != resB) {
throw new IllegalStateException("Intersects(rect2d) are not equals ["
+ resA + "|" + resB + "] !");
}
resA = pathA.intersects(1.0, 2.0, 13.0, 17.0);
resB = pathB.intersects(1.0, 2.0, 13.0, 17.0);
if (resA != resB) {
throw new IllegalStateException("Intersects(doubles) are not equals ["
+ resA + "|" + resB + "] !");
}
log("testIntersect: passed.");
}
static void testIntersect(Path2D pathA, Path2D pathB) {
boolean resA = pathA.intersects(rect2d);
boolean resB = pathB.intersects(rect2d);
if (resA != resB) {
throw new IllegalStateException("Intersects(rect2d) are not equals ["
+ resA + "|" + resB + "] !");
}
resA = pathA.intersects(1.0, 2.0, 13.0, 17.0);
resB = pathB.intersects(1.0, 2.0, 13.0, 17.0);
if (resA != resB) {
throw new IllegalStateException("Intersects(doubles) are not equals ["
+ resA + "|" + resB + "] !");
}
log("testIntersect: passed.");
}
static void testIntersect(Path2D pathA, Path2D pathB) {
boolean resA = pathA.intersects(rect2d);
boolean resB = pathB.intersects(rect2d);
if (resA != resB) {
throw new IllegalStateException("Intersects(rect2d) are not equals ["
+ resA + "|" + resB + "] !");
}
resA = pathA.intersects(1.0, 2.0, 13.0, 17.0);
resB = pathB.intersects(1.0, 2.0, 13.0, 17.0);
if (resA != resB) {
throw new IllegalStateException("Intersects(doubles) are not equals ["
+ resA + "|" + resB + "] !");
}
log("testIntersect: passed.");
}
static void testIntersect(Path2D pathA, Path2D pathB) {
boolean resA = pathA.intersects(rect2d);
boolean resB = pathB.intersects(rect2d);
if (resA != resB) {
throw new IllegalStateException("Intersects(rect2d) are not equals ["
+ resA + "|" + resB + "] !");
}
resA = pathA.intersects(1.0, 2.0, 13.0, 17.0);
resB = pathB.intersects(1.0, 2.0, 13.0, 17.0);
if (resA != resB) {
throw new IllegalStateException("Intersects(doubles) are not equals ["
+ resA + "|" + resB + "] !");
}
log("testIntersect: passed.");
}
static void testIntersect(Path2D pathA, Path2D pathB) {
boolean resA = pathA.intersects(rect2d);
boolean resB = pathB.intersects(rect2d);
if (resA != resB) {
throw new IllegalStateException("Intersects(rect2d) are not equals ["
+ resA + "|" + resB + "] !");
}
resA = pathA.intersects(1.0, 2.0, 13.0, 17.0);
resB = pathB.intersects(1.0, 2.0, 13.0, 17.0);
if (resA != resB) {
throw new IllegalStateException("Intersects(doubles) are not equals ["
+ resA + "|" + resB + "] !");
}
log("testIntersect: passed.");
}
static void testIntersect(Path2D pathA, Path2D pathB) {
boolean resA = pathA.intersects(rect2d);
boolean resB = pathB.intersects(rect2d);
if (resA != resB) {
throw new IllegalStateException("Intersects(rect2d) are not equals ["
+ resA + "|" + resB + "] !");
}
resA = pathA.intersects(1.0, 2.0, 13.0, 17.0);
resB = pathB.intersects(1.0, 2.0, 13.0, 17.0);
if (resA != resB) {
throw new IllegalStateException("Intersects(doubles) are not equals ["
+ resA + "|" + resB + "] !");
}
log("testIntersect: passed.");
}
public boolean intersects(double x, double y, double w, double h) {
return Path2D.intersects(getPathIterator(null), x, y, w, h);
}
public boolean intersects(Rectangle2D r) {
return Path2D.intersects(getPathIterator(null), r);
}
private ShapeInfo CreateFeintDummyIndicator(String symbolID, Rectangle2D symbolBounds, Rectangle2D echelonBounds )
{
Path2D sFeint = new Path2D.Double();
ShapeInfo siFeint = null;
//float dash[] = {5.0f};
float dash[] = {6.0f, 4.0f};
//Shape sFeint = null;
//dashed stroke
float width = 2.0f;
try
{
if(symbolBounds != null && symbolBounds.getWidth()<20)
{
width = 1.0f;
dash[0] = 5.0f;
dash[1] = 3.0f;
}
Stroke stroke = new BasicStroke(width,BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash, 0.0f);
Point2D left = new Point2D.Double(symbolBounds.getX(), symbolBounds.getY());
Point2D top = null;//new Point2D.Double(symbolBounds.getCenterX(), symbolBounds.getY() - (symbolBounds.getHeight() * .75));
Point2D right = new Point2D.Double(symbolBounds.getX() + symbolBounds.getWidth(), symbolBounds.getY());
String affiliation = symbolID.substring(1, 2);
if(affiliation.equals("F") ||
affiliation.equals("A") ||
affiliation.equals("D") ||
affiliation.equals("M") ||
affiliation.equals("J") ||
affiliation.equals("K"))
{
top = new Point2D.Double(symbolBounds.getCenterX(), symbolBounds.getY() - (symbolBounds.getHeight() * .75));
}
else
{
top = new Point2D.Double(symbolBounds.getCenterX(), symbolBounds.getY() - (symbolBounds.getHeight() * .54));
}
Line2D leftLine = new Line2D.Double(left, top);
Line2D rightLine = new Line2D.Double(top, right);
sFeint.append(leftLine, false);
sFeint.append(rightLine, false);
if(echelonBounds != null && sFeint.intersects(echelonBounds))
{
//move it above echelon and add some breathing room
sFeint.transform(AffineTransform.getTranslateInstance(0, -echelonBounds.getHeight()-2));
}
siFeint = new ShapeInfo(sFeint);
siFeint.setLineColor(Color.BLACK);
siFeint.setStroke(stroke);
siFeint.setShapeType(ShapeInfo.SHAPE_TYPE_UNIT_DISPLAY_MODIFIER);
}
catch(Exception exc)
{
ErrorLogger.LogException(_className, "CreateFeintDummyIndicator()", exc);
}
return siFeint;
}