本文整理了Java中java.awt.Polygon.translate()
方法的一些代码示例,展示了Polygon.translate()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Polygon.translate()
方法的具体详情如下:
包路径:java.awt.Polygon
类名称:Polygon
方法名:translate
[英]Translates the vertices of the Polygon
by deltaX
along the x axis and by deltaY
along the y axis.
[中]将Polygon
的顶点沿x轴平移deltaX
,沿y轴平移deltaY
。
代码示例来源:origin: Activiti/Activiti
yPoints,
5);
pentagon.translate(x + width / 2,
y + width / 2);
代码示例来源:origin: stackoverflow.com
this.setPreferredSize(new Dimension(700, 700));
this.setBackground(Color.white);
p1.translate(-50, +100);
p2.translate(-100, -100);
代码示例来源:origin: MegaMek/megamek
@Override
public void translate(int deltaX, int deltaY) {
super.translate(deltaX, deltaY);
hotArea.translate(deltaX, deltaY);
}
代码示例来源:origin: com.harium/etyl
public void setLocation(int mx, int my) {
int difx = mx;
int dify = my;
polygon.translate(difx-cursorX, dify-cursorY);
cursorX = difx;
cursorY = dify;
}
代码示例来源:origin: org.integratedmodelling/klab-engine
@Override
public final void translate(int x, int y) {
bbox = null;
super.translate(x, y);
}
}
代码示例来源:origin: MegaMek/megamek
public void translate(int x, int y) {
areaShape.translate(x, y);
}
代码示例来源:origin: MegaMek/megamek
public void translate(int x, int y) {
areaShape.translate(x, y);
}
代码示例来源:origin: stackoverflow.com
Polygon newPolygon = new Polygon(oldPolygon.xpoints, oldPolygon.ypoints, oldPolygon.npoints);
newPolygon.translate(newXPos, newYPos);
代码示例来源:origin: triplea-game/triplea
/**
* Returns a new polygon that is a copy of {@code polygon} translated by {@code deltaX} along the x-axis and by
* {@code deltaY} along the y-axis.
*/
public static Polygon translatePolygon(final Polygon polygon, final int deltaX, final int deltaY) {
checkNotNull(polygon);
final Polygon translatedPolygon = new Polygon(polygon.xpoints, polygon.ypoints, polygon.npoints);
translatedPolygon.translate(deltaX, deltaY);
return translatedPolygon;
}
}
代码示例来源:origin: MegaMek/megamek
@Override
public void drawOnto(Graphics g, int x, int y, ImageObserver observer) {
Polygon drawPoly = new Polygon(attackPoly.xpoints,
attackPoly.ypoints, attackPoly.npoints);
drawPoly.translate(x, y);
g.setColor(attackColor);
g.fillPolygon(drawPoly);
g.setColor(Color.gray.darker());
g.drawPolygon(drawPoly);
}
代码示例来源:origin: MegaMek/megamek
@Override
public void drawOnto(Graphics g, int x, int y, ImageObserver observer) {
// don't draw anything if the unit has no velocity
if (vel == 0) {
return;
}
Polygon drawPoly = new Polygon(movePoly.xpoints, movePoly.ypoints,
movePoly.npoints);
drawPoly.translate(x, y);
g.setColor(moveColor);
g.fillPolygon(drawPoly);
g.setColor(Color.gray.darker());
g.drawPolygon(drawPoly);
}
代码示例来源:origin: MegaMek/megamek
@Override
public void drawOnto(Graphics g, int x, int y, ImageObserver observer) {
Polygon drawPoly = new Polygon(c3Poly.xpoints, c3Poly.ypoints,
c3Poly.npoints);
drawPoly.translate(x, y);
g.setColor(spriteColor);
g.fillPolygon(drawPoly);
g.setColor(Color.black);
g.drawPolygon(drawPoly);
}
代码示例来源:origin: stackoverflow.com
public Polygon getPoly() {
Polygon poly = new Polygon(new float[] {
position.x - (width / 2), position.y + (width / 2),
position.x + (width / 2), position.y + (width / 2),
position.x + (width / 2), position.y - (width / 2),
position.x - (width / 2), position.y - (width / 2)
});
poly.setOrigin(position.x, position.y);
poly.setRotation(getRotation());
poly.translate(width / 2, width / 2);
return new Polygon(poly.getTransformedVertices());
}
代码示例来源:origin: nz.ac.waikato.cms.weka.thirdparty/bounce
protected void drawClosedFold(Graphics g, int x, int y) {
Polygon polygon = new Polygon();
polygon.addPoint(0, 1);
polygon.addPoint(8, 1);
polygon.addPoint(8, 9);
polygon.addPoint(0, 9);
polygon.translate(x, y);
g.drawPolygon(polygon);
g.drawLine(x + 2, y + 5, x + 6, y + 5);
g.drawLine(x + 4, y + 3, x + 4, y + 7);
}
}
代码示例来源:origin: org.java.net.substance/substance
/**
* Creates the crayons.
* @return Array of crayons in z-order from bottom to top.
*/
protected Crayon[] createCrayons() {
Color[] colors = DefaultPalettes.CRAYONS;
crayons = new Crayon[colors.length];
for (int i=0; i < colors.length; i++) {
crayons[i] = new Crayon(
colors[i],
UIManager.getString("ColorChooser.crayon."+Integer.toHexString(0xff000000|colors[i].getRGB()).substring(2)),
new Polygon((int[]) crayonXPoints.clone(), (int[]) crayonYPoints.clone(), crayonXPoints.length));
crayons[i].shape.translate(
(i % 8) * 22 + 4 +((i / 8) % 2) * 11,
(i / 8) * 20 + 23
);
}
return crayons;
}
代码示例来源:origin: stackoverflow.com
// load the image
BufferedImage originalImage = ImageIO.read(...);
// create the polygon
Polygon polygon = new Polygon();
polygon.addPoint(50, 50);
polygon.addPoint(150, 50);
polygon.addPoint(250, 150);
polygon.addPoint(150, 150);
Rectangle bounds = polygon.getBounds();
// create a transparent clipped image based on the bounds of the Polygon
BufferedImage clippedImage = new BufferedImage(bounds.width, bounds.height, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = clippedImage.createGraphics();
polygon.translate(-bounds.x, -bounds.y);
g.setClip(polygon);
g.drawImage(originalImage, -bounds.x, -bounds.y, null);
// save the clipped image
ImageIO.write(...);
代码示例来源:origin: com.bbossgroups.activiti/activiti-engine
public void drawEventBasedGateway(int x, int y, int width, int height) {
// rhombus
drawGateway(x, y, width, height);
double scale = .6;
drawCatchingEvent((int)(x + width*(1-scale)/2), (int)(y + height*(1-scale)/2), (int)(width*scale), (int)(height*scale), false, null);
double r = width / 6.;
// create pentagon (coords with respect to center)
int topX = (int)(.95 * r); // top right corner
int topY = (int)(-.31 * r);
int bottomX = (int)(.59 * r); // bottom right corner
int bottomY = (int)(.81 * r);
int[] xPoints = new int[]{ 0, topX, bottomX, -bottomX, -topX };
int[] yPoints = new int[]{ -(int)r, topY, bottomY, bottomY, topY };
Polygon pentagon = new Polygon(xPoints, yPoints, 5);
pentagon.translate(x+width/2, y+width/2);
// draw
g.drawPolygon(pentagon);
}
代码示例来源:origin: nz.ac.waikato.cms.weka.thirdparty/bounce
protected void drawOpenFold(Graphics g, int x, int y) {
Polygon polygon = new Polygon();
polygon.addPoint(0, 1);
polygon.addPoint(8, 1);
polygon.addPoint(8, 9);
polygon.addPoint(0, 9);
polygon.translate(x, y);
g.drawPolygon(polygon);
g.drawLine(x + 2, y + 5, x + 6, y + 5);
}
代码示例来源:origin: MegaMek/megamek
@Override
public Rectangle getBounds() {
makePoly();
// set bounds
bounds = new Rectangle(c3Poly.getBounds());
bounds.setSize(bounds.getSize().width + 1,
bounds.getSize().height + 1);
// move poly to upper right of image
c3Poly.translate(-bounds.getLocation().x, -bounds.getLocation().y);
image = null;
return bounds;
}
代码示例来源:origin: de.biomedical-imaging.ij/ij_blob
private void fitEllipse(){
if(fittedEllipse==null){
fittedEllipse = new EllipseFitter();
Rectangle r = outerContour.getBounds();
ImagePlus help = NewImage.createByteImage("", r.width+1, r.height+1, 1, NewImage.FILL_WHITE);
ByteProcessor ip = (ByteProcessor) help.getProcessor();
ip.setColor(Color.black);
Polygon p = new Polygon(outerContour.xpoints, outerContour.ypoints, outerContour.npoints);
p.translate(-r.x, -r.y);
ip.resetRoi();
ip.setRoi(p);
fittedEllipse.fit(ip, null);
}
}
内容来源于网络,如有侵权,请联系作者删除!