當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。