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


Java Direction类代码示例

本文整理汇总了Java中com.cburch.logisim.data.Direction的典型用法代码示例。如果您正苦于以下问题:Java Direction类的具体用法?Java Direction怎么用?Java Direction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: paintInstance

import com.cburch.logisim.data.Direction; //导入依赖的package包/类
@Override
public void paintInstance(InstancePainter painter) {
	painter.drawRoundBounds(Color.WHITE);
	painter.drawClock(0, Direction.EAST); // draw a triangle on port 0
	painter.drawPort(1); // draw port 1 as just a dot

	// Display the current counter value centered within the rectangle.
	// However, if the context says not to show state (as when generating
	// printer output), then skip this.
	if (painter.getShowState()) {
		CounterData state = CounterData.get(painter, BIT_WIDTH);
		Bounds bds = painter.getBounds();
		GraphicsUtil.drawCenteredText(painter.getGraphics(),
				StringUtil.toHexString(BIT_WIDTH.getWidth(), state.getValue().toIntValue()),
				bds.getX() + bds.getWidth() / 2, bds.getY() + bds.getHeight() / 2);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:18,代码来源:SimpleGrayCounter.java

示例2: updateports

import com.cburch.logisim.data.Direction; //导入依赖的package包/类
private void updateports(Instance instance) {
	Direction facing = instance.getAttributeValue(StdAttr.FACING);
	BitWidth bits = (instance.getAttributeValue(Io.MULTI_BIT)) ? BitWidth.create(8) : BitWidth.ONE;
	Port[] port = new Port[3];
	if (facing == Direction.NORTH || facing == Direction.SOUTH) {
		port[0] = new Port(-10, 0, Port.INPUT, bits);
		port[1] = new Port(0, 0, Port.INPUT, bits);
		port[2] = new Port(10, 0, Port.INPUT, bits);
	} else {
		port[0] = new Port(0, -10, Port.INPUT, bits);
		port[1] = new Port(0, 0, Port.INPUT, bits);
		port[2] = new Port(0, 10, Port.INPUT, bits);
	}
	port[0].setToolTip(Strings.getter("Red"));
	port[1].setToolTip(Strings.getter("Green"));
	port[2].setToolTip(Strings.getter("Blue"));
	instance.setPorts(port);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:19,代码来源:RGBLed.java

示例3: computeTextField

import com.cburch.logisim.data.Direction; //导入依赖的package包/类
private void computeTextField(Instance instance) {
	Object labelLoc = instance.getAttributeValue(Io.ATTR_LABEL_LOC);

	Bounds bds = instance.getBounds();
	int x = bds.getX() + bds.getWidth() / 2;
	int y = bds.getY() + bds.getHeight() / 2;
	int halign = GraphicsUtil.H_CENTER;
	int valign = GraphicsUtil.V_CENTER;
	if (labelLoc == Direction.NORTH) {
		y = bds.getY() - 2;
		valign = GraphicsUtil.V_BOTTOM;
	} else if (labelLoc == Direction.SOUTH) {
		y = bds.getY() + bds.getHeight() + 2;
		valign = GraphicsUtil.V_TOP;
	} else if (labelLoc == Direction.EAST) {
		x = bds.getX() + bds.getWidth() + 2;
		halign = GraphicsUtil.H_LEFT;
	} else if (labelLoc == Direction.WEST) {
		x = bds.getX();
		y = bds.getY() - 2;
		valign = GraphicsUtil.V_BOTTOM;
	}
	instance.setTextField(StdAttr.LABEL, StdAttr.LABEL_FONT, StdAttr.ATTR_LABEL_COLOR, x, y, halign, valign);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:25,代码来源:DigitalOscilloscope.java

示例4: paintRotated

import com.cburch.logisim.data.Direction; //导入依赖的package包/类
public static void paintRotated(Graphics g, int x, int y, Direction dir, Icon icon, Component dest) {
	if (!(g instanceof Graphics2D) || dir == Direction.EAST) {
		icon.paintIcon(dest, g, x, y);
		return;
	}

	Graphics2D g2 = (Graphics2D) g.create();
	double cx = x + icon.getIconWidth() / 2.0;
	double cy = y + icon.getIconHeight() / 2.0;
	if (dir == Direction.WEST) {
		g2.rotate(Math.PI, cx, cy);
	} else if (dir == Direction.NORTH) {
		g2.rotate(-Math.PI / 2.0, cx, cy);
	} else if (dir == Direction.SOUTH) {
		g2.rotate(Math.PI / 2.0, cx, cy);
	} else {
		g2.translate(-x, -y);
	}
	icon.paintIcon(dest, g2, x, y);
	g2.dispose();
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:22,代码来源:Icons.java

示例5: paintInstance

import com.cburch.logisim.data.Direction; //导入依赖的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(B_IN, "b in", Direction.NORTH);
	painter.drawPort(B_OUT, "b 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, x - 5, y);
	GraphicsUtil.switchToWidth(g, 1);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:21,代码来源:Subtractor.java

示例6: updateports

import com.cburch.logisim.data.Direction; //导入依赖的package包/类
private void updateports(Instance instance) {
	Direction dir = instance.getAttributeValue(StdAttr.FACING);
	BitWidth bw = instance.getAttributeValue(ATTR_WIDTH);
	Port[] ports = new Port[2];
	if (dir == Direction.EAST || dir == Direction.WEST) {
		ports[0] = new Port(0, 0, Port.OUTPUT, bw);
		ports[1] = new Port(0, 10, Port.OUTPUT, bw);
	} else {
		ports[0] = new Port(0, 0, Port.OUTPUT, bw);
		ports[1] = new Port(-10, 0, Port.OUTPUT, bw);
	}
	ports[0].setToolTip(Strings.getter("X"));
	ports[1].setToolTip(Strings.getter("Y"));

	instance.setPorts(ports);

}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:18,代码来源:Joystick.java

示例7: setValue

import com.cburch.logisim.data.Direction; //导入依赖的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: getOffsetBounds

import com.cburch.logisim.data.Direction; //导入依赖的package包/类
@Override
public Bounds getOffsetBounds(AttributeSet attrs) {
	Direction dir = attrs.getValue(StdAttr.FACING);
	BitWidth select = attrs.getValue(Plexers.ATTR_SELECT);
	int inputs = 1 << select.getWidth();
	int offs = -5 * inputs;
	int len = 10 * inputs + 10;
	if (dir == Direction.NORTH) {
		return Bounds.create(offs, 0, len, 40);
	} else if (dir == Direction.SOUTH) {
		return Bounds.create(offs, -40, len, 40);
	} else if (dir == Direction.WEST) {
		return Bounds.create(0, offs, 40, len);
	} else { // dir == Direction.EAST
		return Bounds.create(-40, offs, 40, len);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:18,代码来源:PriorityEncoder.java

示例9: paintSubcircuit

import com.cburch.logisim.data.Direction; //导入依赖的package包/类
public void paintSubcircuit(Graphics g, Direction facing) {
	Direction defaultFacing = getFacing();
	double rotate = 0.0;
	if (facing != defaultFacing && g instanceof Graphics2D) {
		rotate = defaultFacing.toRadians() - facing.toRadians();
		((Graphics2D) g).rotate(rotate);
	}
	Location offset = findAnchorLocation();
	g.translate(-offset.getX(), -offset.getY());
	for (CanvasObject shape : getObjectsFromBottom()) {
		if (!(shape instanceof AppearanceElement)) {
			Graphics dup = g.create();
			shape.paint(dup, null);
			dup.dispose();
		}
	}
	g.translate(offset.getX(), offset.getY());
	if (rotate != 0.0) {
		((Graphics2D) g).rotate(-rotate);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:22,代码来源:CircuitAppearance.java

示例10: WindowOptions

import com.cburch.logisim.data.Direction; //导入依赖的package包/类
public WindowOptions(PreferencesFrame window) {
	super(window);

	checks = new PrefBoolean[] {
			new PrefBoolean(AppPreferences.SHOW_TICK_RATE, Strings.getter("windowTickRate")), };

	toolbarPlacement = new PrefOptionList(AppPreferences.TOOLBAR_PLACEMENT, Strings.getter("windowToolbarLocation"),
			new PrefOption[] { new PrefOption(Direction.NORTH.toString(), Direction.NORTH.getDisplayGetter()),
					new PrefOption(Direction.SOUTH.toString(), Direction.SOUTH.getDisplayGetter()),
					new PrefOption(Direction.EAST.toString(), Direction.EAST.getDisplayGetter()),
					new PrefOption(Direction.WEST.toString(), Direction.WEST.getDisplayGetter()),
					new PrefOption(AppPreferences.TOOLBAR_DOWN_MIDDLE, Strings.getter("windowToolbarDownMiddle")),
					new PrefOption(AppPreferences.TOOLBAR_HIDDEN, Strings.getter("windowToolbarHidden")) });

	JPanel panel = new JPanel(new TableLayout(2));

	panel.add(toolbarPlacement.getJLabel());
	panel.add(toolbarPlacement.getJComboBox());

	setLayout(new TableLayout(1));
	for (int i = 0; i < checks.length; i++) {
		add(checks[i]);
	}
	add(panel);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:26,代码来源:WindowOptions.java

示例11: ClipboardActions

import com.cburch.logisim.data.Direction; //导入依赖的package包/类
private ClipboardActions(boolean remove, AppearanceCanvas canvas) {
	this.remove = remove;
	this.canvas = canvas;
	this.canvasModel = canvas.getModel();

	ArrayList<CanvasObject> contents = new ArrayList<CanvasObject>();
	Direction anchorFacing = null;
	Location anchorLocation = null;
	ArrayList<CanvasObject> aff = new ArrayList<CanvasObject>();
	for (CanvasObject o : canvas.getSelection().getSelected()) {
		if (o.canRemove()) {
			aff.add(o);
			contents.add(o.clone());
		} else if (o instanceof AppearanceAnchor) {
			AppearanceAnchor anch = (AppearanceAnchor) o;
			anchorFacing = anch.getFacing();
			anchorLocation = anch.getLocation();
		}
	}
	contents.trimToSize();
	affected = ZOrder.getZIndex(aff, canvasModel);
	newClipboard = new ClipboardContents(contents, anchorLocation, anchorFacing);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:24,代码来源:ClipboardActions.java

示例12: configurePorts

import com.cburch.logisim.data.Direction; //导入依赖的package包/类
private void configurePorts(Instance instance) {
	Direction facing = instance.getAttributeValue(StdAttr.FACING);
	Bounds bds = getOffsetBounds(instance.getAttributeSet());
	int d = Math.max(bds.getWidth(), bds.getHeight()) - 20;
	Location loc0 = Location.create(0, 0);
	Location loc1 = loc0.translate(facing.reverse(), 20 + d);
	Location loc2;
	if (instance.getAttributeValue(ATTR_CONTROL) == LEFT_HANDED) {
		loc2 = loc0.translate(facing.reverse(), 10 + d, 10);
	} else {
		loc2 = loc0.translate(facing.reverse(), 10 + d, -10);
	}

	Port[] ports = new Port[3];
	ports[0] = new Port(0, 0, Port.OUTPUT, StdAttr.WIDTH);
	ports[1] = new Port(loc1.getX(), loc1.getY(), Port.INPUT, StdAttr.WIDTH);
	ports[2] = new Port(loc2.getX(), loc2.getY(), Port.INPUT, 1);
	instance.setPorts(ports);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:20,代码来源:ControlledBuffer.java

示例13: attemptReface

import com.cburch.logisim.data.Direction; //导入依赖的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

示例14: toString

import com.cburch.logisim.data.Direction; //导入依赖的package包/类
@Override
public String toString() {
	if (value < 0) {
		return Strings.get("splitterBitNone");
	} else {
		String ret = "" + value;
		Direction noteDir;
		if (value == 0) {
			noteDir = isVertical ? Direction.NORTH : Direction.EAST;
		} else if (isLast) {
			noteDir = isVertical ? Direction.SOUTH : Direction.WEST;
		} else {
			noteDir = null;
		}
		if (noteDir != null) {
			ret += " (" + noteDir.toVerticalDisplayString() + ")";
		}
		return ret;
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:21,代码来源:SplitterAttributes.java

示例15: configureLabel

import com.cburch.logisim.data.Direction; //导入依赖的package包/类
static void configureLabel(Instance instance, boolean isRectangular, Location control) {
	Object facing = instance.getAttributeValue(StdAttr.FACING);
	Bounds bds = instance.getBounds();
	int x;
	int y;
	int halign;
	if (facing == Direction.NORTH || facing == Direction.SOUTH) {
		x = bds.getX() + bds.getWidth() / 2 + 2;
		y = bds.getY() - 2;
		halign = TextField.H_LEFT;
	} else { // west or east
		y = isRectangular ? bds.getY() - 2 : bds.getY();
		if (control != null && control.getY() == bds.getY()) {
			// the control line will get in the way
			x = control.getX() + 2;
			halign = TextField.H_LEFT;
		} else {
			x = bds.getX() + bds.getWidth() / 2;
			halign = TextField.H_CENTER;
		}
	}
	instance.setTextField(StdAttr.LABEL, StdAttr.LABEL_FONT, StdAttr.ATTR_LABEL_COLOR, x, y, halign,
			TextField.V_BASELINE);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:25,代码来源:NotGate.java


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