Example #1
0
 public void paint(Graphics g) {
   g.setColor(Color.gray);
   g.fillRect(0, 0, w, h);
   g.setColor(Color.black);
   g.drawRect(0, 0, w, h);
   g.setColor(Color.blue);
   g.fillRect(0, h, w, h);
   g.setColor(Color.black);
   g.drawRect(0, h, w, h);
   g.drawString("resting", 10, 20);
   g.drawString("waits to swim", 10, h - 20);
   g.drawString("waits to exit", 10, (3 * h) / 2 - 20);
   g.drawString("swimming", 10, 2 * h - 20);
   if (e == null) return;
   for (int i = 0; i < e.e.length; i++) {
     switch (e.get(i)) {
       case 0:
         rect(g, (i < e.K ? Color.red : Color.green), i, 0);
         break;
       case 1:
         rect(g, (i < e.K ? Color.red : Color.green), i, 1);
         break;
       case 2:
         rect(g, (i < e.K ? Color.red : Color.green), i, 3);
         break;
       case 3:
         rect(g, (i < e.K ? Color.red : Color.green), i, 2);
         break;
       default:
     }
   }
 }
		@Override
		public void paintComponent(Graphics g) {
			Rectangle player = game.getPlayerArea();
			g.setColor(Color.RED);
			g.drawRect(player.x, player.y, player.width, player.height);

			g.setColor(Color.BLACK);
			for(Rectangle bullet : game.getBulletAreaList()) {
				g.drawRect(bullet.x, bullet.y, bullet.width, bullet.height);
			}

			g.setColor(Color.BLUE);
			for(Rectangle enemy : game.getEnemyAreaList()) {
				g.drawRect(enemy.x, enemy.y, enemy.width, enemy.height);
			}

			g.setColor(Color.BLACK);
			g.drawString(Integer.toString(score), 10, 10);
			g.drawString(Integer.toString(highScore), 350, 10);

			g.setColor(Color.BLACK);
			if (game.isGameOver()) {
				g.drawString("Game Over.", ShootingSquare.FRAME_SIZE / 2,
						ShootingSquare.FRAME_SIZE / 2);
			}
		}
