com.pixelmed.dicom

## Class DicomDirectory

- java.lang.Object
- - com.pixelmed.dicom.DicomDirectory

All Implemented Interfaces:
  javax.swing.tree.TreeModel

    public class DicomDirectory
    extends java.lang.Object
    implements javax.swing.tree.TreeModel

### Field Summary

Fields
`protected java.util.HashMap` `mapOfDirectoryRecordsToSequenceItems`

### Constructor Summary

Constructors
Constructor and Description
`DicomDirectory()` Create an empty DicomDirectory
`DicomDirectory(AttributeList list)` Create a DicomDirectory from a DICOMDIR instance already read as an AttributeList
`DicomDirectory(AttributeList list, boolean doConcatenations)` Create a DicomDirectory from a DICOMDIR instance already read as an AttributeList, optionally creating synthetic concatenation records
`DicomDirectory(java.io.File rootDirectoryName, java.lang.String[] fileNames)` Create a new DicomDirectory from a list of existing DICOM files contained within a specified root directory.
`DicomDirectory(java.lang.String[] fileNames)` Create a new DicomDirectory from a list of existing DICOM files contained within the current working directory.

### Method Summary

Methods
`void` `addAttributeListFromDicomFileToDirectory(AttributeList list, java.lang.String fileName)`
`void` `addTreeModelListener(javax.swing.event.TreeModelListener tml)`
`static java.util.Vector` `findAllContainedReferencedFileNames(DicomDirectoryRecord record, java.lang.String parentFilePath)` Get all the referenced file names at or below the specified directory record.
`java.util.Vector` `findAllContainedReferencedFileNames(java.lang.String parentFilePath)` Get all the referenced file names in the entire directory.
`static java.util.HashMap` `findAllContainedReferencedFileNamesAndTheirRecords(DicomDirectoryRecord record, java.lang.String parentFilePath)` Get all the referenced file names at or below the specified directory record, and a map to the directory records that reference them.
`java.util.HashMap` `findAllContainedReferencedFileNamesAndTheirRecords(java.lang.String parentFilePath)` Get all the referenced file names in the entire directory, and a map to the directory records that reference them.
`java.util.Vector` `findAllImagesForFrameOfReference(java.lang.String frameOfReferenceUID)` Get the attribute lists from all the IMAGE level directory records which have a particular FrameOfReferenceUID.
`java.lang.Object` `getChild(java.lang.Object node, int index)`
`int` `getChildCount(java.lang.Object parent)`
`int` `getIndexOfChild(java.lang.Object parent, java.lang.Object child)`
`java.util.Map` `getMapOfSOPInstanceUIDToReferencedFileName(java.lang.String parentFilePath)`
`java.lang.String` `getReferencedFileNameForSOPInstanceUID(java.lang.String sopInstanceUID)`
`java.lang.Object` `getRoot()`
`boolean` `isLeaf(java.lang.Object node)`
`static void` `main(java.lang.String[] arg)` Read DICOM files and create a DICOMDIR.
`void` `readDicomFileAndAddToDirectory(java.io.File rootDirectoryName, java.lang.String fileName)`
`void` `readDicomFileAndAddToDirectory(java.lang.String fileName)`
`void` `removeTreeModelListener(javax.swing.event.TreeModelListener tml)`
`java.lang.String` `toString()`
`void` `valueForPathChanged(javax.swing.tree.TreePath path, java.lang.Object newValue)`
`void` `write(java.lang.String name)` Write the directory to the named file.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### mapOfDirectoryRecordsToSequenceItems

    protected java.util.HashMap mapOfDirectoryRecordsToSequenceItems

### Constructor Detail

#### DicomDirectory

    public DicomDirectory(java.lang.String[] fileNames)

Create a new DicomDirectory from a list of existing DICOM files contained within the current working directory.

The filenames must be relative to the current working directory, and not absolute paths, since the full name will be used in the DICOMDIR records.

Filenames are NOT checked for compliance with restrictions on length and character set.

Parameters:
  `fileNames` -

#### DicomDirectory

    public DicomDirectory(java.io.File rootDirectoryName,
                  java.lang.String[] fileNames)

Create a new DicomDirectory from a list of existing DICOM files contained within a specified root directory.

The specified root directory will NOT be included in the referenced file name in the DICOMDIR records.

Filenames are NOT checked for compliance with restrictions on length and character set.

Parameters:
  `rootDirectoryName` -
  `fileNames` -

#### DicomDirectory

    public DicomDirectory()

Create an empty DicomDirectory

#### DicomDirectory

    public DicomDirectory(AttributeList list)
                   throws DicomException

Create a DicomDirectory from a DICOMDIR instance already read as an AttributeList

Parameters:
  `list` -
Throws:
  `DicomException`

#### DicomDirectory

    public DicomDirectory(AttributeList list,
                  boolean doConcatenations)
                   throws DicomException

Create a DicomDirectory from a DICOMDIR instance already read as an AttributeList, optionally creating synthetic concatenation records

Parameters:
  `list` -
  `doConcatenations` -
Throws:
  `DicomException`

### Method Detail

#### getChild

    public java.lang.Object getChild(java.lang.Object node,
                            int index)

Specified by:
  `getChild` in interface `javax.swing.tree.TreeModel`
Parameters:
  `node` -
  `index` -

#### getIndexOfChild

    public int getIndexOfChild(java.lang.Object parent,
                      java.lang.Object child)

Specified by:
  `getIndexOfChild` in interface `javax.swing.tree.TreeModel`
Parameters:
  `parent` -
  `child` -

#### getRoot

    public java.lang.Object getRoot()

