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

📄 viewer.java

📁 客户端浏览医学图像的jsp源代码。可用于临床工作站。
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/*
 * Viewer.java - This is MAIN. (Applet)
 *
 * Copyright(C) 2000, Nagoya Institute of Technology, Iwata laboratory and Takahiro Katoji
 * http://mars.elcom.nitech.ac.jp/dicom/
 *
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * @author	Takahiro Katoji(mailto:katoco@mars.elcom.nitech.ac.jp)
 * @version
 *
 */

package dicomviewer;

import java.awt.*;
import java.awt.event.*;
import java.applet.*;

public class Viewer extends Applet {

  int           debug_level = 3;

  // 僷儔儊乕僞娭學偺僼傿乕儖僪
  boolean           isLtlEndian;
  boolean           vrType;
  boolean           privacy;
  int               NUM;
  String            dicURL;
  String[]          imgURL;

  // DICOM娭學偺僼傿乕儖僪
  DicomFile         dicomFile;
  DicomData         dicomData;            // 尰嵼尒偰偄傞僇儗儞僩僨乕僞
  ImageData         imageData;            // 尰嵼尒偰偄傞僇儗儞僩僨乕僞
  DicomData[]       dicomData_tmp;        // 僥儞億儔儕偺僨乕僞
  ImageData[]       imageData_tmp;        // 僥儞億儔儕偺僨乕僞
  int[]             index;                // 僥儞億儔儕傪尒偰偄傞応崌偼偦偺攝楍偺揧偊帤
  int               TMPSIZE;              // 僥儞億儔儕攝楍偺戝偒偝乮嬼悢乯
  int[]             arrayIndex;           // 僥儞億儔儕偵擖偭偰偄傞夋憸斣崋
  int               start;                // 尰嵼僥儞億儔儕偵擖偭偰偄傞愭摢偺夋憸斣崋
  int               start_old;
  int[]             ww, wl;               // 慡偰偺夋憸暘偺WW偲WL偺僨僼僅儖僩抣偐傜偺嵎傪帩偮
  double            zoom = 1.0;           // 奼戝弅彫攞棪
  int               canvasSize = 100;
  boolean           inv_flag = false;     // 僱僈億僕斀揮
  // boolean           color_flag = false;   // 媅帡僇儔乕
  boolean           rotateL_flag = false; // 90搙夋憸夞揮僼儔僌
  boolean           rotateR_flag = false; // 90搙夋憸夞揮僼儔僌
  boolean           flipLR_flag = false;  // 嵍塃夋憸斀揮僼儔僌
  boolean           flipUD_flag = false;  // 忋壓夋憸斀揮僼儔僌
  boolean           reset_flag = false;   // 弶婜壔僼儔僌
  int               imageNo;              // Stack偺帪偺崱尒偰偄傞僀儊乕僕NO(0-?)
  boolean           synchro_flag = true;  // 慡偰偺夋憸傪曄壔偝偣傞偐偳偆偐丠
  int               imageNo_old;
  LoaderThread      loader;               // 僗儗僢僪
  boolean           isThreadStarted;      // Applet偺start傪堦搙幚峴偟偨偐偳偆偐丠
  boolean           requestStop = false;  // 僗儗僢僪偵巭傑偭偰傕傜偆傛偆偵偡傞偨傔偺僼儔僌

  // 昞帵娭學偺僼傿乕儖僪
  ImageTiledCanvas  imageTiledCanvas;     // 暲傋偰昞帵偺帪偺僉儍儞僷僗
  int               row =1;               // 暘妱悢丅峴丅
  int               column =1;            // 暘妱悢丅楍丅
  TagInfoFrame      tagInfoFrame;         // 僞僌傪昞帵偡傞僼儗乕儉
  int               tile_start;           // 僞僀儖昞帵偡傞偲偒偺僗僞乕僩夋憸斣崋
  int               width, height;        // 僀儊乕僕僆儕僕僫儖側暆偲崅偝
  AnimationThread   animationThread;      // 僔僱儌乕僪偺僗儗僢僪
  boolean           notCine = true;       // CineMode偱側偄偲偒true

