예제 #1
0
    @SuppressWarnings("UseJBColor")
    @Override
    protected void paintComponent(Graphics g) {
      final Insets i = getInsets();

      final Dimension d = getSize();

      final int left = i.left + (d.width - i.left - i.right - WIDTH) / 2;
      final int top = i.top + (d.height - i.top - i.bottom - HEIGHT) / 2;

      g.setColor(Color.WHITE);
      g.fillRect(left, top, WIDTH, HEIGHT);

      g.setColor(Color.GRAY);
      g.drawLine(left + 1, i.top + HEIGHT / 2, left + WIDTH - 3, i.top + HEIGHT / 2);
      g.drawRect(left + 1, top + 1, WIDTH - 3, HEIGHT - 3);

      for (int k = 1; k < 10; k++) {
        g.drawLine(left + 1 + k * 31, top + 1, left + 1 + k * 31, top + HEIGHT - 3);
      }

      for (int r = 0; r < myRecentColors.size(); r++) {
        int row = r / 10;
        int col = r % 10;
        Color color = myRecentColors.get(r);
        g.setColor(color);
        g.fillRect(left + 2 + col * 30 + col + 1, top + 2 + row * 30 + row + 1, 28, 28);
      }
    }
예제 #2
0
  public void drawVictory(Graphics g) {
    g.setColor(new Color(0, 0, 0, 200));
    g.fillRect(195, 220, 410, 110);
    g.setColor(new Color(255, 255, 255, 200));
    g.fillRect(200, 225, 400, 100);
    g.setColor(new Color(0, 0, 0, 200));
    g.setFont(new Font("Bell MT", Font.BOLD, 20));
    FontMetrics metrics = g.getFontMetrics(new Font("Bell MT", Font.BOLD, 20));
    int hgt = metrics.getHeight();

    String initialMessage;
    String followupMessage;

    if (nextWindow) {
      initialMessage = "You have gotten stronger.";
      followupMessage = player.getName() + " is now level " + player.getLevel() + "!";
    } else {
      initialMessage = "You survived!";
      followupMessage = "You and your allies gain " + totalExperience + " experience!";
    }

    // Hgt = 26
    int adv = metrics.stringWidth(initialMessage);
    g.drawString(initialMessage, getWidth() / 2 - adv / 2, 234 + hgt);
    adv = metrics.stringWidth(followupMessage);
    g.drawString(followupMessage, getWidth() / 2 - adv / 2, 269 + hgt);
  }
예제 #3
0
    @Override
    public void paintComponent(Graphics g) {
      Graphics g2 = g.create();

      Dimension d = getSize();
      CPArtwork artwork = controller.getArtwork();
      Object[] layers = artwork.getLayers();

      g2.setColor(new Color(0x606060));
      g2.fillRect(0, 0, d.width, d.height - layers.length * layerH);

      g2.setColor(Color.black);
      g2.translate(0, d.height - layerH);
      for (int i = 0; i < layers.length; i++) {
        drawLayer(g2, (CPLayer) layers[i], i == artwork.getActiveLayerNb());
        g2.translate(0, -layerH);
      }

      if (layerDragReally) {
        g2.translate(0, layers.length * layerH - (d.height - layerH));
        g2.drawRect(0, layerDragY - layerH / 2, d.width, layerH);

        int layerOver = (d.height - layerDragY) / layerH;
        if (layerOver <= layers.length
            && layerOver != layerDragNb
            && layerOver != layerDragNb + 1) {
          g2.fillRect(0, d.height - layerOver * layerH - 2, d.width, 4);
        }
      }
    }
예제 #4
0
  public void paintComponent(Graphics g) {
    super.paintComponent(g);
    this.setBackground(Color.black);

    // Nested for loop to draw all rows and columns
    for (int x = 0; x < num.tileRow; x++) {
      for (int y = 0; y < num.tileCol; y++) {

        if (land.xTile[x][y].isDiscovered) {
          g.setColor(land.xTile[x][y].locColor);
        } else {
          g.setColor(Color.black);
        }
        g.fillRect(
            (land.xTile[x][y].xPos + num.xOff) * num.zoom,
            (land.xTile[x][y].yPos + num.yOff) * num.zoom,
            num.tileSq * num.zoom,
            num.tileSq * num.zoom);
      }
    }

    // Code to draw and animate player
    g.setColor(Color.red);
    g.fillRect(
        num.tileSq * num.zoom * num.tileSq,
        num.tileSq * num.zoom * num.tileSq,
        num.tileSq * num.zoom,
        num.tileSq * num.zoom);
    g.setColor(Color.white);
    g.fillRect(num.tileCol * 5 - 50, 0, 150, num.tileRow * 5 + 15);
    g.setColor(Color.black);
    g.fillRect(num.tileCol * 5 - 50, 0, 10, num.tileRow * 5 + 15);
  }