Specified by:
  `getRoot` in interface `javax.swing.tree.TreeModel`

#### getChildCount

    public int getChildCount(java.lang.Object parent)

Specified by:
  `getChildCount` in interface `javax.swing.tree.TreeModel`
Parameters:
  `parent` -

#### isLeaf

    public boolean isLeaf(java.lang.Object node)

Specified by:
  `isLeaf` in interface `javax.swing.tree.TreeModel`
Parameters:
  `node` -

#### valueForPathChanged

    public void valueForPathChanged(javax.swing.tree.TreePath path,
                           java.lang.Object newValue)

Specified by:
  `valueForPathChanged` in interface `javax.swing.tree.TreeModel`
Parameters:
  `path` -
  `newValue` -

#### addTreeModelListener

    public void addTreeModelListener(javax.swing.event.TreeModelListener tml)

Specified by:
  `addTreeModelListener` in interface `javax.swing.tree.TreeModel`
Parameters:
  `tml` -

#### removeTreeModelListener

    public void removeTreeModelListener(javax.swing.event.TreeModelListener tml)

Specified by:
  `removeTreeModelListener` in interface `javax.swing.tree.TreeModel`
Parameters:
  `tml` -

#### readDicomFileAndAddToDirectory

    public void readDicomFileAndAddToDirectory(java.io.File rootDirectoryName,
                                      java.lang.String fileName)
                                        throws DicomException,
                                               java.io.IOException

Parameters:
  `rootDirectoryName` -
  `fileName` -
Throws:
  `DicomException`
  `java.io.IOException`

#### readDicomFileAndAddToDirectory

    public void readDicomFileAndAddToDirectory(java.lang.String fileName)
                                        throws DicomException,
                                               java.io.IOException

Parameters:
  `fileName` -
Throws:
  `DicomException`
  `java.io.IOException`

#### addAttributeListFromDicomFileToDirectory

    public void addAttributeListFromDicomFileToDirectory(AttributeList list,
                                                java.lang.String fileName)
                                                  throws DicomException,
                                                         java.io.IOException

Parameters:
  `list` -
  `fileName` -
Throws:
  `DicomException`
  `java.io.IOException`

#### write

    public void write(java.lang.String name)
               throws java.io.IOException,
                      DicomException

Write the directory to the named file.

Parameters:
  `name` - the file name to write to
Throws:
  `java.io.IOException`
  `DicomException`

#### toString

    public java.lang.String toString()

Overrides:
  `toString` in class `java.lang.Object`

#### getMapOfSOPInstanceUIDToReferencedFileName

    public java.util.Map getMapOfSOPInstanceUIDToReferencedFileName(java.lang.String parentFilePath)

Parameters:
  `parentFilePath` -

#### getReferencedFileNameForSOPInstanceUID

    public java.lang.String getReferencedFileNameForSOPInstanceUID(java.lang.String sopInstanceUID)
                                                            throws DicomException

Parameters:
  `sopInstanceUID` -
Throws:
  `DicomException`

#### findAllContainedReferencedFileNamesAndTheirRecords

    public static java.util.HashMap findAllContainedReferencedFileNamesAndTheirRecords(DicomDirectoryRecord record,
                                                                       java.lang.String parentFilePath)

Get all the referenced file names at or below the specified directory record, and a map to the directory records that reference them.

Parameters:
  `record` -
  `parentFilePath` - the folder in which the DICOMDIR lives (i.e., the base for contained references)
Returns:
  a java.util.HashMap whose keys are string file names fully qualified by the specified parent, mapped to DicomDirectoryRecords

#### findAllContainedReferencedFileNamesAndTheirRecords

    public java.util.HashMap findAllContainedReferencedFileNamesAndTheirRecords(java.lang.String parentFilePath)

Get all the referenced file names in the entire directory, and a map to the directory records that reference them.

Parameters:
  `parentFilePath` - the folder in which the DICOMDIR lives (i.e., the base for contained references)
Returns:
  a java.util.HashMap whose keys are string file names fully qualified by the specified parent, mapped to DicomDirectoryRecords

#### findAllContainedReferencedFileNames

    public static java.util.Vector findAllContainedReferencedFileNames(DicomDirectoryRecord record,
                                                       java.lang.String parentFilePath)

Get all the referenced file names at or below the specified directory record.

Parameters:
  `record` -
  `parentFilePath` - the folder in which the DICOMDIR lives (i.e., the base for contained references)
Returns:
  a java.util.Vector of string file names fully qualified by the specified parent

#### findAllContainedReferencedFileNames

    public java.util.Vector findAllContainedReferencedFileNames(java.lang.String parentFilePath)

Get all the referenced file names in the entire directory.

Parameters:
  `parentFilePath` - the folder in which the DICOMDIR lives (i.e., the base for contained references)
Returns:
  a java.util.Vector of string file names fully qualified by the specified parent

#### findAllImagesForFrameOfReference

    public java.util.Vector findAllImagesForFrameOfReference(java.lang.String frameOfReferenceUID)

Get the attribute lists from all the IMAGE level directory records which have a particular FrameOfReferenceUID.

Useful for finding potential localizers and orthogonal images.

Note that even though FrameOfReference is a series level entity, in the CT/MR profiles it is specified at the IMAGE directory record level.

Parameters:
  `frameOfReferenceUID` -
Returns:
  a java.util.Vector of com.pixelmed.dicom.AttributeList

#### main

    public static void main(java.lang.String[] arg)

Read DICOM files and create a DICOMDIR.

Parameters:
  `arg` - optionally the folder in which the files and DICOMDIR are rooted, the filename of the DICOMDIR to be created, then the filenames of the DICOM files to include