當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。