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


Java GraphicsUtil.switchToWidth方法代码示例

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


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

示例1: setForStroke

import com.cburch.logisim.util.GraphicsUtil; //导入方法依赖的package包/类
protected boolean setForStroke(Graphics g) {
	List<Attribute<?>> attrs = getAttributes();
	if (attrs.contains(DrawAttr.PAINT_TYPE)) {
		Object value = getValue(DrawAttr.PAINT_TYPE);
		if (value == DrawAttr.PAINT_FILL)
			return false;
	}

	Integer width = getValue(DrawAttr.STROKE_WIDTH);
	if (width != null && width.intValue() > 0) {
		Color color = getValue(DrawAttr.STROKE_COLOR);
		if (color != null && color.getAlpha() == 0) {
			return false;
		} else {
			GraphicsUtil.switchToWidth(g, width.intValue());
			if (color != null)
				g.setColor(color);
			return true;
		}
	} else {
		return false;
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:24,代码来源:AbstractCanvasObject.java

示例2: paintInstance

import com.cburch.logisim.util.GraphicsUtil; //导入方法依赖的package包/类
@Override
public void paintInstance(InstancePainter painter) {
	Graphics g = painter.getGraphics();
	painter.drawRoundBounds(Color.WHITE);

	g.setColor(Color.GRAY);
	painter.drawPort(IN0);
	painter.drawPort(IN1);
	painter.drawPort(OUT);
	painter.drawPort(C_IN, "c in", Direction.NORTH);
	painter.drawPort(C_OUT, "c out", Direction.SOUTH);

	Location loc = painter.getLocation();
	int x = loc.getX();
	int y = loc.getY();
	GraphicsUtil.switchToWidth(g, 2);
	g.setColor(Color.BLACK);
	g.drawLine(x - 15, y - 5, x - 5, y + 5);
	g.drawLine(x - 15, y + 5, x - 5, y - 5);
	GraphicsUtil.switchToWidth(g, 1);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:22,代码来源:Multiplier.java

示例3: paintShield

import com.cburch.logisim.util.GraphicsUtil; //导入方法依赖的package包/类
private static void paintShield(Graphics g, int xlate, int width, int height) {
	GraphicsUtil.switchToWidth(g, 2);
	g.translate(xlate, 0);
	((Graphics2D) g).draw(computeShield(width, height));
	g.translate(-xlate, 0);

	/*
	 * The following, used previous to version 2.5.1, didn't use GeneralPath if
	 * (width < 40) { GraphicsUtil.drawCenteredArc(g, x - 26, y, 30, -30, 60); }
	 * else if (width < 60) { GraphicsUtil.drawCenteredArc(g, x - 43, y, 50, -30,
	 * 60); } else { GraphicsUtil.drawCenteredArc(g, x - 60, y, 70, -30, 60); } if
	 * (height > width) { // we need to draw the shield
	 * GraphicsUtil.drawCenteredArc(g, x - dx, y - (width + extra) / 2, extra, -30,
	 * 60); GraphicsUtil.drawCenteredArc(g, x - dx, y + (width + extra) / 2, extra,
	 * -30, 60); }
	 */
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:18,代码来源:PainterShaped.java

示例4: paintRectangularBase

import com.cburch.logisim.util.GraphicsUtil; //导入方法依赖的package包/类
private void paintRectangularBase(Graphics g, InstancePainter painter) {
	GraphicsUtil.switchToWidth(g, 2);
	if (painter.getAttributeValue(ATTR_SIZE) == SIZE_NARROW) {
		if (AppPreferences.FILL_COMPONENT_BACKGROUND.getBoolean()) {
			g.setColor(Color.WHITE);
			g.fillRoundRect(-20, -9, 14, 18, 5, 5);
			g.fillOval(-6, -3, 6, 6);
			g.setColor(Color.BLACK);
		}
		g.drawRoundRect(-20, -9, 14, 18, 5, 5);
		GraphicsUtil.drawCenteredText(g, RECT_LABEL, -13, -2);
		g.drawOval(-6, -3, 6, 6);
	} else {
		if (AppPreferences.FILL_COMPONENT_BACKGROUND.getBoolean()) {
			g.setColor(Color.WHITE);
			g.fillRoundRect(-30, -9, 20, 18, 10, 10);
			g.fillOval(-10, -5, 9, 9);
			g.setColor(Color.BLACK);
		}
		g.drawRoundRect(-30, -9, 20, 18, 10, 10);
		GraphicsUtil.drawCenteredText(g, RECT_LABEL, -20, -2);
		g.drawOval(-10, -5, 9, 9);
	}
	GraphicsUtil.switchToWidth(g, 1);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:26,代码来源:NotGate.java

示例5: paintShape

import com.cburch.logisim.util.GraphicsUtil; //导入方法依赖的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

示例6: paint

import com.cburch.logisim.util.GraphicsUtil; //导入方法依赖的package包/类
public void paint(Graphics g, int leftX, int topY) {
	int addrBits = getAddrBits();
	int dataBits = contents.getWidth();
	int boxX = leftX + (addrBits <= 12 ? ENTRY_XOFFS12 : ENTRY_XOFFS32);
	int boxY = topY + ENTRY_YOFFS;
	int boxW = addrBits <= 12 ? TABLE_WIDTH12 : TABLE_WIDTH32;
	int boxH = ROWS * ENTRY_HEIGHT;

	GraphicsUtil.switchToWidth(g, 1);
	g.drawRect(boxX, boxY, boxW, boxH);
	int entryWidth = boxW / columns;
	for (int row = 0; row < ROWS; row++) {
		long addr = (curScroll / columns * columns) + columns * row;
		int x = boxX;
		int y = boxY + ENTRY_HEIGHT * row;
		int yoffs = ENTRY_HEIGHT - 3;
		if (isValidAddr(addr)) {
			g.setColor(Color.GRAY);
			GraphicsUtil.drawText(g, StringUtil.toHexString(getAddrBits(), (int) addr), x - 2, y + yoffs,
					GraphicsUtil.H_RIGHT, GraphicsUtil.V_BASELINE);
		}
		g.setColor(Color.BLACK);
		for (int col = 0; col < columns && isValidAddr(addr); col++) {
			int val = contents.get(addr);
			if (addr == curAddr) {
				g.fillRect(x, y, entryWidth, ENTRY_HEIGHT);
				g.setColor(Color.WHITE);
				GraphicsUtil.drawText(g, StringUtil.toHexString(dataBits, val), x + entryWidth / 2, y + yoffs,
						GraphicsUtil.H_CENTER, GraphicsUtil.V_BASELINE);
				g.setColor(Color.BLACK);
			} else {
				GraphicsUtil.drawText(g, StringUtil.toHexString(dataBits, val), x + entryWidth / 2, y + yoffs,
						GraphicsUtil.H_CENTER, GraphicsUtil.V_BASELINE);
			}
			addr++;
			x += entryWidth;
		}
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:40,代码来源:MemState.java

示例7: paintGhost

import com.cburch.logisim.util.GraphicsUtil; //导入方法依赖的package包/类
@Override
public void paintGhost(InstancePainter painter) {
	Bounds bds = painter.getBounds();
	Graphics g = painter.getGraphics();
	GraphicsUtil.switchToWidth(g, 2);
	g.drawRoundRect(bds.getX(), bds.getY(), bds.getWidth(), bds.getHeight(), 10, 10);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:8,代码来源:DipSwitch.java

示例8: paintGhost

import com.cburch.logisim.util.GraphicsUtil; //导入方法依赖的package包/类
@Override
public void paintGhost(InstancePainter painter) {
	Graphics g = painter.getGraphics();
	Bounds bds = painter.getBounds();
	GraphicsUtil.switchToWidth(g, 2);
	g.drawOval(bds.getX() + 1, bds.getY() + 1, bds.getWidth() - 2, bds.getHeight() - 2);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:8,代码来源:Led.java

示例9: paintForeground

import com.cburch.logisim.util.GraphicsUtil; //导入方法依赖的package包/类
void paintForeground(Graphics g) {
	if (!table.isFocusOwner())
		return;
	if (cursorRow >= 0 && cursorCol >= 0) {
		int x = table.getX(cursorCol);
		int y = table.getY(cursorRow);
		GraphicsUtil.switchToWidth(g, 2);
		g.drawRect(x, y, table.getCellWidth(), table.getCellHeight());
		GraphicsUtil.switchToWidth(g, 2);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:12,代码来源:TableTabCaret.java

示例10: draw

import com.cburch.logisim.util.GraphicsUtil; //导入方法依赖的package包/类
@Override
public void draw(Canvas canvas, ComponentDrawContext context) {
	Location loc = wireLoc;
	if (loc != NULL_LOCATION && current != wiring) {
		int x = loc.getX();
		int y = loc.getY();
		Graphics g = context.getGraphics();
		g.setColor(Value.TRUE_COLOR);
		GraphicsUtil.switchToWidth(g, 2);
		g.drawOval(x - 5, y - 5, 10, 10);
		g.setColor(Color.BLACK);
		GraphicsUtil.switchToWidth(g, 1);
	}
	current.draw(canvas, context);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:16,代码来源:EditTool.java

示例11: drawBall

import com.cburch.logisim.util.GraphicsUtil; //导入方法依赖的package包/类
private static void drawBall(Graphics g, int x, int y, Color c, boolean inColor) {
	if (inColor) {
		g.setColor(c == null ? Color.RED : c);
	} else {
		int hue = c == null ? 128 : (c.getRed() + c.getGreen() + c.getBlue()) / 3;
		g.setColor(new Color(hue, hue, hue));
	}
	GraphicsUtil.switchToWidth(g, 1);
	g.fillOval(x - 4, y - 4, 8, 8);
	g.setColor(Color.BLACK);
	g.drawOval(x - 4, y - 4, 8, 8);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:13,代码来源:Joystick.java

示例12: paintGhost

import com.cburch.logisim.util.GraphicsUtil; //导入方法依赖的package包/类
@Override
public void paintGhost(InstancePainter painter) {
	int v = painter.getAttributeValue(ATTR_VALUE).intValue();
	String vStr = Integer.toHexString(v);
	Bounds bds = getOffsetBounds(painter.getAttributeSet());

	Graphics g = painter.getGraphics();
	GraphicsUtil.switchToWidth(g, 2);
	g.fillOval(-2, -2, 4, 4);
	GraphicsUtil.drawCenteredText(g, vStr, bds.getX() + bds.getWidth() / 2, bds.getY() + bds.getHeight() / 2 - 2);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:12,代码来源:Constant.java

示例13: drawInstance

import com.cburch.logisim.util.GraphicsUtil; //导入方法依赖的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

示例14: paintGhost

import com.cburch.logisim.util.GraphicsUtil; //导入方法依赖的package包/类
@Override
public void paintGhost(InstancePainter painter) {
	Graphics g = painter.getGraphics();
	GraphicsUtil.switchToWidth(g, 2);
	Bounds bds = painter.getBounds();
	g.drawRoundRect(bds.getX(), bds.getY(), bds.getWidth(), bds.getHeight(), 10, 10);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:8,代码来源:Tty.java

示例15: draw

import com.cburch.logisim.util.GraphicsUtil; //导入方法依赖的package包/类
@Override
public void draw(ComponentDrawContext context) {
	CircuitState state = context.getCircuitState();
	Graphics g = context.getGraphics();

	GraphicsUtil.switchToWidth(g, WIDTH);
	g.setColor(state.getValue(e0).getColor());
	g.drawLine(e0.getX(), e0.getY(), e1.getX(), e1.getY());
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:10,代码来源:Wire.java


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