Example #3
0
  public void paint(Graphics g) {

    g.setColor(Color.green);

    g.drawRect(25, 50, 200, 0);

    g.drawRect(25, 100, 200, 100);

    g.drawRoundRect(25, 250, 200, 100, 10, 10);

    g.drawRect(250, 100, 250, 100);
    g.fillRect(250, 100, 250, 100);

    g.setColor(Color.black);
    g.drawOval(250, 100, 250, 100);

    g.setColor(Color.green);
    g.drawOval(250, 250, 250, 99);
    g.fillOval(250, 250, 250, 100);

    g.drawOval(550, 100, 250, 100);
    g.drawArc(550, 100, 250, 100, 90, 82);
    g.fillArc(550, 100, 250, 100, 90, 82);

    g.drawOval(600, 250, 100, 100);
  }
  /**
   * Calls <code>setBoundsForFrame</code> with the new values.
   *
   * @param f the component to be resized
   * @param newX the new x-coordinate
   * @param newY the new y-coordinate
   * @param newWidth the new width
   * @param newHeight the new height
   */
  public void resizeFrame(JComponent f, int newX, int newY, int newWidth, int newHeight) {

    if (dragMode == DEFAULT_DRAG_MODE || dragMode == FASTER_DRAG_MODE) {
      setBoundsForFrame(f, newX, newY, newWidth, newHeight);
    } else {
      JDesktopPane desktopPane = getDesktopPane(f);
      if (desktopPane != null) {
        Graphics g = JComponent.safelyGetGraphics(desktopPane);

        g.setXORMode(Color.white);
        if (currentBounds != null) {
          g.drawRect(
              currentBounds.x, currentBounds.y, currentBounds.width - 1, currentBounds.height - 1);
        }
        g.drawRect(newX, newY, newWidth - 1, newHeight - 1);

        // Work around for 6635462, see comment in dragFrame()
        sun.java2d.SurfaceData sData = ((sun.java2d.SunGraphics2D) g).getSurfaceData();
        if (!sData.isSurfaceLost()) {
          currentBounds = new Rectangle(newX, newY, newWidth, newHeight);
        }

        g.setPaintMode();
        g.dispose();
      }
    }
  }
  private void drawPedals(Graphics g, int panelWidth, int panelHeight) {
    // drawing the box for gas
    int x = panelWidth / 2 - WheelRadius - ElementPadding - PedalBoxWidth - 2 * PedalBorderSize;
    int y = panelHeight / 2 - PedalBoxHeight / 2 - 2 * PedalBorderSize;
    g.setColor(Color.LIGHT_GRAY);
    g.drawRect(x, y, PedalBoxWidth + PedalBorderSize, PedalBoxHeight + PedalBorderSize);

    // drawing the fill in the gas box
    int valueScaleRatio = (int) (PedalBoxHeight / DriverInput.MaxPedalPushValue);
    double valueDiffFromMax = DriverInput.MaxPedalPushValue - in.getGasPedalPercentage();
    int tempGasPedalBoxX = x;
    int tempGasPedalBoxY = y;
    x += PedalBorderSize;
    y += valueDiffFromMax * valueScaleRatio + PedalBorderSize;
    g.setColor(Color.GREEN);
    g.fillRect(x, y, PedalBoxWidth, (int) (PedalBoxHeight - (valueDiffFromMax * valueScaleRatio)));

    // drawing the box for brake
    x = tempGasPedalBoxX - ElementPadding - PedalBoxWidth - 2 * PedalBorderSize;
    y = tempGasPedalBoxY;
    g.setColor(Color.LIGHT_GRAY);
    g.drawRect(x, y, PedalBoxWidth + PedalBorderSize, PedalBoxHeight + PedalBorderSize);

    // drawing the fill in the brake box
    valueDiffFromMax = DriverInput.MaxPedalPushValue - in.getBrakePedalPercentage();
    x += PedalBorderSize;
    y += valueDiffFromMax * valueScaleRatio + PedalBorderSize;
    g.setColor(Color.RED);
    g.fillRect(x, y, PedalBoxWidth, (int) (PedalBoxHeight - (valueDiffFromMax * valueScaleRatio)));
  }
  @Override
  protected void renderMoveSelectionForCell(Graphics g, int xCell, int yCell, String theMove) {
    int width = g.getClipBounds().width;
    int height = g.getClipBounds().height;
    xCell -= 2;

    String xLetter = coordinateToLetter(xCell);

    String[] moveParts = theMove.split(" ");
    String xTarget = moveParts[5];
    int yTarget = Integer.parseInt(moveParts[6]);
    if (xLetter.equals(xTarget) && yCell == yTarget) {
      g.setColor(Color.BLUE);
      g.drawRect(3, 3, width - 6, height - 6);
      CommonGraphics.fillWithString(g, "X", 3);
    }
    if (moveParts.length > 8) {
      xTarget = moveParts[7];
      yTarget = Integer.parseInt(moveParts[8]);
      if (xLetter.equals(xTarget) && yCell == yTarget) {
        g.setColor(Color.BLUE);
        g.drawRect(3, 3, width - 6, height - 6);
        CommonGraphics.fillWithString(g, "Y", 3);
      }
    }
    if (moveParts.length > 10) {
      xTarget = moveParts[9];
      yTarget = Integer.parseInt(moveParts[10]);
      if (xLetter.equals(xTarget) && yCell == yTarget) {
        g.setColor(Color.BLUE);
        g.drawRect(3, 3, width - 6, height - 6);
        CommonGraphics.fillWithString(g, "Z", 3);
      }
    }
  }
