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


Java Graphics.drawPolyline方法代码示例

本文整理汇总了Java中java.awt.Graphics.drawPolyline方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics.drawPolyline方法的具体用法?Java Graphics.drawPolyline怎么用?Java Graphics.drawPolyline使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Graphics的用法示例。


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

示例1: getStationIcon

import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public Image getStationIcon(String type, Rectangle bounds) {
	int qLength = 60, height = 40, width = 100;
	BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR);
	Graphics g = bi.getGraphics();
	for (int i = 0, monoChannel = 0; i < 10; i++, monoChannel = (int) ((1 - Math.exp(-i)) * 50)) {
		g.setColor(new Color(230 - monoChannel, 230 - monoChannel, 230 - monoChannel));
		g.drawPolyline(new int[] { i, i, qLength - i }, new int[] { height - i, i, i }, 3);
		g.fillArc(width - height + i, i, height - 2 * i, height - 2 * i, 45, 180);
		g.setColor(new Color(130 + monoChannel, 130 + monoChannel, 130 + monoChannel));
		g.drawPolyline(new int[] { i, qLength - i, qLength - i }, new int[] { height - i, height - i, i }, 3);
		g.fillArc(width - height + i, i, height - 2 * i, height - 2 * i, 225, 180);
	}
	g.fillRect(5, 5, qLength - 9, height - 9);
	g.fillOval(width - height + 5, 5, height - 10, height - 10);
	return bi.getScaledInstance(bounds.width, bounds.height, Image.SCALE_SMOOTH);
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:18,代码来源:DefaultIconsToolkit.java

示例2: paint

import java.awt.Graphics; //导入方法依赖的package包/类
@Override public void paint(Graphics graphics) {
	graphics.setColor(Color.BLACK);
	graphics.drawRect(10, 0, size.width-20, size.height);
	Class<? extends FlipFlop> cls = this.getClass();
	if(cls.isAnnotationPresent(Clocked.class)) {
		if(tiggerType!=TiggerType.PULSE_TIGGERED) {
			graphics.drawLine(10, size.height/2-5, 20, size.height/2);
			graphics.drawLine(10, size.height/2+5, 20, size.height/2);
			if(tiggerType==TiggerType.NEGATIVE_EDGE_TIGGERED)
				graphics.drawOval(2, size.height/2-4, 8, 8);
		}
	}
	if(cls.isAnnotationPresent(MasterSlave.class)&&isMasterSlave) {
		Polygon polygon = new Polygon(new int[]{0, 8, 8},
				new int[]{0, 0, 8}, 3);
		polygon.translate(size.width-22, 5);
		graphics.drawPolyline(polygon.xpoints, polygon.ypoints, polygon.npoints);
		polygon.translate(0, size.height-17);
		graphics.drawPolyline(polygon.xpoints, polygon.ypoints, polygon.npoints);
	}
}
 
开发者ID:kristian,项目名称:JDigitalSimulator,代码行数:22,代码来源:FlipFlop.java

示例3: paintIcon

