コード例 #1
0
ファイル: PaintApplet.java プロジェクト: acpanna/coding
  public void mouseReleased(MouseEvent evt) {
    Graphics g = canvas.getGraphics();
    g.setColor(color);
    g.setPaintMode();
    end = evt.getPoint();

    if (type == 0) {
      g.drawRect(start.x, start.y, end.x - start.x, end.y - start.y);

      if (filled.getState() == true) g.fillRect(start.x, start.y, end.x - start.x, end.y - start.y);

      status.setText("2. Ecke des Rechtecks festgelegt");
    } else if (type == 1) {
      int radius;

      radius = (int) Math.sqrt(Math.pow(end.x - start.x, 2) + Math.pow(end.y - start.y, 2));

      g.drawOval(start.x - radius, start.y - radius, 2 * radius, 2 * radius);

      if (filled.getState() == true)
        g.fillOval(start.x - radius, start.y - radius, 2 * radius, 2 * radius);

      status.setText("Radius des Kreises festgelegt");
    } else if (type == 2) {
      g.drawOval(start.x, start.y, end.x - start.x, end.y - start.y);

      if (filled.getState() == true) g.fillOval(start.x, start.y, end.x - start.x, end.y - start.y);

      status.setText("Radius der Ellipse festgelegt");
    }
  }
コード例 #2
0
ファイル: Main_b.java プロジェクト: avijitgupta/pinBall
  public void paint(Graphics g) {
    if (!gameComplete) {
      if (!initialPaintComplete) {
        g.setColor(Color.WHITE);
        g.fillRect(0, 0, MaxX, MaxY);
        initialPaintComplete = true;
      }

      Graphics blockGraphics = blockBuffer.getGraphics();
      Graphics padGraphics = padBuffer.getGraphics();
      Graphics ballGraphics = ballBuffer.getGraphics();
      Graphics ballPreviousGraphics = ballBufferPrevious.getGraphics();

      ballPreviousGraphics.setColor(Color.WHITE);
      ballPreviousGraphics.fillRect(0, 0, ballDiameter, ballDiameter);
      g.drawImage(ballBufferPrevious, ballPreviousX, ballPreviousY, null);

      ballGraphics.setColor(Color.BLUE);
      ballGraphics.fillOval(0, 0, ballDiameter, ballDiameter); // whole line white
      g.drawImage(ballBuffer, ballX, ballY, null);

      ballGraphics.setColor(Color.RED);
      ballGraphics.fillOval(4, 4, ballDiameter - 8, ballDiameter - 8); // whole line white
      g.drawImage(ballBuffer, ballX, ballY, null);

      padGraphics.setColor(Color.WHITE);
      padGraphics.fillRect(0, 0, MaxX, blockHeight); // whole line white
      padGraphics.setColor(Color.BLACK);
      padLeft = padx - padLength / 2;

      if (padLeft >= 0 && padx + padLength / 2 < MaxX) {
        padGraphics.fillRoundRect(padLeft, 0, padLength, padHeight, padHeight, padHeight);
      }
      if (padLeft < 0) {
        padGraphics.fillRoundRect(0, 0, padLength, padHeight, padHeight, padHeight);
      } else if (padx + padLength / 2 >= MaxX) {
        padGraphics.fillRoundRect(MaxX - padLength, 0, padLength, padHeight, padHeight, padHeight);
      }
      g.drawImage(padBuffer, 0, padTop, null);
      // g.drawString(msg, 50, 50);
      // Drawing Blocks

      Iterator<Entry<String, Color>> it = blockMap.entrySet().iterator();
      blockGraphics.setColor(Color.WHITE);
      blockGraphics.fillRect(0, 0, blockSetWidth, blockSetHeight); // whole line white
      while (it.hasNext()) {
        Map.Entry<String, Color> pairs = (Map.Entry<String, Color>) it.next();
        String coordinate = pairs.getKey();
        blockGraphics.setColor(pairs.getValue());
        blockGraphics.fillRect(
            new Pair(coordinate).first, new Pair(coordinate).second, blockLength, blockHeight);
      }
      if (repaintBlocks) {
        g.drawImage(blockBuffer, blockStartX, blockStartY, null);
        if (--count < 0) repaintBlocks = false;
      }
    }
  }
