Example #1
0
  @Override
  public void draw(Graphics2D g2d, Surface s) {

    g2d.setPaint(getColor());
    g2d.fill(getSurface());

    if (getHover() && !selected) {
      Stroke outl = new BasicStroke(2f);
      g2d.setStroke(outl);
      if (getColor() != Color.red) g2d.setPaint(Color.red);
      else g2d.setPaint(Color.BLACK);
      g2d.drawPolygon(getSurface());
    } else if (selected) {
      float[] dash = {4f, 0f, 2f};
      BasicStroke outl =
          new BasicStroke(
              2f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1.0f, dash, getFramesAlive() * .2f);
      g2d.setStroke(outl);

      if (ownedby.equals(Player.NONE)) {
        g2d.setPaint(Color.black);
      } else if (ownedby.equals(Player.COMPUTER)) {
        g2d.setPaint(Color.RED);
      } else if (ownedby.equals(Player.PLAYER)) {
        g2d.setPaint(Color.BLUE);
      }

      g2d.drawPolygon(getSurface());
    }

    g2d.setPaint(Color.BLUE.brighter());
    for (Territory t : neighbors) {
      double distance;
      if (CalculateDistance(this.capital.x, this.capital.y, t.GetCapital().x, t.GetCapital().y)
          < 800) g2d.drawLine(this.capital.x, this.capital.y, t.GetCapital().x, t.GetCapital().y);
      else {
        if (CalculateDistance(this.capital.x, this.capital.y, 0, 0) < 500) {
          g2d.drawLine(this.capital.x, this.capital.y, 0, 70);
        } else if (CalculateDistance(this.capital.x, this.capital.y, 0, 0) > 500) {
          g2d.drawLine(this.capital.x, this.capital.y, 1280, 70);
        }
      }
    }

    if (ownedby.equals(Player.NONE)) {
      g2d.setPaint(Color.black);
    } else if (ownedby.equals(Player.COMPUTER)) {
      g2d.setPaint(Color.RED);
    } else if (ownedby.equals(Player.PLAYER)) {
      g2d.setPaint(Color.BLUE);
    }

    g2d.setFont(new Font("TimesRoman", Font.PLAIN, 18));
    g2d.setStroke(new BasicStroke(1f));
    g2d.fillOval(capital.x - 10, capital.y - 10, 20, 20);
    g2d.setPaint(Color.BLACK);
    g2d.drawOval(capital.x - 10, capital.y - 10, 20, 20);
    g2d.setPaint(Color.WHITE);
    g2d.drawString("" + armies, capital.x - 5, capital.y + 5);
  }
Example #2
0
  private void drawArrow(final int zoom, final Graphics2D g) {
    BasicStroke pen = new BasicStroke(2F, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER);
    Polygon p = new Polygon();
    double peakLength = 0.4;
    double tailThickness = 0.1;

    double length = 10 + (zoom - 15) * 10 / 4;
    double height = 4 + (zoom - 15) * 3 / 4;

    int ycenter = -(int) height / 2;

    p.addPoint(
        (int) (length * peakLength), (int) (ycenter + (height - (height * tailThickness)) / 2));
    p.addPoint((int) (length), (int) (ycenter + (height - (height * tailThickness)) / 2));

    p.addPoint((int) (length), ycenter);
    p.addPoint((int) ((length) + (length * peakLength)), (int) height / 2 + ycenter);
    p.addPoint((int) (length), (int) height + ycenter);

    p.addPoint(
        (int) (length),
        (int) (ycenter + (height - (height * tailThickness)) / 2 + (height * tailThickness)));
    p.addPoint(
        (int) (length * peakLength),
        (int) (ycenter + (height - (height * tailThickness)) / 2 + (height * tailThickness)));

    g.setStroke(pen);
    g.fillPolygon(p);
    g.drawPolygon(p);
  }
Example #3
0
  @Override
  public synchronized void draw(Graphics g, Transform t) {
    Graphics2D g2d = (Graphics2D) g;
    AffineTransform ord = g2d.getTransform();
    g2d.setTransform(t.getAffineTransform());

    float y1 = -length; // * t.scaling.y;
    float y2 = 0;
    if (reverse) {
      float tmp = y1;
      y1 = y2;
      y2 = tmp;
    }
    //		Vec2 p1 = Vec2.add(t.position, new Vec2(0,y1));
    //		Vec2 p2 = Vec2.add(t.position, new Vec2(width * t.scaling.x / 2, y2));//Vec2.mul(offset2,
    // t.scaling));
    //		Vec2 p3 = Vec2.add(t.position, new Vec2(-width * t.scaling.x / 2, y2));//Vec2.mul(offset3,
    // t.scaling));
    Vec2 p1 = new Vec2(0, y1);
    Vec2 p2 = new Vec2(width / 2, y2);
    Vec2 p3 = new Vec2(-width / 2, y2);

    int[] xPoints = new int[] {(int) p1.x, (int) p2.x, (int) p3.x};
    int[] yPoints = new int[] {(int) p1.y, (int) p2.y, (int) p3.y};
    g2d.drawPolygon(xPoints, yPoints, 3);
    g2d.setTransform(ord);
  }
Example #4
0
  /**
   * This method provides the implementation for rendering polygons. Note that it will go through
   * and render each part.
   */
  public void render(
      Graphics2D g2,
      double zoomScale,
      double viewportCenterX,
      double viewportCenterY,
      int panelWidth,
      int panelHeight) {
    // FOR ALL PARTS (POLYGONS)
    for (int a = 0; a < numParts; a++) {
      // DETERMINE HOW MANY POINTS ARE IN THIS PART
      int size = calculateSize(a);

      // AND FILL OUR POINTS ARRAYS WITH DATA
      this.fillData(
          a,
          size,
          xRenderData,
          yRenderData,
          zoomScale,
          viewportCenterX,
          viewportCenterY,
          panelWidth,
          panelHeight);

      // THEN USE THEM TO RENDER
      g2.setColor(fillColor);
      g2.fillPolygon(xRenderData, yRenderData, size);
      g2.setColor(lineColor);
      g2.drawPolygon(xRenderData, yRenderData, size);
    }
  }
