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);
     }
   }
 }
Esempio n. 2
0
  private void drawAxes(Graphics g) {
    g.drawLine(padding, height, width + padding, height);
    g.drawLine(padding, 0, padding, height);

    g.drawString("time", padding + width / 2, height + padding - 5);
    g.drawString("pop", 5, height / 2);
  }
 public void doPaintSquare(Graphics g) {
   int h = height;
   g.setColor(bgColor);
   int bx = text.length() == 0 ? 0 : 2;
   int by = text.length() == 0 ? 0 : (h - boxWidth) / 2 + 1;
   g.fillRect(bx + 2, by + 2, boxWidth - 4, boxWidth - 4);
   if (state || pressState) {
     Color c = Color.LightGray;
     if (!pressState) {
       if (!state) c = bgColor;
       else c = Color.Black;
     }
     Pen oldpen = g.setPen(new Pen(c, Pen.SOLID, 2));
     g.drawLine(bx + 4, by + boxWidth - 5, bx + boxWidth - 5, by + 4);
     g.drawLine(bx + 4, by + boxWidth - 5, bx + 4, by + boxWidth - 10);
     //				g.drawLine(bx+3,by+3,bx+boxWidth-5,by+boxWidth-5);
     //				g.drawLine(bx+3,by+boxWidth-5,bx+boxWidth-5,by+3);
     g.setPen(oldpen);
   }
   g.draw3DRect(
       new Rect(bx, by, boxWidth, boxWidth),
       ButtonObject.checkboxEdge,
       true,
       null,
       Color.DarkGray);
 }
Esempio n. 4
0
  private void drawDarkerSide(
      Graphics graphics, Color[] br, int top, int left, int bottom, int right) {
    graphics.setLineWidth(1);
    graphics.setAlpha(200);
    Color color;
    for (int i = 0; i < br.length; i++) {
      color = br[i];
      graphics.setForegroundColor(color);

      graphics.drawArc(
          right - i - corner.width,
          bottom - i - corner.height,
          corner.width,
          corner.height,
          270,
          90);
      Point rightButtomRight = new Point(right - i, bottom - i - corner.height / 2);
      Point rightTopRight = new Point(right - i, top + i + corner.height / 2);
      graphics.drawLine(rightButtomRight, rightTopRight);
      graphics.drawArc(right - i - corner.width, top - i, corner.width, corner.height, 0, 45);

      Point rightButtomButtom = new Point(right - i - corner.width / 2, bottom - i);
      Point leftBottomLeft = new Point(left + i + corner.width / 2, bottom - i);
      graphics.drawLine(rightButtomButtom, leftBottomLeft);
      graphics.drawArc(
          left - i, bottom - i - corner.height, corner.width, corner.height, 180 + 45, 45);
    }
  }
Esempio n. 5
0
  /**
   * Paints the graphic component
   *
   * @param g Graphic component
   */
  public void paint(Graphics g) {
    if (environment != null) {
      Sudoku env = (Sudoku) environment;
      Board board = env.getBoard();

      int n = SudokuLanguage.DIGITS;
      int sqrt_n = (int) (Math.sqrt(n) + 0.1);

      g.setColor(Color.lightGray);
      Font font = g.getFont();
      g.setFont(new Font(font.getName(), font.getStyle(), 20));
      for (int i = 0; i < n; i++) {
        int ci = getCanvasValue(i);
        if (i % sqrt_n == 0) {
          g.drawLine(ci, DRAW_AREA_SIZE + MARGIN, ci, MARGIN);
          g.drawLine(DRAW_AREA_SIZE + MARGIN, ci, MARGIN, ci);
        }

        for (int j = 0; j < n; j++) {
          int cj = getCanvasValue(j);
          int value = board.get(i, j);
          if (value > 0) {
            g.setColor(Color.black);
            g.drawString("" + value, cj + CELL_SIZE / 5, ci + CELL_SIZE);
            g.setColor(Color.lightGray);
          }
        }
      }
      g.drawLine(DRAW_AREA_SIZE + MARGIN, DRAW_AREA_SIZE + MARGIN, DRAW_AREA_SIZE + MARGIN, MARGIN);
      g.drawLine(DRAW_AREA_SIZE + MARGIN, DRAW_AREA_SIZE + MARGIN, MARGIN, DRAW_AREA_SIZE + MARGIN);
    }
  }