Example #7
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);
   }
 }
  private static ImageIcon makeColorIconForColor(final Color color) {
    final int size = UIUtil.isRetina() ? 8 : 16;
    final int halfSize = size / 2;

    final Image img = UIUtil.createImage(size, size, BufferedImage.TYPE_INT_RGB);
    final Graphics gfx = img.getGraphics();
    try {
      if (color == null) {
        gfx.setColor(IdeaUtils.isDarkTheme() ? Color.darkGray : Color.white);
        gfx.fillRect(0, 0, size, size);
        gfx.setColor(IdeaUtils.isDarkTheme() ? Color.yellow : Color.black);
        gfx.drawRect(0, 0, size - 1, size - 1);
        gfx.drawLine(0, 0, size - 1, size - 1);
      } else if (color == DIFF_COLORS) {
        gfx.setColor(Color.red);
        gfx.fillRect(0, 0, halfSize, halfSize);
        gfx.setColor(Color.green);
        gfx.fillRect(halfSize, 0, halfSize, halfSize);
        gfx.setColor(Color.blue);
        gfx.fillRect(0, halfSize, halfSize, halfSize);
        gfx.setColor(Color.yellow);
        gfx.fillRect(halfSize, halfSize, halfSize, halfSize);
      } else {
        gfx.setColor(color);
        gfx.fillRect(0, 0, size, size);
        gfx.setColor(Color.black);
        gfx.drawRect(0, 0, size - 1, size - 1);
      }
    } finally {
      gfx.dispose();
    }
    return new ImageIcon(img);
  }
Example #9
0
  public void mouseDragged(MouseEvent evt) {
    Graphics g = canvas.getGraphics();
    g.setColor(color);

    if (type == 0) {
      g.setXORMode(canvas.getBackground());
      g.drawRect(start.x, start.y, end.x - start.x, end.y - start.y);
      end = evt.getPoint();
      g.drawRect(start.x, start.y, end.x - start.x, end.y - start.y);
    } else if (type == 1) {
      int radius;

      g.setXORMode(canvas.getBackground());

      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);
      end = evt.getPoint();

      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);
    } else if (type == 2) {
      g.setXORMode(canvas.getBackground());
      g.drawOval(start.x, start.y, end.x - start.x, end.y - start.y);
      end = evt.getPoint();
      g.drawOval(start.x, start.y, end.x - start.x, end.y - start.y);
    }
  }
  /**
   * Moves the visible location of the frame being dragged to the location specified. The means by
   * which this occurs can vary depending on the dragging algorithm being used. The actual logical
   * location of the frame might not change until <code>endDraggingFrame</code> is called.
   */
  public void dragFrame(JComponent f, int newX, int newY) {

    if (dragMode == OUTLINE_DRAG_MODE) {
      JDesktopPane desktopPane = getDesktopPane(f);
      if (desktopPane != null) {
        Graphics g = JComponent.safelyGetGraphics(desktopPane);

        g.setXORMode(Color.white);
        if (currentLoc != null) {
          g.drawRect(currentLoc.x, currentLoc.y, f.getWidth() - 1, f.getHeight() - 1);
        }
        g.drawRect(newX, newY, f.getWidth() - 1, f.getHeight() - 1);
        /* Work around for 6635462: XOR mode may cause a SurfaceLost on first use.
         * Swing doesn't expect that its XOR drawRect did
         * not complete, so believes that on re-entering at
         * the next update location, that there is an XOR rect
         * to draw out at "currentLoc". But in fact
         * it's now got a new clean surface without that rect,
         * so drawing it "out" in fact draws it on, leaving garbage.
         * So only update/set currentLoc if the draw completed.
         */
        sun.java2d.SurfaceData sData = ((sun.java2d.SunGraphics2D) g).getSurfaceData();

        if (!sData.isSurfaceLost()) {
          currentLoc = new Point(newX, newY);
        }
        g.dispose();
      }
    } else if (dragMode == FASTER_DRAG_MODE) {
      dragFrameFaster(f, newX, newY);
    } else {
      setBoundsForFrame(f, newX, newY, f.getWidth(), f.getHeight());
    }
  }
