當前位置: 首頁>>代碼示例>>Java>>正文


Java GeneralPath.contains方法代碼示例

本文整理匯總了Java中java.awt.geom.GeneralPath.contains方法的典型用法代碼示例。如果您正苦於以下問題:Java GeneralPath.contains方法的具體用法?Java GeneralPath.contains怎麽用?Java GeneralPath.contains使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.geom.GeneralPath的用法示例。


在下文中一共展示了GeneralPath.contains方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getTriangle

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
protected int getTriangle(final FloatPoint point) {
    int res = -1;

    FloatPoint l = getLocation();

    for (int type = MovingPanel.RIGHT; type <= MovingPanel.TOP; type++) {
        GeneralPath gp = getTrianglePath(type);
        double y = point.getY() + l.getY();
        double x = point.getX() + l.getX();
        if (gp.contains(new Point2D.Double(x, y))) {
            res = type;
            break;
        }
    }

    return res;
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:18,代碼來源:DFDFunctionEllipse.java

示例2: getTriangle

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
protected int getTriangle(final FloatPoint point) {
    int res = -1;

    FloatPoint l = getLocation();

    for (int type = MovingPanel.RIGHT; type <= MovingPanel.TOP; type++) {
        GeneralPath gp = getTrianglePath(type);
        double y = point.getY() + l.getY();
        double x = point.getX() + l.getX();
        if (gp.contains(new Point2D.Double(x, y))) {
            res = type;
            break;
        }
    }

    if (isShowRight() ^ res == Point.RIGHT)
        res = -1;
    return res;
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:20,代碼來源:IDEF0Object.java

示例3: selectLasso

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
/**
	Selects the area represented by poly
*/	
void selectLasso(XYGraph xyg) {
	GeneralPath path = new GeneralPath();

	for (int i=0; i<poly.npoints; i++){
		Point2D p2 = new Point2D.Float (poly.xpoints[i], poly.ypoints[i]);
		Point2D point = new Point2D.Double (xyg.getXAt(p2), xyg.getYAt(p2));
		if (i==0) path.moveTo((float)point.getX(), (float) point.getY());
		else path.lineTo((float)point.getX(), (float) point.getY());
	}
	path.closePath();
	Rectangle2D r = path.getBounds();

	int n = 0;
	while (n<x.length&&(Float.isNaN(x[n])||Float.isNaN(y[n]))) {
		n++;
	}
	if (n>=x.length) return;
	
	table.getSelectionModel().setValueIsAdjusting(true);
	table.clearSelection();
	for (int i = n; i < x.length; i++) {
		if (Float.isNaN(x[i])||Float.isNaN(y[i])) continue;
		if (r.contains(x[i], y[i]) && path.contains(x[i], y[i])) {
			table.getSelectionModel().addSelectionInterval(i, i);
		}
	}
	table.getSelectionModel().setValueIsAdjusting(false);

	unDrawLasso(xyg);
	if (table.getSelectedRow() != -1)
		table.ensureIndexIsVisible(table.getSelectedRow());
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:36,代碼來源:PDBDataSetGraph.java

示例4: selectLasso

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
/**
		Selects the area represented by poly
	*/
	void selectLasso(XYGraph xyg) {
		GeneralPath path = new GeneralPath();

		for (int i=0; i<poly.npoints; i++){
			Point2D p2 = new Point2D.Float (poly.xpoints[i], poly.ypoints[i]);
			Point2D point = new Point2D.Double (xyg.getXAt(p2), xyg.getYAt(p2));
			if (i==0) path.moveTo((float)point.getX(), (float) point.getY());
			else path.lineTo((float)point.getX(), (float) point.getY());
		}
		path.closePath();
		Rectangle2D r = path.getBounds();

		ds.dataT.getSelectionModel().setValueIsAdjusting(true);
		if (scatter) {
			int n = 0;
			while (n<x.length&&(Float.isNaN(x[n])||Float.isNaN(y[n]))) {
				n++;
			}
			if (n>=x.length) return;
			for (int i = n; i < x.length; i++) {
				if (Float.isNaN(x[i])||Float.isNaN(y[i])) continue;
				if (r.contains(x[i], y[i]) && path.contains(x[i], y[i])) {
					ds.dataT.getSelectionModel().addSelectionInterval(i, i);
				}
			}
		}

		unDrawLasso(xyg);
//		selectionChangedRedraw(ds.selected);

		ds.dataT.getSelectionModel().setValueIsAdjusting(false);

		if (ds.dataT.getSelectedRow() != -1)
			ds.dataT.ensureIndexIsVisible(ds.dataT.getSelectedRow());
	}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:39,代碼來源:DataSetGraph.java

示例5: selectLasso

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
public void selectLasso() {
	GeneralPath path = new GeneralPath();

	for (int i=0; i<poly.npoints; i++){
		Point2D point = map.getScaledPoint(new Point(poly.xpoints[i],poly.ypoints[i]));
		if (i==0) path.moveTo((float)point.getX(), (float) point.getY());
		else path.lineTo((float)point.getX(), (float) point.getY());
	}
	path.closePath();
	r=path.getBounds();

	Rectangle2D rect = map.getClipRect2D();
	float yMin = (float)rect.getY();
	float yMax = (float)(rect.getY() + rect.getHeight());
	float xMin = (float)rect.getX();
	float xMax = (float)(rect.getX() + rect.getWidth());
	float wrap = (float)map.getWrap();

	table.getSelectionModel().setValueIsAdjusting(true);
	table.clearSelection();

	for( int k=0 ; k<model.current.length ; k++) {
		PDBStation stat = PDBStation.get(model.current[k]);

		double x = stat.getX();
		double y = stat.getY();
		if( y<yMin || y>yMax ) continue;

		if( wrap>0f ) {
			while( x>xMin+wrap ) x -= wrap;
			while( x<xMin ) x += wrap;
			while( x<xMax ) {
				if (r.contains(x, y)&&path.contains(x, y))
					table.addRowSelectionInterval(k, k);
				x += wrap;
			}
		} else {
			if( x>xMin && x<xMax ) {
				if (r.contains(x, y)&&path.contains(x, y))
					table.addRowSelectionInterval(k, k);
			}
		}
	}
	table.getSelectionModel().setValueIsAdjusting(false);

	int selected = table.getSelectedRow();
	if (selected != -1)
		table.ensureIndexIsVisible(selected);

	unDrawLasso();
	table.getRowHeader().setSelectedIndices(table.getSelectedRows());
	table.getRowHeader().repaint();
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:54,代碼來源:PDB.java

示例6: selectLasso

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
public void selectLasso() {
		GeneralPath path = new GeneralPath();

		for (int i=0; i<poly.npoints; i++){
			Point2D point = map.getScaledPoint(new Point(poly.xpoints[i],poly.ypoints[i]));
			if (i==0) path.moveTo((float)point.getX(), (float) point.getY());
			else path.lineTo((float)point.getX(), (float) point.getY());
		}
		path.closePath();
		r=path.getBounds();

//		Point2D p = map.getScaledPoint(new Point(r.x,r.y));
//		Rectangle2D.Double r = new Rectangle2D.Double(p.getX(),p.getY(),
//				this.r.width/map.getZoom(),this.r.height/map.getZoom()); 

		Rectangle2D rect = map.getClipRect2D();
		float yMin = (float)rect.getY();
		float yMax = (float)(rect.getY() + rect.getHeight());
		float xMin = (float)rect.getX();
		float xMax = (float)(rect.getX() + rect.getWidth());
		float wrap = (float)map.getWrap();
		//System.out.println(xMin+"\t"+xMax+"\t"+yMin+"\t"+yMax);

		dataT.getSelectionModel().setValueIsAdjusting(true);

		if (station){
			for( int k=0 ; k<tm.displayToDataIndex.size() ; k++) {
				int z = tm.displayToDataIndex.get(k);
				UnknownData d = data.get(z);

				if (f!=null&&k<f.length&&Float.isNaN(f[k])) continue;
				if (f2!=null&&k<f2.length&&Float.isNaN(f2[k])) continue;
				if (dataT.isRowSelected(k)){ continue; }
				//Symbol s = new Symbol(Symbol.CIRCLE, (float) (3./zoom), b, a);

				float x = d.x;
				float y = d.y;
				//System.out.println(d+"\t"+yMin+"\t"+yMax);
				if( y<yMin || y>yMax ) continue;
				if (Float.isNaN(d.x) || Float.isNaN(d.y)) continue;
				if( wrap>0f ) {
					while( x>xMin+wrap ) x -= wrap;
					while( x<xMin ) x += wrap;
					while( x<xMax ) {
						if (r.contains(x, y)&&path.contains(x, y))
							dataT.getSelectionModel().addSelectionInterval(k, k);
						x += wrap;
					}
				} else {
					if( x>xMin && x<xMax ) {
						if (r.contains(x, y)&&path.contains(x, y))
							dataT.getSelectionModel().addSelectionInterval(k, k);
					}
				}
			}
		}

		dataT.getSelectionModel().setValueIsAdjusting(false);

		unDrawLasso();
//		selectionChangedRedraw(os);
		if (dataT.getSelectedRow() != -1)
			dataT.ensureIndexIsVisible(dataT.getSelectedRow());
	}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:65,代碼來源:UnknownDataSet.java

示例7: getInputLineLengths

import java.awt.geom.GeneralPath; //導入方法依賴的package包/類
private static int[] getInputLineLengths(GateAttributes attrs, AbstractGate factory) {
	int inputs = attrs.inputs;
	int mainHeight = ((Integer) attrs.size.getValue()).intValue();
	Integer key = Integer.valueOf(inputs * 31 + mainHeight);
	Object ret = INPUT_LENGTHS.get(key);
	if (ret != null) {
		return (int[]) ret;
	}

	Direction facing = attrs.facing;
	if (facing != Direction.EAST) {
		attrs = (GateAttributes) attrs.clone();
		attrs.facing = Direction.EAST;
	}

	int[] lengths = new int[inputs];
	INPUT_LENGTHS.put(key, lengths);
	int width = mainHeight;
	Location loc0 = OrGate.FACTORY.getInputOffset(attrs, 0);
	Location locn = OrGate.FACTORY.getInputOffset(attrs, inputs - 1);
	int totalHeight = 10 + loc0.manhattanDistanceTo(locn);
	if (totalHeight < width)
		totalHeight = width;

	GeneralPath path = computeShield(width, totalHeight);
	for (int i = 0; i < inputs; i++) {
		Location loci = OrGate.FACTORY.getInputOffset(attrs, i);
		Point2D p = new Point2D.Float(loci.getX() + 1, loci.getY());
		int iters = 0;
		while (path.contains(p) && iters < 15) {
			iters++;
			p.setLocation(p.getX() + 1, p.getY());
		}
		if (iters >= 15)
			iters = 0;
		lengths[i] = iters;
	}

	/*
	 * used prior to 2.5.1, when moved to GeneralPath int wingHeight = (totalHeight
	 * - mainHeight) / 2; double wingCenterX = wingHeight * Math.sqrt(3) / 2; double
	 * mainCenterX = mainHeight * Math.sqrt(3) / 2;
	 * 
	 * for (int i = 0; i < inputs; i++) { Location loci =
	 * factory.getInputOffset(attrs, i); int disti = 5 +
	 * loc0.manhattanDistanceTo(loci); if (disti > totalHeight - disti) { // ensure
	 * on top half disti = totalHeight - disti; } double dx; if (disti < wingHeight)
	 * { // point is on wing int dy = wingHeight / 2 - disti; dx =
	 * Math.sqrt(wingHeight * wingHeight - dy * dy) - wingCenterX; } else { // point
	 * is on main shield int dy = totalHeight / 2 - disti; dx = Math.sqrt(mainHeight
	 * * mainHeight - dy * dy) - mainCenterX; } lengths[i] = (int) (dx - 0.5); }
	 */
	return lengths;
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:55,代碼來源:PainterShaped.java


注:本文中的java.awt.geom.GeneralPath.contains方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。