當前位置: 首頁>>代碼示例>>Java>>正文


Java InstanceDataSingleton.getValue方法代碼示例

本文整理匯總了Java中com.cburch.logisim.instance.InstanceDataSingleton.getValue方法的典型用法代碼示例。如果您正苦於以下問題:Java InstanceDataSingleton.getValue方法的具體用法?Java InstanceDataSingleton.getValue怎麽用?Java InstanceDataSingleton.getValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.cburch.logisim.instance.InstanceDataSingleton的用法示例。


在下文中一共展示了InstanceDataSingleton.getValue方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: paintInstance

import com.cburch.logisim.instance.InstanceDataSingleton; //導入方法依賴的package包/類
@Override
public void paintInstance(InstancePainter painter) {
	InstanceDataSingleton data = (InstanceDataSingleton) painter.getData();
	Value val = data == null ? Value.FALSE : (Value) data.getValue();
	Bounds bds = painter.getBounds().expand(-1);

	Graphics g = painter.getGraphics();
	if (painter.getShowState()) {
		Color onColor = painter.getAttributeValue(Io.ATTR_ON_COLOR);
		Color offColor = painter.getAttributeValue(Io.ATTR_OFF_COLOR);
		Boolean activ = painter.getAttributeValue(Io.ATTR_ACTIVE);
		Object desired = activ.booleanValue() ? Value.TRUE : Value.FALSE;
		g.setColor(val == desired ? onColor : offColor);
		g.fillOval(bds.getX(), bds.getY(), bds.getWidth(), bds.getHeight());
	}
	g.setColor(Color.BLACK);
	GraphicsUtil.switchToWidth(g, 2);
	g.drawOval(bds.getX(), bds.getY(), bds.getWidth(), bds.getHeight());
	GraphicsUtil.switchToWidth(g, 1);
	painter.drawLabel();
	painter.drawPorts();
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:23,代碼來源:Led.java

示例2: paintInstance

import com.cburch.logisim.instance.InstanceDataSingleton; //導入方法依賴的package包/類
@Override
public void paintInstance(InstancePainter painter) {
	InstanceDataSingleton data = (InstanceDataSingleton) painter.getData();
	Value val = data == null ? Value.FALSE : (Value) data.getValue();
	Bounds bds = painter.getBounds().expand(-1);

	Graphics g = painter.getGraphics();
	if (painter.getShowState()) {
		Color onColor = painter.getAttributeValue(Io.ATTR_ON_COLOR);
		Color offColor = painter.getAttributeValue(Io.ATTR_OFF_COLOR);
		Boolean activ = painter.getAttributeValue(Io.ATTR_ACTIVE);
		Object desired = activ.booleanValue() ? Value.TRUE : Value.FALSE;
		g.setColor(val == desired ? onColor : offColor);
		g.fillOval(bds.getX(), bds.getY(), bds.getWidth(), bds.getHeight());
	}
	g.setColor(Color.BLACK);
	GraphicsUtil.switchToWidth(g, 2);
	g.drawOval(bds.getX(), bds.getY(), bds.getWidth(), bds.getHeight());
	GraphicsUtil.switchToWidth(g, 1);
	g.setColor(painter.getAttributeValue(Io.ATTR_LABEL_COLOR));
	painter.drawLabel();
	painter.drawPorts();
}
 
開發者ID:franciscaconcha,項目名稱:ProyectoLogisim,代碼行數:24,代碼來源:Led.java

示例3: mouseReleased

import com.cburch.logisim.instance.InstanceDataSingleton; //導入方法依賴的package包/類
@Override
public void mouseReleased(InstanceState state, MouseEvent e) {
	InstanceDataSingleton data = (InstanceDataSingleton) state.getData();
	if (data != null && (Boolean) data.getValue())
		setActive(state, false);
	else
		setActive(state, true);
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:9,代碼來源:Switch.java

示例4: propagate

import com.cburch.logisim.instance.InstanceDataSingleton; //導入方法依賴的package包/類
@Override
public void propagate(InstanceState state) {
	InstanceDataSingleton data = (InstanceDataSingleton) state.getData();
	Value val = (data == null || !(Boolean) data.getValue())
			? Value.createUnknown(state.getAttributeValue(StdAttr.WIDTH))
			: state.getPort(0);
	state.setPort(1, val, 1);
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:9,代碼來源:Switch.java

示例5: getLogValue

import com.cburch.logisim.instance.InstanceDataSingleton; //導入方法依賴的package包/類
@Override
public Value getLogValue(InstanceState state, Object option) {
	InstanceDataSingleton data = (InstanceDataSingleton) state.getData();
	if (data == null)
		return Value.FALSE;
	return data.getValue() == Value.TRUE ? Value.TRUE : Value.FALSE;
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:8,代碼來源:Led.java

示例6: getLogValue

import com.cburch.logisim.instance.InstanceDataSingleton; //導入方法依賴的package包/類
@Override
public Value getLogValue(InstanceState state, Object option) {
	InstanceDataSingleton data = (InstanceDataSingleton) state
			.getData();
	if (data == null)
		return Value.FALSE;
	return data.getValue() == Value.TRUE ? Value.TRUE : Value.FALSE;
}
 
開發者ID:reds-heig,項目名稱:logisim-evolution,代碼行數:9,代碼來源:RGBLed.java

示例7: getLogValue

import com.cburch.logisim.instance.InstanceDataSingleton; //導入方法依賴的package包/類
@Override
public Value getLogValue(InstanceState state, Object option) {
	InstanceDataSingleton data = (InstanceDataSingleton) state.getData();
	return data == null ? Value.FALSE : (Value) data.getValue();
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:6,代碼來源:Button.java

示例8: propagate

import com.cburch.logisim.instance.InstanceDataSingleton; //導入方法依賴的package包/類
@Override
public void propagate(InstanceState state) {
	InstanceDataSingleton data = (InstanceDataSingleton) state.getData();
	Value val = data == null ? Value.FALSE : (Value) data.getValue();
	state.setPort(0, val, 1);
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:7,代碼來源:Button.java

示例9: getLogValue

import com.cburch.logisim.instance.InstanceDataSingleton; //導入方法依賴的package包/類
@Override
public Value getLogValue(InstanceState state, Object option) {
	InstanceDataSingleton data = (InstanceDataSingleton) state
			.getData();
	return data == null ? Value.FALSE : (Value) data.getValue();
}
 
開發者ID:reds-heig,項目名稱:logisim-evolution,代碼行數:7,代碼來源:Button.java

示例10: paintInstance

import com.cburch.logisim.instance.InstanceDataSingleton; //導入方法依賴的package包/類
@Override
public void paintInstance(InstancePainter painter) {
	Bounds bds = painter.getBounds();
	int x = bds.getX();
	int y = bds.getY();
	int w = bds.getWidth();
	int h = bds.getHeight();

	Value val;
	if (painter.getShowState()) {
		InstanceDataSingleton data = (InstanceDataSingleton) painter
				.getData();
		val = data == null ? Value.FALSE : (Value) data.getValue();
	} else {
		val = Value.FALSE;
	}

	Color color = painter.getAttributeValue(Io.ATTR_COLOR);
	if (!painter.shouldDrawColor()) {
		int hue = (color.getRed() + color.getGreen() + color.getBlue()) / 3;
		color = new Color(hue, hue, hue);
	}

	Graphics g = painter.getGraphics();
	int depress;
	if (val == Value.TRUE) {
		x += DEPTH;
		y += DEPTH;
		Object labelLoc = painter.getAttributeValue(Io.ATTR_LABEL_LOC);
		if (labelLoc == Io.LABEL_CENTER || labelLoc == Direction.NORTH
				|| labelLoc == Direction.WEST) {
			depress = DEPTH;
		} else {
			depress = 0;
		}

		Object facing = painter.getAttributeValue(StdAttr.FACING);
		if (facing == Direction.NORTH || facing == Direction.WEST) {
			Location p = painter.getLocation();
			int px = p.getX();
			int py = p.getY();
			GraphicsUtil.switchToWidth(g, Wire.WIDTH);
			g.setColor(Value.TRUE_COLOR);
			if (facing == Direction.NORTH)
				g.drawLine(px, py, px, py + 10);
			else
				g.drawLine(px, py, px + 10, py);
			GraphicsUtil.switchToWidth(g, 1);
		}

		g.setColor(color);
		g.fillRect(x, y, w - DEPTH, h - DEPTH);
		g.setColor(Color.BLACK);
		g.drawRect(x, y, w - DEPTH, h - DEPTH);
	} else {
		depress = 0;
		int[] xp = new int[] { x, x + w - DEPTH, x + w, x + w, x + DEPTH, x };
		int[] yp = new int[] { y, y, y + DEPTH, y + h, y + h, y + h - DEPTH };
		g.setColor(color.darker());
		g.fillPolygon(xp, yp, xp.length);
		g.setColor(color);
		g.fillRect(x, y, w - DEPTH, h - DEPTH);
		g.setColor(Color.BLACK);
		g.drawRect(x, y, w - DEPTH, h - DEPTH);
		g.drawLine(x + w - DEPTH, y + h - DEPTH, x + w, y + h);
		g.drawPolygon(xp, yp, xp.length);
	}

	g.translate(depress, depress);
	painter.drawLabel();
	g.translate(-depress, -depress);
	painter.drawPorts();
}
 
開發者ID:reds-heig,項目名稱:logisim-evolution,代碼行數:74,代碼來源:Button.java

示例11: getLogValue

import com.cburch.logisim.instance.InstanceDataSingleton; //導入方法依賴的package包/類
@Override
public Value getLogValue(InstanceState state, Object option) {
	InstanceDataSingleton data = (InstanceDataSingleton) state.getData();
	if (data == null) return Value.FALSE;
	return data.getValue() == Value.TRUE ? Value.TRUE : Value.FALSE; 
}
 
開發者ID:franciscaconcha,項目名稱:ProyectoLogisim,代碼行數:7,代碼來源:Led.java

示例12: paintInstance

import com.cburch.logisim.instance.InstanceDataSingleton; //導入方法依賴的package包/類
@Override
public void paintInstance(InstancePainter painter) {
	Bounds bds = painter.getBounds();
	int x = bds.getX();
	int y = bds.getY();
	int w = bds.getWidth();
	int h = bds.getHeight();

	Value val;
	if (painter.getShowState()) {
		InstanceDataSingleton data = (InstanceDataSingleton) painter.getData();
		val = data == null ? Value.FALSE : (Value) data.getValue();
	} else {
		val = Value.FALSE;
	}
	
	Color color = painter.getAttributeValue(Io.ATTR_COLOR);
	if (!painter.shouldDrawColor()) {
		int hue = (color.getRed() + color.getGreen() + color.getBlue()) / 3;
		color = new Color(hue, hue, hue);
	}
	
	Graphics g = painter.getGraphics();
	int depress;
	if (val == Value.TRUE) {
		x += DEPTH;
		y += DEPTH;
		Object labelLoc = painter.getAttributeValue(Io.ATTR_LABEL_LOC);
		if (labelLoc == Io.LABEL_CENTER || labelLoc == Direction.NORTH
				|| labelLoc == Direction.WEST) {
			depress = DEPTH;
		} else {
			depress = 0;
		}
		
		Object facing = painter.getAttributeValue(StdAttr.FACING);
		if (facing == Direction.NORTH || facing == Direction.WEST) {
			Location p = painter.getLocation();
			int px = p.getX();
			int py = p.getY();
			GraphicsUtil.switchToWidth(g, Wire.WIDTH);
			g.setColor(Value.TRUE_COLOR);
			if (facing == Direction.NORTH) g.drawLine(px, py, px, py + 10);
			else                          g.drawLine(px, py, px + 10, py);
			GraphicsUtil.switchToWidth(g, 1);
		}
		
		g.setColor(color);
		g.fillRect(x, y, w - DEPTH, h - DEPTH);
		g.setColor(Color.BLACK);
		g.drawRect(x, y, w - DEPTH, h - DEPTH);
	} else {
		depress = 0;
		int[] xp = new int[] { x, x + w - DEPTH, x + w, x + w, x + DEPTH, x };
		int[] yp = new int[] { y, y, y + DEPTH, y + h, y + h, y + h - DEPTH };
		g.setColor(color.darker());
		g.fillPolygon(xp, yp, xp.length);
		g.setColor(color);
		g.fillRect(x, y, w - DEPTH, h - DEPTH);
		g.setColor(Color.BLACK);
		g.drawRect(x, y, w - DEPTH, h - DEPTH);
		g.drawLine(x + w - DEPTH, y + h - DEPTH, x + w, y + h);
		g.drawPolygon(xp, yp, xp.length);
	}
	
	g.translate(depress, depress);
	g.setColor(painter.getAttributeValue(Io.ATTR_LABEL_COLOR));
	painter.drawLabel();
	g.translate(-depress, -depress);
	painter.drawPorts();
}
 
開發者ID:franciscaconcha,項目名稱:ProyectoLogisim,代碼行數:72,代碼來源:Button.java


注:本文中的com.cburch.logisim.instance.InstanceDataSingleton.getValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。