当前位置: 首页>>代码示例>>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;未经允许,请勿转载。