⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 swingterminal.java

📁 The Javatm Telnet Application/Applet 很好用的
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
    for (int l = 0; l < buffer.height; l++) {      if (!buffer.update[0] && !buffer.update[l + 1]) continue;      buffer.update[l + 1] = false;      if (debug > 2) System.err.println("redraw(): line " + l);      for (int c = 0; c < buffer.width; c++) {        int addr = 0;        int currAttr = buffer.charAttributes[buffer.windowBase + l][c];        fg = darken(getForeground());        bg = darken(getBackground());        if ((currAttr & buffer.COLOR_FG) != 0)          fg = darken(color[((currAttr & buffer.COLOR_FG) >> buffer.COLOR_FG_SHIFT) - 1]);        if ((currAttr & buffer.COLOR_BG) != 0)          bg = darken(darken(color[((currAttr & buffer.COLOR_BG) >> buffer.COLOR_BG_SHIFT) - 1]));        if ((currAttr & VDUBuffer.BOLD) != 0) {          g.setFont(new Font(normalFont.getName(), Font.BOLD, normalFont.getSize()));          // does not work with IE6: g.setFont(normalFont.deriveFont(Font.BOLD));          if (null != color[COLOR_BOLD]) {            fg = color[COLOR_BOLD];          }          /*          if(fg.equals(Color.black)) {            fg = Color.gray;          } else {            fg = brighten(fg);            // bg = bg.brighter(); -- make some programs ugly          }          */        } else {          g.setFont(normalFont);        }        if ((currAttr & VDUBuffer.LOW) != 0) {          fg = darken(fg);        }        if ((currAttr & VDUBuffer.INVERT) != 0) {          if (null == color[COLOR_INVERT]) {            Color swapc = bg;            bg = fg;            fg = swapc;          } else {            if (null == color[COLOR_BOLD]) {              fg = bg;            } else {              fg = color[COLOR_BOLD];            }            bg = color[COLOR_INVERT];          }        }        if (sf.inSoftFont(buffer.charArray[buffer.windowBase + l][c])) {          g.setColor(bg);          g.fillRect(c * charWidth + xoffset, l * charHeight + yoffset,                     charWidth, charHeight);          g.setColor(fg);	  if ((currAttr & VDUBuffer.INVISIBLE) == 0)            sf.drawChar(g, buffer.charArray[buffer.windowBase + l][c], xoffset + c * charWidth,                        l * charHeight + yoffset, charWidth, charHeight);          if ((currAttr & VDUBuffer.UNDERLINE) != 0)            g.drawLine(c * charWidth + xoffset,                       (l + 1) * charHeight - charDescent / 2 + yoffset,                       c * charWidth + charWidth + xoffset,                       (l + 1) * charHeight - charDescent / 2 + yoffset);          continue;        }        // determine the maximum of characters we can print in one go        while ((c + addr < buffer.width) &&                ((buffer.charArray[buffer.windowBase + l][c + addr] < ' ') ||                (buffer.charAttributes[buffer.windowBase + l][c + addr] == currAttr)) &&                !sf.inSoftFont(buffer.charArray[buffer.windowBase + l][c + addr])) {          if (buffer.charArray[buffer.windowBase + l][c + addr] < ' ') {            buffer.charArray[buffer.windowBase + l][c + addr] = ' ';            buffer.charAttributes[buffer.windowBase + l][c + addr] = 0;            continue;          }          addr++;        }        // clear the part of the screen we want to change (fill rectangle)        g.setColor(bg);        g.fillRect(c * charWidth + xoffset, l * charHeight + yoffset,                   addr * charWidth, charHeight);        g.setColor(fg);        // draw the characters, if not invisible.	if ((currAttr & VDUBuffer.INVISIBLE) == 0)          g.drawChars(buffer.charArray[buffer.windowBase + l], c, addr,                    c * charWidth + xoffset,                    (l + 1) * charHeight - charDescent + yoffset);        if ((currAttr & VDUBuffer.UNDERLINE) != 0)          g.drawLine(c * charWidth + xoffset,                     (l + 1) * charHeight - charDescent / 2 + yoffset,                     c * charWidth + addr * charWidth + xoffset,                     (l + 1) * charHeight - charDescent / 2 + yoffset);        c += addr - 1;      }      // selection code, highlites line or part of it when it was      // selected previously      if (l >= selectStartLine && l <= selectEndLine) {        int selectStartColumn = (l == selectStartLine ? selectBegin.x : 0);        int selectEndColumn =                (l == selectEndLine ?                (l == selectStartLine ? selectEnd.x - selectStartColumn :                selectEnd.x) : buffer.width);        if (selectStartColumn != selectEndColumn) {          if (debug > 0)            System.err.println("select(" + selectStartColumn + "-"                               + selectEndColumn + ")");          g.setXORMode(bg);          g.fillRect(selectStartColumn * charWidth + xoffset,                     l * charHeight + yoffset,                     selectEndColumn * charWidth,                     charHeight);          g.setPaintMode();        }      }    }    // draw cursor    if (buffer.showcursor && (            buffer.screenBase + buffer.cursorY >= buffer.windowBase &&            buffer.screenBase + buffer.cursorY < buffer.windowBase + buffer.height)    ) {      g.setColor(cursorColorFG);      g.setXORMode(cursorColorBG);      g.fillRect(buffer.cursorX * charWidth + xoffset,                 (buffer.cursorY + buffer.screenBase - buffer.windowBase) * charHeight + yoffset,                 charWidth, charHeight);      g.setPaintMode();      g.setColor(color[COLOR_FG_STD]);    }    // draw border    if (insets != null) {      g.setColor(getBackground());      xoffset--;      yoffset--;      for (int i = insets.top - 1; i >= 0; i--)        g.draw3DRect(xoffset - i, yoffset - i,                     charWidth * buffer.width + 1 + i * 2,                     charHeight * buffer.height + 1 + i * 2,                     raised);    }    buffer.update[0] = false;  }  /**   * Paint the current screen using the backing store image.   */  public void paint(Graphics g) {    if (backingStore == null) {      Dimension size = super.getSize();      backingStore = createImage(size.width, size.height);      buffer.update[0] = true;      redraw();    }    if (debug > 1)      System.err.println("Clip region: " + g.getClipBounds());    g.drawImage(backingStore, 0, 0, this);  }/*  public int print(Graphics g, PageFormat pf, int pi) throws PrinterException {    if(pi >= 1) {      return Printable.NO_SUCH_PAGE;    }    paint(g);    return Printable.PAGE_EXISTS;  }*/  /**   * Set default for printing black&amp;white or colorized as displayed on   * screen.   * @param colorPrint true = print in full color, default b&amp;w only   */  public void setColorPrinting(boolean colorPrint) {    colorPrinting = colorPrint;  }  public void print(Graphics g) {    if (debug > 0) System.err.println("DEBUG: print()");    for (int i = 0; i <= buffer.height; i++) buffer.update[i] = true;    Color fg = null, bg = null, colorSave[] = null;    if (!colorPrinting) {      fg = getForeground();      bg = getBackground();      setForeground(Color.black);      setBackground(Color.white);      colorSave = color;      color = new Color[]{Color.black,                          Color.black,                          Color.black,                          Color.black,                          Color.black,                          Color.black,                          Color.black,                          Color.white,                          null,                          null,      };    }    redraw(g);    if (!colorPrinting) {      color = colorSave;      setForeground(fg);      setBackground(bg);    }  }  /**   * Convert Mouse Event coordinates into character cell coordinates   * @param  evtpt the mouse point to be converted   * @return Character cell coordinate of passed point   */  public Point mouseGetPos(Point evtpt) {    Point mousepos;    mousepos = new Point(0, 0);    int xoffset = (super.getSize().width - buffer.width * charWidth) / 2;    int yoffset = (super.getSize().height - buffer.height * charHeight) / 2;    mousepos.x = (evtpt.x - xoffset) / charWidth;    if (mousepos.x < 0) mousepos.x = 0;    if (mousepos.x >= buffer.width) mousepos.x = buffer.width - 1;    mousepos.y = (evtpt.y - yoffset) / charHeight;    if (mousepos.y < 0) mousepos.y = 0;    if (mousepos.y >= buffer.height) mousepos.y = buffer.height - 1;    return mousepos;  }  /**   * Set cursor FG and BG colors   * @param fg foreground color or null   * @param bg background color or null   */  public void setCursorColors(Color fg, Color bg) {    if (fg == null)      cursorColorFG = color[COLOR_FG_STD];    else      cursorColorFG = fg;    if (bg == null)      cursorColorBG = color[COLOR_BG_STD];    else      cursorColorBG = bg;    repaint();  }  /**   * Reshape character display according to resize strategy.   * @see #setResizeStrategy   */  public void setBounds(int x, int y, int w, int h) {    if (debug > 0)      System.err.println("VDU: setBounds(" + x + "," + y + "," + w + "," + h + ")");    super.setBounds(x, y, w, h);    // ignore zero bounds    if (x == 00 && y == 0 && w == 0 && h == 0) {      return;    }    if (insets != null) {      w -= insets.left + insets.right;      h -= insets.top + insets.bottom;    }    if (debug > 0)      System.err.println("VDU: looking for better match for " + normalFont);    Font tmpFont = normalFont;    String fontName = tmpFont.getName();    int fontStyle = tmpFont.getStyle();    fm = getFontMetrics(normalFont);    if (fm != null) {      charWidth = fm.charWidth('@');      charHeight = fm.getHeight();    }    switch (resizeStrategy) {      case RESIZE_SCREEN:        buffer.setScreenSize(w / charWidth, buffer.height = h / charHeight);        break;      case RESIZE_FONT:        int height = h / buffer.height;        int width = w / buffer.width;        fm = getFontMetrics(normalFont = new Font(fontName, fontStyle,                                                  charHeight));        // adapt current font size (from small up to best fit)        if (fm.getHeight() < height || fm.charWidth('@') < width)          do {            fm = getFontMetrics(normalFont = new Font(fontName, fontStyle,                                                      ++charHeight));          } while (fm.getHeight() < height || fm.charWidth('@') < width);        // now check if we got a font that is too large        if (fm.getHeight() > height || fm.charWidth('@') > width)          do {            fm = getFontMetrics(normalFont = new Font(fontName, fontStyle,                                                      --charHeight));          } while (charHeight > 1 &&                  (fm.getHeight() > height ||                  fm.charWidth('@') > width));        if (charHeight <= 1) {          System.err.println("VDU: error during resize, resetting");          normalFont = tmpFont;          System.err.println("VDU: disabling font/screen resize");          resizeStrategy = RESIZE_NONE;        }        setFont(normalFont);        fm = getFontMetrics(normalFont);        charWidth = fm.charWidth('@');        charHeight = fm.getHeight();        charDescent = fm.getDescent();        break;      case RESIZE_NONE:      default:        break;    }    if (debug > 0) {      System.err.println("VDU: charWidth=" + charWidth + ", " +                         "charHeight=" + charHeight + ", " +                         "charDescent=" + charDescent);    }    // delete the double buffer image and mark all lines    backingStore = null;    buffer.markLine(0, buffer.height);  }  /**   * Return the real size in points of the character display.   * @return Dimension the dimension of the display   * @see java.awt.Dimension   */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -