コード例 #1
0
  public void scrollToAttribute(Attribute a) {
    if (!a.getDescriptor().getConfig().equals(getConfig())) {
      logger.fine("Cannot scroll to attribute that isn't attached to this type of descriptor");
      return;
    }
    int rowIndex = getCurrentModel().getRowForDescriptor(a.getDescriptor());
    int colIndex = getCurrentModel().getColumnForAttribute(a);
    JScrollPane scrollPane = (JScrollPane) this.getComponent(0);
    JViewport viewport = (JViewport) scrollPane.getViewport();
    EnhancedTable table = (EnhancedTable) viewport.getView();

    // This rectangle is relative to the table where the
    // northwest corner of cell (0,0) is always (0,0).
    Rectangle rect = table.getCellRect(rowIndex, colIndex, true);

    // The location of the viewport relative to the table
    Point pt = viewport.getViewPosition();

    // Translate the cell location so that it is relative
    // to the view, assuming the northwest corner of the
    // view is (0,0)
    rect.setLocation(rect.x - pt.x, rect.y - pt.y);

    // Scroll the area into view
    viewport.scrollRectToVisible(rect);
  }
コード例 #2
0
ファイル: ChestImageViewer.java プロジェクト: kullen/MRI
 /**
  * @param list
  * @return array of two String values, row then column orientation, else array of two nulls if
  *     cannot be obtained
  */
 private static String[] getPatientOrientation(AttributeList list) {
   String[] vPatientOrientation = null;
   Attribute aPatientOrientation = list.get(TagFromName.PatientOrientation);
   if (aPatientOrientation != null && aPatientOrientation.getVM() == 2) {
     try {
       vPatientOrientation = aPatientOrientation.getStringValues();
       if (vPatientOrientation != null && vPatientOrientation.length != 2) {
         vPatientOrientation = null;
       }
     } catch (DicomException e) {
       vPatientOrientation = null;
     }
   }
   if (vPatientOrientation == null) {
     vPatientOrientation = new String[2];
   }
   return vPatientOrientation;
 }
コード例 #3
0
    public void show(Component invoker, int x, int y) {
      ViperViewMediator mediator = getMediator();
      Point pnt = new Point(x, y);
      EnhancedTable tab = getTable();
      int row = tab.rowAtPoint(pnt);
      desc = getCurrentModel().getDescriptorAtRow(row);
      int col = tab.columnAtPoint(pnt);
      Object cellValue = tab.getValueAt(row, col);
      if (cellValue instanceof Attribute) {
        attr = (Attribute) cellValue;

        // hide the "Occlusions..." option when we're not dealing with a Textline object
        boolean isTextline = attr.getAttrConfig().getAttrType().endsWith("textline");
        occlusions.setVisible(isTextline);
        occSeparator.setVisible(isTextline);

        Instant now = mediator.getCurrentFrame();
        if (now == null) {
          mediator.getDisplayWRTManager().setAttribute(null, null);
          wrt.setEnabled(false);
          wrt.setSelected(false);
        } else {
          boolean isDwrt = attr == mediator.getDisplayWRTManager().getAttribute();
          boolean dwrtable =
              (attr.getAttrValueAtInstant(now) instanceof HasCentroid
                  && attr.getDescriptor().getValidRange().contains(now));
          wrt.setEnabled(dwrtable);
          wrt.setSelected(isDwrt);
        }
      } else {
        attr = null;
        wrt.setEnabled(false);
        wrt.setSelected(false);
      }
      if (null != desc) {
        PropagateInterpolateModule proper = getMediator().getPropagator();
        p.setSelected(proper.isPropagatingThis(desc));
        v.setSelected(mediator.isThisValidNow(desc));
        resetMarks();
        super.show(invoker, x, y);
      }
    }
コード例 #4
0
ファイル: ChestImageViewer.java プロジェクト: kullen/MRI
 /**
  * @param list
  * @return a single String value, null if cannot be obtained
  */
 private static String getDate(AttributeList list) {
   return Attribute.getSingleStringValueOrNull(list, TagFromName.StudyDate);
 }
コード例 #5
0
ファイル: ChestImageViewer.java プロジェクト: kullen/MRI
 /**
  * @param list
  * @return a single String value, null if cannot be obtained
  */
 private static String getLaterality(AttributeList list) {
   return Attribute.getSingleStringValueOrNull(list, TagFromName.ImageLaterality);
 }
