Esempio n. 1
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;
  }
Esempio n. 2
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());
    }
  }
  /**
   * 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();
      }
    }
  }
Esempio n. 5
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);
  }
Esempio n. 6
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);
   }
 }
Esempio n. 7
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:
     }
   }
 }
Esempio n. 8
0
  /**
   * Metoda wyswietlajaca pasek postepu nad przyciskami
   *
   * @param g Referencja do obiektu klasy Graphics, ktory pozwala na narysowanie pasku postepu
   * @param current Aktualny czas trwania piosenki, 0 <= progress <= max
   * @param max Calkowity czas trwania piosenki
   */
  public void showProgressBar(Graphics g, int current, int max) {
    int color = g.getColor(); // przechowanie uzywanego koloru
    int progressBarWidth = screenWidth - 25; // szerokosc paska postepu
    int progress = (progressBarWidth * current) / max;

    if (current == -1) // jesli timer jest wylaczony
    progress = 0;

    g.setColor(110, 110, 110); // narysowanie szarej obwodki
    g.drawRect(10, screenHeight - 29 + buttonsLocation, progressBarWidth + 3, 17);

    g.setColor(90, 90, 90); // narysowanie ciemnej obwodki
    g.drawRect(11, screenHeight - 28 + buttonsLocation, progressBarWidth + 1, 15);

    g.setColor(BACKGROUND_COLOR);
    g.fillRect(12, screenHeight - 27 + buttonsLocation, progressBarWidth, 14);

    g.setColor(230, 230, 230);
    g.fillRect(12, screenHeight - 27 + buttonsLocation, progress, 14);

    g.setColor(70, 70, 70);

    if (this.displayedScreen == MainCanvas.PLAYER_SCREEN)
      g.drawString(
          bluetoothPlayer.getCurrentTimeString(),
          screenWidth / 2 - 17,
          screenHeight - 26 + buttonsLocation,
          Graphics.TOP | Graphics.LEFT);

    g.setColor(color);
  }
Esempio n. 9
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);
  }
Esempio n. 10
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);
 }
Esempio n. 11
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);
 }
  // 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);
  }
Esempio n. 13
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);
   }
 }
Esempio n. 14
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);
 }
Esempio n. 15
0
  /**
   * Draws a colored cell.
   *
   * @param g graphics reference
   * @param xs horizontal start position
   * @param xe horizontal end position
   * @param ys vertical start position
   * @param ye vertical end position
   * @param focus highlighting flag
   */
  public static void drawCell(
      final Graphics g,
      final int xs,
      final int xe,
      final int ys,
      final int ye,
      final boolean focus) {

    g.setColor(gray);
    g.drawRect(xs, ys, xe - xs - 1, ye - ys - 1);
    g.setColor(BACK);
    g.drawRect(xs + 1, ys + 1, xe - xs - 3, ye - ys - 3);
    g.setColor(focus ? lgray : BACK);
    g.fillRect(xs + 1, ys + 1, xe - xs - 2, ye - ys - 2);
  }
 /**
  * This method draws the health bar, and an outline around it. It also displays the Baron picture.
  * It also draws a few strings to tell the person how much health baron has in the for of a
  * numeral and displays whether you have successfully smited baron or not.
  *
  * @param g
  */
 public void paintComponent(Graphics g) {
   g.drawImage(img, 0, 0, null);
   r2.height = (int) hpDecreaseDec;
   // Rectangle for Baron's health
   g.setColor(Color.RED);
   g.fillRect(r2.x, r2.y, r2.height, r2.width);
   // Rectangle to outline Baron's health
   g.setColor(Color.BLACK);
   g.drawRect(r1.x, r1.y, r1.height, r1.width);
   // Displays a title
   g.setColor(Color.ORANGE);
   g.drawString("Baron Nashor Smite Simulator", 450, 100);
   // Displays amount of health baron has
   g.setColor(Color.WHITE);
   if (baronHealth >= 0) g.drawString("BARON HP: " + baronHealth, 80, 620);
   else {
     g.drawString("BARON HP: 0", 80, 620);
     baronHealth = 0;
   }
   g.setColor(Color.GRAY);
   g.drawString("Smite damage: " + smiteDmg, 75, 580);
   g.drawString("Click anywhere to smite", 450, 580);
   if (smiteDone) {
     g.setColor(Color.WHITE);
     // This outputs whether you were successful in smitting baron or not
     if (outCome == 1) {
       g.drawString("You have smited too early and the enemy has stolen Baron Nashor!", 350, 350);
     } else if (outCome == 2) {
       g.drawString("You have smited Baron Nashor!", 350, 350);
     } else if (outCome == 3) {
       g.drawString("The enemy has stolen Baron Nashor!", 350, 350);
     }
   }
   repaint();
 }
