Beispiel #1
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);
    }
  }
    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);
    }
 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);
     }
   }
 }
  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);
  }
Beispiel #5
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);
  }
Beispiel #6
0
 // färger, se sid 43 i boken
 // grafiska metoder, sid 248 i boken
 public void paintComponent(Graphics g) { // för att vara säker på att
   // "super"-klassen gör sitt
   // anropar vi den metoden, innan
   // vi skriver eller ritar
   super.paintComponent(g);
   g.drawLine(185, 10, 195, 40); // x1,y1 till x2,y2
   g.drawLine(200, 10, 200, 40);
   g.drawLine(215, 10, 205, 40);
   g.setColor(Color.white);
   g.fillOval(50, 30, 300, 150); // x,y,b,h (x,y för ö v h)
   g.setColor(Color.red);
   g.drawArc(100, 100, 200, 50, 180, 180); // x,y,b,h,s,l
   g.setColor(Color.yellow);
   g.fillRect(200, 100, 30, 30);
   g.fill3DRect(150, 50, 30, 50, true); // true upphöjd figur
   g.fill3DRect(250, 50, 30, 50, true);
   // skriv ut en textsträng, samt ange läget i avståndet från
   // övre vänstra hörnet i x-led åt höger och i y-led neråt
   g.drawString("** Tjenare kompis !! **", 20, 20);
   f = new Font("Arial", Font.BOLD, 30);
   setBackground(Color.cyan);
   g.setFont(f);
   g.setColor(new Color(255, 175, 175));
   g.drawString("YEEEEEEEES!!", 100, 250);
 }
    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);
    }
    @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);
      }
    }
 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);
 }
 public void paintComponent(Graphics g) {
   super.paintComponent(g);
   g.setColor(highlight);
   g.drawLine(7, 8, 7, 11);
   g.drawLine(7, 8, 10, 8);
   g.setColor(shadow);
   g.drawLine(8, 11, 10, 11);
   g.drawLine(11, 9, 11, 11);
 }
 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);
 }
    public void paintIcon(Component c, Graphics g, int x, int y) {
      Color oldColor = g.getColor();
      boolean enabled = c.isEnabled();
      boolean pressed = false;
      if (c instanceof JButton) {
        pressed = ((JButton) c).getModel().isPressed();
      }

      int i = 0;
      int j = 0;
      int w = Math.min(width, c.getWidth());
      int h = c.getHeight();
      if (h < 5 || w < 5) { // not enough space for the arrow
        g.setColor(oldColor);
        return;
      }

      int size = Math.min(h / 2, w / 2);
      size = Math.max(size, 2);
      int mid = size / 2;

      x = ((w - size) / 2); // center arrow
      y = (h - size) / 2; // center arrow
      if (pressed) {
        x++;
        y++;
      }
      g.translate(x, y); // move the x,y origin in the graphic

      if (enabled) g.setColor(UIManager.getColor("controlDkShadow")); // NOT
      // LOCALIZABLE
      else g.setColor(UIManager.getColor("controlShadow")); // NOT
      // LOCALIZABLE

      if (!enabled) {
        g.translate(1, 1);
        g.setColor(UIManager.getColor("controlLtHighlight")); // NOT
        // LOCALIZABLE
        for (i = size - 1; i >= 0; i--) {
          g.drawLine(mid - i, j, mid + i, j);
          j++;
        }
        g.translate(-1, -1);
        g.setColor(UIManager.getColor("controlShadow")); // NOT
        // LOCALIZABLE
      }

      j = 0;
      for (i = size - 1; i >= 0; i--) {
        g.drawLine(mid - i, j, mid + i, j);
        j++;
      }

      g.translate(-x, -y);
      g.setColor(oldColor);
    }