コード例 #6
0
ファイル: ChestImageViewer.java プロジェクト: kullen/MRI
  /**
   * @param filenames
   * @exception Exception if internal error
   */
  public void loadMultiPanelFromSpecifiedFiles(String filenames[]) throws Exception {

    int nFiles = filenames.length;

    SingleImagePanel imagePanels[] = new SingleImagePanel[nFiles];

    String orientations[][] = new String[nFiles][];
    String views[] = new String[nFiles];
    String lateralityViewAndModifiers[] = new String[nFiles];
    String lateralities[] = new String[nFiles];
    int widths[] = new int[nFiles];
    int heights[] = new int[nFiles];
    PixelSpacing spacing[] = new PixelSpacing[nFiles];

    String rowOrientations[] = new String[nFiles];
    String columnOrientations[] = new String[nFiles];

    HashMap eventContexts = new HashMap();

    double maximumHorizontalExtentInMm = 0;
    double maximumVerticalExtentInMm = 0;

    StructuredReport sr[] = new StructuredReport[nFiles];

    int nImages = 0;
    int nCAD = 0;
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    for (int f = 0; f < nFiles; ++f) {
      try {
        String filename = filenames[f];
        DicomInputStream distream = null;
        InputStream in = classLoader.getResourceAsStream(filename);
        if (in != null) {
          distream = new DicomInputStream(in);
        } else {
          distream = new DicomInputStream(new File(filename));
        }
        AttributeList list = new AttributeList();
        list.read(distream);
        if (list.isImage()) {
          int i = nImages++;
          System.err.println("IMAGE [" + i + "] is file " + f + " (" + filenames[f] + ")");

          orientations[i] = getPatientOrientation(list);
          // System.err.println("IMAGE ["+i+"] orientation="+(orientations[i] == null &&
          // orientations[i].length == 2 ? "" : (orientations[i][0] + " " + orientations[i][1])));
          views[i] = getView(list);
          // System.err.println("IMAGE ["+i+"] view="+views[i]);
          lateralityViewAndModifiers[i] = getImageLateralityViewModifierAndViewModifier(list);
          // System.err.println("IMAGE ["+i+"]
          // lateralityViewAndModifiers="+lateralityViewAndModifiers[i]);
          // System.err.println("File "+filenames[f]+": "+lateralityViewAndModifiers[i]);
          lateralities[i] = getLaterality(list);
          // System.err.println("IMAGE ["+i+"] laterality="+lateralities[i]);
          spacing[i] = new PixelSpacing(list);
          // System.err.println("IMAGE ["+i+"] spacing="+spacing[i]);

          SourceImage sImg = new SourceImage(list);
          BufferedImage img = sImg.getBufferedImage();

          widths[i] = sImg.getWidth();
          heights[i] = sImg.getHeight();

          boolean shareVOIEventsInStudy =
              false; // does not seem to work anyway, since adding VOITransform to panel constructor
                     // :(

          EventContext eventContext = new EventContext(Integer.toString(i));

          SingleImagePanel imagePanel = makeNewImagePanel(sImg, eventContext);
          imagePanel.setDemographicAndTechniqueAnnotations(
              new DemographicAndTechniqueAnnotations(list),
              "SansSerif",
              Font.PLAIN,
              10,
              Color.pink);
          imagePanel.setOrientationAnnotations(
              new OrientationAnnotations(rowOrientations[i], columnOrientations[i]),
              "SansSerif",
              Font.PLAIN,
              20,
              Color.pink);
          imagePanel.setPixelSpacingInSourceImage(
              spacing[i].getSpacing(), spacing[i].getDescription());
          if (Attribute.getSingleStringValueOrEmptyString(list, TagFromName.VOILUTFunction)
              .equals("SIGMOID")) {
            imagePanel.setVOIFunctionToLogistic();
          }
          imagePanels[i] = imagePanel;
        } else {
          throw new DicomException("Unsupported SOP Class in file " + filenames[f]);
        }
      } catch (Exception e) { // FileNotFoundException,IOException,DicomException
        e.printStackTrace(System.err);
      }
    }

    // int imagesPerRow = nImages;			// i.e., 1 -> 1, 2 -> 1, 4 -> 4, 5 -> 4, 8 -> 4
    // int imagesPerCol = 1;

    int imagesPerRow = nImages >= 8 ? 8 : nImages; // i.e., 1 -> 1, 2 -> 1, 4 -> 4, 5 -> 4, 8 -> 4
    int imagesPerCol =
        (nImages - 1) / imagesPerRow + 1; // i.e., 1 -> 1, 2 -> 2, 4 -> 1, 5 -> 2, 8 -> 2

    int singleWidth = frameWidth / imagesPerRow;
    int singleHeight = frameHeight / imagesPerCol;

    if (nImages == 1 && singleWidth > singleHeight) {
      singleWidth =
          singleWidth / 2; // use only half the screen for a single view and a landscape monitor
    }

    for (int i = 0; i < nImages; ++i) {
      DisplayedAreaSelection displayedAreaSelection = null;
      displayedAreaSelection =
          new DisplayedAreaSelection(
              widths[i],
              heights[i],
              0,
              0,
              widths[i],
              heights[i],
              true, // in case spacing was not supplied
              0,
              0,
              0,
              0,
              0,
              false /*crop*/);
      imagePanels[i].setDisplayedAreaSelection(displayedAreaSelection);
      imagePanels[i].setPreTransformImageRelativeCoordinates(null);
    }

    SingleImagePanel.deconstructAllSingleImagePanelsInContainer(multiPanel);
    multiPanel.removeAll();
    multiPanel.setLayout(new GridLayout(imagesPerCol, imagesPerRow));
    multiPanel.setBackground(Color.black);

    for (int x = 0; x < imagesPerCol; ++x) {
      for (int y = 0; y < imagesPerRow; ++y) {
        int i = x * imagesPerRow + y;
        if (i < nImages) {
          imagePanels[i].setPreferredSize(new Dimension(singleWidth, singleHeight));
          multiPanel.add(imagePanels[i]);
        }
      }
    }
    frame.getContentPane().validate();
    frame.getContentPane().repaint();
  }