Esempio n. 1
0
 /**
  * Draws a visualization tooltip.
  *
  * @param g graphics reference
  * @param tt tooltip label
  * @param x horizontal position
  * @param y vertical position
  * @param w width
  * @param c color color depth
  */
 public static void drawTooltip(
     final Graphics g, final String tt, final int x, final int y, final int w, final int c) {
   final int tw = width(g, tt);
   final int th = g.getFontMetrics().getHeight();
   final int xx = Math.min(w - tw - 8, x);
   g.setColor(color(c));
   g.fillRect(xx - 1, y - th, tw + 4, th);
   g.setColor(BACK);
   g.drawString(tt, xx, y - 4);
 }
Esempio n. 2
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);
  }
Esempio n. 3
0
  /* (non-Javadoc)
   * @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
   */
  protected void paintComponent(Graphics arg0) {
    // long time1 = System.currentTimeMillis();
    try {
      super.paintComponent(arg0);
      if (this.isOpaque()) {
        Rectangle clipBounds = arg0.getClipBounds();
        arg0.setColor(this.getBackground());
        arg0.fillRect(clipBounds.x, clipBounds.y, clipBounds.width, clipBounds.height);
      }
      this.rblock.paint(arg0);

      // Paint FrameContext selection

      RenderablePoint start = this.startSelection;
      RenderablePoint end = this.endSelection;
      if (start != null && end != null && !start.equals(end)) {
        this.rblock.paintSelection(arg0, false, start, end);
      }
    } finally {
      // long time2 = System.currentTimeMillis();
      // System.out.println("NonScrollableHtmlPanel.paintComponent(): numRenderables=" +
      // numRenderables + ",time=" + (time2 - time1) + " ms.");
    }
  }
Esempio n. 4
0
  public void print(Graphics g) {
    TextField txt = (TextField) target;
    Dimension d = txt.size();
    int w = d.width - (2 * BORDER);
    int h = d.height - (2 * BORDER);
    Color bg = txt.getBackground();
    Color fg = txt.getForeground();
    Color highlight = bg.brighter();
    String text = txt.getText();
    int moved = 0;
    int selStart = 0;
    int selEnd = 0;

    g.setFont(txt.getFont());
    g.setColor(txt.isEditable() ? highlight : bg);
    g.fillRect(BORDER, BORDER, w, h);

    g.setColor(bg);
    // g.drawRect(0, 0, d.width-1, d.height-1);
    draw3DRect(g, bg, 1, 1, d.width - 3, d.height - 3, false);

    if (text != null) {
      g.clipRect(BORDER, MARGIN, w, d.height - (2 * MARGIN));
      FontMetrics fm = g.getFontMetrics();

      w = d.width - BORDER;
      h = d.height - (2 * MARGIN);
      int xs = pos2x(selStart) - moved;
      int xe = pos2x(selEnd) - moved;

      if ((xs < MARGIN) && (xe > w)) {
        g.setColor(highlight);
        g.fillRect(BORDER, MARGIN, w - BORDER, h);
      } else {
        g.setColor(bg);
        // g.fillRect(BORDER, MARGIN, w - BORDER, h);

        if ((xs >= MARGIN) && (xs <= w)) {
          g.setColor(highlight); // selected text

          if (xe > w) {
            g.fillRect(xs, MARGIN, w - xs, h);
          } else if (xs == xe) {
            // g.fillRect(xs, MARGIN, 1, h);
          } else {
            g.fillRect(xs, MARGIN, xe - xs, h);
          }
        } else if ((xe >= MARGIN) && (xe <= w)) {
          g.setColor(highlight);
          g.fillRect(BORDER, MARGIN, xe - BORDER, h);
        }
      }
      g.setColor(fg);
      int x = MARGIN - moved;
      char echoChar = txt.getEchoChar();
      if (echoChar == 0) {
        g.drawString(text, x, BORDER + MARGIN + fm.getMaxAscent());
      } else {
        char data[] = new char[text.length()];
        for (int i = 0; i < data.length; i++) {
          data[i] = echoChar;
        }
        g.drawChars(data, 0, data.length, x, BORDER + MARGIN + fm.getMaxAscent());
      }
    }

    target.print(g);
  }