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


Java HandleGesture.getHandle方法代码示例

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


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

示例1: paint

import com.cburch.draw.model.HandleGesture; //导入方法依赖的package包/类
@Override
public void paint(Graphics g, HandleGesture gesture) {
	if (setForStroke(g)) {
		int x0 = this.x0;
		int y0 = this.y0;
		int x1 = this.x1;
		int y1 = this.y1;
		Handle h = gesture.getHandle();
		if (h.isAt(x0, y0)) {
			x0 += gesture.getDeltaX();
			y0 += gesture.getDeltaY();
		}
		if (h.isAt(x1, y1)) {
			x1 += gesture.getDeltaX();
			y1 += gesture.getDeltaY();
		}
		g.drawLine(x0, y0, x1, y1);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:20,代码来源:Line.java

示例2: getHandles

import com.cburch.draw.model.HandleGesture; //导入方法依赖的package包/类
@Override
public List<Handle> getHandles(HandleGesture gesture) {
	if (gesture == null) {
		return UnmodifiableList.create(new Handle[] {
				new Handle(this, x0, y0), new Handle(this, x1, y1) });
	} else {
		Handle h = gesture.getHandle();
		int dx = gesture.getDeltaX();
		int dy = gesture.getDeltaY();
		Handle[] ret = new Handle[2];
		ret[0] = new Handle(this, h.isAt(x0, y0) ? Location.create(x0 + dx,
				y0 + dy) : Location.create(x0, y0));
		ret[1] = new Handle(this, h.isAt(x1, y1) ? Location.create(x1 + dx,
				y1 + dy) : Location.create(x1, y1));
		return UnmodifiableList.create(ret);
	}
}
 
开发者ID:reds-heig,项目名称:logisim-evolution,代码行数:18,代码来源:Line.java

示例3: moveHandle

import com.cburch.draw.model.HandleGesture; //导入方法依赖的package包/类
@Override
public Handle moveHandle(HandleGesture gesture) {
	Handle[] oldHandles = getHandleArray(null);
	Handle[] newHandles = getHandleArray(gesture);
	Handle moved = gesture == null ? null : gesture.getHandle();
	Handle result = null;
	int x0 = Integer.MAX_VALUE;
	int x1 = Integer.MIN_VALUE;
	int y0 = Integer.MAX_VALUE;
	int y1 = Integer.MIN_VALUE;
	int i = -1;
	for (Handle h : newHandles) {
		i++;
		if (oldHandles[i].equals(moved)) {
			result = h;
		}
		int hx = h.getX();
		int hy = h.getY();
		if (hx < x0) x0 = hx;
		if (hx > x1) x1 = hx;
		if (hy < y0) y0 = hy;
		if (hy > y1) y1 = hy;
	}
	bounds = Bounds.create(x0, y0, x1 - x0, y1 - y0);
	return result;
}
 
开发者ID:franciscaconcha,项目名称:ProyectoLogisim,代码行数:27,代码来源:Rectangular.java

示例4: getHandles

import com.cburch.draw.model.HandleGesture; //导入方法依赖的package包/类
@Override
public List<Handle> getHandles(HandleGesture gesture) {
	if (gesture == null) {
		return UnmodifiableList.create(new Handle[] {
				new Handle(this, x0, y0), new Handle(this, x1, y1) });
	} else {
		Handle h = gesture.getHandle();
		int dx = gesture.getDeltaX();
		int dy = gesture.getDeltaY();
		Handle[] ret = new Handle[2];
		ret[0] = new Handle(this, h.isAt(x0, y0)
				? Location.create(x0 + dx, y0 + dy) : Location.create(x0, y0));
		ret[1] = new Handle(this, h.isAt(x1, y1)
				? Location.create(x1 + dx, y1 + dy) : Location.create(x1, y1));
		return UnmodifiableList.create(ret);
	}
}
 
开发者ID:franciscaconcha,项目名称:ProyectoLogisim,代码行数:18,代码来源:Line.java

示例5: moveHandle

import com.cburch.draw.model.HandleGesture; //导入方法依赖的package包/类
@Override
public Handle moveHandle(HandleGesture gesture) {
	Handle[] oldHandles = getHandleArray(null);
	Handle[] newHandles = getHandleArray(gesture);
	Handle moved = gesture == null ? null : gesture.getHandle();
	Handle result = null;
	int x0 = Integer.MAX_VALUE;
	int x1 = Integer.MIN_VALUE;
	int y0 = Integer.MAX_VALUE;
	int y1 = Integer.MIN_VALUE;
	int i = -1;
	for (Handle h : newHandles) {
		i++;
		if (oldHandles[i].equals(moved)) {
			result = h;
		}
		int hx = h.getX();
		int hy = h.getY();
		if (hx < x0)
			x0 = hx;
		if (hx > x1)
			x1 = hx;
		if (hy < y0)
			y0 = hy;
		if (hy > y1)
			y1 = hy;
	}
	bounds = Bounds.create(x0, y0, x1 - x0, y1 - y0);
	return result;
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:31,代码来源:Rectangular.java

示例6: getHandles

import com.cburch.draw.model.HandleGesture; //导入方法依赖的package包/类
@Override
public List<Handle> getHandles(HandleGesture gesture) {
	if (gesture == null) {
		return UnmodifiableList.create(new Handle[] { new Handle(this, x0, y0), new Handle(this, x1, y1) });
	} else {
		Handle h = gesture.getHandle();
		int dx = gesture.getDeltaX();
		int dy = gesture.getDeltaY();
		Handle[] ret = new Handle[2];
		ret[0] = new Handle(this, h.isAt(x0, y0) ? Location.create(x0 + dx, y0 + dy) : Location.create(x0, y0));
		ret[1] = new Handle(this, h.isAt(x1, y1) ? Location.create(x1 + dx, y1 + dy) : Location.create(x1, y1));
		return UnmodifiableList.create(ret);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:15,代码来源:Line.java

示例7: setHandleGesture

import com.cburch.draw.model.HandleGesture; //导入方法依赖的package包/类
public void setHandleGesture(HandleGesture gesture) {
	HandleGesture g = curHandleGesture;
	if (g != null)
		suppressed.remove(g.getHandle().getObject());

	Handle h = gesture.getHandle();
	suppressed.put(h.getObject(), MOVING_HANDLE);
	curHandleGesture = gesture;
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:10,代码来源:Selection.java

示例8: setHandleGesture

import com.cburch.draw.model.HandleGesture; //导入方法依赖的package包/类
public void setHandleGesture(HandleGesture gesture) {
	HandleGesture g = curHandleGesture;
	if (g != null) suppressed.remove(g.getHandle().getObject());
	
	Handle h = gesture.getHandle();
	suppressed.put(h.getObject(), MOVING_HANDLE);
	curHandleGesture = gesture;
}
 
开发者ID:franciscaconcha,项目名称:ProyectoLogisim,代码行数:9,代码来源:Selection.java

示例9: getHandles

import com.cburch.draw.model.HandleGesture; //导入方法依赖的package包/类
@Override
public List<Handle> getHandles(HandleGesture gesture) {
	Handle[] hs = handles;
	if (gesture == null) {
		return UnmodifiableList.create(hs);
	} else {
		Handle g = gesture.getHandle();
		Handle[] ret = new Handle[hs.length];
		for (int i = 0, n = hs.length; i < n; i++) {
			Handle h = hs[i];
			if (h.equals(g)) {
				int x = h.getX() + gesture.getDeltaX();
				int y = h.getY() + gesture.getDeltaY();
				Location r;
				if (gesture.isShiftDown()) {
					Location prev = hs[(i + n - 1) % n].getLocation();
					Location next = hs[(i + 1) % n].getLocation();
					if (!closed) {
						if (i == 0)
							prev = null;
						if (i == n - 1)
							next = null;
					}
					if (prev == null) {
						r = LineUtil.snapTo8Cardinals(next, x, y);
					} else if (next == null) {
						r = LineUtil.snapTo8Cardinals(prev, x, y);
					} else {
						Location to = Location.create(x, y);
						Location a = LineUtil.snapTo8Cardinals(prev, x, y);
						Location b = LineUtil.snapTo8Cardinals(next, x, y);
						int ad = a.manhattanDistanceTo(to);
						int bd = b.manhattanDistanceTo(to);
						r = ad < bd ? a : b;
					}
				} else {
					r = Location.create(x, y);
				}
				ret[i] = new Handle(this, r);
			} else {
				ret[i] = h;
			}
		}
		return UnmodifiableList.create(ret);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:47,代码来源:Poly.java

示例10: getHandles

import com.cburch.draw.model.HandleGesture; //导入方法依赖的package包/类
@Override
public List<Handle> getHandles(HandleGesture gesture) {
	Handle[] hs = handles;
	if (gesture == null) {
		return UnmodifiableList.create(hs);
	} else {
		Handle g = gesture.getHandle();
		Handle[] ret = new Handle[hs.length];
		for (int i = 0, n = hs.length; i < n; i++) {
			Handle h = hs[i];
			if (h.equals(g)) {
				int x = h.getX() + gesture.getDeltaX();
				int y = h.getY() + gesture.getDeltaY();
				Location r;
				if (gesture.isShiftDown()) {
					Location prev = hs[(i + n - 1) % n].getLocation();
					Location next = hs[(i + 1) % n].getLocation();
					if (!closed) {
						if (i == 0) prev = null;
						if (i == n - 1) next = null;
					}
					if (prev == null) {
						r = LineUtil.snapTo8Cardinals(next, x, y);
					} else if (next == null) {
						r = LineUtil.snapTo8Cardinals(prev, x, y);
					} else {
						Location to = Location.create(x, y);
						Location a = LineUtil.snapTo8Cardinals(prev, x, y);
						Location b = LineUtil.snapTo8Cardinals(next, x, y);
						int ad = a.manhattanDistanceTo(to);
						int bd = b.manhattanDistanceTo(to);
						r = ad < bd ? a : b;
					}
				} else {
					r = Location.create(x, y);
				}
				ret[i] = new Handle(this, r);
			} else {
				ret[i] = h;
			}
		}
		return UnmodifiableList.create(ret);
	}
}
 
开发者ID:franciscaconcha,项目名称:ProyectoLogisim,代码行数:45,代码来源:Poly.java


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