예제 #5
0
 private void paintBell(Graphics g) {
   P9TermPreferences preferences = P9Term.getPreferences();
   if (preferences.getBoolean(P9TermPreferences.VISUAL_BELL) == false) {
     return;
   }
   Color foreground = preferences.getColor(P9TermPreferences.FOREGROUND_COLOR);
   if (preferences.getBoolean(P9TermPreferences.FANCY_BELL)) {
     // On decent hardware, we can produce a really tasteful effect by compositing a
     // semi-transparent rectangle over the terminal.
     // We need to choose a color that will show up against the background.
     // A reasonable assumption is that the user has already chosen such a color for the
     // foreground.
     Color color =
         new Color(foreground.getRed(), foreground.getGreen(), foreground.getBlue(), 100);
     g.setColor(color);
     g.fillRect(0, 0, getWidth(), getHeight());
   } else {
     // On a remote X11 display (or really rubbish hardware) the compositing effect is
     // prohibitively expensive, so we offer XOR instead.
     Color background = preferences.getColor(P9TermPreferences.BACKGROUND_COLOR);
     ;
     final int R = blend(background.getRed(), foreground.getRed());
     final int G = blend(background.getGreen(), foreground.getGreen());
     final int B = blend(background.getBlue(), foreground.getBlue());
     g.setColor(background);
     g.setXORMode(new Color(R, G, B));
     g.fillRect(0, 0, getWidth(), getHeight());
     g.setPaintMode();
   }
 }
예제 #6
0
  public void paint(Graphics graphics) {
    super.paint(graphics);
    int size = getFont().getSize();
    for (int y = 0; y < Chess.NUM_OF_ROWS; y++) {
      for (int x = 0; x < Chess.NUM_OF_COLS; x++) {
        //                System.out.println(y + " " + x);
        int sqi =
            (m_bottom == Chess.WHITE
                ? Chess.coorToSqi(x, Chess.NUM_OF_ROWS - y - 1)
                : Chess.coorToSqi(Chess.NUM_OF_COLS - x - 1, y));
        if (Chess.isWhiteSquare(sqi)) {
          graphics.setColor(m_whiteSquareColor);
          graphics.fillRect(x * size, y * size, size, size);
        } else {
          graphics.setColor(m_blackSquareColor);
          graphics.fillRect(x * size, y * size, size, size);
        }
        int stone = (sqi == m_draggedFrom ? Chess.NO_STONE : m_position.getStone(sqi));
        graphics.setColor(Chess.stoneToColor(stone) == Chess.WHITE ? m_whiteColor : m_blackColor);
        if (m_solidStones) stone = Chess.pieceToStone(Chess.stoneToPiece(stone), Chess.BLACK);
        //                graphics.drawString(getStringForStone(stone, Chess.isWhiteSquare(sqi)), x
        // * size, (y + 1) * size);
        graphics.drawString(getStringForStone(stone, true), x * size, (y + 1) * size);
      }
    }

    if (m_draggedStone != Chess.NO_STONE) {
      graphics.setColor(
          Chess.stoneToColor(m_draggedStone) == Chess.WHITE ? m_whiteColor : m_blackColor);
      graphics.drawString(
          getStringForStone(m_draggedStone, true), m_draggedX - size / 2, m_draggedY + size / 2);
    }
  }
예제 #7
0
  // draws the button, based on the type of button (ImageIcon, Image, or String)
  public void draw(Graphics g) {
    if (visible) {
      // if its image/imageicon, draw it
      g.setColor(new Color(50, 200, 50));
      g.fillRect(x - 1, y - 1, width + 2, height + 2);
      if (mode.equals("Image") || mode.equals("ImageIcon")) {
        if (enabled) {
          g.drawImage(image, x, y, null);
        } else {
          g.drawImage(BWimage, x, y, null);
        }
        // if its string, draw the string
      } else {

        g.setFont(new Font("Arial", Font.PLAIN, 20));
        if (enabled) {
          g.setColor(Color.black);
          g.drawString(message, x + 20, y + 20);
        } else {
          g.setColor(new Color(255, 255, 255));
          g.fillRect(x - 1, y - 1, width + 2, height + 2);
          g.setColor(Color.black);
          g.drawString(message, x + 20, y + 20);
        }
      }
    }
  }