コード例 #3
0
ファイル: Grapher.java プロジェクト: afisher/School
  public void paintComponent(Graphics g) {
    super.paintComponent(g);

    calcSizes();
    drawAxes(g);
    calcMaxes();
    calcTickIncrements();
    drawXTicks(g);
    drawYTicks(g);

    int t = 0;
    int prevX = 0, prevY1 = 0, prevY2 = 0;

    for (DataPair pair : data) {

      int h = pair.getH();
      int p = pair.getP();

      // calculate where to put the dots
      int x = xVal(t, maxT);
      int y1 = yVal(h, maxH);
      int y2 = yVal(p, maxP);

      // draw herbivore dot
      g.setColor(Color.BLUE);
      g.fillOval(x, y1, 2 * r, 2 * r);

      // draw a line connecting this dot to the last
      if (prevX != 0) {
        g.drawLine(prevX + r, prevY1 + r, x + r, y1 + r);
      }

      // draw predator dot
      g.setColor(Color.RED);
      g.fillOval(x, y2, 2 * r, 2 * r);

      // draw a line connecting this dot to the last
      if (prevX != 0) {
        g.drawLine(prevX + r, prevY2 + r, x + r, y2 + r);
      }

      // remember these dots
      prevX = x;
      prevY1 = y1;
      prevY2 = y2;

      g.setColor(Color.BLACK);

      t++;
    }
  }
コード例 #4
0
  /**
   * Function: drawNode Pre: Takes a graphics object g to draw on. Also takes two ints (x_size,
   * y_size) defining the screen size Also takes a node radius r Post: Prints out this node to the
   * screen appropriately
   */
  public void drawNode(Graphics g, int x_size, int y_size, int r) {
    // Don't print nodes that aren't activated
    if (!activated) return;

    // First, get some stats based on the Graphics area size
    // In particular, the size of the Node
    int px = (int) (x_size * x) - r; // X & Y positions
    int py = (int) (y_size * y) - r;

    // Set the font to appropriate no matter what
    // int sizor;    //The size for the text, based on radius
    g.setFont(new Font("Serif", Font.BOLD, r));

    // Find the color for the text, it's used often... we'll do this later now
    // String textcol = getOtherTextColor(color);  MOOF!  UPDATE THIS LATER!
    // Make sure the color is correct no matter what... adjust also later!

    // Node insides... get this color correct later, moof!
    g.setColor(getMyJavaColor());
    // g.setColor(Color.white);
    g.fillOval(px, py, r * 2, r * 2);

    // Node border
    g.setColor(getJavaColor(getOtherNodeColor(color)));
    g.drawOval(px, py, r * 2, r * 2);

    // Text inside... set up to be centered
    py = py + r + (int) (g.getFontMetrics().getAscent() / 2.2);
    px = px + r - (g.getFontMetrics().stringWidth("" + cindex) / 2);
    g.drawString("" + cindex, px, py);
  }
コード例 #5
0
 @Override
 public void paintComponent(Graphics g) {
   super.paintComponent(g);
   setBackground(CANVAS_BACKGROUND);
   g.setColor(LINE_COLOR);
   g.fillOval(x, y, size, size); // draw the ball
 }
