Package java.awt

Examples of java.awt.Polygon$PolygonPathIterator


      // Test filter
      double compareZoomFactor = 2.75;

      ManualMapFilter filter = new ManualMapFilter(battleId);
      filter.showPolygon(new Polygon(new int[] { 5, 25, 25, 5 },
          new int[] { 5, 5, 25, 25 }, 4));
      filter.hidePolygon(new Polygon(new int[] { 5, 25, 25, 5 },
          new int[] { 5, 5, 25, 25 }, 4));

      CampaignClient.getInstance().addBean(filter);
      UniqueID filterId = filter.getId();

      mapFiltered.setFilter(filterId);
      filter = CampaignClient.getInstance()
          .getBean(filterId, waitingTime);

      BufferedImage filteredImage = new BufferedImage(
          (int) (mapFiltered.getWidth() * compareZoomFactor),
          (int) (mapFiltered.getHeight() * compareZoomFactor),
          BufferedImage.TYPE_INT_ARGB);

      BufferedImage targetFilteredImage = new BufferedImage(
          (int) (mapFiltered.getWidth() * 2.75),
          (int) (mapFiltered.getHeight() * 2.75),
          BufferedImage.TYPE_INT_ARGB);

      ManualMapFilter targetFilter = new ManualMapFilter(battleId);

      Graphics2D g = (Graphics2D) filteredImage.getGraphics();
      mapFiltered.drawBackground(g);
      mapFiltered.drawFilter(g, true);
      g.dispose();

      g = (Graphics2D) targetFilteredImage.getGraphics();
      AffineTransform transform = new AffineTransform();
      transform.scale(2.75, 2.75);
      g.drawImage(targetImages, transform, null);
      targetFilter.draw(g, 2.75, true);
      g.dispose();

      assertTrue("Images filter should be same",
          compareImage(filteredImage, targetFilteredImage));

      // Change filter
      Polygon showPolygon = new Polygon(new int[] { 15, 50, 50, 15 },
          new int[] { 15, 15, 50, 50 }, 4);
      filter.showPolygon(showPolygon);
      targetFilter.showPolygon(showPolygon);
      sleep();

      BufferedImage filteredShowImage = new BufferedImage(
          (int) (mapFiltered.getWidth() * 0.75),
          (int) (mapFiltered.getHeight() * 0.75),
          BufferedImage.TYPE_INT_ARGB);

      BufferedImage targetFilteredShowImage = new BufferedImage(
          (int) (mapFiltered.getWidth() * 0.75),
          (int) (mapFiltered.getHeight() * 0.75),
          BufferedImage.TYPE_INT_ARGB);

      g = (Graphics2D) filteredShowImage.getGraphics();
      mapFiltered.drawBackground(g);
      mapFiltered.drawFilter(g, true);
      g.dispose();

      g = (Graphics2D) targetFilteredShowImage.getGraphics();
      transform = new AffineTransform();
      transform.scale(0.75, 0.75);
      g.drawImage(targetImages, transform, null);
      targetFilter.draw(g, 0.75, true);
      g.dispose();

      assertTrue("Images filter should be same",
          compareImage(filteredShowImage, targetFilteredShowImage));

      // Compare with previous filter, should have changed
      filteredShowImage = new BufferedImage(
          (int) (mapFiltered.getWidth() * compareZoomFactor),
          (int) (mapFiltered.getHeight() * compareZoomFactor),
          BufferedImage.TYPE_INT_ARGB);

      g = (Graphics2D) filteredShowImage.getGraphics();
      mapFiltered.drawBackground(g);
      mapFiltered.drawFilter(g, true);
      g.dispose();

      assertTrue("Images filter should not be same",
          !compareImage(filteredShowImage, filteredImage));

      // Change filter
      Polygon hidePolygon = new Polygon(new int[] { 15, 20, 20, 15 },
          new int[] { 15, 15, 20, 20 }, 4);
      filter.hidePolygon(hidePolygon);
      targetFilter.hidePolygon(hidePolygon);
      sleep();

View Full Code Here


    BufferedImage steeringWheel = painter.createSteeringWheel((int)Math.rint(bounds.getWidth()), castValue);
    BufferedImage merge = new BufferedImage(bounds.width, bounds.height, BufferedImage.TYPE_INT_ARGB);
    Graphics drawG = merge.getGraphics();
    drawG.drawImage(steeringWheel, 0, 0, null);
    g.drawImage(merge, bounds.x, bounds.y, null);
    Polygon poly = painter.getSteeringWheelHandle((int)Math.rint(getPreferredSize().getWidth()), castValue());
    poly.translate(bounds.x, bounds.y);
    handle = poly;
    if (!paintLabels()) paintCurrentLabel(g, (int)Math.rint(castValue(getSelectedIndex())));
    else paintLabels(g);
  }