Beispiel #13
0
 public void drawPool(int deepEnd, int shallEnd, int length) {
   Graphics paper = panel.getGraphics();
   paper.setColor(Color.WHITE);
   paper.fillRect(0, 0, 200, 175);
   paper.setColor(Color.BLACK);
   paper.drawLine(50, 50, 50 + length * 15, 50);
   paper.drawLine(50, 50 + deepEnd * 15, 50, 50);
   paper.drawLine(50 + length * 15, 50, 50 + length * 15, 50 + shallEnd * 15);
   paper.drawLine(50, 50 + deepEnd * 15, 50 + length * 15, 50 + shallEnd * 15);
 }
 public void paintComponent(Graphics g) {
   super.paintComponent(g);
   int max = BUTTON_SIZE - 5;
   boolean isMaxed = frame.isMaximum();
   g.setColor(isMaxed ? shadow : highlight);
   g.drawLine(4, 4, 4, max);
   g.drawLine(4, 4, max, 4);
   g.setColor(isMaxed ? highlight : shadow);
   g.drawLine(5, max, max, max);
   g.drawLine(max, 5, max, max);
 }
Beispiel #15
0
 public void paint(Graphics g) {
   super.paint(g);
   if (!isEditing) return;
   Dimension psize = getPreferredSize();
   if (isFocused) g.setColor(Color.yellow);
   else g.setColor(Color.green);
   g.drawLine(0, 0, psize.width, 0);
   g.drawLine(0, 0, 0, psize.height);
   g.drawLine(0, psize.height - 1, psize.width - 1, psize.height - 1);
   g.drawLine(psize.width - 1, 0, psize.width - 1, psize.height - 1);
 }
  private void drawColorButton(Graphics g, int no) {
    g.setColor(cDarkShadowColor);
    g.drawLine(mRect[no].x, mRect[no].y, mRect[no].x + mRect[no].width - 2, mRect[no].y);
    g.drawLine(mRect[no].x, mRect[no].y, mRect[no].x, mRect[no].y + mRect[no].height - 2);
    g.drawLine(
        mRect[no].x + mRect[no].width - 2,
        mRect[no].y + 2,
        mRect[no].x + mRect[no].width - 2,
        mRect[no].y + mRect[no].height - 2);
    g.drawLine(
        mRect[no].x + 2,
        mRect[no].y + mRect[no].height - 2,
        mRect[no].x + mRect[no].width - 2,
        mRect[no].y + mRect[no].height - 2);

    if (mPressedButton != no || !mMouseOverButton) g.setColor(Color.white);

    g.drawLine(
        mRect[no].x + 1, mRect[no].y + 1, mRect[no].x + mRect[no].width - 3, mRect[no].y + 1);
    g.drawLine(
        mRect[no].x + 1, mRect[no].y + 1, mRect[no].x + 1, mRect[no].y + mRect[no].height - 3);

    if (mPressedButton == no && mMouseOverButton) g.setColor(Color.white);

    g.drawLine(
        mRect[no].x + mRect[no].width - 1,
        mRect[no].y + 1,
        mRect[no].x + mRect[no].width - 1,
        mRect[no].y + mRect[no].height - 1);
    g.drawLine(
        mRect[no].x + 1,
        mRect[no].y + mRect[no].height - 1,
        mRect[no].x + mRect[no].width - 1,
        mRect[no].y + mRect[no].height - 1);

    if (mColorListMode != VisualizationColor.cColorListModeCategories && no == cColorWedgeButton) {
      int x1 = mRect[no].x + 2;
      int x2 = x1 + mRect[no].width - 4;
      if (x1 < x2) {
        for (int x = x1; x < x2; x++) {
          int c = mWedgeColorList.length * (x - x1) / (x2 - x1);
          g.setColor(
              (mPressedButton == no && mMouseOverButton)
                  ? mWedgeColorList[c].darker()
                  : mWedgeColorList[c]);
          g.drawLine(x, mRect[no].y + 2, x, mRect[no].y + mRect[no].height - 3);
        }
      }
    } else {
      Color color =
          (mColorListMode == VisualizationColor.cColorListModeCategories)
              ? mCategoryColorList[no]
              : mWedgeColorList[no * (mWedgeColorList.length - 1)];
      if (mPressedButton == no && mMouseOverButton) color = color.darker();

      g.setColor(color);
      g.fillRect(mRect[no].x + 2, mRect[no].y + 2, mRect[no].width - 4, mRect[no].height - 4);
    }
  }
 @Override
 public void paintIcon(Component c, Graphics g, int x, int y) {
   g.translate(x, y);
   g.setColor(Color.ORANGE);
   g.drawLine(2, 3, 9, 10);
   g.drawLine(2, 4, 8, 10);
   g.drawLine(3, 3, 9, 9);
   g.drawLine(9, 3, 2, 10);
   g.drawLine(9, 4, 3, 10);
   g.drawLine(8, 3, 2, 9);
   g.translate(-x, -y);
 }