コード例 #6
0
 // färger, se sid 43 i boken
 // grafiska metoder, sid 248 i boken
 public void paintComponent(Graphics g) { // för att vara säker på att
   // "super"-klassen gör sitt
   // anropar vi den metoden, innan
   // vi skriver eller ritar
   super.paintComponent(g);
   g.drawLine(185, 10, 195, 40); // x1,y1 till x2,y2
   g.drawLine(200, 10, 200, 40);
   g.drawLine(215, 10, 205, 40);
   g.setColor(Color.white);
   g.fillOval(50, 30, 300, 150); // x,y,b,h (x,y för ö v h)
   g.setColor(Color.red);
   g.drawArc(100, 100, 200, 50, 180, 180); // x,y,b,h,s,l
   g.setColor(Color.yellow);
   g.fillRect(200, 100, 30, 30);
   g.fill3DRect(150, 50, 30, 50, true); // true upphöjd figur
   g.fill3DRect(250, 50, 30, 50, true);
   // skriv ut en textsträng, samt ange läget i avståndet från
   // övre vänstra hörnet i x-led åt höger och i y-led neråt
   g.drawString("** Tjenare kompis !! **", 20, 20);
   f = new Font("Arial", Font.BOLD, 30);
   setBackground(Color.cyan);
   g.setFont(f);
   g.setColor(new Color(255, 175, 175));
   g.drawString("YEEEEEEEES!!", 100, 250);
 }
コード例 #7
0
 public void drawTo(Graphics g, Line line) {
   if (!calc.tileOnMap(t1) || !calc.tileOnMap(t2)) return;
   if (calc.tileOnMap(line.getTile1()) && calc.tileOnMap(line.getTile2())) {
     Point p1 = calc.tileToMinimap(t1);
     Point p2 = calc.tileToMinimap(t2);
     Point p3 = calc.tileToMinimap(line.getTile2());
     Point p4 = calc.tileToMinimap(line.getTile1());
     GeneralPath path = new GeneralPath();
     path.moveTo(p1.x, p1.y);
     path.lineTo(p2.x, p2.y);
     path.lineTo(p3.x, p3.y);
     path.lineTo(p4.x, p4.y);
     path.closePath();
     g.setColor(POLY_FILL);
     ((Graphics2D) g).fill(path);
     ((Graphics2D) g).draw(path);
   }
   Point last = null, p;
   g.setColor(Color.ORANGE);
   for (RSTile t : pathList) {
     if (calc.tileOnMap(t)) {
       p = calc.tileToMinimap(t);
       g.fillOval(p.x - 2, p.y - 2, 5, 5);
       if (last != null) g.drawLine(p.x, p.y, last.x, last.y);
       last = p;
     } else last = null;
   }
 }
コード例 #8
0
    private void displayTree(Graphics g, AVLTree.TreeNode root, int x, int y, int gap) {
      if (root != null) {
        // Display root
        if (setOfHighlightedNodes.contains(root)) {
          g.setColor(Color.GREEN);
          g.fillOval(x - radius, y - radius, 2 * radius, 2 * radius);
          g.setColor(Color.BLACK);
        } else {
          g.drawOval(x - radius, y - radius, 2 * radius, 2 * radius);
        }

        g.drawString(root.element + "", x - 6, y + 4);

        // Draw a line to the left node
        if (root.left != null) connectLeftChild(g, x - gap, y + virticalGap, x, y);

        // Draw left subtree
        displayTree(g, root.left, x - gap, y + virticalGap, gap / 2);

        // Draw a line to the right node
        if (root.right != null) connectRightChild(g, x + gap, y + virticalGap, x, y);

        // Draw right subtree
        displayTree(g, root.right, x + gap, y + virticalGap, gap / 2);
      }
    }
コード例 #9
0
ファイル: THA.java プロジェクト: tlulu/Tetris-Platformer
 public void paintComponent(Graphics g) {
   super.paintComponent(g);
   setBackground(Color.black);
   add(l);
   add(s);
   drawSpecialLines(g);
   g.setColor(Color.white);
   g.fillOval(30, 100, 75, 75);
   g.setColor(Color.blue);
   g.fillRect(getWidth() / 2, getHeight() / 2, (int) bl, 10);
   g.fillRect(getWidth() / 2, getHeight() / 2 + 40, (int) gl, 10);
   g.fillRect(getWidth() / 2, getHeight() / 2 + 80, (int) ll, 10);
   g.fillRect(getWidth() / 2, getHeight() / 2 + 120, (int) sl, 10);
   g.drawImage(bullet.getImage(), 30, getHeight() / 2 - 10, 20, 20, null);
   g.drawImage(grenade.getImage(), 30, getHeight() / 2 + 40 - 10, 20, 20, null);
   g.drawImage(laser.getImage(), 30, getHeight() / 2 + 80 - 10, 20, 20, null);
   g.drawImage(shotgun.getImage(), 30, getHeight() / 2 + 120 - 10, 20, 20, null);
   g.setColor(Color.yellow);
   if (gunTrack == 0) {
     g.drawRect(30, getHeight() / 2 - 10, 20, 20);
   } else if (gunTrack == 1) {
     g.drawRect(30, getHeight() / 2 + 40 - 10, 20, 20);
   } else if (gunTrack == 2) {
     g.drawRect(30, getHeight() / 2 + 80 - 10, 20, 20);
   } else {
     g.drawRect(30, getHeight() / 2 + 120 - 10, 20, 20);
   }
 }
