コード例 #1
0
  /**
   * For testing, establish an association to the specified AE and send a DICOM instance (send a
   * C-STORE request).
   *
   * @param arg array of seven or nine strings - their hostname, their port, their AE Title, our AE
   *     Title, the filename containing the instance to send, optionally the SOP Class and the SOP
   *     Instance (otherwise will be read from the file), the compression level (0=none,1=propose
   *     deflate,2=propose deflate and bzip2) and the debugging level
   */
  public static void main(String arg[]) {
    try {
      String theirHost = null;
      int theirPort = -1;
      String theirAETitle = null;
      String ourAETitle = null;
      String fileName = null;
      String SOPClassUID = null;
      String SOPInstanceUID = null;
      int compressionLevel = 0;
      int debugLevel = 0;

      if (arg.length == 9) {
        theirHost = arg[0];
        theirPort = Integer.parseInt(arg[1]);
        theirAETitle = arg[2];
        ourAETitle = arg[3];
        fileName = arg[4];
        SOPClassUID = arg[5];
        SOPInstanceUID = arg[6];
        compressionLevel = Integer.parseInt(arg[7]);
        debugLevel = Integer.parseInt(arg[8]);
      } else if (arg.length == 7) {
        theirHost = arg[0];
        theirPort = Integer.parseInt(arg[1]);
        theirAETitle = arg[2];
        ourAETitle = arg[3];
        fileName = arg[4];
        SOPClassUID = null; // figured out by StorageSOPClassSCU() by reading the metaheader
        SOPInstanceUID = null; // figured out by StorageSOPClassSCU() by reading the metaheader
        compressionLevel = Integer.parseInt(arg[5]);
        debugLevel = Integer.parseInt(arg[6]);
      } else {
        throw new Exception("Argument list must be 7 or 9 values");
      }
      new TestSendingCommandAndDataInOnePDU(
          theirHost,
          theirPort,
          theirAETitle,
          ourAETitle,
          fileName,
          SOPClassUID,
          SOPInstanceUID,
          compressionLevel,
          debugLevel);
    } catch (Exception e) {
      e.printStackTrace(System.err);
      System.exit(0);
    }
  }
コード例 #2
0
ファイル: TestApp.java プロジェクト: hajk1/pixelmed-20151119
  /** @param arg */
  public static void main(String arg[]) {
    TestApp af = new TestApp();

    SourceImage sImg = null;

    int imagesPerRow = 0;
    int imagesPerCol = 0;

    int imgMin = 65536;
    int imgMax = 0;

    boolean signed = false;
    boolean inverted = false;
    boolean hasPad = false;
    int padValue = 0;

    if (arg.length == 6) {
      // do it with raw file
      int w = 0;
      int h = 0;
      int d = 0;
      try {
        w = Integer.valueOf(arg[1]).intValue();
        h = Integer.valueOf(arg[2]).intValue();
        d = Integer.valueOf(arg[3]).intValue();
        imagesPerRow = Integer.valueOf(arg[4]).intValue();
        imagesPerCol = Integer.valueOf(arg[5]).intValue();
      } catch (Exception e) {
        System.err.println(e);
        System.exit(0);
      }

      try {
        FileInputStream i = new FileInputStream(arg[0]);
        sImg = new SourceImage(i, w, h, d);
      } catch (Exception e) {
        System.err.println(e);
        System.exit(0);
      }
    } else {
      // do it with DICOM file

      if (arg.length > 2) {
        try {
          imagesPerRow = Integer.valueOf(arg[1]).intValue();
          imagesPerCol = Integer.valueOf(arg[2]).intValue();
        } catch (Exception e) {
          System.err.println(e);
          e.printStackTrace(System.err);
          System.exit(0);
        }
      } else {
        imagesPerRow = 1;
        imagesPerCol = 1;
      }

      try {
        DicomInputStream i = new DicomInputStream(new FileInputStream(arg[0]));
        sImg = new SourceImage(i);
      } catch (Exception e) {
        System.err.println(e);
        e.printStackTrace(System.err);
        System.exit(0);
      }
    }

    try {
      // com.apple.cocoa.application.NSMenu.setMenuBarVisible(false);							// Won't compile on
      // other platforms
      // Class classToUse =
      // ClassLoader.getSystemClassLoader().loadClass("com.apple.cocoa.application.NSMenu");	//
      // Needs "/System/Library/Java" in classpath
      Class classToUse =
          new java.net.URLClassLoader(new java.net.URL[] {new File("/System/Library/Java").toURL()})
              .loadClass("com.apple.cocoa.application.NSMenu");
      Class[] parameterTypes = {Boolean.TYPE};
      java.lang.reflect.Method methodToUse =
          classToUse.getDeclaredMethod("setMenuBarVisible", parameterTypes);
      Object[] args = {Boolean.FALSE};
      methodToUse.invoke(null /*since static*/, args);
    } catch (Exception e) { // ClassNotFoundException,NoSuchMethodException,IllegalAccessException
      e.printStackTrace(System.err);
    }

    java.awt.Dimension d = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    int frameWidth = (int) d.getWidth();
    int frameHeight = (int) d.getHeight();
    System.err.println("frameWidth=" + frameWidth);
    System.err.println("frameHeight=" + frameHeight);
    af.setUndecorated(true);
    af.setLocation(0, 0);
    af.setSize(frameWidth, frameHeight);

    JPanel multiPanel = new JPanel();
    multiPanel.setLayout(new GridLayout(imagesPerCol, imagesPerRow));
    multiPanel.setBackground(Color.black);

    SingleImagePanel imagePanel[] = new SingleImagePanel[imagesPerRow * imagesPerCol];

    int singleWidth = frameWidth / imagesPerRow;
    int singleHeight = frameHeight / imagesPerCol;
    System.err.println("singleWidth=" + singleWidth);
    System.err.println("singleHeight=" + singleHeight);

    for (int x = 0; x < imagesPerCol; ++x) {
      for (int y = 0; y < imagesPerRow; ++y) {
        SingleImagePanel ip = new SingleImagePanel(sImg);
        // ip.setPreferredSize(new Dimension(img.getWidth(),img.getHeight()));
        // ip.setPreferredSize(new Dimension(sImg.getWidth(),sImg.getHeight()));
        ip.setPreferredSize(new Dimension(singleWidth, singleHeight));
        multiPanel.add(ip);
        imagePanel[x * imagesPerRow + y] = ip;
      }
    }

    // multiPanel.setSize(img.getWidth()*imagesPerRow,img.getHeight()*imagesPerRow);

    // JScrollPane scrollPane = new JScrollPane(multiPanel);

    Container content = af.getContentPane();
    content.setLayout(new GridLayout(1, 1));
    // content.add(scrollPane);
    content.add(multiPanel);

    af.pack();
    af.setVisible(true);
  }