当前位置: 首页>>代码示例>>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;未经允许,请勿转载。