Example #5
0
  // From: http://forum.java.sun.com/thread.jspa?threadID=378460&tstart=135
  void drawArrow(
      Graphics2D g2d,
      int xCenter,
      int yCenter,
      int x,
      int y,
      float stroke,
      BasicStroke drawStroke) {
    double aDir = Math.atan2(xCenter - x, yCenter - y);
    // Line can be dashed.
    g2d.setStroke(drawStroke);
    g2d.drawLine(x, y, xCenter, yCenter);
    // make the arrow head solid even if dash pattern has been specified
    g2d.setStroke(lineStroke);
    Polygon tmpPoly = new Polygon();
    int i1 = 12 + (int) (stroke * 2);
    // make the arrow head the same size regardless of the length length
    int i2 = 6 + (int) stroke;
    tmpPoly.addPoint(x, y);
    tmpPoly.addPoint(x + xCor(i1, aDir + .5), y + yCor(i1, aDir + .5));
    tmpPoly.addPoint(x + xCor(i2, aDir), y + yCor(i2, aDir));
    tmpPoly.addPoint(x + xCor(i1, aDir - .5), y + yCor(i1, aDir - .5));
    tmpPoly.addPoint(x, y); // arrow tip
    g2d.drawPolygon(tmpPoly);

    // Remove this line to leave arrow head unpainted:
    g2d.fillPolygon(tmpPoly);
  }
  public void drawMathObject(PolygonObject object, Graphics g, Point pageOrigin, float zoomLevel) {
    g.setColor(Color.BLACK);
    ScaledSizeAndPosition sap =
        getSizeAndPositionWithLineThickness(object, pageOrigin, zoomLevel, object.getThickness());

    Graphics2D g2d = (Graphics2D) g;

    g2d.setStroke(new BasicStroke(sap.getLineThickness()));

    Polygon p = new Polygon();

    GridPoint[] points = object.getAdjustedVertices();
    for (int i = 0; i < points.length; i++) {
      p.addPoint(
          (int) (points[i].getx() * sap.getWidth()) + sap.getxOrigin(),
          (int) (points[i].gety() * sap.getHeight()) + sap.getyOrigin());
    }

    if (object.getColor() != null) {
      g2d.setColor(object.getColor());
      g2d.fillPolygon(p);
      g2d.setColor(Color.BLACK);
    }

    g2d.drawPolygon(p);

    g2d.setStroke(new BasicStroke(1));
  }
 /** Draw the current map and pieces. */
 @Override
 protected void paintComponentMiddleLayer(
     final Graphics2D g2d, final int topLeftX, final int topLeftY) {
   g2d.setColor(Color.lightGray);
   // g2d.fillRect(0, 0, getWidth(), getHeight());
   g2d.fillRect(0, 0, m_model.getMaxWidth(), m_model.getMaxHeight());
   g2d.setColor(Color.white);
   g2d.fillRect(
       m_mapData.getBevelWidth(),
       m_mapData.getBevelHeight(),
       m_model.getMaxWidth() - (m_mapData.getBevelWidth() * 2),
       m_model.getMaxHeight() - (m_mapData.getBevelHeight() * 2));
   for (final Map.Entry<Territory, Polygon> entry :
       m_mapData.getTerritoryPolygons(m_gameData.getMap()).entrySet()) {
     final Polygon p = entry.getValue();
     final Territory at = entry.getKey();
     final Color backgroundColor = Color.WHITE;
     g2d.setColor(Color.black);
     final Image image = m_images.get(at);
     if (image != null) {
       final Rectangle square = p.getBounds();
       g2d.drawImage(
           image, square.x, square.y, square.width, square.height, backgroundColor, null);
     }
     g2d.drawPolygon(p);
   }
 }
  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);
  }
Example #9
0
  public void render(Vehicle vehicle) {
    Vector adjustedPosition = vehicle.position().add(viewPoint);
    int x = (int) adjustedPosition.x();
    int y = (int) adjustedPosition.y();

    Vector tip = new Vector(x + vehicle.boundingRadius(), y);
    Vector left = new Vector(x - 5, y - 5);
    Vector right = new Vector(x - 5, y + 5);

    int[] xPos = {(int) tip.x(), (int) left.x(), (int) right.x()};
    int[] yPos = {(int) tip.y(), (int) left.y(), (int) right.y()};

    AffineTransform orig = graphics.getTransform();

    AffineTransform rot =
        AffineTransform.getRotateInstance(vehicle.heading().x(), vehicle.heading().y(), x, y);
    graphics.transform(rot);
    graphics.drawPolygon(xPos, yPos, 3);
    graphics.setTransform(orig);

    if (showFeelers) {
      Vector[] feelers = createFeelersFor(vehicle);
      for (Vector feeler : feelers) {
        graphics.drawLine(x, y, (int) feeler.x(), (int) feeler.y());
      }
    }
    renderHealthBar(vehicle, x, y);
    renderEnergyBar(vehicle, x, y);
  }
Example #10
0
  public void StaticObjNew(StaticObj so) {
    Graphics2D g = radarArea.backImage.createGraphics();
    g.setColor(so_color);

    if (so instanceof Beacon) {
      g.drawOval(
          convPos(so.pos.x) - grid_size / 6,
          convPos(so.pos.y) - grid_size / 6,
          grid_size / 3,
          grid_size / 3);
      JLabel sol = new JLabel(Integer.toString(so.id));
      sol.setForeground(so_text_color);
      sol.setBounds(
          convPos(so.pos.x) + grid_size / 6, convPos(so.pos.y), grid_size / 3, grid_size / 2);
      radarArea.add(sol, new Integer(1));
    }

    if (so instanceof Airfield) {
      int xa[] = new int[3], ya[] = new int[3];
      int l1 = grid_size / 2, l2 = grid_size / 6;
      xa[0] = convPos(so.pos.x);
      ya[0] = convPos(so.pos.y);
      xa[1] = convPos(so.pos.x) - l1 * so.dir.x - l2 * so.dir.y;
      ya[1] = convPos(so.pos.y) - l1 * so.dir.y + l2 * so.dir.x;
      xa[2] = convPos(so.pos.x) - l1 * so.dir.x + l2 * so.dir.y;
      ya[2] = convPos(so.pos.y) - l1 * so.dir.y - l2 * so.dir.x;
      g.drawPolygon(xa, ya, 3);
      JLabel sol = new JLabel(Integer.toString(so.id));
      sol.setForeground(so_text_color);
      sol.setBounds(
          convPos(so.pos.x) + grid_size / 6, convPos(so.pos.y), grid_size / 3, grid_size / 2);
      radarArea.add(sol, new Integer(1));
    }

    if (so instanceof Exit) {
      g.drawRect(
          convPos(so.pos.x) - grid_size / 6,
          convPos(so.pos.y) - grid_size / 6,
          grid_size / 3,
          grid_size / 3);
      JLabel sol = new JLabel(Integer.toString(so.id));
      sol.setForeground(so_text_color);
      sol.setBounds(
          convPos(so.pos.x) + grid_size / 6, convPos(so.pos.y), grid_size / 3, grid_size / 2);
      radarArea.add(sol, new Integer(1));
    }

    if (so instanceof Line) {
      g.setColor(line_color);
      g.drawLine(
          convPos(((Line) so).pos.x),
          convPos(((Line) so).pos.y),
          convPos(((Line) so).second_end.x),
          convPos(((Line) so).second_end.y));
    }

    radarArea.backIcon = new ImageIcon(radarArea.backImage);
    radarArea.back.setIcon(radarArea.backIcon);
  }
  @Override
  public void paintLayer(Graphics2D g) {
    g.setRenderingHint(
        RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);

    g.setColor(new Color(0, 0, 255, 120));
    for (Polygon w : waters) {
      g.drawPolygon(w);
      g.fillPolygon(w);
    }
    g.setColor(new Color(0, 255, 0, 120));
    for (Polygon l : lands) {
      g.drawPolygon(l);
      g.fillPolygon(l);
    }
  }