Example #11
0
  public static void paint(Graphics g) {
    g.setColor(Color.BLACK);
    g.fillRect(0, 0, 80, View.getFrameHeight());

    int h = (View.getFrameHeight() - 50) / 10;
    for (int i = 0; i < items.length; i++) {
      if (selectedItem != -1 && i == selectedItem) {
        g.setColor(Color.WHITE);
        if (items[i] != null) {
          g.drawImage(items[i].getImage(), 5, i * h + (i + 1) * 5, 70, h, null);
        }
        g.drawRect(5, i * h + (i + 1) * 5, 70, h);
      } else {
        if (items[i] != null) {
          g.drawImage(items[i].getImage(), 5, i * h + (i + 1) * 5, 70, h, null);
        }
        g.setColor(Color.GRAY);
        g.drawRect(5, i * h + (i + 1) * 5, 70, h);
      }

      if (items[i] instanceof HardDrive && ((HardDrive) items[i]).beingProgrammed()) {
        g.setColor(new Color(1f, 1f, 1f, 0.5f));
        g.fillRect(5, i * h + (i + 1) * 5, 70, h);

        g.setColor(Color.RED);
        g.setFont(new Font("Arial", Font.BOLD, 11));
        g.drawString("Being", 15, i * h + (i + 1) * 5 + 15);
        g.drawString("Progra", 15, i * h + (i + 1) * 5 + 25);
        g.drawString("mmed...", 15, i * h + (i + 1) * 5 + 35);
      }
    }
  }
Example #12
0
  /** Overrides <code>Graphics.drawRect</code>. */
  public void drawRect(int x, int y, int width, int height) {
    DebugGraphicsInfo info = info();

    if (debugLog()) {
      info().log(toShortString() + " Drawing rect: " + new Rectangle(x, y, width, height));
    }

    if (isDrawingBuffer()) {
      if (debugBuffered()) {
        Graphics debugGraphics = debugGraphics();

        debugGraphics.drawRect(x, y, width, height);
        debugGraphics.dispose();
      }
    } else if (debugFlash()) {
      Color oldColor = getColor();
      int i, count = (info.flashCount * 2) - 1;

      for (i = 0; i < count; i++) {
        graphics.setColor((i % 2) == 0 ? info.flashColor : oldColor);
        graphics.drawRect(x, y, width, height);
        Toolkit.getDefaultToolkit().sync();
        sleep(info.flashTime);
      }
      graphics.setColor(oldColor);
    }
    graphics.drawRect(x, y, width, height);
  }
  private void drawKey(Graphics g, int index, Color keyColor) {
    int xOffset = IMG_XOFFSET;
    int yOffset = IMG_YOFFSET + ITEM_HEIGHT * index;

    if (keyColor.equals(Color.RED)) {
      loadImage();
      g.drawImage(img_redkey, xOffset, yOffset, null);
    } else {
      g.setColor(Color.BLACK);
      g.drawRect(xOffset + 7, yOffset + 19, 6, 24);
      g.setColor(keyColor);
      g.fillRect(xOffset + 7, yOffset + 19, 6, 24);

      g.setColor(Color.BLACK);
      g.drawRect(xOffset + 7, yOffset + 33, 10, 5);
      g.setColor(keyColor);
      g.fillRect(xOffset + 7, yOffset + 33, 10, 5);

      g.setColor(Color.BLACK);
      g.drawOval(xOffset + 0, yOffset + 0, 20, 20);
      g.setColor(keyColor);
      g.fillOval(xOffset + 0, yOffset + 0, 20, 20);
      g.setColor(Color.BLACK);
      g.drawOval(xOffset + 7, yOffset + 3, 6, 6);
      g.fillOval(xOffset + 7, yOffset + 3, 6, 6);
    }
  }
