当前位置: 首页>>代码示例>>Java>>正文


Java Polygon.contains方法代码示例

本文整理汇总了Java中java.awt.Polygon.contains方法的典型用法代码示例。如果您正苦于以下问题:Java Polygon.contains方法的具体用法?Java Polygon.contains怎么用?Java Polygon.contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Polygon的用法示例。


在下文中一共展示了Polygon.contains方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: selectLine

import java.awt.Polygon; //导入方法依赖的package包/类
/**
 * Return true if the point is on a line between the first and the second
 * point
 * 
 * @param p1
 *            The first point of the line
 * @param p2
 *            The second point of the line
 * @param point
 *            The point that could be on the line
 * @return True if the point is on a line between the first and the second
 *         point
 */
public boolean selectLine(DPoint p1, DPoint p2, Point point) {
	Polygon p = new Polygon();
	p.addPoint(plane.getTrueX(p1.getX()) - 3 * getPointSize(),
			plane.getTrueY(p1.getY()) + 3 * getPointSize());
	p.addPoint(plane.getTrueX(p1.getX()) + 3 * getPointSize(),
			plane.getTrueY(p1.getY()) + 3 * getPointSize());
	p.addPoint(plane.getTrueX(p2.getX()) + 3 * getPointSize(),
			plane.getTrueY(p2.getY()) - 3 * getPointSize());
	p.addPoint(plane.getTrueX(p2.getX()) - 3 * getPointSize(),
			plane.getTrueY(p2.getY()) - 3 * getPointSize());

	if (p.contains(point)) {
		return true;
	}
	return false;

}
 
开发者ID:max6cn,项目名称:jmt,代码行数:31,代码来源:Convex2DGraph.java

示例2: mouseMoved