Example #12
0
 public void paint(Graphics g) {
   Graphics2D g2 = (Graphics2D) g;
   g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
   g2.setColor(new Color(0, 224, 0));
   g2.fillPolygon(px, py, 4);
   g2.setColor(Color.BLACK);
   g2.drawPolygon(px, py, 4);
 }
 protected void paintComponent(Graphics g) {
   if (day == select.get(Calendar.DAY_OF_MONTH) && month == select.get(Calendar.MONTH)) {
     // 如果当前日期是选择日期,则高亮显示
     g.setColor(new Color(160, 185, 215));
     g.fillRect(0, 0, getWidth(), getHeight());
   }
   if (year == now.get(Calendar.YEAR)
       && month == now.get(Calendar.MONTH)
       && day == now.get(Calendar.DAY_OF_MONTH)) {
     // 如果日期和当前日期一样,则用红框
     Graphics2D gd = (Graphics2D) g;
     gd.setColor(Color.RED);
     Polygon p = new Polygon();
     p.addPoint(0, 0);
     p.addPoint(getWidth() - 1, 0);
     p.addPoint(getWidth() - 1, getHeight() - 1);
     p.addPoint(0, getHeight() - 1);
     gd.drawPolygon(p);
   }
   if (isSelected) { // 如果被选中了就画出一个虚线框出来
     Stroke s =
         new BasicStroke(
             1.0f,
             BasicStroke.CAP_SQUARE,
             BasicStroke.JOIN_BEVEL,
             1.0f,
             new float[] {2.0f, 2.0f},
             1.0f);
     Graphics2D gd = (Graphics2D) g;
     gd.setStroke(s);
     gd.setColor(Color.BLACK);
     Polygon p = new Polygon();
     p.addPoint(0, 0);
     p.addPoint(getWidth() - 1, 0);
     p.addPoint(getWidth() - 1, getHeight() - 1);
     p.addPoint(0, getHeight() - 1);
     gd.drawPolygon(p);
   }
   super.paintComponent(g);
 }
  @Override
  protected void drawImprecise(
      Graphics2D graphics, STRTransform transform, boolean transformUpdated) {
    if (transformUpdated) {
      transform.transformVertices(vertices, xPoints, yPoints);
    }

    if (filled) {
      graphics.fillPolygon(xPoints, yPoints, nVertices);
    } else {
      graphics.drawPolygon(xPoints, yPoints, nVertices);
    }
  }
Example #15
0
  void paint(Graphics2D g2) {
    for (int i = 0; i < 13; i++) {
      pXP[i] = (int) (xP[i] * Math.cos(g) - yP[i] * Math.sin(g) + x);
      pYP[i] = (int) (xP[i] * Math.sin(g) + yP[i] * Math.cos(g) + y);
    }
    ovn = new Polygon(pXP, this.pYP, 13);

    for (int i = 0; i < shots.size(); i++) {
      shots.get(i).paint(g2);
    }

    g2.setColor(Color.gray);
    g2.drawPolygon(ovn);
  }
Example #16
0
  /** Draw polygon. The coordinates are in logical coordinates. */
  public void drawPolygon(double[]... coord) {
    int[][] c = new int[coord.length][2];
    for (int i = 0; i < coord.length; i++) {
      c[i] = projection.screenProjection(coord[i]);
    }

    int[] x = new int[c.length];
    for (int i = 0; i < c.length; i++) {
      x[i] = c[i][0];
    }
    int[] y = new int[c.length];
    for (int i = 0; i < c.length; i++) {
      y[i] = c[i][1];
    }
    g2d.drawPolygon(x, y, c.length);
  }
  @Override
  public void paintIcon(Component c, Graphics g, int x, int y) {
    Graphics2D g2 = (Graphics2D) g;
    g2.setPaint(Color.BLACK);
    g2.translate(x, y);

    int[] xPoints = {6, 2, 6};
    int[] yPoints = {2, 6, 6};

    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    g2.drawPolygon(xPoints, yPoints, 3);
    g2.fillPolygon(xPoints, yPoints, 3);

    g2.translate(-x, -y);
  }