예제 #8
0
 protected void paintBackground(Graphics g) {
   int draggedColumn = -1;
   if ((header != null) && (header.getTable() != null) && header.getDraggedColumn() != null) {
     draggedColumn =
         header.getColumnModel().getColumnIndex(header.getDraggedColumn().getIdentifier());
   }
   int w = getWidth();
   int h = getHeight();
   if ((table != null) && table.isEnabled() && (col == rolloverCol || col == draggedColumn)) {
     JTattooUtilities.fillHorGradient(
         g, AbstractLookAndFeel.getTheme().getRolloverColors(), 0, 0, w, h);
     if (drawRolloverBar()) {
       g.setColor(AbstractLookAndFeel.getFocusColor());
       g.drawLine(0, 0, w - 1, 0);
       g.drawLine(0, 1, w - 1, 1);
       g.drawLine(0, 2, w - 1, 2);
     }
   } else if (drawAllwaysActive() || JTattooUtilities.isFrameActive(header)) {
     if (header.getBackground() instanceof ColorUIResource) {
       JTattooUtilities.fillHorGradient(
           g, AbstractLookAndFeel.getTheme().getColHeaderColors(), 0, 0, w, h);
     } else {
       g.setColor(header.getBackground());
       g.fillRect(0, 0, w, h);
     }
   } else {
     if (header.getBackground() instanceof ColorUIResource) {
       JTattooUtilities.fillHorGradient(
           g, AbstractLookAndFeel.getTheme().getInActiveColors(), 0, 0, w, h);
     } else {
       g.setColor(header.getBackground());
       g.fillRect(0, 0, w, h);
     }
   }
 }
    /**
     * Paints a highlight.
     *
     * @param g the graphics context
     * @param offs0 the starting model offset &gt;= 0
     * @param offs1 the ending model offset &gt;= offs1
     * @param bounds the bounding box for the highlight
     * @param c the editor
     */
    public void paint(Graphics g, int offs0, int offs1, Shape bounds, JTextComponent c) {
      Rectangle alloc = bounds.getBounds();
      try {
        // --- determine locations ---
        TextUI mapper = c.getUI();
        Rectangle p0 = mapper.modelToView(c, offs0);
        Rectangle p1 = mapper.modelToView(c, offs1);

        // --- render ---
        Color color = getColor();

        if (color == null) {
          g.setColor(c.getSelectionColor());
        } else {
          g.setColor(color);
        }
        if (p0.y == p1.y) {
          // same line, render a rectangle
          Rectangle r = p0.union(p1);
          g.fillRect(r.x, r.y, r.width, r.height);
        } else {
          // different lines
          int p0ToMarginWidth = alloc.x + alloc.width - p0.x;
          g.fillRect(p0.x, p0.y, p0ToMarginWidth, p0.height);
          if ((p0.y + p0.height) != p1.y) {
            g.fillRect(alloc.x, p0.y + p0.height, alloc.width, p1.y - (p0.y + p0.height));
          }
          g.fillRect(alloc.x, p1.y, (p1.x - alloc.x), p1.height);
        }
      } catch (BadLocationException e) {
        // can't render
      }
    }
예제 #10
0
 @Override
 public void paint(Graphics g) {
   g.setColor(Color.LIGHT_GRAY);
   g.fillRect(0, 0, 1100, 600);
   g.setColor(Color.BLACK);
   for (int i = 0; i < 11; i++) {
     g.drawLine(i * 50, 0, i * 50, 500);
     g.drawLine(0, i * 50, 500, i * 50);
   }
   for (int i = 0; i < 11; i++) {
     g.drawLine(i * 50 + 550, 0, i * 50 + 550, 500);
     g.drawLine(550, i * 50, 1050, i * 50);
   }
   for (int x = 0; x < 10; x++) {
     for (int y = 0; y < 10; y++) {
       g.setColor(color1[x][y]);
       g.fillRect(x * 50 + 1, y * 50 + 1, 49, 49);
     }
   }
   for (int x = 0; x < 10; x++) {
     for (int y = 0; y < 10; y++) {
       g.setColor(color2[x][y]);
       g.fillRect(x * 50 + 1 + 550, y * 50 + 1, 49, 49);
     }
   }
 }
예제 #11
0
 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);
   }
 }
