Java Code Examples for java.awt.Polygon#translate()

The following examples show how to use java.awt.Polygon#translate() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MovementSprite.java    From megamek with GNU General Public License v2.0 6 votes vote down vote up
@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);

}
 
Example 2
Source File: DefaultProcessDiagramCanvas.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void drawEventBasedGateway(GraphicInfo graphicInfo, double scaleFactor) {
  // rhombus
  drawGateway(graphicInfo);
  
  if (scaleFactor == 1.0) {
    int x = (int) graphicInfo.getX();
    int y = (int) graphicInfo.getY();
    int width = (int) graphicInfo.getWidth();
    int height = (int) graphicInfo.getHeight();
    
    double scale = .6;
    
    GraphicInfo eventInfo = new GraphicInfo();
    eventInfo.setX(x + width*(1-scale)/2);
    eventInfo.setY(y + height*(1-scale)/2);
    eventInfo.setWidth(width*scale);
    eventInfo.setHeight(height*scale);
    drawCatchingEvent(eventInfo, true, null, "eventGateway", scaleFactor);
    
    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);
  }
}
 
Example 3
Source File: DefaultTabbedContainerUI.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public Polygon getExactTabIndication(int idx) {
    Polygon result = tabDisplayer.getUI().getExactTabIndication(idx);
    scratchPoint.setLocation(0,0);
    Point p = SwingUtilities.convertPoint(tabDisplayer, scratchPoint, container);
    result.translate (-p.x, -p.y);
    return appendContentBoundsTo(result);
}
 
Example 4
Source File: DefaultTabbedContainerUI.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public Polygon getInsertTabIndication(int idx) {
    Polygon result = tabDisplayer.getUI().getInsertTabIndication(idx);
    scratchPoint.setLocation(0,0);
    Point p = SwingUtilities.convertPoint(tabDisplayer, scratchPoint, container);
    result.translate (-p.x, -p.y);
    return appendContentBoundsTo(result);
}
 
Example 5
Source File: DefaultProcessDiagramCanvas.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public void drawEventBasedGateway(GraphicInfo graphicInfo, double scaleFactor) {
    // rhombus
    drawGateway(graphicInfo);

    if (scaleFactor == 1.0) {
        int x = (int) graphicInfo.getX();
        int y = (int) graphicInfo.getY();
        int width = (int) graphicInfo.getWidth();
        int height = (int) graphicInfo.getHeight();

        double scale = .6;

        GraphicInfo eventInfo = new GraphicInfo();
        eventInfo.setX(x + width * (1 - scale) / 2);
        eventInfo.setY(y + height * (1 - scale) / 2);
        eventInfo.setWidth(width * scale);
        eventInfo.setHeight(height * scale);
        drawCatchingEvent(eventInfo, true, null, "eventGateway", scaleFactor);

        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);
    }
}
 
Example 6
Source File: Util.java    From triplea with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 7
Source File: AttackSprite.java    From megamek with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example 8
Source File: C3Sprite.java    From megamek with GNU General Public License v2.0 5 votes vote down vote up
@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);
}