Example #18
0
  /**
   * paintComponent schreibt alle Laendernamen an die entsprechende Stelle der Landkarte
   * (Hintergrundgrafik) und zeichnet die Laendergrenzen auf der Landkarte nach.
   *
   * @param g Zeichenflaeche der Landkarte
   */
  public void paintComponent(Graphics g) {
    Shape shape;

    Graphics2D g2d = (Graphics2D) g;
    g2d.drawImage(img, 0, 0, this.getWidth(), this.getHeight(), this);
    Font myFont = new Font("Times New Roman", Font.BOLD, 12);
    g2d.setFont(myFont);

    g2d.setStroke(new BasicStroke(2.0f));

    Territory territory;
    Color color;

    ListIterator territories = worldMap.getTerritories().listIterator();

    while (territories.hasNext()) {
      territory = (Territory) territories.next();

      if (territory.getOwner() != null) {
        color = territory.getOwner().getPlayerColor();
      } else {
        color = Color.WHITE;
      }

      g2d.setColor(color);
      g2d.drawString(
          territory.getName(),
          (int) territory.getMidpoint().getX() - 15,
          (int) territory.getMidpoint().getY() - 10);

      g2d.drawString(
          new Integer(territory.getArmySize()).toString(),
          (int) territory.getMidpoint().getX(),
          (int) territory.getMidpoint().getY());
    }

    if (territoryBattle.size() != 0) {
      for (int j = 0; j < territoryBattle.size(); j++) {
        g2d.setColor(territoryBattle.get(j).getOwner().getPlayerColor());
        // g2d.fillPolygon(territoryTmp.getFrontiers());   Sieht bei unseren Grenzen nicht huebsch
        // aus
        g2d.drawPolygon(territoryBattle.get(j).getFrontiers());
      }
    }

    repaint();
  }
Example #19
0
 @Override
 public void drawPolygon(Vec2[] vertices, int vertexCount, Color3f color) {
   Color s = cpool.getColor(color.x, color.y, color.z, 1f);
   Graphics2D g = getGraphics();
   saveState(g);
   int[] xInts = xIntsPool.get(vertexCount);
   int[] yInts = yIntsPool.get(vertexCount);
   for (int i = 0; i < vertexCount; i++) {
     getWorldToScreenToOut(vertices[i], temp);
     xInts[i] = (int) temp.x;
     yInts[i] = (int) temp.y;
   }
   g.setStroke(stroke);
   g.setColor(s);
   g.drawPolygon(xInts, yInts, vertexCount);
   restoreState(g);
 }
Example #20
0
 // Taken from http://forum.java.sun.com/thread.jspa?threadID=378460&tstart=135
 public static void drawArrow(Graphics g, int xCenter, int yCenter, int x, int y) {
   Graphics2D g2d = (Graphics2D) g;
   double aDir = Math.atan2(xCenter - x, yCenter - y);
   // g2d.drawLine(x, y, xCenter, yCenter);
   g2d.setStroke(
       new BasicStroke(1f)); // make the arrow head solid even if dash pattern has been specified
   Polygon tmpPoly = new Polygon();
   int i1 = 12;
   int i2 = 6; // make the arrow head the same size regardless of the length length
   tmpPoly.addPoint(x, y); // arrow tip
   tmpPoly.addPoint(x + xCor(i1, aDir + 0.5), y + yCor(i1, aDir + 0.5));
   tmpPoly.addPoint(x + xCor(i2, aDir), y + yCor(i2, aDir));
   tmpPoly.addPoint(x + xCor(i1, aDir - 0.5), y + yCor(i1, aDir - 0.5));
   tmpPoly.addPoint(x, y); // arrow tip
   g2d.drawPolygon(tmpPoly);
   g2d.fillPolygon(tmpPoly); // remove this line to leave arrow head unpainted
 }
Example #21
0
  /**
   * Updates the arrow.
   *
   * @param x
   * @param y
   * @param dir
   */
  public void updateArrow(Coord coords) {
    Graphics2D surface = currentScreen.createGraphics();
    Polygon arrow = getArrow(coords);
    int mapHeight = ((mapLevel.getHeight() - 1) * ImageBank.FEATUREHEIGHT);

    // Redraw this square.
    surface.drawImage(
        createSquare(mapLevel.getMapSquare(coords)),
        null,
        coords.getX() * ImageBank.FEATUREWIDTH,
        mapHeight - (coords.getY() * ImageBank.FEATUREHEIGHT));

    // Overlay the arrow.
    surface.setColor(Color.RED);
    surface.fillPolygon(arrow);
    surface.setColor(Color.WHITE);
    surface.drawPolygon(arrow);

    surface.dispose();
  }
Example #22
0
  /**
   * Updates the whole map image.
   *
   * @param playerCoords Coordinates of the player.
   */
  private void updateMapImage(Coord playerCoords) {
    currentScreen =
        new BufferedImage(
            mapLevel.getWidth() * ImageBank.FEATUREWIDTH,
            mapLevel.getHeight() * ImageBank.FEATUREHEIGHT,
            BufferedImage.TYPE_INT_ARGB);
    Graphics2D surface = currentScreen.createGraphics();
    int mapHeight = ((mapLevel.getHeight() - 1) * ImageBank.FEATUREHEIGHT);

    surface.setColor(Color.GRAY);
    surface.fillRect(0, 0, currentScreen.getWidth(), currentScreen.getHeight());

    for (byte x = 0; x < mapLevel.getWidth(); x++) {
      for (byte y = 0; y < mapLevel.getHeight(); y++) {
        if (mapLevel.getMapSquare(x, y).isVisited()) {
          surface.drawImage(
              createSquare(mapLevel.getMapSquare(x, y)),
              null,
              x * ImageBank.FEATUREWIDTH,
              mapHeight - (y * ImageBank.FEATUREHEIGHT));
        }
      }
    }

    // draw player arrow.
    if (playerCoords.getZ() == mapLevel.getLevel()) {
      Polygon arrow = getArrow(playerCoords);
      surface.setColor(Color.RED);
      surface.fillPolygon(arrow);
      surface.setColor(Color.WHITE);
      surface.drawPolygon(arrow);
    }

    setPreferredSize(
        new Dimension(
            mapLevel.getWidth() * ImageBank.FEATUREWIDTH,
            mapLevel.getHeight() * ImageBank.FEATUREHEIGHT));
    revalidate();
  }
  private void renderTile(TileNode tileNode, Graphics2D g, float opacity) {

    // Do the actual Drawing here!
    Polygon tilePolygon = getHexTile(tileNode.pixelPoint);
    g.setColor(Color.BLACK);
    g.drawPolygon(
        tilePolygon); // This part kinda helps the tiles come together. Due to the math involved in
                      // rendering
    // The hex tiles, there are a few points where we have to cast to an int and lose precision.

    // Get the old clip (Should be the entire window).
    Shape oldClip = g.getClip();

    // Set the clip to just the hex tile
    g.setClip(tilePolygon);

    // Set the opacity.
    AlphaComposite acomp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opacity);
    g.setComposite(acomp);

    // Render the tile image.
    Image tileImage = tileNode.tile.getTileImage();
    int tileX = (int) (tileNode.pixelPoint.getX() - hexWidth / 2);
    int tileY = (int) (tileNode.pixelPoint.getY()) - hexHeight / 2;
    g.drawImage(tileImage, tileX, tileY, hexWidth, hexHeight, getDisplay());

    // Add this entity to list of entities and their locations to render its health later alligator
    if (tileNode.tile.getEntity() != null) {
      Entity entity = tileNode.tile.getEntity();
      Stats stats = entity.getStats();
      this.entityLocationTuples.add(
          new EntityLocationTuple(
              entity,
              new Point((int) tileNode.pixelPoint.getX(), (int) tileNode.pixelPoint.getY())));
      this.entityHealthMap.put(entity, stats.getStat(Stats.Type.HEALTH));
    }

    g.setClip(oldClip);
  }