예제 #12
0
  public void paintComponent(Graphics graphics) {
    Rectangle bounds = getBounds();
    GraphicsUtility graphicsUtility = new GraphicsUtility(graphics);
    graphicsUtility.setStroke(GraphicsUtility.STROKE_BOLD);

    if (isSelected()) {
      graphics.setColor(GraphicsUtility.getSelectedColor());
      graphics.fillRect(0, 0, bounds.width, SELECT_BORDER_SIZE);
      graphics.fillRect(0, 0, SELECT_BORDER_SIZE, bounds.height);
      graphics.fillRect(0, bounds.height - SELECT_BORDER_SIZE, bounds.width, SELECT_BORDER_SIZE);
      graphics.fillRect(bounds.width - SELECT_BORDER_SIZE, 0, SELECT_BORDER_SIZE, bounds.height);
      graphics.setColor(Color.BLACK);
    }
    graphics.drawString(getCaption(), 10, 10);

    graphicsUtility.drawArrow(
        8, BORDER_INSET, BORDER_INSET, BORDER_INSET, bounds.height - BORDER_INSET);
    graphicsUtility.drawArrow(
        8,
        BORDER_INSET,
        bounds.height - BORDER_INSET,
        bounds.width - BORDER_INSET,
        bounds.height - BORDER_INSET);
    graphicsUtility.drawArrow(
        8,
        bounds.width - BORDER_INSET,
        bounds.height - BORDER_INSET,
        bounds.width - BORDER_INSET,
        BORDER_INSET);
    graphicsUtility.drawArrow(
        8, bounds.width - BORDER_INSET, BORDER_INSET, bounds.width - 50, BORDER_INSET);
    graphicsUtility.setStroke(GraphicsUtility.STROKE_NORMAL);
  }
예제 #13
0
  @Override
  public void paintDeterminate(Graphics g, JComponent c) {
    Insets b = progressBar.getInsets(); // area for border
    int barRectWidth = progressBar.getWidth() - b.right - b.left;
    int barRectHeight = progressBar.getHeight() - b.top - b.bottom;
    if (barRectWidth <= 0 || barRectHeight <= 0) {
      return;
    }
    // int cellLength = getCellLength();
    // int cellSpacing = getCellSpacing();
    // amount of progress to draw
    int amountFull = getAmountFull(b, barRectWidth, barRectHeight);

    // draw the cells
    if (progressBar.getOrientation() == SwingConstants.HORIZONTAL) {
      float x = amountFull / (float) barRectWidth;
      g.setColor(getColorFromPallet(pallet, x));
      g.fillRect(b.left, b.top, amountFull, barRectHeight);
    } else { // VERTICAL
      float y = amountFull / (float) barRectHeight;
      g.setColor(getColorFromPallet(pallet, y));
      g.fillRect(b.left, barRectHeight + b.bottom - amountFull, barRectWidth, amountFull);
    }
    // Deal with possible text painting
    if (progressBar.isStringPainted()) {
      paintString(g, b.left, b.top, barRectWidth, barRectHeight, amountFull, b);
    }
  }
예제 #14
0
  public void paintComponent(Graphics g) {
    if (m.isPressed()) {
      t = colorCount - 1;
      g.setColor(pressed[t]);
      g.fillRect(0, 0, getSize().width - 1, getSize().height - 1);
      g.setColor(border[t]);

    } else {
      g.setColor(rollOver[t]);
      g.fillRect(0, 0, getSize().width - 1, getSize().height - 1);
      g.setColor(border[t]);
      if (m.isRollover()) {
        if (t < colorCount - 1 && !fadeIn.isRunning()) {
          fadeOut.stop();
          fadeIn.start();
        }
      } else {
        if (t > 0 && !fadeOut.isRunning()) {
          fadeIn.stop();
          fadeOut.start();
        }
      }
    }

    super.paintComponent(g);
  }
    @Override
    public void paintIcon(final Component component, final Graphics g, final int i, final int j) {
      final int iconWidth = getIconWidth();
      final int iconHeight = getIconHeight();
      if (myColor != null) {
        g.setColor(myColor);
        g.fillRect(i, j, iconWidth, iconHeight);
      } else if (myColours != null) {
        final Color top = myColours[0];
        g.setColor(top);
        g.fillRect(i, j, iconWidth, 2);

        final Color right = myColours[1];
        g.setColor(right);
        g.fillRect(i + iconWidth / 2, j + 2, iconWidth / 2, iconHeight / 2);

        final Color bottom = myColours[2];
        g.setColor(bottom);
        g.fillRect(i, j + iconHeight - 2, iconWidth, 2);

        final Color left = myColours[3];
        g.setColor(left);
        g.fillRect(i, j + 2, iconWidth / 2, iconHeight / 2);
      }

      final Composite old = ((Graphics2D) g).getComposite();
      ((Graphics2D) g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.1f));
      g.setColor(Color.BLACK);
      g.drawRect(i, j, iconWidth - 1, iconHeight - 1);
      ((Graphics2D) g).setComposite(old);
    }
예제 #16
0
파일: Card.java 프로젝트: agale123/Catan
  public void paint(Graphics g) {

    g.fillRect((_x), (_y), _w, _h);
    g.fillRect((_x), (_y), _w, _h);
    g.fillRect((_x), (_y), _w, _h);
    g.drawImage(images.get(mytype), (_x), (_y), _w, _h, null);
  }