Esempio n. 6
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);
     }
   }
 }
  protected void paintComponent(Graphics g) {
    g.setColor(GroupedElementsRenderer.POPUP_SEPARATOR_FOREGROUND);

    if (hasCaption()) {
      Rectangle viewR = new Rectangle(0, getVgap(), getWidth() - 1, getHeight() - getVgap() - 1);
      Rectangle iconR = new Rectangle();
      Rectangle textR = new Rectangle();
      String s =
          SwingUtilities.layoutCompoundLabel(
              g.getFontMetrics(),
              myCaption,
              null,
              CENTER,
              myCaptionCentered ? CENTER : LEFT,
              CENTER,
              myCaptionCentered ? CENTER : LEFT,
              viewR,
              iconR,
              textR,
              0);
      final int lineY = textR.y + textR.height / 2;
      if (s.equals(myCaption) && viewR.width - textR.width > 2 * getHgap()) {
        if (myCaptionCentered) {
          g.drawLine(0, lineY, textR.x - getHgap(), lineY);
        }
        g.drawLine(textR.x + textR.width + getHgap(), lineY, getWidth() - 1, lineY);
      }
      UIUtil.applyRenderingHints(g);
      g.setColor(GroupedElementsRenderer.POPUP_SEPARATOR_TEXT_FOREGROUND);
      g.drawString(s, textR.x, textR.y + g.getFontMetrics().getAscent());
    } else {
      g.drawLine(0, getVgap(), getWidth() - 1, getVgap());
    }
  }
    public void paintIcon(Component c, Graphics g, int xo, int yo) {
      int w = getIconWidth();
      int h = getIconHeight();

      g.setColor(lightShadow);
      g.drawLine(xo, yo, xo + w - 1, yo);
      g.drawLine(xo, yo + 1, xo + w - 3, yo + 1);
      g.setColor(darkShadow);
      g.drawLine(xo + w - 2, yo + 1, xo + w - 1, yo + 1);

      for (int x = xo + 1, y = yo + 2, dx = w - 6; y + 1 < yo + h; y += 2) {
        g.setColor(lightShadow);
        g.drawLine(x, y, x + 1, y);
        g.drawLine(x, y + 1, x + 1, y + 1);
        if (dx > 0) {
          g.setColor(fill);
          g.drawLine(x + 2, y, x + 1 + dx, y);
          g.drawLine(x + 2, y + 1, x + 1 + dx, y + 1);
        }
        g.setColor(darkShadow);
        g.drawLine(x + dx + 2, y, x + dx + 3, y);
        g.drawLine(x + dx + 2, y + 1, x + dx + 3, y + 1);
        x += 1;
        dx -= 2;
      }

      g.setColor(darkShadow);
      g.drawLine(xo + (w / 2), yo + h - 1, xo + (w / 2), yo + h - 1);
    }
    @Override
    protected void paintComponent(Graphics g) {
      g.setColor(ButtonlessScrollBarUI.getTrackBackground());
      g.fillRect(0, 0, getWidth(), getHeight());

      g.setColor(ButtonlessScrollBarUI.getTrackBorderColor());

      int x2 = getWidth() - 1;
      int y2 = getHeight() - 1;

      if (myPos == UPPER_LEFT_CORNER || myPos == UPPER_RIGHT_CORNER) {
        g.drawLine(0, y2, x2, y2);
      }
      if (myPos == LOWER_LEFT_CORNER || myPos == LOWER_RIGHT_CORNER) {
        g.drawLine(0, 0, x2, 0);
      }

      if (myPos == UPPER_LEFT_CORNER || myPos == LOWER_LEFT_CORNER) {
        g.drawLine(x2, 0, x2, y2);
      }

      if (myPos == UPPER_RIGHT_CORNER || myPos == LOWER_RIGHT_CORNER) {
        g.drawLine(0, 0, 0, y2);
      }
    }