Example #24
0
  @Override
  public void paint(Graphics graphics) {
    super.paint(graphics);

    Graphics2D g = (Graphics2D) graphics;

    if (shot != null) {
      for (Zone zone : shot.getZones().getZonesList()) {
        if (!"default-zone".equalsIgnoreCase(zone.getId())) {
          try {
            Polygon p = zone.getShape().getPolygon();

            if (zone.getId() == null) g.setColor(Color.BLUE);
            else if (zone.getId().equalsIgnoreCase("stumps")) g.setColor(Color.GREEN);
            else g.setColor(Color.RED);

            g.fillPolygon(p);
            g.setColor(g.getColor().darker());
            g.drawPolygon(p);
          } catch (Exception ex) {
            //					ex.printStackTrace();
          }
        }
      }
    }

    Stroke s = g.getStroke();
    g.setColor(Color.ORANGE);
    g.setStroke(new BasicStroke(5));
    g.drawRect(150, 250, 100, 150);
    g.setStroke(s);

    if (ballLoc != null) {
      g.setColor(Color.BLACK);
      g.fillOval((int) ballLoc.getX() - 5, (int) ballLoc.getY() - 5, 10, 10);
    }
  }
Example #25
0
  /*
   * Drawing SetCard
   */
  @Override
  protected void paintComponent(Graphics g) {
    super.paintComponent(g);

    Graphics2D gg = (Graphics2D) g;

    gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    gg.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);

    // For border
    int w = getWidth();
    int h = getHeight();

    int t = borderThickness;
    int arc = arcWidth;
    gg.setColor(BG_COLOR);
    gg.fillRoundRect(0, 0, w, h, arc, arc);
    gg.setColor(BORDER_COLOR);
    gg.setStroke(new BasicStroke(t)); // Set border thickness
    gg.drawRoundRect(t / 2, t / 2, w - t, h - t, arc, arc);

    gg.setStroke(new BasicStroke()); // Reset Stroke

    // For picture
    int xpoints[] = new int[4];
    int ypoints[] = new int[4];

    Color fillColor = new Color(colorVal[this.color]);

    int bgWidth = w;
    int bgHeight = h;
    gg.setColor(BG_COLOR);
    int count = this.number + 1;
    for (int i = 0; i < count; i++) {
      switch (this.shape) {
        case 0: // Diamond
          xpoints[0] = (int) (bgWidth * 0.2);
          xpoints[1] = (int) (bgWidth * 0.5);
          xpoints[2] = (int) (bgWidth * 0.8);
          xpoints[3] = (int) (bgWidth * 0.5);

          ypoints[0] = (int) (bgHeight * (i + .5) / count);
          ypoints[1] = (int) (bgHeight * (i + .5) / count - bgHeight / 10);
          ypoints[2] = (int) (bgHeight * (i + .5) / count);
          ypoints[3] = (int) (bgHeight * (i + .5) / count + bgHeight / 10);

          if (shade != 0) {
            gg.setColor(fillColor);
            gg.fillPolygon(xpoints, ypoints, 4);
            if (shade == 1) {
              gg.setColor(BG_COLOR);
              shadeCard(gg, i, count, bgWidth, bgHeight);
            }
          }

          gg.setColor(fillColor);
          for (int k = 0; k < 3; k++) {
            gg.drawPolygon(xpoints, ypoints, 4);
            for (int j = 0; j < 4; j++) {
              ypoints[j]++;
            }
          }

          break;
        case 1: // Oval
          if (shade != 0) {
            gg.setColor(fillColor);
            gg.fillOval(
                (int) (bgWidth * .2),
                (int) (bgHeight * (i + .5) / count - bgHeight / 9),
                (int) (bgWidth * .6),
                (int) (bgHeight / 6));
            if (shade == 1) {
              gg.setColor(BG_COLOR);
              shadeCard(gg, i, count, bgWidth, bgHeight);
            }
          }

          g.setColor(fillColor);
          for (int k = 0; k < 3; k++) {
            gg.drawOval(
                (int) (w * .2),
                (int) (bgHeight * (i + .5) / count - bgHeight / 9) + k,
                (int) (bgWidth * .6),
                (int) (bgHeight / 6));
          }
          break;
        case 2: // Squiggle OR BOX
          if (shade != 0) {
            gg.setColor(fillColor);
            gg.fillRect(
                (int) (bgWidth * 0.2),
                (int) (bgHeight * (i + .5) / count - 10),
                (int) (bgWidth * 0.6),
                20);
            if (shade == 1) {
              gg.setColor(BG_COLOR);
              shadeCard(gg, i, count, bgWidth, bgHeight);
            }
          }
          g.setColor(fillColor);
          for (int k = 0; k < 3; k++) {
            gg.drawRect(
                (int) (bgWidth * 0.2),
                (int) (bgHeight * (i + .5) / count - 10),
                (int) (bgWidth * 0.6),
                20);
            gg.setStroke(new BasicStroke(2.0f));
          }
          break;
      }
    }
  }
