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


Java Attribute類代碼示例

本文整理匯總了Java中com.cburch.logisim.data.Attribute的典型用法代碼示例。如果您正苦於以下問題:Java Attribute類的具體用法?Java Attribute怎麽用?Java Attribute使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: attemptReface

import com.cburch.logisim.data.Attribute; //導入依賴的package包/類
private void attemptReface(Canvas canvas, final Direction facing, KeyEvent e) {
	if (e.getModifiersEx() == 0) {
		final Circuit circuit = canvas.getCircuit();
		final Selection sel = canvas.getSelection();
		SetAttributeAction act = new SetAttributeAction(circuit, Strings.getter("selectionRefaceAction"));
		for (Component comp : sel.getComponents()) {
			if (!(comp instanceof Wire)) {
				Attribute<Direction> attr = getFacingAttribute(comp);
				if (attr != null) {
					act.set(comp, attr, facing);
				}
			}
		}
		if (!act.isEmpty()) {
			canvas.getProject().doAction(act);
			e.consume();
		}
	}
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:20,代碼來源:EditTool.java

示例2: getValue

import com.cburch.logisim.data.Attribute; //導入依賴的package包/類
@Override
public <V> V getValue(Attribute<V> attr) {
	if (attr == DrawAttr.FONT) {
		return (V) label.getFont();
	} else if (attr == DrawAttr.FILL_COLOR) {
		return (V) label.getColor();
	} else if (attr == DrawAttr.ALIGNMENT) {
		int halign = label.getHorizontalAlignment();
		AttributeOption h;
		if (halign == EditableLabel.LEFT) {
			h = DrawAttr.ALIGN_LEFT;
		} else if (halign == EditableLabel.RIGHT) {
			h = DrawAttr.ALIGN_RIGHT;
		} else {
			h = DrawAttr.ALIGN_CENTER;
		}
		return (V) h;
	} else {
		return null;
	}
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:22,代碼來源:Text.java

示例3: setForFill

import com.cburch.logisim.data.Attribute; //導入依賴的package包/類
protected boolean setForFill(Graphics g) {
	List<Attribute<?>> attrs = getAttributes();
	if (attrs.contains(DrawAttr.PAINT_TYPE)) {
		Object value = getValue(DrawAttr.PAINT_TYPE);
		if (value == DrawAttr.PAINT_STROKE)
			return false;
	}

	Color color = getValue(DrawAttr.FILL_COLOR);
	if (color != null && color.getAlpha() == 0) {
		return false;
	} else {
		if (color != null)
			g.setColor(color);
		return true;
	}
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:18,代碼來源:AbstractCanvasObject.java

示例4: getName

import com.cburch.logisim.data.Attribute; //導入依賴的package包/類
@Override
public String getName() {
	Attribute<?> a = attr;
	if (a == null) {
		boolean found = false;
		for (AttributeMapKey key : newValues.keySet()) {
			Attribute<?> at = key.getAttribute();
			if (found) {
				if (a == null ? at != null : !a.equals(at)) {
					a = null;
					break;
				}
			} else {
				found = true;
				a = at;
			}
		}
		attr = a;
	}
	if (a == null) {
		return Strings.get("actionChangeAttributes");
	} else {
		return Strings.get("actionChangeAttribute", a.getDisplayName());
	}
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:26,代碼來源:ModelChangeAttributeAction.java

示例5: addAttributeSetContent

import com.cburch.logisim.data.Attribute; //導入依賴的package包/類
void addAttributeSetContent(Element elt, AttributeSet attrs, AttributeDefaultProvider source) {
	if (attrs == null)
		return;
	LogisimVersion ver = Main.VERSION;
	if (source != null && source.isAllDefaultValues(attrs, ver))
		return;
	for (Attribute<?> attrBase : attrs.getAttributes()) {
		Attribute<Object> attr = (Attribute<Object>) attrBase;
		Object val = attrs.getValue(attr);
		if (attrs.isToSave(attr) && val != null) {
			Object dflt = source == null ? null : source.getDefaultAttributeValue(attr, ver);
			if (dflt == null || !dflt.equals(val)) {
				Element a = doc.createElement("a");
				a.setAttribute("name", attr.getName());
				String value = attr.toStandardString(val);
				if (value.indexOf("\n") >= 0) {
					a.appendChild(doc.createTextNode(value));
				} else {
					a.setAttribute("val", attr.toStandardString(val));
				}
				elt.appendChild(a);
			}
		}
	}
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:26,代碼來源:XmlWriter.java

示例6: Comparator

import com.cburch.logisim.data.Attribute; //導入依賴的package包/類
public Comparator() {
	super("Comparator", Strings.getter("comparatorComponent"));
	setAttributes(new Attribute[] { StdAttr.WIDTH, MODE_ATTRIBUTE },
			new Object[] { BitWidth.create(8), SIGNED_OPTION });
	setKeyConfigurator(new BitWidthConfigurator(StdAttr.WIDTH));
	setOffsetBounds(Bounds.create(-40, -20, 40, 40));
	setIconName("comparator.gif");

	Port[] ps = new Port[5];
	ps[IN0] = new Port(-40, -10, Port.INPUT, StdAttr.WIDTH);
	ps[IN1] = new Port(-40, 10, Port.INPUT, StdAttr.WIDTH);
	ps[GT] = new Port(0, -10, Port.OUTPUT, 1);
	ps[EQ] = new Port(0, 0, Port.OUTPUT, 1);
	ps[LT] = new Port(0, 10, Port.OUTPUT, 1);
	ps[IN0].setToolTip(Strings.getter("comparatorInputATip"));
	ps[IN1].setToolTip(Strings.getter("comparatorInputBTip"));
	ps[GT].setToolTip(Strings.getter("comparatorGreaterTip"));
	ps[EQ].setToolTip(Strings.getter("comparatorEqualTip"));
	ps[LT].setToolTip(Strings.getter("comparatorLessTip"));
	setPorts(ps);
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:22,代碼來源:Comparator.java

示例7: setValue

import com.cburch.logisim.data.Attribute; //導入依賴的package包/類
@Override
public <V> void setValue(Attribute<V> attr, V value) {
	if (attr == StdAttr.FACING) {
		facing = (Direction) value;
	} else if (attr == StdAttr.LABEL) {
		label = (String) value;
	} else if (attr == Pin.ATTR_LABEL_LOC) {
		labelloc = (Direction) value;
	} else if (attr == StdAttr.LABEL_FONT) {
		labelfont = (Font) value;
	} else if (attr == RadixOption.ATTRIBUTE) {
		radix = (RadixOption) value;
	} else if (attr == StdAttr.ATTR_LABEL_COLOR) {
		labelColor = (Color) value;
	} else {
		throw new IllegalArgumentException("unknown attribute");
	}
	fireAttributeValueChanged(attr, value);
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:20,代碼來源:ProbeAttributes.java

示例8: setValue

import com.cburch.logisim.data.Attribute; //導入依賴的package包/類
@Override
public <V> void setValue(Attribute<V> attr, V value) {
	Attribute<?>[] attrs = this.selAttrs;
	Object[] values = this.selValues;
	for (int i = 0; i < attrs.length; i++) {
		if (attrs[i] == attr) {
			boolean same = value == null ? values[i] == null : value.equals(values[i]);
			if (!same) {
				values[i] = value;
				for (AttributeSet objAttrs : selected.keySet()) {
					objAttrs.setValue(attr, value);
				}
			}
			break;
		}
	}
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:18,代碼來源:SelectionAttributes.java

示例9: getDefaultAttributeValue

import com.cburch.logisim.data.Attribute; //導入依賴的package包/類
@Override
public Object getDefaultAttributeValue(Attribute<?> attr, LogisimVersion ver) {
	Attribute<?>[] as = attrs;
	if (as != null) {
		for (int i = 0; i < as.length; i++) {
			if (as[i] == attr) {
				return defaults[i];
			}
		}
		return null;
	} else {
		AttributeSet dfltSet = defaultSet;
		if (dfltSet == null) {
			dfltSet = createAttributeSet();
			defaultSet = dfltSet;
		}
		return dfltSet.getValue(attr);
	}
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:20,代碼來源:InstanceFactory.java

示例10: Adder

import com.cburch.logisim.data.Attribute; //導入依賴的package包/類
public Adder() {
	super("Adder", Strings.getter("adderComponent"));
	setAttributes(new Attribute[] { StdAttr.WIDTH }, new Object[] { BitWidth.create(8) });
	setKeyConfigurator(new BitWidthConfigurator(StdAttr.WIDTH));
	setOffsetBounds(Bounds.create(-40, -20, 40, 40));
	setIconName("adder.gif");

	Port[] ps = new Port[5];
	ps[IN0] = new Port(-40, -10, Port.INPUT, StdAttr.WIDTH);
	ps[IN1] = new Port(-40, 10, Port.INPUT, StdAttr.WIDTH);
	ps[OUT] = new Port(0, 0, Port.OUTPUT, StdAttr.WIDTH);
	ps[C_IN] = new Port(-20, -20, Port.INPUT, 1);
	ps[C_OUT] = new Port(-20, 20, Port.INPUT, 1);
	ps[IN0].setToolTip(Strings.getter("adderInputTip"));
	ps[IN1].setToolTip(Strings.getter("adderInputTip"));
	ps[OUT].setToolTip(Strings.getter("adderOutputTip"));
	ps[C_IN].setToolTip(Strings.getter("adderCarryInTip"));
	ps[C_OUT].setToolTip(Strings.getter("adderCarryOutTip"));
	setPorts(ps);
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:21,代碼來源:Adder.java

示例11: Random

import com.cburch.logisim.data.Attribute; //導入依賴的package包/類
public Random() {
	super("Random", Strings.getter("randomComponent"));
	setAttributes(
			new Attribute[] { StdAttr.WIDTH, ATTR_SEED, StdAttr.EDGE_TRIGGER, StdAttr.LABEL, StdAttr.LABEL_FONT,
					StdAttr.ATTR_LABEL_COLOR },
			new Object[] { BitWidth.create(8), Integer.valueOf(0), StdAttr.TRIG_RISING, "",
					StdAttr.DEFAULT_LABEL_FONT, Color.BLACK });
	setKeyConfigurator(new BitWidthConfigurator(StdAttr.WIDTH));

	setOffsetBounds(Bounds.create(-30, -20, 30, 40));
	setIconName("random.gif");
	setInstanceLogger(Logger.class);

	Port[] ps = new Port[4];
	ps[OUT] = new Port(0, 0, Port.OUTPUT, StdAttr.WIDTH);
	ps[CK] = new Port(-30, -10, Port.INPUT, 1);
	ps[NXT] = new Port(-30, 10, Port.INPUT, 1);
	ps[RST] = new Port(-20, 20, Port.INPUT, 1);
	ps[OUT].setToolTip(Strings.getter("randomQTip"));
	ps[CK].setToolTip(Strings.getter("randomClockTip"));
	ps[NXT].setToolTip(Strings.getter("randomNextTip"));
	ps[RST].setToolTip(Strings.getter("randomResetTip"));
	setPorts(ps);
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:25,代碼來源:Random.java

示例12: copyInto

import com.cburch.logisim.data.Attribute; //導入依賴的package包/類
@Override
protected void copyInto(AbstractAttributeSet destObj) {
	SplitterAttributes dest = (SplitterAttributes) destObj;
	dest.parameters = this.parameters;
	dest.attrs = new ArrayList<Attribute<?>>(this.attrs.size());
	dest.attrs.addAll(INIT_ATTRIBUTES);
	for (int i = INIT_ATTRIBUTES.size(), n = this.attrs.size(); i < n; i++) {
		BitOutAttribute attr = (BitOutAttribute) this.attrs.get(i);
		dest.attrs.add(attr.createCopy());
	}

	dest.facing = this.facing;
	dest.fanout = this.fanout;
	dest.appear = this.appear;
	dest.bit_end = this.bit_end.clone();
	dest.options = this.options;
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:18,代碼來源:SplitterAttributes.java

示例13: SevenSegment

import com.cburch.logisim.data.Attribute; //導入依賴的package包/類
public SevenSegment() {
	super("7-Segment Display", Strings.getter("sevenSegmentComponent"));
	setAttributes(new Attribute[] { Io.ATTR_ON_COLOR, Io.ATTR_OFF_COLOR, Io.ATTR_BACKGROUND, Io.ATTR_ACTIVE },
			new Object[] { new Color(240, 0, 0), DEFAULT_OFF, Io.DEFAULT_BACKGROUND, Boolean.TRUE });
	setOffsetBounds(Bounds.create(-5, 0, 40, 60));
	setIconName("7seg.gif");
	Port[] port = new Port[] { new Port(20, 0, Port.INPUT, 1), new Port(30, 0, Port.INPUT, 1),
			new Port(20, 60, Port.INPUT, 1), new Port(10, 60, Port.INPUT, 1), new Port(0, 60, Port.INPUT, 1),
			new Port(10, 0, Port.INPUT, 1), new Port(0, 0, Port.INPUT, 1), new Port(30, 60, Port.INPUT, 1) };
	char c = 97;// a
	for (int i = 0; i < 7; i++) {
		port[i].setToolTip(Strings.getter("" + c));
		c++;
	}
	port[7].setToolTip(Strings.getter("dp"));// dot point
	setPorts(port);
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:18,代碼來源:SevenSegment.java

示例14: getValue

import com.cburch.logisim.data.Attribute; //導入依賴的package包/類
@Override
public <E> E getValue(Attribute<E> attr) {
	if (attr == StdAttr.FACING)
		return (E) facing;
	if (attr == StdAttr.LABEL)
		return (E) label;
	if (attr == Pin.ATTR_LABEL_LOC)
		return (E) labelloc;
	if (attr == StdAttr.LABEL_FONT)
		return (E) labelfont;
	if (attr == RadixOption.ATTRIBUTE)
		return (E) radix;
	if (attr == StdAttr.ATTR_LABEL_COLOR)
		return (E) labelColor;
	return null;
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:17,代碼來源:ProbeAttributes.java

示例15: setValue

import com.cburch.logisim.data.Attribute; //導入依賴的package包/類
@Override
public <V> void setValue(Attribute<V> attr, V value) {
	if (attr == StdAttr.WIDTH) {
		width = (BitWidth) value;
	} else if (attr == Pin.ATTR_TRISTATE) {
		threeState = ((Boolean) value).booleanValue();
	} else if (attr == Pin.ATTR_TYPE) {
		type = ((Boolean) value).booleanValue() ? EndData.OUTPUT_ONLY : EndData.INPUT_ONLY;
	} else if (attr == Pin.ATTR_PULL) {
		pull = value;
	} else if (attr == StdAttr.ATTR_LABEL_COLOR) {
		LabelColor = (Color) value;
	} else {
		super.setValue(attr, value);
		return;
	}
	fireAttributeValueChanged(attr, value);
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:19,代碼來源:PinAttributes.java


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