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


Java GraphicsUtil.V_TOP屬性代碼示例

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


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

示例1: computeTextField

private void computeTextField(Instance instance) {
	Object labelLoc = instance.getAttributeValue(Io.ATTR_LABEL_LOC);

	Bounds bds = instance.getBounds();
	int x = bds.getX() + bds.getWidth() / 2;
	int y = bds.getY() + bds.getHeight() / 2;
	int halign = GraphicsUtil.H_CENTER;
	int valign = GraphicsUtil.V_CENTER;
	if (labelLoc == Direction.NORTH) {
		y = bds.getY() - 2;
		valign = GraphicsUtil.V_BOTTOM;
	} else if (labelLoc == Direction.SOUTH) {
		y = bds.getY() + bds.getHeight() + 2;
		valign = GraphicsUtil.V_TOP;
	} else if (labelLoc == Direction.EAST) {
		x = bds.getX() + bds.getWidth() + 2;
		halign = GraphicsUtil.H_LEFT;
	} else if (labelLoc == Direction.WEST) {
		x = bds.getX();
		y = bds.getY() - 2;
		valign = GraphicsUtil.V_BOTTOM;
	}
	instance.setTextField(StdAttr.LABEL, StdAttr.LABEL_FONT, StdAttr.ATTR_LABEL_COLOR, x, y, halign, valign);
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:24,代碼來源:DigitalOscilloscope.java

示例2: configureLabel

private void configureLabel(Instance instance) {
	Bounds bds = instance.getBounds();
	Direction loc = instance.getAttributeValue(CircuitAttributes.LABEL_LOCATION_ATTR);

	int x = bds.getX() + bds.getWidth() / 2;
	int y = bds.getY() + bds.getHeight() / 2;
	int ha = GraphicsUtil.H_CENTER;
	int va = GraphicsUtil.V_CENTER;
	if (loc == Direction.EAST) {
		x = bds.getX() + bds.getWidth() + 2;
		ha = GraphicsUtil.H_LEFT;
	} else if (loc == Direction.WEST) {
		x = bds.getX() - 2;
		ha = GraphicsUtil.H_RIGHT;
	} else if (loc == Direction.SOUTH) {
		y = bds.getY() + bds.getHeight() + 2;
		va = GraphicsUtil.V_TOP;
	} else {
		y = bds.getY() - 2;
		va = GraphicsUtil.V_BASELINE;
	}
	instance.setTextField(StdAttr.LABEL, StdAttr.LABEL_FONT, StdAttr.ATTR_LABEL_COLOR, x, y, ha, va);
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:23,代碼來源:SubcircuitFactory.java

示例3: computeTextField

private void computeTextField(Instance instance) {
	Direction facing = instance.getAttributeValue(StdAttr.FACING);
	Object labelLoc = instance.getAttributeValue(Io.ATTR_LABEL_LOC);

	Bounds bds = instance.getBounds();
	int x = bds.getX() + bds.getWidth() / 2;
	int y = bds.getY() + bds.getHeight() / 2;
	int halign = GraphicsUtil.H_CENTER;
	int valign = GraphicsUtil.V_CENTER;
	if (labelLoc == Direction.NORTH) {
		y = bds.getY() - 2;
		valign = GraphicsUtil.V_BOTTOM;
	} else if (labelLoc == Direction.SOUTH) {
		y = bds.getY() + bds.getHeight() + 2;
		valign = GraphicsUtil.V_TOP;
	} else if (labelLoc == Direction.EAST) {
		x = bds.getX() + bds.getWidth() + 2;
		halign = GraphicsUtil.H_LEFT;
	} else if (labelLoc == Direction.WEST) {
		x = bds.getX() - 2;
		halign = GraphicsUtil.H_RIGHT;
	}
	if (labelLoc == facing) {
		if (labelLoc == Direction.NORTH || labelLoc == Direction.SOUTH) {
			x += 12;
			halign = GraphicsUtil.H_LEFT;
		} else {
			y -= 12;
			valign = GraphicsUtil.V_BOTTOM;
		}
	}

	instance.setTextField(StdAttr.LABEL, StdAttr.LABEL_FONT, StdAttr.ATTR_LABEL_COLOR, x, y, halign, valign);
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:34,代碼來源:RGBLed.java

示例4: computeTextField

private void computeTextField(Instance instance) {
	Direction facing = instance.getAttributeValue(StdAttr.FACING);
	Object labelLoc = instance.getAttributeValue(Io.ATTR_LABEL_LOC);

	Bounds bds = instance.getBounds();
	int x = bds.getX() + bds.getWidth() / 2;
	int y = bds.getY() + bds.getHeight() / 2;
	int halign = GraphicsUtil.H_CENTER;
	int valign = GraphicsUtil.V_CENTER;
	if (labelLoc == Io.LABEL_CENTER) {
		x = bds.getX() + (bds.getWidth() - DEPTH) / 2;
		y = bds.getY() + (bds.getHeight() - DEPTH) / 2;
	} else if (labelLoc == Direction.NORTH) {
		y = bds.getY() - 2;
		valign = GraphicsUtil.V_BOTTOM;
	} else if (labelLoc == Direction.SOUTH) {
		y = bds.getY() + bds.getHeight() + 2;
		valign = GraphicsUtil.V_TOP;
	} else if (labelLoc == Direction.EAST) {
		x = bds.getX() + bds.getWidth() + 2;
		halign = GraphicsUtil.H_LEFT;
	} else if (labelLoc == Direction.WEST) {
		x = bds.getX() - 2;
		halign = GraphicsUtil.H_RIGHT;
	}
	if (labelLoc == facing) {
		if (labelLoc == Direction.NORTH || labelLoc == Direction.SOUTH) {
			x += 2;
			halign = GraphicsUtil.H_LEFT;
		} else {
			y -= 2;
			valign = GraphicsUtil.V_BOTTOM;
		}
	}

	instance.setTextField(StdAttr.LABEL, StdAttr.LABEL_FONT, StdAttr.ATTR_LABEL_COLOR, x, y, halign, valign);
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:37,代碼來源:Switch.java

示例5: computeTextField

private void computeTextField(Instance instance) {
	Direction facing = instance.getAttributeValue(StdAttr.FACING);
	Object labelLoc = instance.getAttributeValue(Io.ATTR_LABEL_LOC);

	Bounds bds = instance.getBounds();
	int x = bds.getX() + bds.getWidth() / 2;
	int y = bds.getY() + bds.getHeight() / 2;
	int halign = GraphicsUtil.H_CENTER;
	int valign = GraphicsUtil.V_CENTER;
	if (labelLoc == Direction.NORTH) {
		y = bds.getY() - 2;
		valign = GraphicsUtil.V_BOTTOM;
	} else if (labelLoc == Direction.SOUTH) {
		y = bds.getY() + bds.getHeight() + 2;
		valign = GraphicsUtil.V_TOP;
	} else if (labelLoc == Direction.EAST) {
		x = bds.getX() + bds.getWidth() + 2;
		halign = GraphicsUtil.H_LEFT;
	} else if (labelLoc == Direction.WEST) {
		x = bds.getX() - 2;
		halign = GraphicsUtil.H_RIGHT;
	}
	if (labelLoc == facing) {
		if (labelLoc == Direction.NORTH || labelLoc == Direction.SOUTH) {
			x += 2;
			halign = GraphicsUtil.H_LEFT;
		} else {
			y -= 2;
			valign = GraphicsUtil.V_BOTTOM;
		}
	}

	instance.setTextField(StdAttr.LABEL, StdAttr.LABEL_FONT, StdAttr.ATTR_LABEL_COLOR, x, y, halign, valign);
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:34,代碼來源:Led.java

示例6: drawLabels

static void drawLabels(ComponentDrawContext context, SplitterAttributes attrs, Location origin) {
	// compute labels
	String[] ends = new String[attrs.fanout + 1];
	int curEnd = -1;
	int cur0 = 0;
	for (int i = 0, n = attrs.bit_end.length; i <= n; i++) {
		int bit = i == n ? -1 : attrs.bit_end[i];
		if (bit != curEnd) {
			int cur1 = i - 1;
			String toAdd;
			if (curEnd <= 0) {
				toAdd = null;
			} else if (cur0 == cur1) {
				toAdd = "" + cur0;
			} else {
				toAdd = cur0 + "-" + cur1;
			}
			if (toAdd != null) {
				String old = ends[curEnd];
				if (old == null) {
					ends[curEnd] = toAdd;
				} else {
					ends[curEnd] = old + "," + toAdd;
				}
			}
			curEnd = bit;
			cur0 = i;
		}
	}

	Graphics g = context.getGraphics().create();
	Font font = g.getFont();
	g.setFont(font.deriveFont(7.0f));

	SplitterParameters parms = attrs.getParameters();
	int x = origin.getX() + parms.getEnd0X() + parms.getEndToSpineDeltaX();
	int y = origin.getY() + parms.getEnd0Y() + parms.getEndToSpineDeltaY();
	int dx = parms.getEndToEndDeltaX();
	int dy = parms.getEndToEndDeltaY();
	if (parms.getTextAngle() != 0) {
		((Graphics2D) g).rotate(Math.PI / 2.0);
		int t;
		t = -x;
		x = y;
		y = t;
		t = -dx;
		dx = dy;
		dy = t;
	}
	int halign = parms.getTextHorzAlign();
	int valign = parms.getTextVertAlign();
	x += (halign == GraphicsUtil.H_RIGHT ? -1 : 1) * (SPINE_WIDTH / 2 + 1);
	y += valign == GraphicsUtil.V_TOP ? 0 : -3;
	for (int i = 0, n = attrs.fanout; i < n; i++) {
		String text = ends[i + 1];
		if (text != null) {
			GraphicsUtil.drawText(g, text, x, y, halign, valign);
		}
		x += dx;
		y += dy;
	}

	g.dispose();
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:64,代碼來源:SplitterPainter.java


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