Example #14
0
 // Draw function. Normally draws nothing, or a box if pt is
 // selected or highlighted
 public void draw(Graphics g) {
   updateValue();
   if (isHighlighted && !isSelected) {
     g.setColor(CDA_G.DARK_GREEN);
     g.drawRect(
         x - CDA_G.DRAWBOXSIZE / 2,
         y - CDA_G.DRAWBOXSIZE / 2,
         CDA_G.DRAWBOXSIZE,
         CDA_G.DRAWBOXSIZE);
   } else {
     if (isSelected) {
       g.setColor(CDA_G.DARK_GREEN);
       g.fillRect(
           x - CDA_G.SELBOXSIZE / 2,
           y - CDA_G.SELBOXSIZE / 2,
           CDA_G.SELBOXSIZE + 1,
           CDA_G.SELBOXSIZE + 1);
     } else {
       g.setColor(Color.blue);
       g.drawRect(
           x - CDA_G.DRAWBOXSIZE / 2,
           y - CDA_G.DRAWBOXSIZE / 2,
           CDA_G.DRAWBOXSIZE,
           CDA_G.DRAWBOXSIZE);
     }
   }
 }
 public void paintSelection(Graphics g, int rowMin, int rowMax, int colMin, int colMax) {
   for (int row = rowMin; row <= rowMax; row++) {
     for (int column = colMin; column <= colMax; column++) {
       if (!grid.isCellSpan(row, column)) {
         Rectangle cellBounds = grid.getCellBounds(row, column);
         if (grid.getSelectionModel().isSelected(row, column)) {
           g.setColor(Color.RED);
           g.drawRect(
               (int) cellBounds.getX() + 1,
               (int) cellBounds.getY() + 1,
               (int) cellBounds.getWidth() - 2,
               (int) cellBounds.getHeight() - 2);
         }
       } else {
         CellSpan span = grid.getSpanModel().getSpanOver(row, column);
         if (grid.getSelectionModel().isSelected(span.getRow(), span.getColumn())) {
           g.setColor(Color.RED);
           Rectangle cellBounds = grid.getCellBounds(span.getFirstRow(), span.getLastColumn());
           g.drawRect(
               (int) cellBounds.getX() + 1,
               (int) cellBounds.getY() + 1,
               (int) cellBounds.getWidth() - 2,
               (int) cellBounds.getHeight() - 2);
         }
       }
     }
   }
 }
  // draw rectangles and arcs
  public void paintComponent(Graphics g) {
    super.paintComponent(g); // call superclass's paintComponent

    // start at 0 and sweep 360 degrees
    g.setColor(Color.RED);
    g.drawRect(15, 35, 80, 80);
    g.setColor(Color.BLACK);
    g.drawArc(15, 35, 80, 80, 0, 360);

    // start at 0 and sweep 110 degrees
    g.setColor(Color.RED);
    g.drawRect(100, 35, 80, 80);
    g.setColor(Color.BLACK);
    g.drawArc(100, 35, 80, 80, 0, 110);

    // start at 0 and sweep -270 degrees
    g.setColor(Color.RED);
    g.drawRect(185, 35, 80, 80);
    g.setColor(Color.BLACK);
    g.drawArc(185, 35, 80, 80, 0, -270);

    // start at 0 and sweep 360 degrees
    g.fillArc(15, 120, 80, 40, 0, 360);

    // start at 270 and sweep -90 degrees
    g.fillArc(100, 120, 80, 40, 270, -90);

    // start at 0 and sweep -270 degrees
    g.fillArc(185, 120, 80, 40, 0, -270);
  } // end method paintComponent