Esempio n. 17
0
 public void paintComponent(Graphics g) {
   g.setColor(new Color(0x8090ff));
   g.fillRect(0, 0, level.length * 16, level.height * 16);
   levelRenderer.render(g, 0);
   g.setColor(Color.BLACK);
   g.drawRect(xTile * 16 - 1, yTile * 16 - 1, 17, 17);
 }
Esempio n. 18
0
    public void paint(Graphics g) {
      Dimension dim = getSize();

      g.draw3DRect(1, 1, dim.width - 3, dim.height - 3, true);
      g.setColor(Color.black);
      g.drawRect(0, 0, dim.width - 1, dim.height - 1);
    }
    @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);
    }
Esempio n. 20
0
  /**
   * The function prints out key to jumpshot data.
   */
  int print (Graphics g, int x, int y, int width, int height) {
    Font f = g.getFont ();
    FontMetrics fm = getToolkit ().getFontMetrics (f);
    
    int charW = fm.stringWidth (" "), charH = fm.getHeight ();
    int hgap1 = charW, hgap2 = 2 * charW, vgap = fm.getAscent ();
    int rectW = 30, rectH = charH; //Dimensions of state rectangles
    int xcord = x, ycord = y;
    
    Enumeration enum = parent.stateDefs.elements ();
    while (enum.hasMoreElements ()) {
      RecDef s = (RecDef)enum.nextElement ();
      
      if (s.stateVector.size () > 0) {
	int strW = fm.stringWidth (s.description);
	
	if ((xcord + rectW + hgap1 + strW) > (width + x)) {
          xcord = x; ycord += (charH + vgap);
        }
        
        g.setColor (s.color);
        g.fillRect (xcord, ycord, rectW, rectH);
        g.setColor (Color.black);
        g.drawRect (xcord, ycord, rectW - 1, rectH - 1);
        g.drawString( s.description,
                      xcord + rectW + hgap1,
                      ycord + rectH - fm.getDescent () - 1);
        xcord += (rectW + hgap1 + strW + hgap2);
      }
    }
    return (ycord - y + (2 * charH));
  }      
 public void paint(Graphics g) {
   g.drawRect(x[0], y[0], 40, 40);
   g.fillRect(x[1], y[1], 20, 20);
   g.drawLine(x[2], y[2], x[3], y[3]);
   g.drawOval(x[4], y[4], 20, 30);
   g.drawString("Moveing", x[5], y[5]);
 }
Esempio n. 22
0
  /** Draw the map. */
  @Override
  public void paint(Graphics g) {
    try {
      super.paint(g);

      // draw selection rectangle
      if (iSelectionRectStart != null && iSelectionRectEnd != null) {

        int zoomDiff = MAX_ZOOM - zoom;
        Point tlc = getTopLeftCoordinates();
        int x_min = (iSelectionRectStart.x >> zoomDiff) - tlc.x;
        int y_min = (iSelectionRectStart.y >> zoomDiff) - tlc.y;
        int x_max = (iSelectionRectEnd.x >> zoomDiff) - tlc.x;
        int y_max = (iSelectionRectEnd.y >> zoomDiff) - tlc.y;

        int w = x_max - x_min;
        int h = y_max - y_min;
        g.setColor(new Color(0.9f, 0.7f, 0.7f, 0.6f));
        g.fillRect(x_min, y_min, w, h);

        g.setColor(Color.BLACK);
        g.drawRect(x_min, y_min, w, h);
      }

      iSizeButton.paint(g);
      iSourceButton.paint(g);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Esempio n. 23
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);
      }
    }
