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


Java DrawAttr类代码示例

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


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

示例1: setForFill

import com.cburch.draw.shapes.DrawAttr; //导入依赖的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

示例2: setForStroke

import com.cburch.draw.shapes.DrawAttr; //导入依赖的package包/类
protected boolean setForStroke(Graphics g) {
	List<Attribute<?>> attrs = getAttributes();
	if (attrs.contains(DrawAttr.PAINT_TYPE)) {
		Object value = getValue(DrawAttr.PAINT_TYPE);
		if (value == DrawAttr.PAINT_FILL)
			return false;
	}

	Integer width = getValue(DrawAttr.STROKE_WIDTH);
	if (width != null && width.intValue() > 0) {
		Color color = getValue(DrawAttr.STROKE_COLOR);
		if (color != null && color.getAlpha() == 0) {
			return false;
		} else {
			GraphicsUtil.switchToWidth(g, width.intValue());
			if (color != null)
				g.setColor(color);
			return true;
		}
	} else {
		return false;
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:24,代码来源:AbstractCanvasObject.java

示例3: mouseReleased

import com.cburch.draw.shapes.DrawAttr; //导入依赖的package包/类
@Override
public void mouseReleased(Canvas canvas, MouseEvent e) {
	if (active) {
		updateMouse(canvas, e.getX(), e.getY(), e.getModifiersEx());
		Location start = mouseStart;
		Location end = mouseEnd;
		CanvasObject add = null;
		if (!start.equals(end)) {
			active = false;
			CanvasModel model = canvas.getModel();
			Location[] ends = { start, end };
			List<Location> locs = UnmodifiableList.create(ends);
			add = attrs.applyTo(new Poly(false, locs));
			add.setValue(DrawAttr.PAINT_TYPE, DrawAttr.PAINT_STROKE);
			canvas.doAction(new ModelAddAction(model, add));
			repaintArea(canvas);
		}
		canvas.toolGestureComplete(this, add);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:21,代码来源:LineTool.java

示例4: applyTo

import com.cburch.draw.shapes.DrawAttr; //导入依赖的package包/类
public <E extends CanvasObject> E applyTo(E drawable) {
	AbstractCanvasObject d = (AbstractCanvasObject) drawable;
	// use a for(i...) loop since the attribute list may change as we go on
	for (int i = 0; i < d.getAttributes().size(); i++) {
		Attribute<?> attr = d.getAttributes().get(i);
		@SuppressWarnings("unchecked")
		Attribute<Object> a = (Attribute<Object>) attr;
		if (attr == DrawAttr.FILL_COLOR
				&& this.containsAttribute(DrawAttr.TEXT_DEFAULT_FILL)) {
			d.setValue(a, this.getValue(DrawAttr.TEXT_DEFAULT_FILL));
		} else if (this.containsAttribute(a)) {
			Object value = this.getValue(a);
			d.setValue(a, value);
		}
	}
	return drawable;
}
 
开发者ID:reds-heig,项目名称:logisim-evolution,代码行数:18,代码来源:DrawingAttributeSet.java

示例5: setForStroke

import com.cburch.draw.shapes.DrawAttr; //导入依赖的package包/类
protected boolean setForStroke(Graphics g) {
	List<Attribute<?>> attrs = getAttributes();
	if (attrs.contains(DrawAttr.PAINT_TYPE)) {
		Object value = getValue(DrawAttr.PAINT_TYPE);
		if (value == DrawAttr.PAINT_FILL) return false;
	}

	Integer width = getValue(DrawAttr.STROKE_WIDTH);
	if (width != null && width.intValue() > 0) {
		Color color = getValue(DrawAttr.STROKE_COLOR);
		if (color != null && color.getAlpha() == 0) {
			return false;
		} else {
			GraphicsUtil.switchToWidth(g, width.intValue());
			if (color != null) g.setColor(color);
			return true;
		}
	} else {
		return false;
	}
}
 
开发者ID:franciscaconcha,项目名称:ProyectoLogisim,代码行数:22,代码来源:AbstractCanvasObject.java

示例6: applyTo

import com.cburch.draw.shapes.DrawAttr; //导入依赖的package包/类
public <E extends CanvasObject> E applyTo(E drawable) {
	AbstractCanvasObject d = (AbstractCanvasObject) drawable;
	// use a for(i...) loop since the attribute list may change as we go on
	for (int i = 0; i < d.getAttributes().size(); i++) {
		Attribute<?> attr = d.getAttributes().get(i);
		Attribute<Object> a = (Attribute<Object>) attr;
		if (attr == DrawAttr.FILL_COLOR && this.containsAttribute(DrawAttr.TEXT_DEFAULT_FILL)) {
			d.setValue(a, this.getValue(DrawAttr.TEXT_DEFAULT_FILL));
		} else if (this.containsAttribute(a)) {
			Object value = this.getValue(a);
			d.setValue(a, value);
		}
	}
	return drawable;
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:16,代码来源:DrawingAttributeSet.java

示例7: paintInstance

import com.cburch.draw.shapes.DrawAttr; //导入依赖的package包/类
@Override
public void paintInstance(InstancePainter painter) {
	State state = (State) painter.getData();
	if (state == null || state.size != painter.getAttributeValue(ATTR_SIZE)) {
		int val = (state == null) ? 0 : state.Value;
		state = new State(val, painter.getAttributeValue(ATTR_SIZE));
		painter.setData(state);
	}
	Bounds bds = painter.getBounds().expand(-1);

	Graphics g = painter.getGraphics();
	GraphicsUtil.switchToWidth(g, 2);
	g.setColor(Color.darkGray);
	g.fillRect(bds.getX(), bds.getY(), bds.getWidth(), bds.getHeight());
	GraphicsUtil.switchToWidth(g, 1);
	g.setColor(Color.white);
	g.setFont(DrawAttr.DEFAULT_FONT);
	int offset = 0;
	for (int i = 0; i < painter.getAttributeValue(ATTR_SIZE); i++) {
		if (i == 9) {
			g.setFont(g.getFont()
					.deriveFont(g.getFont().getSize2D() * 0.6f));
			offset = -2;
		}
		g.fillRect(bds.getX() + 6 + (i * 10), bds.getY() + 15, 6, 20);
		g.drawChars(Integer.toString(i + 1).toCharArray(), 0, Integer
				.toString(i + 1).toCharArray().length, bds.getX() + 5
				+ offset + i * 10, bds.getY() + 12);
	}
	g.setColor(Color.lightGray);
	for (int i = 0; i < painter.getAttributeValue(ATTR_SIZE); i++) {
		int ypos = (state.BitSet(i)) ? bds.getY() + 16 : bds.getY() + 25;
		g.fillRect(bds.getX() + 7 + (i * 10), ypos, 4, 9);
	}
	painter.drawLabel();
	painter.drawPorts();

}
 
开发者ID:reds-heig,项目名称:logisim-evolution,代码行数:39,代码来源:DipSwitch.java

示例8: setForFill

import com.cburch.draw.shapes.DrawAttr; //导入依赖的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:franciscaconcha,项目名称:ProyectoLogisim,代码行数:16,代码来源:AbstractCanvasObject.java

示例9: getAttributes

import com.cburch.draw.shapes.DrawAttr; //导入依赖的package包/类
@Override
public List<Attribute<?>> getAttributes() {
	return DrawAttr.ATTRS_STROKE;
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:5,代码来源:LineTool.java

示例10: getAttributes

import com.cburch.draw.shapes.DrawAttr; //导入依赖的package包/类
@Override
public List<Attribute<?>> getAttributes() {
	return DrawAttr.getFillAttributes(attrs.getValue(DrawAttr.PAINT_TYPE));
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:5,代码来源:RectangleTool.java

示例11: getAttributes

import com.cburch.draw.shapes.DrawAttr; //导入依赖的package包/类
@Override
public List<Attribute<?>> getAttributes() {
	return DrawAttr.ATTRS_TEXT_TOOL;
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:5,代码来源:TextTool.java

示例12: drawShape

import com.cburch.draw.shapes.DrawAttr; //导入依赖的package包/类
@Override
public void drawShape(Graphics g, int x, int y, int w, int h) {
	int r = 2 * attrs.getValue(DrawAttr.CORNER_RADIUS).intValue();
	g.drawRoundRect(x, y, w, h, r, r);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:6,代码来源:RoundRectangleTool.java

示例13: fillShape

import com.cburch.draw.shapes.DrawAttr; //导入依赖的package包/类
@Override
public void fillShape(Graphics g, int x, int y, int w, int h) {
	int r = 2 * attrs.getValue(DrawAttr.CORNER_RADIUS).intValue();
	g.fillRoundRect(x, y, w, h, r, r);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:6,代码来源:RoundRectangleTool.java

示例14: getAttributes

import com.cburch.draw.shapes.DrawAttr; //导入依赖的package包/类
@Override
public List<Attribute<?>> getAttributes() {
	return DrawAttr.getRoundRectAttributes(attrs.getValue(DrawAttr.PAINT_TYPE));
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:5,代码来源:RoundRectangleTool.java

示例15: build

import com.cburch.draw.shapes.DrawAttr; //导入依赖的package包/类
public static List<CanvasObject> build(Collection<Instance> pins) {
	Map<Direction, List<Instance>> edge;
	edge = new HashMap<Direction, List<Instance>>();
	edge.put(Direction.NORTH, new ArrayList<Instance>());
	edge.put(Direction.SOUTH, new ArrayList<Instance>());
	edge.put(Direction.EAST, new ArrayList<Instance>());
	edge.put(Direction.WEST, new ArrayList<Instance>());
	for (Instance pin : pins) {
		Direction pinFacing = pin.getAttributeValue(StdAttr.FACING);
		Direction pinEdge = pinFacing.reverse();
		List<Instance> e = edge.get(pinEdge);
		e.add(pin);
	}

	for (Map.Entry<Direction, List<Instance>> entry : edge.entrySet()) {
		sortPinList(entry.getValue(), entry.getKey());
	}

	int numNorth = edge.get(Direction.NORTH).size();
	int numSouth = edge.get(Direction.SOUTH).size();
	int numEast = edge.get(Direction.EAST).size();
	int numWest = edge.get(Direction.WEST).size();
	int maxVert = Math.max(numNorth, numSouth);
	int maxHorz = Math.max(numEast, numWest);

	int offsNorth = computeOffset(numNorth, numSouth, maxHorz);
	int offsSouth = computeOffset(numSouth, numNorth, maxHorz);
	int offsEast = computeOffset(numEast, numWest, maxVert);
	int offsWest = computeOffset(numWest, numEast, maxVert);

	int width = computeDimension(maxVert, maxHorz);
	int height = computeDimension(maxHorz, maxVert);

	// compute position of anchor relative to top left corner of box
	int ax;
	int ay;
	if (numEast > 0) { // anchor is on east side
		ax = width;
		ay = offsEast;
	} else if (numNorth > 0) { // anchor is on north side
		ax = offsNorth;
		ay = 0;
	} else if (numWest > 0) { // anchor is on west side
		ax = 0;
		ay = offsWest;
	} else if (numSouth > 0) { // anchor is on south side
		ax = offsSouth;
		ay = height;
	} else { // anchor is top left corner
		ax = 0;
		ay = 0;
	}

	// place rectangle so anchor is on the grid
	int rx = OFFS + (9 - (ax + 9) % 10);
	int ry = OFFS + (9 - (ay + 9) % 10);

	Location e0 = Location.create(rx + (width - 8) / 2, ry + 2);
	Location e1 = Location.create(rx + (width + 8) / 2, ry + 2);
	Location ct = Location.create(rx + width / 2, ry + 11);

	Curve notch = new Curve(e0, e1, ct);
	notch.setValue(DrawAttr.STROKE_WIDTH, Integer.valueOf(2));
	notch.setValue(DrawAttr.STROKE_COLOR, Color.GRAY);

	RoundRectangle rect = new RoundRectangle(rx, ry, width, height, 5);
	rect.setValue(DrawAttr.STROKE_WIDTH, Integer.valueOf(2));
	rect.setValue(DrawAttr.PAINT_TYPE,
			AppPreferences.FILL_COMPONENT_BACKGROUND.getBoolean() ? DrawAttr.PAINT_STROKE_FILL
					: DrawAttr.PAINT_STROKE);
	List<CanvasObject> ret = new ArrayList<CanvasObject>();
	ret.add(rect);
	ret.add(notch);
	placePins(ret, edge.get(Direction.WEST), rx, ry + offsWest, 0, 10);
	placePins(ret, edge.get(Direction.EAST), rx + width, ry + offsEast, 0, 10);
	placePins(ret, edge.get(Direction.NORTH), rx + offsNorth, ry, 10, 0);
	placePins(ret, edge.get(Direction.SOUTH), rx + offsSouth, ry + height, 10, 0);
	ret.add(new AppearanceAnchor(Location.create(rx + ax, ry + ay)));
	return ret;
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:81,代码来源:DefaultAppearance.java


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