Esempio n. 10
0
  public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
    // choose which colors we want to use
    Color bg = c.getBackground();

    if (c.getParent() != null) {
      bg = c.getParent().getBackground();
    }

    if (bg != null) {
      Color mid = bg.darker();
      Color edge = average(mid, bg);

      g.setColor(bg);
      g.drawLine(0, h - 2, w, h - 2);
      g.drawLine(0, h - 1, w, h - 1);
      g.drawLine(w - 2, 0, w - 2, h);
      g.drawLine(w - 1, 0, w - 1, h);

      // draw the drop-shadow
      g.setColor(mid);
      g.drawLine(1, h - 2, w - 2, h - 2);
      g.drawLine(w - 2, 1, w - 2, h - 2);

      g.setColor(edge);
      g.drawLine(2, h - 1, w - 2, h - 1);
      g.drawLine(w - 1, 2, w - 1, h - 2);
    }
  }
Esempio n. 11
0
  /** Overrides <code>Graphics.drawLine</code>. */
  public void drawLine(int x1, int y1, int x2, int y2) {
    DebugGraphicsInfo info = info();

    if (debugLog()) {
      info()
          .log(
              toShortString()
                  + " Drawing line: from "
                  + pointToString(x1, y1)
                  + " to "
                  + pointToString(x2, y2));
    }

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

        debugGraphics.drawLine(x1, y1, x2, y2);
        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.drawLine(x1, y1, x2, y2);
        Toolkit.getDefaultToolkit().sync();
        sleep(info.flashTime);
      }
      graphics.setColor(oldColor);
    }
    graphics.drawLine(x1, y1, x2, y2);
  }
  public void paint(Graphics g, JComponent c) {
    Dimension s = c.getSize();
    if (WindowsMenuItemUI.isVistaPainting()) {
      int x = 1;
      Component parent = c.getParent();
      if (parent instanceof JComponent) {
        Object gutterOffsetObject =
            ((JComponent) parent).getClientProperty(WindowsPopupMenuUI.GUTTER_OFFSET_KEY);
        if (gutterOffsetObject instanceof Integer) {
          /*
           * gutter offset is in parent's coordinates.
           * See comment in
           * WindowsPopupMenuUI.getTextOffset(JComponent)
           */
          x = ((Integer) gutterOffsetObject).intValue() - c.getX();
          x += WindowsPopupMenuUI.getGutterWidth();
        }
      }
      Skin skin = XPStyle.getXP().getSkin(c, Part.MP_POPUPSEPARATOR);
      int skinHeight = skin.getHeight();
      int y = (s.height - skinHeight) / 2;
      skin.paintSkin(g, x, y, s.width - x - 1, skinHeight, State.NORMAL);
    } else {
      int y = s.height / 2;
      g.setColor(c.getForeground());
      g.drawLine(1, y - 1, s.width - 2, y - 1);

      g.setColor(c.getBackground());
      g.drawLine(1, y, s.width - 2, y);
    }
  }
 protected void computeGeometry() {
   pictHalfWidth = Width.getInt() / 2;
   pictWidth = pictHalfWidth + pictHalfWidth - 1;
   pictHeight = Height.getInt();
   xLoc = -pictHalfWidth;
   yLoc = -pictHeight / 2;
   setFramesPerCycle(pictWidth - 1);
   setFrameIncrement(FrameIncrement.getInt());
   // System.out.println("width = " + pictWidth);
   // System.out.println("    x = " + xLoc);
   // System.out.println("    y = " + yLoc);
   PxlColor[] ramp = AColor.getPxlColor().sinusoidalRampTo(BColor.getPxlColor(), pictHalfWidth);
   // System.out.println("w=" + (4*pictHalfWidth-1) + ", h=" + pictHeight);
   int ibWidth = 4 * pictHalfWidth - 1;
   if ((imageBuffer == null)
       || (imageBuffer.getWidth() != ibWidth)
       || (imageBuffer.getHeight() != pictHeight)) {
     imageBuffer = new BufferedImage(ibWidth, pictHeight, BufferedImage.TYPE_INT_RGB);
   }
   Graphics g = imageBuffer.getGraphics();
   for (int x = 0; x < pictHalfWidth; x++) {
     g.setColor(ramp[x].dev());
     g.drawLine(x, 0, x, pictHeight - 1);
     if (x < (pictHalfWidth - 1))
       g.drawLine(pictWidth - x - 1, 0, pictWidth - x - 1, pictHeight - 1);
     if (x > 0) g.drawLine(pictWidth + x - 1, 0, pictWidth + x - 1, pictHeight - 1);
     if ((x > 0) && (x < (pictHalfWidth - 1)))
       g.drawLine(4 * pictHalfWidth - 4 - x, 0, 4 * pictHalfWidth - 4 - x, pictHeight - 1);
   }
   g.dispose();
   BitMapElement p = (BitMapElement) getDisplayElement(pictElement);
   p.setImage(imageBuffer);
   p.setLocation(xLoc, yLoc);
   p.setClipRect(xLoc, yLoc, pictWidth, pictHeight);
 }