Example #26
0
  @Override
  public void paintComponent(Graphics g) {

    // check if something needs to be painted at all
    if (ready) {
      sPage = startState.getPage();
      myPage = sPage;
      ePage = endState.getPage();
    }
    // check if anything needs to be drawn
    if (ready && (sPage == currPage || ePage == currPage)) {
      Graphics2D g2D = (Graphics2D) g;

      g2D.setColor(color);

      // draw arrow head for non-stub transitions
      if (currPage == ePage && !stub) {
        // find angle between end point and end control point
        int dx = (int) endCtrlPt.getX() - (int) endPt.getX();
        int dy = (int) endCtrlPt.getY() - (int) endPt.getY();
        double alpha = 0;
        if (dx == 0) {
          if (dy <= 0) alpha = Math.PI / 2;
          else alpha = 3 * Math.PI / 2;
        } else if (dx > 0 && dy > 0) alpha = 2 * Math.PI - Math.atan((double) dy / dx);
        else if (dx > 0 && dy <= 0) {
          if (dy == 0) alpha = 0;
          else alpha = -Math.atan((double) dy / (dx));
        } else if (dx < 0) alpha = Math.PI - Math.atan((double) dy / dx);

        double adj = Math.PI / 6;
        int[] xP = {
          (int) endPt.getX(),
          (int) endPt.getX() + (int) (13 * Math.cos(alpha + adj)),
          (int) endPt.getX() + (int) (13 * Math.cos(alpha - adj))
        };
        int[] yP = {
          (int) endPt.getY(),
          (int) endPt.getY() - (int) (13 * Math.sin(alpha + adj)),
          (int) endPt.getY() - (int) (13 * Math.sin(alpha - adj))
        };
        g2D.drawPolygon(xP, yP, 3);
        g2D.fillPolygon(xP, yP, 3);
      }

      // draw stub
      if (currPage == sPage && stub) {
        g2D.drawLine(
            (int) startPt.getX(), (int) startPt.getY(), (int) pageS.getX(), (int) pageS.getY());
        int x = (int) pageS.getX();
        int y = (int) pageS.getY();
        double cos = Math.cos(angle);
        double sin = Math.sin(angle);

        g2D.drawLine(
            x - (int) Math.round(6 * sin + 7 * cos), y - (int) Math.round(6 * cos - 7 * sin), x, y);
        g2D.drawLine(
            x, y, x + (int) Math.round(6 * sin - 7 * cos), y + (int) Math.round(6 * cos + 7 * sin));

        FontMetrics fm = g2D.getFontMetrics();
        int width = fm.stringWidth(endState.getName());
        int height = fm.getHeight();
        g2D.drawString(
            endState.getName(),
            (int) (pageS.getX() + (12 + width / 2) * Math.cos(angle) - width / 2),
            (int) (pageS.getY() - 12 * Math.sin(angle) + height / 3));

        // draw control points if needed
        if (selectStatus != SelectOptions.NONE) {
          g2D.setColor(Color.red);
          g2D.fillRect((int) startPt.getX() - 3, (int) startPt.getY() - 3, 7, 7);
          g2D.fillRect((int) pageS.getX() - 3, (int) pageS.getY() - 3, 7, 7);
          g2D.setColor(color);
        }
      }

      // draw normal transition
      if (sPage == ePage && !stub) {
        g2D.draw(curve);

        // draw control points
        if (selectStatus != SelectOptions.NONE) {
          g2D.setColor(Color.red);
          g2D.fillRect((int) startPt.getX() - 3, (int) startPt.getY() - 3, 7, 7);
          g2D.fillRect((int) endPt.getX() - 3, (int) endPt.getY() - 3, 7, 7);
          g2D.fillRect((int) startCtrlPt.getX() - 3, (int) startCtrlPt.getY() - 3, 7, 7);
          g2D.fillRect((int) endCtrlPt.getX() - 3, (int) endCtrlPt.getY() - 3, 7, 7);
          g2D.drawLine(
              (int) startPt.getX(),
              (int) startPt.getY(),
              (int) startCtrlPt.getX(),
              (int) startCtrlPt.getY());
          g2D.drawLine(
              (int) endPt.getX(),
              (int) endPt.getY(),
              (int) endCtrlPt.getX(),
              (int) endCtrlPt.getY());
          g2D.setColor(color);
        }
      }
      // draw page connector
      if (sPage != ePage && !stub) {
        // if one start page
        if (sPage == currPage) {
          curve.setCurve(
              startPt.getX(),
              startPt.getY(),
              startCtrlPt.getX(),
              startCtrlPt.getY(),
              pageSC.getX(),
              pageSC.getY(),
              pageS.getX(),
              pageS.getY());
          int x = (int) pageS.getX();
          int y = (int) pageS.getY();
          g2D.drawLine(x, y, x, y + 10);
          g2D.drawLine(x, y + 10, x + 30, y + 10);
          g2D.drawLine(x + 30, y + 10, x + 40, y);
          g2D.drawLine(x + 40, y, x + 30, y - 10);
          g2D.drawLine(x + 30, y - 10, x, y - 10);
          g2D.drawLine(x, y - 10, x, y);

          FontMetrics fm = g2D.getFontMetrics();
          String pageName = drawArea.getPageName(endState.getPage());
          String text = endState.getName() + " (" + pageName + ")";
          int tW = fm.stringWidth(text);
          if (tW > 40) g2D.drawString(text, x + 40 - tW, y + 25);
          else g2D.drawString(text, x, y + 25);

          // draw control points if needed
          if (selectStatus != SelectOptions.NONE) {
            g2D.setColor(Color.red);
            g2D.fillRect((int) startPt.getX() - 3, (int) startPt.getY() - 3, 7, 7);
            g2D.fillRect((int) pageS.getX() - 3, (int) pageS.getY() - 3, 7, 7);
            g2D.fillRect((int) startCtrlPt.getX() - 3, (int) startCtrlPt.getY() - 3, 7, 7);
            g2D.fillRect((int) pageSC.getX() - 3, (int) pageSC.getY() - 3, 7, 7);
            g2D.drawLine(
                (int) startPt.getX(),
                (int) startPt.getY(),
                (int) startCtrlPt.getX(),
                (int) startCtrlPt.getY());
            g2D.drawLine(
                (int) pageS.getX(), (int) pageS.getY(), (int) pageSC.getX(), (int) pageSC.getY());
          }
          g2D.setColor(color);
          g2D.draw(curve);
        }
        // in on end page
        else if (ePage == currPage) {
          curve.setCurve(
              pageE.getX(),
              pageE.getY(),
              pageEC.getX(),
              pageEC.getY(),
              endCtrlPt.getX(),
              endCtrlPt.getY(),
              endPt.getX(),
              endPt.getY());
          int x = (int) pageE.getX() - 40;
          int y = (int) pageE.getY();
          g2D.drawLine(x, y, x, y + 10);
          g2D.drawLine(x, y + 10, x + 30, y + 10);
          g2D.drawLine(x + 30, y + 10, x + 40, y);
          g2D.drawLine(x + 40, y, x + 30, y - 10);
          g2D.drawLine(x + 30, y - 10, x, y - 10);
          g2D.drawLine(x, y - 10, x, y);

          g2D.drawString(
              startState.getName() + " (" + drawArea.getPageName(startState.getPage()) + ")",
              x,
              y + 25);

          // control points if needed
          if (selectStatus != SelectOptions.NONE) {
            g2D.setColor(Color.red);
            g2D.fillRect((int) endPt.getX() - 3, (int) endPt.getY() - 3, 7, 7);
            g2D.fillRect((int) pageE.getX() - 3, (int) pageE.getY() - 3, 7, 7);
            g2D.fillRect((int) endCtrlPt.getX() - 3, (int) endCtrlPt.getY() - 3, 7, 7);
            g2D.fillRect((int) pageEC.getX() - 3, (int) pageEC.getY() - 3, 7, 7);
            g2D.drawLine(
                (int) endPt.getX(),
                (int) endPt.getY(),
                (int) endCtrlPt.getX(),
                (int) endCtrlPt.getY());
            g2D.drawLine(
                (int) pageE.getX(), (int) pageE.getY(), (int) pageEC.getX(), (int) pageEC.getY());
          }
          g2D.setColor(color);
          g2D.draw(curve);
        }
      }
    }
  }
  /** Dessine le corps de la figure. */
  protected void drawBody(
      Graphics g,
      Color fillColor,
      Color lineColor,
      int decalageX,
      int decalageY,
      int resizeX,
      int resizeY) {
    Graphics2D g2 = (Graphics2D) g;

    int x = ((MDElement) getModele()).getX() + decalageX;
    int y = ((MDElement) getModele()).getY() + decalageY;
    int l = ((MDElement) getModele()).getLargeur() + resizeX;
    int h = ((MDElement) getModele()).getHauteur() + resizeY;

    int x1[] = new int[5];
    int y1[] = new int[5];

    x1[0] = x;
    x1[1] = x + l - (l / 5);
    x1[2] = x + l;
    x1[3] = x + l;
    x1[4] = x;

    y1[0] = y;
    y1[1] = y;
    y1[2] = y + (h / 5);
    y1[3] = y + h;
    y1[4] = y + h;

    // code effectué si on ne déplace pas le produit
    if (fillColor != null) {
      // Color c = new Color(223,146,126);
      // Color c = new Color(255,146,126);
      Color c = new Color(255, 255, 0);
      g2.setPaint(c);
      g2.fillPolygon(x1, y1, 5);
    }

    g2.setPaint(Color.BLACK);
    g2.setStroke(new BasicStroke(2));
    g2.drawPolygon(x1, y1, 5);
    g2.drawLine(x1[1], y1[1], x1[1], y1[2]);
    g2.drawLine(x1[1], y1[2], x1[2], y1[2]);
    g2.setStroke(new BasicStroke(1));

    int i;
    for (i = y + 5; i < y1[2]; i += 5) {
      g2.drawLine(x1[0] + (x1[1] - x1[0]) / 6, i, x1[1] - (x1[1] - x1[0]) / 6, i);
    }
    for (; i < y1[4]; i += 5) {
      g2.drawLine(x1[0] + (x1[1] - x1[0]) / 6, i, x1[3] - (x1[1] - x1[0]) / 6, i);
    }

    g2.setStroke(new BasicStroke(1));

    g2.setFont(((MDProduit) getModele()).getPolice());

    // centrer le texte associé au composant
    this.taille = getNomFusion().length();
    this.largeurChaine =
        g2.getFontMetrics(((MDProduit) getModele()).getPolice())
            .charsWidth(getNomFusion().toCharArray(), 0, this.taille);
    g2.drawString(getNomFusion(), x + (l / 2) - (this.largeurChaine / 2), y + h + 15);
  }