예제 #17
0
 protected void paintBackground(Graphics g, JComponent c, int x, int y, int w, int h) {
   JMenuItem b = (JMenuItem) c;
   ButtonModel model = b.getModel();
   if (c.getParent() instanceof JMenuBar) {
     if (model.isArmed() || (c instanceof JMenu && model.isSelected())) {
       g.setColor(AbstractLookAndFeel.getMenuSelectionBackgroundColor());
       g.fillRect(x, y, w, h);
     }
   } else {
     if (model.isArmed() || (c instanceof JMenu && model.isSelected())) {
       g.setColor(AbstractLookAndFeel.getMenuSelectionBackgroundColor());
       g.fillRect(x, y, w, h);
     } else if (!AbstractLookAndFeel.getTheme().isMenuOpaque()) {
       Graphics2D g2D = (Graphics2D) g;
       Composite composite = g2D.getComposite();
       AlphaComposite alpha =
           AlphaComposite.getInstance(
               AlphaComposite.SRC_OVER, AbstractLookAndFeel.getTheme().getMenuAlpha());
       g2D.setComposite(alpha);
       g.setColor(AbstractLookAndFeel.getMenuBackgroundColor());
       g.fillRect(x, y, w, h);
       g2D.setComposite(composite);
     } else {
       g.setColor(AbstractLookAndFeel.getMenuBackgroundColor());
       g.fillRect(x, y, w, h);
     }
   }
   if (menuItem.isSelected() && menuItem.isArmed()) {
     g.setColor(AbstractLookAndFeel.getMenuSelectionForegroundColor());
   } else {
     g.setColor(AbstractLookAndFeel.getMenuForegroundColor());
   }
 }
예제 #18
0
 public static void smoothFillInverseHorGradient(
     Graphics g, Color[] colors, int x, int y, int w, int h) {
   if (colors != null) {
     Graphics2D g2D = (Graphics2D) g;
     Paint savedPaint = g2D.getPaint();
     int steps = colors.length;
     double dy = (double) h / (double) steps;
     int y1 = y;
     for (int i = 0; i < steps; i++) {
       int y2 = y + (int) Math.round((double) i * dy);
       g.setColor(colors[colors.length - i - 1]);
       if (i == (steps - 1)) {
         g2D.setPaint(null);
         g2D.setColor(colors[colors.length - i - 1]);
         g.fillRect(x, y1, w, y + h - y1);
       } else {
         g2D.setPaint(
             new GradientPaint(
                 0, y1, colors[colors.length - i - 1], 0, y2, colors[colors.length - i - 2]));
         g.fillRect(x, y1, w, y2 - y1);
       }
       y1 = y2;
     }
     g2D.setPaint(savedPaint);
   }
 }
예제 #19
0
파일: Viewer.java 프로젝트: lrei/overbrain
    public void paint(Graphics g) {
      g.setColor(Color.black);
      g.fillRect(0, 0, (int) getSize().getWidth(), (int) getSize().getHeight());

      int color_strength = 0;
      for (int i = 0; i < pheroMap.length; i++)
        for (int j = 0; j < pheroMap[i].length; j++) {
          if (pheroMap[i][j] == null) System.err.println(i + " " + j);
          if (pheroMap[i][j].getWallProbability() != 0) {
            color_strength =
                (int) (pheroMap[i][j].getWallProbability() * 100.0 * COLOR_SCALE_FACTOR);
            if (color_strength > 255) color_strength = 255;

            if (pheroMap[i][j].getWallProbability() > 0.55) {
              g.setColor(new Color(255, 255 - color_strength, 255 - color_strength));
            }
            if (pheroMap[i][j].getWallProbability() < 0.55) {
              g.setColor(
                  new Color(255 - color_strength, 255 - color_strength, 255 - color_strength));
            }
            if (pheroMap[i][j].getWallProbability() == 0.55) {
              g.setColor(new Color(255, 255, 255));
            }
            g.fillRect(
                i * square_side,
                (pheroMap[i].length - j - 1) * square_side,
                square_side,
                square_side);
          }
        }

      g.setColor(Color.black);
      for (int y = square_side * 10; y < getSize().getHeight(); y += square_side * 10)
        g.drawLine(0, y, (int) getSize().getWidth() - 1, y);
      for (int x = square_side * 10; x < getSize().getWidth(); x += square_side * 10)
        g.drawLine(x, 0, x, (int) getSize().getHeight());

      if (points != null) {
        for (Point2D pt : points) {
          g.setColor(Color.yellow);
          g.fillOval(
              (int) (pt.getX() * 10 * square_side) - 12,
              (int) ((pheroMap[0].length - (pt.getY() * 10)) * square_side) - 12,
              25,
              25);
        }
      }

      g.setColor(Color.blue);
      g.fillOval(
          (int) (rob_x) * square_side - 20,
          (int) ((pheroMap[0].length - 10) - (rob_y)) * square_side - 20,
          ROBOT_RADIUS,
          ROBOT_RADIUS);

      // g.setColor(new Color(0, 0, 0));
      // g.fillRect( 24*2*square_side, 12*2*square_side, square_side, square_side);
    }