Esempio n. 14
0
 /** Dessine l'icone de la grille */
 protected static void drawGrid(Graphics g, int x, int y, Color c) {
   g.setColor(c);
   for (int i = 0; i < TX.length; i++)
     g.drawLine(TX[i][0] + x, TX[i][2] + y, TX[i][1] + x, TX[i][2] + y);
   for (int i = 0; i < TY.length; i++)
     g.drawLine(TY[i][2] + x, TY[i][0] + y, TY[i][2] + x, TY[i][1] + y);
 }
Esempio n. 15
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. 16
0
  public void paint(Graphics g) {
    // clear field
    super.paint(g);

    // draw grid lines
    g.setColor(Color.DARK_GRAY);
    gridXIter = gridX.listIterator();
    while (gridXIter.hasNext()) {
      int x = gridXIter.next();
      g.drawLine(x, 0, x, getHeight());
    }
    gridYIter = gridY.listIterator();
    while (gridYIter.hasNext()) {
      int y = gridYIter.next();
      g.drawLine(0, y, getWidth(), y);
    }

    // draw objects
    ListIterator<PhysicsObject> iter = Universe.allObjects.listIterator();
    while (iter.hasNext()) {
      PhysicsObject obj = iter.next();
      int x = (int) (obj.getX() * pixelsPerMeter + origin.x);
      int y = (int) (obj.getY() * pixelsPerMeter + origin.y);
      g.fillOval(x - 5, y - 5, 10, 10); // TODO update for non-point objects
    }
  }
    public void paintIcon(Component c, Graphics g, int x, int y) {
      Color color = c == null ? Color.GRAY : c.getBackground();
      // In a compound sort, make each succesive triangle 20%
      // smaller than the previous one.
      int dx = (int) (size / 2 * Math.pow(0.8, priority));
      int dy = descending ? dx : -dx;
      // Align icon (roughly) with font baseline.
      y = y + 5 * size / 6 + (descending ? -dy : 0);
      int shift = descending ? 1 : -1;
      g.translate(x, y);

      // Right diagonal.
      g.setColor(color.darker());
      g.drawLine(dx / 2, dy, 0, 0);
      g.drawLine(dx / 2, dy + shift, 0, shift);

      // Left diagonal.
      g.setColor(color.brighter());
      g.drawLine(dx / 2, dy, dx, 0);
      g.drawLine(dx / 2, dy + shift, dx, shift);

      // Horizontal line.
      if (descending) {
        g.setColor(color.darker().darker());
      } else {
        g.setColor(color.brighter().brighter());
      }
      g.drawLine(dx, 0, 0, 0);

      g.setColor(color);
      g.translate(-x, -y);
    }
Esempio n. 18
0
  /**
   * Override the pain method do draw the axis lines
   *
   * @param g The graphics to paint to
   */
  public void paint(Graphics g) {
    Rectangle b = getBounds();
    g.setColor(canvasBg);
    g.fillRect(0, 0, b.width, b.height);
    paintGrid(g);

    Point center = getCenter();
    if (g instanceof Graphics2D) {
      ((Graphics2D) g).translate(center.x, center.y);
    }
    super.paint(g);
    if (g instanceof Graphics2D) {
      ((Graphics2D) g).scale(1.0, 1.0);
    }
    g.setColor(Color.gray);
    g.drawLine(0, -10 * b.height, 0, 10 * b.height);
    g.drawLine(-10 * b.width, 0, 10 * b.width, 0);

    MetSymbol tmp = highlightedMetSymbol;
    if (tmp != null) {
      Rectangle tb = tmp.getBounds();
      g.setColor(Color.red);
      g.drawRect(tb.x - 2, tb.y - 2, tb.width + 4, tb.height + 4);
    }
  }