コード例 #10
0
ファイル: Cwiczenie5_4.java プロジェクト: Lenbon/s8376ppj
 public void draw(Graphics g) {
   if (running) {
     g.setColor(color);
     synchronized (pos) {
       g.fillOval(pos.x, pos.y, SIZE, SIZE);
     }
   }
 }
コード例 #11
0
ファイル: Cent.java プロジェクト: Auzzy/personal
 public void drawSpider() {
   buf.setColor(Color.black);
   for (int k = 0; k < 10; k++) {
     if (spid[k][2] != -1) {
       buf.fillOval(spid[k][0], spid[k][1], 10, 10);
       if (spid[k][0] < 0 || spid[k][0] > 290) spid[k][2] = -1;
     }
   }
 }
コード例 #12
0
ファイル: DrawingPanel.java プロジェクト: Tigatok/GUIExample
 @Override
 public void mouseDragged(MouseEvent me) {
   Graphics g = getGraphics();
   g.setColor(bg);
   x = me.getX();
   y = me.getY();
   g.setColor(Color.RED);
   g.fillOval(x - 12, y - 10, 30, 30);
 }
コード例 #13
0
ファイル: DrawingPanel.java プロジェクト: Tigatok/GUIExample
 public void mouseClicked(MouseEvent me) {
   Graphics g = getGraphics();
   g.setColor(bg);
   // g.fillRect(x, y, 30, 30);
   x = me.getX();
   y = me.getY();
   g.setColor(Color.RED);
   g.fillOval(x - 12, y - 10, 30, 30);
 }
コード例 #14
0
ファイル: Tank.java プロジェクト: hanyc1992/TankWar
  public void draw(Graphics g) {
    getDirection();
    move();

    Color c = g.getColor();
    g.setColor(TANK_COLOR);
    g.fillOval(xpos, ypos, TANK_RADIUS, TANK_RADIUS);
    drawPT(g);
    g.setColor(c);
  }
コード例 #15
0
ファイル: Board.java プロジェクト: ankeshs/hex
 void circle(Graphics g, double x, double y, int st) {
   switch (st) {
     case Block.BLANK:
       return;
     case Block.RED_BEAD:
       switch (gst.theme) {
         case 0:
           g.setColor(Color.RED);
           break;
         case 1:
           g.setColor(Color.BLACK);
           break;
         case 2:
           g.drawImage(
               gold,
               (int) (x - bst.scale * r3 / 2 * 0.75),
               (int) (y - bst.scale * r3 / 2 * 0.75),
               (int) (bst.scale * r3 * 0.75),
               (int) (bst.scale * r3 * 0.75),
               Color.WHITE,
               null);
           return;
       }
       break;
     case Block.BLUE_BEAD:
       switch (gst.theme) {
         case 0:
           g.setColor(Color.BLUE);
           break;
         case 1:
           g.setColor(new Color(1, 175, 1));
           break;
         case 2:
           g.drawImage(
               silver,
               (int) (x - bst.scale * r3 / 2 * 0.75),
               (int) (y - bst.scale * r3 / 2 * 0.75),
               (int) (bst.scale * r3 * 0.75),
               (int) (bst.scale * r3 * 0.75),
               Color.WHITE,
               null);
           return;
       }
       break;
     case Block.RED_PATH:
     case Block.BLUE_PATH:
       g.setColor(Color.GREEN);
       break;
   }
   g.fillOval(
       (int) (x - bst.scale * r3 / 2 * 0.75),
       (int) (y - bst.scale * r3 / 2 * 0.75),
       (int) (bst.scale * r3 * 0.75),
       (int) (bst.scale * r3 * 0.75));
 }
コード例 #16
0
ファイル: Tank.java プロジェクト: hanyc1992/TankWar
  public void draw(Graphics g) {
    getDirection();
    move();

    Color c = g.getColor();
    Color tankColor = (isMe) ? MY_TANK_COLOR : ENENMY_TANK_COLOR;
    g.setColor(tankColor);
    g.fillOval(xpos, ypos, TANK_RADIUS, TANK_RADIUS);
    drawPT(g);
    g.setColor(c);
  }
コード例 #17
0
 /**
  * Adds pixel to queue and calls repaint() whenever we have MAX_ITEMS pixels in the queue or
  * when MAX_TIME msecs have elapsed (whichever comes first). The advantage compared to just
  * calling repaint() after adding a pixel to the queue is that repaint() can most often draw
  * multiple points at the same time.
  */
 public void drawPoint(DrawCommand c) {
   if (c == null || gr == null) return;
   Color col = new Color(c.rgb);
   gr.setColor(col);
   gr.fillOval(c.x, c.y, 10, 10);
   repaint();
   if (state != null) {
     synchronized (state) {
       state.put(new Point(c.x, c.y), col);
     }
   }
 }
コード例 #18
0
ファイル: Cent.java プロジェクト: Auzzy/personal
 public void drawStatus() {
   buf.setColor(Color.black);
   buf.fillRect(0, 400, dimX, 50);
   buf.setColor(Color.white);
   buf.drawString("Level " + level, 0, 420);
   buf.drawString("score:" + score, 200, 420);
   buf.drawString("Lives:", 0, 435);
   for (int k = 0; k < lives - 1; k++) buf.fillOval(35 + k * 10, 425, 10, 10);
   buf.drawString("High Score", 200, 435);
   if (norm) buf.drawString(name + "|" + high, 125, 448);
   else buf.drawString(endName[dif] + "|" + endHigh[dif], 125, 448);
 }
コード例 #19
0
  private void drawPageIndicator(Graphics g)
        //  PRE:  g must be initialized.
        //  POST: Draws a page indicator above the OK button. The filled in circle represents which
        //        page we're currently on.
      {
    int x1; // First x coordinate for drawing area.
    int y1; // First y coordinate for drawing area.
    int x2; // Second x coordinate for drawing area.
    int y2; // Second y coordinate for drawing area.
    int width; // Width of drawing area.
    int height; // Height of drawing area.
    int offset; // Offset between circles.
    Graphics2D g2; // Graphics2D to change brush stroke.

    x1 = ScaledPoint.scalerToX(0.275);
    x2 = ScaledPoint.scalerToX(0.325);
    y1 = ScaledPoint.scalerToY(0.85);
    y2 = ScaledPoint.scalerToY(0.89);

    width = (x2 - x1) / 2;
    height = y2 - y1;

    offset = ScaledPoint.scalerToX(0.005) / 2;

    g2 = (Graphics2D) g;

    g2.setColor(Color.WHITE);
    g2.setStroke(new BasicStroke(1));

    if (currentPage == 0) // if we are on the first page
    {
      g.fillOval(x1 - offset, y1, width, height);
      g.drawOval(x1 + width + offset, y1, width, height);
    } else // if we are on the second page.
    {
      g.drawOval(x1 - offset, y1, width, height);
      g.fillOval(x1 + width + offset, y1, width, height);
    }
  }
コード例 #20
0
  // Paint the round background and label.
  protected void paintComponent(Graphics g) {
    if (getModel().isArmed()) {
      // You might want to make the highlight color
      // a property of the RoundButton class.
      g.setColor(Color.lightGray);
    } else {
      g.setColor(getBackground());
    }
    g.fillOval(0, 0, getSize().width - 1, getSize().height - 1);

    // This call will paint the label and the
    // focus rectangle.
    super.paintComponent(g);
  }
