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

📄 borderpanel.java

📁 客户端浏览医学图像的jsp源代码。可用于临床工作站。
💻 JAVA
字号:
/**
 * BorderPanel.java
 *
 * 儔儀儖偲棫懱揑側榞慄偑昞帵偝傟傞僷僱儖丅
 * 儔儀儖晅偒偺応崌丄僷僱儖偺壓偵彮偟梋敀偑偱偒傞丅
 * 儗僀傾僂僩偼 FlowLayout 偺傒偵懳墳丅
 *
 * Copyright(C) 2000, Nagoya Institute of Technology, Iwata laboratory and Takahiro Katoji
 * http://mars.elcom.nitech.ac.jp/dicom/
 *
 * @author	Takahiro Katoji(mailto:katoco@mars.elcom.nitech.ac.jp)
 * @version
 *
 */

package dicomviewer;

import java.awt.*;

public class BorderPanel extends Panel {
  boolean isLabelNull = true; // 儔儀儖晅偒偐偳偆偐丠(儔儀儖側偟:true)
  Color color;                // 尦偲側傞怓
  Color upLeft, downRight;    // 尦偺怓偺彮偟擹偄怓偲敄偄怓
  String label;               // 儔儀儖
  Font font;                  // 儔儀儖傪昞帵偡傞僼僅儞僩
  FontMetrics fm;

  // 僐儞僗僩儔僋僞
  // 儔儀儖側偟
  public BorderPanel() {
    // 僼僅儞僩偺愝掕
    font = new Font("Dialog", Font.PLAIN, 12);
    fm = getFontMetrics(font);
    // 儗僀傾僂僩偺愝掕
    super.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
  }
  // 儔儀儖晅偒
  public BorderPanel(String label) {
    isLabelNull = false;
    // 僼僅儞僩偺愝掕
    font = new Font("Dialog", Font.PLAIN, 12);
    fm = getFontMetrics(font);
    // 儔儀儖偺庢摼
    this.label = label;
    // 儗僀傾僂僩偺愝掕
    super.setLayout(new FlowLayout(FlowLayout.CENTER, 5, fm.getHeight()));
  }

  // setLayout偺僆乕僶乕儔僀僪
  public void setLayout(LayoutManager mgr) {
    // 壗傕偟側偄丅偮傑傝儗僀傾僂僩偺曄峏傪嫋偝側偄丅
  }

  // 儔儀儖丄榞慄偺昤夋
  public void paint(Graphics g){
    // 怓偺愝掕
    color = Color.gray;
	upLeft = color.darker();
    downRight = color.brighter();
    // 昤夋偺偨傔偺戝偒偝
    int width, height, fmHeightHalf, stringWidth;

    // 棫懱揑側榞慄偲儔儀儖傪昤偔
    // 儔儀儖側偟偺応崌
    if(isLabelNull) {
      // 戝偒偝偺強摼
      width = (int)this.getSize().width;
      height = (int)this.getSize().height;
      fmHeightHalf = 0;

      // 忋偺慄
      g.setColor(upLeft);
      g.drawLine(0, 0, width -1, 0);
      g.setColor(downRight);
      g.drawLine(1, 1, width -2, 1);

    // 儔儀儖晅偒偺応崌
    }else {
      // 戝偒偝偺強摼
      width = (int)this.getSize().width;
      height = (int)this.getSize().height - fm.getHeight() +5;
      fmHeightHalf = fm.getAscent() >> 1;
      stringWidth = fm.stringWidth(label);

      // 儔儀儖偺昤夋
      g.setFont(font);
      g.setColor(Color.black);
      g.drawString(label, fm.getAscent(), 10);

      // 忋偺慄
      g.setColor(upLeft);
      g.drawLine(0, fmHeightHalf, 7, fmHeightHalf);
      g.drawLine(stringWidth +16, fmHeightHalf, width -1, fmHeightHalf);
      g.setColor(downRight);
      g.drawLine(1, fmHeightHalf +1, 7, fmHeightHalf +1);
      g.drawLine(stringWidth +16, fmHeightHalf +1, width -2, fmHeightHalf +1);
    }

    // 儔儀儖側偟丄儔儀儖晅偒偲傕嫟捠
    // 嵍偺慄
    g.setColor(upLeft);
    g.drawLine(0, fmHeightHalf, 0, height -1);
    g.setColor(downRight);
    g.drawLine(1, fmHeightHalf +1, 1, height -2);
    // 壓偺慄
    g.setColor(upLeft);
    g.drawLine(1, height -2, width -2, height -2);
    g.setColor(downRight);
    g.drawLine(0, height -1, width -1, height -1);
    // 塃偺慄
    g.setColor(upLeft);
    g.drawLine(width -2, fmHeightHalf +1, width -2, height -2);
    g.setColor(downRight);
    g.drawLine(width -1, fmHeightHalf, width -1, height -1);
  }

  // updata儊僜僢僪偺僆乕僶乕儔僀僪乮昤夋偺岠棪壔偺偨傔偵乯
  public void updata(Graphics g){
    paint(g);
  }

}

⌨️ 快捷键说明

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