Beispiel #18
0
 @Override
 public void paint(Graphics g) {
   this.setSize(owner.getSize());
   int x = owner.getWidth();
   int y = owner.getHeight();
   for (int i = 1; i <= 2000; i++) {
     g.drawLine(0, space * i, x, space * i);
   }
   for (int u = 1; u <= 2000; u++) {
     g.drawLine(space * u, 0, space * u, y);
   }
 }
Beispiel #19
0
 public void paint(Graphics g) {
   double beatWidth = sp.beatWidth;
   g.setFont(font);
   for (int i = 0; i < (sp.score.getEndTime()); i++) {
     int xLoc = (int) Math.round(i * beatWidth);
     if (i % timeSig == 0) {
       g.drawLine(xLoc, 0, xLoc, height);
       if (beatWidth > 15) g.drawString("" + i, xLoc + 2, height - 2);
     } else {
       g.drawLine(xLoc, height / 2, xLoc, height);
     }
   }
 }
Beispiel #20
0
  /**
   * Called to recursively paint the check box for the specified item.
   *
   * @param item row number
   * @param g graphics object to paint.
   * @param bookmark to check selected value.
   * @return the next row number to paint.
   */
  public int paintCheckbox(final int item, final Graphics g, final Bookmark bookmark) {
    int nextItem = item + 1;

    if (bookmark != null) {
      final Rectangle checkboxBounds =
          getCheckboxBounds(item, bookmark, getDepthMap().get(bookmark));
      final int yCheckboxMidPoint = checkboxBounds.y + (checkboxBounds.height / 2);
      final int xCheckboxMidPoint = checkboxBounds.x + (checkboxBounds.width / 2);
      final Enumeration e = bookmark.elements();

      if (e.hasMoreElements()) {
        // clear any lines crossing through the checkbox.
        g.clearRect(
            checkboxBounds.x, checkboxBounds.y, checkboxBounds.width, checkboxBounds.height);

        // draw box around checkbox
        g.drawRect(checkboxBounds.x, checkboxBounds.y, checkboxBounds.width, checkboxBounds.height);

        // draw dash inside checkbox
        g.drawLine(
            checkboxBounds.x + 2,
            yCheckboxMidPoint,
            (checkboxBounds.x + checkboxBounds.width) - 2,
            yCheckboxMidPoint);

        boolean drawPlus = true;

        do {
          final Bookmark child = (Bookmark) e.nextElement();
          final Bookmark next = getBookmark(nextItem);

          if (child != next) {
            break;
          }

          drawPlus = false;
          nextItem = paintCheckbox(nextItem, g, child);
        } while (e.hasMoreElements());

        if (drawPlus) {
          g.drawLine(
              xCheckboxMidPoint,
              checkboxBounds.y + 2,
              xCheckboxMidPoint,
              (checkboxBounds.y + checkboxBounds.height) - 2);
        }
      }
    }

    return nextItem;
  }
Beispiel #21
0
  public void paintComponent(Graphics g) {
    super.paintComponent(g);

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

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

    for (DataPair pair : data) {

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

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

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

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

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

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

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

      g.setColor(Color.BLACK);

      t++;
    }
  }
Beispiel #22
0
 void PressedRect(Graphics g, int x, int y, int w, int h) {
   Color dg = new Color(128, 128, 128);
   g.setColor(Color.lightGray);
   g.drawLine(x + 1, y + h - 1, x + 1, y + h - 1);
   g.setColor(dg);
   g.drawLine(x, y, x + w - 1, y);
   g.drawLine(x, y, x, y + h - 1);
   g.setColor(Color.black);
   g.drawLine(x + 1, y + 1, x + w - 2, y + 1);
   g.drawLine(x + 1, y + 1, x + 1, y + h - 2);
   g.setColor(Color.white);
   g.drawLine(x + w, y, x + w, y + h);
   g.drawLine(x + w, y + h, x, y + h);
 }