View Full Code Here

  /**
   * Paint the label over the center of the tracker handle (commonly known as thumb)
   */
  private void paintHorizontalLabel(Graphics g, int value) {
    Rectangle bounds = getBounds();
    Polygon poly = painter.getSteeringWheelHandle((int)Math.rint(bounds.getWidth()), castValue(value));
    poly.translate(bounds.x, bounds.y)
    Rectangle rect = poly.getBounds();
    Label label = new Label(metric);
    label.setText(getItem(value));
    label.setFont(getFont());
    paintLabelAt(g, label, rect);
  }
View Full Code Here

            graph.fillRect(0, 0, bounds.width, bounds.height);

            // setup some variables
            final Point stepPos = getHexLocation(step.getPosition());
            stepPos.translate(-bounds.x, -bounds.y);
            final Polygon facingPoly = facingPolys[step.getFacing()];
            final Polygon movePoly = movementPolys[step.getFacing()];
            Point offsetCostPos;
            Polygon myPoly;
            Color col;
            // set color
            switch (step.getMovementType()) {
            case IEntityMovementType.MOVE_RUN:
            case IEntityMovementType.MOVE_VTOL_RUN:
            case IEntityMovementType.MOVE_OVER_THRUST:
                if (step.isUsingMASC()) {
                    col = GUIPreferences.getInstance().getColor(
                            "AdvancedMoveMASCColor");
                } else {
                    col = GUIPreferences.getInstance().getColor(
                            "AdvancedMoveRunColor");
                }
                break;
            case IEntityMovementType.MOVE_JUMP:
                col = GUIPreferences.getInstance().getColor(
                        "AdvancedMoveJumpColor");
                break;
            case IEntityMovementType.MOVE_ILLEGAL:
                col = GUIPreferences.getInstance().getColor(
                        "AdvancedMoveIllegalColor");
                break;
            default:
                if (step.getType() == MovePath.STEP_BACKWARDS) {
                    col = GUIPreferences.getInstance().getColor(
                            "AdvancedMoveBackColor");
                } else {
                    col = GUIPreferences.getInstance().getColor(
                            "AdvancedMoveDefaultColor");
                }
            break;
            }

            if(game.useVectorMove()) {
                drawActiveVectors(step, stepPos, graph);
            }

            drawConditions(step, stepPos, graph, col);

            // draw arrows and cost for the step
            switch (step.getType()) {
            case MovePath.STEP_FORWARDS:
            case MovePath.STEP_SWIM:
            case MovePath.STEP_BACKWARDS:
            case MovePath.STEP_CHARGE:
            case MovePath.STEP_DFA:
            case MovePath.STEP_LATERAL_LEFT:
            case MovePath.STEP_LATERAL_RIGHT:
            case MovePath.STEP_LATERAL_LEFT_BACKWARDS:
            case MovePath.STEP_LATERAL_RIGHT_BACKWARDS:
            case MovePath.STEP_DEC:
            case MovePath.STEP_DECN:
            case MovePath.STEP_ACC:
            case MovePath.STEP_ACCN:
            case MovePath.STEP_LOOP:
                // draw arrows showing them entering the next
                myPoly = new Polygon(movePoly.xpoints, movePoly.ypoints,
                        movePoly.npoints);
                graph.setColor(Color.darkGray);
                myPoly.translate(stepPos.x + 1, stepPos.y + 1);
                graph.drawPolygon(myPoly);
                graph.setColor(col);
                myPoly.translate(-1, -1);
                graph.drawPolygon(myPoly);
                // draw movement cost
                drawMovementCost(step, stepPos, graph, col, true);
                drawRemainingVelocity(step, stepPos, graph, true);
                break;
            case MovePath.STEP_GO_PRONE:
            case MovePath.STEP_HULL_DOWN:
            case MovePath.STEP_DOWN:
            case MovePath.STEP_DIG_IN:
            case MovePath.STEP_FORTIFY:
                //draw arrow indicating dropping prone
                // also doubles as the descent indication
                Polygon downPoly = movementPolys[7];
                myPoly = new Polygon(downPoly.xpoints, downPoly.ypoints,
                        downPoly.npoints);
                graph.setColor(Color.darkGray);
                myPoly.translate(stepPos.x, stepPos.y);
                graph.drawPolygon(myPoly);
                graph.setColor(col);
                myPoly.translate(-1, -1);
                graph.drawPolygon(myPoly);
                offsetCostPos = new Point(stepPos.x + 1, stepPos.y + 15);
                drawMovementCost(step, offsetCostPos, graph, col, false);
                drawRemainingVelocity(step, stepPos, graph, true);
                break;
            case MovePath.STEP_GET_UP:
            case MovePath.STEP_UP:
            case MovePath.STEP_CAREFUL_STAND:
                // draw arrow indicating standing up
                // also doubles as the climb indication
                // and triples as deceleration
                Polygon upPoly = movementPolys[6];
                myPoly = new Polygon(upPoly.xpoints, upPoly.ypoints,
                        upPoly.npoints);
                graph.setColor(Color.darkGray);
                myPoly.translate(stepPos.x, stepPos.y);
                graph.drawPolygon(myPoly);
                graph.setColor(col);
                myPoly.translate(-1, -1);
                graph.drawPolygon(myPoly);
                offsetCostPos = new Point(stepPos.x, stepPos.y + 15);
                drawMovementCost(step, offsetCostPos, graph, col, false);
                drawRemainingVelocity(step, stepPos, graph, true);
                break;
            case MovePath.STEP_CLIMB_MODE_ON:
                // draw climb mode indicator
                String climb;
                if (step.getParent().getEntity().getMovementMode() == IEntityMovementMode.WIGE) {
                    climb = Messages.getString("BoardView1.WIGEClimb"); //$NON-NLS-1$
                } else {
                    climb = Messages.getString("BoardView1.Climb"); //$NON-NLS-1$
                }
                if (step.isPastDanger()) {
                    climb = "(" + climb + ")"; //$NON-NLS-1$ //$NON-NLS-2$
                }
                graph.setFont(new Font("SansSerif", Font.PLAIN, 12)); //$NON-NLS-1$
                int climbX = stepPos.x
                + 42
                - (graph.getFontMetrics(graph.getFont())
                        .stringWidth(climb) / 2);
                graph.setColor(Color.darkGray);
                graph.drawString(climb, climbX, stepPos.y + 39);
                graph.setColor(col);
                graph.drawString(climb, climbX - 1, stepPos.y + 38);
                break;
            case MovePath.STEP_CLIMB_MODE_OFF:
                // cancel climb mode indicator
                String climboff;
                if (step.getParent().getEntity().getMovementMode() == IEntityMovementMode.WIGE) {
                    climboff = Messages.getString("BoardView1.WIGEClimbOff"); //$NON-NLS-1$
                } else {
                    climboff = Messages.getString("BoardView1.ClimbOff"); //$NON-NLS-1$
                }
                if (step.isPastDanger()) {
                    climboff = "(" + climboff + ")"; //$NON-NLS-1$ //$NON-NLS-2$
                }
                graph.setFont(new Font("SansSerif", Font.PLAIN, 12)); //$NON-NLS-1$
                int climboffX = stepPos.x
                + 42
                - (graph.getFontMetrics(graph.getFont())
                        .stringWidth(climboff) / 2);
                graph.setColor(Color.darkGray);
                graph.drawString(climboff, climboffX, stepPos.y + 39);
                graph.setColor(col);
                graph.drawString(climboff, climboffX - 1, stepPos.y + 38);
                break;
            case MovePath.STEP_TURN_LEFT:
            case MovePath.STEP_TURN_RIGHT:
            case MovePath.STEP_THRUST:
            case MovePath.STEP_YAW:
            case MovePath.STEP_EVADE:
            case MovePath.STEP_ROLL:
                // draw arrows showing the facing
                myPoly = new Polygon(facingPoly.xpoints,
                        facingPoly.ypoints, facingPoly.npoints);
                graph.setColor(Color.darkGray);
                myPoly.translate(stepPos.x + 1, stepPos.y + 1);
                graph.drawPolygon(myPoly);
                graph.setColor(col);
View Full Code Here

            masterId = m.getId();
            spriteColor = PlayerColors.getColor(e.getOwner()
                    .getColorIndex());

            if ((e.getPosition() == null) || (m.getPosition() == null)) {
                C3Poly = new Polygon();
                C3Poly.addPoint(0, 0);
                C3Poly.addPoint(1, 0);
                C3Poly.addPoint(0, 1);
                bounds = new Rectangle(C3Poly.getBounds());
                bounds.setSize(bounds.getSize().width + 1,
View Full Code Here

            final double an = (entityE.getPosition().radian(
                    entityM.getPosition()) + (Math.PI * 1.5))
                    % (Math.PI * 2); // angle
            final double lw = scale * C3_LINE_WIDTH; // line width

            C3Poly = new Polygon();
            C3Poly.addPoint(a.x
                    + (int) (scale * (HEX_W / 2) - (int) Math.round(Math
                            .sin(an)
                            * lw)), a.y
                            + (int) (scale * (HEX_H / 2) + (int) Math.round(Math
View Full Code Here

        @Override
        public void drawOnto(Graphics g, int x, int y, ImageObserver observer) {
            // makePoly();

            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);
View Full Code Here

            graph.fillRect(0, 0, bounds.width, bounds.height);

            // setup some variables
            final Point stepPos = getHexLocation(step.getPosition());
            stepPos.translate(-bounds.x, -bounds.y);
            final Polygon facingPoly = facingPolys[step.getFacing()];
            final Polygon movePoly = movementPolys[step.getFacing()];
            Point offsetCostPos;
            Polygon myPoly;
            Color col;
            // set color
            switch (step.getMovementType()) {
            case IEntityMovementType.MOVE_RUN:
            case IEntityMovementType.MOVE_VTOL_RUN:
            case IEntityMovementType.MOVE_OVER_THRUST:
                if (step.isUsingMASC()) {
                    col = GUIPreferences.getInstance().getColor("AdvancedMoveMASCColor");
                } else {
                    col = GUIPreferences.getInstance().getColor("AdvancedMoveRunColor");
                }
                break;
            case IEntityMovementType.MOVE_JUMP:
                col = GUIPreferences.getInstance().getColor("AdvancedMoveJumpColor");
                break;
            case IEntityMovementType.MOVE_ILLEGAL:
                col = GUIPreferences.getInstance().getColor("AdvancedMoveIllegalColor");
                break;
            default:
                if (step.getType() == MovePath.STEP_BACKWARDS) {
                    col = GUIPreferences.getInstance().getColor("AdvancedMoveBackColor");
                } else {
                    col = GUIPreferences.getInstance().getColor("AdvancedMoveDefaultColor");
                }
                break;
            }

            if (game.useVectorMove()) {
                drawActiveVectors(step, stepPos, graph);
            }

            drawConditions(step, stepPos, graph, col);

            // draw arrows and cost for the step
            switch (step.getType()) {
            case MovePath.STEP_FORWARDS:
            case MovePath.STEP_SWIM:
            case MovePath.STEP_BACKWARDS:
            case MovePath.STEP_CHARGE:
            case MovePath.STEP_DFA:
            case MovePath.STEP_LATERAL_LEFT:
            case MovePath.STEP_LATERAL_RIGHT:
            case MovePath.STEP_LATERAL_LEFT_BACKWARDS:
            case MovePath.STEP_LATERAL_RIGHT_BACKWARDS:
            case MovePath.STEP_DEC:
            case MovePath.STEP_DECN:
            case MovePath.STEP_ACC:
            case MovePath.STEP_ACCN:
            case MovePath.STEP_LOOP:
                // draw arrows showing them entering the next
                myPoly = new Polygon(movePoly.xpoints, movePoly.ypoints, movePoly.npoints);
                graph.setColor(Color.darkGray);
                myPoly.translate(stepPos.x + 1, stepPos.y + 1);
                graph.drawPolygon(myPoly);
                graph.setColor(col);
                myPoly.translate(-1, -1);
                graph.drawPolygon(myPoly);
                // draw movement cost
                drawMovementCost(step, stepPos, graph, col, true);
                drawRemainingVelocity(step, stepPos, graph, true);
                break;
            case MovePath.STEP_GO_PRONE:
            case MovePath.STEP_HULL_DOWN:
            case MovePath.STEP_DOWN:
            case MovePath.STEP_DIG_IN:
            case MovePath.STEP_FORTIFY:
                // draw arrow indicating dropping prone
                // also doubles as the descent indication
                Polygon downPoly = movementPolys[7];
                myPoly = new Polygon(downPoly.xpoints, downPoly.ypoints, downPoly.npoints);
                graph.setColor(Color.darkGray);
                myPoly.translate(stepPos.x, stepPos.y);
                graph.drawPolygon(myPoly);
                graph.setColor(col);
                myPoly.translate(-1, -1);
                graph.drawPolygon(myPoly);
                offsetCostPos = new Point(stepPos.x + 1, stepPos.y + 15);
                drawMovementCost(step, offsetCostPos, graph, col, false);
                break;
            case MovePath.STEP_GET_UP:
            case MovePath.STEP_UP:
            case MovePath.STEP_CAREFUL_STAND:
                // draw arrow indicating standing up
                // also doubles as the climb indication
                Polygon upPoly = movementPolys[6];
                myPoly = new Polygon(upPoly.xpoints, upPoly.ypoints, upPoly.npoints);
                graph.setColor(Color.darkGray);
                myPoly.translate(stepPos.x, stepPos.y);
                graph.drawPolygon(myPoly);
                graph.setColor(col);
                myPoly.translate(-1, -1);
                graph.drawPolygon(myPoly);
                offsetCostPos = new Point(stepPos.x, stepPos.y + 15);
                drawMovementCost(step, offsetCostPos, graph, col, false);
                break;
            case MovePath.STEP_CLIMB_MODE_ON:
                // draw climb mode indicator
                String climb;
                if (step.getParent().getEntity().getMovementMode() == IEntityMovementMode.WIGE) {
                    climb = Messages.getString("BoardView1.WIGEClimb"); //$NON-NLS-1$
                } else {
                    climb = Messages.getString("BoardView1.Climb"); //$NON-NLS-1$
                }
                if (step.isPastDanger()) {
                    climb = "(" + climb + ")"; //$NON-NLS-1$ //$NON-NLS-2$
                }
                graph.setFont(new Font("SansSerif", Font.PLAIN, 12)); //$NON-NLS-1$
                int climbX = stepPos.x + 42
                        - (graph.getFontMetrics(graph.getFont()).stringWidth(climb) / 2);
                graph.setColor(Color.darkGray);
                graph.drawString(climb, climbX, stepPos.y + 39);
                graph.setColor(col);
                graph.drawString(climb, climbX - 1, stepPos.y + 38);
                break;
            case MovePath.STEP_CLIMB_MODE_OFF:
                // cancel climb mode indicator
                String climboff;
                if (step.getParent().getEntity().getMovementMode() == IEntityMovementMode.WIGE) {
                    climboff = Messages.getString("BoardView1.WIGEClimbOff"); //$NON-NLS-1$
                } else {
                    climboff = Messages.getString("BoardView1.ClimbOff"); //$NON-NLS-1$
                }
                if (step.isPastDanger()) {
                    climboff = "(" + climboff + ")"; //$NON-NLS-1$ //$NON-NLS-2$
                }
                graph.setFont(new Font("SansSerif", Font.PLAIN, 12)); //$NON-NLS-1$
                int climboffX = stepPos.x + 42
                        - (graph.getFontMetrics(graph.getFont()).stringWidth(climboff) / 2);
                graph.setColor(Color.darkGray);
                graph.drawString(climboff, climboffX, stepPos.y + 39);
                graph.setColor(col);
                graph.drawString(climboff, climboffX - 1, stepPos.y + 38);
                break;
            case MovePath.STEP_TURN_LEFT:
            case MovePath.STEP_TURN_RIGHT:
            case MovePath.STEP_THRUST:
            case MovePath.STEP_YAW:
            case MovePath.STEP_EVADE:
            case MovePath.STEP_ROLL:
                // draw arrows showing the facing
                myPoly = new Polygon(facingPoly.xpoints, facingPoly.ypoints, facingPoly.npoints);
                graph.setColor(Color.darkGray);
                myPoly.translate(stepPos.x + 1, stepPos.y + 1);
                graph.drawPolygon(myPoly);
                graph.setColor(col);
                myPoly.translate(-1, -1);
View Full Code Here

            entityId = e.getId();
            masterId = m.getId();
            spriteColor = PlayerColors.getColor(e.getOwner().getColorIndex());

            if ((e.getPosition() == null) || (m.getPosition() == null)) {
                c3Poly = new Polygon();
                c3Poly.addPoint(0, 0);
                c3Poly.addPoint(1, 0);
                c3Poly.addPoint(0, 1);
                bounds = new Rectangle(c3Poly.getBounds());
                bounds.setSize(bounds.getSize().width + 1, bounds.getSize().height + 1);
View Full Code Here

            final double an = (entityE.getPosition().radian(entityM.getPosition()) + (Math.PI * 1.5))
                    % (Math.PI * 2); // angle
            final double lw = scale * C3_LINE_WIDTH; // line width

            c3Poly = new Polygon();
            c3Poly.addPoint(
                    a.x + (int) (scale * (HEX_W / 2) - (int) Math.round(Math.sin(an) * lw)), a.y
                            + (int) (scale * (HEX_H / 2) + (int) Math.round(Math.cos(an) * lw)));
            c3Poly.addPoint(
                    a.x + (int) (scale * (HEX_W / 2) + (int) Math.round(Math.sin(an) * lw)), a.y
View Full Code Here

TOP

Related Classes of java.awt.Polygon$PolygonPathIterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.