Example #28
0
  public void drawPolygon(int[] polygon) {

    gc.drawPolygon(getSwingPolygon(polygon));
  }
Example #29
0
  private void render(Graphics g, int drawingPage, double scale) {
    Graphics2D g2 = (Graphics2D) g;
    g2.scale(scale, scale);
    int pageIndex;
    paperPanel.setPreferredSize(new Dimension(600, numberOfPages * (pageHeight + 25)));

    for (int page = 0; page < numberOfPages; page++) {
      g2.setColor(Color.white);
      g2.fillRect(0, page * (pageHeight + 25), pageWidth, pageHeight);
    }

    g2.setColor(Color.black);

    for (Object[] task : elements) {
      switch ((Integer) task[0]) {
        case DRAW_STRING:
          FontMetrics metrics = getFontMetrics(g2.getFont());
          String string = task[1].toString();
          int x = (Integer) task[2];
          int y = (Integer) task[3];
          pageIndex = (Integer) task[4];
          if (drawingPage == -1) y += (pageIndex * (pageHeight + 25));
          int width = metrics.stringWidth(string);
          if (drawingPage == -1 || drawingPage == pageIndex) {
            if (currentAlignment == LEFT) {
              g2.drawString(string, x, y);
              if (underline) {
                g2.drawLine(x, y + 3, x + width, y + 3);
              }
            } else if (currentAlignment == RIGHT) {
              g2.drawString(string, x - width, y);
              if (underline) {
                g2.drawLine(x, y + 3, x - width, y + 3);
              }
            } else if (currentAlignment == CENTER) {
              g2.drawString(string, x - (width / 2), y);
              if (underline) {
                g2.drawLine(x - (width / 2), y + 3, x + (width / 2), y + 3);
              }
            }
          }
          break;
        case DRAW_LINE:
          int x1 = (Integer) task[1],
              y1 = (Integer) task[2],
              x2 = (Integer) task[3],
              y2 = (Integer) task[4];
          pageIndex = (Integer) task[5];
          if (drawingPage == -1)
            g2.drawLine(
                x1, (pageIndex * (pageHeight + 25)) + y1, x2, (pageIndex * (pageHeight + 25)) + y2);
          else if (drawingPage == pageIndex) g2.drawLine(x1, y1, x2, y2);
          break;
        case DRAW_RECT:
          int rectX = (Integer) task[1],
              rectY = (Integer) task[2],
              rectWidth = (Integer) task[3],
              rectHeight = (Integer) task[4];
          pageIndex = (Integer) task[5];
          if (drawingPage == -1)
            g2.drawRect(rectX, (pageIndex * (pageHeight + 25)) + rectY, rectWidth, rectHeight);
          else if (drawingPage == pageIndex) g2.drawRect(rectX, rectY, rectWidth, rectHeight);
          break;
        case DRAW_OVAL:
          int ovalX = (Integer) task[1],
              ovalY = (Integer) task[3],
              ovalWidth = (Integer) task[3],
              ovalHeight = (Integer) task[4];
          pageIndex = (Integer) task[5];
          if (drawingPage == -1)
            g2.drawOval(ovalX, (pageIndex * (pageHeight + 25)) + ovalY, ovalWidth, ovalHeight);
          else if (drawingPage == pageIndex) g2.drawOval(ovalX, ovalY, ovalWidth, ovalHeight);
          break;
        case DRAW_IMAGE:
          Image image = (Image) task[1];
          int imageX = (Integer) task[2],
              imageY = (Integer) task[3],
              imageWidth = (Integer) task[4],
              imageHeight = (Integer) task[5];
          pageIndex = (Integer) task[6];
          if (drawingPage == -1)
            g2.drawImage(
                image,
                imageX,
                (pageIndex * (pageHeight + 25)) + imageY,
                imageWidth,
                imageHeight,
                this);
          else if (drawingPage == pageIndex)
            g2.drawImage(image, imageX, imageY, imageWidth, imageHeight, this);
          break;
        case DRAW_POLYGON:
          int[] xPoints = (int[]) task[1], yPoints = (int[]) task[2];
          int numberOfPoints = (Integer) task[3];
          pageIndex = (Integer) task[4];
          if (drawingPage == -1) {
            for (int i = 0; i < yPoints.length; i++) {
              yPoints[i] += (pageIndex * (pageHeight + 25));
            }
            g2.drawPolygon(xPoints, yPoints, numberOfPoints);
          } else if (drawingPage == pageIndex) g2.drawPolygon(xPoints, yPoints, numberOfPoints);
          break;
        case DRAW_ARC:
          int arcX = (Integer) task[1],
              arcY = (Integer) task[2],
              arcWidth = (Integer) task[3],
              arcHeight = (Integer) task[4],
              startAngle = (Integer) task[5],
              arcAngle = (Integer) task[6];
          pageIndex = (Integer) task[7];
          if (drawingPage == -1)
            g2.drawArc(
                arcX,
                (pageIndex * (pageHeight + 25)) + arcY,
                arcWidth,
                arcHeight,
                startAngle,
                arcAngle);
          else if (drawingPage == pageIndex)
            g2.drawArc(arcX, arcY, arcWidth, arcHeight, startAngle, arcAngle);
          break;
        case FILL_RECT:
          int fillRectX = (Integer) task[1],
              fillRectY = (Integer) task[2],
              fillRectWidth = (Integer) task[3],
              fillRectHeight = (Integer) task[4];
          pageIndex = (Integer) task[5];
          if (drawingPage == -1)
            g2.fillRect(
                fillRectX,
                (pageIndex * (pageHeight + 25)) + fillRectY,
                fillRectWidth,
                fillRectHeight);
          else if (drawingPage == pageIndex)
            g2.fillRect(fillRectX, fillRectY, fillRectWidth, fillRectHeight);
          break;
        case FILL_OVAL:
          int fillOvalX = (Integer) task[1],
              fillOvalY = (Integer) task[2],
              fillOvalWidth = (Integer) task[3],
              fillOvalHeight = (Integer) task[4];
          pageIndex = (Integer) task[5];
          if (drawingPage == -1)
            g2.fillOval(
                fillOvalX,
                (pageIndex * (pageHeight + 25)) + fillOvalY,
                fillOvalWidth,
                fillOvalHeight);
          else if (drawingPage == pageIndex)
            g2.fillOval(fillOvalX, fillOvalY, fillOvalWidth, fillOvalHeight);
          break;
        case FILL_POLYGON:
          int[] fillXPoints = (int[]) task[1], fillYPoints = (int[]) task[2];
          int fillNumberOfPoints = (Integer) task[3];
          pageIndex = (Integer) task[4];
          if (drawingPage == -1) {
            for (int i = 0; i < fillYPoints.length; i++) {
              fillYPoints[i] += (pageIndex * (pageHeight + 25));
            }
            g2.fillPolygon(fillXPoints, fillYPoints, fillNumberOfPoints);
          } else if (drawingPage == pageIndex)
            g2.fillPolygon(fillXPoints, fillYPoints, fillNumberOfPoints);
          break;
        case FILL_ARC:
          int fillArcX = (Integer) task[1],
              fillArcY = (Integer) task[2],
              fillArcWidth = (Integer) task[3],
              fillArcHeight = (Integer) task[4],
              fillStartAngle = (Integer) task[5],
              fillArcAngle = (Integer) task[6];
          pageIndex = (Integer) task[7];
          if (drawingPage == -1)
            g2.fillArc(
                fillArcX,
                (pageIndex * (pageHeight + 25)) + fillArcY,
                fillArcWidth,
                fillArcHeight,
                fillStartAngle,
                fillArcAngle);
          else if (drawingPage == pageIndex)
            g2.fillArc(
                fillArcX, fillArcY, fillArcWidth, fillArcHeight, fillStartAngle, fillArcAngle);
          break;
        case SET_COLOR:
          g2.setColor((Color) task[1]);
          break;
        case SET_FONT:
          g2.setFont((Font) task[1]);
          break;
        case SET_STROKE:
          g2.setStroke((Stroke) task[1]);
          break;
        case SET_PAINT:
          g2.setPaint((Paint) task[1]);
          break;
        case SET_ALIGNMENT:
          currentAlignment = (Integer) task[1];
          break;
        case SET_STYLE:
          int style = (Integer) task[1];
          //				currentStyle = style;
          styleFont = currentFont.deriveFont(Font.PLAIN);
          if (style == BOLD) styleFont = styleFont.deriveFont(Font.BOLD);
          if (style == ITALIC) styleFont = styleFont.deriveFont(Font.ITALIC);
          underline = (style == UNDERLINE);
          if (style == BOLD_UNDERLINE) {
            styleFont = styleFont.deriveFont(Font.BOLD);
            underline = true;
          }
          g2.setFont(styleFont);
          break;
      }
    }
  }
Example #30
0
 public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints) {
   g2d.drawPolygon(xPoints, yPoints, nPoints);
 }