コード例 #21
0
 public void paint(Graphics g) {
   if (mainMenu) {
     drawTitleScreen(g);
   } else if (gamePlaying) {
     drawBricks(g);
     g.setColor(Color.green);
     g.fillRect(pad.x(), 590, pad.width(), 10);
     g.fillOval(
         ball.x_Pos() - ball.radius(),
         ball.y_Pos() - ball.radius(),
         ball.radius() * 2,
         ball.radius() * 2);
   }
 } // paint method
コード例 #22
0
ファイル: DrawTool.java プロジェクト: tstamler/linAlg
 void drawPoint(Graphics g, DrawObject p) {
   if (p == null) {
     return;
   }
   if ((sequencingOn) && (p.sequenceNum != currentSequenceNumDisplay)) {
     return;
   }
   int x = (int) ((p.x - minX) / (maxX - minX) * (D.width - 2 * inset));
   int y = (int) ((p.y - minY) / (maxY - minY) * (D.height - 2.0 * inset));
   if (p.diameter > 1) {
     int r = p.diameter / 2;
     g.fillOval(inset + x - r, D.height - y - inset - r, 2 * r, 2 * r);
   } else {
     g.fillRect(inset + x, D.height - y - inset, 1, 1);
   }
 }
コード例 #23
0
  public void paint(Graphics g) {
    // Set color first before we draw
    g.setColor(Color.red);
    g.drawRect(snakeAreaX, snakeAreaY, snakeAreaWidth, snakeAreaHeight); // draw boundary

    g.setColor(Color.blue);

    for (int i = 0; i < snakeLength; i++) {
      g.fillRect(snakex[i], snakey[i], 10, 10);
      // g.fillOval(snakex[i],snakey[i] , 10, 10);
    }
    // System.out.println(snakex[0]+":"+snakey[0]);
    // System.out.println("_____");
    g.setColor(Color.BLACK);
    g.fillOval(baitX, baitY, 10, 10);
  }
コード例 #24
0
 /** Draw the entire panel from the state */
 @SuppressWarnings("rawtypes")
 public void drawState() {
   // clear();
   Map.Entry entry;
   Point pt;
   Color col;
   synchronized (state) {
     for (Iterator it = state.entrySet().iterator(); it.hasNext(); ) {
       entry = (Map.Entry) it.next();
       pt = (Point) entry.getKey();
       col = (Color) entry.getValue();
       gr.setColor(col);
       gr.fillOval(pt.x, pt.y, 10, 10);
     }
   }
   repaint();
 }
コード例 #25
0
ファイル: Missile.java プロジェクト: WinjayYu/TankWar
  public void draw(Graphics g) {
    if (!live) {
      // System.out.println("子弹死了");
      // t.missiles.remove(this);
      return;
    }
    Color c = g.getColor(); // 拿到前景色
    if (good) {
      g.setColor(Color.RED);
    } else {
      g.setColor(Color.YELLOW);
    }
    g.fillOval(x, y, WIDTH, HEIGHT); // 画一个实心圆并用当前颜色填充
    g.setColor(c);

    move();
  }
コード例 #26
0
ファイル: GUI.java プロジェクト: actorclavilis/InsaneMouse
  private void drawPlayers(Graphics g) {
    Iterator i = players.iterator();
    Player p;
    while (i.hasNext()) {
      p = (Player) i.next();

      if (p.isActive()) {
        if (p.getImmunity()) {
          g.setColor(Color.red.brighter());
          g.drawOval(p.getX() - 30, p.getY() - 30, 60, 60);
        }
        g.setColor(Color.WHITE);
        g.fillOval(p.getX() - 5, p.getY() - 5, 10, 10);
      }

      p.paint(g);
    }
  }
