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


Java RadixOption.RADIX_2属性代码示例

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


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

示例1: draw

@Override
public void draw(Graphics g) {
	Value v = canvas.getCircuitState().getValue(wire.getEnd0());
	RadixOption radix1 = RadixOption.decode(AppPreferences.POKE_WIRE_RADIX1.get());
	RadixOption radix2 = RadixOption.decode(AppPreferences.POKE_WIRE_RADIX2.get());
	if (radix1 == null)
		radix1 = RadixOption.RADIX_2;
	String vStr = radix1.toString(v);
	if (radix2 != null && v.getWidth() > 1) {
		vStr += " / " + radix2.toString(v);
	}

	FontMetrics fm = g.getFontMetrics();
	g.setColor(caretColor);
	g.fillRect(x + 2, y + 2, fm.stringWidth(vStr) + 4, fm.getAscent() + fm.getDescent() + 4);
	g.setColor(Color.BLACK);
	g.drawRect(x + 2, y + 2, fm.stringWidth(vStr) + 4, fm.getAscent() + fm.getDescent() + 4);
	g.fillOval(x - 2, y - 2, 5, 5);
	g.drawString(vStr, x + 4, y + 4 + fm.getAscent());
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:20,代码来源:PokeTool.java

示例2: mouseReleased

@Override
public void mouseReleased(InstanceState state, MouseEvent e) {
	if (state.getAttributeValue(RadixOption.ATTRIBUTE) == RadixOption.RADIX_2) {
		int bit = getBit(state, e);
		if (bit == bitPressed && bit >= 0) {
			handleBitPress(state, bit, e);
		}
		bitPressed = -1;
	} else {
		PinState pinState = getState(state);
		EditText dialog = new EditText(pinState.intendedValue,
				state.getAttributeValue(RadixOption.ATTRIBUTE),
				pinState.intendedValue.getWidth());
		dialog.setLocation(e.getXOnScreen(), e.getYOnScreen());
		dialog.setVisible(true);
		// System.err.println("New Value: '" + dialog.getValue() + "'");
		pinState.intendedValue = dialog.getValue();
		state.fireInvalidated();
	}
}
 
开发者ID:reds-heig,项目名称:logisim-evolution,代码行数:20,代码来源:Pin.java

示例3: draw

@Override
public void draw(Graphics g) {
	Value v = canvas.getCircuitState().getValue(wire.getEnd0());
	RadixOption radix1 = RadixOption
			.decode(AppPreferences.POKE_WIRE_RADIX1.get());
	RadixOption radix2 = RadixOption
			.decode(AppPreferences.POKE_WIRE_RADIX2.get());
	if (radix1 == null)
		radix1 = RadixOption.RADIX_2;
	String vStr = radix1.toString(v);
	if (radix2 != null && v.getWidth() > 1) {
		vStr += " / " + radix2.toString(v);
	}

	FontMetrics fm = g.getFontMetrics();
	g.setColor(caretColor);
	g.fillRect(x + 2, y + 2, fm.stringWidth(vStr) + 4, fm.getAscent()
			+ fm.getDescent() + 4);
	g.setColor(Color.BLACK);
	g.drawRect(x + 2, y + 2, fm.stringWidth(vStr) + 4, fm.getAscent()
			+ fm.getDescent() + 4);
	g.fillOval(x - 2, y - 2, 5, 5);
	g.drawString(vStr, x + 4, y + 4 + fm.getAscent());
}
 
开发者ID:reds-heig,项目名称:logisim-evolution,代码行数:24,代码来源:PokeTool.java

示例4: draw

@Override
public void draw(Graphics g) {
	Value v = canvas.getCircuitState().getValue(wire.getEnd0());
	RadixOption radix1 = RadixOption.decode(AppPreferences.POKE_WIRE_RADIX1.get());
	RadixOption radix2 = RadixOption.decode(AppPreferences.POKE_WIRE_RADIX2.get());
	if (radix1 == null) radix1 = RadixOption.RADIX_2;
	String vStr = radix1.toString(v);
	if (radix2 != null && v.getWidth() > 1) {
		vStr += " / " + radix2.toString(v);
	}
	
	FontMetrics fm = g.getFontMetrics();
	g.setColor(caretColor);
	g.fillRect(x + 2, y + 2, fm.stringWidth(vStr) + 4, 
			fm.getAscent() + fm.getDescent() + 4);
	g.setColor(Color.BLACK);
	g.drawRect(x + 2, y + 2, fm.stringWidth(vStr) + 4, 
			fm.getAscent() + fm.getDescent() + 4);
	g.fillOval(x - 2, y - 2, 5, 5);
	g.drawString(vStr, x + 4, y + 4 + fm.getAscent());
}
 
开发者ID:franciscaconcha,项目名称:ProyectoLogisim,代码行数:21,代码来源:PokeTool.java

示例5: paintValue

static void paintValue(InstancePainter painter, Value value) {
	Graphics g = painter.getGraphics();
	Bounds bds = painter.getBounds(); // intentionally with no graphics
										// object - we don't want label
										// included

	RadixOption radix = painter.getAttributeValue(RadixOption.ATTRIBUTE);
	if (radix == null || radix == RadixOption.RADIX_2) {
		int x = bds.getX();
		int y = bds.getY();
		int wid = value.getWidth();
		if (wid == 0) {
			x += bds.getWidth() / 2;
			y += bds.getHeight() / 2;
			GraphicsUtil.switchToWidth(g, 2);
			g.drawLine(x - 4, y, x + 4, y);
			return;
		}
		int x0 = bds.getX() + bds.getWidth() - 5;
		int compWidth = wid * 10;
		if (compWidth < bds.getWidth() - 3) {
			x0 = bds.getX() + (bds.getWidth() + compWidth) / 2 - 5;
		}
		int cx = x0;
		int cy = bds.getY() + bds.getHeight() - 12;
		int cur = 0;
		for (int k = 0; k < wid; k++) {
			GraphicsUtil.drawCenteredText(g, value.get(k).toDisplayString(), cx, cy);
			++cur;
			if (cur == 8) {
				cur = 0;
				cx = x0;
				cy -= 20;
			} else {
				cx -= 10;
			}
		}
	} else {
		String text = radix.toString(value);
		GraphicsUtil.drawCenteredText(g, text, bds.getX() + bds.getWidth() / 2, bds.getY() + bds.getHeight() / 2);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:42,代码来源:Probe.java

示例6: paintValue

static void paintValue(InstancePainter painter, Value value) {
	Graphics g = painter.getGraphics();
	Bounds bds = painter.getBounds(); // intentionally with no graphics
										// object - we don't want label
										// included

	RadixOption radix = painter.getAttributeValue(RadixOption.ATTRIBUTE);
	if (radix == null || radix == RadixOption.RADIX_2) {
		int x = bds.getX();
		int y = bds.getY();
		int wid = value.getWidth();
		if (wid == 0) {
			x += bds.getWidth() / 2;
			y += bds.getHeight() / 2;
			GraphicsUtil.switchToWidth(g, 2);
			g.drawLine(x - 4, y, x + 4, y);
			return;
		}
		int x0 = bds.getX() + bds.getWidth() - 5;
		int compWidth = wid * 10;
		if (compWidth < bds.getWidth() - 3) {
			x0 = bds.getX() + (bds.getWidth() + compWidth) / 2 - 5;
		}
		int cx = x0;
		int cy = bds.getY() + bds.getHeight() - 12;
		int cur = 0;
		for (int k = 0; k < wid; k++) {
			GraphicsUtil.drawCenteredText(g,
					value.get(k).toDisplayString(), cx, cy);
			++cur;
			if (cur == 8) {
				cur = 0;
				cx = x0;
				cy -= 20;
			} else {
				cx -= 10;
			}
		}
	} else {
		String text = radix.toString(value);
		GraphicsUtil.drawCenteredText(g, text, bds.getX() + bds.getWidth()
				/ 2, bds.getY() + bds.getHeight() / 2);
	}
}
 
开发者ID:reds-heig,项目名称:logisim-evolution,代码行数:44,代码来源:Probe.java

示例7: paintValue

static void paintValue(InstancePainter painter, Value value) {
	Graphics g = painter.getGraphics();
	Bounds bds = painter.getBounds(); // intentionally with no graphics object - we don't want label included

	RadixOption radix = painter.getAttributeValue(RadixOption.ATTRIBUTE);
	if (radix == null || radix == RadixOption.RADIX_2) {
		int x = bds.getX();
		int y = bds.getY();
		int wid = value.getWidth();
		if (wid == 0) {
			x += bds.getWidth() / 2;
			y += bds.getHeight() / 2;
			GraphicsUtil.switchToWidth(g, 2);
			g.drawLine(x - 4, y, x + 4, y);
			return;
		}
		int x0 = bds.getX() + bds.getWidth() - 5;
		int compWidth = wid * 10;
		if (compWidth < bds.getWidth() - 3) {
			x0 = bds.getX() + (bds.getWidth() + compWidth) / 2 - 5;
		}
		int cx = x0;
		int cy = bds.getY() + bds.getHeight() - 12;
		int cur = 0;
		for (int k = 0; k < wid; k++) {
			GraphicsUtil.drawCenteredText(g,
				value.get(k).toDisplayString(), cx, cy);
			++cur;
			if (cur == 8) {
				cur = 0;
				cx = x0;
				cy -= 20;
			} else {
				cx -= 10;
			}
		}
	} else {
		String text = radix.toString(value);
		GraphicsUtil.drawCenteredText(g, text,
				bds.getX() + bds.getWidth() / 2,
				bds.getY() + bds.getHeight() / 2);
	}
}
 
开发者ID:franciscaconcha,项目名称:ProyectoLogisim,代码行数:43,代码来源:Probe.java


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