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


Java Direction.toRadians方法代码示例

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


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

示例1: paintSubcircuit

import com.cburch.logisim.data.Direction; //导入方法依赖的package包/类
public void paintSubcircuit(Graphics g, Direction facing) {
	Direction defaultFacing = getFacing();
	double rotate = 0.0;
	if (facing != defaultFacing && g instanceof Graphics2D) {
		rotate = defaultFacing.toRadians() - facing.toRadians();
		((Graphics2D) g).rotate(rotate);
	}
	Location offset = findAnchorLocation();
	g.translate(-offset.getX(), -offset.getY());
	for (CanvasObject shape : getObjectsFromBottom()) {
		if (!(shape instanceof AppearanceElement)) {
			Graphics dup = g.create();
			shape.paint(dup, null);
			dup.dispose();
		}
	}
	g.translate(offset.getX(), offset.getY());
	if (rotate != 0.0) {
		((Graphics2D) g).rotate(-rotate);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:22,代码来源:CircuitAppearance.java

示例2: paintShape

import com.cburch.logisim.data.Direction; //导入方法依赖的package包/类
private void paintShape(InstancePainter painter) {
	Direction facing = painter.getAttributeValue(StdAttr.FACING);
	Location loc = painter.getLocation();
	int x = loc.getX();
	int y = loc.getY();
	double rotate = 0.0;
	Graphics g = painter.getGraphics();
	g.translate(x, y);
	if (facing != Direction.EAST && g instanceof Graphics2D) {
		rotate = -facing.toRadians();
		((Graphics2D) g).rotate(rotate);
	}

	if (isInverter) {
		PainterShaped.paintNot(painter);
	} else {
		GraphicsUtil.switchToWidth(g, 2);
		int d = isInverter ? 10 : 0;
		int[] xp = new int[] { -d, -19 - d, -19 - d, -d };
		int[] yp = new int[] { 0, -7, 7, 0 };
		g.drawPolyline(xp, yp, 4);
		// if (isInverter) g.drawOval(-9, -4, 9, 9);
	}

	if (rotate != 0.0) {
		((Graphics2D) g).rotate(-rotate);
	}
	g.translate(-x, -y);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:30,代码来源:ControlledBuffer.java

示例3: paintBase

import com.cburch.logisim.data.Direction; //导入方法依赖的package包/类
private void paintBase(InstancePainter painter) {
	Direction facing = painter.getAttributeValue(StdAttr.FACING);
	Location loc = painter.getLocation();
	int x = loc.getX();
	int y = loc.getY();
	Graphics g = painter.getGraphics();
	g.translate(x, y);
	double rotate = 0.0;
	if (facing != Direction.EAST && g instanceof Graphics2D) {
		rotate = -facing.toRadians();
		((Graphics2D) g).rotate(rotate);
	}

	GraphicsUtil.switchToWidth(g, 2);
	int[] xp = new int[4];
	int[] yp = new int[4];
	xp[0] = 0;
	yp[0] = 0;
	xp[1] = -19;
	yp[1] = -7;
	xp[2] = -19;
	yp[2] = 7;
	xp[3] = 0;
	yp[3] = 0;
	g.drawPolyline(xp, yp, 4);

	if (rotate != 0.0) {
		((Graphics2D) g).rotate(-rotate);
	}
	g.translate(-x, -y);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:32,代码来源:Buffer.java

示例4: paintBase

import com.cburch.logisim.data.Direction; //导入方法依赖的package包/类
private void paintBase(InstancePainter painter) {
	Graphics g = painter.getGraphics();
	Direction facing = painter.getAttributeValue(StdAttr.FACING);
	Location loc = painter.getLocation();
	int x = loc.getX();
	int y = loc.getY();
	g.translate(x, y);
	double rotate = 0.0;
	if (facing != null && facing != Direction.EAST && g instanceof Graphics2D) {
		rotate = -facing.toRadians();
		((Graphics2D) g).rotate(rotate);
	}

	Object shape = painter.getGateShape();
	if (shape == AppPreferences.SHAPE_RECTANGULAR) {
		paintRectangularBase(g, painter);
	} else if (shape == AppPreferences.SHAPE_DIN40700) {
		int width = painter.getAttributeValue(ATTR_SIZE) == SIZE_NARROW ? 20 : 30;
		PainterDin.paintAnd(painter, width, 18, true);
	} else {
		PainterShaped.paintNot(painter);
	}

	if (rotate != 0.0) {
		((Graphics2D) g).rotate(-rotate);
	}
	g.translate(-x, -y);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:29,代码来源:NotGate.java

示例5: paintBase

import com.cburch.logisim.data.Direction; //导入方法依赖的package包/类
private void paintBase(InstancePainter painter, Value pullValue, Color inColor, Color outColor) {
	boolean color = painter.shouldDrawColor();
	Direction facing = painter.getAttributeValue(StdAttr.FACING);
	Graphics g = painter.getGraphics();
	Color baseColor = g.getColor();
	GraphicsUtil.switchToWidth(g, 3);
	if (color && inColor != null)
		g.setColor(inColor);
	if (facing == Direction.EAST) {
		GraphicsUtil.drawText(g, pullValue.toDisplayString(), -32, 0, GraphicsUtil.H_RIGHT, GraphicsUtil.V_CENTER);
	} else if (facing == Direction.WEST) {
		GraphicsUtil.drawText(g, pullValue.toDisplayString(), 32, 0, GraphicsUtil.H_LEFT, GraphicsUtil.V_CENTER);
	} else if (facing == Direction.NORTH) {
		GraphicsUtil.drawText(g, pullValue.toDisplayString(), 0, 32, GraphicsUtil.H_CENTER, GraphicsUtil.V_TOP);
	} else {
		GraphicsUtil.drawText(g, pullValue.toDisplayString(), 0, -32, GraphicsUtil.H_CENTER,
				GraphicsUtil.V_BASELINE);
	}

	double rotate = 0.0;
	if (g instanceof Graphics2D) {
		rotate = Direction.SOUTH.toRadians() - facing.toRadians();
		if (rotate != 0.0)
			((Graphics2D) g).rotate(rotate);
	}
	g.drawLine(0, -30, 0, -26);
	g.drawLine(-6, -30, 6, -30);
	if (color && outColor != null)
		g.setColor(outColor);
	g.drawLine(0, -4, 0, 0);
	g.setColor(baseColor);
	GraphicsUtil.switchToWidth(g, 2);
	if (painter.getGateShape() == AppPreferences.SHAPE_SHAPED) {
		int[] xp = { 0, -5, 5, -5, 5, -5, 0 };
		int[] yp = { -25, -23, -19, -15, -11, -7, -5 };
		g.drawPolyline(xp, yp, xp.length);
	} else {
		g.drawRect(-5, -25, 10, 20);
	}
	if (rotate != 0.0) {
		((Graphics2D) g).rotate(-rotate);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:44,代码来源:PullResistor.java

示例6: paintBase

import com.cburch.logisim.data.Direction; //导入方法依赖的package包/类
private void paintBase(InstancePainter painter) {
	GateAttributes attrs = (GateAttributes) painter.getAttributeSet();
	Direction facing = attrs.facing;
	int inputs = attrs.inputs;
	int negated = attrs.negated;

	Object shape = painter.getGateShape();
	Location loc = painter.getLocation();
	Bounds bds = painter.getOffsetBounds();
	int width = bds.getWidth();
	int height = bds.getHeight();
	if (facing == Direction.NORTH || facing == Direction.SOUTH) {
		int t = width;
		width = height;
		height = t;
	}
	if (negated != 0) {
		width -= 10;
	}

	Graphics g = painter.getGraphics();
	Color baseColor = g.getColor();
	if (shape == AppPreferences.SHAPE_SHAPED && paintInputLines) {
		PainterShaped.paintInputLines(painter, this);
	} else if (negated != 0) {
		for (int i = 0; i < inputs; i++) {
			int negatedBit = (negated >> i) & 1;
			if (negatedBit == 1) {
				Location in = getInputOffset(attrs, i);
				Location cen = in.translate(facing, 5);
				painter.drawDongle(loc.getX() + cen.getX(), loc.getY() + cen.getY());
			}
		}
	}

	g.setColor(baseColor);
	g.translate(loc.getX(), loc.getY());
	double rotate = 0.0;
	if (facing != Direction.EAST && g instanceof Graphics2D) {
		rotate = -facing.toRadians();
		Graphics2D g2 = (Graphics2D) g;
		g2.rotate(rotate);
	}

	if (shape == AppPreferences.SHAPE_RECTANGULAR) {
		paintRectangular(painter, width, height);
	} else if (shape == AppPreferences.SHAPE_DIN40700) {
		paintDinShape(painter, width, height, inputs);
	} else { // SHAPE_SHAPED
		if (negateOutput) {
			g.translate(-10, 0);
			paintShape(painter, width - 10, height);
			painter.drawDongle(5, 0);
			g.translate(10, 0);
		} else {
			paintShape(painter, width, height);
		}
	}

	if (rotate != 0.0) {
		((Graphics2D) g).rotate(-rotate);
	}
	g.translate(-loc.getX(), -loc.getY());
	painter.drawLabel();
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:66,代码来源:AbstractGate.java


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