Esempio n. 24
0
 public void draw(Graphics g, Color c, boolean draw_name) {
   g.setColor(c);
   g.fillRect(this.x, this.y, this.sx, this.sy);
   g.setColor(Color.black);
   g.drawRect(this.x, this.y, this.sx, this.sy);
   if (draw_name) g.drawString(this.name, this.x, this.y);
 }
Esempio n. 25
0
  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");
    }
  }
 private void drawButton(Graphics g, int x, int y, String txt) {
   g.setColor(Color.white);
   g.fillRect(x, y, 30, 30);
   g.setColor(Color.black);
   g.drawRect(x, y, 30, 30);
   g.drawString(txt, x + 18, y + 18);
 }
Esempio n. 27
0
  protected void paintCaret(Graphics gfx, int line, int y) {
    // System.out.println("painting caret " + line + " " + y);
    if (textArea.isCaretVisible()) {
      // System.out.println("caret is visible");
      int offset = textArea.getCaretPosition() - textArea.getLineStartOffset(line);
      int caretX = textArea._offsetToX(line, offset);
      int caretWidth = ((blockCaret || textArea.isOverwriteEnabled()) ? fm.charWidth('w') : 1);
      y += fm.getLeading() + fm.getMaxDescent();
      int height = fm.getHeight();

      // System.out.println("caretX, width = " + caretX + " " + caretWidth);

      gfx.setColor(caretColor);

      if (textArea.isOverwriteEnabled()) {
        gfx.fillRect(caretX, y + height - 1, caretWidth, 1);

      } else {
        // some machines don't like the drawRect for the single
        // pixel caret.. this caused a lot of hell because on that
        // minority of machines, the caret wouldn't show up past
        // the first column. the fix is to use drawLine() in
        // those cases, as a workaround.
        if (caretWidth == 1) {
          gfx.drawLine(caretX, y, caretX, y + height - 1);
        } else {
          gfx.drawRect(caretX, y, caretWidth - 1, height - 1);
        }
        // gfx.drawRect(caretX, y, caretWidth, height - 1);
      }
    }
  }
 public void draw(Graphics g) {
   Color oldColor = g.getColor();
   g.setColor(color);
   if (filled) g.fillRect(cornerX, cornerY, width, height);
   else g.drawRect(cornerX, cornerY, width, height);
   g.setColor(oldColor);
 }
Esempio n. 29
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);
        }
      }
    }
 synchronized void drawCurrentFrame(Graphics g) {
   // Called to draw the current frame.  But it is not drawn during
   // the animation of the solution.  During the animation, the
   // moveDisk() method just modifies the existing picture.
   g.setColor(BACKGROUND_COLOR);
   g.fillRect(0, 0, 430, 143);
   g.setColor(BORDER_COLOR);
   g.drawRect(0, 0, 429, 142);
   g.drawRect(1, 1, 427, 140);
   if (tower == null) return;
   g.fillRect(10, 128, 130, 5);
   g.fillRect(150, 128, 130, 5);
   g.fillRect(290, 128, 130, 5);
   g.setColor(DISK_COLOR);
   for (int t = 0; t < 3; t++) {
     for (int i = 0; i < towerHeight[t]; i++) {
       int disk = tower[t][i];
       g.fillRoundRect(75 + 140 * t - 5 * disk - 5, 116 - 12 * i, 10 * disk + 10, 10, 10, 10);
     }
   }
   if (moveDisk > 0) {
     g.setColor(MOVE_DISK_COLOR);
     g.fillRoundRect(
         75 + 140 * moveTower - 5 * moveDisk - 5,
         116 - 12 * towerHeight[moveTower],
         10 * moveDisk + 10,
         10,
         10,
         10);
   }
 }