예제 #20
0
 /**
  * Paint method for applet.
  *
  * @param g the Graphics object for this applet
  */
 public void paint(Graphics g) {
   // simple text displayed on applet
   g.setColor(c);
   g.fillRect(0, 0, 200, 100);
   g.setColor(Color.black);
   g.drawString("Sample Applet", 20, 20);
   g.setColor(Color.blue);
   g.drawString("created by BlueJ", 20, 40);
 }
예제 #21
0
 public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
   Color logoColor = AbstractLookAndFeel.getMenuSelectionBackgroundColor();
   Color borderColorLo = AbstractLookAndFeel.getFrameColor();
   Color borderColorHi =
       ColorHelper.brighter(AbstractLookAndFeel.getMenuSelectionBackgroundColor(), 40);
   g.setColor(logoColor);
   if (JTattooUtilities.isLeftToRight(c)) {
     int dx = getBorderInsets(c).left;
     g.fillRect(x, y, dx - 1, h - 1);
     paintLogo(c, g, x, y, w, h);
     // - highlight
     g.setColor(ColorHelper.brighter(AbstractLookAndFeel.getMenuBackgroundColor(), 40));
     g.drawLine(x + dx, y + 1, x + w - 2, y + 1);
     g.setColor(borderColorHi);
     g.drawLine(x + 1, y, x + 1, y + h - 2);
     // - outer frame
     g.setColor(borderColorLo);
     if (isMenuBarPopup(c)) {
       // top
       g.drawLine(x + dx - 1, y, x + w, y);
       // left
       g.drawLine(x, y, x, y + h - 1);
       // bottom
       g.drawLine(x, y + h - 1, x + w, y + h - 1);
       // right
       g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1);
     } else {
       g.drawRect(x, y, w - 1, h - 1);
     }
     // - logo separator
     g.drawLine(x + dx - 1, y + 1, x + dx - 1, y + h - 1);
   } else {
     int dx = getBorderInsets(c).right;
     g.fillRect(x + w - dx, y, dx, h - 1);
     paintLogo(c, g, x, y, w, h);
     // - highlight
     g.setColor(ColorHelper.brighter(AbstractLookAndFeel.getMenuBackgroundColor(), 40));
     g.drawLine(x + 1, y + 1, x + w - dx - 1, y + 1);
     g.drawLine(x + 1, y + 1, x + 1, y + h - 2);
     // - outer frame
     g.setColor(borderColorLo);
     if (isMenuBarPopup(c)) {
       // top
       g.drawLine(x, y, x + w - dx, y);
       // left
       g.drawLine(x, y, x, y + h - 1);
       // bottom
       g.drawLine(x, y + h - 1, x + w, y + h - 1);
       // right
       g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);
     } else {
       g.drawRect(x, y, w - 1, h - 1);
     }
     // - logo separator
     g.drawLine(x + w - dx, y + 1, x + w - dx, y + h - 1);
   }
 }
예제 #22
0
  private void replaceSurfaceData(
      int newBackBufferCount, BufferCapabilities newBackBufferCaps, boolean blit) {
    synchronized (surfaceDataLock) {
      final SurfaceData oldData = getSurfaceData();
      surfaceData = platformWindow.replaceSurfaceData();
      // TODO: volatile image
      //        VolatileImage oldBB = backBuffer;
      BufferedImage oldBB = backBuffer;
      backBufferCount = newBackBufferCount;
      backBufferCaps = newBackBufferCaps;
      final Rectangle size = getSize();
      if (getSurfaceData() != null && oldData != getSurfaceData()) {
        clearBackground(size.width, size.height);
      }

      if (blit) {
        blitSurfaceData(oldData, getSurfaceData());
      }

      if (oldData != null && oldData != getSurfaceData()) {
        // TODO: drop oldData for D3D/WGL pipelines
        // This can only happen when this peer is being created
        oldData.flush();
      }

      // TODO: volatile image
      //        backBuffer = (VolatileImage)delegate.createBackBuffer();
      backBuffer = (BufferedImage) platformWindow.createBackBuffer();
      if (backBuffer != null) {
        Graphics g = backBuffer.getGraphics();
        try {
          Rectangle r = getBounds();
          if (g instanceof Graphics2D) {
            ((Graphics2D) g).setComposite(AlphaComposite.Src);
          }
          g.setColor(nonOpaqueBackground);
          g.fillRect(0, 0, r.width, r.height);
          if (g instanceof SunGraphics2D) {
            ((SunGraphics2D) g).constrain(0, 0, r.width, r.height, getRegion());
          }
          if (!isTextured()) {
            g.setColor(getBackground());
            g.fillRect(0, 0, r.width, r.height);
          }
          if (oldBB != null) {
            // Draw the old back buffer to the new one
            g.drawImage(oldBB, 0, 0, null);
            oldBB.flush();
          }
        } finally {
          g.dispose();
        }
      }
    }
    flushOnscreenGraphics();
  }