import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paintIcon(InstancePainter painter) {
	Graphics g = painter.getGraphics();
	Icon icon = isInverter ? ICON_INVERTER : ICON_BUFFER;
	if (icon != null) {
		icon.paintIcon(painter.getDestination(), g, 2, 2);
	} else {
		int x = isInverter ? 0 : 2;
		g.setColor(Color.BLACK);
		int[] xp = new int[] { x + 15, x + 1, x + 1, x + 15 };
		int[] yp = new int[] { 10, 3, 17, 10 };
		g.drawPolyline(xp, yp, 4);
		if (isInverter)
			g.drawOval(x + 13, 8, 4, 4);
		g.setColor(Value.FALSE_COLOR);
		g.drawLine(x + 8, 14, x + 8, 18);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:19,代码来源:ControlledBuffer.java

示例4: getStationIcon

import java.awt.Graphics; //导入方法依赖的package包/类
public static Image getStationIcon(String type, Rectangle bounds) {
	BufferedImage bi = new BufferedImage(bounds.width, bounds.height, BufferedImage.TYPE_4BYTE_ABGR);
	Graphics g = bi.getGraphics();
	int qLength = bounds.width * 3 / 5, height = bounds.height, width = bounds.width;
	for (int i = 0, monoChannel = 0; i < 5; i++, monoChannel = (int) ((1 - Math.exp(-i)) * 50)) {
		g.setColor(new Color(230 - monoChannel, 230 - monoChannel, 230 - monoChannel, 255));
		g.drawPolyline(new int[] { i, i, qLength - i }, new int[] { height - i, i, i }, 3);
		g.fillArc(width - height + i, i, height - 2 * i, height - 2 * i, 45, 180);
		g.setColor(new Color(130 + monoChannel, 130 + monoChannel, 130 + monoChannel, 255));
		g.drawPolyline(new int[] { i, qLength - i, qLength - i }, new int[] { height - i, height - i, i }, 3);
		g.fillArc(width - height + i, i, height - 2 * i, height - 2 * i, 225, 180);
	}
	g.fillRect(5, 5, qLength - 9, height - 9);
	g.fillOval(width - height + 5, 5, height - 10, height - 10);
	return bi;
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:17,代码来源:DefaultIcons.java

示例5: createOverlayImage

import java.awt.Graphics; //导入方法依赖的package包/类
private void createOverlayImage() {
	int height = getBounds().height * 2, width = getBounds().width * 2, qLength = width - (height * 4) / 5, qHeight = (height * 4) / 5, yOffs = (height - qHeight) / 2;
	overlayedShading = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR);
	Color[] shades = new Color[7], lights = new Color[7];
	for (int i = 0; i < shades.length; i++) {
		shades[i] = new Color(0, 0, 0, 160 - (i * 160) / shades.length);
		lights[i] = new Color(255, 255, 255, 200 - (i * 200) / lights.length);
	}
	Graphics g = overlayedShading.getGraphics();
	for (int i = 0; i < shades.length; i++) {
		g.setColor(lights[i]);
		g.drawPolyline(new int[] { i, i, qLength - i }, new int[] { height - i - yOffs, i + yOffs, i + yOffs }, 3);
		g.drawArc(width - height + i, i, height - 2 * i, height - 2 * i, 45 + 4 * i, 180 - 8 * i);
		g.setColor(shades[i]);
		g.drawPolyline(new int[] { i, qLength - i, qLength - i }, new int[] { height - i - yOffs, height - i - yOffs, i + yOffs }, 2);
		g.drawArc(width - height + i, i, height - 2 * i, height - 2 * i, 225 + 4 * i, 180 - 8 * i);
	}
	overlayedShading = overlayedShading.getScaledInstance(getBounds().width, getBounds().height, Image.SCALE_SMOOTH);
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:20,代码来源:SampleQNAnimation.java

示例6: paint

import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paint(Graphics g, HandleGesture gesture) {
	List<Handle> hs = getHandles(gesture);
	int[] xs = new int[hs.size()];
	int[] ys = new int[hs.size()];
	int i = -1;
	for (Handle h : hs) {
		i++;
		xs[i] = h.getX();
		ys[i] = h.getY();
	}

	if (setForFill(g)) {
		g.fillPolygon(xs, ys, xs.length);
	}
	if (setForStroke(g)) {
		if (closed)
			g.drawPolygon(xs, ys, xs.length);
		else
			g.drawPolyline(xs, ys, xs.length);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:23,代码来源:Poly.java

示例7: draw

import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void draw(Canvas canvas, Graphics g) {
	if (active) {
		g.setColor(Color.GRAY);
		int size = locations.size();
		int[] xs = new int[size];
		int[] ys = new int[size];
		for (int i = 0; i < size; i++) {
			Location loc = locations.get(i);
			xs[i] = loc.getX();
			ys[i] = loc.getY();
		}
		g.drawPolyline(xs, ys, size);
		int lastX = xs[xs.length - 1];
		int lastY = ys[ys.length - 1];
		g.fillOval(lastX - 2, lastY - 2, 4, 4);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:19,代码来源:PolyTool.java

示例8: paintNot

import java.awt.Graphics; //导入方法依赖的package包/类
static void paintNot(Graphics g, int x, int y, int width, int height) {
	int[] xp = new int[4];
	int[] yp = new int[4];
	xp[0] = x - 4;
	yp[0] = y;
	xp[1] = x - width;
	yp[1] = y - height / 2;
	xp[2] = x - width;
	yp[2] = y + height / 2;
	xp[3] = x - 4;
	yp[3] = y;
	g.drawPolyline(xp, yp, 4);
	g.drawOval(x - 4, y - 2, 4, 4);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:15,代码来源:Drawgates.java

示例9: paintInstance

import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paintInstance(InstancePainter painter) {
	Graphics g = painter.getGraphics();
	Bounds bds = painter.getInstance().getBounds();
	int x = bds.getX();
	int y = bds.getY();
	g.setColor(painter.getAttributeValue(StdAttr.ATTR_LABEL_COLOR));
	painter.drawLabel();
	g.setColor(Color.BLACK);
	boolean drawUp;
	if (painter.getShowState()) {
		ProgrammableGeneratorState state = getState(painter);
		painter.drawBounds(state.sending.getColor());
		drawUp = state.sending == Value.TRUE;
	} else {
		painter.drawBounds(Color.BLACK);
		drawUp = true;
	}
	g.setColor(Color.WHITE);
	x += 10;
	y += 10;
	int[] xs = { x + 1, x + 1, x + 4, x + 4, x + 7, x + 7 };
	int[] ys;
	if (drawUp) {
		ys = new int[] { y + 5, y + 3, y + 3, y + 7, y + 7, y + 5 };
	} else {
		ys = new int[] { y + 5, y + 7, y + 7, y + 3, y + 3, y + 5 };
	}
	g.drawPolyline(xs, ys, xs.length);
	GraphicsUtil.switchToWidth(g, 2);
	xs = new int[] { x - 6, x - 6, x + 1, x + 1, x - 5 };
	ys = new int[] { y + 6, y - 6, y - 6, y, y };
	g.drawPolyline(xs, ys, xs.length);
	painter.drawPorts();
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:36,代码来源:ProgrammableGenerator.java

示例10: paintIcon

import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paintIcon(InstancePainter painter) {
	Graphics g = painter.getGraphics();
	g.setColor(Color.black);
	if (painter.getGateShape() == AppPreferences.SHAPE_RECTANGULAR) {
		if (toolIconRect != null) {
			toolIconRect.paintIcon(painter.getDestination(), g, 2, 2);
		} else {
			g.drawRect(0, 2, 16, 16);
			GraphicsUtil.drawCenteredText(g, RECT_LABEL, 8, 8);
			g.drawOval(16, 8, 4, 4);
		}
	} else if (painter.getGateShape() == AppPreferences.SHAPE_DIN40700) {
		if (toolIconDin != null) {
			toolIconDin.paintIcon(painter.getDestination(), g, 2, 2);
		} else {
			g.drawRect(0, 2, 16, 16);
			GraphicsUtil.drawCenteredText(g, RECT_LABEL, 8, 8);
			g.drawOval(16, 8, 4, 4);
		}
	} else {
		if (toolIcon != null) {
			toolIcon.paintIcon(painter.getDestination(), g, 2, 2);
		} else {
			int[] xp = new int[4];
			int[] yp = new int[4];
			xp[0] = 15;
			yp[0] = 10;
			xp[1] = 1;
			yp[1] = 3;
			xp[2] = 1;
			yp[2] = 17;
			xp[3] = 15;
			yp[3] = 10;
			g.drawPolyline(xp, yp, 4);
			g.drawOval(15, 8, 4, 4);
		}
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:40,代码来源:NotGate.java

示例11: paintSingleInputgate

import java.awt.Graphics; //导入方法依赖的package包/类
static void paintSingleInputgate(Graphics g, int xpin, int y, int xinput, int youtput, boolean up) {
	int[] yPoints, xPoints;
	xPoints = new int[] { xpin, xpin, xinput };
	if (!up)
		yPoints = new int[] { y + AbstractTtlGate.height - AbstractTtlGate.pinheight, youtput, youtput };
	else
		yPoints = new int[] { y + AbstractTtlGate.pinheight, youtput, youtput };
	g.drawPolyline(xPoints, yPoints, 3);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:10,代码来源:Drawgates.java

示例12: paint

import java.awt.Graphics; //导入方法依赖的package包/类
@Override public void paint(Graphics graphics) {
	graphics.setColor(Color.BLACK);
	graphics.drawRect(10, 0, size.width-10, size.height);
	for(int input=0;input<inputs.length;input++) {
		Polygon polygon = new Polygon(POLYGONS_X[input], POLYGONS_Y[input], 7);
		polygon.translate(15, 4);
		if(inputs[input].isCharged()) {
			graphics.setColor(Color.RED);
			graphics.fillPolygon(polygon);
		}
		graphics.setColor(Color.BLACK);
		graphics.drawPolyline(polygon.xpoints, polygon.ypoints, polygon.npoints);
	}
	ContactUtilities.paintSolderingJoints(graphics, 10, 0, inputs);
}
 
开发者ID:kristian,项目名称:JDigitalSimulator,代码行数:16,代码来源:SevenSegmentDisplay.java

示例13: paint

import java.awt.Graphics; //导入方法依赖的package包/类
@Override public void paint(Graphics graphics) {
	graphics.setColor(Color.BLACK);
	graphics.drawRect(0, 0, size.width-5, size.height);
	int x=size.width-28, yt=size.height/2-2, yb=size.height/2;
	graphics.drawPolyline(new int[]{x , x+=2, x , x+=3, x , x+=3, x , x+=2, x , x+=2, x , x+=2},
			new int[]{yt, yt  , yb, yb  , yt, yt  , yb, yb  , yt, yt  , yb, yb  }, 12);
	ContactUtilities.paintSolderingJoints(graphics, contacts);
}
 
开发者ID:kristian,项目名称:JDigitalSimulator,代码行数:9,代码来源:Clock.java

示例14: paintAnd

import java.awt.Graphics; //导入方法依赖的package包/类
public static void paintAnd(Graphics g, int x, int y, int width, int height, boolean negated) {
	if (negated)
		paintNegatedOutput(g, x, y);
	int[] xp = new int[] { x - width / 2, x - width, x - width, x - width / 2 };
	int[] yp = new int[] { y - width / 2, y - width / 2, y + width / 2, y + width / 2 };
	GraphicsUtil.drawCenteredArc(g, x - width / 2, y, width / 2, -90, 180);

	g.drawPolyline(xp, yp, 4);
	if (height > width) {
		g.drawLine(x - width, y - height / 2, x - width, y + height / 2);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:13,代码来源:Drawgates.java

示例15: drawArrow

import java.awt.Graphics; //导入方法依赖的package包/类
static public void drawArrow(Graphics g, int x0, int y0, int x1, int y1, int headLength, int headAngle) {
	double offs = headAngle * Math.PI / 180.0;
	double angle = Math.atan2(y0 - y1, x0 - x1);
	int[] xs = { x1 + (int) (headLength * Math.cos(angle + offs)), x1,
			x1 + (int) (headLength * Math.cos(angle - offs)) };
	int[] ys = { y1 + (int) (headLength * Math.sin(angle + offs)), y1,
			y1 + (int) (headLength * Math.sin(angle - offs)) };
	g.drawLine(x0, y0, x1, y1);
	g.drawPolyline(xs, ys, 3);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:11,代码来源:GraphicsUtil.java


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