  // GUI娭學偺僼傿乕儖僪
  // EventListener
  MyCheckBoxListener  myCheckBoxListener  = new MyCheckBoxListener();
  MyKeyListener       myKeyListener       = new MyKeyListener();
  // Font
  Font  bold  = new Font("Dialog", Font.BOLD, 12);
  Font  plain = new Font("Dialog", Font.PLAIN, 12);
  // Layout
  BorderLayout        borderLayout1       = new BorderLayout();
  GridBagLayout       gridBagLayout1      = new GridBagLayout();
  GridBagLayout       gridBagLayout2      = new GridBagLayout();
  GridBagConstraints  gridBagConstraints1 = new GridBagConstraints();
  GridBagConstraints  gridBagConstraints2 = new GridBagConstraints();
  // Panel
  ScrollPane  scrollPane1   = new ScrollPane();
  Panel       panel1        = new Panel();
  Panel       controlPanel  = new Panel();
  BorderPanel borderPanel1  = new BorderPanel("Mouse Manupilation");
  Panel       mousePanel    = new Panel();
  InfoPanel   infoPanel     = new InfoPanel();
  Panel       buttonPanel   = new Panel();
  Panel       copyrightPanel= new Panel();
  // Label
  Label label1        = new Label();
  Label label2        = new Label("ImageNo");
  MyLabel copyright_L   = new MyLabel("Copyright (C) 2000 Nagoya Institute of Technology, Iwata lab. & KtC");
  //MyLabel copyright_L   = new MyLabel("@see http://mars.elcom.nitech.ac.jp/dicom/index-e.html");
  // TextField
  TextField imageNo_F = new TextField(3);
  // Scrollbar
  Scrollbar imageNo_S = new Scrollbar(Scrollbar.HORIZONTAL);
  // Checkbox
  CheckboxGroup checkboxGroup1  = new CheckboxGroup();
  Checkbox      wwwlSingle_C    = new Checkbox("WL/WW(Single)", false, checkboxGroup1);
  Checkbox      wwwlALL_C       = new Checkbox("WL/WW(All images)", true, checkboxGroup1);
  Checkbox      move_C          = new Checkbox("Move" , false, checkboxGroup1);
  Checkbox      zoom_C          = new Checkbox("Zoom", false, checkboxGroup1);
  Checkbox      loupe_C         = new Checkbox("Loupe", false, checkboxGroup1);
  Checkbox      studyInfo_C     = new Checkbox("Annotation", true);
  // Button
  Button fit_B      = new Button("Reset Move/Zoom");
  Button default_B  = new Button("Default WL/WW");
  Button less_B     = new Button("LessFrame");
  Button more_B     = new Button("MoreFrame");
  Button tag_B      = new Button("Show Tag Info");
  Button inv_B      = new Button("Reverse");
  Button rotateL_B  = new Button("Rotate L");
  Button rotateR_B  = new Button("Rotate R");
  Button flipLR_B   = new Button("Flip RL");
  Button flipUD_B   = new Button("Flip UD");
  Button reset_B    = new Button("Reset Angle");
  Button cine_B     = new Button("Cine Mode");
  Button cineNext1_B= new Button("->");
  Button cinePrev1_B= new Button("<-");
  Button cineNext2_B= new Button(">>");
  Button cinePrev2_B= new Button("<<");

  //堷悢抣偺庢摼
  public String getParameter(String key, String def) {
    String paramString;
    paramString = getParameter(key) != null ? getParameter(key) : def;

    // 僨僶僢僌梡
    if (debug_level > 3) System.out.println("Parameter " + key + " is " + paramString);

    return paramString;
  }

  //堷悢忣曬偺庢摼
  public String[][] getParameterInfo() {
    String[][] pinfo =
    {
      {"isLtlEndian", "boolean", "揮憲峔暥丅LittleEndian側傜true"},
      {"vrType", "boolean", "VR偺庬椶丅柧帵揑VR側傜true"},
      {"patientPrivacy", "boolean", "姵幰僾儔僀僶僔乕曐岇偺偨傔姵幰柤曄姺偡傞偲偒true"},
      {"tmpSize", "int", "僉儍僢僔儏偝傟傞嵟戝夋憸枃悢(嬼悢)"},
      {"NUM", "int", "夋憸枃悢"},
      {"currentNo", "int", "嵟弶偵尒傞夋憸斣崋 (0-?)"},
      {"dicURL", "String", "帿彂URL"},
      {"imgURL", "String", "夋憸URL"},
    };
    return pinfo;
  }

  //傾僾儗僢僩偺峔抸乮僐儞僗僩儔僋僞乯
  public Viewer() {
  }