import java.awt.Polygon; //导入方法依赖的package包/类
public void mouseMoved(MouseEvent ev) {
	DPoint test = adjustMousePoint(ev.getX(), ev.getY());

	DPoint pointA = plane.getTruePoint(new DPoint(0, 1));
	DPoint pointB = plane.getTruePoint(new DPoint(1, 0));

	Polygon rect = new Polygon();
	rect.addPoint((int) pointA.getX(), (int) pointA.getY() - 16);
	rect.addPoint((int) pointA.getX(), (int) pointA.getY() + 16);
	rect.addPoint((int) pointB.getX(), (int) pointB.getY() - 16);
	rect.addPoint((int) pointB.getX(), (int) pointB.getY() + 16);
	if (rect.contains(test)) {
		tooltip = test;
		repaint();
		return;
	}
	if (tooltip != null) {
		tooltip = null;
		repaint();
		return;
	}
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:23,代码来源:Sectors2DGraph.java

示例3: mouseMoved

import java.awt.Polygon; //导入方法依赖的package包/类
public void mouseMoved(MouseEvent ev) {
	ArrayList<DPoint>[] util;
	util = data.getResults().getUtilization();

	for (int j = 0; j < data.getStationNames().length; j++) {
		DPoint test = this.adjustMousePoint(ev.getX(), ev.getY());
		if (stationLabels[j] != null && stationLabels[j].contains(test)) {
			setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
			return;
		}
		int i;
		for (i = 0; i < util[j].size(); i = i + 2) {
			if (!showStation[j])
				continue;
			DPoint pointA = plane.getTruePoint(util[j].get(i));
			DPoint pointB = plane.getTruePoint(util[j].get(i + 1));

			Polygon rect = new Polygon();
			rect.addPoint((int) pointA.getX(), (int) pointA.getY() - 16);
			rect.addPoint((int) pointA.getX(), (int) pointA.getY() + 16);
			rect.addPoint((int) pointB.getX(), (int) pointB.getY() - 16);
			rect.addPoint((int) pointB.getX(), (int) pointB.getY() + 16);
			if (rect.contains(test)) {
				tooltip = test;
				repaint();
				return;
			}
		}
	}
	setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
	if (tooltip != null) {
		tooltip = null;
		repaint();
	}
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:36,代码来源:PerformanceIndices2DGraph.java

示例4: selectLine

import java.awt.Polygon; //导入方法依赖的package包/类
/**
 * Return true if the point is on a line between the first and the second point
 * @param p1 The first point of the line
 * @param p2 The second point of the line
 * @param point The point that could be on the line
 * @return True if the point is on a line between the first and the second point
 */
public boolean selectLine(DPoint p1, DPoint p2, Point point) {
	Polygon p = new Polygon();
	p.addPoint((int) ((p1.getX() * scale) + tran_x - ((pointSize + 1))), (int) ((tran_y - (p1.getY() * scale) + ((pointSize + 1)))));
	p.addPoint((int) ((p1.getX() * scale) + tran_x + ((pointSize + 1))), (int) ((tran_y - (p1.getY() * scale) - ((pointSize + 1)))));
	p.addPoint((int) ((p2.getX() * scale) + tran_x + ((pointSize + 1))), (int) ((tran_y - (p2.getY() * scale) - ((pointSize + 1)))));
	p.addPoint((int) ((p2.getX() * scale) + tran_x - ((pointSize + 1))), (int) ((tran_y - (p2.getY() * scale) + ((pointSize + 1)))));

	if (p.contains(point)) {
		return true;
	}
	return false;
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:20,代码来源:PainterConvex2D.java

示例5: mouseMoved

import java.awt.Polygon; //导入方法依赖的package包/类
@Override
public void mouseMoved(MouseEvent e) {
    final Point p = e.getPoint();
    final Polygon polygon = getTriangle();
    if(polygon.contains(p)){
        inTheTriangleZone = true;
        this.setCursor(new Cursor(Cursor.SE_RESIZE_CURSOR));
        this.repaint();
    } else {
        inTheTriangleZone = false;
        this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        this.repaint();
    }
}
 
开发者ID:Panzer1119,项目名称:JAddOn,代码行数:15,代码来源:JExpandableTextArea.java

示例6: mouseMoved

import java.awt.Polygon; //导入方法依赖的package包/类
public void mouseMoved(MouseEvent e) {
	dragPoint = adjustMousePoint2(e.getX(), e.getY());
	Vector<Point2D> point = data.getResults().getAllPoints();
	DPoint p;

	selectedPoint = null;
	selectedConvexSegment = null;
	dragging = false;
	// If the mouse pass over a point, the mouse change
	for (int i = 0; i < point.size(); i++) {
		p = (DPoint) point.get(i);
		if (theSame(dragPoint, p, 2)) {
			setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
			selectedPoint = p;
			repaint();
			return;
		}
	}
	selectedPoint = null;
	// If the cursor pass over a saturation sector the mouse change
	Vector<Point2D> convex = data.getResults().getAllConvex();
	for (int k = 0; k < convex.size() - 1; k++) {
		DPoint pointA = plane.getTruePoint(convex.get(k));
		DPoint pointB = plane.getTruePoint(convex.get(k + 1));

		Polygon rect = new Polygon();
		rect.addPoint((int) pointA.getX(), (int) pointA.getY() - 16);
		rect.addPoint((int) pointA.getX(), (int) pointA.getY() + 16);
		rect.addPoint((int) pointB.getX(), (int) pointB.getY() - 16);
		rect.addPoint((int) pointB.getX(), (int) pointB.getY() + 16);
		DPoint test = new DPoint(dragPoint.getX(), dragPoint.getY());
		if (rect.contains(test)) {
			selectedConvexSegment = new ConvexSegment(new DPoint(convex
					.get(k).getX(), convex.get(k).getY()), new DPoint(
					convex.get(k + 1).getX(), convex.get(k + 1).getY()));
			repaint();
			return;
		}

	}
	selectedConvexSegment = null;
	setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
	repaint();
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:45,代码来源:Convex2DGraph.java

示例7: mouseReleased

import java.awt.Polygon; //导入方法依赖的package包/类
public void mouseReleased(MouseEvent e) {
	double[][][] serviceDemands;
	Vector<Point2D> allPoints;

	if (filtering || unFiltering) {
		int x[] = new int[2];
		int y[] = new int[2];
		x[0] = filterStartPoint.x;
		y[0] = filterStartPoint.y;
		int deltaX = filterStartPoint.x - filterEndPoint.x;
		int deltaY = filterStartPoint.y - filterEndPoint.y;
		x[1] = x[0] - deltaX;
		y[1] = y[0] - deltaY;
		Polygon area = twoPointRectangle(x[0], y[0], x[1], y[1]);

		for (int i = 0; i < data.getResults().getPoints().size(); i++) {
			Point2D test = data.getResults().getPoints().get(i);
			if (area.contains(plane.getTruePoint(test))) {
				filterStationLabel[i] = filtering;
			}
		}
		// TODO Add code to (un)filter.
		filtering = false;
		unFiltering = false;
		repaint();
		return;
	}
	if (!dragging || selectedPoint == null)
		return;
	mouseButtonPress = e.getButton();

	if (mouseButtonPress == 1) {
		setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
		serviceDemands = this.data.getServiceTimes();

		allPoints = data.getResults().getAllPoints();
		for (int k = 0; k < allPoints.size(); k++) {
			if (((DPoint) allPoints.get(k)).equals(selectedPoint)) {
				serviceDemands[k][0][0] = Math
						.max(getTrueX(e.getX()), 0.01);
				serviceDemands[k][1][0] = Math
						.max(getTrueY(e.getY()), 0.01);
				commit(serviceDemands);
				mainWin.solve();
			}
		}
	}
	dragging = false;
	selectedPoint = null;
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:51,代码来源:Convex2DGraph.java


注:本文中的java.awt.Polygon.contains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。