Example #17
0
  private BufferedImage generateFrame(GifFrame frame) {
    int width = frame.getColumns() * CELL_WIDTH;
    BufferedImage img =
        new BufferedImage(width, frame.getRows() * CELL_HEIGHT + TEXT_AREA_HEIGHT, IMAGE_TYPE_GIF);
    Graphics graphics = img.getGraphics();
    for (int row = 0; row < frame.getRows(); row++) {
      for (int col = 0; col < frame.getColumns(); col++) {
        ImageIcon icon =
            new ImageIcon(
                "site/images/" + frame.getBoard().get(row, col).getImageFilename() + ".png");
        graphics.drawImage(icon.getImage(), col * CELL_WIDTH, row * CELL_HEIGHT, null);
      }
    }

    for (BoxOverlay overlay : frame.getOverlays()) {
      graphics.setColor(overlay.getColor());
      Rectangle rect = overlay.getRectangle();
      int rect_x = rect.getLeft() * CELL_WIDTH - OVERLAY_PADDING;
      int rect_y = rect.getTop() * CELL_HEIGHT - OVERLAY_PADDING;
      int rect_width = (rect.getRight() - rect.getLeft() + 1) * CELL_WIDTH + 2 * OVERLAY_PADDING;
      int rect_height = (rect.getBottom() - rect.getTop() + 1) * CELL_HEIGHT + 2 * OVERLAY_PADDING;
      graphics.drawRect(rect_x, rect_y, rect_width, rect_height);
      graphics.drawRect(rect_x - 1, rect_y - 1, rect_width + 2, rect_height + 2);
    }

    graphics.setColor(FONT_COLOR);
    graphics.setFont(FONT);
    FontMetrics fm = graphics.getFontMetrics();
    graphics.drawString(
        frame.getText(),
        width / 2 - fm.stringWidth(frame.getText()) / 2,
        frame.getRows() * CELL_HEIGHT + TEXT_AREA_HEIGHT / 2 + fm.getHeight() / 2);

    return img;
  }
Example #18
0
  public void paint(Graphics g) {
    g.setColor(Color.pink);

    g.drawRect(40, 40, 80, 80);
    g.drawLine(80, 10, 40, 40);
    g.drawLine(80, 10, 120, 40);
    g.drawRect(70, 80, 20, 40);
  }
Example #19
0
 public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
   Color hiColor = ColorHelper.brighter(AbstractLookAndFeel.getTheme().getFocusFrameColor(), 60);
   Color loColor = AbstractLookAndFeel.getTheme().getFocusFrameColor();
   g.setColor(loColor);
   g.drawRect(x, y, width - 1, height - 1);
   g.setColor(hiColor);
   g.drawRect(x + 1, y + 1, width - 3, height - 3);
 }
