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


Java Direction.toDegrees方法代碼示例

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


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

示例1: drawInstance

import com.cburch.logisim.data.Direction; //導入方法依賴的package包/類
private void drawInstance(InstancePainter painter, boolean isGhost) {
	Graphics2D g = (Graphics2D) painter.getGraphics().create();
	Location loc = painter.getLocation();
	g.translate(loc.getX(), loc.getY());

	Direction from = painter.getAttributeValue(StdAttr.FACING);
	int degrees = Direction.EAST.toDegrees() - from.toDegrees();
	double radians = Math.toRadians((degrees + 360) % 360);
	g.rotate(radians);

	GraphicsUtil.switchToWidth(g, Wire.WIDTH);
	if (!isGhost && painter.getShowState()) {
		g.setColor(painter.getPort(0).getColor());
	}
	g.drawLine(0, 0, 5, 0);

	GraphicsUtil.switchToWidth(g, 1);
	if (!isGhost && painter.shouldDrawColor()) {
		BitWidth width = painter.getAttributeValue(StdAttr.WIDTH);
		g.setColor(Value.repeat(Value.TRUE, width.getWidth()).getColor());
	}
	g.drawPolygon(new int[] { 6, 14, 6 }, new int[] { -8, 0, 8 }, 3);

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

示例2: drawInstance

import com.cburch.logisim.data.Direction; //導入方法依賴的package包/類
private void drawInstance(InstancePainter painter, boolean isGhost) {
	Graphics2D g = (Graphics2D) painter.getGraphics().create();
	Location loc = painter.getLocation();
	g.translate(loc.getX(), loc.getY());

	Direction from = painter.getAttributeValue(StdAttr.FACING);
	int degrees = Direction.EAST.toDegrees() - from.toDegrees();
	double radians = Math.toRadians((degrees + 360) % 360);
	g.rotate(radians);

	GraphicsUtil.switchToWidth(g, Wire.WIDTH);
	if (!isGhost && painter.getShowState()) {
		g.setColor(painter.getPort(0).getColor());
	}
	g.drawLine(0, 0, 5, 0);

	GraphicsUtil.switchToWidth(g, 1);
	if (!isGhost && painter.shouldDrawColor()) {
		BitWidth width = painter.getAttributeValue(StdAttr.WIDTH);
		g.setColor(Value.repeat(Value.FALSE, width.getWidth()).getColor());
	}
	g.drawLine(6, -8, 6, 8);
	g.drawLine(9, -5, 9, 5);
	g.drawLine(12, -2, 12, 2);

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

示例3: drawInstance

import com.cburch.logisim.data.Direction; //導入方法依賴的package包/類
private void drawInstance(InstancePainter painter, boolean isGhost) {
	Bounds bds = painter.getBounds();
	Object powerLoc = painter.getAttributeValue(Wiring.ATTR_GATE);
	Direction facing = painter.getAttributeValue(StdAttr.FACING);
	boolean flip = (facing == Direction.SOUTH || facing == Direction.WEST) == (powerLoc == Wiring.GATE_TOP_LEFT);

	int degrees = Direction.WEST.toDegrees() - facing.toDegrees();
	if (flip)
		degrees += 180;
	double radians = Math.toRadians((degrees + 360) % 360);

	Graphics2D g = (Graphics2D) painter.getGraphics().create();
	g.rotate(radians, bds.getX() + 20, bds.getY() + 20);
	g.translate(bds.getX(), bds.getY());
	GraphicsUtil.switchToWidth(g, Wire.WIDTH);

	Color gate0 = g.getColor();
	Color gate1 = gate0;
	Color input = gate0;
	Color output = gate0;
	Color platform = gate0;
	if (!isGhost && painter.getShowState()) {
		gate0 = painter.getPort(GATE0).getColor();
		gate1 = painter.getPort(GATE0).getColor();
		input = painter.getPort(INPUT).getColor();
		output = painter.getPort(OUTPUT).getColor();
		platform = computeOutput(painter).getColor();
	}

	g.setColor(flip ? input : output);
	g.drawLine(0, 20, 11, 20);
	g.drawLine(11, 13, 11, 27);

	g.setColor(flip ? output : input);
	g.drawLine(29, 20, 40, 20);
	g.drawLine(29, 13, 29, 27);

	g.setColor(gate0);
	g.drawLine(20, 35, 20, 40);
	GraphicsUtil.switchToWidth(g, 1);
	g.drawOval(18, 30, 4, 4);
	g.drawLine(10, 30, 30, 30);
	GraphicsUtil.switchToWidth(g, Wire.WIDTH);

	g.setColor(gate1);
	g.drawLine(20, 9, 20, 0);
	GraphicsUtil.switchToWidth(g, 1);
	g.drawLine(10, 10, 30, 10);

	g.setColor(platform);
	g.drawLine(9, 12, 31, 12);
	g.drawLine(9, 28, 31, 28);
	if (flip) { // arrow
		g.drawLine(18, 17, 21, 20);
		g.drawLine(18, 23, 21, 20);
	} else {
		g.drawLine(22, 17, 19, 20);
		g.drawLine(22, 23, 19, 20);
	}

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

示例4: drawInstance

import com.cburch.logisim.data.Direction; //導入方法依賴的package包/類
private void drawInstance(InstancePainter painter, boolean isGhost) {
	Object type = painter.getAttributeValue(ATTR_TYPE);
	Object powerLoc = painter.getAttributeValue(Wiring.ATTR_GATE);
	Direction from = painter.getAttributeValue(StdAttr.FACING);
	Direction facing = painter.getAttributeValue(StdAttr.FACING);
	boolean flip = (facing == Direction.SOUTH || facing == Direction.WEST) == (powerLoc == Wiring.GATE_TOP_LEFT);

	int degrees = Direction.EAST.toDegrees() - from.toDegrees();
	double radians = Math.toRadians((degrees + 360) % 360);
	int m = flip ? 1 : -1;

	Graphics2D g = (Graphics2D) painter.getGraphics();
	Location loc = painter.getLocation();
	g.translate(loc.getX(), loc.getY());
	g.rotate(radians);

	Color gate;
	Color input;
	Color output;
	Color platform;
	if (!isGhost && painter.getShowState()) {
		gate = painter.getPort(GATE).getColor();
		input = painter.getPort(INPUT).getColor();
		output = painter.getPort(OUTPUT).getColor();
		Value out = computeOutput(painter);
		platform = out.isUnknown() ? Value.UNKNOWN.getColor() : out.getColor();
	} else {
		Color base = g.getColor();
		gate = base;
		input = base;
		output = base;
		platform = base;
	}

	// input and output lines
	GraphicsUtil.switchToWidth(g, Wire.WIDTH);
	g.setColor(output);
	g.drawLine(0, 0, -11, 0);
	g.drawLine(-11, m * 7, -11, 0);

	g.setColor(input);
	g.drawLine(-40, 0, -29, 0);
	g.drawLine(-29, m * 7, -29, 0);

	// gate line
	g.setColor(gate);
	if (type == TYPE_P) {
		g.drawLine(-20, m * 20, -20, m * 15);
		GraphicsUtil.switchToWidth(g, 1);
		g.drawOval(-22, m * 12 - 2, 4, 4);
	} else {
		g.drawLine(-20, m * 20, -20, m * 11);
		GraphicsUtil.switchToWidth(g, 1);
	}

	// draw platforms
	g.drawLine(-10, m * 10, -30, m * 10); // gate platform
	g.setColor(platform);
	g.drawLine(-9, m * 8, -31, m * 8); // input/output platform

	// arrow (same color as platform)
	g.drawLine(-21, m * 6, -18, m * 3);
	g.drawLine(-21, 0, -18, m * 3);

	g.rotate(-radians);
	g.translate(-loc.getX(), -loc.getY());
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:68,代碼來源:Transistor.java


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