Esempio n. 19
0
    private void drawSquare(Graphics g, int x, int y, Tetrominoes shape) {

      int squareWidth = (int) getSize().getWidth() / model.getWidth();
      int squareHeight = (int) getSize().getHeight() / model.getHeight();

      Color colors[] = {
        new Color(0, 0, 0),
        new Color(204, 102, 102),
        new Color(102, 204, 102),
        new Color(102, 102, 204),
        new Color(204, 204, 102),
        new Color(204, 102, 204),
        new Color(102, 204, 204),
        new Color(218, 170, 0)
      };

      Color color = colors[shape.ordinal()];
      g.setColor(color);
      g.fillRect(x + 1, y + 1, squareWidth - 2, squareHeight - 2);
      g.setColor(color.brighter());
      g.drawLine(x, y + squareHeight - 1, x, y);
      g.drawLine(x, y, x + squareWidth - 1, y);

      g.setColor(color.darker());
      g.drawLine(x + 1, y + squareHeight - 1, x + squareWidth - 1, y + squareHeight - 1);
      g.drawLine(x + squareWidth - 1, y + squareHeight - 1, x + squareWidth - 1, y + 1);
    }
Esempio n. 20
0
  private void drawWinBorder(Component c, Graphics g, int x, int y, int w, int h) {
    if (!c.isEnabled()) {
      g.setColor(Theme.textBorderDisabledColor[Theme.style].getColor());
    } else {
      g.setColor(Theme.textBorderColor[Theme.style].getColor());
    }
    g.drawLine(x + 1, y + 1, x + w - 3, y + 1);
    g.drawLine(x + 1, y + 2, x + 1, y + h - 3);

    if (!c.isEnabled()) {
      g.setColor(Theme.textBorderDarkDisabledColor[Theme.style].getColor());
    } else {
      g.setColor(Theme.textBorderDarkColor[Theme.style].getColor());
    }
    g.drawLine(x, y, x + w - 2, y);
    g.drawLine(x, y + 1, x, y + h - 2);

    g.setColor(Theme.backColor[Theme.style].getColor());
    g.drawLine(x + 1, y + h - 2, x + w - 2, y + h - 2);
    g.drawLine(x + w - 2, y + 1, x + w - 2, y + h - 2);

    if (!c.isEnabled()) {
      g.setColor(Theme.textBorderLightDisabledColor[Theme.style].getColor());
    } else {
      g.setColor(Theme.textBorderLightColor[Theme.style].getColor());
    }
    g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);
    g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);
  }