Example #20
0
 public void displayInstructions(Graphics g) {
   // Slightly freshened the look of the intro page.
   g.drawRect(128, 100, 250, 150); // decorative rectangles
   g.drawRect(122, 95, 260, 162);
   g.drawString("Welcome to Snake", 200, 130); // Centered instructions
   g.drawString("Press any key to start", 195, 150);
   g.drawString("Press 'q' to quit", 210, 170);
 }
  // documentation inherited
  public void paintComponent(Graphics g) {
    super.paintComponent(g);

    Graphics2D g2 = (Graphics2D) g;

    // center the tile display if we are bigger than we need to be
    g.translate(_tx, _ty);

    //         // paint coordinates in the grid that contains our tiles
    //         for (int yy = 0; yy < _height; yy++) {
    //             for (int xx = 0; xx < _width; xx++) {
    //                 int cx = xx*TILE_WIDTH, cy = yy*TILE_HEIGHT;
    //                 g.drawRect(cx, cy, TILE_WIDTH, TILE_HEIGHT);
    //                 String coord = (xx-_origX) + "/" + (yy-_origY);
    //                 g.drawString(coord, cx+TILE_WIDTH/2, cy+TILE_HEIGHT/2);
    //             }
    //         }

    // iterate over our tiles, painting each of them
    for (AtlantiTile tile : _tiles) {
      tile.paint(g2, _origX, _origY);
    }

    // if we have a placing tile, draw that one as well
    if (_placingTile != null && _validPlacement) {
      // if the current position is valid, draw the placing tile
      _placingTile.paint(g2, _origX, _origY);

      // draw a green rectangle around the placing tile
      g.setColor(Color.blue);
      int sx = (_placingTile.x + _origX) * TILE_WIDTH;
      int sy = (_placingTile.y + _origY) * TILE_HEIGHT;
      g.drawRect(sx, sy, TILE_WIDTH - 1, TILE_HEIGHT - 1);
    }

    // if we have a recently placed tile, draw that one as well
    if (_placedTile != null) {
      // draw the tile
      _placedTile.paint(g2, _origX, _origY);

      // draw a white rectangle around the placed tile
      g.setColor(Color.white);
      int sx = (_placedTile.x + _origX) * TILE_WIDTH;
      int sy = (_placedTile.y + _origY) * TILE_HEIGHT;
      g.drawRect(sx, sy, TILE_WIDTH - 1, TILE_HEIGHT - 1);
    }

    // draw a white rectangle around the last placed
    if (_lastPlacedTile != null) {
      g.setColor(Color.white);
      int sx = (_lastPlacedTile.x + _origX) * TILE_WIDTH;
      int sy = (_lastPlacedTile.y + _origY) * TILE_HEIGHT;
      g.drawRect(sx, sy, TILE_WIDTH - 1, TILE_HEIGHT - 1);
    }

    // undo our translations
    g.translate(-_tx, -_ty);
  }
Example #22
0
 private void drawBordered(
     Graphics g, int x, int y, int w, int h, Color fill, Color highlight, Color shadow) {
   g.setColor(shadow);
   g.drawRect(x + 1, y + 1, w - 1, h - 1);
   g.setColor(highlight);
   g.drawRect(x, y, w - 1, h - 1);
   g.setColor(fill);
   g.fillRect(x + 1, y + 1, w - 1, h - 1);
 }
Example #23
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);
   }
 }
Example #24
0
 /** This draws the "Flush 3D Border" which is used throughout the Metal L&F */
 static void drawFlush3DBorder(Graphics g, int x, int y, int w, int h) {
   g.translate(x, y);
   g.setColor(MetalLookAndFeel.getControlDarkShadow());
   g.drawRect(0, 0, w - 2, h - 2);
   g.setColor(MetalLookAndFeel.getControlHighlight());
   g.drawRect(1, 1, w - 2, h - 2);
   g.setColor(MetalLookAndFeel.getControl());
   g.drawLine(0, h - 1, 1, h - 2);
   g.drawLine(w - 1, 0, w - 2, 1);
   g.translate(-x, -y);
 }
Example #25
0
 public void draw(Graphics g) {
   Image img = this.getImage();
   if (isFlipped()) {
     g.drawImage(img, (-1 * x + 7) * width, (-1 * y + 7) * height, width, height, null);
     g.setColor(Color.BLACK);
     g.drawRect((-1 * x + 7) * width, (-1 * y + 7) * height, width, height);
   } else {
     g.drawImage(img, x * width, y * height, width, height, null);
     g.setColor(Color.BLACK);
     g.drawRect(x * width, y * height, width, height);
   }
 }
Example #26
0
 public void render(Graphics g) {
   g.setColor(Color.black);
   g.drawRect(0, 0, 80, 30);
   g.drawRect(Game.WIDTH - 100, 0, 95, 30);
   g.setColor(Color.white);
   g.fillRect(5, 5, 75, 25);
   g.fillRect(Game.WIDTH - 99, 5, 95, 25);
   g.setFont(keyFont);
   g.setColor(Color.black);
   g.drawString("Keys: " + player.numKeys, 5, 25);
   g.drawString("Deaths: " + player.numDeaths, Game.WIDTH - 100, 25);
 }
