⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 intersect.java

📁 这是自定义工作流的图形定义部分
💻 JAVA
字号:
//package vlab;   判断此点是否在规定地范围内import java.awt.*;/** * Title:        work-flow * Description: * Copyright:    Copyright (c) 2002 * Company:      CSU * @author       smallbeetle * @version 1.0 */public class Intersect {  //dot and line  public static boolean isIntersect(Point dot, Point header, Point tail ){    return isIntersect(new Rectangle(dot.x, dot.y, 1, 1), getRect(header, tail));  }  public static Rectangle getRect(Point p1, Point p2){    int x = p1.x <= p2.x ? p1.x : p2.x;    int y = p1.y <= p2.y ? p1.y : p2.y;    int w = Math.abs(p1.x - p2.x);    int h = Math.abs(p1.y - p2.y);    return new Rectangle(x, y, w, h);  }  //dot and rectangle  public static boolean isIntersect(Point dot, Rectangle rect){    return rect.contains(dot) ;  //    return ((dot.x >= rect.x ) && (dot.x <= rect.x +rect.width) &&(dot.y >= rect.y ) && (dot.y <= rect.y +rect.height));  } //line and line public static boolean isIntersect(Point h1, Point t1, Point h2, Point t2){   return isIntersect(getRect(h1,t1), getRect(h2, t2)); } //line and rectangle  public static boolean isIntersect(Point h, Point t, Rectangle r){    return isIntersect(getRect(h, t), r);  }  //rectangle and rectangle  public static boolean isIntersect(Rectangle r1, Rectangle r2){    if ( r2.y > r1.y+r1.height || r2.y + r2.height < r1.y         || r2.x + r2.width < r1.x || r2.x  > r1.x + r1.width){      return false;    }    return true;  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -