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