Beispiel #23
0
  public void paint(Graphics g) // g is an object of type Graphics which can change colors etc
      {
    // everything here is for drawing a robot
    g.setColor(Color.red);
    g.drawRect(85, 60, 75, 75); // head
    g.drawRect(110, 120, 25, 10);

    g.drawLine(105, 85, 115, 75);
    g.drawLine(130, 75, 140, 85);
    g.drawLine(105, 102, 140, 102);
    g.drawRect(70, 131, 100, 75);

    // arms
    g.drawRect(30, 150, 40, 10);
    g.drawRect(170, 150, 40, 10);

    // legs
    g.drawRect(90, 206, 10, 40);
    g.drawRect(140, 206, 10, 40);
    // belly
    g.drawString(number1 + " ", 80, 180);
    g.drawString(number2 + " ", 150, 180);

    switch (choice) {
      case 0:
        drawBellyButton(g, "?", 113, 165, 20, 20);
        break;
      case 1:
        drawBellyButton(g, "+", 113, 165, 20, 20);
        g.drawString("answer = " + answer, 170, 90);
        break;
      case 2:
        drawBellyButton(g, "-", 113, 165, 20, 20);
        g.drawString("answer = " + answer, 170, 90);
        break;
      case 3:
        drawBellyButton(g, "*", 113, 165, 20, 20);
        g.drawString("answer = " + answer, 170, 90);
        break;
      case 4:
        drawBellyButton(g, "/", 113, 165, 20, 20);
        g.drawString("answer = " + answer, 170, 90);
        break;
      case 5:
        drawBellyButton(g, "%", 113, 165, 20, 20);
        g.drawString("answer = " + answer, 170, 90);
        break;
    }
  }
 public void drawTo(Graphics g, Line line) {
   if (!calc.tileOnMap(t1) || !calc.tileOnMap(t2)) return;
   if (calc.tileOnMap(line.getTile1()) && calc.tileOnMap(line.getTile2())) {
     Point p1 = calc.tileToMinimap(t1);
     Point p2 = calc.tileToMinimap(t2);
     Point p3 = calc.tileToMinimap(line.getTile2());
     Point p4 = calc.tileToMinimap(line.getTile1());
     GeneralPath path = new GeneralPath();
     path.moveTo(p1.x, p1.y);
     path.lineTo(p2.x, p2.y);
     path.lineTo(p3.x, p3.y);
     path.lineTo(p4.x, p4.y);
     path.closePath();
     g.setColor(POLY_FILL);
     ((Graphics2D) g).fill(path);
     ((Graphics2D) g).draw(path);
   }
   Point last = null, p;
   g.setColor(Color.ORANGE);
   for (RSTile t : pathList) {
     if (calc.tileOnMap(t)) {
       p = calc.tileToMinimap(t);
       g.fillOval(p.x - 2, p.y - 2, 5, 5);
       if (last != null) g.drawLine(p.x, p.y, last.x, last.y);
       last = p;
     } else last = null;
   }
 }
Beispiel #25
0
  private void drawYTicks(Graphics g) {
    int hPos = 0;
    int pPos = 0;
    for (int i = 0; i < yTicks; i++) {
      int drawPos = yVal(hPos, maxH) + r;

      if (hPos % hInc == 0) {

        // draw line
        g.setColor(Color.BLACK);
        g.drawLine(padding - 10, drawPos, padding, drawPos);

        // draw tick values for herbivores
        g.setColor(Color.BLUE);
        g.drawString("" + hPos, padding - 50, drawPos + r);

        // draw tick values for predators
        g.setColor(Color.RED);
        g.drawString("" + pPos, padding - 50, drawPos + r + 20);
      }

      hPos += hInc;
      pPos += pInc;
    }
  }
  public void paintPalette(Graphics g) {
    boolean leftToRight = MetalUtils.isLeftToRight(frame);

    int width = getWidth();
    int height = getHeight();

    if (paletteBumps == null) {
      paletteBumps =
          new MetalBumps(
              0,
              0,
              MetalLookAndFeel.getPrimaryControlHighlight(),
              MetalLookAndFeel.getPrimaryControlInfo(),
              MetalLookAndFeel.getPrimaryControlShadow());
    }

    Color background = MetalLookAndFeel.getPrimaryControlShadow();
    Color darkShadow = MetalLookAndFeel.getPrimaryControlDarkShadow();

    g.setColor(background);
    g.fillRect(0, 0, width, height);

    g.setColor(darkShadow);
    g.drawLine(0, height - 1, width, height - 1);

    int xOffset = leftToRight ? 4 : buttonsWidth + 4;
    int bumpLength = width - buttonsWidth - 2 * 4;
    int bumpHeight = getHeight() - 4;
    paletteBumps.setBumpArea(bumpLength, bumpHeight);
    paletteBumps.paintIcon(this, g, xOffset, 2);
  }
Beispiel #27
0
 void drawLine(Graphics g, DrawObject L) {
   if (L == null) {
     return;
   }
   if ((sequencingOn) && (L.sequenceNum != currentSequenceNumDisplay)) {
     return;
   }
   Graphics2D g2 = (Graphics2D) g;
   g2.setStroke(L.drawStroke);
   int x1 = (int) ((L.x - minX) / (maxX - minX) * (D.width - 2 * inset));
   int y1 = (int) ((L.y - minY) / (maxY - minY) * (D.height - 2.0 * inset));
   int x2 = (int) ((L.x2 - minX) / (maxX - minX) * (D.width - 2 * inset));
   int y2 = (int) ((L.y2 - minY) / (maxY - minY) * (D.height - 2.0 * inset));
   if (L.isArrow) {
     drawArrow(
         (Graphics2D) g,
         inset + x1,
         D.height - y1 - inset,
         inset + x2,
         D.height - y2 - inset,
         1.0f,
         L.drawStroke);
   } else {
     g.drawLine(inset + x1, D.height - y1 - inset, inset + x2, D.height - y2 - inset);
   }
 }
 public void paint(Graphics g) {
   if (f == 1) {
     g.setColor(Color.RED);
     g.drawLine(10, 10, 10, 200);
     g.setColor(Color.green);
     g.fill3DRect(20, 20, 200, 200, true);
   }
 }
 private void connectRightChild(Graphics g, int x1, int y1, int x2, int y2) {
   double r = Math.sqrt(virticalGap * virticalGap + (x2 - x1) * (x2 - x1));
   int x11 = (int) (x1 - radius * (x1 - x2) / r);
   int y11 = (int) (y1 - radius * virticalGap / r);
   int x21 = (int) (x2 + radius * (x1 - x2) / r);
   int y21 = (int) (y2 + radius * virticalGap / r);
   g.drawLine(x11, y11, x21, y21);
 }
Beispiel #30
0
  /*
   * Draws a rectangle around each viewport
   */
  public static void ShowViewport(Graphics g) {
    g.setColor(Color.black);
    // draws the viewports
    drawPoint drawFirstPoint;
    drawPoint drawSecondPoint;

    Point2D firstPoint = new Point2D(0, 0);
    Point2D secondPoint = new Point2D(1, 1);

    drawFirstPoint = ViewPortToFrameWindow(firstPoint);
    drawSecondPoint = ViewPortToFrameWindow(secondPoint);

    g.drawLine(drawFirstPoint.x, drawFirstPoint.y, drawSecondPoint.x, drawFirstPoint.y);
    g.drawLine(drawSecondPoint.x, drawFirstPoint.y, drawSecondPoint.x, drawSecondPoint.y);
    g.drawLine(drawSecondPoint.x, drawSecondPoint.y, drawFirstPoint.x, drawSecondPoint.y);
    g.drawLine(drawFirstPoint.x, drawSecondPoint.y, drawFirstPoint.x, drawFirstPoint.y);
  }