예제 #23
0
파일: MazeView.java 프로젝트: aumgn/Cours
  @Override
  protected void paintComponent(Graphics g) {
    g.clearRect(0, 0, getWidth(), getHeight());

    g.setColor(Color.BLACK);
    g.drawRect(CELL_SIZE, CELL_SIZE, maze.width * CELL_SIZE, maze.height * CELL_SIZE);

    drawWalls(g, maze);

    boolean even = true;
    PathCell pathIt = path.first;
    while (pathIt != null) {
      even = !even;
      g.setColor(even ? Color.GREEN : Color.CYAN);
      g.fillRect(
          CELL_SIZE + pathIt.node.x * CELL_SIZE + 1,
          CELL_SIZE + pathIt.node.y * CELL_SIZE + 1,
          pathIt.node.width * CELL_SIZE - 1,
          pathIt.node.height * CELL_SIZE - 1);

      MazeNode door = pathIt.doorNode;
      g.setColor(Color.YELLOW);
      if (door != null) {

        if (door.division == Division.VERTICAL) {
          g.drawLine(
              CELL_SIZE + door.doorX * CELL_SIZE,
              CELL_SIZE + door.doorY * CELL_SIZE + 1,
              CELL_SIZE + door.doorX * CELL_SIZE,
              CELL_SIZE + (door.doorY + 1) * CELL_SIZE - 1);
        } else {
          g.drawLine(
              CELL_SIZE + door.doorX * CELL_SIZE + 1,
              CELL_SIZE + door.doorY * CELL_SIZE,
              CELL_SIZE + (door.doorX + 1) * CELL_SIZE - 1,
              CELL_SIZE + door.doorY * CELL_SIZE);
        }
      }

      pathIt = pathIt.next;
    }

    g.setColor(Color.ORANGE);
    g.fillRect(
        CELL_SIZE + sx * CELL_SIZE + 2,
        CELL_SIZE + sy * CELL_SIZE + 2,
        CELL_SIZE - 3,
        CELL_SIZE - 3);
    g.setColor(Color.RED);
    g.fillRect(
        CELL_SIZE + dx * CELL_SIZE + 2,
        CELL_SIZE + dy * CELL_SIZE + 2,
        CELL_SIZE - 3,
        CELL_SIZE - 3);
  }
예제 #24
0
 public void paintLogo(Graphics g, Color color, int size, int posX, int posY) {
   if (g == null) return;
   super.paint(g);
   g.setColor(color);
   g.fillRect(posX, posY, size, size);
   if (color == Color.WHITE) g.setColor(Color.LIGHT_GRAY);
   else g.setColor(Color.WHITE);
   g.fillOval(posX + 5, posY + 5, size - 10, size - 10);
   g.setColor(Color.BLACK);
   g.fillRect(posX + (size / 2) - 5, posY + (size / 2) - 5, 10, 10);
 }
예제 #25
0
  public void paintComponent(Graphics g) {
    super.paintComponent(g);
    g.setColor(BACKGROUND);
    g.fillRect(0, 0, width, height);
    g.setColor(FOREGROUND);

    for (int i = 0; i < NUMBOXES; i++) {
      g.fillRect(boxXs[i], boxYs[i], BOXWIDTH, BOXHEIGHT);
      g.drawLine(lineXs[i], lineYs[i], lineXXs[i], lineYYs[i]);
    }
  }
예제 #26
0
  /** {@inheritDoc} */
  @Override
  public void finishedPaintingChildren(final JSplitPane jc, final Graphics g) {
    if (jc == splitPane && getLastDragLocation() != -1 && !isContinuousLayout() && !draggingHW) {
      final Dimension size = splitPane.getSize();

      g.setColor(dragDividerColor);
      if (getOrientation() == JSplitPane.HORIZONTAL_SPLIT) {
        g.fillRect(getLastDragLocation(), 0, dividerSize - 1, size.height - 1);
      } else {
        g.fillRect(0, getLastDragLocation(), size.width - 1, dividerSize - 1);
      }
    }
  }
예제 #27
0
 @Override
 protected void paintComponent(Graphics g) {
   super.paintComponent(g);
   if (myColorDescriptor != null) {
     final int size = getBounds().height;
     g.setColor(getBackground());
     g.fillRect(0, 0, size + getIconTextGap() + 1, size);
     g.setColor(myColorDescriptor.getResolvedColor());
     g.fillRect(2, 2, size - 4, size - 4);
     g.setColor(Color.BLACK);
     g.drawRect(2, 2, size - 4, size - 4);
   }
 }