Esempio n. 21
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);
 }
  protected void paintGrid(Graphics g, int rowMin, int rowMax, int colMin, int colMax) {
    if (!grid.getShowGrid()) {
      return; // do nothing
    }

    int y1 = grid.getRowPosition(rowMin);
    int y2 = grid.getRowPosition(rowMax) + grid.getRowHeight(rowMax);
    int x1 = grid.getColumnPosition(colMin);
    int x2 = grid.getColumnPosition(colMax) + grid.getColumnWidth(colMax);

    g.setColor(grid.getGridColor());

    // Draw the horizontal lines
    for (int row = rowMin; row <= rowMax; row++) {
      int rowY = grid.getRowPosition(row);
      g.drawLine(x1, rowY, x2, rowY);
    }
    g.drawLine(x1, y2, x2, y2);

    // Draw the vertical gridlines
    for (int col = colMin; col <= colMax; col++) {
      int colX = grid.getColumnPosition(col);
      g.drawLine(colX, y1, colX, y2);
    }
    g.drawLine(x2, y1, x2, y2);
  }
 protected void paintText(Graphics g, JComponent com, Rectangle rect, String s) {
   JButtonLinkA bn = (JButtonLinkA) com;
   ButtonModel bnModel = bn.getModel();
   Color color = bn.getForeground();
   Object obj = null;
   if (bnModel.isEnabled()) {
     if (bnModel.isPressed()) bn.setForeground(bn.getActiveLinkColor());
     else if (bn.isLinkVisited()) bn.setForeground(bn.getVisitedLinkColor());
     else bn.setForeground(bn.getLinkColor());
   } else {
     if (bn.getDisabledLinkColor() != null) bn.setForeground(bn.getDisabledLinkColor());
   }
   super.paintText(g, com, rect, s);
   int behaviour = bn.getLinkBehavior();
   boolean drawLine = false;
   if (behaviour == JButtonLinkA.HOVER_UNDERLINE) {
     if (bnModel.isRollover()) drawLine = true;
   } else if (behaviour == JButtonLinkA.ALWAYS_UNDERLINE
       || behaviour == JButtonLinkA.SYSTEM_DEFAULT) drawLine = true;
   if (!drawLine) return;
   FontMetrics fm = g.getFontMetrics();
   int x = rect.x + getTextShiftOffset();
   int y = (rect.y + fm.getAscent() + fm.getDescent() + getTextShiftOffset()) - 1;
   if (bnModel.isEnabled()) {
     g.setColor(bn.getForeground());
     g.drawLine(x, y, (x + rect.width) - 1, y);
   } else {
     g.setColor(bn.getBackground().brighter());
     g.drawLine(x, y, (x + rect.width) - 1, y);
   }
 }
Esempio n. 24
0
 public void paintIcon(Component c, Graphics g, int x, int y) {
   if (WindowsMenuItemUI.isVistaPainting()) {
     XPStyle xp = XPStyle.getXP();
     State state = State.NORMAL;
     if (c instanceof JMenuItem) {
       state = ((JMenuItem) c).getModel().isEnabled() ? State.NORMAL : State.DISABLED;
     }
     Skin skin = xp.getSkin(c, Part.MP_POPUPSUBMENU);
     if (WindowsGraphicsUtils.isLeftToRight(c)) {
       skin.paintSkin(g, x, y, state);
     } else {
       Graphics2D g2d = (Graphics2D) g.create();
       g2d.translate(x + skin.getWidth(), y);
       g2d.scale(-1, 1);
       skin.paintSkin(g2d, 0, 0, state);
       g2d.dispose();
     }
   } else {
     g.translate(x, y);
     if (WindowsGraphicsUtils.isLeftToRight(c)) {
       g.drawLine(0, 0, 0, 7);
       g.drawLine(1, 1, 1, 6);
       g.drawLine(2, 2, 2, 5);
       g.drawLine(3, 3, 3, 4);
     } else {
       g.drawLine(4, 0, 4, 7);
       g.drawLine(3, 1, 3, 6);
       g.drawLine(2, 2, 2, 5);
       g.drawLine(1, 3, 1, 4);
     }
     g.translate(-x, -y);
   }
 }
Esempio n. 25
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. 26
0
 void draw3DRect(Graphics g, int x, int y, int width, int height) {
   g.setColor(Color.darkGray);
   g.drawLine(x, y, x, y + height);
   g.drawLine(x, y, x + width, y);
   g.setColor(Color.white);
   g.drawLine(x + width, y + height, x, y + height);
   g.drawLine(x + width, y + height, x + width, y);
 }