  //傾僾儗僢僩偺弶婜壔
  public void init() {
    // 僨僶僢僌梡
    if (debug_level > 3) System.out.println("Now Loading Parameter....");
    try {
      // 奺僷儔儊乕僞傪撉傒弌偡
      isLtlEndian = Boolean.valueOf(this.getParameter("isLtlEndian", "true")).booleanValue();
      vrType = Boolean.valueOf(this.getParameter("vrType", "false")).booleanValue();
      privacy = Boolean.valueOf(this.getParameter("patientPrivacy", "false")).booleanValue();
      TMPSIZE = Integer.parseInt(this.getParameter("tmpSize", "10"));
      NUM = Integer.parseInt(this.getParameter("NUM", "1"));
      imageNo = Integer.parseInt(this.getParameter("currentNo", "0"));
      dicURL = this.getParameter("dicURL", "none");
      imgURL = new String[NUM];
      for (int i=0; i<NUM ; i++) imgURL[i] = this.getParameter("imgURL"+i, "");

      // 僐儞億乕僱儞僩偺弶婜壔傪峴偆
      jbInit();
    }
    catch(Exception e)  {
      // 慡偰偺Exception傪僉儍僢僠偡傞
      e.printStackTrace();
    }
  }

  //僐儞億乕僱儞僩偺弶婜壔
  private void jbInit() throws Exception {

    isThreadStarted = false;

    // this.setSize(new Dimension(700,500));
    this.setLayout(borderLayout1);
    controlPanel.setLayout(gridBagLayout1);
    mousePanel.setLayout(gridBagLayout2);

    // TextFiled偺愝掕
    imageNo_F.setText(String.valueOf(imageNo +1));

    // Scrollbar偺愝掕
    imageNo_S.setValues(imageNo +1, 0, 1, NUM +1);

    // 儃僞儞偺愝掕
    less_B.setEnabled(false);
    cineNext1_B.setFont(bold);
    cineNext2_B.setFont(plain);
    cinePrev1_B.setFont(plain);
    cinePrev2_B.setFont(plain);
    cineNext1_B.setEnabled(false);
    cineNext2_B.setEnabled(false);
    cinePrev1_B.setEnabled(false);
    cinePrev2_B.setEnabled(false);

    // 奺僐儞億乕僱儞僩傪揬傝晅偗傞
    panel1.setLayout(new BorderLayout());
    this.add(scrollPane1, BorderLayout.CENTER);
    this.add(panel1, BorderLayout.WEST);
    this.add(copyrightPanel, BorderLayout.SOUTH);

    // CopyrightPanel娭學
    copyright_L.setAppletContext(this.getAppletContext());
    copyrightPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 5, 0));
    copyrightPanel.add(copyright_L);

    // buttonPanel娭學
    buttonPanel.setLayout(new GridLayout(2,1));
    buttonPanel.add(studyInfo_C);
    buttonPanel.add(tag_B);
    panel1.add(buttonPanel, BorderLayout.SOUTH);

    // InfoPanel娭學
    panel1.add(infoPanel, BorderLayout.CENTER);

    // mousePanel娭學
    gridBagConstraints2.fill = GridBagConstraints.BOTH;   // 壜擻側尷傝僐儞億乕僱儞僩傪戝偒偔偡傞

    add2mousePanel(0, 0, 6, wwwlALL_C);
    add2mousePanel(0, 1, 6, wwwlSingle_C);
    add2mousePanel(0, 2, 1, label1);
    add2mousePanel(1, 2, 5, default_B);
    add2mousePanel(0, 3, 1, label1);
    add2mousePanel(1, 3, 5, inv_B);
    add2mousePanel(0, 4, 6, move_C);
    add2mousePanel(0, 5, 6, zoom_C);
    add2mousePanel(0, 6, 1, label1);
    add2mousePanel(1, 6, 5, fit_B);
    add2mousePanel(0, 7, 6, loupe_C);

    borderPanel1.add(mousePanel);

    // controlPanel娭學
    panel1.add(controlPanel, BorderLayout.NORTH);
    gridBagConstraints1.fill = GridBagConstraints.BOTH;   // 壜擻側尷傝僐儞億乕僱儞僩傪戝偒偔偡傞

    gridBagConstraints1.gridx = 0;
    gridBagConstraints1.gridy = 0;
    gridBagConstraints1.gridwidth = 4;
    gridBagConstraints1.gridheight = 9;
    gridBagConstraints1.insets = new Insets(3,3,0,3); // 梋敀傪梌偊傞
    gridBagLayout1.setConstraints(borderPanel1, gridBagConstraints1);
    controlPanel.add(borderPanel1);
    gridBagConstraints1.insets = new Insets(0,0,0,0); // 梋敀0偵栠偡
    gridBagConstraints1.gridheight = 1;

    int line = 9; // 峴悢偺僇僂儞僩
    add2controlPanel(0, line, 4, reset_B);
    line++;
    add2controlPanel(0, line, 2, rotateL_B);
    add2controlPanel(2, line, 2, rotateR_B);
    line++;
    add2controlPanel(0, line, 2, flipLR_B);
    add2controlPanel(2, line, 2, flipUD_B);
    line++;
    gridBagConstraints1.insets = new Insets(5,0,0,0); // 僐儞億乕僱儞僩偺忋偵5僺僋僙儖偺梋敀傪梌偊傞
    add2controlPanel(0, line, 4, cine_B);
    line++;
    gridBagConstraints1.insets = new Insets(0,0,0,0); // 梋敀0偵栠偡
    add2controlPanel(0, line, 1, cinePrev2_B);
    add2controlPanel(1, line, 1, cinePrev1_B);
    add2controlPanel(2, line, 1, cineNext1_B);
    add2controlPanel(3, line, 1, cineNext2_B);
    line++;
    gridBagConstraints1.insets = new Insets(5,0,0,0); // 僐儞億乕僱儞僩偺忋偵5僺僋僙儖偺梋敀傪梌偊傞
    add2controlPanel(0, line, 2, label2);
    add2controlPanel(2, line, 2, imageNo_F);
    line++;
    gridBagConstraints1.insets = new Insets(0,0,0,0); // 梋敀0偵栠偡
    add2controlPanel(0, line, 4, imageNo_S);
    line++;
    add2controlPanel(0, line, 2, less_B);
    add2controlPanel(2, line, 2, more_B);
    line++;

    // scrollPane1娭學
    scrollPane1.setBackground(Color.black);
    // add偼start()偱峴偆

    // TagInfoFrame偺愝掕
    tagInfoFrame = new TagInfoFrame();
    tagInfoFrame.setSize(500, 400);
    tagInfoFrame.setResizable(true);

    // 僀儀儞僩偺張棟
    // imageNo娭學
    imageNo_F.addActionListener(new ActionListener () {
      public void actionPerformed(ActionEvent e) {
        imageNo_S.setValue((int)getFieldValue(imageNo_F));
        imageNo_old = imageNo;
        imageNo = imageNo_S.getValue() - 1;
        changeImageNo();
      }
    });
    imageNo_F.addKeyListener(myKeyListener);
    imageNo_S.addAdjustmentListener(new AdjustmentListener () {
      public void adjustmentValueChanged(AdjustmentEvent e) {
        imageNo_F.setText(String.valueOf(imageNo_S.getValue()));
        imageNo_old = imageNo;
        imageNo = imageNo_S.getValue() - 1;
        changeImageNo();
      }
    });
    imageNo_S.addKeyListener(myKeyListener);
    // 僠僃僢僋儃僢僋僗娭學
    wwwlSingle_C.addItemListener(myCheckBoxListener);
    wwwlSingle_C.addKeyListener(myKeyListener);
    wwwlALL_C.addItemListener(myCheckBoxListener);
    wwwlALL_C.addKeyListener(myKeyListener);
    move_C.addItemListener(myCheckBoxListener);
    move_C.addKeyListener(myKeyListener);
    zoom_C.addItemListener(myCheckBoxListener);
    zoom_C.addKeyListener(myKeyListener);
    loupe_C.addItemListener(myCheckBoxListener);
    loupe_C.addKeyListener(myKeyListener);
    studyInfo_C.addItemListener(new ItemListener() {
      public void itemStateChanged(ItemEvent e) {
        imageTiledCanvas.setStudyInfo_flag(studyInfo_C.getState());
      }
    });
    studyInfo_C.addKeyListener(myKeyListener);
    // CanvasSize傪ScrollPane偺僒僀僘偵Fit偡傞傛偆偵偡傞
    fit_B.addActionListener(new ActionListener () {
      public void actionPerformed(ActionEvent e) {
        getCanvasSize();
      }
    });

⌨️ 快捷键说明

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