예제 #28
0
  public void paint(Graphics g) {
    g.setColor(Color.GRAY);
    g.fillRect(0, 0, getWidth(), getHeight());

    Rectangle sheetRect = renderer.getSheetRect();

    g.setColor(Color.WHITE);
    g.fillRect(sheetRect.x, sheetRect.y, sheetRect.width, sheetRect.height);

    g.setColor(Color.BLACK);
    g.drawRect(sheetRect.x, sheetRect.y, sheetRect.width, sheetRect.height);

    renderer.render(g);
  }
예제 #29
0
    /** Paints the border */
    public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {

      x += backgroundThickness;
      y += backgroundThickness;
      height -= 2 * backgroundThickness;
      width -= 2 * backgroundThickness;

      // Right
      g.setColor(borderColor);
      g.drawLine(x + width - 4, y, x + width - 4, y + height);
      g.setColor(shadowColor);
      g.drawLine(x + width - 3, y, x + width - 3, y + height);
      g.drawLine(x + width - 2, y, x + width - 2, y + height);
      g.setColor(backgroundColor);
      g.drawLine(x + width - 1, y, x + width - 1, y + height);
      g.fillRect(x + width - 3, y, x + width, y + 5);

      // Bottom
      g.setColor(borderColor);
      g.drawLine(x + 3, y + height - 4, x + width - 4, y + height - 4);
      g.setColor(shadowColor);
      g.drawLine(x, y + height - 3, x + width - 2, y + height - 3);
      g.drawLine(x, y + height - 2, x + width - 2, y + height - 2);
      g.setColor(backgroundColor);
      g.drawLine(x, y + height - 1, x + width, y + height - 1);
      g.fillRect(x, y + height - 3, x + 5, y + height);

      // Top
      g.setColor(backgroundColor);
      g.drawLine(x, y, x + width, y);
      g.drawLine(x, y + 1, x + width, y + 1);
      g.drawLine(x, y + 2, x + width, y + 2);
      g.setColor(borderColor);
      g.drawLine(x, y + 3, x + width - 4, y + 3);

      // Left
      g.setColor(backgroundColor);
      g.drawLine(x, y, x, y + height);
      g.drawLine(x + 1, y, x + 1, y + height);
      g.drawLine(x + 2, y, x + 2, y + height);
      g.setColor(borderColor);
      g.drawLine(x + 3, y + 3, x + 3, y + height - 4);

      // Background around the border
      g.setColor(backgroundColor);
      for (int i = 0; i < backgroundThickness + 1; i++) {
        g.drawRect(x - i, y - i, width - 1 + 2 * i, height - 1 + 2 * i);
      }
    }
예제 #30
0
    @Override
    protected void paintComponent(Graphics g) {
      Graphics2D g2d = (Graphics2D) g;

      final Dimension size = getSize();
      int _size = Math.min(size.width, size.height);
      _size = Math.min(_size, 600);

      if (myImage != null && myShouldInvalidate) {
        if (myImage.getWidth(null) != _size) {
          myImage = null;
        }
      }

      myShouldInvalidate = false;

      if (myImage == null) {
        myImage =
            createImage(
                new ColorWheelImageProducer(
                    _size - BORDER_SIZE * 2, _size - BORDER_SIZE * 2, myBrightness));
        myWheel =
            new Rectangle(
                BORDER_SIZE, BORDER_SIZE, _size - BORDER_SIZE * 2, _size - BORDER_SIZE * 2);
      }

      g.setColor(UIManager.getColor("Panel.background"));
      g.fillRect(0, 0, getWidth(), getHeight());

      g2d.setComposite(
          AlphaComposite.getInstance(AlphaComposite.SRC_OVER, ((float) myOpacity) / 255f));
      g.drawImage(myImage, myWheel.x, myWheel.y, null);

      g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC, 1.0f));

      int mx = myWheel.x + myWheel.width / 2;
      int my = myWheel.y + myWheel.height / 2;
      //noinspection UseJBColor
      g.setColor(Color.WHITE);
      int arcw = (int) (myWheel.width * mySaturation / 2);
      int arch = (int) (myWheel.height * mySaturation / 2);
      double th = myHue * 2 * Math.PI;
      final int x = (int) (mx + arcw * Math.cos(th));
      final int y = (int) (my - arch * Math.sin(th));
      g.fillRect(x - 2, y - 2, 4, 4);
      //noinspection UseJBColor
      g.setColor(Color.BLACK);
      g.drawRect(x - 2, y - 2, 4, 4);
    }