Esempio n. 27
0
  /**
   * Renders the 1D cellular automata. This overrides the usual render function to scroll the CA
   * data once the number of timesteps is greater than the height of the rendering area.
   *
   * @param graphics the graphics context.
   * @param pw the width of the context.
   * @param ph the height of the context.
   * @see CellularAutomata#render(Graphics, int, int)
   */
  public void render(Graphics graphics, int pw, int ph) {
    if (!isScrolling) {
      super.render(graphics, pw, ph);
      return;
    }
    // We are overloading the default rendering procedure to
    // allow for smooth scrolling.
    graphics.setColor(clrBackground);
    graphics.fillRect(0, 0, pw, ph);
    // cx/cy is the size of the CA world with
    // the size in pixels factored in.
    int cx = getSizeX() * caSize;
    int cy = getSizeY() * caSize;
    // sx/sy are the starting points for the CA world
    // centred within the the graphics context.
    int sx = (int) ((double) (pw - cx) / 2.0);
    int sy = (int) ((double) (ph - cy) / 2.0);
    // draw the default state of the world
    graphics.setColor(clrWorld[0]);
    graphics.fillRect(sx, sy, cx, cy);

    // draw the ca world
    int dh = 0;
    for (int j = stepPosition + 1; j < getSizeY(); j++) {
      for (int i = 0; i < getSizeX(); i++) {
        int state = getWorldAt(i, j);
        if (state != 0) {
          graphics.setColor(clrWorld[state]);
          graphics.fillRect(sx + i * caSize, sy + dh * caSize, caSize, caSize);
        }
      }
      dh++;
    }
    for (int j = 0; j < stepPosition + 1; j++) {
      for (int i = 0; i < getSizeX(); i++) {
        int state = getWorldAt(i, j);
        if (state != 0) {
          graphics.setColor(clrWorld[state]);
          graphics.fillRect(sx + i * caSize, sy + dh * caSize, caSize, caSize);
        }
      }
      dh++;
    }

    // draw a grid if neccessary
    if (caSize > 2 && drawGrid) {
      graphics.setColor(clrGrid);
      for (int i = sx - 1; i < (sx + cx - 1); i += caSize) {
        graphics.drawLine(i, sy, i, sy + cy);
      }
      for (int i = sy - 1; i < (sy + cy - 1); i += caSize) {
        graphics.drawLine(sx, i, sx + cx, i);
      }
    }
    // draw a bordering rectangle
    graphics.setColor(Color.black);
    graphics.drawRect(sx - 1, sy - 1, cx + 1, cy + 1);
  }
Esempio n. 28
0
    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);
    }
 public void paintComponent(Graphics g) {
   super.paintComponent(g);
   g.setColor(highlight);
   g.drawLine(4, 8, 4, 11);
   g.drawLine(4, 8, BUTTON_SIZE - 5, 8);
   g.setColor(shadow);
   g.drawLine(5, 11, BUTTON_SIZE - 5, 11);
   g.drawLine(BUTTON_SIZE - 5, 9, BUTTON_SIZE - 5, 11);
 }
Esempio n. 30
0
  void CheckDiagonal1(Graphics canvas) {
    // Check diagonal 1

    for (int nRow = NUMROWS - 1; nRow >= 0; nRow--) {
      int nCol = 0;

      int nThisRow = nRow;
      int nThisCol = nCol;

      int nColCount = 0;

      while (nThisCol < NUMCOLS && nThisRow < NUMROWS) {
        if (m_nBoard[nThisRow][nThisCol] != 0) {
          nColCount++;
        }
        nThisCol++;
        nThisRow++;
      }

      if (nColCount > 1) {
        canvas.drawLine(
            BOARDLEFT + nCol * SQUAREWIDTH + (SQUAREWIDTH / 2),
            BOARDTOP + nRow * SQUAREHEIGHT + (SQUAREHEIGHT / 2),
            BOARDLEFT + (nThisCol - 1) * SQUAREWIDTH + (SQUAREWIDTH / 2),
            BOARDTOP + (nThisRow - 1) * SQUAREHEIGHT + (SQUAREHEIGHT / 2));

        m_bClash = true;
      }
    }

    for (int nCol = 1; nCol < NUMCOLS; nCol++) {
      int nRow = 0;

      int nThisRow = nRow;
      int nThisCol = nCol;

      int nColCount = 0;

      while (nThisCol < NUMCOLS && nThisRow < NUMROWS) {
        if (m_nBoard[nThisRow][nThisCol] != 0) {
          nColCount++;
        }
        nThisCol++;
        nThisRow++;
      }

      if (nColCount > 1) {
        canvas.drawLine(
            BOARDLEFT + nCol * SQUAREWIDTH + (SQUAREWIDTH / 2),
            BOARDTOP + nRow * SQUAREHEIGHT + (SQUAREHEIGHT / 2),
            BOARDLEFT + (nThisCol - 1) * SQUAREWIDTH + (SQUAREWIDTH / 2),
            BOARDTOP + (nThisRow - 1) * SQUAREHEIGHT + (SQUAREHEIGHT / 2));

        m_bClash = true;
      }
    }
  }