Example #27
0
 private void paintRectangularBase(Graphics g, InstancePainter painter) {
   GraphicsUtil.switchToWidth(g, 2);
   if (painter.getAttributeValue(ATTR_SIZE) == SIZE_NARROW) {
     g.drawRect(-20, -9, 14, 18);
     GraphicsUtil.drawCenteredText(g, RECT_LABEL, -13, 0);
     g.drawOval(-6, -3, 6, 6);
   } else {
     g.drawRect(-30, -9, 20, 18);
     GraphicsUtil.drawCenteredText(g, RECT_LABEL, -20, 0);
     g.drawOval(-10, -5, 9, 9);
   }
   GraphicsUtil.switchToWidth(g, 1);
 }
Example #28
0
 public void paint(Graphics g) {
   super.paint(g);
   g.setColor(Color.blue);
   g.drawRect(30, 80, 100, 140);
   int ms = Integer.parseInt(sp1.getValue().toString());
   int mi = Integer.parseInt(sp2.getValue().toString());
   g.setColor(Color.red);
   g.drawLine(30, 80 + ms, 130, 80 + ms);
   g.drawLine(30, 220 - mi, 130, 220 - mi);
   String direccion = (String) comboBox.getSelectedItem();
   if (direccion.equals("Horizontal")) g.drawRect(320, 120, 200, 100);
   else g.drawRect(320, 120, 100, 200);
 }
    @Override
    protected void paintComponent(Graphics g) {
      g.setColor(Color.BLACK);
      g.fillRect(0, 0, getWidth(), getHeight());

      if (isLoading) {
        return;
      }

      if (image != null) {
        g.drawImage(image, 0, 0, null);
        if (overlay != null) {
          Graphics2D g2 = (Graphics2D) g.create();
          g2.setComposite(overlayAlpha);
          g2.drawImage(overlay, 0, image.getHeight() - overlay.getHeight(), null);
        }
      }

      if (node != null) {
        Graphics s = g.create();
        s.setColor(boundsColor);
        ViewNode p = node.parent;
        while (p != null) {
          s.translate(p.left - p.scrollX, p.top - p.scrollY);
          p = p.parent;
        }
        s.drawRect(node.left, node.top, node.width - 1, node.height - 1);
        s.translate(node.left, node.top);

        s.setXORMode(Color.WHITE);
        if ((node.paddingBottom | node.paddingLeft | node.paddingTop | node.paddingRight) != 0) {
          s.setColor(Color.BLACK);
          s.drawRect(
              node.paddingLeft,
              node.paddingTop,
              node.width - node.paddingRight - node.paddingLeft - 1,
              node.height - node.paddingBottom - node.paddingTop - 1);
        }
        if (node.hasMargins
            && (node.marginLeft | node.marginBottom | node.marginRight | node.marginRight) != 0) {
          s.setColor(Color.BLACK);
          s.drawRect(
              -node.marginLeft,
              -node.marginTop,
              node.marginLeft + node.width + node.marginRight - 1,
              node.marginTop + node.height + node.marginBottom - 1);
        }

        s.dispose();
      }
    }
Example #30
0
  private void paintTrack(Graphics g) {

    if (orientation == HORIZONTAL) {
      g.setColor(SystemColor.controlDkShadow);
      g.drawRect(getTrackLeftEdge(), 5, getTrackRightEdge() - getTrackLeftEdge() - 1, 5);
      g.setColor(SystemColor.controlShadow);
      g.drawLine(getTrackLeftEdge() + 1, 6, getTrackRightEdge() - 2, 6);
    } else {
      g.setColor(SystemColor.controlDkShadow);
      g.drawRect(5, getTrackLeftEdge(), 5, getTrackRightEdge() - getTrackLeftEdge() - 1);
      g.setColor(SystemColor.controlShadow);
      g.drawLine(6, getTrackLeftEdge() + 1, 6, getTrackRightEdge() - 2);
    }
  }