コード例 #27
0
ファイル: Life.java プロジェクト: dragon66/icafe
  public void placeCell(int x, int y) {

    if (t != null) return;

    x = x / cellSize;
    y = y / cellSize;

    if (cell[x][y] == 0) {
      cell[x][y] = 1;
      offScrGraphics.setColor(Color.red);
      offScrGraphics.fillOval(x * cellSize + 1, y * cellSize + 1, cellSize - 2, cellSize - 2);
    } else {
      cell[x][y] = 0;
      offScrGraphics.setColor(Color.black);
      offScrGraphics.fillRect(x * cellSize + 1, y * cellSize + 1, cellSize - 2, cellSize - 2);
    }

    canvas.repaint();
  }
コード例 #28
0
 /**
  * Draws a filled or unfilled oval in the rectangle with corners at the points (x1,y1) and
  * (x2,y2). Nothing is drawn if x1 == x2 or y1 == y2.
  *
  * @param g the graphics context where the oval is drawn
  * @param filled tells whether to draw a filled or unfilled oval.
  */
 private void putOval(Graphics g, boolean filled, int x1, int y1, int x2, int y2) {
   if (x1 == x2 || y1 == y2) {
     return;
   }
   if (x2 < x1) { // Swap x1,x2 if necessary to make x2 > x1.
     int temp = x1;
     x1 = x2;
     x2 = temp;
   }
   if (y2 < y1) { // Swap y1,y2 if necessary to make y2 > y1.
     int temp = y1;
     y1 = y2;
     y2 = temp;
   }
   if (filled) {
     g.fillOval(x1, y1, x2 - x1, y2 - y1);
   } else {
     g.drawOval(x1, y1, x2 - x1, y2 - y1);
   }
 }
コード例 #29
0
    private void drawLayer(Graphics g, CPLayer layer, boolean selected) {
      Dimension d = getSize();

      if (selected) {
        g.setColor(new Color(0xB0B0C0));
      } else {
        g.setColor(Color.white);
      }
      g.fillRect(0, 0, d.width, layerH);
      g.setColor(Color.black);
      g.drawLine(0, 0, d.width, 0);
      g.drawLine(eyeW, 0, eyeW, layerH);

      g.drawString(layer.getName(), eyeW + 6, 12);
      g.drawLine(eyeW + 6, layerH / 2, d.width - 6, layerH / 2);
      g.drawString(modeNames[layer.getBlendMode()] + ": " + layer.getAlpha() + "%", eyeW + 6, 27);

      if (layer.isVisible()) {
        g.fillOval(eyeW / 2 - 5, layerH / 2 - 5, 10, 10);
      } else {
        g.drawOval(eyeW / 2 - 5, layerH / 2 - 5, 10, 10);
      }
    }
コード例 #30
0
ファイル: Life.java プロジェクト: dragon66/icafe
  public synchronized void nextGeneration() {
    int x, y;

    offScrGraphics.setColor(Color.red);

    CellCoordinate cellCoordinate;

    while (!nextLive.isEmpty()) {
      cellCoordinate = nextLive.removeFromHead();
      x = cellCoordinate.x;
      y = cellCoordinate.y;

      if (cell[x][y] == 0 && cellNeighbours[x][y] == 3) {
        cell[x][y] = 1;
        offScrGraphics.fillOval(x * cellSize + 1, y * cellSize + 1, cellSize - 2, cellSize - 2);
        live.addToTail(new CellCoordinate(x, y));
      }
      cellCoordinate = null;
    }

    offScrGraphics.setColor(Color.black);

    while (!nextDie.isEmpty()) {
      cellCoordinate = nextDie.removeFromHead();
      x = cellCoordinate.x;
      y = cellCoordinate.y;

      if ((cell[x][y] == 1) && (cellNeighbours[x][y] != 2) && (cellNeighbours[x][y] != 3)) {
        cell[x][y] = 0;
        offScrGraphics.fillRect(x * cellSize + 1, y * cellSize + 1, cellSize - 2, cellSize - 2);
        die.addToTail(new CellCoordinate(x, y));
      }
      cellCoordinate = null;
    }
    canvas.repaint();
    notifyAll();
  }