[med-svn] [mayam] 08/10: New upstream version 0.8

Andreas Tille tille at debian.org
Tue Dec 26 13:08:43 UTC 2017


This is an automated email from the git hooks/post-receive script.

tille pushed a commit to branch master
in repository mayam.

commit b95324a78bb9aefc8272ee4edd28f789bfbf7481
Author: Andreas Tille <tille at debian.org>
Date:   Tue Dec 26 14:03:14 2017 +0100

    New upstream version 0.8
---
 LICENSE.txt                                        |   40 +
 build.xml                                          |   74 +
 debian/changelog                                   |    5 -
 debian/compat                                      |    1 -
 debian/control                                     |   44 -
 debian/copyright                                   |   15 -
 debian/rules                                       |   12 -
 debian/source/format                               |    1 -
 debian/watch                                       |    8 -
 lib/clibwrapper_jiio.jar                           |  Bin 0 -> 69341 bytes
 lib/dcm4che-core-2.0.22.jar                        |  Bin 0 -> 320685 bytes
 lib/dcm4che-filecache-2.0.22.jar                   |  Bin 0 -> 5797 bytes
 lib/dcm4che-imageio-rle-2.0.23.jar                 |  Bin 0 -> 10102 bytes
 lib/dcm4che-net-2.0.22.jar                         |  Bin 0 -> 116459 bytes
 lib/dcm4che.jar                                    |  Bin 0 -> 764339 bytes
 lib/derby.jar                                      |  Bin 0 -> 2276398 bytes
 lib/jai_codec.jar                                  |  Bin 0 -> 181608 bytes
 lib/jai_core.jar                                   |  Bin 0 -> 1422677 bytes
 lib/jai_imageio.jar                                |  Bin 0 -> 1140632 bytes
 lib/libclib_jiio.so                                |  Bin 0 -> 1244729 bytes
 lib/nimrodlf-1.0.jar                               |  Bin 0 -> 203271 bytes
 lib/pdf-renderer-1.0.5.jar                         |  Bin 0 -> 2087109 bytes
 manifest.mf                                        |    3 +
 nbproject/build-impl.xml                           |  891 +++++++
 nbproject/genfiles.properties                      |    8 +
 nbproject/private/config.properties                |    0
 nbproject/private/private.properties               |    7 +
 nbproject/private/private.xml                      |    4 +
 nbproject/project.properties                       |  104 +
 nbproject/project.xml                              |   15 +
 src/DcmRcv.properties                              |   61 +
 src/MoveScu.properties                             |   10 +
 src/NimRODThemeFile.theme                          |   10 +
 src/TranscoderMain.properties                      |   21 +
 src/de/iftm/dcm4che/services/CDimseService.java    | 1139 +++++++++
 src/de/iftm/dcm4che/services/ConfigProperties.java |  233 ++
 src/de/iftm/dcm4che/services/StorageService.java   |  541 +++++
 .../dcm4che/services/StorageServiceAdapter.java    |  554 +++++
 .../iftm/dcm4che/services/StorageServiceEvent.java |  103 +
 .../services/StorageServiceEventListener.java      |   55 +
 .../raster/mayam/context/ApplicationContext.java   |  168 ++
 .../raster/mayam/delegate/AnnotationDelegate.java  |  240 ++
 src/in/raster/mayam/delegate/Anonymize.java        |   73 +
 src/in/raster/mayam/delegate/CgetDelegate.java     |   72 +
 src/in/raster/mayam/delegate/CineTimer.java        |   74 +
 .../raster/mayam/delegate/DestinationFinder.java   |  132 ++
 .../raster/mayam/delegate/DicomServerDelegate.java |   80 +
 src/in/raster/mayam/delegate/EchoService.java      |  163 ++
 .../mayam/delegate/EncapsulatedPdfToJpeg.java      |  122 +
 .../raster/mayam/delegate/ExportToDcmDelegate.java |  197 ++
 .../raster/mayam/delegate/ExportingDelegate.java   |  132 ++
 src/in/raster/mayam/delegate/ImageOrientation.java |  118 +
 .../mayam/delegate/ImportDcmDirDelegate.java       |  354 +++
 src/in/raster/mayam/delegate/ImportDelegate.java   |  190 ++
 .../mayam/delegate/InputArgumentsParser.java       |  198 ++
 .../mayam/delegate/JpegConvertorDelegate.java      |  526 +++++
 .../raster/mayam/delegate/LocalizerDelegate.java   |  160 ++
 src/in/raster/mayam/delegate/MoveDelegate.java     |   76 +
 .../mayam/delegate/NetworkQueueUpdateDelegate.java |  144 ++
 .../mayam/delegate/QueryInstanceService.java       |  161 ++
 .../raster/mayam/delegate/QuerySeriesService.java  |  162 ++
 src/in/raster/mayam/delegate/QueryService.java     |  183 ++
 src/in/raster/mayam/delegate/ReceiveDelegate.java  |   94 +
 src/in/raster/mayam/delegate/RemoveStudy.java      |   90 +
 src/in/raster/mayam/delegate/SendingDelegate.java  |  120 +
 .../mayam/delegate/SeriesChooserDelegate.java      |  174 ++
 .../raster/mayam/delegate/SeriesListUpdator.java   |  366 +++
 .../raster/mayam/delegate/SeriesThumbUpdator.java  |  126 +
 .../delegate/ShowComparisonViewerDelegate.java     |  138 ++
 .../mayam/delegate/ShowImageViewDelegate.java      |   94 +
 .../raster/mayam/delegate/ShowViewerDelegate.java  |  132 ++
 src/in/raster/mayam/delegate/StudyListUpdator.java |  144 ++
 .../mayam/delegate/SynchronizationDelegate.java    |   98 +
 .../mayam/delegate/WadoRetrieveDelegate.java       |  238 ++
 .../mayam/delegate/WindowingPanelLoader.java       |   74 +
 .../exception/CompressedDcmOnMacException.java     |   67 +
 .../mayam/exception/ImageReadingException.java     |   68 +
 src/in/raster/mayam/facade/ApplicationFacade.java  |  110 +
 src/in/raster/mayam/facade/Platform.java           |   96 +
 src/in/raster/mayam/form/AnnotationPanel.form      |   31 +
 src/in/raster/mayam/form/AnnotationPanel.java      | 1428 ++++++++++++
 src/in/raster/mayam/form/Canvas.form               |   41 +
 src/in/raster/mayam/form/Canvas.java               |  388 ++++
 src/in/raster/mayam/form/DateFormatPanel.form      |  107 +
 src/in/raster/mayam/form/DateFormatPanel.java      |  138 ++
 src/in/raster/mayam/form/DicomListenerPanel.form   |   83 +
 src/in/raster/mayam/form/DicomListenerPanel.java   |  146 ++
 src/in/raster/mayam/form/DicomTagsViewer.form      |  123 +
 src/in/raster/mayam/form/DicomTagsViewer.java      |  153 ++
 src/in/raster/mayam/form/ExportingProgress.form    |   63 +
 src/in/raster/mayam/form/ExportingProgress.java    |  127 +
 src/in/raster/mayam/form/ImagePanel.form           |   43 +
 src/in/raster/mayam/form/ImagePanel.java           | 2444 ++++++++++++++++++++
 src/in/raster/mayam/form/ImageToolbar.form         |  634 +++++
 src/in/raster/mayam/form/ImageToolbar.java         | 1645 +++++++++++++
 src/in/raster/mayam/form/ImageView.form            |   67 +
 src/in/raster/mayam/form/ImageView.java            |  159 ++
 src/in/raster/mayam/form/ImportingProgress.form    |   63 +
 src/in/raster/mayam/form/ImportingProgress.java    |  129 ++
 src/in/raster/mayam/form/LayeredCanvas.java        |  324 +++
 src/in/raster/mayam/form/LayoutManagerPanel.form   |  156 ++
 src/in/raster/mayam/form/LayoutManagerPanel.java   |  245 ++
 src/in/raster/mayam/form/MainScreen.form           |  666 ++++++
 src/in/raster/mayam/form/MainScreen.java           | 1222 ++++++++++
 src/in/raster/mayam/form/QueryRetrieve.form        |  691 ++++++
 src/in/raster/mayam/form/QueryRetrieve.java        | 1043 +++++++++
 src/in/raster/mayam/form/SendReceiveFrame.form     |   54 +
 src/in/raster/mayam/form/SendReceiveFrame.java     |  104 +
 src/in/raster/mayam/form/SendReceivePanel.form     |  139 ++
 src/in/raster/mayam/form/SendReceivePanel.java     |  126 +
 src/in/raster/mayam/form/SendingProgress.form      |   63 +
 src/in/raster/mayam/form/SendingProgress.java      |  127 +
 src/in/raster/mayam/form/SeriesPanel.form          |   72 +
 src/in/raster/mayam/form/SeriesPanel.java          |  412 ++++
 src/in/raster/mayam/form/ServerChangeListener.java |   51 +
 src/in/raster/mayam/form/ServerManager.form        |  144 ++
 src/in/raster/mayam/form/ServerManager.java        |  368 +++
 src/in/raster/mayam/form/ServerManagerFrame.form   |   46 +
 src/in/raster/mayam/form/ServerManagerFrame.java   |   99 +
 src/in/raster/mayam/form/SplashScreen.form         |   44 +
 src/in/raster/mayam/form/SplashScreen.java         |   86 +
 src/in/raster/mayam/form/TextOverlay.form          |  360 +++
 src/in/raster/mayam/form/TextOverlay.java          |  407 ++++
 src/in/raster/mayam/form/Thumbnail.java            |  123 +
 src/in/raster/mayam/form/ThumbnailImage.form       |   65 +
 src/in/raster/mayam/form/ThumbnailImage.java       |  320 +++
 src/in/raster/mayam/form/Tile.form                 |   36 +
 src/in/raster/mayam/form/Tile.java                 |  164 ++
 .../mayam/form/WindowConfigurationPanel.form       |  118 +
 .../mayam/form/WindowConfigurationPanel.java       |  170 ++
 src/in/raster/mayam/form/WindowingCanvas.form      |   38 +
 src/in/raster/mayam/form/WindowingCanvas.java      |  275 +++
 src/in/raster/mayam/form/WindowingImagePanel.form  |   31 +
 src/in/raster/mayam/form/WindowingImagePanel.java  | 1107 +++++++++
 .../raster/mayam/form/WindowingLayeredCanvas.java  |  211 ++
 .../raster/mayam/form/WindowingManagerPanel.form   |  146 ++
 .../raster/mayam/form/WindowingManagerPanel.java   |  213 ++
 src/in/raster/mayam/form/WindowingTextOverlay.form |  283 +++
 src/in/raster/mayam/form/WindowingTextOverlay.java |  352 +++
 src/in/raster/mayam/form/dcm3d/DicomMIP.form       |  228 ++
 src/in/raster/mayam/form/dcm3d/DicomMIP.java       |  794 +++++++
 src/in/raster/mayam/form/dcm3d/DicomMPR2D.form     |  174 ++
 src/in/raster/mayam/form/dcm3d/DicomMPR2D.java     |  532 +++++
 .../raster/mayam/form/dcm3d/DicomMPR3DSlider.form  |  267 +++
 .../raster/mayam/form/dcm3d/DicomMPR3DSlider.java  |  967 ++++++++
 .../mayam/form/dcm3d/DicomVolumeRendering.form     |  223 ++
 .../mayam/form/dcm3d/DicomVolumeRendering.java     |  798 +++++++
 .../raster/mayam/form/dcm3d/SurfaceRendering.form  |  663 ++++++
 .../raster/mayam/form/dcm3d/SurfaceRendering.java  | 1373 +++++++++++
 .../mayam/form/dialog/AEManagementDialog.form      |  188 ++
 .../mayam/form/dialog/AEManagementDialog.java      |  374 +++
 src/in/raster/mayam/form/dialog/About.form         |   65 +
 src/in/raster/mayam/form/dialog/About.java         |  147 ++
 src/in/raster/mayam/form/dialog/ConfirmDelete.form |   87 +
 src/in/raster/mayam/form/dialog/ConfirmDelete.java |  229 ++
 src/in/raster/mayam/form/dialog/EchoStatus.form    |   74 +
 src/in/raster/mayam/form/dialog/EchoStatus.java    |  161 ++
 src/in/raster/mayam/form/dialog/ExportDialog.form  |  143 ++
 src/in/raster/mayam/form/dialog/ExportDialog.java  |  266 +++
 .../mayam/form/dialog/ExportLocationChooser.form   |   98 +
 .../mayam/form/dialog/ExportLocationChooser.java   |  242 ++
 .../raster/mayam/form/dialog/FieldValidator.form   |   67 +
 .../raster/mayam/form/dialog/FieldValidator.java   |  161 ++
 .../mayam/form/dialog/FileChooserDialog.form       |   55 +
 .../mayam/form/dialog/FileChooserDialog.java       |  183 ++
 .../mayam/form/dialog/NumberFormatValidator.form   |   80 +
 .../mayam/form/dialog/NumberFormatValidator.java   |  179 ++
 .../raster/mayam/form/dialog/SendingProgress.form  |   77 +
 .../raster/mayam/form/dialog/SendingProgress.java  |  178 ++
 .../raster/mayam/form/dialog/ServerListDialog.form |   88 +
 .../raster/mayam/form/dialog/ServerListDialog.java |  245 ++
 .../raster/mayam/form/dialog/SettingsDialog.form   |  185 ++
 .../raster/mayam/form/dialog/SettingsDialog.java   |  331 +++
 .../mayam/form/dialog/StudyAvailabilityStatus.form |   71 +
 .../mayam/form/dialog/StudyAvailabilityStatus.java |  158 ++
 .../raster/mayam/form/dialog/WadoInformation.form  |  141 ++
 .../raster/mayam/form/dialog/WadoInformation.java  |  242 ++
 src/in/raster/mayam/form/display/Display.java      |   81 +
 src/in/raster/mayam/form/images/AxialView.png      |  Bin 0 -> 1479 bytes
 src/in/raster/mayam/form/images/CoronalView.png    |  Bin 0 -> 1428 bytes
 src/in/raster/mayam/form/images/Cube3D.png         |  Bin 0 -> 572 bytes
 src/in/raster/mayam/form/images/Cut.png            |  Bin 0 -> 628 bytes
 src/in/raster/mayam/form/images/DrawCircle.png     |  Bin 0 -> 708 bytes
 src/in/raster/mayam/form/images/DrawLine.png       |  Bin 0 -> 512 bytes
 .../mayam/form/images/FusionSurfaceSettings.png    |  Bin 0 -> 1064 bytes
 src/in/raster/mayam/form/images/Grid.png           |  Bin 0 -> 230 bytes
 src/in/raster/mayam/form/images/Link.png           |  Bin 0 -> 856 bytes
 src/in/raster/mayam/form/images/Move.png           |  Bin 0 -> 622 bytes
 src/in/raster/mayam/form/images/Movie.png          |  Bin 0 -> 532 bytes
 .../raster/mayam/form/images/ResetInteractor.png   |  Bin 0 -> 572 bytes
 src/in/raster/mayam/form/images/RotateSurface.png  |  Bin 0 -> 676 bytes
 src/in/raster/mayam/form/images/SagittalView.png   |  Bin 0 -> 1515 bytes
 src/in/raster/mayam/form/images/ScreenShot.png     |  Bin 0 -> 512 bytes
 src/in/raster/mayam/form/images/Search.png         |  Bin 0 -> 576 bytes
 src/in/raster/mayam/form/images/Settings.png       |  Bin 0 -> 675 bytes
 src/in/raster/mayam/form/images/ZoomInOut.png      |  Bin 0 -> 607 bytes
 src/in/raster/mayam/form/images/ZoomInOut_1.png    |  Bin 0 -> 607 bytes
 src/in/raster/mayam/form/images/angle.png          |  Bin 0 -> 413 bytes
 .../mayam/form/images/annotation_overlay.png       |  Bin 0 -> 633 bytes
 .../mayam/form/images/annotation_selection.png     |  Bin 0 -> 527 bytes
 src/in/raster/mayam/form/images/cd_burn.png        |  Bin 0 -> 4061 bytes
 src/in/raster/mayam/form/images/cd_burn1.png       |  Bin 0 -> 2729 bytes
 src/in/raster/mayam/form/images/cd_burn2.png       |  Bin 0 -> 3124 bytes
 src/in/raster/mayam/form/images/cd_import.png      |  Bin 0 -> 2108 bytes
 src/in/raster/mayam/form/images/cd_import1.png     |  Bin 0 -> 2143 bytes
 src/in/raster/mayam/form/images/cd_import2.png     |  Bin 0 -> 2040 bytes
 src/in/raster/mayam/form/images/cineloop.png       |  Bin 0 -> 899 bytes
 src/in/raster/mayam/form/images/cineloop1.png      |  Bin 0 -> 744 bytes
 src/in/raster/mayam/form/images/cineloop2.png      |  Bin 0 -> 969 bytes
 .../mayam/form/images/clear_all_annotation.png     |  Bin 0 -> 732 bytes
 .../raster/mayam/form/images/delete_annotation.png |  Bin 0 -> 702 bytes
 src/in/raster/mayam/form/images/delete_study.png   |  Bin 0 -> 2330 bytes
 src/in/raster/mayam/form/images/delete_study1.png  |  Bin 0 -> 2186 bytes
 src/in/raster/mayam/form/images/delete_study2.png  |  Bin 0 -> 2243 bytes
 src/in/raster/mayam/form/images/drop_down.png      |  Bin 0 -> 467 bytes
 src/in/raster/mayam/form/images/ellipse.png        |  Bin 0 -> 637 bytes
 src/in/raster/mayam/form/images/export_series.png  |  Bin 0 -> 561 bytes
 src/in/raster/mayam/form/images/export_study.png   |  Bin 0 -> 1892 bytes
 src/in/raster/mayam/form/images/export_study1.png  |  Bin 0 -> 1884 bytes
 src/in/raster/mayam/form/images/export_study2.png  |  Bin 0 -> 1865 bytes
 src/in/raster/mayam/form/images/fav_mayam.png      |  Bin 0 -> 2538 bytes
 .../raster/mayam/form/images/flip_horizontal.png   |  Bin 0 -> 479 bytes
 src/in/raster/mayam/form/images/flip_vertical.png  |  Bin 0 -> 565 bytes
 src/in/raster/mayam/form/images/import.png         |  Bin 0 -> 1832 bytes
 src/in/raster/mayam/form/images/import1.png        |  Bin 0 -> 1801 bytes
 src/in/raster/mayam/form/images/import2.png        |  Bin 0 -> 1801 bytes
 src/in/raster/mayam/form/images/invert.png         |  Bin 0 -> 658 bytes
 src/in/raster/mayam/form/images/layout.png         |  Bin 0 -> 515 bytes
 src/in/raster/mayam/form/images/mayam.png          |  Bin 0 -> 44215 bytes
 .../raster/mayam/form/images/metadata_mainpage.png |  Bin 0 -> 1714 bytes
 .../mayam/form/images/metadata_mainpage1.png       |  Bin 0 -> 955 bytes
 .../mayam/form/images/metadata_mainpage2.png       |  Bin 0 -> 1337 bytes
 .../mayam/form/images/metadata_viewerpage.png      |  Bin 0 -> 729 bytes
 src/in/raster/mayam/form/images/pan.png            |  Bin 0 -> 622 bytes
 src/in/raster/mayam/form/images/pdficon.png        |  Bin 0 -> 9018 bytes
 src/in/raster/mayam/form/images/probe.png          |  Bin 0 -> 611 bytes
 src/in/raster/mayam/form/images/query.png          |  Bin 0 -> 1950 bytes
 src/in/raster/mayam/form/images/query1.png         |  Bin 0 -> 1526 bytes
 src/in/raster/mayam/form/images/query2.png         |  Bin 0 -> 1955 bytes
 src/in/raster/mayam/form/images/queue.png          |  Bin 0 -> 1647 bytes
 src/in/raster/mayam/form/images/queue1.png         |  Bin 0 -> 930 bytes
 src/in/raster/mayam/form/images/queue2.png         |  Bin 0 -> 1148 bytes
 src/in/raster/mayam/form/images/rectangle.png      |  Bin 0 -> 278 bytes
 src/in/raster/mayam/form/images/reset.png          |  Bin 0 -> 615 bytes
 src/in/raster/mayam/form/images/rotate_left.png    |  Bin 0 -> 676 bytes
 src/in/raster/mayam/form/images/rotate_right.png   |  Bin 0 -> 684 bytes
 src/in/raster/mayam/form/images/ruler.png          |  Bin 0 -> 1071 bytes
 src/in/raster/mayam/form/images/scout.png          |  Bin 0 -> 563 bytes
 src/in/raster/mayam/form/images/send.png           |  Bin 0 -> 1690 bytes
 src/in/raster/mayam/form/images/send1.png          |  Bin 0 -> 1421 bytes
 src/in/raster/mayam/form/images/send2.png          |  Bin 0 -> 1667 bytes
 src/in/raster/mayam/form/images/stack.png          |  Bin 0 -> 519 bytes
 src/in/raster/mayam/form/images/textoverlay.png    |  Bin 0 -> 327 bytes
 src/in/raster/mayam/form/images/viewer.png         |  Bin 0 -> 2522 bytes
 src/in/raster/mayam/form/images/viewer1.png        |  Bin 0 -> 1847 bytes
 src/in/raster/mayam/form/images/viewer2.png        |  Bin 0 -> 2520 bytes
 src/in/raster/mayam/form/images/windowing.png      |  Bin 0 -> 684 bytes
 src/in/raster/mayam/form/images/zoomin.png         |  Bin 0 -> 607 bytes
 src/in/raster/mayam/form/images/zoomout.png        |  Bin 0 -> 606 bytes
 src/in/raster/mayam/form/shapes/SelectedShape.java |  101 +
 .../raster/mayam/form/shapes/ShapeCoordinates.java |   94 +
 .../mayam/form/tab/component/ButtonTabComp.java    |  164 ++
 src/in/raster/mayam/model/AEModel.java             |  102 +
 src/in/raster/mayam/model/InputArgumentValues.java |  242 ++
 src/in/raster/mayam/model/Instance.java            |  305 +++
 src/in/raster/mayam/model/PresetModel.java         |  104 +
 src/in/raster/mayam/model/ScoutLineInfoModel.java  |  170 ++
 src/in/raster/mayam/model/Series.java              |  206 ++
 src/in/raster/mayam/model/ServerModel.java         |  156 ++
 src/in/raster/mayam/model/Study.java               |  133 ++
 src/in/raster/mayam/model/StudyModel.java          |  160 ++
 .../mayam/model/combo/ModalityComboModel.java      |   83 +
 .../mayam/model/combo/TransferSyntaxModel.java     |   81 +
 .../mayam/model/combo/WindowingComboModel.java     |   83 +
 .../raster/mayam/model/table/PresetTableModel.java |  140 ++
 .../raster/mayam/model/table/SeriesListModel.java  |  118 +
 .../raster/mayam/model/table/ServerTableModel.java |  195 ++
 .../raster/mayam/model/table/StudyListModel.java   |  123 +
 .../mayam/model/table/TagsTableDataModel.java      |  116 +
 .../mayam/model/table/renderer/CellRenderer.java   |   84 +
 .../mayam/model/table/renderer/HeaderRenderer.java |   62 +
 src/in/raster/mayam/param/QueryParam.java          |  289 +++
 src/in/raster/mayam/param/TextOverlayParam.java    |  267 +++
 src/in/raster/mayam/param/WadoParam.java           |  187 ++
 src/in/raster/mayam/util/DicomTags.java            |  102 +
 src/in/raster/mayam/util/DicomTagsReader.java      |  140 ++
 src/in/raster/mayam/util/core/Configuration.java   |  117 +
 src/in/raster/mayam/util/core/DcmQR.java           | 1804 +++++++++++++++
 src/in/raster/mayam/util/core/DcmRcv.java          | 1272 ++++++++++
 src/in/raster/mayam/util/core/DcmSnd.java          | 1472 ++++++++++++
 src/in/raster/mayam/util/core/MoveScu.java         |  537 +++++
 src/in/raster/mayam/util/core/MoveScu.properties   |   10 +
 src/in/raster/mayam/util/core/PixelDataParam.java  |  213 ++
 .../raster/mayam/util/core/SendStgCmtResult.java   |   81 +
 src/in/raster/mayam/util/core/StgCmtSCP.java       |   72 +
 src/in/raster/mayam/util/core/StorageSCP.java      |  101 +
 src/in/raster/mayam/util/core/Transcoder.java      |  730 ++++++
 src/in/raster/mayam/util/core/TranscoderMain.java  |  233 ++
 .../mayam/util/core/TranscoderMain.properties      |   21 +
 .../mayam/util/database/DatabaseHandler.java       | 1741 ++++++++++++++
 .../raster/mayam/util/localizer/SliceLocator.java  |  584 +++++
 .../raster/mayam/util/measurement/Annotation.java  |   86 +
 .../mayam/util/measurement/AnnotationObj.java      |  237 ++
 .../mayam/util/measurement/InstanceAnnotation.java |  102 +
 .../mayam/util/measurement/SeriesAnnotation.java   |   95 +
 .../mayam/util/measurement/StudyAnnotation.java    |   79 +
 src/log4j.properties                               |    6 +
 src/resources/CDimseService.cfg                    |  266 +++
 src/resources/EchoService.cfg                      |  247 ++
 src/resources/Image.cfg                            |  256 ++
 .../KeyTool_genkey_identityJava_20years.bat        |    6 +
 src/resources/SaveFilesystem.cfg                   |   64 +
 src/resources/Series.cfg                           |  255 ++
 src/resources/StorageService.cfg                   |  195 ++
 src/resources/Study.cfg                            |  264 +++
 src/resources/cacerts.jks                          |  Bin 0 -> 721 bytes
 src/resources/identity.p12                         |  Bin 0 -> 1725 bytes
 src/resources/identityJava.jks                     |  Bin 0 -> 1257 bytes
 src/resources/movescu.cfg                          |   23 +
 319 files changed, 54331 insertions(+), 86 deletions(-)

diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..c1aa66b
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,40 @@
+
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */ 
diff --git a/build.xml b/build.xml
new file mode 100644
index 0000000..794bb17
--- /dev/null
+++ b/build.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- You may freely edit this file. See commented blocks below for -->
+<!-- some examples of how to customize the build. -->
+<!-- (If you delete it and reopen the project it will be recreated.) -->
+<!-- By default, only the Clean and Build commands use this build script. -->
+<!-- Commands such as Run, Debug, and Test only use this build script if -->
+<!-- the Compile on Save feature is turned off for the project. -->
+<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
+<!-- in the project's Project Properties dialog box.-->
+<project name="Mayam" default="default" basedir=".">
+    <description>Builds, tests, and runs the project Mayam.</description>
+    <import file="nbproject/build-impl.xml"/>
+    <!--
+
+    There exist several targets which are by default empty and which can be 
+    used for execution of your tasks. These targets are usually executed 
+    before and after some main targets. They are: 
+
+      -pre-init:                 called before initialization of project properties
+      -post-init:                called after initialization of project properties
+      -pre-compile:              called before javac compilation
+      -post-compile:             called after javac compilation
+      -pre-compile-single:       called before javac compilation of single file
+      -post-compile-single:      called after javac compilation of single file
+      -pre-compile-test:         called before javac compilation of JUnit tests
+      -post-compile-test:        called after javac compilation of JUnit tests
+      -pre-compile-test-single:  called before javac compilation of single JUnit test
+      -post-compile-test-single: called after javac compilation of single JUunit test
+      -pre-jar:                  called before JAR building
+      -post-jar:                 called after JAR building
+      -post-clean:               called after cleaning build products
+
+    (Targets beginning with '-' are not intended to be called on their own.)
+
+    Example of inserting an obfuscator after compilation could look like this:
+
+        <target name="-post-compile">
+            <obfuscate>
+                <fileset dir="${build.classes.dir}"/>
+            </obfuscate>
+        </target>
+
+    For list of available properties check the imported 
+    nbproject/build-impl.xml file. 
+
+
+    Another way to customize the build is by overriding existing main targets.
+    The targets of interest are: 
+
+      -init-macrodef-javac:     defines macro for javac compilation
+      -init-macrodef-junit:     defines macro for junit execution
+      -init-macrodef-debug:     defines macro for class debugging
+      -init-macrodef-java:      defines macro for class execution
+      -do-jar-with-manifest:    JAR building (if you are using a manifest)
+      -do-jar-without-manifest: JAR building (if you are not using a manifest)
+      run:                      execution of project 
+      -javadoc-build:           Javadoc generation
+      test-report:              JUnit report generation
+
+    An example of overriding the target for project execution could look like this:
+
+        <target name="run" depends="Mayam-impl.jar">
+            <exec dir="bin" executable="launcher.exe">
+                <arg file="${dist.jar}"/>
+            </exec>
+        </target>
+
+    Notice that the overridden target depends on the jar target and not only on 
+    the compile target as the regular run target does. Again, for a list of available 
+    properties which you can use, check the target you are overriding in the
+    nbproject/build-impl.xml file. 
+
+    -->
+</project>
diff --git a/debian/changelog b/debian/changelog
deleted file mode 100644
index cdec2da..0000000
--- a/debian/changelog
+++ /dev/null
@@ -1,5 +0,0 @@
-mayam (0.8-1) UNRELEASED; urgency=low
-
-  * Initial release (Closes: #???)
-
- -- Andreas Tille <tille at debian.org>  Thu, 17 Mar 2011 19:24:30 +0100
diff --git a/debian/compat b/debian/compat
deleted file mode 100644
index f599e28..0000000
--- a/debian/compat
+++ /dev/null
@@ -1 +0,0 @@
-10
diff --git a/debian/control b/debian/control
deleted file mode 100644
index 9a96ef5..0000000
--- a/debian/control
+++ /dev/null
@@ -1,44 +0,0 @@
-Source: mayam
-Maintainer: Debian Med Packaging Team <debian-med-packaging at lists.alioth.debian.org>
-Uploaders: Andreas Tille <tille at debian.org>
-Section: science
-Priority: optional
-Build-Depends: debhelper (>= 10),
-               javahelper,
-               ant,
-               openjdk-6-jdk,
-               libcommons-cli-java,
-               libgetopt-java,
-               liblog4j1.2-java,
-               libslf4j-java,
-               libswing-layout-java,
-               libvtk-java
-Standards-Version: 3.9.8
-Vcs-Browser: https://anonscm.debian.org/viewvc/debian-med/trunk/packages/mayam/trunk/
-Vcs-Svn: svn://anonscm.debian.org/debian-med/trunk/packages/mayam/trunk/
-Homepage: http://www.dcm4che.org/confluence/display/OV/MAYAM
-
-Package: mayam
-Architecture: all
-Depends: ${shlibs:Depends},
-         ${misc:Depends},
-         ${java:Depends}
-Description: Cross-platform DICOM Viewer
- A Cross-platform DICOM viewer using the dcm4che toolkit.
- .
- The current features are:
-  * DICOM Listener for Q/R
-  * DICOM Send
-  * Local DB for storing study information
-  * Importing DICOM studies from local disk
-  * Parsing DicomDir from local disk or CD
-  * Query compressed studies without decompressing them
-  * Multiple Studies viewer using Layout,Tab view
-  * Export to JPEG (Study, Series, Instance level). Windowing can be
-    applied to a single instance or series of instance while exporting
-  * Cine Loop & stack navigation
-  * Toggle for Text and Annotation Overlay
-  * Windowing Presets Settings (based on modality)
-  * Layout Settings (based on modality)
-  * AE Management
-  * DICOM Tags Viewer
diff --git a/debian/copyright b/debian/copyright
deleted file mode 100644
index 5481da3..0000000
--- a/debian/copyright
+++ /dev/null
@@ -1,15 +0,0 @@
-Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
-Upstream-Name: Mayam
-Upstream-Contact: Babu Hussain A
-Source: http://sourceforge.net/projects/dcm4che/files/Mayam/
-
-Files: *
-Copyright: © 2009-2011 Raster Images, Babu Hussain A, Guru Rajan R,
-                       Meer Asgar Hussain B, Prakash J,
-                       Sathishkumar V, Suresh V
-License: MPL 1.1/GPL 2.0/LGPL 2.1
-
-Files: debian/*
-Copyright: © 2011 Andreas Tille <tille at debian.org>
-License: LGPL 2.1
- The packaging work has the same license as choosen above
diff --git a/debian/rules b/debian/rules
deleted file mode 100755
index 4702e28..0000000
--- a/debian/rules
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/make -f
-# debian/rules for mayam
-# Andreas Tille <tille at debian.org>
-# GPL
-
-# Uncomment this to turn on verbose mode.
-#export DH_VERBOSE=1
-
-JAVA_HOME=/usr/lib/jvm/default-java
-
-%:
-	dh $@ --with javahelper
diff --git a/debian/source/format b/debian/source/format
deleted file mode 100644
index 163aaf8..0000000
--- a/debian/source/format
+++ /dev/null
@@ -1 +0,0 @@
-3.0 (quilt)
diff --git a/debian/watch b/debian/watch
deleted file mode 100644
index 3d217f1..0000000
--- a/debian/watch
+++ /dev/null
@@ -1,8 +0,0 @@
-# Attention:  Both watch files just obtain different binary
-#             archive downloads.  The source seems to be
-#             available only in SVN - so a get-orig-source
-#             script is needed
-
-version=3
-# http://sf.net/dcm4che/Mayam-(.*)-bin-Linux\.tar\.gz 
-http://sf.net/dcm4che/Mayam-(.*)-bin\.zip
diff --git a/lib/clibwrapper_jiio.jar b/lib/clibwrapper_jiio.jar
new file mode 100644
index 0000000..977b48e
Binary files /dev/null and b/lib/clibwrapper_jiio.jar differ
diff --git a/lib/dcm4che-core-2.0.22.jar b/lib/dcm4che-core-2.0.22.jar
new file mode 100644
index 0000000..ffd0647
Binary files /dev/null and b/lib/dcm4che-core-2.0.22.jar differ
diff --git a/lib/dcm4che-filecache-2.0.22.jar b/lib/dcm4che-filecache-2.0.22.jar
new file mode 100644
index 0000000..b340e3b
Binary files /dev/null and b/lib/dcm4che-filecache-2.0.22.jar differ
diff --git a/lib/dcm4che-imageio-rle-2.0.23.jar b/lib/dcm4che-imageio-rle-2.0.23.jar
new file mode 100644
index 0000000..d3c01b1
Binary files /dev/null and b/lib/dcm4che-imageio-rle-2.0.23.jar differ
diff --git a/lib/dcm4che-net-2.0.22.jar b/lib/dcm4che-net-2.0.22.jar
new file mode 100644
index 0000000..9582c98
Binary files /dev/null and b/lib/dcm4che-net-2.0.22.jar differ
diff --git a/lib/dcm4che.jar b/lib/dcm4che.jar
new file mode 100644
index 0000000..7676b95
Binary files /dev/null and b/lib/dcm4che.jar differ
diff --git a/lib/derby.jar b/lib/derby.jar
new file mode 100644
index 0000000..8be286f
Binary files /dev/null and b/lib/derby.jar differ
diff --git a/lib/jai_codec.jar b/lib/jai_codec.jar
new file mode 100644
index 0000000..7f59ad2
Binary files /dev/null and b/lib/jai_codec.jar differ
diff --git a/lib/jai_core.jar b/lib/jai_core.jar
new file mode 100644
index 0000000..69cd233
Binary files /dev/null and b/lib/jai_core.jar differ
diff --git a/lib/jai_imageio.jar b/lib/jai_imageio.jar
new file mode 100644
index 0000000..571aa19
Binary files /dev/null and b/lib/jai_imageio.jar differ
diff --git a/lib/libclib_jiio.so b/lib/libclib_jiio.so
new file mode 100644
index 0000000..d47f3cc
Binary files /dev/null and b/lib/libclib_jiio.so differ
diff --git a/lib/nimrodlf-1.0.jar b/lib/nimrodlf-1.0.jar
new file mode 100644
index 0000000..c953361
Binary files /dev/null and b/lib/nimrodlf-1.0.jar differ
diff --git a/lib/pdf-renderer-1.0.5.jar b/lib/pdf-renderer-1.0.5.jar
new file mode 100644
index 0000000..524b6a6
Binary files /dev/null and b/lib/pdf-renderer-1.0.5.jar differ
diff --git a/manifest.mf b/manifest.mf
new file mode 100644
index 0000000..328e8e5
--- /dev/null
+++ b/manifest.mf
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+X-COMMENT: Main-Class will be added automatically by build
+
diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml
new file mode 100644
index 0000000..b4ee5ca
--- /dev/null
+++ b/nbproject/build-impl.xml
@@ -0,0 +1,891 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+*** GENERATED FROM project.xml - DO NOT EDIT  ***
+***         EDIT ../build.xml INSTEAD         ***
+
+For the purpose of easier reading the script
+is divided into following sections:
+
+  - initialization
+  - compilation
+  - jar
+  - execution
+  - debugging
+  - javadoc
+  - junit compilation
+  - junit execution
+  - junit debugging
+  - applet
+  - cleanup
+
+        -->
+<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="Mayam-impl">
+    <fail message="Please build using Ant 1.7.1 or higher.">
+        <condition>
+            <not>
+                <antversion atleast="1.7.1"/>
+            </not>
+        </condition>
+    </fail>
+    <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
+    <!-- 
+                ======================
+                INITIALIZATION SECTION 
+                ======================
+            -->
+    <target name="-pre-init">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="-pre-init" name="-init-private">
+        <property file="nbproject/private/config.properties"/>
+        <property file="nbproject/private/configs/${config}.properties"/>
+        <property file="nbproject/private/private.properties"/>
+    </target>
+    <target depends="-pre-init,-init-private" name="-init-user">
+        <property file="${user.properties.file}"/>
+        <!-- The two properties below are usually overridden -->
+        <!-- by the active platform. Just a fallback. -->
+        <property name="default.javac.source" value="1.4"/>
+        <property name="default.javac.target" value="1.4"/>
+    </target>
+    <target depends="-pre-init,-init-private,-init-user" name="-init-project">
+        <property file="nbproject/configs/${config}.properties"/>
+        <property file="nbproject/project.properties"/>
+    </target>
+    <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
+        <available file="${manifest.file}" property="manifest.available"/>
+        <available file="${application.splash}" property="splashscreen.available"/>
+        <condition property="main.class.available">
+            <and>
+                <isset property="main.class"/>
+                <not>
+                    <equals arg1="${main.class}" arg2="" trim="true"/>
+                </not>
+            </and>
+        </condition>
+        <condition property="manifest.available+main.class">
+            <and>
+                <isset property="manifest.available"/>
+                <isset property="main.class.available"/>
+            </and>
+        </condition>
+        <condition property="do.mkdist">
+            <and>
+                <isset property="libs.CopyLibs.classpath"/>
+                <not>
+                    <istrue value="${mkdist.disabled}"/>
+                </not>
+            </and>
+        </condition>
+        <condition property="manifest.available+main.class+mkdist.available">
+            <and>
+                <istrue value="${manifest.available+main.class}"/>
+                <isset property="do.mkdist"/>
+            </and>
+        </condition>
+        <condition property="manifest.available+main.class+mkdist.available+splashscreen.available">
+            <and>
+                <istrue value="${manifest.available+main.class+mkdist.available}"/>
+                <istrue value="${splashscreen.available}"/>
+            </and>
+        </condition>
+        <condition property="do.archive">
+            <not>
+                <istrue value="${jar.archive.disabled}"/>
+            </not>
+        </condition>
+        <condition property="do.archive+manifest.available">
+            <and>
+                <isset property="manifest.available"/>
+                <istrue value="${do.archive}"/>
+            </and>
+        </condition>
+        <condition property="do.archive+manifest.available+main.class">
+            <and>
+                <istrue value="${manifest.available+main.class}"/>
+                <istrue value="${do.archive}"/>
+            </and>
+        </condition>
+        <condition property="do.archive+manifest.available+main.class+mkdist.available">
+            <and>
+                <istrue value="${manifest.available+main.class+mkdist.available}"/>
+                <istrue value="${do.archive}"/>
+            </and>
+        </condition>
+        <condition property="do.archive+manifest.available+main.class+mkdist.available+splashscreen.available">
+            <and>
+                <istrue value="${manifest.available+main.class+mkdist.available+splashscreen.available}"/>
+                <istrue value="${do.archive}"/>
+            </and>
+        </condition>
+        <condition property="have.tests">
+            <or>
+                <available file="${test.src.dir}"/>
+            </or>
+        </condition>
+        <condition property="have.sources">
+            <or>
+                <available file="${src.dir}"/>
+            </or>
+        </condition>
+        <condition property="netbeans.home+have.tests">
+            <and>
+                <isset property="netbeans.home"/>
+                <isset property="have.tests"/>
+            </and>
+        </condition>
+        <condition property="no.javadoc.preview">
+            <and>
+                <isset property="javadoc.preview"/>
+                <isfalse value="${javadoc.preview}"/>
+            </and>
+        </condition>
+        <property name="run.jvmargs" value=""/>
+        <property name="javac.compilerargs" value=""/>
+        <property name="work.dir" value="${basedir}"/>
+        <condition property="no.deps">
+            <and>
+                <istrue value="${no.dependencies}"/>
+            </and>
+        </condition>
+        <property name="javac.debug" value="true"/>
+        <property name="javadoc.preview" value="true"/>
+        <property name="application.args" value=""/>
+        <property name="source.encoding" value="${file.encoding}"/>
+        <property name="runtime.encoding" value="${source.encoding}"/>
+        <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
+            <and>
+                <isset property="javadoc.encoding"/>
+                <not>
+                    <equals arg1="${javadoc.encoding}" arg2=""/>
+                </not>
+            </and>
+        </condition>
+        <property name="javadoc.encoding.used" value="${source.encoding}"/>
+        <property name="includes" value="**"/>
+        <property name="excludes" value=""/>
+        <property name="do.depend" value="false"/>
+        <condition property="do.depend.true">
+            <istrue value="${do.depend}"/>
+        </condition>
+        <path id="endorsed.classpath.path" path="${endorsed.classpath}"/>
+        <condition else="" property="endorsed.classpath.cmd.line.arg" value="-Xbootclasspath/p:'${toString:endorsed.classpath.path}'">
+            <length length="0" string="${endorsed.classpath}" when="greater"/>
+        </condition>
+        <property name="javac.fork" value="false"/>
+        <property name="jar.index" value="false"/>
+        <available file="${meta.inf.dir}/persistence.xml" property="has.persistence.xml"/>
+    </target>
+    <target name="-post-init">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
+        <fail unless="src.dir">Must set src.dir</fail>
+        <fail unless="test.src.dir">Must set test.src.dir</fail>
+        <fail unless="build.dir">Must set build.dir</fail>
+        <fail unless="dist.dir">Must set dist.dir</fail>
+        <fail unless="build.classes.dir">Must set build.classes.dir</fail>
+        <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
+        <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
+        <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
+        <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
+        <fail unless="dist.jar">Must set dist.jar</fail>
+    </target>
+    <target name="-init-macrodef-property">
+        <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
+            <attribute name="name"/>
+            <attribute name="value"/>
+            <sequential>
+                <property name="@{name}" value="${@{value}}"/>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-ap-cmdline-properties" if="ap.supported.internal" name="-init-macrodef-javac-with-processors">
+        <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${src.dir}" name="srcdir"/>
+            <attribute default="${build.classes.dir}" name="destdir"/>
+            <attribute default="${javac.classpath}" name="classpath"/>
+            <attribute default="${javac.processorpath}" name="processorpath"/>
+            <attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/>
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="${javac.debug}" name="debug"/>
+            <attribute default="${empty.dir}" name="sourcepath"/>
+            <attribute default="${empty.dir}" name="gensrcdir"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <property location="${build.dir}/empty" name="empty.dir"/>
+                <mkdir dir="${empty.dir}"/>
+                <mkdir dir="@{apgeneratedsrcdir}"/>
+                <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">
+                    <src>
+                        <dirset dir="@{gensrcdir}" erroronmissingdir="false">
+                            <include name="*"/>
+                        </dirset>
+                    </src>
+                    <classpath>
+                        <path path="@{classpath}"/>
+                    </classpath>
+                    <compilerarg line="${endorsed.classpath.cmd.line.arg}"/>
+                    <compilerarg line="${javac.compilerargs}"/>
+                    <compilerarg value="-processorpath"/>
+                    <compilerarg path="@{processorpath}:${empty.dir}"/>
+                    <compilerarg line="${ap.processors.internal}"/>
+                    <compilerarg line="${annotation.processing.processor.options}"/>
+                    <compilerarg value="-s"/>
+                    <compilerarg path="@{apgeneratedsrcdir}"/>
+                    <compilerarg line="${ap.proc.none.internal}"/>
+                    <customize/>
+                </javac>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-ap-cmdline-properties" name="-init-macrodef-javac-without-processors" unless="ap.supported.internal">
+        <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${src.dir}" name="srcdir"/>
+            <attribute default="${build.classes.dir}" name="destdir"/>
+            <attribute default="${javac.classpath}" name="classpath"/>
+            <attribute default="${javac.processorpath}" name="processorpath"/>
+            <attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/>
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="${javac.debug}" name="debug"/>
+            <attribute default="${empty.dir}" name="sourcepath"/>
+            <attribute default="${empty.dir}" name="gensrcdir"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <property location="${build.dir}/empty" name="empty.dir"/>
+                <mkdir dir="${empty.dir}"/>
+                <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">
+                    <src>
+                        <dirset dir="@{gensrcdir}" erroronmissingdir="false">
+                            <include name="*"/>
+                        </dirset>
+                    </src>
+                    <classpath>
+                        <path path="@{classpath}"/>
+                    </classpath>
+                    <compilerarg line="${endorsed.classpath.cmd.line.arg}"/>
+                    <compilerarg line="${javac.compilerargs}"/>
+                    <customize/>
+                </javac>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-macrodef-javac-with-processors,-init-macrodef-javac-without-processors" name="-init-macrodef-javac">
+        <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${src.dir}" name="srcdir"/>
+            <attribute default="${build.classes.dir}" name="destdir"/>
+            <attribute default="${javac.classpath}" name="classpath"/>
+            <sequential>
+                <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
+                    <classpath>
+                        <path path="@{classpath}"/>
+                    </classpath>
+                </depend>
+            </sequential>
+        </macrodef>
+        <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${build.classes.dir}" name="destdir"/>
+            <sequential>
+                <fail unless="javac.includes">Must set javac.includes</fail>
+                <pathconvert pathsep="," property="javac.includes.binary">
+                    <path>
+                        <filelist dir="@{destdir}" files="${javac.includes}"/>
+                    </path>
+                    <globmapper from="*.java" to="*.class"/>
+                </pathconvert>
+                <delete>
+                    <files includes="${javac.includes.binary}"/>
+                </delete>
+            </sequential>
+        </macrodef>
+    </target>
+    <target name="-init-macrodef-junit">
+        <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <sequential>
+                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true" tempdir="${build.dir}">
+                    <batchtest todir="${build.test.results.dir}">
+                        <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
+                            <filename name="@{testincludes}"/>
+                        </fileset>
+                    </batchtest>
+                    <classpath>
+                        <path path="${run.test.classpath}"/>
+                    </classpath>
+                    <syspropertyset>
+                        <propertyref prefix="test-sys-prop."/>
+                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
+                    </syspropertyset>
+                    <formatter type="brief" usefile="false"/>
+                    <formatter type="xml"/>
+                    <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
+                    <jvmarg line="${run.jvmargs}"/>
+                </junit>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
+        <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
+            <attribute default="${main.class}" name="name"/>
+            <attribute default="${debug.classpath}" name="classpath"/>
+            <attribute default="" name="stopclassname"/>
+            <sequential>
+                <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
+                    <classpath>
+                        <path path="@{classpath}"/>
+                    </classpath>
+                </nbjpdastart>
+            </sequential>
+        </macrodef>
+        <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
+            <attribute default="${build.classes.dir}" name="dir"/>
+            <sequential>
+                <nbjpdareload>
+                    <fileset dir="@{dir}" includes="${fix.classes}">
+                        <include name="${fix.includes}*.class"/>
+                    </fileset>
+                </nbjpdareload>
+            </sequential>
+        </macrodef>
+    </target>
+    <target name="-init-debug-args">
+        <property name="version-output" value="java version "${ant.java.version}"/>
+        <condition property="have-jdk-older-than-1.4">
+            <or>
+                <contains string="${version-output}" substring="java version "1.0"/>
+                <contains string="${version-output}" substring="java version "1.1"/>
+                <contains string="${version-output}" substring="java version "1.2"/>
+                <contains string="${version-output}" substring="java version "1.3"/>
+            </or>
+        </condition>
+        <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
+            <istrue value="${have-jdk-older-than-1.4}"/>
+        </condition>
+        <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
+            <os family="windows"/>
+        </condition>
+        <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
+            <isset property="debug.transport"/>
+        </condition>
+    </target>
+    <target depends="-init-debug-args" name="-init-macrodef-debug">
+        <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${main.class}" name="classname"/>
+            <attribute default="${debug.classpath}" name="classpath"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <java classname="@{classname}" dir="${work.dir}" fork="true">
+                    <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
+                    <jvmarg line="${debug-args-line}"/>
+                    <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
+                    <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
+                    <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
+                    <jvmarg line="${run.jvmargs}"/>
+                    <classpath>
+                        <path path="@{classpath}"/>
+                    </classpath>
+                    <syspropertyset>
+                        <propertyref prefix="run-sys-prop."/>
+                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
+                    </syspropertyset>
+                    <customize/>
+                </java>
+            </sequential>
+        </macrodef>
+    </target>
+    <target name="-init-macrodef-java">
+        <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
+            <attribute default="${main.class}" name="classname"/>
+            <attribute default="${run.classpath}" name="classpath"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <java classname="@{classname}" dir="${work.dir}" fork="true">
+                    <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
+                    <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
+                    <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
+                    <jvmarg line="${run.jvmargs}"/>
+                    <classpath>
+                        <path path="@{classpath}"/>
+                    </classpath>
+                    <syspropertyset>
+                        <propertyref prefix="run-sys-prop."/>
+                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
+                    </syspropertyset>
+                    <customize/>
+                </java>
+            </sequential>
+        </macrodef>
+    </target>
+    <target name="-init-macrodef-copylibs">
+        <macrodef name="copylibs" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <element name="customize" optional="true"/>
+            <sequential>
+                <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
+                <pathconvert property="run.classpath.without.build.classes.dir">
+                    <path path="${run.classpath}"/>
+                    <map from="${build.classes.dir.resolved}" to=""/>
+                </pathconvert>
+                <pathconvert pathsep=" " property="jar.classpath">
+                    <path path="${run.classpath.without.build.classes.dir}"/>
+                    <chainedmapper>
+                        <flattenmapper/>
+                        <globmapper from="*" to="lib/*"/>
+                    </chainedmapper>
+                </pathconvert>
+                <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
+                <copylibs compress="${jar.compress}" index="${jar.index}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
+                    <fileset dir="${build.classes.dir}"/>
+                    <manifest>
+                        <attribute name="Class-Path" value="${jar.classpath}"/>
+                        <customize/>
+                    </manifest>
+                </copylibs>
+            </sequential>
+        </macrodef>
+    </target>
+    <target name="-init-presetdef-jar">
+        <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
+            <jar compress="${jar.compress}" index="${jar.index}" jarfile="${dist.jar}">
+                <j2seproject1:fileset dir="${build.classes.dir}"/>
+            </jar>
+        </presetdef>
+    </target>
+    <target name="-init-ap-cmdline-properties">
+        <property name="annotation.processing.enabled" value="true"/>
+        <property name="annotation.processing.processors.list" value=""/>
+        <property name="annotation.processing.processor.options" value=""/>
+        <property name="annotation.processing.run.all.processors" value="true"/>
+        <property name="javac.processorpath" value="${javac.classpath}"/>
+        <property name="javac.test.processorpath" value="${javac.test.classpath}"/>
+        <condition property="ap.supported.internal" value="true">
+            <not>
+                <matches pattern="1\.[0-5](\..*)?" string="${javac.source}"/>
+            </not>
+        </condition>
+    </target>
+    <target depends="-init-ap-cmdline-properties" if="ap.supported.internal" name="-init-ap-cmdline-supported">
+        <condition else="" property="ap.processors.internal" value="-processor ${annotation.processing.processors.list}">
+            <isfalse value="${annotation.processing.run.all.processors}"/>
+        </condition>
+        <condition else="" property="ap.proc.none.internal" value="-proc:none">
+            <isfalse value="${annotation.processing.enabled}"/>
+        </condition>
+    </target>
+    <target depends="-init-ap-cmdline-properties,-init-ap-cmdline-supported" name="-init-ap-cmdline">
+        <property name="ap.cmd.line.internal" value=""/>
+    </target>
+    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar,-init-ap-cmdline" name="init"/>
+    <!--
+                ===================
+                COMPILATION SECTION
+                ===================
+            -->
+    <target name="-deps-jar-init" unless="built-jar.properties">
+        <property location="${build.dir}/built-jar.properties" name="built-jar.properties"/>
+        <delete file="${built-jar.properties}" quiet="true"/>
+    </target>
+    <target if="already.built.jar.${basedir}" name="-warn-already-built-jar">
+        <echo level="warn" message="Cycle detected: Mayam was already built"/>
+    </target>
+    <target depends="init,-deps-jar-init" name="deps-jar" unless="no.deps">
+        <mkdir dir="${build.dir}"/>
+        <touch file="${built-jar.properties}" verbose="false"/>
+        <property file="${built-jar.properties}" prefix="already.built.jar."/>
+        <antcall target="-warn-already-built-jar"/>
+        <propertyfile file="${built-jar.properties}">
+            <entry key="${basedir}" value=""/>
+        </propertyfile>
+    </target>
+    <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
+    <target depends="init" name="-check-automatic-build">
+        <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
+    </target>
+    <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
+        <antcall target="clean"/>
+    </target>
+    <target depends="init,deps-jar" name="-pre-pre-compile">
+        <mkdir dir="${build.classes.dir}"/>
+    </target>
+    <target name="-pre-compile">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target if="do.depend.true" name="-compile-depend">
+        <pathconvert property="build.generated.subdirs">
+            <dirset dir="${build.generated.sources.dir}" erroronmissingdir="false">
+                <include name="*"/>
+            </dirset>
+        </pathconvert>
+        <j2seproject3:depend srcdir="${src.dir}:${build.generated.subdirs}"/>
+    </target>
+    <target depends="init,deps-jar,-pre-pre-compile,-pre-compile, -copy-persistence-xml,-compile-depend" if="have.sources" name="-do-compile">
+        <j2seproject3:javac gensrcdir="${build.generated.sources.dir}"/>
+        <copy todir="${build.classes.dir}">
+            <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
+        </copy>
+    </target>
+    <target if="has.persistence.xml" name="-copy-persistence-xml">
+        <mkdir dir="${build.classes.dir}/META-INF"/>
+        <copy todir="${build.classes.dir}/META-INF">
+            <fileset dir="${meta.inf.dir}" includes="persistence.xml"/>
+        </copy>
+    </target>
+    <target name="-post-compile">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
+    <target name="-pre-compile-single">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
+        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
+        <j2seproject3:force-recompile/>
+        <j2seproject3:javac excludes="" gensrcdir="${build.generated.sources.dir}" includes="${javac.includes}" sourcepath="${src.dir}"/>
+    </target>
+    <target name="-post-compile-single">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
+    <!--
+                ====================
+                JAR BUILDING SECTION
+                ====================
+            -->
+    <target depends="init" name="-pre-pre-jar">
+        <dirname file="${dist.jar}" property="dist.jar.dir"/>
+        <mkdir dir="${dist.jar.dir}"/>
+    </target>
+    <target name="-pre-jar">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.archive" name="-do-jar-without-manifest" unless="manifest.available">
+        <j2seproject1:jar/>
+    </target>
+    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.archive+manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class">
+        <j2seproject1:jar manifest="${manifest.file}"/>
+    </target>
+    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.archive+manifest.available+main.class" name="-do-jar-with-mainclass" unless="manifest.available+main.class+mkdist.available">
+        <j2seproject1:jar manifest="${manifest.file}">
+            <j2seproject1:manifest>
+                <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
+            </j2seproject1:manifest>
+        </j2seproject1:jar>
+        <echo>To run this application from the command line without Ant, try:</echo>
+        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
+        <property location="${dist.jar}" name="dist.jar.resolved"/>
+        <pathconvert property="run.classpath.with.dist.jar">
+            <path path="${run.classpath}"/>
+            <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
+        </pathconvert>
+        <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
+    </target>
+    <target depends="init,compile,-pre-pre-jar,-pre-jar,-init-macrodef-copylibs" if="do.archive+manifest.available+main.class+mkdist.available+splashscreen.available" name="-do-jar-with-libraries-and-splashscreen">
+        <basename file="${application.splash}" property="splashscreen.basename"/>
+        <mkdir dir="${build.classes.dir}/META-INF"/>
+        <copy failonerror="false" file="${application.splash}" todir="${build.classes.dir}/META-INF"/>
+        <j2seproject3:copylibs>
+            <customize>
+                <attribute name="Main-Class" value="${main.class}"/>
+                <attribute name="SplashScreen-Image" value="META-INF/${splashscreen.basename}"/>
+            </customize>
+        </j2seproject3:copylibs>
+        <echo>To run this application from the command line without Ant, try:</echo>
+        <property location="${dist.jar}" name="dist.jar.resolved"/>
+        <echo>java -jar "${dist.jar.resolved}"</echo>
+    </target>
+    <target depends="init,compile,-pre-pre-jar,-pre-jar,-init-macrodef-copylibs" if="do.archive+manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries" unless="splashscreen.available">
+        <j2seproject3:copylibs>
+            <customize>
+                <attribute name="Main-Class" value="${main.class}"/>
+            </customize>
+        </j2seproject3:copylibs>
+        <echo>To run this application from the command line without Ant, try:</echo>
+        <property location="${dist.jar}" name="dist.jar.resolved"/>
+        <echo>java -jar "${dist.jar.resolved}"</echo>
+    </target>
+    <target name="-post-jar">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries-and-splashscreen,-do-jar-with-libraries,-post-jar" description="Build JAR." name="jar"/>
+    <!--
+                =================
+                EXECUTION SECTION
+                =================
+            -->
+    <target depends="init,compile" description="Run a main class." name="run">
+        <j2seproject1:java>
+            <customize>
+                <arg line="${application.args}"/>
+            </customize>
+        </j2seproject1:java>
+    </target>
+    <target name="-do-not-recompile">
+        <property name="javac.includes.binary" value=""/>
+    </target>
+    <target depends="init,compile-single" name="run-single">
+        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
+        <j2seproject1:java classname="${run.class}"/>
+    </target>
+    <target depends="init,compile-test-single" name="run-test-with-main">
+        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
+        <j2seproject1:java classname="${run.class}" classpath="${run.test.classpath}"/>
+    </target>
+    <!--
+                =================
+                DEBUGGING SECTION
+                =================
+            -->
+    <target depends="init" if="netbeans.home" name="-debug-start-debugger">
+        <j2seproject1:nbjpdastart name="${debug.class}"/>
+    </target>
+    <target depends="init" if="netbeans.home" name="-debug-start-debugger-main-test">
+        <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${debug.class}"/>
+    </target>
+    <target depends="init,compile" name="-debug-start-debuggee">
+        <j2seproject3:debug>
+            <customize>
+                <arg line="${application.args}"/>
+            </customize>
+        </j2seproject3:debug>
+    </target>
+    <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
+    <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
+        <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
+    </target>
+    <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
+    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
+        <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
+        <j2seproject3:debug classname="${debug.class}"/>
+    </target>
+    <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
+    <target depends="init,compile-test-single" if="netbeans.home" name="-debug-start-debuggee-main-test">
+        <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
+        <j2seproject3:debug classname="${debug.class}" classpath="${debug.test.classpath}"/>
+    </target>
+    <target depends="init,compile-test-single,-debug-start-debugger-main-test,-debug-start-debuggee-main-test" if="netbeans.home" name="debug-test-with-main"/>
+    <target depends="init" name="-pre-debug-fix">
+        <fail unless="fix.includes">Must set fix.includes</fail>
+        <property name="javac.includes" value="${fix.includes}.java"/>
+    </target>
+    <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
+        <j2seproject1:nbjpdareload/>
+    </target>
+    <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
+    <!--
+                ===============
+                JAVADOC SECTION
+                ===============
+            -->
+    <target depends="init" if="have.sources" name="-javadoc-build">
+        <mkdir dir="${dist.javadoc.dir}"/>
+        <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
+            <classpath>
+                <path path="${javac.classpath}"/>
+            </classpath>
+            <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
+                <filename name="**/*.java"/>
+            </fileset>
+            <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
+                <include name="**/*.java"/>
+            </fileset>
+        </javadoc>
+        <copy todir="${dist.javadoc.dir}">
+            <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
+                <filename name="**/doc-files/**"/>
+            </fileset>
+            <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
+                <include name="**/doc-files/**"/>
+            </fileset>
+        </copy>
+    </target>
+    <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
+        <nbbrowse file="${dist.javadoc.dir}/index.html"/>
+    </target>
+    <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
+    <!--
+                =========================
+                JUNIT COMPILATION SECTION
+                =========================
+            -->
+    <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
+        <mkdir dir="${build.test.classes.dir}"/>
+    </target>
+    <target name="-pre-compile-test">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target if="do.depend.true" name="-compile-test-depend">
+        <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
+    </target>
+    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
+        <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" processorpath="${javac.test.processorpath}" srcdir="${test.src.dir}"/>
+        <copy todir="${build.test.classes.dir}">
+            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
+        </copy>
+    </target>
+    <target name="-post-compile-test">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
+    <target name="-pre-compile-test-single">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
+        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
+        <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
+        <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" processorpath="${javac.test.processorpath}" sourcepath="${test.src.dir}" srcdir="${test.src.dir}"/>
+        <copy todir="${build.test.classes.dir}">
+            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
+        </copy>
+    </target>
+    <target name="-post-compile-test-single">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
+    <!--
+                =======================
+                JUNIT EXECUTION SECTION
+                =======================
+            -->
+    <target depends="init" if="have.tests" name="-pre-test-run">
+        <mkdir dir="${build.test.results.dir}"/>
+    </target>
+    <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
+        <j2seproject3:junit testincludes="**/*Test.java"/>
+    </target>
+    <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
+        <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
+    </target>
+    <target depends="init" if="have.tests" name="test-report"/>
+    <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
+    <target depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests." name="test"/>
+    <target depends="init" if="have.tests" name="-pre-test-run-single">
+        <mkdir dir="${build.test.results.dir}"/>
+    </target>
+    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
+        <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
+        <j2seproject3:junit excludes="" includes="${test.includes}"/>
+    </target>
+    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
+        <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
+    </target>
+    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>
+    <!--
+                =======================
+                JUNIT DEBUGGING SECTION
+                =======================
+            -->
+    <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
+        <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
+        <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
+        <delete file="${test.report.file}"/>
+        <mkdir dir="${build.test.results.dir}"/>
+        <j2seproject3:debug classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" classpath="${ant.home}/lib/ant.jar:${ant.home}/lib/ant-junit.jar:${debug.test.classpath}">
+            <customize>
+                <syspropertyset>
+                    <propertyref prefix="test-sys-prop."/>
+                    <mapper from="test-sys-prop.*" to="*" type="glob"/>
+                </syspropertyset>
+                <arg value="${test.class}"/>
+                <arg value="showoutput=true"/>
+                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
+                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
+            </customize>
+        </j2seproject3:debug>
+    </target>
+    <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
+        <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
+    </target>
+    <target depends="init,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
+    <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
+        <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
+    </target>
+    <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
+    <!--
+                =========================
+                APPLET EXECUTION SECTION
+                =========================
+            -->
+    <target depends="init,compile-single" name="run-applet">
+        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
+        <j2seproject1:java classname="sun.applet.AppletViewer">
+            <customize>
+                <arg value="${applet.url}"/>
+            </customize>
+        </j2seproject1:java>
+    </target>
+    <!--
+                =========================
+                APPLET DEBUGGING  SECTION
+                =========================
+            -->
+    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
+        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
+        <j2seproject3:debug classname="sun.applet.AppletViewer">
+            <customize>
+                <arg value="${applet.url}"/>
+            </customize>
+        </j2seproject3:debug>
+    </target>
+    <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
+    <!--
+                ===============
+                CLEANUP SECTION
+                ===============
+            -->
+    <target name="-deps-clean-init" unless="built-clean.properties">
+        <property location="${build.dir}/built-clean.properties" name="built-clean.properties"/>
+        <delete file="${built-clean.properties}" quiet="true"/>
+    </target>
+    <target if="already.built.clean.${basedir}" name="-warn-already-built-clean">
+        <echo level="warn" message="Cycle detected: Mayam was already built"/>
+    </target>
+    <target depends="init,-deps-clean-init" name="deps-clean" unless="no.deps">
+        <mkdir dir="${build.dir}"/>
+        <touch file="${built-clean.properties}" verbose="false"/>
+        <property file="${built-clean.properties}" prefix="already.built.clean."/>
+        <antcall target="-warn-already-built-clean"/>
+        <propertyfile file="${built-clean.properties}">
+            <entry key="${basedir}" value=""/>
+        </propertyfile>
+    </target>
+    <target depends="init" name="-do-clean">
+        <delete dir="${build.dir}"/>
+        <delete dir="${dist.dir}" followsymlinks="false" includeemptydirs="true"/>
+    </target>
+    <target name="-post-clean">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
+    <target name="-check-call-dep">
+        <property file="${call.built.properties}" prefix="already.built."/>
+        <condition property="should.call.dep">
+            <not>
+                <isset property="already.built.${call.subproject}"/>
+            </not>
+        </condition>
+    </target>
+    <target depends="-check-call-dep" if="should.call.dep" name="-maybe-call-dep">
+        <ant antfile="${call.script}" inheritall="false" target="${call.target}">
+            <propertyset>
+                <propertyref prefix="transfer."/>
+                <mapper from="transfer.*" to="*" type="glob"/>
+            </propertyset>
+        </ant>
+    </target>
+</project>
diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties
new file mode 100644
index 0000000..a260542
--- /dev/null
+++ b/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=b06abccd
+build.xml.script.CRC32=7de8e21b
+build.xml.stylesheet.CRC32=28e38971 at 1.38.2.45
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=b06abccd
+nbproject/build-impl.xml.script.CRC32=37c664ba
+nbproject/build-impl.xml.stylesheet.CRC32=f33e10ff at 1.38.2.45
diff --git a/nbproject/private/config.properties b/nbproject/private/config.properties
new file mode 100644
index 0000000..e69de29
diff --git a/nbproject/private/private.properties b/nbproject/private/private.properties
new file mode 100644
index 0000000..1c55d62
--- /dev/null
+++ b/nbproject/private/private.properties
@@ -0,0 +1,7 @@
+compile.on.save=true
+do.depend=false
+do.jar=true
+javac.debug=true
+javadoc.preview=true
+jaxbwiz.endorsed.dirs=/Applications/NetBeans/NetBeans 6.8.app/Contents/Resources/NetBeans/ide12/modules/ext/jaxb/api
+user.properties.file=/Users/babu/.netbeans/6.9/build.properties
diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml
new file mode 100644
index 0000000..c1f155a
--- /dev/null
+++ b/nbproject/private/private.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
+    <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
+</project-private>
diff --git a/nbproject/project.properties b/nbproject/project.properties
new file mode 100644
index 0000000..0d36aaf
--- /dev/null
+++ b/nbproject/project.properties
@@ -0,0 +1,104 @@
+application.title=Mayam
+application.vendor=babu
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+# Uncomment to specify the preferred debugger connection transport:
+#debug.transport=dt_socket
+debug.classpath=\
+    ${run.classpath}
+debug.test.classpath=\
+    ${run.test.classpath}
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/Mayam.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+endorsed.classpath=
+excludes=
+file.reference.clibwrapper_jiio.jar=lib/clibwrapper_jiio.jar
+file.reference.commons-cli-1.0.jar=lib/commons-cli-1.0.jar
+file.reference.dcm4che-core-2.0.22.jar=lib/dcm4che-core-2.0.22.jar
+file.reference.dcm4che-filecache-2.0.22.jar=lib/dcm4che-filecache-2.0.22.jar
+file.reference.dcm4che-imageio-rle-2.0.23.jar=lib/dcm4che-imageio-rle-2.0.23.jar
+file.reference.dcm4che-net-2.0.22.jar=lib/dcm4che-net-2.0.22.jar
+file.reference.dcm4che.jar=lib/dcm4che.jar
+file.reference.derby.jar=lib/derby.jar
+file.reference.getopt.jar=lib/getopt.jar
+file.reference.jai_codec.jar=lib/jai_codec.jar
+file.reference.jai_core.jar=lib/jai_core.jar
+file.reference.jai_imageio.jar=lib/jai_imageio.jar
+file.reference.log4j-1.2.13.jar=lib/log4j-1.2.13.jar
+file.reference.nimrodlf-1.0.jar=lib/nimrodlf-1.0.jar
+file.reference.pdf-renderer-1.0.5.jar=lib/pdf-renderer-1.0.5.jar
+file.reference.slf4j-api-1.4.3.jar=lib/slf4j-api-1.4.3.jar
+file.reference.slf4j-log4j12-1.4.3.jar=lib/slf4j-log4j12-1.4.3.jar
+file.reference.swing-layout-1.0.3.jar=lib/swing-layout-1.0.3.jar
+file.reference.vtk-5.6.1.jar=lib/vtk-5.6.1.jar
+includes=**
+jar.compress=false
+javac.classpath=\
+    ${file.reference.clibwrapper_jiio.jar}:\
+    ${file.reference.commons-cli-1.0.jar}:\
+    ${file.reference.dcm4che.jar}:\
+    ${file.reference.getopt.jar}:\
+    ${file.reference.jai_codec.jar}:\
+    ${file.reference.jai_core.jar}:\
+    ${file.reference.jai_imageio.jar}:\
+    ${file.reference.log4j-1.2.13.jar}:\
+    ${file.reference.slf4j-api-1.4.3.jar}:\
+    ${file.reference.slf4j-log4j12-1.4.3.jar}:\
+    ${file.reference.swing-layout-1.0.3.jar}:\
+    ${file.reference.dcm4che-filecache-2.0.22.jar}:\
+    ${file.reference.dcm4che-net-2.0.22.jar}:\
+    ${file.reference.dcm4che-core-2.0.22.jar}:\
+    ${file.reference.derby.jar}:\
+    ${file.reference.nimrodlf-1.0.jar}:\
+    ${file.reference.dcm4che-imageio-rle-2.0.23.jar}:\
+    ${file.reference.vtk-5.6.1.jar}:\
+    ${file.reference.pdf-renderer-1.0.5.jar}
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.source=1.5
+javac.target=1.5
+javac.test.classpath=\
+    ${javac.classpath}:\
+    ${build.classes.dir}:\
+    ${libs.junit.classpath}:\
+    ${libs.junit_4.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+jaxbwiz.endorsed.dirs="${netbeans.home}/../ide12/modules/ext/jaxb/api"
+main.class=in.raster.mayam.facade.ApplicationFacade
+manifest.file=manifest.mf
+meta.inf.dir=${src.dir}/META-INF
+platform.active=default_platform
+run.classpath=\
+    ${javac.classpath}:\
+    ${build.classes.dir}
+# Space-separated list of JVM arguments used when running the project
+# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
+# or test-sys-prop.name=value to set system properties for unit tests):
+run.jvmargs=-Xms128m -Xmx1g
+run.test.classpath=\
+    ${javac.test.classpath}:\
+    ${build.test.classes.dir}
+source.encoding=UTF-8
+src.dir=src
+test.src.dir=test
diff --git a/nbproject/project.xml b/nbproject/project.xml
new file mode 100644
index 0000000..d5ab2d4
--- /dev/null
+++ b/nbproject/project.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://www.netbeans.org/ns/project/1">
+    <type>org.netbeans.modules.java.j2seproject</type>
+    <configuration>
+        <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
+            <name>Mayam</name>
+            <source-roots>
+                <root id="src.dir"/>
+            </source-roots>
+            <test-roots>
+                <root id="test.src.dir"/>
+            </test-roots>
+        </data>
+    </configuration>
+</project>
diff --git a/src/DcmRcv.properties b/src/DcmRcv.properties
new file mode 100644
index 0000000..b989adc
--- /dev/null
+++ b/src/DcmRcv.properties
@@ -0,0 +1,61 @@
+usage=Usage\: java -jar dcmrcv.jar [OPTION]... PORT\
+\nStart DICOM Server listening on PORT\
+\nOptions (override presets defined in resource dcmrcv.cfg)\:\
+\n--max-clients=NUM      maximum number of simultaneous clients [default=10].\
+\n--rq-timeout=MSEC      time-out waiting for A-ASSOCIATE-RQ after TCP connect,\
+\n                       0 is interpreted as an infinite timeout [default=5000].\
+\n--dimse-timeout=MSEC   time-out waiting for DIMSE on open association,\
+\n                       0 is interpreted as an infinite timeout [default=0].\
+\n--so-close-delay=MSEC  time delay for socket close after sending A-RELEASE-RP\
+\n                       or A-ABORT [default=500].\
+\n--called-aets=AET1,..  only association requests with matching called and\
+\n--calling-aets=AET1,.. calling AET will be accepted. [default: <any>]\
+\n--max-pdu-len=LEN      set maximal length of receiving PDUs [default=16352].\
+\n--max-op-invoked=NUM   set maximal number of invoked operations with\
+\n                       outstanding response.\
+\n--pack-pdvs            activates packing of command PDV + (first) data PDV\
+\n                       into one P-DATA-TF PDU\
+\n--rsp-delay=SEC        define additional delay of response\
+\n                       (useful for testing async mode).\
+\n--abort                send A-ABORT instead C-STORE-RSP (useful for testing\
+\n                       STORE SCU behavior in case of STORE SCP failure)\
+\n--rsp-status=STATUS    define status code in C-STORE-RSP in decimal (#####) or\
+\n                       hex (####H) [default=0]. Useful for testing modality\
+\n                       behavior in case of status!=0.\
+\n--dest=DEST            define storage destination for received objects,\
+\n                       if DEST specifies a DICOMDIR file path (=last\
+\n                       component = \"DICOMDIR\"), the received objects will\
+\n                       be stored as DICOM File-set, further specified by\
+\n--fs-id=NAME           the File-set Identifier [default=<none>],\
+\n--fs-uid=UID           the File-set SOP Instance UID [default=<auto>],\
+\n--fs-file-id=TAG_PATH  specifies schema for generated file IDs [default=\
+\n                       StudyDate,StudyID,SeriesNumber,InstanceNumber],\
+\n--fs-lazy-update       defer update of DICOMDIR at association release,\
+\n                       instead immedately at each object receipt.\
+\n--set=TAG:VAL          Replace value of specified attribute with\
+\n                       specified value in received object\
+\n                       (e.g.: --set=PatientName:anonymous).\
+\n--buf-len=LEN          set length byte buffer, used to store data to file\
+\n--dicom-tls            accept TLS connection (offer AES and DES encryption)\
+\n--dicom-tls.aes        accept TLS connection (force AES or DES encryption)\
+\n--dicom-tls.3des       accept TLS connection (force DES encryption)\
+\n--dicom-tls.nodes      accept TLS connection (no encryption)\
+\n--tls-key=KEYSTORE     get key from specified resource [default:identity.p12]\
+\n--tls-key-passwd=PASS  password for keystore and key specified by --tls-key\
+\n                       [default: secret]\
+\n--tls-cacerts=KEYSTORE read trusted CA Certificats from specified resource\
+\n                       [default:cacerts.jks]\
+\n--tls-cacerts-passwd=PASS  password for keystore specified by --tls-cacerts\
+\n                       [default: secret]\
+\n--help     display this help and exit\
+\n--version  output version information and exit\n
+version=dcmrcv version @VERSION@ compiled on @TODAY@
+missing=missing port argument
+many=too many arguments
+mkdir=create new directory {0}
+failmkdir=failed to create directory {0}
+errnum={0} - not a number
+errdir={0} is not a valid directory
+try=Try 'java -jar dcmrcv.jar --help' for more information.
+cfg=Configuration\:
+
diff --git a/src/MoveScu.properties b/src/MoveScu.properties
new file mode 100644
index 0000000..37db8ca
--- /dev/null
+++ b/src/MoveScu.properties
@@ -0,0 +1,10 @@
+usage=Usage\: java -jar movescu.jar [OPTIONS]... URL [MOVEPARAMS]\nInvoke DICOM Move Request on remote DICOM node specified by URL. If no\nMOVEPARAMS are specified the connection to the remote node will only be\nverified by DICOM Echo.\n\nURL\: PROTOCOL\://CALLED[\:CALLING]@HOST[\:PORT]\n  PROTOCOL   Specifies protocol. Possible values:\n    dicom            DICOM default (without TLS)\n    dicom-tls        DICOM on TLS (offer AES and DES encryption)\n    dicom-tls.aes    DICOM on TLS (f [...]
+version=movescu version @VERSION@ compiled on @TODAY@
+missing=missing DICOM URL
+errnum={0} - not a number
+errurl={0} - invalid DICOM URL
+erruids=list of uids not allowed for keys above retrieve level
+noPCEcho=Verification Service not supported by remote DICOM node
+noPCMove=No appropriate Move Service negotiated with remote DICOM node
+try=Try 'java -jar movescu.jar --help' for more information.
+
diff --git a/src/NimRODThemeFile.theme b/src/NimRODThemeFile.theme
new file mode 100644
index 0000000..e7fb8e4
--- /dev/null
+++ b/src/NimRODThemeFile.theme
@@ -0,0 +1,10 @@
+nimrodlf.p1=#000000
+nimrodlf.p2=#000000
+nimrodlf.p3=#000000
+nimrodlf.s1=#1F1F1F
+nimrodlf.s2=#292929
+nimrodlf.s3=#333333
+nimrodlf.w=#333333
+nimrodlf.b=#FF8A00
+nimrodlf.menuOpacity=73
+nimrodlf.frameOpacity=180
diff --git a/src/TranscoderMain.properties b/src/TranscoderMain.properties
new file mode 100644
index 0000000..6f511a2
--- /dev/null
+++ b/src/TranscoderMain.properties
@@ -0,0 +1,21 @@
+usage=\r\nUsage: java -jar imgcodec.jar [OPTION] SOURCE DEST\
+\r\n  or:  java -jar imgcodec.jar [OPTION] SOURCE... DIRECTORY\
+\r\n\r\nTranscode SOURCE according OPTION to DEST,\
+\r\nor multiple SOURCE[s] to DIRECTORY\
+\r\n\r\nOPTION:\
+\r\n --jpll           use JPEG (ISO 10918-1) lossless\
+\r\n --jply[=quality] use JPEG baseline on 8-bit and JPEG extended mode on\
+\r\n                  up to 12-bit images with specified compression quality\
+\r\n                  [0..100], default: 75\
+\r\n --jlsl           use JPEG LS (ISO 14495-1)\
+\r\n --j2kr           use JPEG 2000 reversible mode\
+\r\n --j2ki[=rate]    use JPEG 2000 irreversible mode with specified\
+\r\n                  encoding rate (default: 1.0)\
+\r\n -v --version     display version and exit\
+\r\n -h --help        display this help and exit
+version=dcm2dcm v{0}
+ignoreQuality=warning: ignore invalid compression quality '{0}'
+ignoreRate=warning: ignore invalid encoding rate '{0}'
+missingArgs=missing file arguments
+missingDest=missing destination file
+needDir=transcoding multiple file, but last argument '{0}' is not a directory
\ No newline at end of file
diff --git a/src/de/iftm/dcm4che/services/CDimseService.java b/src/de/iftm/dcm4che/services/CDimseService.java
new file mode 100644
index 0000000..9f311ee
--- /dev/null
+++ b/src/de/iftm/dcm4che/services/CDimseService.java
@@ -0,0 +1,1139 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is part of dcm4che, an implementation of DICOM(TM) in
+ * Java(TM), hosted at http://sourceforge.net/projects/dcm4che.
+ *
+ * The Initial Developer of the Original Code is
+ * TIANI Medgraph AG.
+ * Portions created by the Initial Developer are Copyright (C) 2002-2005
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Gunter Zeilinger <gunter.zeilinger at tiani.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package de.iftm.dcm4che.services;
+
+//import java.io.File;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.net.Socket;
+import java.net.URL;
+import java.net.ConnectException;
+import java.security.GeneralSecurityException;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Vector;
+import java.text.ParseException;
+
+import org.dcm4che.data.Command;
+import org.dcm4che.data.Dataset;
+//import org.dcm4che.data.DcmDecodeParam;
+//import org.dcm4che.data.DcmElement;
+//import org.dcm4che.data.DcmEncodeParam;
+import org.dcm4che.data.DcmObjectFactory;
+//import org.dcm4che.data.DcmParseException;
+//import org.dcm4che.data.DcmParser;
+import org.dcm4che.data.DcmParserFactory;
+//import org.dcm4che.data.FileFormat;
+import org.dcm4che.dict.DictionaryFactory;
+import org.dcm4che.dict.Tags;
+import org.dcm4che.dict.UIDDictionary;
+import org.dcm4che.dict.UIDs;
+//import org.dcm4che.dict.VRs;
+import org.dcm4che.net.AAssociateAC;
+import org.dcm4che.net.AAssociateRQ;
+import org.dcm4che.net.ActiveAssociation;
+import org.dcm4che.net.Association;
+import org.dcm4che.net.AssociationFactory;
+import org.dcm4che.net.Dimse;
+//import org.dcm4che.net.DataSource;
+import org.dcm4che.net.FutureRSP;
+import org.dcm4che.net.PDU;
+import org.dcm4che.net.PresContext;
+//import org.dcm4che.server.PollDirSrv;
+//import org.dcm4che.server.PollDirSrvFactory;
+import org.dcm4che.util.DcmURL;
+import org.dcm4che.util.SSLContextAdapter;
+
+import org.apache.log4j.Logger;
+
+
+/**
+ * Implementation of C-DIMSE services.
+ * <p>
+ * <p> Usage:
+ * <p> 1. Create a new instance of this class.
+ * <p> 2. Use the aASSOCIATE method to establish an association.
+ * <p> 3. Use the cFIND method to query  the archive.
+ * <p> 4. Use the cMOVE method to move an object from the archive to a destination server.
+ * <p> 5. Use the cSTORE to store an object into an archive.
+ * <p> 6. Use the cECHO to verfy a association.
+ * <p> 7. If you are ready with the C-DIMSE services use the aRELEASE method to close the association.
+ * <p>
+ * <p>The query/retrieve levels used by C-FIND and C-MOVE are defined as enummerated constants.
+ * Use the method getQueryRetrieveLevel to convert these values to the String representation
+ * used in the DICOM element QueryRetrieveLevel (0008,0052).
+ * <p>
+ * <p>Based on dcm4che 1.4.0 sample: MoveStudy.java revision date 2005-10-05
+ * <p>Based on dcm4che 1.4.0 sample: DcmSnd.java revision date 2005-10-05
+ * <p>
+ * <p>See: PS 3.4 - Annex B STORAGE SERVICE CLASS
+ * <p>See: PS 3.4 - Annex C QUERY/RETRIEVE SERVICE CLASS
+ * <p>See: PS 3.4 - C.6 SOP CLASS DEFINITIONS
+ * <p>See: PS 3.4 - C.6.2 Study Root SOP Class Group
+ * <p>
+ * <p>Details of how to run the services is given in a configuration property file.
+ * A sample may be found at "./resources/CDimseService.cfg".
+ *
+ *
+ * @author Thomas Hacklaender
+ * @version 2006-08-28
+ */
+public class CDimseService {
+    
+    static final Logger log = Logger.getLogger("CDimseService");
+    
+    /** The DEBUG flag is set, if the logging level of this class is Debug */
+    final static boolean DEBUG = log.isDebugEnabled();
+    
+    //>>>> Factorys >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+    private static final UIDDictionary uidDict = DictionaryFactory.getInstance().getDefaultUIDDictionary();
+    private static final AssociationFactory aFact = AssociationFactory.getInstance();
+    private static final DcmObjectFactory oFact = DcmObjectFactory.getInstance();
+    private static final DcmParserFactory pFact = DcmParserFactory.getInstance();
+    private final static DcmObjectFactory dof = DcmObjectFactory.getInstance();
+    
+    /** Default AE title used for the association if it is not explicit given in the url filed. */
+    public static String DEFAULT_CALLING_AET = "MAYAM";
+    
+    /** Query/Retrieve Level Values for Study = "PATIENT". See PS 3.4 - C.6 SOP CLASS DEFINITIONS*/
+    static public final int PATIENT_LEVEL = 0;
+     
+    /** Query/Retrieve Level Values for Study = "STUDY". See PS 3.4 - C.6. SOP CLASS DEFINITIONS*/
+    static public final int STUDY_LEVEL = 1;
+    
+    /** Query/Retrieve Level Values for Series = "SERIES". See PS 3.4 - C.6 SOP CLASS DEFINITIONS*/
+    static public final int SERIES_LEVEL = 2;
+    
+    /** Query/Retrieve Level Values for Image = "IMAGE". See PS 3.4 - C.6 SOP CLASS DEFINITIONS*/
+    static public final int IMAGE_LEVEL = 3;
+    
+    PresContext pc;
+    
+    /** DICOM URL to define a communication partner for an association.
+     * <p>PROTOCOL://CALLED[:CALLING]@HOST[:PORT]
+     * <p>
+     * <p>PROTOCOL Specifies protocol. Possible values:
+     * <p>   - dicom            DICOM default (without TLS)
+     * <p>   - dicom-tls        DICOM on TLS (offer AES and DES encryption)
+     * <p>   - dicom-tls.aes    DICOM on TLS (force AES or DES encryption)
+     * <p>   - dicom-tls.3des   DICOM on TLS (force DES encryption)
+     * <p>   - dicom-tls.nodes  DICOM on TLS (no encryption)
+     * <p>CALLED  Called AET in association request (max 16 chars)
+     * <p>CALLING Calling AET in association request (max 16 chars) [default id final field DEFAULT_CALLING_AET = MYAET]
+     * <p>HOST    Name or IP address of host, where the server is running
+     * <p>PORT    TCP port address, on which the server is listing for
+     * <p>        incoming TCP Transport Connection Indication [default=104] */
+    private DcmURL url = null;
+    
+    /** Message priority. Possible values Command.LOW = 2, Command.MEDIUM = 0, Command.HIGH = 1*/
+    private int priority = Command.MEDIUM;
+    
+    
+    
+    /** Time-out waiting [in msec] for A-ASSOCIATE-AC acknowlage, 0 is interpreted
+     * as an infinite timeout [default=5000]. */
+    private int acTimeout = 5000;
+    
+    /** Time-out waiting [in msec] for DIMSE on aASSOCIATE association, 0 is
+     * interpreted as an infinite timeout [default=0]. */
+    private int dimseTimeout = 0;
+    
+    /** Time delay [in msec] for socket aRELEASE after sending A-ABORT [default=500]. */
+    private int soCloseDelay = 500;
+    
+    /** Association Request package (A-ASSOCIATE-RQ) is part of the connection
+     * service ACSE (Association Control Service Element). In TCP/IP networks
+     * connection services are emulated by the "DICOM Upper Layer Service".
+     * This presentation srvice encapsulats the data in PDUs (Protocol Data Unit). */
+    private AAssociateRQ assocRQ = aFact.newAAssociateRQ();
+    
+    /** Association object for establishing an active association. */
+    private Association assoc = null;
+    
+    /** Accepted association */
+    private ActiveAssociation aassoc = null;
+    
+    /** Activates packing of command PDV (Presentation Data Value) + (first) data
+     * PDV into one P-DATA-TF PDU (Protocol Data Unit) */
+    private boolean packPDVs = false;
+    
+    /** TLS context. Set by method initTLS */
+    private SSLContextAdapter tls = null;
+    
+    /** An array of implemented ciphers for the communication protocol (given in url). */
+    private String[] cipherSuites = null;
+    
+    /** Specifies Key Attributes used for C-FIND.
+     * Wildcards '*','?', '-' and '\' are allowed as element-values (see PS 3.4 - C.2.2.2 Attribute Matching).
+     * If an key attribute is defined, but has an empty value, it matches every value at the storage side.
+     * <p>Key attributes have a type (PS 3.4 - C.2.2.1 Attribute Types)
+     * <p>  - U = one Attribute shall be defined as a Unique Key.
+     * <p>  - R = a set of Attributes shall be defined as Required Keys.
+     * <p>  - O = a set of Attributes shall be defined as Optional Keys.
+     * <p>The complete list of Key Attributes can be found at PS 3.4 - C.6.2 Study Root SOP Class Group.
+     * <p>As a result of C-FIND for each matching item in the archive a DIMSE object containing
+     * the Key Attributes is send back. In this object the Key Attributes are set corresponding to
+     * values found in the archive. Attributes of type "O" may be send back with empty value.
+     * Only used by C-FIND. */
+    private Dataset keys = dof.newDataset();
+    
+    /** Application Entity Title (AET) of the destination for the C-MOVE. The
+     * AET must be known by the archive together with the host IP adress and the
+     * port number. Only used by C-MOVE. */
+    private String dest;
+    
+    
+    //>>>> Constructor >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+    
+    /**
+     *  Constructor for the StorageSCUServiceClass object. Initializes everything.
+     *
+     * <p>Details of how to run the server is given in another configuration property file.
+     * A sample may be found at "./resources/StorageSCUServiceClass.cfg".
+     *
+     * @param cfg the configuration properties for this class.
+     * @param url the DcmURL of the communication partner.
+     * @throws ParseException
+     */
+    public CDimseService(ConfigProperties cfg, DcmURL url) throws ParseException {
+        this.url = url;
+        this.priority = Integer.parseInt(cfg.getProperty("prior", "0"));
+        this.packPDVs = "true".equalsIgnoreCase(cfg.getProperty("pack-pdvs", "false"));
+        initAssocParam(cfg, url);
+        // initEchoAssocParam(cfg, url);
+        initTLS(cfg);
+        
+        // Only used by C-FIND
+        initKeys(cfg);
+        
+        // Only used by C-MOVE
+        this.dest = cfg.getProperty("dest");
+    }
+    
+    
+    //>>>> Methods >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+    
+    /**
+     * Initializes Association related parameters.
+     *
+     * @param cfg the configuration properties for this class.
+     * @param url the DcmURL of the communication partner.
+     */
+    private final void initAssocParam(ConfigProperties cfg, DcmURL url) {
+        String callingAET = null;
+        
+        //>>>> Get data for filling the Association object for establishing an
+        //>>>> active association from configuration file
+        
+        acTimeout = Integer.parseInt(cfg.getProperty("ac-timeout", "5000"));
+        dimseTimeout = Integer.parseInt(cfg.getProperty("dimse-timeout", "0"));
+        soCloseDelay = Integer.parseInt(cfg.getProperty("so-close-delay", "500"));
+        
+        //>>>> Fill the Association Request package (A-ASSOCIATE-RQ)
+        
+        // Identifying the communication partner by an AET (Application Entity Title)
+        assocRQ.setCalledAET(url.getCalledAET());
+        
+        // Identifying ourselves by an AET (Application Entity Title)
+        if (url.getCallingAET() != null) {
+            callingAET = url.getCallingAET();
+        } else {
+            callingAET = DEFAULT_CALLING_AET;
+        }
+        assocRQ.setCallingAET(callingAET);
+        
+        // Maximum size of one PDU (Protocol Data Unit)
+        assocRQ.setMaxPDULength(Integer.parseInt(cfg.getProperty("max-pdu-len", "16352")));
+        
+        // Defines possibilities for asynchron DIMSE communication. Noramly synchron DIMSE communication is used.
+        // API doc: AssociationFactory.newAsyncOpsWindow(int maxOpsInvoked, int maxOpsPerfomed)
+        // PS 3.7 - Annex D.3.3.3 ASYNCHRONOUS OPERATIONS WINDOW NEGOTIATION
+        // maxOpsInvoked: This field shall contain the Maximum-number-operationsinvoked as defined for the Association-requester
+        // maxOpsPerfomed: This field shall contain the Maximum-number-operationsperformed as defined for the Association-requester
+        assocRQ.setAsyncOpsWindow(aFact.newAsyncOpsWindow(Integer.parseInt(cfg.getProperty("max-op-invoked", "0")), 1));
+        
+        for (Enumeration it = cfg.keys(); it.hasMoreElements();) {
+            String key = (String) it.nextElement();
+            
+            // Setup available transfer syntaces for storage SOP classes
+            // PS 3.4 - Annex B STORAGE SERVICE CLASS
+            // PS 3.4 - B.5 STANDARD SOP CLASSES
+            if (key.startsWith("pc.")) {
+                initPresContext(Integer.parseInt(key.substring(3)), cfg.tokenize(cfg.getProperty(key), new LinkedList()));
+            }
+        }
+    }
+    
+    
+    /**
+     * Only used by method initAssocParam:
+     * Sets up available transfer syntaces for storage SOP classes.
+     * @param pcid is a for the association unique odd number between 1 and 255.
+     * @param val a list: First element is the symbolic name of the UID of the
+     *            SOP to transmit, the following elements are the supportet
+     *            transfer syntax for that SOP.
+     */
+    private final void initPresContext(int pcid, List val) {
+        Iterator it = val.iterator();
+        String as = UIDs.forName((String) it.next());
+        String[] tsUIDs = new String[val.size() - 1];
+        for (int i = 0; i < tsUIDs.length; ++i) {
+            tsUIDs[i] = UIDs.forName((String) it.next());
+        }
+        // API doc: AssociationFactory.newPresContext(int pcid, String asuid, String[] tsuid)
+        // pcid is a for the association unique odd number between 1 and 255.
+        // asuid is the UID of a SOP class
+        // TS list of transfer syntaces supported by this class for asuid.
+        assocRQ.addPresContext(aFact.newPresContext(pcid, as, tsUIDs));
+    }
+    
+    
+    /**
+     * Initializes TLS (Transport Layer Security, predecessor of SSL, Secure
+     * Sockets Layer) connection related parameters. TLS expects RSA (Ron Rivest,
+     * Adi Shamir and Len Adleman) encoded keys and certificates.
+     *
+     * <p>Keys and certificates may be stored in PKCS #12 (Public Key
+     * Cryptography Standards) or JKS (Java Keystore) containers.
+     *
+     * <p>TSL is used to encrypt data during transmission, which is accomplished
+     * when the connection between the two partners A (normally the client) and B
+     * (normally the server) is established. If A asks B to send TSL encrypted
+     * data, both partners exchange some handshake information. In a first step
+     * B tries to authentify itself against A (server authentification, optional
+     * in TSL but implementet in this way in dcm4che). For that B presents its
+     * public key for A to accept or deny. If the authentification is accepted,
+     * A tries to authentify itself against B (client authentification, optional
+     * in TSL but implementet in this way in dcm4che).If B accepts the
+     * authentification A and B agree on a hash (symmetric key, which is
+     * independent of the private/public keys used for authentification) for the
+     * duration of their conversation, which is used to encrypt the data.
+     *
+     * <p>To be able to establish a TSL connection B needs a privat/public key
+     * pair, which identifies B unambiguously. For that the private key is
+     * generated first; than the root-public key is derived from that private
+     * key. To bind the root-public key with the identity of B a Certificate
+     * Authority (CA) is used: The root-public key is send to CA, which returns
+     * a certified-public key, which includes information about the CA as well
+     * as the root-public key. Optionally this process can be repeated several
+     * times so that the certified-public key contains a chain of certificates
+     * of different CA's.
+     *
+     * <p>The certified-public key of B is presented to A during server
+     * authentification. Partner A should accept this key, if it can match the
+     * last certificate in the chain with a root-certificat found in its local
+     * list of root-certificates of CA's. That means, that A does not check the
+     * identity of B, but "trusts" B because it was certified by an authority.
+     * The same happens for client authentification. Handling of authentification
+     * of the identity of the communication partner is subject of PS 3.15 -
+     * Security and System Management Profiles.
+     *
+     * <p>In the configuration files of this method the certified-public key is
+     * stored in the property "tls-key" and the root-certificates of the known
+     * CA's in "tls-cacerts".
+     *
+     * <p>Usually the certified-public keys of A and B are different, but they
+     * also may be the same. In this case the root-certificates are also the same.
+     *
+     * <p>It is possible to establish a TLS connection without using a CA: In
+     * this case both partners creates a individual container holding their
+     * private and root-public key. These containers could be used for certifying
+     * also, because the length of the certifying chain is one and therefore the
+     * root-public key is also the last certified-public key. Therefore the
+     * root-public key works in this scenario also as the root-certificate of
+     * the "certifying authoroty".
+     *
+     * <p>If no keystores are specified in the configuration properties, the
+     * not-certified default-keystore "resources/identityJava.jks" is used for
+     * "tls-key" and "tls-cacerts" when establishing the connection.
+     *
+     * @param cfg the configuration properties for this class.
+     * @throws ParseException
+     */
+    private void initTLS(ConfigProperties cfg) throws ParseException {
+        char[]  keystorepasswd;
+        char[]  keypasswd;
+        char[]  cacertspasswd;
+        URL     keyURL;
+        URL     cacertURL;
+        String  value;
+        
+        try {
+            
+            // Cipher suites for protokoll:
+            // dicom = null
+            // dicom-tls = SSL_RSA_WITH_NULL_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA
+            // dicom-tls.3des = SSL_RSA_WITH_3DES_EDE_CBC_SHA
+            // dicom-tls.aes = TLS_RSA_WITH_AES_128_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA
+            // dicom-tls.nodes = SSL_RSA_WITH_NULL_SHA
+            cipherSuites = url.getCipherSuites();
+            if (cipherSuites == null) {
+                return;
+            }
+            
+            // Get a new TLS context
+            tls = SSLContextAdapter.getInstance();
+            
+            //>>>> Managing the keystore file containing the privat key and
+            //>>>> certified-public key to establish the communication
+            
+            // Password of the keystore [default: secret]
+            keystorepasswd = cfg.getProperty("tls-keystore-passwd", "secret").toCharArray();
+            
+            // Password of the private key [default: secret]
+            keypasswd = cfg.getProperty("tls-key-passwd", "secret").toCharArray();
+            
+            // URL of the file containing the default-keystore
+            keyURL = CDimseService.class.getResource("/resources/identityJava.jks");
+            
+            // If availabel, replace URL with the one specified in the configuration file
+            if ((value = cfg.getProperty("tls-key")) != null) {
+                try {
+                    // Property specified, try to set to specified value
+                    keyURL = ConfigProperties.fileRefToURL(CDimseService.class.getResource(""), value);
+                } catch (Exception e) {
+                    log.warn("Wrong value for tls-key: " + value + ". tls-key was set to default value.");
+                }
+            }
+            
+            // log.info("Key URL: " + keyURL.toString());
+            
+            // Sets the key attribute of the SSLContextAdapter object
+            // API doc: SSLContextAdapter.loadKeyStore(java.net.URL url, char[] password)
+            // API doc: SSLContextAdapter.setKey(java.security.KeyStore key, char[] password)
+            tls.setKey(tls.loadKeyStore(keyURL, keystorepasswd), keypasswd);
+            
+            //>>>> Managing the keystore containing the root-certificates of the Ceritifying Authorities
+            //>>>> used for signing the public key
+            
+            // Password of the keystore [default: secret]
+            cacertspasswd = cfg.getProperty("tls-cacerts-passwd", "secret").toCharArray();
+            
+            // URL of the file containing the default-keystore
+            cacertURL = CDimseService.class.getResource("/resources/identityJava.jks");
+            
+            // If availabel, replace URL with the one specified in the configuration file
+            if ((value = cfg.getProperty("tls-cacerts")) != null) {
+                try {
+                    // Property specified, try to set to specified value
+                    cacertURL = ConfigProperties.fileRefToURL(CDimseService.class.getResource(""), value);
+                } catch (Exception e) {
+                    log.warn("Wrong value for tls-cacerts: " + value + ". tls-cacerts was set to default value.");
+                }
+            }
+            
+            // log.info("Root-certificat of CA URL: " + cacertURL.toString());
+            
+            // Sets the trust attribute of the SSLContextAdapter object
+            // API doc: SSLContextAdapter.loadKeyStore(java.net.URL url, char[] password)
+            // API doc: SSLContextAdapter.setTrust(java.security.KeyStore cacerts)
+            tls.setTrust(tls.loadKeyStore(cacertURL, cacertspasswd));
+            
+            // Init TLS context adapter
+            tls.init();
+            
+        } catch (Exception ex) {
+            throw new ParseException("Could not initalize TLS configuration.", 0);
+        }
+    }
+    
+    
+    /**
+     * Prepares the Dataset representing the search key in C-FIND. As no values are
+     * set, the keys match to every content in the archive. The user has to specify
+     * concret values to limit the searchSee PS 3.4 - C.6.2.1.2 Study level.
+     * <p>As the result for C-FIND these keys are filled with the values found in the archive.
+     * @param cfg the configuration properties for this class.
+     * @throws ParseException if a given properties for the keys was not found.
+     */
+    private void initKeys(ConfigProperties cfg) throws ParseException {
+        // Remove all keys
+        keys = dof.newDataset();
+        
+        // Query/Retrieve Level. PS 3.4 - C.6.2 Study Root SOP Class Group
+        keys.putCS(Tags.QueryRetrieveLevel, getQueryRetrieveLevel(STUDY_LEVEL));
+        
+        // UNIQUE STUDY LEVEL KEY FOR THE STUDY. See PS 3.4 - C.6.2.1.2 Study level
+        keys.putUI(Tags.StudyInstanceUID);
+        
+        // REQUIRED STUDY LEVEL KEY FOR THE STUDY. See PS 3.4 - C.6.2.1.2 Study level
+        keys.putDA(Tags.StudyDate);
+        // Not defined: StudyTime
+        // Not defined: AccessionNumber
+        keys.putPN(Tags.PatientName);
+        keys.putLO(Tags.PatientID);
+        // Not defined: StudyID
+        
+        // OPTIONAL STUDY LEVEL KEY FOR THE STUDY. See PS 3.4 - C.6.2.1.2 Study level
+        keys.putUS(Tags.NumberOfStudyRelatedSeries);
+        keys.putUS(Tags.NumberOfStudyRelatedInstances);
+        keys.putUS(Tags.InstitutionName);
+        // mutch more defined...
+        
+        // Add the keys found in the configuration properties
+        addQueryKeys(cfg);
+    }
+    
+    
+    /**
+     * Add the query keys found in the configuration properties to the Dataset
+     * "keys" used bei the cFIND method.
+     *
+     * @param cfg the configuration properties for this class.
+     * @throws ParseException if a given properties for the keys was not found.
+     */
+    private void addQueryKeys(ConfigProperties cfg) throws ParseException {
+        // Add/replace keys found in the configuration file. Syntax key.<element name> = <element value>
+        for (Enumeration it = cfg.keys(); it.hasMoreElements(); ) {
+            String key = (String) it.nextElement();
+            if (key.startsWith("key.")) {
+                try {
+                    keys.putXX(Tags.forName(key.substring(4)), cfg.getProperty(key));
+                } catch (Exception e) {
+                    throw new ParseException("Illegal entry in configuration filr: " + key + "=" + cfg.getProperty(key), 0);
+                }
+            }
+        }
+    }
+    
+    
+    /**
+     * Sets the Dataset representing the query keys in C-FIND. The user can specify
+     * concret values to limit the search.
+     * <p>Wildcards '*','?', '-' and '\' are allowed as element-values (see PS 3.4 - C.2.2.2 Attribute Matching).
+     * If an key attribute is defined, but has an empty value, it matches every value at the storage side.
+     * <p> At a minimum the key "QueryRetrieveLevel" must be set ("STUDY", "SERIES" or "IMAGE").
+     * See PS 3.4 - C.6.2 Study Root SOP Class Group
+     * <p>As the result for C-FIND these keys are filled with the values found in the archive.
+     * @param ds the Dataset containig the search keys.
+     */
+    public void setQueryKeys(Dataset ds) {
+        keys = ds;
+    }
+    
+    
+    /**
+     * Sets the Dataset representing the query keys in C-FIND. The user can specify
+     * concret values to limit the search.
+     * <p>Wildcards '*','?', '-' and '\' are allowed as element-values (see PS 3.4 - C.2.2.2 Attribute Matching).
+     * If an key attribute is defined, but has an empty value, it matches every value at the storage side.
+     * <p> At a minimum the key "QueryRetrieveLevel" must be set ("STUDY", "SERIES" or "IMAGE").
+     * See PS 3.4 - C.6.2 Study Root SOP Class Group
+     * <p>As the result for C-FIND these keys are filled with the values found in the archive.
+     * @param cfg the configuration properties for this class.
+     * @throws ParseException if a given properties for the keys was not found.
+     */
+    public void setQueryKeys(ConfigProperties cfg) throws ParseException {
+        
+        // Remove all keys
+        keys = dof.newDataset();
+        
+        // Add the keys found in the configuration properties
+        addQueryKeys(cfg);
+    }
+    
+    
+    /**
+     * Starts a active association to a communication partner.
+     * See PS 3.8 - 7.1 A-ASSOCIATE SERVICE
+     *
+     * @return true, if association was successful established.
+     * @exception  ConnectException
+     * @exception  IOException
+     * @exception  GeneralSecurityException
+     */
+    public boolean aASSOCIATE() throws ConnectException, IOException, GeneralSecurityException {
+        
+        // No association may be active
+        if (assoc != null) {
+            throw new ConnectException("Association already established");
+        }
+        
+        // New Association object for establishing an active association
+        assoc = aFact.newRequestor(newSocket(url.getHost(), url.getPort()));
+        
+        //>>>> Fill the Association object with relevant data
+        assoc.setAcTimeout(acTimeout);
+        assoc.setDimseTimeout(dimseTimeout);
+        assoc.setSoCloseDelay(soCloseDelay);
+        assoc.setPackPDVs(packPDVs);
+        
+        // 1. Create an communication channel to the communication partner defined in the Association object
+        // 2. Send the A-ASSOCIATE-RQ package
+        // 3. Receive the aAssociation acknowlage/reject package from the communication partner as a PDU (Protocol Data Unit)
+        PDU assocAC = assoc.connect(assocRQ);
+        
+        if (!(assocAC instanceof AAssociateAC)) {
+            // Acknowlage is A-ASSOCIATE-RJ
+            // Association rejected
+            assoc = null;
+            
+            // Return aASSOCIATE faild
+            return false;
+        }
+        // Acknowlage is A-ASSOCIATE_AC
+        // Association accepted
+        
+        // Start the accepted association
+        // API doc: AssociationFactory.newActiveAssociation(Association assoc, DcmServiceRegistry services)
+        aassoc = aFact.newActiveAssociation(assoc, null);
+        aassoc.start();
+        
+        // Return successfull opened
+        return true;
+    }
+    
+    
+    /**
+     * Creates a stream socket and connects it to the specified port number on the named host.
+     * @param host the IP address.
+     * @param port the port number.
+     * @return the Socket.
+     * @exception  IOException
+     * @exception  GeneralSecurityException
+     */
+    private Socket newSocket(String host, int port) throws IOException, GeneralSecurityException {
+        
+        // Test, if a secured connection is needed
+        if (cipherSuites != null) {
+            
+            // Creates a socket for secured connection.
+            // The SSLContextAdapter tls uses the javax.net.ssl package for establishing
+            // the connection.
+            return tls.getSocketFactory(cipherSuites).createSocket(host, port);
+        } else {
+            
+            // Creates a standard Java socket for unsecured connection.
+            return new Socket(host, port);
+        }
+    }
+    
+    
+    /**
+     * Releases the active association.
+     * See PS 3.8 - 7.2 A-RELEASE SERVICE
+     *
+     * @param waitOnRSP if true, method waits until it receives the responds
+     *                  to the release request.
+     * @exception  InterruptedException  Description of the Exception
+     * @exception  IOException           Description of the Exception
+     */
+    public void aRELEASE(boolean waitOnRSP) throws InterruptedException, IOException {
+        if (assoc != null) {
+            try {
+                aassoc.release(waitOnRSP);
+            } finally {
+                assoc = null;
+                aassoc = null;
+            }
+        }
+    }
+    
+    
+    /**
+     * Stores a DICOM object in an archive (Storage SCP).
+     * <p>See PS 3.4 - Annex B STORAGE SERVICE CLASS.
+     *
+     * @param ds the Dataset to store.
+     * @throws ConnectException
+     * @throws ParseException
+     * @throws IOException
+     * @throws InterruptedException
+     * @throws IllegalStateException
+     */
+    public void cSTORE(Dataset ds) throws InterruptedException, IOException, ConnectException, ParseException {
+        String  sopClassUID;
+        String  sopInstUID;
+        PresContext pc = null;
+        
+        // An association must be active
+        if (aassoc == null) {
+            throw new ConnectException("No Association established");
+        }
+        
+        // SOP Class UID must be given
+        if ((sopClassUID = ds.getString(Tags.SOPClassUID)) == null) {
+            
+            throw new ParseException("No SOP Class UID in Dataset", 0);
+        }
+        
+        // SOP Instance UID must be given
+        if ((sopInstUID = ds.getString(Tags.SOPInstanceUID)) == null) {
+            throw new ParseException("No SOP Instance UID in Dataset", 0);
+        }
+        
+        // Test, if applicable presentation context was found
+        if ((pc = aassoc.getAssociation().getAcceptedPresContext(sopClassUID, UIDs.ImplicitVRLittleEndian)) == null &&
+            (pc = aassoc.getAssociation().getAcceptedPresContext(sopClassUID, UIDs.ExplicitVRLittleEndian)) == null &&
+            (pc = aassoc.getAssociation().getAcceptedPresContext(sopClassUID, UIDs.ExplicitVRBigEndian)) == null) {
+            
+            throw new ConnectException("No applicable presentation context found");
+        }
+        
+        // New Cammand Set, see: DICOM Part 7: Message Exchange, 6.3.1 Command Set Structure
+        Command cStoreRQ = oFact.newCommand();
+        // API doc: Command.initCStoreRQ(int msgID, String sopClassUID, String sopInstUID, int priority)
+        cStoreRQ.initCStoreRQ(assoc.nextMsgID(), sopClassUID, sopInstUID, priority);
+        
+        // API doc: AssociationFactorynewDimse(int pcid, Command cmd, Dataset ds)
+        // DIMSE (DICOM Message Service Element) ist ein Nachrichtendienst in DICOM
+        Dimse storeRq = aFact.newDimse(pc.pcid(), cStoreRQ, ds);
+        
+        // PS 3.7 - 9.3.1 C-STORE PROTOCOL, 9.3.1.2 C-STORE-RSP
+        // Always returns SUCESS result code.
+        // Invoke active association with echo request Dimse
+        FutureRSP future = aassoc.invoke(storeRq);
+        //System.out.println("store is going in this AE");
+        // Response to the C-ECHO request.
+        // The result cannot be accessed until it has been set.
+        Dimse storeRsp = future.get();
+        Command rspCmd = storeRsp.getCommand();
+        
+        // PS 3.7 - 9.3.5 C-MOVE PROTOCOL, 9.3.5.2 C-ECHO-RSP
+        int status = rspCmd.getStatus();
+        switch (status) {
+            case 0x0000:
+                // Success
+                break;
+            default:
+                log.error("C-STORE failed: " + Integer.toHexString(status));
+                break;
+        }
+        
+    }
+    
+    
+    
+    
+    public Vector cGET(Dataset ds) throws ConnectException, IOException, InterruptedException {
+        PresContext pc;
+        List dimseList;
+        Vector datasetVector;
+        
+        // An association must be active
+        if (aassoc == null) {
+            throw new ConnectException("No Association established");
+        }
+        
+        // Test, if Presentation Context for C-MOVE is supported
+        // API doc: Association.getAcceptedPresContext(String asuid, String tsuid)
+        if ((pc = aassoc.getAssociation().getAcceptedPresContext(UIDs.StudyRootQueryRetrieveInformationModelGET, UIDs.ExplicitVRLittleEndian)) == null &&
+            (pc = aassoc.getAssociation().getAcceptedPresContext(UIDs.StudyRootQueryRetrieveInformationModelGET, UIDs.ImplicitVRLittleEndian)) == null) {
+            throw new ConnectException("Association does not support presentation context for StudyRootQueryRetrieveInformationModelMOVE SOP.");
+        }
+        
+        // Get the Study Instance UID of the study to mode
+        String suid = ds.getString(Tags.SOPInstanceUID);
+        
+        // Prepare info for logging
+        String patName = ds.getString(Tags.PatientName);
+        String patID = ds.getString(Tags.PatientID);
+        String studyDate = ds.getString(Tags.StudyDate);
+        String prompt = "Study[" + suid + "] from " + studyDate + " for Patient[" + patID + "]: " + patName;
+        
+        // log.info("Moving: " + prompt);
+        
+        // New Cammand Set, see: DICOM Part 7: Message Exchange, 6.3.1 Command Set Structure
+        Command rqCmd = dof.newCommand();
+        // API doc: Command.initCMoveRQ(int msgID, String sopClassUID, int priority, String moveDest)
+        rqCmd.initCGetRSP(assoc.nextMsgID(), UIDs.StudyRootQueryRetrieveInformationModelGET, priority);
+        Dataset rqDs = dof.newDataset();
+        rqDs.putCS(Tags.QueryRetrieveLevel, getQueryRetrieveLevel(STUDY_LEVEL));
+        // Only Unique Key allowed in C-MOVE. PS 3.4 -C.2.2.1 Attribute Types
+        rqDs.putUI(Tags.SOPInstanceUID, suid);
+        // API doc: AssociationFactorynewDimse(int pcid, Command cmd, Dataset ds)
+        // DIMSE (DICOM Message Service Element) ist ein Nachrichtendienst in DICOM
+        Dimse moveRq = aFact.newDimse(pc.pcid(), rqCmd, rqDs);
+        
+        // Invoke active association with move request Dimse
+        FutureRSP future = aassoc.invoke(moveRq);
+        // Response to the C-MOVE request.
+        // The result cannot be accessed until it has been set.
+        Dimse moveRsp = future.get();
+        Command rspCmd = moveRsp.getCommand();
+       
+        
+      
+        
+        if (DEBUG) {
+            StringWriter w = new StringWriter();
+            w.write("C-FIND RQ Identifier:\n");
+            keys.dumpDataset(w, null);
+            log.debug(w.toString());
+        }
+        
+        // Invoke active association with find request Dimse
+      
+        // Response to the C-FIND request.
+        // The result cannot be accessed until it has been set.
+        
+        
+        // Get the list of found objects
+        dimseList = future.listPending();
+       
+        
+        //>>>> Extract Dataset from Dimse
+        
+        datasetVector = new Vector();
+        
+        // If no List of DIMSE objects was generated or it is empty return an empty Vector
+        if (dimseList == null || dimseList.isEmpty()) {
+            return datasetVector;
+        }
+        
+        // Process all elements
+        for (int i = 0; i < dimseList.size(); i++) {
+            datasetVector.addElement(((Dimse) dimseList.get(i)).getDataset());         
+        }
+        
+       
+        
+        // PS 3.7 - 9.3.4 C-MOVE PROTOCOL, 9.3.4.2 C-MOVE-RSP
+        int status = rspCmd.getStatus();
+        switch (status) {
+            case 0x0000:
+                // log.info("Moved: " + prompt);
+                break;
+            case 0xB000:
+                log.error("One or more failures during move of " + prompt);
+                break;
+            default:
+                log.error("Failed to move " + prompt + "\n\terror tstatus: " + Integer.toHexString(status));
+                break;
+        }
+       // System.out.println("The move sise is : "+datasetVector.size());
+        return datasetVector;
+    }
+    
+    
+    /**
+     * Queries the archive for DICOM objects matching Attribute Keys defined in
+     * the loacal field "keys". This field is set by the constructor out of the
+     * configuration parameters or by the methods setQueryKeys(Configuration) and setQueryKeys(Dataset).
+     * See PS 3.4 - Annex C QUERY/RETRIEVE SERVICE CLASS.
+     * <p>The method returns, when the result is received from the communication partner.
+     *
+     *
+     * @return the result of the cFIND as a Vector of Dataset objects each specifying
+     *         one matching DICOM object. If no matching objects are found an empty Vector is returned.
+     * @throws ConnectException
+     * @throws IOException
+     */
+    public Vector cFIND() throws ConnectException, IOException, InterruptedException {
+      
+        List dimseList;
+        Vector datasetVector;
+        
+        // An association must be active
+        if (aassoc == null) {
+            throw new ConnectException("No Association established");
+        }
+        
+        // Test, if Presentation Context for C-FIND is supported
+        // API doc: Association.getAcceptedPresContext(String asuid, String tsuid)
+//        UIDs.StudyRootQueryRetrieveInformationModelGET
+        if ((pc = aassoc.getAssociation().getAcceptedPresContext(UIDs.StudyRootQueryRetrieveInformationModelFIND, UIDs.ExplicitVRLittleEndian)) == null &&
+            (pc = aassoc.getAssociation().getAcceptedPresContext(UIDs.StudyRootQueryRetrieveInformationModelFIND, UIDs.ImplicitVRLittleEndian)) == null) {
+            throw new ConnectException("Association does not support presentation context for StudyRootQueryRetrieveInformationModelFIND SOP.");
+        }
+        
+        // New Cammand Set, see: DICOM Part 7: Message Exchange, 6.3.1 Command Set Structure
+        Command rqCmd = dof.newCommand();
+        // API doc: Command.initCFindRQ(int msgID, String sopClassUID, int priority)
+        rqCmd.initCFindRQ(assoc.nextMsgID(), UIDs.StudyRootQueryRetrieveInformationModelFIND, priority);
+      
+        // API doc: AssociationFactorynewDimse(int pcid, Command cmd, Dataset ds)
+        // DIMSE (DICOM Message Service Element) ist ein Nachrichtendienst in DICOM
+        Dimse findRq = aFact.newDimse(pc.pcid(), rqCmd,keys);
+        
+        if (DEBUG) {
+            StringWriter w = new StringWriter();
+            w.write("C-FIND RQ Identifier:\n");
+            keys.dumpDataset(w, null);
+            log.debug(w.toString());
+        }
+        
+        // Invoke active association with find request Dimse
+        FutureRSP future = aassoc.invoke(findRq);
+        // Response to the C-FIND request.
+        // The result cannot be accessed until it has been set.
+        Dimse findRsp = future.get();
+        
+        // Get the list of found objects
+        dimseList = future.listPending();
+        
+        //>>>> Extract Dataset from Dimse
+        
+        datasetVector = new Vector();
+        
+        // If no List of DIMSE objects was generated or it is empty return an empty Vector
+        if (dimseList == null || dimseList.isEmpty()) {
+            return datasetVector;
+        }
+        
+        // Process all elements
+        for (int i = 0; i < dimseList.size(); i++) {
+            datasetVector.addElement(((Dimse) dimseList.get(i)).getDataset());
+        }
+        
+        return datasetVector;
+    }
+    
+    
+    /**
+     * Ask archive to move one DICOM object to the destination (C-MOVE).
+     * See PS 3.4 - Annex C QUERY/RETRIEVE SERVICE CLASS.
+     * <p>Use the Study Root Query/Retrieve Information Model to communicate with the archive.
+     * See PS 3.4 - C.6.2 Study Root SOP Class Group.
+     * <p>PS 3.4 - C.4.2.1.4.1 Request Identifier Structure (for C-MOVE):
+     * An Identifier in a C-MOVE request shall contain:
+     * <p>- the Query/Retrieve Level (0008,0052) which defines the level of the retrieval
+     * <p>- Unique Key Attributes which may include Patient ID, Study Instance UIDs, Series Instance UIDs, and the SOP Instance UIDs
+     * <p>PS 3.4 - C.4.2.2.1 Baseline Behavior of SCU (of C-MOVE):
+     * <p>The SCU shall supply a single value in the Unique Key Attribute for each
+     * level above the Query/Retrieve level. For the level of retrieve, the SCU shall
+     * supply one unique key if the level of retrieve is above the STUDY level and
+     * shall supply one UID, or a list of UIDs if a retrieval of several items is desired
+     * and the retrieve level is STUDY, SERIES or IMAGE.
+     *
+     * @param ds the DICOM object represented as a Dataset.
+     * @return a result-code: 0x0000 = SUCCESS sub-operations complete no failures,
+     *                        0xB000 = WARNING sub-operations complete  one or more failures,
+     *                        other = errors defined in PS 3.4 - C.4.2.1.5 Status
+     * @throws ConnectException
+     * @throws InterruptedException
+     * @throws IOException
+     */
+    public Vector cMOVE(Dataset ds) throws ConnectException, InterruptedException, IOException {
+        PresContext pc;
+        List dimseList;
+        Vector datasetVector;
+        
+        
+        
+        // An association must be active
+        if (aassoc == null) {
+            throw new ConnectException("No Association established");
+        }
+        
+        // Test, if Presentation Context for C-MOVE is supported
+        // API doc: Association.getAcceptedPresContext(String asuid, String tsuid)
+        if ((pc = aassoc.getAssociation().getAcceptedPresContext(UIDs.StudyRootQueryRetrieveInformationModelMOVE, UIDs.ExplicitVRLittleEndian)) == null &&
+            (pc = aassoc.getAssociation().getAcceptedPresContext(UIDs.StudyRootQueryRetrieveInformationModelMOVE, UIDs.ImplicitVRLittleEndian)) == null) {
+            throw new ConnectException("Association does not support presentation context for StudyRootQueryRetrieveInformationModelMOVE SOP.");
+        }
+        
+        // Get the Study Instance UID of the study to mode
+        String suid = ds.getString(Tags.StudyInstanceUID);
+        
+        // Prepare info for logging
+        String patName = ds.getString(Tags.PatientName);
+        String patID = ds.getString(Tags.PatientID);
+        String studyDate = ds.getString(Tags.StudyDate);
+        String prompt = "Study[" + suid + "] from " + studyDate + " for Patient[" + patID + "]: " + patName;
+        
+        // log.info("Moving: " + prompt);
+        
+        // New Cammand Set, see: DICOM Part 7: Message Exchange, 6.3.1 Command Set Structure
+        Command rqCmd = dof.newCommand();
+        // API doc: Command.initCMoveRQ(int msgID, String sopClassUID, int priority, String moveDest)
+        rqCmd.initCMoveRQ(assoc.nextMsgID(), UIDs.StudyRootQueryRetrieveInformationModelMOVE, priority, dest);
+        Dataset rqDs = dof.newDataset();
+        rqDs.putCS(Tags.QueryRetrieveLevel, getQueryRetrieveLevel(STUDY_LEVEL));
+        // Only Unique Key allowed in C-MOVE. PS 3.4 -C.2.2.1 Attribute Types
+        rqDs.putUI(Tags.StudyInstanceUID, suid);
+        
+
+        // API doc: AssociationFactorynewDimse(int pcid, Command cmd, Dataset ds)
+        // DIMSE (DICOM Message Service Element) ist ein Nachrichtendienst in DICOM
+        Dimse moveRq = aFact.newDimse(pc.pcid(), rqCmd, rqDs);
+        
+        // Invoke active association with move request Dimse
+        FutureRSP future = aassoc.invoke(moveRq);
+        // Response to the C-MOVE request.
+        // The result cannot be accessed until it has been set.
+        Dimse moveRsp = future.get();
+        Command rspCmd = moveRsp.getCommand();
+        Dataset dds = moveRsp.getDataset();
+        
+        
+        
+        
+
+        
+      
+        
+        if (DEBUG) {
+            StringWriter w = new StringWriter();
+            w.write("C-FIND RQ Identifier:\n");
+            keys.dumpDataset(w, null);
+            log.debug(w.toString());
+        }
+        
+        // Invoke active association with find request Dimse
+      
+        // Response to the C-FIND request.
+        // The result cannot be accessed until it has been set.
+        
+        
+        // Get the list of found objects
+        Dimse dms = future.get();
+       
+        
+        //>>>> Extract Dataset from Dimse
+        
+        datasetVector = new Vector();
+        
+        // If no List of DIMSE objects was generated or it is empty return an empty Vector
+      //  if (dimseList == null || dimseList.isEmpty()) {
+         //   return datasetVector;
+      //  }
+        
+        // Process all elements
+      //  for (int i = 0; i < dimseList.size(); i++) {
+         //   datasetVector.addElement(((Dimse) dimseList.get(i)).getDataset());
+          //  if(((Dimse) dimseList.get(i)).getDataset()==null)
+          //  System.out.println("              Dataset created succesffullyu          ");
+      //  }
+        
+       
+        
+        // PS 3.7 - 9.3.4 C-MOVE PROTOCOL, 9.3.4.2 C-MOVE-RSP
+        int status = rspCmd.getStatus();
+        switch (status) {
+            case 0x0000:
+                // log.info("Moved: " + prompt);
+                break;
+            case 0xB000:
+                log.error("One or more failures during move of " + prompt);
+                break;
+            default:
+                log.error("Failed to move " + prompt + "\n\terror tstatus: " + Integer.toHexString(status));
+                break;
+        }
+      //  System.out.println("The move sise is : "+datasetVector.size());
+        return datasetVector;
+    }
+    
+    
+    /**
+     * Implements the ECHO service. The C-ECHO service is invoked by a DIMSE-service-user
+     * to verify end-to-end communications with a peer DIMSE-service-user.
+     * See PS 3.7 - 9.1.5 C-ECHO SERVICE
+     *
+     * @exception ConnectException
+     * @exception InterruptedException
+     * @exception IOException
+     */
+    public long cECHO() throws ConnectException, InterruptedException, IOException {
+        PresContext pc;
+        long t1 = System.currentTimeMillis();
+        
+        // An association must be active
+        if (aassoc == null) {
+            throw new ConnectException("No Association established");
+        }
+        
+        // Test, if Presentation Context for C-ECHO is supported
+        // API doc: Association.getAcceptedPresContext(String asuid, String tsuid)
+        if ((pc = aassoc.getAssociation().getAcceptedPresContext(UIDs.Verification, UIDs.ImplicitVRLittleEndian)) == null) {
+            throw new ConnectException("Association does not support presentation context: Verification SOP/ImplicitVRLittleEndian.");
+        }
+        
+        // New Cammand Set, see: DICOM Part 7: Message Exchange, 6.3.1 Command Set Structure
+        Command cEchoRQ = oFact.newCommand();
+        // API doc: Command.initCEchoRQ(int msgID)
+        cEchoRQ.initCEchoRQ(1);
+        
+        // API doc: AssociationFactorynewDimse(int pcid, Command cmd)
+        // DIMSE (DICOM Message Service Element) ist ein Nachrichtendienst in DICOM
+        Dimse echoRq = aFact.newDimse(pc.pcid(), cEchoRQ);
+        
+        // PS 3.7 - 9.3.5 C-ECHO PROTOCOL, 9.3.5.2 C-ECHO-RSP
+        // Always returns SUCESS result code.
+        // Invoke active association with echo request Dimse
+        FutureRSP future = aassoc.invoke(echoRq);
+        
+        // Response to the C-ECHO request.
+        // The result cannot be accessed until it has been set.
+        Dimse echoRsp = future.get();
+        Command rspCmd = echoRsp.getCommand();
+        
+        // PS 3.7 - 9.3.5 C-MOVE PROTOCOL, 9.3.5.2 C-ECHO-RSP
+        int status = rspCmd.getStatus();
+        switch (status) {
+            case 0x0000:
+                // Success
+                break;
+            default:
+                log.error("C-ECHO failed: " + Integer.toHexString(status));
+                break;
+        }
+        
+        return System.currentTimeMillis() - t1;
+    }
+
+    
+    /**
+     * Gets the String value used for DICOM element QueryRetrieveLevel (0008,0052).
+     * <p>See PS 3.4 - C.6 SOP CLASS DEFINITIONS
+     *
+     * @param queryRetrieveLevel query/retrieve level as a enumerated value.
+     * @return the String value assiciated to enumerated query/retrieve level.
+     */
+    static public String getQueryRetrieveLevel(int queryRetrieveLevel) {
+        switch (queryRetrieveLevel) {
+            case PATIENT_LEVEL:
+                return "PATIENT";
+                
+            case STUDY_LEVEL:
+                return "STUDY";
+                
+            case SERIES_LEVEL:
+                return "SERIES";
+                
+            case IMAGE_LEVEL:
+                return "IMAGE";
+                
+            default:
+                return "";
+        }
+    }
+}
diff --git a/src/de/iftm/dcm4che/services/ConfigProperties.java b/src/de/iftm/dcm4che/services/ConfigProperties.java
new file mode 100644
index 0000000..60d5ce0
--- /dev/null
+++ b/src/de/iftm/dcm4che/services/ConfigProperties.java
@@ -0,0 +1,233 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is part of dcm4che, an implementation of DICOM(TM) in
+ * Java(TM), hosted at http://sourceforge.net/projects/dcm4che.
+ *
+ * The Initial Developer of the Original Code is
+ * TIANI Medgraph AG.
+ * Portions created by the Initial Developer are Copyright (C) 2002-2005
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Gunter Zeilinger <gunter.zeilinger at tiani.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package de.iftm.dcm4che.services;
+
+import java.io.File;
+import java.io.InputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.MalformedURLException;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Properties;
+import java.util.StringTokenizer;
+
+import org.dcm4che.data.*;
+import org.dcm4che.dict.*;
+
+import org.apache.log4j.*;
+
+
+/**
+ * Extension of the Properties class.
+ * <p>Based on dcm4che 1.4.0 sample: Configuration.java revision date 2005-10-05
+ * <p>Method uriToFile added.
+ * <p>No modifications.
+ *
+ * @author Thomas Hacklaender
+ * @version 2006-08-24
+ */
+public class ConfigProperties extends Properties {
+    
+    static final Logger log = Logger.getLogger("ConfigProperties");
+    
+    // Static --------------------------------------------------------
+    
+    private static String replace(String val, String from, String to) {
+        return from.equals(val) ? to : val;
+    }
+    
+    
+    // Constructors --------------------------------------------------
+    
+    /**
+     * Create an ConfigurationProperty object (extension of Propreties) without 
+     * any Properties included.
+     */
+    public ConfigProperties() {
+    }
+
+    
+    /**
+     * Create an ConfigurationProperty object (extension of Propreties) and load 
+     * Properties from given URL.
+     *
+     * @param url the URL containing the Properties.
+     */
+    public ConfigProperties(URL url) throws IOException {
+        
+        InputStream in = null;
+        try {
+            load(in = url.openStream());
+        } catch (Exception e) {
+            throw new IOException("Could not load configuration from " + url);
+        } finally {
+            if (in != null) {
+                try { in.close(); } catch (IOException ignore) {ignore.printStackTrace();}
+            }
+        }
+    }
+    
+    
+    // Public --------------------------------------------------------
+    
+    public String getProperty(String key, String defaultValue, String replace, String to) {
+        return replace(getProperty(key, defaultValue), replace, to);
+    }
+    
+    
+    public List tokenize(String s, List result) {
+        StringTokenizer stk = new StringTokenizer(s, ", ");
+        while (stk.hasMoreTokens()) {
+            String tk = stk.nextToken();
+            if (tk.startsWith("$")) {
+                tokenize(getProperty(tk.substring(1),""), result);
+            } else {
+                result.add(tk);
+            }
+        }
+        return result;
+    }
+    
+    
+    public String[] tokenize(String s) {
+        if (s == null)
+            return null;
+        
+        List l = tokenize(s, new LinkedList());
+        return (String[])l.toArray(new String[l.size()]);
+    }
+    
+    
+    /**
+     * Create a File from an URI.
+     * <span style="font-style: italic;">file-uri</span>
+     * <p>See the API-Doc of the URI class. For Windows-OS the absolute URI
+     * "file:/c:/user/tom/foo.txt" describes the file
+     * "C:\\user\\tom\\foo.txt". Relative URI's, e.g. without the "file:"
+     * schema-prefix, are relativ to the user-directory, given by the system
+     * property user.dir.
+     * <p>For example: If the user.dir is "C:\\user\\tom\\"
+     * and the relative URI is "/abc/foo.txt" the referenced file is
+     * "C:\\user\\tom\\abc\\foo.txt". The abbreviations "." for the current
+     * and ".." for the upper directory are valid to form a relative URI.
+     *
+     * @param uriString The string-description of an absolute or relative URI.
+     * @return the file which is described by the uriString. Returns null, if
+     *         uriString is null or "". Returns null also, if a conversion error occures.
+     */
+    static public File uriToFile(String uriString) {
+        URI baseURI;
+        URI uri;
+        
+        if (uriString == null) {
+            return null;
+        }
+        
+        if (uriString.equals("")) {
+            return null;
+        }
+        
+        try {
+            uri = new URI(uriString);
+            
+            // Remove redundend elements:
+            // Auakommentiert, weil eine URI der  Form "./a.b" (nicht "./a/b.c") zu
+            // einer ArrayIndexOutOfBoundsException fuehrt. Grund unklar. Interner Fehler?
+            // uri = uri.normalize();
+            
+            // Example of an absolute URI: file://de.iftm/abc/def/g.txt
+            // Relative URI do not have a "schema". Example: ./abc/def/g.txt
+            if (!uri.isAbsolute()) {
+                // Relative URI's werden auf das user.dir bezogen.
+                baseURI = (new File(System.getProperty("user.dir"))).toURI();
+                uri = baseURI.resolve(uri);
+            }
+            
+            return new File(uri);
+        } catch (Exception e) {
+            return null;
+        }
+    }
+    
+    
+    /**
+     * Returns a URL of a reference to a file. If the file reference is a valid
+     * absolute URI, this URI is converted directly to a URL. If the file reference
+     * is a relative URI this is resolved relative to a given base URL.
+     * <p>Example: For a class de.iftm.dcm4che.servicesCDimseService the method call
+     * fileRefToURL(CDimseService.class.getResource(""), "resources/identity.p12")
+     * results to the URL "file:/D:/DcmServices/build/classes/de/iftm/dcm4che/services/resources/identity.p12"
+     *
+     * @param baseURL the base URL to which relative file references are resolved.
+     *                May be null, if the fileRef is a absolute reference.
+     * @param fileRef the reference to file file. May be an absolute reference
+     *                (file:/C:/a/b/c.cfg) or relative reference (b/c.cfg).
+     * @return the URL of a file reference. The String representation is of the form "file:/a/b/c.cfg".
+     * @throws URISyntaxException if the fileRef is not formed as a URI.
+     * @throws MalformedURLException if the fileRef is not a reference to a file or
+     *                               baseURL is null for relative file references.
+     */
+    static public URL fileRefToURL(URL baseURL, String fileRef) throws URISyntaxException, MalformedURLException {
+        URL resultURL = null;
+        URI fileRefURI;
+        URI baseURI;
+        
+        // log.info("baseURL: " + baseURL.toString());
+        // log.info("fileRef: " + fileRef);
+        
+        fileRefURI = new URI(fileRef);
+        
+        if (fileRefURI.isAbsolute()) {
+            
+            // Absolute URI (file:/C:/a/b/c.cfg):
+            resultURL = fileRefURI.toURL();
+            
+        } else {
+            
+            // Relativ URI (b/c.cfg):
+            resultURL = new URL(baseURL, fileRef);
+        }
+        
+        // log.info("result URL: " + resultURL.toString());
+        return resultURL;
+    }
+    
+}
diff --git a/src/de/iftm/dcm4che/services/StorageService.java b/src/de/iftm/dcm4che/services/StorageService.java
new file mode 100644
index 0000000..4865e1e
--- /dev/null
+++ b/src/de/iftm/dcm4che/services/StorageService.java
@@ -0,0 +1,541 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is part of dcm4che, an implementation of DICOM(TM) in
+ * Java(TM), hosted at http://sourceforge.net/projects/dcm4che.
+ *
+ * The Initial Developer of the Original Code is
+ * TIANI Medgraph AG.
+ * Portions created by the Initial Developer are Copyright (C) 2002-2005
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Gunter Zeilinger <gunter.zeilinger at tiani.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package de.iftm.dcm4che.services;
+
+// import java.io.BufferedInputStream;
+// import java.io.File;
+// import java.io.FileInputStream;
+// import java.io.FileOutputStream;
+import java.io.IOException;
+// import java.io.InputStream;
+// import java.io.OutputStream;
+import java.net.URL;
+// import java.net.ConnectException;
+// import java.text.MessageFormat;
+import java.util.*;
+import java.text.ParseException;
+
+import org.dcm4che.data.Command;
+//import org.dcm4che.data.Dataset;
+//import org.dcm4che.data.DcmDecodeParam;
+//import org.dcm4che.data.DcmElement;
+//import org.dcm4che.data.DcmEncodeParam;
+import org.dcm4che.data.DcmObjectFactory;
+//import org.dcm4che.data.DcmParser;
+import org.dcm4che.data.DcmParserFactory;
+//import org.dcm4che.data.FileFormat;
+import org.dcm4che.data.FileMetaInfo;
+//import org.dcm4che.dict.Status;
+import org.dcm4che.dict.Tags;
+import org.dcm4che.dict.UIDs;
+//import org.dcm4che.dict.VRs;
+//import org.dcm4che.net.AAbort;
+import org.dcm4che.net.AcceptorPolicy;
+import org.dcm4che.net.ActiveAssociation;
+import org.dcm4che.net.AssociationFactory;
+import org.dcm4che.net.DcmServiceBase;
+//import org.dcm4che.net.DcmServiceException;
+import org.dcm4che.net.DcmServiceRegistry;
+import org.dcm4che.net.Dimse;
+import org.dcm4che.server.DcmHandler;
+import org.dcm4che.server.Server;
+import org.dcm4che.server.ServerFactory;
+//import org.dcm4che.util.BufferedOutputStream;
+import org.dcm4che.util.DcmProtocol;
+import org.dcm4che.util.SSLContextAdapter;
+
+import org.apache.log4j.Logger;
+
+/**
+ * Implementation of a DICOM server.
+ * <p>
+ * <p> Usage:
+ * <p> 1. Create a new instance of this class.
+ * <p> 2. Register one or more listeners for StorageServiceEvents. These events are fired for each received DICOM object.
+ * <p> 3. Use the start method to start the server.
+ * <p> 4. Use the stop method to start the server.
+ * <p>
+ * <p>Details of how to run the server is given in another configuration property file.
+ * A sample may be found at "./resources/StorageService.cfg".
+ * <p>
+ * <p>Based on dcm4che 1.4.0 sample: DcmRcv.java revision date 2006-04-06
+ * <p>
+ * <p>See: PS 3.4 - Annex B STORAGE SERVICE CLASS
+ * 
+ * @author Thomas Hacklaender
+ * @version 2006-07-25
+ */
+public class StorageService extends DcmServiceBase {
+    
+    final static Logger log = Logger.getLogger(StorageService.class);
+    
+    /** The DEBUG flag is set, if the logging level of this class is Debug */
+    final static boolean DEBUG = log.isDebugEnabled();
+    
+    
+    //>>>> Factorys >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+    private final static ServerFactory srvFact = ServerFactory.getInstance();
+    private final static AssociationFactory fact = AssociationFactory.getInstance();
+    private final static DcmParserFactory pFact = DcmParserFactory.getInstance();
+    private final static DcmObjectFactory oFact = DcmObjectFactory.getInstance();
+    
+    
+    //>>>> Fields >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+    
+    /** TLS context. Set by method initTLS */
+    private SSLContextAdapter tls = null;
+    
+    /** Type of encryption used for connections [default=DICOM]. */
+    private DcmProtocol protocol = DcmProtocol.DICOM;
+    
+    /** Acceptor policy of the server. */
+    private AcceptorPolicy policy = fact.newAcceptorPolicy();
+    
+    /** ??? */
+    private DcmServiceRegistry services = fact.newDcmServiceRegistry();
+    
+    /** The server handler instance.*/
+    private DcmHandler handler = srvFact.newDcmHandler(policy, services);
+    
+    /** The server instance.*/
+    private Server server = srvFact.newServer(handler);
+    
+    /** Additional delay of response [in sec] (useful for testing async mode). */
+    private long rspDelay = 0L;
+    
+    /** Status code in C-STORE-RSP in decimal (#####) or hex (####H) [default=0].
+     * Useful for testing modality behavior in case of status != 0 */
+    private int rspStatus = 0;
+    
+    /** A Vector of listeners registered to receive StorageServiceClassEvents. */
+    private Vector eventListeners = new Vector();
+    
+    
+    //>>>> Constructor >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+    
+    /**
+     *  Constructor for the StorageService object. Initializes everything.
+     * 
+     * @param cfg the configuration properties for this class.
+     * @throws ParseException
+     */
+    public StorageService(ConfigProperties cfg) throws ParseException {
+        // Additional delay of response [in sec] (useful for testing async mode).
+        rspDelay = Integer.parseInt(cfg.getProperty("rsp-delay", "0")) * 1000L;
+        
+        // Status code in C-STORE-RSP in decimal (#####) or hex (####H) [default=0]. Useful for testing modality behavior in case of status != 0
+        String decOrHex = cfg.getProperty("rsp-status", "0");
+        if (decOrHex.endsWith("H")) {
+            rspStatus = Integer.parseInt(decOrHex.substring(0, decOrHex.length()-1), 16);
+        } else {
+            rspStatus = Integer.parseInt(decOrHex);
+        }
+        
+        initServer(cfg);
+        initTLS(cfg);
+        initPolicy(cfg);
+    }
+    
+    
+    /**
+     * Initializes server related parameters.
+     *
+     * @param cfg the configuration properties for this class.
+     */
+    private void initServer(ConfigProperties cfg) {
+        //>>>> Setup parameters of the server itself
+        
+        // Port number of the server [default=104]
+        server.setPort(Integer.parseInt(cfg.getProperty("port", "104")));
+        // Maximum number of simultaneous clients [default=10].
+        server.setMaxClients(Integer.parseInt(cfg.getProperty("max-clients", "10")));
+        
+        //>>>> Setup parameters of the server handler
+        
+        // Time-out waiting [in msec] for A-ASSOCIATE-RQ after TCP connect. 0 is interpreted as an infinite timeout [default=5000].
+        handler.setRqTimeout(Integer.parseInt(cfg.getProperty("rq-timeout", "5000")));
+        // Time-out waiting [in msec] for DIMSE on open association. 0 is interpreted as an infinite timeout [default=0].
+        handler.setDimseTimeout(Integer.parseInt(cfg.getProperty("dimse-timeout", "0")));
+        // Time delay [in msec] for socket close after sending A-RELEASE-RP or A-ABORT [default=500].
+        handler.setSoCloseDelay(Integer.parseInt(cfg.getProperty("so-close-delay", "500")));
+        // Activates packing of command PDV (Presentation Data Value) + (first) data PDV into one P-DATA-TF PDU (Protocol Data Unit)
+        handler.setPackPDVs("true".equalsIgnoreCase(cfg.getProperty("pack-pdvs", "false")));
+    }
+    
+    
+    /**
+     * Initializes TLS (Transport Layer Security, predecessor of SSL, Secure 
+     * Sockets Layer) connection related parameters. TLS expects RSA (Ron Rivest, 
+     * Adi Shamir and Len Adleman) encoded keys and certificates.
+     *
+     * <p>Keys and certificates may be stored in PKCS #12 (Public Key 
+     * Cryptography Standards) or JKS (Java Keystore) containers.
+     *
+     * <p>TSL is used to encrypt data during transmission, which is accomplished 
+     * when the connection between the two partners A (normally the client) and B 
+     * (normally the server) is established. If A asks B to send TSL encrypted 
+     * data, both partners exchange some handshake information. In a first step 
+     * B tries to authentify itself against A (server authentification, optional 
+     * in TSL but implementet in this way in dcm4che). For that B presents its 
+     * public key for A to accept or deny. If the authentification is accepted, 
+     * A tries to authentify itself against B (client authentification, optional 
+     * in TSL but implementet in this way in dcm4che).If B accepts the 
+     * authentification A and B agree on a hash (symmetric key, which is 
+     * independent of the private/public keys used for authentification) for the 
+     * duration of their conversation, which is used to encrypt the data.
+     *
+     * <p>To be able to establish a TSL connection B needs a privat/public key 
+     * pair, which identifies B unambiguously. For that the private key is 
+     * generated first; than the root-public key is derived from that private 
+     * key. To bind the root-public key with the identity of B a Certificate 
+     * Authority (CA) is used: The root-public key is send to CA, which returns 
+     * a certified-public key, which includes information about the CA as well 
+     * as the root-public key. Optionally this process can be repeated several 
+     * times so that the certified-public key contains a chain of certificates 
+     * of different CA's.
+     *
+     * <p>The certified-public key of B is presented to A during server 
+     * authentification. Partner A should accept this key, if it can match the 
+     * last certificate in the chain with a root-certificat found in its local 
+     * list of root-certificates of CA's. That means, that A does not check the 
+     * identity of B, but "trusts" B because it was certified by an authority. 
+     * The same happens for client authentification. Handling of authentification 
+     * of the identity of the communication partner is subject of PS 3.15 - 
+     * Security and System Management Profiles.
+     *
+     * <p>In the configuration files of this method the certified-public key is 
+     * stored in the property "tls-key" and the root-certificates of the known 
+     * CA's in "tls-cacerts".
+     *
+     * <p>Usually the certified-public keys of A and B are different, but they 
+     * also may be the same. In this case the root-certificates are also the same.
+     *
+     * <p>It is possible to establish a TLS connection without using a CA: In 
+     * this case both partners creates a individual container holding their 
+     * private and root-public key. These containers could be used for certifying 
+     * also, because the length of the certifying chain is one and therefore the 
+     * root-public key is also the last certified-public key. Therefore the 
+     * root-public key works in this scenario also as the root-certificate of 
+     * the "certifying authoroty".
+     *
+     * <p>If no keystores are specified in the configuration properties, the 
+     * not-certified default-keystore "resources/identityJava.jks" is used for 
+     * "tls-key" and "tls-cacerts" when establishing the connection.
+     *
+     * @param cfg the configuration properties for this class.
+     * @throws ParseException
+     */
+    private void initTLS(ConfigProperties cfg) throws ParseException {
+        char[]  keystorepasswd;
+        char[]  keypasswd;
+        char[]  cacertspasswd;
+        URL     keyURL;
+        URL     cacertURL;
+        String  value;
+
+        try {
+            
+            // Get the requested protocol from the configuration properties
+            this.protocol = DcmProtocol.valueOf(cfg.getProperty("protocol", "dicom"));
+            
+            // If no TLS encryption is requested, nothing to do
+            if (!protocol.isTLS()) {
+                return;
+            }
+            
+            // Get a new TLS context
+            tls = SSLContextAdapter.getInstance();
+            
+            
+            //>>>> Managing the keystore file containing the privat key and
+            //>>>> certified-public key to establish the communication
+            
+            // Password of the keystore [default: secret]
+            keystorepasswd = cfg.getProperty("tls-keystore-passwd", "secret").toCharArray();
+            
+            // Password of the private key [default: secret]
+            keypasswd = cfg.getProperty("tls-key-passwd", "secret").toCharArray();
+            
+            // URL of the file containing the default-keystore
+            keyURL = CDimseService.class.getResource("resources/identityJava.jks");
+            
+            // If availabel, replace URL with the one specified in the configuration file
+            if ((value = cfg.getProperty("tls-key")) != null) {
+                try {
+                    // Property specified, try to set to specified value
+                    keyURL = ConfigProperties.fileRefToURL(CDimseService.class.getResource(""), value);
+                } catch (Exception e) {
+                    log.warn("Wrong value for tls-key: " + value + ". tls-key was set to default value.");
+                }
+            }
+            
+            // log.info("Key URL: " + keyURL.toString());
+            
+            // Sets the key attribute of the SSLContextAdapter object
+            // API doc: SSLContextAdapter.loadKeyStore(java.net.URL url, char[] password)
+            // API doc: SSLContextAdapter.setKey(java.security.KeyStore key, char[] password)
+            tls.setKey(tls.loadKeyStore(keyURL, keystorepasswd), keypasswd);
+            
+            //>>>> Managing the keystore containing the root-certificates of the Ceritifying Authorities
+            //>>>> used for signing the public key
+            
+            // Password of the keystore [default: secret]
+            cacertspasswd = cfg.getProperty("tls-cacerts-passwd", "secret").toCharArray();
+            
+            // URL of the file containing the default-keystore
+            cacertURL = CDimseService.class.getResource("resources/identityJava.jks");
+            
+            // If availabel, replace URL with the one specified in the configuration file
+            if ((value = cfg.getProperty("tls-cacerts")) != null) {
+                try {
+                    // Property specified, try to set to specified value
+                    cacertURL = ConfigProperties.fileRefToURL(CDimseService.class.getResource(""), value);
+                } catch (Exception e) {
+                    log.warn("Wrong value for tls-cacerts: " + value + ". tls-cacerts was set to default value.");
+                }
+            }
+            
+            // log.info("Root-certificat of CA URL: " + cacertURL.toString());
+            
+            // Sets the trust attribute of the SSLContextAdapter object
+            // API doc: SSLContextAdapter.loadKeyStore(java.net.URL url, char[] password)
+            // API doc: SSLContextAdapter.setTrust(java.security.KeyStore cacerts)
+            tls.setTrust(tls.loadKeyStore(cacertURL, cacertspasswd));
+            
+            // Get ciphers for selected protocol
+            this.server.setServerSocketFactory(tls.getServerSocketFactory(protocol.getCipherSuites()));
+            
+        } catch (Exception ex) {
+            throw new ParseException("Could not initialize TLS configuration.", 0);
+        }
+    }
+    
+    
+    /**
+     * Initializes acceptor policy related parameters.
+     *
+     * @param cfg the configuration properties for this class.
+     */
+    private void initPolicy(ConfigProperties cfg) {
+        
+        // Own AET (Application Entity Title).
+        // Default is null, that means no AET specified.
+        // The provided property value should be a comma or space separated list of individual AETs.
+        // The string "<any>" is interpreted also as null.
+        policy.setCalledAETs(cfg.tokenize(cfg.getProperty("called-aets", null, "<any>", null)));
+        
+        // AETs  (Application Entity Titles) of the storage service users.
+        // Default is null, that means association of any AET is accepted.
+        // The provided property value should be a comma or space separated list of individual AETs.
+        // The string "<any>" is interpreted also as null.
+        policy.setCallingAETs(cfg.tokenize(cfg.getProperty("calling-aets", null, "<any>", null)));
+        
+        // Maximal length of receiving PDUs (Protocol Data Unit) [default=16352]
+        policy.setMaxPDULength(Integer.parseInt(cfg.getProperty("max-pdu-len", "16352")));
+        
+        // Maximal number of invoked operations with outstanding response.
+        policy.setAsyncOpsWindow(Integer.parseInt(cfg.getProperty("max-op-invoked", "0")), 1);
+        
+        for (Enumeration it = cfg.keys(); it.hasMoreElements(); ) {
+            String key = (String) it.nextElement();
+            
+            // Setup available transfer syntaces for storage SOP classes
+            // PS 3.4 - Annex B STORAGE SERVICE CLASS
+            // PS 3.4 - B.5 STANDARD SOP CLASSES
+            if (key.startsWith("pc.")) {
+                initPresContext(key.substring(3), cfg.tokenize(cfg.getProperty(key)));
+            }
+            
+            // Setup user/provider role for Management Service Classes
+            // PS3.4 - Annex E PATIENT MANAGEMENT SERVICE CLASS (retired since 2004)
+            //                 -- Detached Patient Management SOP class
+            // PS3.4 - Annex G RESULTS MANAGEMENT SERVICE CLASS (retired since 2004)
+            //                 -- Detached Result Management SOP class
+            //                 -- Detached Interpretation Management SOP class
+            if (key.startsWith("role.")) {
+                initRole(key.substring(5), cfg.tokenize(cfg.getProperty(key)));
+            }
+        }
+    }
+    
+    
+    /**
+     * Only used by method initPolicy:
+     * Setsup available transfer syntaces for storage SOP classes.
+     * @param asName name of the storage SOP class (PS 3.4 - B.5 STANDARD SOP CLASSES)
+     * @param tsNames the list of transfer syntaces.
+     */
+    private void initPresContext(String asName, String[] tsNames) {
+        String as = UIDs.forName(asName);
+        String[] tsUIDs = new String[tsNames.length];
+        for (int i = 0; i < tsUIDs.length; ++i) {
+            tsUIDs[i] = UIDs.forName(tsNames[i]);
+        }
+        policy.putPresContext(as, tsUIDs);
+        services.bind(as, this);
+    }
+    
+    
+    /**
+     * Only used by method initPolicy:
+     * <p>Setup user/provider role for Management Service Classes.
+     * <p>PS3.4 - Annex E PATIENT MANAGEMENT SERVICE CLASS (retired since 2004)
+     * <p>                -- Detached Patient Management SOP class
+     * <p>PS3.4 - Annex G RESULTS MANAGEMENT SERVICE CLASS (retired since 2004)
+     * <p>                -- Detached Result Management SOP class
+     * <p>                -- Detached Interpretation Management SOP class
+     * @param asName the name of the Detached Management SOP class.
+     * @param roles the list of implemented roles. Enumerated: "scu" and "scp".
+     */
+    private void initRole(String asName, String[] roles) {
+        String as = UIDs.forName(asName);
+        policy.putRoleSelection(as, contains(roles, "scu"), contains(roles, "scp"));
+    }
+    
+    
+    /**
+     * Only used by method initRole:
+     * Returns true, if one of the Strings in roles are equal to the key String.
+     * @param roles an array of Strings.
+     * @param key a key to match.
+     */
+    private boolean contains(String[] roles, String key) {
+        for (int i = 0; i < roles.length; i++) {
+            if (key.equalsIgnoreCase(roles[i]))
+                return true;
+        }
+        return false;
+    }
+    
+    
+    /**
+     * Add a listener to StorageServiceClassEvenEvents.
+     * @param l the listener object.
+     */
+    public synchronized void addStorageServiceClassEventListener(StorageServiceEventListener l) {
+        // add a listener if it is not already registered
+        if (!eventListeners.contains(l)) {
+            eventListeners.addElement(l);
+        }
+    }
+    
+    
+    /**
+     * Removes a listener to StorageServiceClassEvenEvents.
+     * @param l the listener object.
+     */
+    public synchronized void removeStorageServiceClassEvenEventListener(StorageServiceEventListener l) {
+        // remove a listener if it is not already registered
+        if (eventListeners.contains(l)) {
+            eventListeners.removeElement(l);
+        }
+    }
+    
+    
+    /**
+     * Notify all listener to StorageServiceClassEvenEvents.
+     * @param evt the event object.
+     */
+    private void fireStorageServiceClassEvent(StorageServiceEvent evt) {
+        Vector v = null;
+        
+        // make a copy of the listener object so that it cannot be
+        // changed while we are firing events
+        synchronized(this) {
+            v = (Vector) eventListeners.clone();
+        }
+        
+        // fire the events
+        for (int i = 0; i < v.size(); i++) {
+            StorageServiceEventListener client = (StorageServiceEventListener) v.elementAt(i);
+            client.handleStorageServiceEvent(evt);
+        }
+    }
+    
+    
+    /**
+     *  Start the server.
+     *
+     * @exception  IOException
+     */
+    public void start() throws IOException {
+        server.start();
+    }
+    
+    
+    /**
+     * Stops the server.
+     */
+    public void stop() {
+        server.stop();
+    }
+    
+    
+    /**
+     * If a DICOM object is received,this method is automatically invoken by the 
+     * server implementation of the toolkit. This method extracts the Dataset of 
+     * this object is send to registered listeners as a StorageServiceEvent.
+     * <p>
+     * <p>Overwrites the doCStore method of the parent class DcmServiceBase.
+     * 
+     * @param assoc
+     * @param rq
+     * @param rspCmd
+     * @exception IOException
+     */
+    public void doCStore(ActiveAssociation assoc, Dimse rq, Command rspCmd) throws IOException {
+        Command rqCmd = rq.getCommand();
+        FileMetaInfo fmi = objFact.newFileMetaInfo(rqCmd.getAffectedSOPClassUID(), rqCmd.getAffectedSOPInstanceUID(), rq.getTransferSyntaxUID());
+        
+        // Send the event
+        
+        //System.out.println("Inside DoCCStore");
+        fireStorageServiceClassEvent(new StorageServiceEvent(this, rq.getDataset()));
+        
+        if (rspDelay > 0L) {
+            try {
+                Thread.sleep(rspDelay);
+            } catch (InterruptedException ie) {
+                log.error(ie.getMessage());
+            }
+        }
+        rspCmd.putUS(Tags.Status, rspStatus);
+    }
+    
+}
+
diff --git a/src/de/iftm/dcm4che/services/StorageServiceAdapter.java b/src/de/iftm/dcm4che/services/StorageServiceAdapter.java
new file mode 100644
index 0000000..9dc0b31
--- /dev/null
+++ b/src/de/iftm/dcm4che/services/StorageServiceAdapter.java
@@ -0,0 +1,554 @@
+/*
+ * Copyright (C) 2006 Thomas Hacklaender
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 2
+ * as published by the Free Software Foundation.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+package de.iftm.dcm4che.services;
+
+import java.io.*;
+import java.text.ParseException;
+
+import org.dcm4che.data.*;
+import org.dcm4che.net.*;
+import org.dcm4che.dict.*;
+
+import org.apache.log4j.*;
+
+
+/**
+ * Implementation of an adapter class for the StorageService. It implements
+ * the StorageServiceEventListener to receive StorageServiceEvent when
+ * the server receives an DICOM object. The adapter class stores the received object
+ * into the local filesystem.
+ * <p>Details of how to run the server is given in another configuration property file.
+ * A sample may be found at "resources/StorageService.cfg".
+ * <p>The details how to store the object is given in a configuration property file.
+ * A sample may be found at "resources/SaveFilesystem.cfg".
+ *
+ * @author Thomas Hacklaender
+ * @version 2006-06-21
+ */
+public class StorageServiceAdapter implements StorageServiceEventListener {
+    
+    /** Initialize logger */
+    private static Logger log = Logger.getLogger(StorageServiceAdapter.class);
+    
+    /** The configuration properties of the DcmRcv working class. */
+    private ConfigProperties cfgStorageSC = null;
+    
+    /** The configuration properties for saving the DICOM objects to the filesystem. */
+    private ConfigProperties cfgSaveFilesystem = null;
+    
+    /** The server. */
+    private StorageService storageSC = null;
+    
+    
+    //>>>> Local fields defined in configuration properties for sving to filesystem >>>>
+    
+    /** Directory to save the Dataset */
+    private File directory = ConfigProperties.uriToFile("./");
+    
+    /** Extension of the file to save */
+    private String extension = "dcm";
+    
+    /**
+     * Name of file to save. If the String starts with the character '$' the filename
+     * is set from the DICOM element named in the remaining part of the string. */
+    private String filename = "DICOM_object";
+    
+    /** If true, write files in the subdirectory "$PatientName_$PatientBirthDate/<directory>/" */
+    private boolean separate_patients = false;
+    
+    /** Transfersyntax of the saved file. One of the strings  ImplicitVRLittleEndian,
+     * ExplicitVRLittleEndian, ExplicitVRBigEndian. The string may start with
+     * the praefix-character '$' */
+    private String transfersyntax = "ImplicitVRLittleEndian";
+    
+    /** Write files in the subdirectory "[$PatientName_$PatientBirthDate/]<directory>/<use_subdirectory>/". */
+    private String use_subdirectory = "";
+    
+    /**
+     * If true:
+     * Construct the the file ID of the file to save from the following file ID
+     * components:
+     * <p>1. First letter of family name followed by first letter of given name
+     * followed by date of birth, 6 character. Example: HT570522
+     * <p>2. Study date, 6 character. Example: 043012
+     * <p>3. Modality, 2 character followed by study time, 4 character. Example: MR1531
+     * <p>4. Study ID. Example: 4711
+     * <p>5. Series number. Example: 3
+     * <p>6. Instance number. Example: 54
+     * <p><p>If false:
+     * <p>Construct the the name of the file to save from directory, filename and extension. */
+    private boolean write_dir_tree = true;
+    
+    /** Include a File Meta Information block to the saved file. */
+    private boolean write_fmi = true;
+    
+    
+    //>>>> Constructor >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+    
+    /**
+     * Creates a new instance of StorageServiceAdapter.
+     *
+     * @throws ParseException in case of a parsing error of the configuration properties.
+     */
+    public StorageServiceAdapter(ConfigProperties cfgStorageSC, ConfigProperties cfgSaveFilesystem) throws ParseException {
+        // Store configuration properties local
+        this.cfgStorageSC = cfgStorageSC;
+        this.cfgSaveFilesystem = cfgSaveFilesystem;
+        
+        // Initializelocal fields from the configuration properties for saving to filesystem
+        initFieldsFromCfgSaveFilesystem();
+        
+        // Initialize the working class with the actual configuration properties.
+        storageSC = new StorageService(cfgStorageSC);
+        
+        // Register to server as a listener for StorageServiceClassEvents
+        storageSC.addStorageServiceClassEventListener(this);
+    }
+    
+    
+    /**
+     * Return the working class StorageService. This can be usedto add additional 
+     * listeners for ServiceClassEvent's.
+     *
+     * @return the working class StorageService.
+     */
+    public StorageService getStorageService() {
+        return storageSC;
+    }
+    
+    /**
+     * Starts the server.
+     *
+     * @throws IOException 
+     */
+    public void start() throws IOException {
+        // Start the instance of the working class
+        storageSC.start();
+    }
+    
+    
+    /**
+     * Stops the server.
+     */
+    public void stop() {
+        storageSC.stop();
+    }
+    
+    
+    /**
+     * Handles StorageServiceClassEvents send from the server.
+     *
+     * @param e the StorageServiceEvent send from the server.
+     */
+    public void handleStorageServiceEvent(StorageServiceEvent e) {
+        File     parent = null;
+        File     dcmFile = null;
+        String   value;
+        Dataset  ds = e.getDataset();
+        
+        // log.info(">>>> Received: " + ds.getString(Tags.Modality) + " : "+ ds.getString(Tags.SOPClassUID));
+        
+        // If no Dataset: nothing to do
+        if (ds == null) {
+            log.warn("No Dataset received.");
+            return;
+        }
+        
+        // Filename may be derived from received DICOM object
+        value = cfgSaveFilesystem.getProperty("file-name");
+        
+        if (value != null) {
+            filename = getTagStringOrValue(value, ds);
+            if (filename == null) {
+                log.error("Can't find element" + value.substring(1) +  " in received Dataset.");
+                return;
+            }
+        }
+        
+        // Set working directory
+        parent = directory;
+        if (separate_patients) {
+            parent = addPatientDirectory(parent, ds);
+        }
+        
+        // Dataset toFile
+        if ((dcmFile = createFilePathToSave(parent, ds)) == null) {
+            log.error("Could not craete File from Dataset.");
+            return;
+        }
+        
+        // Exportieren file containing DICOM object
+        if (! saveDataset(ds, dcmFile)) {
+            log.error("Could not save File.");
+            return;
+        }
+    }
+    
+    
+    //>>>> Methods for storing a received DICOM object to the filesystem >>>>>>
+    
+    /**
+     * Inits local fieldfrom the configuration properties.
+     */
+    public void initFieldsFromCfgSaveFilesystem() {
+        String value;
+        File   newDirectory;
+        
+        value = cfgSaveFilesystem.getProperty("directory");
+        if (value != null) {
+            if ((newDirectory = ConfigProperties.uriToFile(value)) != null) {
+                directory = newDirectory;
+            }
+        }
+        
+        value = cfgSaveFilesystem.getProperty("file-extension");
+        if (value != null) {
+            extension = value;
+        }
+        
+        value = cfgSaveFilesystem.getProperty("separate-patients");
+        if (value != null) {
+            if (value.toLowerCase().charAt(0) == 't') {
+                separate_patients = true;
+            } else {
+                separate_patients = false;
+            }
+        }
+        
+        value = cfgSaveFilesystem.getProperty("transfersyntax");
+        if (value != null) {
+            if (value.charAt(0) == '$') {
+                transfersyntax = value.substring(1);
+            } else {
+                transfersyntax = value;
+            }
+        }
+        
+        value = cfgSaveFilesystem.getProperty("use-subdirectory");
+        if (value != null) {
+            use_subdirectory = value;
+        }
+        
+        value = cfgSaveFilesystem.getProperty("write-dir-tree");
+        if (value != null) {
+            if (value.toLowerCase().charAt(0) == 't') {
+                write_dir_tree = true;
+            } else {
+                write_dir_tree = false;
+            }
+        }
+        
+        value = cfgSaveFilesystem.getProperty("write-fmi");
+        if (value != null) {
+            if (value.toLowerCase().charAt(0) == 't') {
+                write_fmi = true;
+            } else {
+                write_fmi = false;
+            }
+        }
+    }
+    
+    
+    /**
+     * Create the file path of the file to save in the directory parent
+     * depending of the property use_subdirectory.
+     * @param parent the working directory.
+     * @param ds the dataset to analyse.
+     * @return the file.
+     */
+    protected File createFilePathToSave(File parent, Dataset ds) {
+        File path;
+        
+        if (use_subdirectory != null) {
+            if (! use_subdirectory.equals("")) {
+                parent = new File(parent, use_subdirectory);
+            }
+        }
+        
+        if (write_dir_tree) {
+            path = new File(parent, datasetToTreeFileID(ds));
+        } else {
+            // Direkt in das angegebene Verzeichnis speichern
+            path = new File(parent, filename + "." + extension);
+        }
+        
+        return path;
+    }
+    
+    
+    /**
+     * Saves the Dataset to the local filesystem.
+     *
+     * @param ds the Dataset to save.
+     * @param f the File to which the Dataset should be save.
+     */
+    protected boolean saveDataset(Dataset ds, File f) {
+        FileOutputStream fos = null;
+        DcmEncodeParam param = null;
+        FileMetaInfo fmi;
+        
+        try {
+            if (f.exists()) {
+                // File besteht bereits. Erst loeschen, dann neu erstellen
+                f.delete();
+                f.createNewFile();
+            } else {
+                if (!f.getParentFile().exists()) {
+                    // Directory Pfad existiert noch nicht
+                    f.getParentFile().mkdirs();
+                }
+            }
+            
+            fos = new FileOutputStream(f);
+            param = DcmEncodeParam.valueOf(UIDs.forName(transfersyntax));
+            
+            // File mit/ohne File Meta Information Block schreiben
+            if (write_fmi) {
+                fmi = DcmObjectFactory.getInstance().newFileMetaInfo(ds,
+                    UIDs.forName(transfersyntax));
+                ds.setFileMetaInfo(fmi);
+                
+                // Die Methode Dataset#writeFile schreibt -sofern != null- einen
+                // File Meta Information Block und ruft dann Dataset#writeDataset
+                // mit den selben Parametern auf.
+                ds.writeFile(fos, param);
+                
+                // File Meta Information Block wieder loeschen
+                ds.setFileMetaInfo(null);
+            } else {
+                ds.writeDataset(fos, param);
+            }
+            
+            // Finished without errors
+            return true;
+            
+        } catch (Exception e) {
+            log.error("Can't save file - Exception: " + e.getMessage());
+            
+            return false;
+        } finally {
+            try {
+                fos.close();
+            } catch (Exception ignore) {ignore.printStackTrace();}
+        }
+    }
+    
+    
+    /**
+     * Builds a file ID from the given Dataset. Components are separated by
+     * the '/' caharcter:<br>
+     * 1. componet: First letter of family name followed by first letter of given
+     * name followed by date of birth, 6 character. Example: TH570522<br>
+     * 2. componet: Study date, 6 character. Example: 043012<br>
+     * 3. componet: Modality, 2 character followed by study time, 4 character.
+     * Example: MR1531<br>
+     * 4. componet: Study ID. Example: 4711<br>
+     * 5. componet: Series number. Example: 3<br>
+     * 6. componet: Instance number. Example: 54<br>
+     * All components are compatible to DICOM part 12, e.g. they have a maximum
+     * of 8 characters and consists of upper case caracters, numbers or '_'.
+     * @param ds the dataset to analyse.
+     * @return the file ID as a absolute pathString.
+     */
+    protected String datasetToTreeFileID(Dataset ds) {
+        String[] nameArray;
+        String pathString;
+        
+        nameArray = datasetToNameArray(ds);
+        
+        pathString = nameArray[0];
+        for (int i = 1; i < nameArray.length; i++) {
+            pathString += "/" + nameArray[i];
+        }
+        
+        return pathString;
+    }
+    
+    
+    /**
+     * Builds an array of strings from the given Dataset:<br>
+     * [0]: First letter of famely name followed by first letter of given
+     * name followed by date of birth, 6 character. Example: TH570522<br>
+     * [1]: Study date, 6 character. Example: 043012<br>
+     * [2]: Modality, 2 character followed by study time, 4 character.
+     * Example: MR1531<br>
+     * [3]: Study ID. Example: 4711<br>
+     * [4]: Series number. Example: 3<br>
+     * [5]: Instance number. Example: 54<br>
+     * All components are compatible to DICOM part 12, e.g. they have a maximum
+     * of 8 characters and consists of upper case caracters, numbers or '_'.
+     * @param ds the dataset to analyse.
+     * @return the array of strings.
+     */
+    protected String[] datasetToNameArray(Dataset ds) {
+        String  s;
+        String  pn;
+        int i;
+        String[] nameArray = new String[6];
+        
+        String patientName = ds.getString(Tags.PatientName, "X^X");
+        String patientBirthDate = ds.getString(Tags.PatientBirthDate, "19990101");
+        String studyDate = ds.getString(Tags.StudyDate, "20050101");
+        String studyTime = ds.getString(Tags.StudyTime, "123456.789");
+        String modality = ds.getString(Tags.Modality, "OT");
+        String studyID = ds.getString(Tags.StudyID, "0");
+        String seriesNumber = ds.getString(Tags.SeriesNumber, "0");
+        String instanceNumber = ds.getString(Tags.InstanceNumber, "0");
+        
+        // Patientenname mindestens 2 Buchstaben lang machen
+        pn = patientName + "XX";
+        
+        s = pn.substring(0, 1);
+        i = pn.indexOf('^');
+        if (i != -1) {
+            // Vorname vorhanden
+            s += pn.substring(i + 1, i + 2);
+        } else {
+            // Kein Vorname vorhanden, die erstenb zwei Buchstaben des Nachnamens verwenden
+            s = pn.substring(0, 2);
+        }
+        
+        s += patientBirthDate.substring(2);
+        nameArray[0] = stringToFileIDComponentString(s);
+        
+        s = studyDate.substring(2);
+        nameArray[1] = stringToFileIDComponentString(s);
+        
+        s = modality.substring(0, 2);
+        s += studyTime.substring(0, 4);
+        nameArray[2] = stringToFileIDComponentString(s);
+        
+        nameArray[3] = stringToFileIDComponentString(studyID);
+        
+        nameArray[4] = stringToFileIDComponentString(seriesNumber);
+        
+        nameArray[5] = stringToFileIDComponentString(instanceNumber);
+        
+        return nameArray;
+    }
+    
+    
+    /**
+     * Checks, if the given file ID is compatible to DICOM Part 12:
+     * It may only contain the characters 'A'..'Z','0'..'9' and '_'. The
+     * maximal length is 8 character.
+     * This method truncates the file ID after 8 characters, converts lower case
+     * to upper case characters and replaces all other not valid characters with
+     * the '_' character.
+     * @param s the file ID to check.
+     * @return the converted file ID.
+     */
+    protected String stringToFileIDComponentString(String s) {
+        if ((s == null) || (s.length() == 0)) {
+            return "__NULL__";
+        }
+        
+        char[] in = s.toUpperCase().toCharArray();
+        char[] out = new char[Math.min(8, in.length)];
+        
+        for (int i = 0; i < out.length; ++i) {
+            out[i] = (((in[i] >= '0') && (in[i] <= '9')) ||
+                ((in[i] >= 'A') && (in[i] <= 'Z'))) ? in[i] : '_';
+        }
+        
+        return new String(out);
+    }
+    
+    
+    /**
+     * Adds a subdirectory to a given path. The name of the subdirectory is
+     * composed of the patients name followed by '_' followed by the birthdate.
+     * @param parent the parent directory.
+     * @param ds the dataset to analyse.
+     * @return the composed directory.
+     */
+    protected File addPatientDirectory(File parent, Dataset ds) {
+        String patientName = ds.getString(Tags.PatientName, "X^X");
+        String patientBirthDate = ds.getString(Tags.PatientBirthDate, "19990101");
+        return new File(parent, patientName + "_" + patientBirthDate);
+    }
+    
+    
+    /**
+     * Returns the given value or, if it is a "Tag String", the contents of the tag.
+     * Tag Strings are value starts wich start with the '$' character it is a
+     * reference by name or with '@' if it is a reference by group/element.
+     * @param value the property value.
+     * @param ds the dataset to analyse.
+     * @return the value or content of tag. null, if unknown tag.
+     */
+    protected String getTagStringOrValue(String value, Dataset ds) {
+        int tag = getTagFromPropertyString(value);
+        
+        // Falls kein Tag String -> value zurueckgeben
+        if (tag <= 0) {
+            return value;
+        }
+        
+        // Ist ein Tag -> dessen Inhalt zurueckgeben
+        try {
+            return ds.getString(tag);
+        } catch (Exception e) {
+            return null;
+        }
+        
+    }
+    
+    
+    /**
+     * Returns the tag described by a given value. If the value starts with the
+     * '$' character it is a reference by name, if it starts with '@' it is a
+     * reference by group/element.
+     * @param value the property value.
+     * @return the tag. 0, if value does not begin with '$' or '@'. -1, if unknown tag.
+     */
+    protected int getTagFromPropertyString(String value) {
+        final int       NO_TAG = 0;
+        final int       UNKNOWN_TAG = -1;
+        int             tag;
+        TagDictionary   td = DictionaryFactory.getInstance().getDefaultTagDictionary();
+        
+        if (value.length() == 0) return NO_TAG;
+        
+        if (value.charAt(0) == '$') {
+            try {
+                tag = Tags.forName(value.substring(1));
+                return tag;
+            } catch (IllegalArgumentException e) {
+                return UNKNOWN_TAG;
+            }
+        }
+        
+        if (value.charAt(0) == '@') {
+            // Reference by group/element
+            try {
+                tag = Integer.parseInt(value.substring(1), 16);
+                TagDictionary.Entry e = td.lookup(tag);
+                if (e != null) {
+                    return tag;
+                } else {
+                    return UNKNOWN_TAG;
+                }
+            } catch (NumberFormatException e) {
+                return UNKNOWN_TAG;
+            }
+        }
+        
+        return NO_TAG;
+    }
+    
+}
diff --git a/src/de/iftm/dcm4che/services/StorageServiceEvent.java b/src/de/iftm/dcm4che/services/StorageServiceEvent.java
new file mode 100644
index 0000000..f5c2ecc
--- /dev/null
+++ b/src/de/iftm/dcm4che/services/StorageServiceEvent.java
@@ -0,0 +1,103 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is part of dcm4che, an implementation of DICOM(TM) in
+ * Java(TM), hosted at http://sourceforge.net/projects/dcm4che.
+ *
+ * The Initial Developer of the Original Code is
+ * TIANI Medgraph AG.
+ * Portions created by the Initial Developer are Copyright (C) 2002-2005
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Gunter Zeilinger <gunter.zeilinger at tiani.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package de.iftm.dcm4che.services;
+
+import java.util.*;
+
+import org.dcm4che.data.*;
+
+import org.apache.log4j.*;
+
+
+/**
+ * Implements the StorageServiceEvent.
+ * 
+ * @author Thomas Hacklaender
+ * @version 2006-06-21
+ */
+public class StorageServiceEvent extends java.util.EventObject {
+    
+    /** Initialize logger */
+    private static Logger log = Logger.getLogger(StorageServiceEvent.class);
+
+    /** The Dataset send as content of the event. */
+    private Dataset dataset = null;
+ 
+    
+    /**
+     * Creates a new instance of StorageServiceEvent.
+     * 
+     * @param source the object which fires the event.
+     */
+    public StorageServiceEvent(Object source) {
+        // pass the source object to the supercalss
+        super(source);
+    }
+
+    
+    /**
+     * Creates a new instance of StorageServiceEvent.
+     * 
+     * @param source the object which fires the event.
+     * @param ds the Dataset as content of the event.
+     */
+    public StorageServiceEvent(Object source, Dataset ds) {
+        // pass the source object to the supercalss
+        super(source);
+        setSelectedFiles(ds);
+    }
+    
+    
+    /**
+     * Sets the content of the event.
+     * @param ds the Dataset as content of the event.
+     */
+    public void setSelectedFiles(Dataset ds) {
+         dataset = ds;
+   }
+    
+    
+    /**
+     * Gets the content of the event.
+     * @return the content as a Dataset.
+     */
+    public Dataset getDataset() {
+        return dataset;
+    }
+ 
+}
diff --git a/src/de/iftm/dcm4che/services/StorageServiceEventListener.java b/src/de/iftm/dcm4che/services/StorageServiceEventListener.java
new file mode 100644
index 0000000..8686c6b
--- /dev/null
+++ b/src/de/iftm/dcm4che/services/StorageServiceEventListener.java
@@ -0,0 +1,55 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is part of dcm4che, an implementation of DICOM(TM) in
+ * Java(TM), hosted at http://sourceforge.net/projects/dcm4che.
+ *
+ * The Initial Developer of the Original Code is
+ * TIANI Medgraph AG.
+ * Portions created by the Initial Developer are Copyright (C) 2002-2005
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Gunter Zeilinger <gunter.zeilinger at tiani.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package de.iftm.dcm4che.services;
+
+/**
+ * Interface, which all listeners of StorageServiceEvent must be implement.
+ *
+ * @author Thomas Hacklaender
+ * @version 2006-06-21
+ */
+public interface StorageServiceEventListener extends java.util.EventListener {
+    
+    
+    /**
+     * Handles StorageSCPServiceEvents.
+     * @param evt the event to hanle.
+     */
+    public void handleStorageServiceEvent(StorageServiceEvent evt);
+    
+}
diff --git a/src/in/raster/mayam/context/ApplicationContext.java b/src/in/raster/mayam/context/ApplicationContext.java
new file mode 100644
index 0000000..86397cf
--- /dev/null
+++ b/src/in/raster/mayam/context/ApplicationContext.java
@@ -0,0 +1,168 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.context;
+
+import in.raster.mayam.facade.Platform;
+import in.raster.mayam.util.database.DatabaseHandler;
+import in.raster.mayam.form.SendingProgress;
+import in.raster.mayam.form.AnnotationPanel;
+import in.raster.mayam.form.ImagePanel;
+import in.raster.mayam.form.ImageView;
+import in.raster.mayam.form.LayeredCanvas;
+import in.raster.mayam.form.MainScreen;
+import in.raster.mayam.form.SeriesPanel;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.dcm4che.util.DcmURL;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class ApplicationContext {
+
+    //Database Interaction Referrence object
+    public static DatabaseHandler databaseRef = DatabaseHandler.getInstance();
+    //Application specific log file reference
+    public static File logFile;
+    //Context reference for ImageView
+    public static ImageView imgView;
+    //Context reference for ImagePanel
+    public static ImagePanel imgPanel;
+    //Context reference for annotation overlay
+    public static AnnotationPanel annotationPanel;
+    //Context reference for Tile
+    public static LayeredCanvas layeredCanvas;
+    public static DcmURL moveScuUrl;
+    //MainScreen singleton object
+    public static MainScreen mainScreen;
+    //Context reference for SeriesPanel
+    public static SeriesPanel selectedSeriesPanel = null;
+    //Context reference for SendingProgress
+    public static SendingProgress sendingProgress;
+
+    public static String applicationName="Mayam";
+
+    private ApplicationContext() {
+    }
+
+    /**
+     * This routine used to create a new image view
+     */
+    public static void createImageView() {
+        imgView = new ImageView();
+        imgView.setVisible(true);
+    }
+
+    /**
+     * This routine used to init the driver and open database if it is already created,
+     * otherwise it will create a new database
+     */
+    public static void openOrCreateDB() {
+        databaseRef.openOrCreateDB();
+    }
+
+    /**
+     * This routine used to create log file if does not exist
+     */
+    public static void createLogFile() {
+        logFile = new File(getAppDirectory() + File.separator, "log.txt");
+        if (!logFile.exists()) {
+            try {
+                logFile.createNewFile();
+            } catch (IOException ex) {
+                logFile = new File(System.getProperty("java.io.tmpdir") + File.separator, "log.txt");
+                if (!logFile.exists()) {
+                    try {
+                        logFile.createNewFile();
+                    } catch (IOException x) {
+                        Logger.getLogger(ApplicationContext.class.getName()).log(Level.SEVERE, null, ex);
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * This routine used to check whether the image view exist or not
+     * @return
+     */
+    public static boolean imageViewExist() {
+        if (imgView != null) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    public static String getAppDirectory()
+    {
+        return Platform.getAppDirectory(applicationName).getAbsolutePath();
+    }
+    /**
+     * This routine used to write a log message
+     * @param logMsg
+     */
+    public static void writeLog(String logMsg) {
+        DateFormat df = new SimpleDateFormat("kk:mm:ss");
+        Date d = new Date();
+        FileOutputStream fileOutputStream = null;
+        try {
+            String logMessage = df.format(d) + ", " + logMsg;
+            fileOutputStream = new FileOutputStream(logFile, true);
+            fileOutputStream.write(logMessage.getBytes());
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        } finally {
+            try {
+                fileOutputStream.close();
+            } catch (IOException ex) {
+                ex.printStackTrace();
+            }
+        }
+    }
+}
diff --git a/src/in/raster/mayam/delegate/AnnotationDelegate.java b/src/in/raster/mayam/delegate/AnnotationDelegate.java
new file mode 100755
index 0000000..ca96a98
--- /dev/null
+++ b/src/in/raster/mayam/delegate/AnnotationDelegate.java
@@ -0,0 +1,240 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.delegate;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.form.LayeredCanvas;
+import in.raster.mayam.form.LayoutManagerPanel;
+import in.raster.mayam.form.MainScreen;
+import in.raster.mayam.model.Instance;
+import in.raster.mayam.model.Series;
+import in.raster.mayam.model.Study;
+import in.raster.mayam.util.measurement.InstanceAnnotation;
+import in.raster.mayam.util.measurement.SeriesAnnotation;
+import in.raster.mayam.util.measurement.StudyAnnotation;
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.swing.*;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.ObjectOutputStream;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.6
+ *
+ */
+public class AnnotationDelegate {
+
+    public AnnotationDelegate() {
+    }
+
+    /**
+     * This method used to save the annotation information to the file.
+     *
+     * @param i
+     */
+    public void saveAnnotation(int i) {
+        Study studyTobeDelete = null;
+        LayeredCanvas tempCanvas = null;
+        StudyAnnotation studyAnnotation = new StudyAnnotation();
+        for (int x = 0; x < ((JPanel) ApplicationContext.imgView.jTabbedPane1.getComponent(i)).getComponentCount(); x++) {
+            if (((JPanel) ApplicationContext.imgView.jTabbedPane1.getComponent(i)).getComponent(x) instanceof LayeredCanvas) {
+                tempCanvas = ((LayeredCanvas) ((JPanel) ApplicationContext.imgView.jTabbedPane1.getComponent(i)).getComponent(x));
+                File instanceFile = new File(tempCanvas.imgpanel.getDicomFileUrl());
+                String studyDir = instanceFile.getParent();
+                for (Study study : MainScreen.studyList) {
+                    if (study.getStudyInstanceUID().equalsIgnoreCase(tempCanvas.imgpanel.getStudyUID())) {
+                        studyTobeDelete = study;
+                        studyAnnotation.setStudyUID(study.getStudyInstanceUID());
+                        if (ApplicationContext.databaseRef.getMultiframeStatus()) {
+                            sepMultiframeModelSave(study, studyAnnotation);
+                        } else {
+                            defaultModelSave(study, studyAnnotation);
+                        }
+                    }
+                }
+                writeToFile(studyDir, studyAnnotation);
+                //RemoveStudy.removeStudyFromStudylist(studyTobeDelete);
+                removeStudyFromStudylist(studyTobeDelete);
+                break;
+            }
+        }
+    }
+
+    /**
+     * This Method used to update instanceAnnotation object based on the details of the instance
+     * (multiframe instance are condisered as seperate series)
+     * If Multiframe instance are considered as a seperate series so that it will concat the
+     * annotation of this series  with the original series.
+     * @param study
+     * @param studyAnnotation
+     */
+    public void sepMultiframeModelSave(Study study, StudyAnnotation studyAnnotation) {
+        for (Series series : study.getSeriesList()) {
+            SeriesAnnotation seriesAnnotation = (SeriesAnnotation) studyAnnotation.getSeriesAnnotation().get(series.getSeriesInstanceUID());
+            if (seriesAnnotation == null) {
+                seriesAnnotation = new SeriesAnnotation();
+                seriesAnnotation.setSeriesUID(series.getSeriesInstanceUID());
+            }
+            for (Instance instance : series.getImageList()) {
+                InstanceAnnotation instanceAnnotation = null;
+                if (!series.isMultiframe()) {
+                    instanceAnnotation = new InstanceAnnotation(instance.getAnnotation());
+                } else {
+                    instanceAnnotation = new InstanceAnnotation(instance.getAnnotations());
+                }
+                instanceAnnotation.setInstanceUID(instance.getSop_iuid());
+                instanceAnnotation.setMultiframe(series.isMultiframe());
+                seriesAnnotation.getInstanceArray().put(instance.getSop_iuid(), instanceAnnotation);
+            }
+            studyAnnotation.getSeriesAnnotation().put(series.getSeriesInstanceUID(), seriesAnnotation);
+        }
+    }
+
+    /**
+     * This Method used to update instanceAnnotation object based on the details of the instance
+     * (multiframe instance are not condisered as seperate series)
+     * Single series level SeriesAnnotation object has been used store all the instance such as
+     * single frame and multiframe instances.
+     * multiframe instance will have annotations hashmap to hold all the frame level annotation states.
+     *
+     * @param study
+     * @param studyAnnotation
+     */
+    public void defaultModelSave(Study study, StudyAnnotation studyAnnotation) {
+        for (Series series : study.getSeriesList()) {
+            SeriesAnnotation seriesAnnotation = new SeriesAnnotation();
+            seriesAnnotation.setSeriesUID(series.getSeriesInstanceUID());
+            for (Instance instance : series.getImageList()) {
+                InstanceAnnotation tempAnnotation = null;
+                if (seriesAnnotation != null && seriesAnnotation.getInstanceArray() != null) {
+                    tempAnnotation = (InstanceAnnotation) seriesAnnotation.getInstanceArray().get(instance.getSop_iuid());
+                }
+                if (instance.isMultiframe()) {
+                    if (tempAnnotation != null) {
+                        tempAnnotation.getAnnotations().put(instance.getCurrentFrameNum(), instance.getAnnotation());
+                    } else {
+                        InstanceAnnotation instanceAnnotation = new InstanceAnnotation();  //When adding first image it has been considered as single frame instance so annotation will have the value.
+                        instanceAnnotation.getAnnotations().put(instance.getCurrentFrameNum(), instance.getAnnotation());
+                        seriesAnnotation.getInstanceArray().put(instance.getSop_iuid(), instanceAnnotation);
+                    }
+                } else {
+                    InstanceAnnotation instanceAnnotation = new InstanceAnnotation(instance.getAnnotation());
+                    seriesAnnotation.getInstanceArray().put(instance.getSop_iuid(), instanceAnnotation);
+                }
+            }
+            studyAnnotation.getSeriesAnnotation().put(series.getSeriesInstanceUID(), seriesAnnotation);
+        }
+    }
+
+    /**
+     *
+     * @param studyDir
+     * @param studyAnnotation
+     */
+    private void writeToFile(String studyDir, StudyAnnotation studyAnnotation) {
+        ObjectOutputStream oos = null;
+        try {
+            File storeFile = new File(studyDir, "info.ser");           
+                FileOutputStream fos = new FileOutputStream(storeFile);
+                oos = new ObjectOutputStream(fos);
+                oos.writeObject(studyAnnotation);
+            
+        } catch (IOException ex) {
+            Logger.getLogger(AnnotationDelegate.class.getName()).log(Level.SEVERE, null, ex);
+        } catch (Exception ex) {
+            Logger.getLogger(AnnotationDelegate.class.getName()).log(Level.SEVERE, null, ex);
+        } finally {
+            try {
+                if (oos != null) {
+                    oos.close();
+                }
+            } catch (IOException ex) {
+                Logger.getLogger(AnnotationDelegate.class.getName()).log(Level.SEVERE, null, ex);
+            }
+        }
+    }
+
+    public void storeAnnotationHook(int i) {
+        for (int j = 0; j < ((JPanel) ApplicationContext.imgView.jTabbedPane1.getComponent(i)).getComponentCount(); j++) {
+            try {
+                if (((JPanel) ApplicationContext.imgView.jTabbedPane1.getComponent(i)).getComponent(j) instanceof LayeredCanvas) {
+                    LayeredCanvas tempCanvas = ((LayeredCanvas) ((JPanel) ApplicationContext.imgView.jTabbedPane1.getComponent(i)).getComponent(j));
+                    if (tempCanvas.imgpanel != null) {
+                        tempCanvas.imgpanel.storeAnnotation();
+                    }
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    public synchronized void removeStudyFromStudylist(Study study) {
+        if (MainScreen.selectedStudy.equalsIgnoreCase(study.getStudyInstanceUID())) {
+            if (!LayoutManagerPanel.updateSeries) {
+                for (Study tempStudy : MainScreen.studyList) {
+                    synchronized (MainScreen.studyList) {
+                        if (tempStudy.getStudyInstanceUID().equalsIgnoreCase(study.getStudyInstanceUID())) {
+                            synchronized (tempStudy.getSeriesList()) {
+                                Series notTobeDeleted = null;
+                                for (Series series : tempStudy.getSeriesList()) {
+                                    if (series.getSeriesInstanceUID().equalsIgnoreCase(MainScreen.selectedSeries)) {
+                                        notTobeDeleted = series;
+                                        break;
+                                    }
+                                }
+                                tempStudy.getSeriesList().clear();
+                                tempStudy.addSeries(notTobeDeleted);
+                                notTobeDeleted = null;
+                            }
+                        }
+                    }
+                }
+            } else {
+                MainScreen.studyList.remove(study);
+            }
+        } else {
+            MainScreen.studyList.remove(study);
+        }
+    }
+}
diff --git a/src/in/raster/mayam/delegate/Anonymize.java b/src/in/raster/mayam/delegate/Anonymize.java
new file mode 100644
index 0000000..fa65c6b
--- /dev/null
+++ b/src/in/raster/mayam/delegate/Anonymize.java
@@ -0,0 +1,73 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.delegate;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.model.Instance;
+import in.raster.mayam.model.Series;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class Anonymize {
+ public void studyLevelConvertor(String siuid)
+    {
+         ArrayList<Series> seriesList = ApplicationContext.databaseRef.getSeriesList(siuid);
+        Iterator<Series> seriesItr = seriesList.iterator();
+        while (seriesItr.hasNext()) {
+            Series series = seriesItr.next();
+            Iterator<Instance> imgitr = series.getImageList().iterator();
+            while (imgitr.hasNext()) {
+                Instance img = imgitr.next();
+                anonymizeStudy(img.getFilepath());
+            }
+        }
+    }
+    private void anonymizeStudy(String filePath)
+    {
+        File dicomFile=new File(filePath);
+    }
+}
diff --git a/src/in/raster/mayam/delegate/CgetDelegate.java b/src/in/raster/mayam/delegate/CgetDelegate.java
new file mode 100644
index 0000000..6ddb597
--- /dev/null
+++ b/src/in/raster/mayam/delegate/CgetDelegate.java
@@ -0,0 +1,72 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.delegate;
+
+import in.raster.mayam.util.core.DcmQR;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.9
+ *
+ */
+public class CgetDelegate extends Thread {
+
+    String getArg[];
+    public CgetDelegate(String getArg[]) {
+        this.getArg = getArg;
+        this.start();
+    }
+    /**
+     * This routine used to perform CGet
+     * @param moveArg
+     */
+    public void get() {
+        try {
+            DcmQR.main(getArg);
+        } catch (Exception ex) {
+            Logger.getLogger(MoveDelegate.class.getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+    public void run() {
+        get();
+    }
+}
diff --git a/src/in/raster/mayam/delegate/CineTimer.java b/src/in/raster/mayam/delegate/CineTimer.java
new file mode 100644
index 0000000..0553b95
--- /dev/null
+++ b/src/in/raster/mayam/delegate/CineTimer.java
@@ -0,0 +1,74 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.delegate;
+
+import in.raster.mayam.context.ApplicationContext;
+import java.util.TimerTask;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class CineTimer extends TimerTask {
+
+    private static int currentInstanceNo = 0;
+    private int totalInstance;
+
+    public CineTimer() {
+    }
+
+    @Override
+    public void run() {
+        if (ApplicationContext.databaseRef.getMultiframeStatus() && ApplicationContext.imgPanel.isMulitiFrame()) {
+            if (!ApplicationContext.imgPanel.isInstanceArray()) {
+                ApplicationContext.imgPanel.nextFrame();
+            } else {
+                ApplicationContext.imgPanel.showNextFrame();
+            }
+        } else {
+            if (!ApplicationContext.imgPanel.isInstanceArray()) {
+                ApplicationContext.imgPanel.nextInstance();
+            } else {
+                ApplicationContext.imgPanel.selectNextInstance();
+            }
+        }
+    }
+}
diff --git a/src/in/raster/mayam/delegate/DestinationFinder.java b/src/in/raster/mayam/delegate/DestinationFinder.java
new file mode 100644
index 0000000..97e422b
--- /dev/null
+++ b/src/in/raster/mayam/delegate/DestinationFinder.java
@@ -0,0 +1,132 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.delegate;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.facade.Platform;
+import in.raster.mayam.util.core.TranscoderMain;
+import java.io.File;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class DestinationFinder {
+
+    public DestinationFinder() {
+    }
+
+    public String getFileDestination(File file) {
+        String fileDest = null;
+        if(!Platform.getCurrentPlatform().equals(Platform.MAC)){
+            try {
+                String archiveDir = "archive";
+                if (file.getAbsolutePath().startsWith(archiveDir)) {
+                    fileDest = transcodedDestination(file);
+                } else {
+                    fileDest = importFileTranscodedDestination(file);
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        } else {
+            fileDest = file.getAbsolutePath();
+        }
+        return fileDest;
+    }
+
+    public String getFileDestination(String filePath) {
+        String fileDest = filePath;
+        try {
+            String archiveDir = "archive";
+            if (filePath.startsWith(archiveDir)) {
+                fileDest = ApplicationContext.getAppDirectory() + File.separator + filePath;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return fileDest;
+    }
+
+    /**
+     *
+     * @param file -
+     * @return
+     */
+    public String transcodedDestination(File file) throws Exception {
+        File parent = new File(file.getParent(), "UnCompressed");
+        parent.mkdir();
+        String dest = file.getParent() + File.separator + "UnCompressed" + File.separator + file.getName();
+        String transParam[] = {"--ivle", file.getAbsolutePath(), dest};
+        if (file.isFile()) {
+            synchronized (this) {
+                TranscoderMain.main(transParam);
+            }
+        }
+        return dest;
+    }
+
+    /**
+     *
+     * @param file
+     * @return
+     */
+    private String importFileTranscodedDestination(File file) throws Exception {
+        String userDir = ApplicationContext.getAppDirectory();
+        String archiveDir = userDir + File.separator + "archive";
+        //In order to avoid duplication it has been changed.
+        //Calendar today = Calendar.getInstance();
+        // String parent = archiveDir + File.separator + today.get(Calendar.YEAR) + File.separator + today.get(Calendar.MONTH) + File.separator + today.get(Calendar.DATE) + File.separator + "UnCompressed";
+        String parent = archiveDir + File.separator + "UnCompressed";
+        File parentFile = new File(parent);
+        if (!parentFile.exists()) {
+            parentFile.mkdirs();
+        }
+        String dest = parent + File.separator + file.getName();
+        String transParam[] = {"--ivle", file.getAbsolutePath(), dest};
+        if (file.isFile()) {
+            synchronized (this) {
+                TranscoderMain.main(transParam);
+            }
+        }
+        return dest;
+    }
+}
diff --git a/src/in/raster/mayam/delegate/DicomServerDelegate.java b/src/in/raster/mayam/delegate/DicomServerDelegate.java
new file mode 100644
index 0000000..8efcc14
--- /dev/null
+++ b/src/in/raster/mayam/delegate/DicomServerDelegate.java
@@ -0,0 +1,80 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.delegate;
+
+import in.raster.mayam.model.AEModel;
+import in.raster.mayam.model.table.StudyListModel;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class DicomServerDelegate {
+
+    private String name;
+    private  AEModel ae;
+    private StudyListModel studyListModel;
+    public DicomServerDelegate() {
+    }
+    public DicomServerDelegate(String name) {
+    this.name=name;
+    }
+
+    public AEModel getAe() {
+        return ae;
+    }
+
+    public void setAe(AEModel ae) {
+        this.ae = ae;
+    }
+
+    public StudyListModel getStudyListModel() {
+        return studyListModel;
+    }
+
+    public void setStudyListModel(StudyListModel studyListModel) {
+        this.studyListModel = studyListModel;
+    }
+
+    public String getName() {
+        return name;
+    }
+}
diff --git a/src/in/raster/mayam/delegate/EchoService.java b/src/in/raster/mayam/delegate/EchoService.java
new file mode 100644
index 0000000..f3f9cc4
--- /dev/null
+++ b/src/in/raster/mayam/delegate/EchoService.java
@@ -0,0 +1,163 @@
+
+
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.delegate;
+
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+import java.text.ParseException;
+
+import org.apache.log4j.Logger;
+import org.dcm4che.util.DcmURL;
+
+import de.iftm.dcm4che.services.CDimseService;
+import de.iftm.dcm4che.services.ConfigProperties;
+import in.raster.mayam.context.ApplicationContext;
+
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class EchoService {
+	
+	/*
+	 * Initialize Logger.
+	 */
+	private static Logger log = Logger.getLogger(EchoService.class);
+	
+	// String object to represent whether the echo is success or failed.
+	private String status;
+	
+	private long delay;
+	
+	// Constructors -----------------------------------------------------
+	public EchoService() {
+             String[] s = ApplicationContext.databaseRef.getListenerDetails();
+             CDimseService.DEFAULT_CALLING_AET=s[0];
+		status = "";
+	}
+	/**
+	 * Used to find whether the configured server is available(running) or not.
+	 * 
+	 */
+	public void checkEcho(DcmURL url) {
+		ConfigProperties cfgCDimseService;
+		CDimseService cDimseService;
+		boolean isOpen;
+		status = "Echo failed";
+		
+
+		// Load configuration properties of the server
+		try {
+			cfgCDimseService = new ConfigProperties(CDimseService.class.getResource("/resources/EchoService.cfg"));
+
+		} catch (IOException e) {
+			log.error("Error while loading configuration properties");
+			return;
+		}
+
+		/*
+		 * new AE().toString() returns the string ('dcmProtocol://aeTitle@hostName:port')
+		 * @see org.dcm4che.util.DcmURL.
+		 */
+		
+
+		try {
+			cDimseService = new CDimseService(cfgCDimseService, url);
+		} catch (ParseException e) {
+			log.error("Unable to create CDimseService instance", e);
+			return;
+		}
+
+		// Open association
+		try {
+			isOpen = cDimseService.aASSOCIATE();
+			if (!isOpen) {
+				return;
+			}
+		} catch (IOException e) {
+			log.error(e.getMessage());
+			status = "Echo failed";
+
+			return;
+		} catch (GeneralSecurityException e) {
+			log.error(e.getMessage());
+			return;
+		}
+
+		// Echo
+		try {
+			delay = cDimseService.cECHO();
+                        
+			status = "EchoSuccess";                       
+		//	log.info("C-ECHO delay: " + String.valueOf(delay));
+		} catch (Exception e) {
+			log.error(e.getMessage());
+			return;
+		}
+
+		// Release association
+		try {
+			cDimseService.aRELEASE(true);
+		} catch (IOException e) {
+			log.error(e.getMessage());
+		} catch (InterruptedException e) {
+			log.error(e.getMessage());
+		}
+
+		log.info(">>>>>>>>>> C-ECHO finished. <<<<<<<<<<");
+
+	}
+	
+	/**
+	 * Getter for property status.
+	 * @return the status represents whether the echo is success or failed.
+	 */
+	public String getStatus() {
+		return status;
+	}
+	
+	public long getDelay(){
+		return delay;
+	}
+}
diff --git a/src/in/raster/mayam/delegate/EncapsulatedPdfToJpeg.java b/src/in/raster/mayam/delegate/EncapsulatedPdfToJpeg.java
new file mode 100644
index 0000000..505e5b4
--- /dev/null
+++ b/src/in/raster/mayam/delegate/EncapsulatedPdfToJpeg.java
@@ -0,0 +1,122 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.delegate;
+
+import com.sun.pdfview.PDFFile;
+import com.sun.pdfview.PDFPage;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.Rectangle;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.swing.ImageIcon;
+import org.dcm4che.dict.Tags;
+import org.dcm4che2.data.DicomObject;
+import org.dcm4che2.io.DicomInputStream;
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.9
+ *
+ */
+public class EncapsulatedPdfToJpeg {
+    PDFFile curFile;
+    int totalInstance ;
+    int curpage;
+    ImageIcon imageIcon;
+    Image loadedImage;
+    BufferedImage currentbufferedimage;
+
+    public EncapsulatedPdfToJpeg() {
+    }
+
+  public void readDicom(File file) {
+        try {
+            DicomInputStream din = new DicomInputStream(new File(file.getAbsolutePath()));
+            DicomObject dcmObject = din.readDicomObject();
+            byte[] buf = dcmObject.getBytes(Tags.EncapsulatedDocument);
+            ByteBuffer byteBuffer = ByteBuffer.wrap(buf);
+            openPDFByteBuffer(byteBuffer, null, null);
+        } catch (IOException ex) {
+            Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+
+    private void openPDFByteBuffer(ByteBuffer buf, String path, String name) {
+        PDFFile newfile = null;
+        try {
+            newfile = new PDFFile(buf);
+        } catch (IOException ioe) {
+            return;
+        }
+        this.curFile = newfile;      
+    }
+    PDFPage pg = null;
+    public ArrayList createPDFArray() {
+        ArrayList<BufferedImage> temp = new ArrayList<BufferedImage>();
+        for (int pagenum = 0; pagenum < curFile.getNumPages(); pagenum++) {
+            PDFPage pdfPage = curFile.getPage(pagenum + 1);
+            Rectangle rect = new Rectangle(0, 0,
+                    (int) pdfPage.getBBox().getWidth(),
+                    (int) pdfPage.getBBox().getHeight());
+
+            //generate the image
+            Image current = pdfPage.getImage(
+                    rect.width, rect.height, //width & height
+                    rect, // clip rect
+                    null, // null for the ImageObserver
+                    true, // fill background with white
+                    true // block until drawing is done
+                    );
+            imageIcon = new ImageIcon();
+            imageIcon.setImage(current);
+            Image tempImage = imageIcon.getImage();
+            BufferedImage tempBufferedImage = new BufferedImage(tempImage.getWidth(null), tempImage.getHeight(null), BufferedImage.TYPE_INT_RGB);
+            Graphics2D g2 = tempBufferedImage.createGraphics();
+            g2.drawImage(tempImage, 0, 0, null);
+            temp.add(tempBufferedImage);
+        }
+        return temp;
+    }
+}
diff --git a/src/in/raster/mayam/delegate/ExportToDcmDelegate.java b/src/in/raster/mayam/delegate/ExportToDcmDelegate.java
new file mode 100644
index 0000000..3187277
--- /dev/null
+++ b/src/in/raster/mayam/delegate/ExportToDcmDelegate.java
@@ -0,0 +1,197 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.delegate;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.model.Instance;
+import in.raster.mayam.model.Series;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class ExportToDcmDelegate {
+
+    public ExportToDcmDelegate() {
+    }
+
+    public void studyExportAsDicom(String studyIUID, String ouputFilePath) {
+        String patientName = ApplicationContext.databaseRef.getPatientNameBasedonStudyUID(studyIUID);
+        File patientNameFile = new File(ouputFilePath, patientName);
+        if (!patientNameFile.exists()) {
+            patientNameFile.mkdirs();
+        }
+        ArrayList<Series> seriesList = ApplicationContext.databaseRef.getSeriesList(studyIUID);
+        Iterator<Series> seriesItr = seriesList.iterator();
+        while (seriesItr.hasNext()) {
+            Series series = seriesItr.next();
+            Iterator<Instance> imgitr = series.getImageList().iterator();
+            while (imgitr.hasNext()) {
+                Instance img = imgitr.next();
+                if (img.isEncapsulatedPDF()) {
+                    File inputFile = new File(img.getFilepath());
+                    exportDcm(inputFile, new File(patientNameFile.getAbsolutePath(), inputFile.getName()));
+                } else if (img.isMultiframe()) {
+                    if (img.getCurrentFrameNum() == 0) {
+                        doExport(img.getFilepath(), patientNameFile.getAbsolutePath());
+                    }
+                } else {
+                    doExport(img.getFilepath(), patientNameFile.getAbsolutePath());
+                }
+            }
+        }
+    }
+
+    public void seriesExportAsDicom(String studyIUID, String seriesIUID, String outputFilePath) {
+        ArrayList<Series> seriesList = ApplicationContext.databaseRef.getSeriesList(studyIUID);
+        Iterator<Series> seriesItr = seriesList.iterator();
+        while (seriesItr.hasNext()) {
+            Series series = seriesItr.next();
+            if (series.getSeriesInstanceUID().equalsIgnoreCase(seriesIUID)) {
+                Iterator<Instance> imgitr = series.getImageList().iterator();
+                while (imgitr.hasNext()) {
+                    Instance img = imgitr.next();
+                    if (img.isEncapsulatedPDF()) {
+                        File inputFile = new File(img.getFilepath());
+                        exportDcm(inputFile, new File(outputFilePath, inputFile.getName()));
+                    } else if (img.isMultiframe()) {
+                        if (img.getCurrentFrameNum() == 0) {
+                            doExport(img.getFilepath(), outputFilePath);
+                        }
+                    } else {
+                        doExport(img.getFilepath(), outputFilePath);
+                    }
+                }
+            }
+        }
+    }
+
+    public void seriesExportAsDicom(String studyIUID, String seriesIUID, boolean multiframe, String instanceUID, String outputFilePath) {
+        ArrayList<Series> seriesList = ApplicationContext.databaseRef.getSeriesList(studyIUID);
+        Iterator<Series> seriesItr = seriesList.iterator();
+        while (seriesItr.hasNext()) {
+            Series series = seriesItr.next();
+            if (multiframe) { //if it is multiframe
+                if (series.isMultiframe() && series.getSeriesInstanceUID().equalsIgnoreCase(seriesIUID) && series.getInstanceUID().equalsIgnoreCase(instanceUID)) {
+                    //Series uid is same as instance uid if it is a multiframe file.
+                    Iterator<Instance> imgitr = series.getImageList().iterator();
+                    while (imgitr.hasNext()) {
+                        //one instance is here.
+                        Instance img = imgitr.next();
+                        if (img.isEncapsulatedPDF()) {
+                            File inputFile = new File(img.getFilepath());
+                            exportDcm(inputFile, new File(outputFilePath, inputFile.getName()));
+                        } else {
+                            doExport(img.getFilepath(), outputFilePath);
+                        }
+                    }
+                }
+            } else {//single frame image
+                if (!series.isMultiframe() && series.getSeriesInstanceUID().equalsIgnoreCase(seriesIUID)) {
+                    Iterator<Instance> imgitr = series.getImageList().iterator();
+                    while (imgitr.hasNext()) {
+
+                        Instance img = imgitr.next();
+                        if (img.isEncapsulatedPDF()) {
+                            File inputFile = new File(img.getFilepath());
+                            exportDcm(inputFile, new File(outputFilePath, inputFile.getName()));
+                        } else {
+                            doExport(img.getFilepath(), outputFilePath);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    public void instanceExportAsDicom(String inputFilePath, String outputFilePath, boolean isEncapsulatedPDF) {
+        if (isEncapsulatedPDF) {
+            File inputFile = new File(inputFilePath);
+            exportDcm(inputFile, new File(outputFilePath, inputFile.getName()));
+        } else {
+            doExport(inputFilePath, outputFilePath);
+        }
+    }
+
+    private void doExport(String inputFilePath, String outputFilePath) {
+        DestinationFinder destFinder = new DestinationFinder();
+        File inputFile = new File(destFinder.getFileDestination(new File(inputFilePath)));
+        File outputFile = new File(outputFilePath, inputFile.getName());
+        exportDcm(inputFile, outputFile);
+    }
+    //new File(outputFilePath, inputFile.getName())
+
+    private void exportDcm(File inputFile, File outputFile) {
+        InputStream in = null;
+        OutputStream out = null;
+        try {
+            in = new FileInputStream(inputFile);
+            out = new FileOutputStream(outputFile);
+            byte[] buf = new byte[4096];
+            int len;
+            while ((len = in.read(buf)) > 0) {
+                out.write(buf, 0, len);
+            }
+        } catch (FileNotFoundException ex) {
+            Logger.getLogger(ExportToDcmDelegate.class.getName()).log(Level.SEVERE, null, ex);
+        } catch (IOException ex) {
+            Logger.getLogger(ExportToDcmDelegate.class.getName()).log(Level.SEVERE, null, ex);
+        } finally {
+            try {
+                in.close();
+                out.close();
+            } catch (IOException ex) {
+                Logger.getLogger(ExportToDcmDelegate.class.getName()).log(Level.SEVERE, null, ex);
+            }
+        }
+    }
+}
diff --git a/src/in/raster/mayam/delegate/ExportingDelegate.java b/src/in/raster/mayam/delegate/ExportingDelegate.java
new file mode 100644
index 0000000..49271e0
--- /dev/null
+++ b/src/in/raster/mayam/delegate/ExportingDelegate.java
@@ -0,0 +1,132 @@
+
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.delegate;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.form.dialog.ExportDialog;
+import in.raster.mayam.form.display.Display;
+import in.raster.mayam.form.ExportingProgress;
+import in.raster.mayam.form.dialog.ExportLocationChooser;
+import java.io.File;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class ExportingDelegate extends Thread {
+
+    private File openedFile;
+    private boolean isSeriesOrInstanceLevel;
+    private String studyUID;
+
+    public ExportingDelegate() {
+    }
+
+    public ExportingDelegate(File openedFile, String studyUID, boolean isSeriesOrInstanceLevel) {
+        this.openedFile = openedFile;
+        this.isSeriesOrInstanceLevel = isSeriesOrInstanceLevel;
+        this.studyUID = studyUID;
+        this.start();
+    }
+
+    public void run() {
+
+        ExportingProgress exportingProgress = new ExportingProgress();
+        Display.alignScreen(exportingProgress);
+        exportingProgress.setVisible(true);
+        exportingProgress.updateBar(0);
+        JpegConvertorDelegate jpegDelegate = new JpegConvertorDelegate();
+        ExportToDcmDelegate exportToDcmDelegate = new ExportToDcmDelegate();
+        process(exportToDcmDelegate, jpegDelegate);
+        exportingProgress.updateBar(100);
+        exportingProgress.setVisible(false);
+    }
+
+    private void process(ExportToDcmDelegate exportToDcmDelegate, JpegConvertorDelegate jpegDelegate) {
+        if (isSeriesOrInstanceLevel) {
+            File patientNameFile = new File(openedFile, ApplicationContext.imgPanel.getTextOverlayParam().getPatientName());
+            if (!patientNameFile.exists()) {
+                patientNameFile.mkdir();
+            }
+            if (ExportDialog.seriesOfImage) {//series of image
+                exportSeriesOfImage(patientNameFile, exportToDcmDelegate, jpegDelegate);
+            } else {//Single image
+                exportInstanceOfImage(patientNameFile, exportToDcmDelegate, jpegDelegate);
+            }
+        } else {//study convert
+            exportStudy(openedFile, exportToDcmDelegate, jpegDelegate);
+        }
+    }
+
+    private void exportSeriesOfImage(File patientNameFile, ExportToDcmDelegate exportToDcmDelegate, JpegConvertorDelegate jpegDelegate) {
+        if (!ApplicationContext.databaseRef.getMultiframeStatus()) {
+            if (ExportDialog.conversionFormatDcm) {
+                exportToDcmDelegate.seriesExportAsDicom(ApplicationContext.imgPanel.getStudyUID(), ApplicationContext.imgPanel.getSeriesUID(), patientNameFile.getAbsolutePath());
+            } else {
+                jpegDelegate.seriesLevelConvertor(ApplicationContext.imgPanel.getStudyUID(), ApplicationContext.imgPanel.getSeriesUID(), patientNameFile.getAbsolutePath(), ApplicationContext.imgPanel.getColorModel());
+            }
+        } else {
+            if (ExportDialog.conversionFormatDcm) {
+                exportToDcmDelegate.seriesExportAsDicom(ApplicationContext.imgPanel.getStudyUID(), ApplicationContext.imgPanel.getSeriesUID(), ApplicationContext.imgPanel.isMulitiFrame(), ApplicationContext.imgPanel.getInstanceUID(), patientNameFile.getAbsolutePath());
+            } else {
+                jpegDelegate.seriesLevelConvertor(ApplicationContext.imgPanel.getStudyUID(), ApplicationContext.imgPanel.getSeriesUID(), ApplicationContext.imgPanel.isMulitiFrame(), ApplicationContext.imgPanel.getInstanceUID(), patientNameFile.getAbsolutePath(), ApplicationContext.imgPanel.getColorModel());
+            }
+
+        }
+    }
+
+    private void exportInstanceOfImage(File patientNameFile, ExportToDcmDelegate exportToDcmDelegate, JpegConvertorDelegate jpegDelegate) {
+        if (ExportDialog.conversionFormatDcm) {
+            exportToDcmDelegate.instanceExportAsDicom(ApplicationContext.imgPanel.getDicomFileUrl(), patientNameFile.getAbsolutePath(),ApplicationContext.imgPanel.isIsEncapsulatedDocument());
+        } else {
+            jpegDelegate.instanceConvertor(patientNameFile.getAbsolutePath() + File.separator + ApplicationContext.imgPanel.getInstanceUID(), ApplicationContext.imgPanel.getCurrentbufferedimage());
+        }
+    }
+
+    private void exportStudy(File patientNameFile, ExportToDcmDelegate exportToDcmDelegate, JpegConvertorDelegate jpegDelegate) {
+        if (ExportLocationChooser.conversionFormatDcm) {
+            exportToDcmDelegate.studyExportAsDicom(this.studyUID, openedFile.getAbsolutePath());
+        } else {
+            jpegDelegate.studyLevelConvertor(this.studyUID, openedFile.getAbsolutePath());
+        }
+    }
+}
diff --git a/src/in/raster/mayam/delegate/ImageOrientation.java b/src/in/raster/mayam/delegate/ImageOrientation.java
new file mode 100644
index 0000000..ecc29ab
--- /dev/null
+++ b/src/in/raster/mayam/delegate/ImageOrientation.java
@@ -0,0 +1,118 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.delegate;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.6
+ *
+ */
+public class ImageOrientation {
+
+    public ImageOrientation() {
+    }
+
+    public static String getOrientation(double x, double y, double z) {
+        String orientation = "";
+        String orientationX = (x < 0) ? "R" : "L";
+        String orientationY = (y < 0) ? "A" : "P";
+        String orientationZ = (z < 0) ? "F" : "H";
+        double absX = Math.abs(x);
+        double absY = Math.abs(y);
+        double absZ = Math.abs(z);
+        for (int i = 0; i < 3; ++i) {
+            if ((absX > 0.0001) && (absX > absY) && (absX > absZ)) {
+                orientation += orientationX;
+                absX = 0;
+            } else if ((absY > 0.0001) && (absY > absX) && (absY > absZ)) {
+                orientation += orientationY;
+                absY = 0;
+            }
+            else if (absZ>0.0001 && absZ>absX && absZ>absY)
+            {
+                orientation+=orientationZ;
+                absZ=0;
+            }
+            else break;
+        }
+        return orientation;
+    }
+    public static void getOrientation(String imageOrientation) {
+        String imageOrientationArray[], columnRowArray[];
+        imageOrientationArray = imageOrientation.split("\\\\");
+        float _imgRowCosx = Float.parseFloat(imageOrientationArray[0]);
+        float _imgRowCosy = Float.parseFloat(imageOrientationArray[1]);
+        float _imgRowCosz = Float.parseFloat(imageOrientationArray[2]);
+        float _imgColCosx = Float.parseFloat(imageOrientationArray[3]);
+        float _imgColCosy = Float.parseFloat(imageOrientationArray[4]);
+        float _imgColCosz = Float.parseFloat(imageOrientationArray[5]);
+        columnRowArray = new String[2];
+        columnRowArray[0] = ImageOrientation.getOrientation(_imgRowCosx, _imgRowCosy, _imgRowCosz);
+        columnRowArray[1] = ImageOrientation.getOrientation(_imgColCosx, _imgColCosy, _imgColCosz);
+    }
+
+    public static String getOppositeOrientation(String orientation) {
+        String oppositePrcl = "";
+        char[] temp = orientation.toCharArray();
+        for (char c : temp) {
+            oppositePrcl += getOpposite(c);
+        }
+        return oppositePrcl;
+    }
+
+    public static char getOpposite(char c) {
+        char opposite = ' ';
+        switch (c) {
+            case 'L':
+                return 'R';
+            case 'R':
+                return 'L';
+            case 'P':
+                return 'A';
+            case 'A':
+                return 'P';
+            case 'H':
+                return 'F';
+            case 'F':
+                return 'H';
+        }
+        return opposite;
+    }
+}
diff --git a/src/in/raster/mayam/delegate/ImportDcmDirDelegate.java b/src/in/raster/mayam/delegate/ImportDcmDirDelegate.java
new file mode 100644
index 0000000..c84c4a7
--- /dev/null
+++ b/src/in/raster/mayam/delegate/ImportDcmDirDelegate.java
@@ -0,0 +1,354 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.delegate;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.exception.CompressedDcmOnMacException;
+import in.raster.mayam.facade.ApplicationFacade;
+import in.raster.mayam.facade.Platform;
+import in.raster.mayam.form.MainScreen;
+import java.io.File;
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.swing.JOptionPane;
+import org.dcm4che2.data.BasicDicomObject;
+import org.dcm4che2.data.DicomObject;
+import org.dcm4che2.data.Tag;
+import org.dcm4che2.data.TransferSyntax;
+import org.dcm4che2.data.VR;
+import org.dcm4che2.media.DirectoryRecordType;
+import org.dcm4che2.media.DicomDirReader;
+import sun.awt.shell.ShellFolder;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class ImportDcmDirDelegate {
+
+    private DicomDirReader dicomDir;
+    private File dcmDirFile;
+    private boolean copyAsLink = false;
+    private DicomObject dataset = new BasicDicomObject();
+
+    public ImportDcmDirDelegate() {
+        findDcmDirInMedia();
+        //this.start();
+    }
+
+    public ImportDcmDirDelegate(File dcmDirFile) {
+        this.dcmDirFile = dcmDirFile;
+        // this.start();
+    }
+
+    public void findAndRun() {
+        findDcmDirInMedia();
+        try {
+            run();
+        } catch (CompressedDcmOnMacException e) {
+            JOptionPane.showMessageDialog(ApplicationContext.mainScreen, e.getMessage());
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void run() throws CompressedDcmOnMacException, Exception {
+        readDcmDirFile();
+        if (dicomDir != null) {
+            new DirParser().parseDir();
+            MainScreen.showLocalDBStorage();
+        }
+
+    }
+
+    /**
+     * This routine used to read the dicom dir file.
+     */
+    public void readDcmDirFile() {
+        try {
+            dicomDir = new DicomDirReader(dcmDirFile);
+            dicomDir.setShowInactiveRecords(false);
+        } catch (NullPointerException ex) {
+            // This Exception will be raised if cd drive is not ready for finding the file   
+
+            JOptionPane.showMessageDialog(null, "Drive reading error please try again later ", null, JOptionPane.ERROR_MESSAGE);
+        } catch (IOException ex) {
+            Logger.getLogger(ImportDcmDirDelegate.class.getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+
+    /**
+     * Member inner class DirParser used to parse the dicom dir file
+     */
+    class DirParser {
+
+        private void parseDir() throws CompressedDcmOnMacException, Exception {
+            parsePatient();
+        }
+
+        /**
+         *
+         * @throws IOException
+         */
+        private void parsePatient() throws CompressedDcmOnMacException, Exception {
+            DicomObject patient = dicomDir.findFirstRootRecord();
+            while (patient != null) {
+                if (DirectoryRecordType.PATIENT.equals(patient.getString(Tag.DirectoryRecordType))) {
+                    new DatasetUpdator().updatePatientInfo(patient);
+                    parseStudy(patient);
+
+                }
+                patient = dicomDir.findNextSiblingRecord(patient);
+            }
+        }
+
+        /**
+         *
+         * @param patient
+         * @throws IOException
+         */
+        private void parseStudy(DicomObject patient) throws IOException, CompressedDcmOnMacException {
+            DicomObject study = dicomDir.findFirstChildRecord(patient);
+            while (study != null) {
+                if (DirectoryRecordType.STUDY.equals(study.getString(Tag.DirectoryRecordType))) {
+                    //update study level tag values
+                    new DatasetUpdator().updateStudyInfo(study);
+                    parseSeries(study);
+                }
+                study = dicomDir.findNextSiblingRecord(study);
+            }//study loop completed
+        }
+
+        /**
+         *
+         * @param study
+         * @throws IOException
+         */
+        private void parseSeries(DicomObject study) throws IOException, CompressedDcmOnMacException {
+            DicomObject series = dicomDir.findFirstChildRecord(study);
+            while (series != null) {
+                if (DirectoryRecordType.SERIES.equals(series.getString(Tag.DirectoryRecordType))) {
+                    //update series level tag values
+                    new DatasetUpdator().updateSeriesInfo(series);
+                    parseInstance(series);
+                }
+                series = dicomDir.findNextSiblingRecord(series);
+            }//series loop completed
+        }
+
+        /**
+         *
+         * @param series-
+         * @throws IOException
+         */
+        private void parseInstance(DicomObject series) throws IOException, CompressedDcmOnMacException {
+            DicomObject instance = dicomDir.findFirstChildRecord(series);
+            while (instance != null) {
+                if (DirectoryRecordType.IMAGE.equals(instance.getString(Tag.DirectoryRecordType))) {
+                    //update instance level tag values
+                    new DatasetUpdator().updateInstanceInfo(instance);
+                    File f = dicomDir.toReferencedFile(instance);
+                    //import to database
+                    if (Platform.getCurrentPlatform().equals(Platform.MAC)) {
+                        if (instance.getString(Tag.ReferencedTransferSyntaxUIDInFile).equalsIgnoreCase(TransferSyntax.ExplicitVRLittleEndian.uid()) || instance.getString(Tag.ReferencedTransferSyntaxUIDInFile).equalsIgnoreCase(TransferSyntax.ImplicitVRLittleEndian.uid())) {
+                            ApplicationContext.databaseRef.importDataToDatabase(dataset, f, copyAsLink);
+                        } else {
+                            throw new CompressedDcmOnMacException();
+                            // JOptionPane.showMessageDialog(ApplicationContext.mainScreen, "Compressed image cannot be opened in Mac");
+                        }
+                    } else {
+                        ApplicationContext.databaseRef.importDataToDatabase(dataset, f, copyAsLink);
+                    }
+                }
+                instance = dicomDir.findNextSiblingRecord(instance);
+            }//instance loop completed
+        }
+    }
+
+    /**
+     * Member inner class DatasetUpdator used to update the dicom object related information
+     */
+    class DatasetUpdator {
+
+        /**
+         *
+         * @param next-It contains the patient related dicom tags information
+         */
+        private void updatePatientInfo(DicomObject next) {
+            updateTag(dataset, Tag.PatientName, next.getString(Tag.PatientName));
+            updateTag(dataset, Tag.PatientID, next.getString(Tag.PatientID));
+            updateTag(dataset, Tag.PatientSex, next.getString(Tag.PatientSex));
+        }
+
+        /**
+         *
+         * @param study-It contains the study related dicom tags information
+         */
+        private void updateStudyInfo(DicomObject study) {
+            updateTag(dataset, Tag.StudyInstanceUID, study.getString(Tag.StudyInstanceUID));
+            updateTag(dataset, Tag.StudyDate, study.getString(Tag.StudyDate));
+            updateTag(dataset, Tag.AccessionNumber, study.getString(Tag.AccessionNumber));
+            updateTag(dataset, Tag.ReferringPhysicianName, study.getString(Tag.ReferringPhysicianName));
+            updateTag(dataset, Tag.NumberOfStudyRelatedSeries, study.getString(Tag.NumberOfStudyRelatedSeries));
+            updateTag(dataset, Tag.NumberOfStudyRelatedInstances, study.getString(Tag.NumberOfStudyRelatedInstances));
+            updateTag(dataset, Tag.StudyDescription, study.getString(Tag.StudyDescription));
+            updateTag(dataset, Tag.Modality, study.getString(Tag.Modality));
+        }
+
+        /**
+         *
+         * @param series-It contains the series related dicom tags information
+         */
+        private void updateSeriesInfo(DicomObject series) {
+            updateTag(dataset, Tag.SeriesDate, series.getString(Tag.SeriesDate));
+            updateTag(dataset, Tag.NumberOfSeriesRelatedInstances, series.getString(Tag.NumberOfSeriesRelatedInstances));
+            updateTag(dataset, Tag.InstitutionName, series.getString(Tag.InstitutionName));
+            updateTag(dataset, Tag.SeriesNumber, series.getString(Tag.SeriesNumber));
+            updateTag(dataset, Tag.Modality, series.getString(Tag.Modality));
+            updateTag(dataset, Tag.SeriesDescription, series.getString(Tag.SeriesDescription));
+            updateTag(dataset, Tag.SeriesInstanceUID, series.getString(Tag.SeriesInstanceUID));
+            updateTag(dataset, Tag.SeriesNumber, series.getString(Tag.SeriesNumber));
+        }
+
+        /**
+         *
+         * @param instance-It contains the instance related dicom tags information
+         */
+        private void updateInstanceInfo(DicomObject instance) {
+            updateTag(dataset, Tag.SOPInstanceUID, instance.getString(Tag.ReferencedSOPInstanceUIDInFile));
+        }
+
+        /**
+         *
+         * @param dObj-dicom object it will contains the dicom tag information
+         * @param tag-Tag constant used to specify the tag information
+         * @param newValue-values to be replaced
+         */
+        private void updateTag(DicomObject dObj, int tag, String newValue) {
+            VR vr = dObj.vrOf(tag);
+            dObj.putString(tag, vr, newValue);
+        }
+    }
+
+    /**
+     * This sub routine used to find the media location based on the platform
+     */
+    public void findDcmDirInMedia() {
+        try {
+            String os = System.getProperty("os.name").toLowerCase();
+            File[] drives = null;
+            // list Filesystem roots
+            if (os.startsWith("win")) {
+                drives = ShellFolder.listRoots();
+            } else if (os.startsWith("mac")) {
+                drives = new File("/Volumes").listFiles();
+            } else {
+                drives = new File("/media").listFiles();
+            }
+            // search for dicomdir in system roots
+            for (int i = 0; i < drives.length; i++) {
+                File dicomDirCD = new File(drives[i] + File.separator + "DICOMDIR");
+                if (dicomDirCD.canRead()) {
+                    dcmDirFile = dicomDirCD;
+                    break;
+                }
+                dicomDirCD = new File(drives[i] + File.separator + "dicomdir");
+                if (dicomDirCD.canRead()) {
+                    dcmDirFile = dicomDirCD;
+                    break;
+                }
+                //Some Unix needs the point at the end
+                dicomDirCD = new File(drives[i] + File.separator + "dicomdir.");
+                if (dicomDirCD.canRead()) {
+                    dcmDirFile = dicomDirCD;
+                    break;
+                }
+            }
+        } catch (Exception ee) {
+            ee.printStackTrace();
+        }
+    }
+
+    public static void findAndLoadDcmDirFiles() {
+        try {
+            ApplicationContext.databaseRef.deleteCopyAsLinkStudies();
+            ImportDcmDirDelegate importDcmDirDelegate = new ImportDcmDirDelegate();
+            importDcmDirDelegate.findAndLoadDcmDir();
+            if (importDcmDirDelegate.dcmDirFile != null && importDcmDirDelegate.dcmDirFile.getParent().startsWith(ApplicationFacade.binPath)) {
+                importDcmDirDelegate.copyAsLink = true;
+                importDcmDirDelegate.run();
+            }
+        } catch (CompressedDcmOnMacException e) {
+            JOptionPane.showMessageDialog(ApplicationContext.mainScreen, e.getMessage());
+        } catch (Exception ee) {
+            ee.printStackTrace();
+        }
+    }
+
+    public void findAndLoadDcmDir() {
+        try {
+            String userDir = ApplicationFacade.binPath;
+            File file = new File(userDir + File.separator + "DCMDIR");
+            if (file.canRead()) {
+                dcmDirFile = file;
+            }
+            file = new File(userDir + File.separator + "dicomdir");
+            if (file.canRead()) {
+                dcmDirFile = file;
+            }
+            file = new File(userDir + File.separator + "dicomdir.");
+            if (file.canRead()) {
+                dcmDirFile = file;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public boolean isCopyAsLink() {
+        return copyAsLink;
+    }
+
+    public void setCopyAsLink(boolean copyAsLink) {
+        this.copyAsLink = copyAsLink;
+    }
+}
diff --git a/src/in/raster/mayam/delegate/ImportDelegate.java b/src/in/raster/mayam/delegate/ImportDelegate.java
new file mode 100644
index 0000000..f602715
--- /dev/null
+++ b/src/in/raster/mayam/delegate/ImportDelegate.java
@@ -0,0 +1,190 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.delegate;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.exception.CompressedDcmOnMacException;
+import in.raster.mayam.facade.Platform;
+import in.raster.mayam.form.display.Display;
+import in.raster.mayam.form.ImportingProgress;
+import in.raster.mayam.form.MainScreen;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import javax.swing.JOptionPane;
+import org.dcm4che.dict.Tags;
+import org.dcm4che2.data.BasicDicomObject;
+import org.dcm4che2.data.DicomObject;
+import org.dcm4che2.data.TransferSyntax;
+import org.dcm4che2.io.DicomInputStream;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class ImportDelegate extends Thread {
+
+    private File importFolder;
+    private File importFile;
+    private File file;
+    private boolean isDirectory;
+    private MainScreen parent;
+    ArrayList<String> absolutePathList = new ArrayList();
+    ImportingProgress importingProgress = null;
+
+    public ImportDelegate() {
+    }
+
+    public ImportDelegate(File file, boolean isDirectory, MainScreen parent) {
+        this.parent = parent;
+        this.isDirectory = isDirectory;
+        this.file = file;
+        this.start();
+    }
+
+    public void run() {
+        importingProgress = new ImportingProgress();
+        Display.alignScreen(importingProgress);
+        importingProgress.setVisible(true);
+        importingProgress.updateBar(0);
+
+        if (isDirectory) {
+            setImportFolder(file);
+            readAndUpdateDB();
+        } else {
+            setImportFile(file);
+            readFileAndUpdateDB();
+
+        }
+        importingProgress.updateBar(importingProgress.getProgressMaximum());
+        importingProgress.setVisible(false);
+        MainScreen.showLocalDBStorage();
+    }
+
+    public ImportDelegate(File importFolder) {
+        this.importFolder = importFolder;
+    }
+
+    private ArrayList getAbsolutePathArray() {
+        addPath(importFolder.getAbsolutePath());
+        return absolutePathList;
+    }
+
+    private void addPath(String directoryPath) {
+        File directory = new File(directoryPath);
+        String[] listOfFiles = directory.list();
+        for (int i = 0; i < listOfFiles.length; i++) {
+            if (new File(directory.getAbsolutePath() + File.separator + listOfFiles[i]).isDirectory()) {
+                //  System.out.println(""+listOfFiles[i]+"is directory");
+                addPath(new String(directory.getAbsolutePath() + File.separator + listOfFiles[i]));
+            } else {
+                absolutePathList.add(new String(directory.getAbsolutePath() + File.separator + listOfFiles[i]));
+            }
+        }
+    }
+
+    public void readAndUpdateDB() {
+        getAbsolutePathArray();
+        importingProgress.setProgressMaximum(absolutePathList.size());
+        for (int i = 0; i < absolutePathList.size(); i++) {
+            try {
+                String s = absolutePathList.get(i);
+                readAndImportDicomFile(s);
+                importingProgress.updateBar(i + 1);
+            } catch (CompressedDcmOnMacException e) {
+                importingProgress.setVisible(false);
+                JOptionPane.showMessageDialog(ApplicationContext.mainScreen, e.getMessage());
+                break;
+            }
+
+        }
+    }
+
+    private void readAndImportDicomFile(String dicomFilePath) throws CompressedDcmOnMacException {
+        DicomInputStream dis = null;
+        File parseFile = new File(dicomFilePath);
+        try {
+            dis = new DicomInputStream(parseFile);
+            DicomObject data = new BasicDicomObject();
+            data = dis.readDicomObject();
+            if (data != null) {
+                if (Platform.getCurrentPlatform().equals(Platform.MAC)) {
+                    if (data.getString(Tags.TransferSyntaxUID).equalsIgnoreCase(TransferSyntax.ExplicitVRLittleEndian.uid()) || data.getString(Tags.TransferSyntaxUID).equalsIgnoreCase(TransferSyntax.ImplicitVRLittleEndian.uid())) {
+                        ApplicationContext.databaseRef.importDataToDatabase(data, parseFile, false);
+                    } else {
+                        throw new CompressedDcmOnMacException();
+                    }
+                } else {
+                    ApplicationContext.databaseRef.importDataToDatabase(data, parseFile, false);
+                }
+
+            }
+        } catch (IOException ex) {
+            ex.printStackTrace();
+        } finally {
+            if (dis != null) {
+                try {
+                    dis.close();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                    // ignore
+                }
+            }
+        }
+    }
+
+    public void setImportFolder(File importFolder) {
+        this.importFolder = importFolder;
+    }
+
+    public void setImportFile(File importFile) {
+        this.importFile = importFile;
+    }
+
+    public void readFileAndUpdateDB() {
+        try {
+            readAndImportDicomFile(importFile.getAbsolutePath());
+        } catch (CompressedDcmOnMacException e) {
+            importingProgress.setVisible(false);
+            JOptionPane.showMessageDialog(ApplicationContext.mainScreen, e.getMessage());
+        }
+    }
+}
diff --git a/src/in/raster/mayam/delegate/InputArgumentsParser.java b/src/in/raster/mayam/delegate/InputArgumentsParser.java
new file mode 100644
index 0000000..c89ce44
--- /dev/null
+++ b/src/in/raster/mayam/delegate/InputArgumentsParser.java
@@ -0,0 +1,198 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.delegate;
+
+import in.raster.mayam.model.InputArgumentValues;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.GnuParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.9
+ *
+ */
+public class InputArgumentsParser {
+
+    public static InputArgumentValues inputArgumentValues = null;
+    private static final String USAGE ="java -jar Mayam.jar [Options] ";//<aet>[@<host>[:<port>]]
+    private static final String EXAMPLE =
+            "\nExample: java -jar Mayam.jar -AET QRSCP -HostName localhost -Port 11112 -StudyDate today -WADOURL wado -WADOPort 8080 -WADOProtocol http  \n"// QRSCP at localhost:11112 -q
+            + "=> Query Application Entity QRSCP listening on local port 11112 for "
+            + "today studies and retrieve instances of matching studies to "
+            + "Application Entity of Mayam";
+
+    public static void parse(String[] args) {
+        inputArgumentValues = new InputArgumentValues();
+        Options opts = new Options();
+        OptionBuilder.withArgName("StudyUID");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription("Set the study instance uid for query/retrieve the studies from server");
+        opts.addOption(OptionBuilder.create("StudyUID"));
+        
+        OptionBuilder.withArgName("PatientID");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription("Set the patient id matching key for query/retrieve the studies of patient from server");
+        opts.addOption(OptionBuilder.create("PatientID"));
+        
+        OptionBuilder.withArgName("Modality");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription("Set the modality matching key for query/retrieve the studies from server.");
+        opts.addOption(OptionBuilder.create("Modality"));
+        
+        OptionBuilder.withArgName("AccessionNumber");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription("Set the accession number matching key for query/retrieve the studies from server");
+        opts.addOption(OptionBuilder.create("Accession"));
+        
+        OptionBuilder.withArgName("PatientName");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription("Set the patient name matching key for query/retrieve the studies from server");
+        opts.addOption(OptionBuilder.create("PatientName"));
+
+        OptionBuilder.withArgName("StudyDate");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription("Set the study date matching key for query/retrieve the studies from server");
+        opts.addOption(OptionBuilder.create("StudyDate"));
+
+        OptionBuilder.withArgName("AETitle");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription("Specifies the AE title of remote DICOM server for query/retrieve");
+        opts.addOption(OptionBuilder.create("AET"));
+
+        OptionBuilder.withArgName("Port");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription("Specifies the port of remote DICOM server for query/retrieve");
+        opts.addOption(OptionBuilder.create("Port"));
+
+        OptionBuilder.withArgName("HostName");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription("Specifies the hostname of remote DICOM server for query/retrieve");
+        opts.addOption(OptionBuilder.create("HostName"));
+
+        OptionBuilder.withArgName("WADOURL");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription("Specifies the wado context path eg.wado\n");
+        opts.addOption(OptionBuilder.create("WADOURL"));
+
+
+        OptionBuilder.withArgName("WADOPort");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription("Specifies the wado port for retrieving the studies via WADO");
+        opts.addOption(OptionBuilder.create("WADOPort"));
+
+        OptionBuilder.withArgName("WADOProtocol");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription("Specifies the wado protocol for retrieving the studies via WADO");
+        opts.addOption(OptionBuilder.create("WADOProtocol"));
+
+
+        OptionBuilder.withArgName("From");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription("Specifies the starting date of the studies to be queried and loaded at startup");
+        opts.addOption(OptionBuilder.create("From"));
+
+
+        OptionBuilder.withArgName("To");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription("Specifies the ending date of the studies to be queries and loaded at startup");
+        opts.addOption(OptionBuilder.create("To") );
+
+        opts.addOption("h", "help", false, "Print this message");
+
+        CommandLine cl = null;
+        try {
+            cl = new GnuParser().parse(opts, args);
+        } catch (ParseException e) {
+            e.printStackTrace();
+            throw new RuntimeException("unreachable");
+        }
+        if (cl.hasOption('h')) {
+            HelpFormatter formatter = new HelpFormatter();
+            formatter.printHelp(USAGE, "\nOptions:", opts, EXAMPLE);
+        }
+        getInputArgumentValues(cl);      
+    }
+
+    public static String[] split(String s, char delim) {
+        String[] s2 = {s, null};
+        int pos = s.indexOf(delim);
+        if (pos != -1) {
+            s2[0] = s.substring(0, pos);
+            s2[1] = s.substring(pos + 1);
+        }
+        return s2;
+    }
+
+    public static void getInputArgumentValues(CommandLine cl) {          
+            if (cl.hasOption("WADOURL")) {
+                inputArgumentValues.setWadoContext(cl.getOptionValue("WADOURL"));                
+            }if (cl.hasOption("WADOPort")) {
+                inputArgumentValues.setWadoPort(Integer.parseInt(cl.getOptionValue("WADOPort")));              
+            }if (cl.hasOption("AET")) {
+                inputArgumentValues.setAeTitle(cl.getOptionValue("AET"));            
+            }if (cl.hasOption("Accession")) {
+                inputArgumentValues.setAccessionNumber(cl.getOptionValue("Accession"));              
+            }if (cl.hasOption("HostName")) {
+                inputArgumentValues.setHostName(cl.getOptionValue("HostName"));           
+            }if (cl.hasOption("Modality")) {
+                inputArgumentValues.setModality(cl.getOptionValue("Modality"));               
+            }if (cl.hasOption("PatientID")) {
+                inputArgumentValues.setPatientID(cl.getOptionValue("PatientID"));               
+            }if (cl.hasOption("PatientName")) {
+                inputArgumentValues.setPatientName(cl.getOptionValue("PatientName"));              
+            }if (cl.hasOption("Port")) {
+                inputArgumentValues.setPort(Integer.parseInt(cl.getOptionValue("Port")));               
+            }if (cl.hasOption("StudyDate")) {
+                inputArgumentValues.setStudyDate(cl.getOptionValue("StudyDate"));              
+            }if (cl.hasOption("StudyUID")) {
+                inputArgumentValues.setStudyUID(cl.getOptionValue("StudyUID"));               
+            }if (cl.hasOption("WADOProtocol")) {
+                inputArgumentValues.setWadoProtocol(cl.getOptionValue("WADOProtocol"));               
+            } if (cl.hasOption("From")) {
+                inputArgumentValues.setFrom(cl.getOptionValue("From"));               
+            }if (cl.hasOption("To")) {
+                inputArgumentValues.setTo(cl.getOptionValue("To"));               
+            }
+    }
+}
\ No newline at end of file
diff --git a/src/in/raster/mayam/delegate/JpegConvertorDelegate.java b/src/in/raster/mayam/delegate/JpegConvertorDelegate.java
new file mode 100644
index 0000000..27221af
--- /dev/null
+++ b/src/in/raster/mayam/delegate/JpegConvertorDelegate.java
@@ -0,0 +1,526 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.delegate;
+
+import com.sun.image.codec.jpeg.JPEGCodec;
+import com.sun.image.codec.jpeg.JPEGImageEncoder;
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.form.MainScreen;
+import in.raster.mayam.model.Instance;
+import in.raster.mayam.model.Series;
+import java.awt.image.BufferedImage;
+import java.awt.image.ColorModel;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.imageio.IIOImage;
+import javax.imageio.ImageIO;
+import javax.imageio.ImageReader;
+import javax.imageio.ImageWriteParam;
+import javax.imageio.ImageWriter;
+import javax.imageio.stream.FileImageOutputStream;
+import javax.imageio.stream.ImageInputStream;
+import org.dcm4che.data.Dataset;
+import org.dcm4che.dict.Tags;
+import org.dcm4che.imageio.plugins.DcmMetadata;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class JpegConvertorDelegate {
+
+    public JpegConvertorDelegate() {
+    }
+
+    /**
+     * This routine used to convert the dicom study to jpeg file based on the studyUID specified as parameter.
+     * @param studyIUID
+     * @param outputPath
+     */
+    public void studyLevelConvertor(String studyIUID, String outputPath) {
+        String patientName = ApplicationContext.databaseRef.getPatientNameBasedonStudyUID(studyIUID);
+        File patientNameFile = new File(outputPath, patientName);
+        if (!patientNameFile.exists()) {
+            patientNameFile.mkdirs();
+        }
+        ArrayList<Series> seriesList = ApplicationContext.databaseRef.getSeriesList(studyIUID);
+        Iterator<Series> seriesItr = seriesList.iterator();
+        while (seriesItr.hasNext()) {
+            Series series = seriesItr.next();
+            Iterator<Instance> imgitr = series.getImageList().iterator();
+            while (imgitr.hasNext()) {
+                Instance img = imgitr.next();
+                //   studyExportAsJpeg(img.getFilepath(), patientNameFile.getAbsolutePath());
+                if (img.isMultiframe()) {
+                    if (img.getCurrentFrameNum() == 0) {
+                        studyExportAsJpeg(img, patientNameFile.getAbsolutePath());
+                    }
+                } else {
+                    studyExportAsJpeg(img, patientNameFile.getAbsolutePath());
+                }
+            }
+        }
+    }
+
+    /**
+     * This routine used to convert the dicom series as jpeg file based on the seriesUID specified as parameter
+     * @param studyIUID
+     * @param seriesUID
+     * @param outputPath
+     * @param cm
+     */
+    public void seriesLevelConvertor(String studyIUID, String seriesUID, String outputPath, ColorModel cm) {
+        ArrayList<Series> seriesList = ApplicationContext.databaseRef.getSeriesList(studyIUID);
+        Iterator<Series> seriesItr = seriesList.iterator();
+        while (seriesItr.hasNext()) {
+            Series series = seriesItr.next();
+            if (series.getSeriesInstanceUID().equalsIgnoreCase(seriesUID)) {
+                Iterator<Instance> imgitr = series.getImageList().iterator();
+                while (imgitr.hasNext()) {
+                    Instance img = imgitr.next();
+                    // seriesExportAsJpeg(img, outputPath, cm);
+                    if (img.isMultiframe()) {
+                        if (img.getCurrentFrameNum() == 0) {
+                            seriesExportAsJpeg(img, outputPath, cm);
+
+                        }
+                    } else {
+                        seriesExportAsJpeg(img, outputPath, cm);
+                    }
+                }
+            }
+        }
+    }
+
+    public void seriesLevelConvertor(String studyIUID, String seriesUID, boolean multiframe, String instanceUID, String outputPath, ColorModel cm) {
+        ArrayList<Series> seriesList = ApplicationContext.databaseRef.getSeriesList(studyIUID);
+        Iterator<Series> seriesItr = seriesList.iterator();
+        while (seriesItr.hasNext()) {
+            Series series = seriesItr.next();
+            if (multiframe) {
+                if (series.isMultiframe() && series.getSeriesInstanceUID().equalsIgnoreCase(seriesUID) && series.getInstanceUID().equalsIgnoreCase(instanceUID)) {        //if multiframe image then instance uid also to be checked.
+                    Iterator<Instance> imgitr = series.getImageList().iterator();
+                    while (imgitr.hasNext()) {
+                        Instance img = imgitr.next();
+                        seriesExportAsJpeg(img.getFilepath(), outputPath, series.isMultiframe(), cm);
+                    }
+                }
+            } else if (ApplicationContext.imgPanel.isIsEncapsulatedDocument()) {
+                int i = 1;
+                ArrayList<BufferedImage> pdfArray = ApplicationContext.imgPanel.createPDFArray();
+                for (BufferedImage b : pdfArray) {
+                    instanceExportAsJpeg(outputPath + File.separator + i, b);
+                    i++;
+                }
+            } else {
+                if (!series.isMultiframe() && series.getSeriesInstanceUID().equalsIgnoreCase(seriesUID)) {        //if multiframe image then instance uid also to be checked.
+                    Iterator<Instance> imgitr = series.getImageList().iterator();
+                    while (imgitr.hasNext()) {
+                        Instance img = imgitr.next();
+                        seriesExportAsJpeg(img.getFilepath(), outputPath, series.isMultiframe(), cm);
+                    }
+                }
+            }
+        }
+    }
+
+    private void seriesExportAsJpeg(String inputFilePath, String outputPath, boolean multiframe, ColorModel cm) {
+        OutputStream output = null;
+        try {
+            File inputDicomFile = new File(inputFilePath);
+            int dotPos = inputDicomFile.getName().lastIndexOf(".");
+            String outputFileName = inputDicomFile.getName();
+            try {
+                String extension = inputDicomFile.getName().substring(dotPos);
+                if (extension.equalsIgnoreCase(".dcm")) {
+                    outputFileName = inputDicomFile.getName().replace(extension, "");
+                }
+            } catch (StringIndexOutOfBoundsException e) {
+                e.printStackTrace();
+            }
+            seriesExportAsJpegProcess(multiframe, inputDicomFile, outputPath, outputFileName, cm, output);
+        } catch (IOException ex) {
+            Logger.getLogger(MainScreen.class.getName()).log(Level.SEVERE, null, ex);
+        } catch (Exception ex) {
+            Logger.getLogger(MainScreen.class.getName()).log(Level.SEVERE, null, ex);
+        } finally {
+            try {
+                if (output != null) {
+                    output.close();
+                }
+            } catch (IOException ex) {
+                Logger.getLogger(MainScreen.class.getName()).log(Level.SEVERE, null, ex);
+            }
+        }
+    }
+
+    private void seriesExportAsJpegProcess(boolean multiframe, File inputDicomFile, String outputPath, String outputFileName, ColorModel cm, OutputStream output) throws IOException {
+        File outputJpegFile = null;
+        ImageInputStream iis = ImageIO.createImageInputStream(inputDicomFile);
+        BufferedImage jpegImage = null;
+        Iterator<ImageReader> iterator = ImageIO.getImageReadersByFormatName("DICOM");
+        ImageReader reader = (ImageReader) iterator.next();
+        reader.setInput(iis, false);
+        int nFrames = 1;
+        if (multiframe) {
+            nFrames = reader.getNumImages(true);
+        }
+        for (int i = 0; i < nFrames; i++) {
+            outputJpegFile = new File(outputPath, outputFileName + i + ".jpg");
+            jpegImage = reader.read(i);
+            BufferedImage temp = jpegImage;
+            if (cm != null) {
+                temp = new BufferedImage(cm, jpegImage.getRaster(), false, null);
+            }
+            if (System.getProperty("os.name").startsWith("Mac")) {
+                output = new BufferedOutputStream(new FileOutputStream(outputJpegFile));
+                JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(output);
+                encoder.encode(temp);
+                // output.close();
+            } else {
+                //For linux and windows
+                exportSeries(outputJpegFile, temp);
+            }
+        }
+    }
+
+    /**
+     * This routine used to convert the dicom instance as jpeg file based on the buffered image specified as parameter.
+     * @param outputPath
+     * @param bimg
+     */
+    public void instanceConvertor(String outputPath, BufferedImage bimg) {
+        instanceExportAsJpeg(outputPath, bimg);
+    }
+
+    /**
+     * This routine perform the core process for converting jpeg using input,output file path specified as parameter.
+     * @param inputFilePath
+     * @param outputPath
+     */
+    private void studyExportAsJpeg(Instance instance, String outputPath) {
+        OutputStream output = null;
+        try {
+            File inputDicomFile = new File(instance.getFilepath());
+            int dotPos = inputDicomFile.getName().lastIndexOf(".");
+            String outputFileName = inputDicomFile.getName();
+            try {
+                String extension = inputDicomFile.getName().substring(dotPos);
+                if (extension.equalsIgnoreCase(".dcm")) {
+                    outputFileName = inputDicomFile.getName().replace(extension, "");
+                }
+            } catch (StringIndexOutOfBoundsException e) {
+                e.printStackTrace();
+            }
+            studyExportAsJpegProcess(instance, outputPath, outputFileName, output, inputDicomFile);
+        } catch (Exception ex) {
+            Logger.getLogger(MainScreen.class.getName()).log(Level.SEVERE, null, ex);
+        } finally {
+            try {
+                if (output != null) {
+                    output.close();
+                }
+            } catch (Exception ex) {
+                Logger.getLogger(MainScreen.class.getName()).log(Level.SEVERE, null, ex);
+            }
+        }
+    }
+
+    private void studyExportAsJpegProcess(Instance instance, String outputPath, String outputFileName, OutputStream output, File inputDicomFile) throws IOException {
+        File outputJpegFile = new File(outputPath, outputFileName + ".jpg");
+        ImageInputStream iis = ImageIO.createImageInputStream(inputDicomFile);
+        BufferedImage jpegImage = null;
+        Iterator<ImageReader> iterator = ImageIO.getImageReadersByFormatName("DICOM");
+        ImageReader reader = (ImageReader) iterator.next();
+        reader.setInput(iis, false);
+        Dataset dataset = ((DcmMetadata) reader.getStreamMetadata()).getDataset();
+        int nFrames = 1;
+        if (instance.isMultiframe()) {
+            nFrames = reader.getNumImages(true);
+        }
+        for (int i = 0; i < nFrames; i++) {
+            outputJpegFile = new File(outputPath, outputFileName + i + ".jpg");
+            if (dataset.getString(Tags.SOPClassUID).equalsIgnoreCase("1.2.840.10008.5.1.4.1.1.104.1")) {
+                //This condition used to check whether the input file is a encapsulated pdf dicom file
+                //following lines of codes are used to create the jpeg image from the encapsulated pdf
+                int k = 1;
+                EncapsulatedPdfToJpeg encapsulatedPdfToJpeg = new EncapsulatedPdfToJpeg();
+                encapsulatedPdfToJpeg.readDicom(inputDicomFile);
+                ArrayList<BufferedImage> pdfArray = encapsulatedPdfToJpeg.createPDFArray();
+                for (BufferedImage b : pdfArray) {
+                    instanceExportAsJpeg(outputPath + File.separator + k, b);
+                    k++;
+                }
+            } else {
+                jpegImage = reader.read(i);
+                BufferedImage temp = jpegImage;
+                if (System.getProperty("os.name").startsWith("Mac")) {
+                    output = new BufferedOutputStream(new FileOutputStream(outputJpegFile));
+                    JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(output);
+                    encoder.encode(jpegImage);
+                    //  output.close();
+                } else {
+                    //For linux and windows
+                    exportStudy(outputJpegFile, jpegImage);
+                }
+            }
+        }
+    }
+
+    public void exportStudy(File outputJpegFile, BufferedImage jpegImage) {
+        FileImageOutputStream ios = null;
+        ImageWriter writer = null;
+        try {
+            Iterator it = ImageIO.getImageWritersByFormatName("jpeg");
+            writer = (ImageWriter) it.next();
+            ImageWriteParam param = writer.getDefaultWriteParam();
+            param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
+            param.setCompressionQuality(1);
+            ios = new FileImageOutputStream(outputJpegFile);
+            writer.setOutput(ios);
+            IIOImage iioImage = new IIOImage(jpegImage, null, null);
+            writer.write(null, iioImage, param);          
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (ios != null) {
+                try {
+                    ios.close();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                    // ignore
+                }
+                if (writer != null) {
+                    try {
+                        writer.dispose();
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                        // ignore
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * This routine performs the core process for converting jpeg using input, output file specified as parameter.
+     * It will generate the output jpeg file with colormodel specified as arguments.
+     * @param inputFilePath
+     * @param outputPath
+     * @param cm
+     */
+    private void seriesExportAsJpeg(Instance instance, String outputPath, ColorModel cm) {
+        OutputStream output = null;
+        try {
+            File inputDicomFile = new File(instance.getFilepath());
+            int dotPos = inputDicomFile.getName().lastIndexOf(".");
+            String outputFileName = inputDicomFile.getName();
+            try {
+                String extension = inputDicomFile.getName().substring(dotPos);
+                if (extension.equalsIgnoreCase(".dcm")) {
+                    outputFileName = inputDicomFile.getName().replace(extension, "");
+                }
+            } catch (StringIndexOutOfBoundsException e) {
+                e.printStackTrace();
+            }
+            seriesExportAsJpegProcess(instance, outputPath, cm, inputDicomFile, output, outputFileName);
+        } catch (IOException ex) {
+            Logger.getLogger(MainScreen.class.getName()).log(Level.SEVERE, null, ex);
+        } catch (Exception ex) {
+            Logger.getLogger(MainScreen.class.getName()).log(Level.SEVERE, null, ex);
+        } finally {
+            try {
+                if (output != null) {
+                    output.close();
+                }
+            } catch (IOException ex) {
+                Logger.getLogger(MainScreen.class.getName()).log(Level.SEVERE, null, ex);
+            }
+        }
+    }
+
+    private void seriesExportAsJpegProcess(Instance instance, String outputPath, ColorModel cm, File inputDicomFile, OutputStream output, String outputFileName) throws IOException {
+        File outputJpegFile = null;
+        ImageInputStream iis = ImageIO.createImageInputStream(inputDicomFile);
+        BufferedImage jpegImage = null;
+        Iterator<ImageReader> iterator = ImageIO.getImageReadersByFormatName("DICOM");
+        ImageReader reader = (ImageReader) iterator.next();
+        reader.setInput(iis, false);
+        jpegImage = reader.read(instance.getCurrentFrameNum());
+
+        int nFrames = 1;
+        if (instance.isMultiframe()) {
+            nFrames = reader.getNumImages(true);
+
+        }
+        for (int i = 0; i < nFrames; i++) {
+            outputJpegFile = new File(outputPath, outputFileName + i + ".jpg");
+            jpegImage = reader.read(i);
+            BufferedImage temp = jpegImage;
+            if (cm != null) {
+                temp = new BufferedImage(cm, jpegImage.getRaster(), false, null);
+            }
+            if (System.getProperty("os.name").startsWith("Mac")) {
+                output = new BufferedOutputStream(new FileOutputStream(outputJpegFile));
+                JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(output);
+                encoder.encode(temp);
+                // output.close();
+            } else {
+                //For linux and windows
+                exportSeries(outputJpegFile, temp);
+            }
+        }
+    }
+
+    public void exportSeries(File outputJpegFile, BufferedImage temp) {
+        FileImageOutputStream ios = null;
+        ImageWriter writer = null;
+        try {
+            Iterator it = ImageIO.getImageWritersByFormatName("jpeg");
+            writer = (ImageWriter) it.next();
+            ImageWriteParam param = writer.getDefaultWriteParam();
+            param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
+            param.setCompressionQuality(1);
+            ios = new FileImageOutputStream(outputJpegFile);
+            writer.setOutput(ios);
+            IIOImage iioImage = new IIOImage(temp, null, null);
+            writer.write(null, iioImage, param);           
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (ios != null) {
+                try {
+                    ios.close();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                    // ignore
+                }
+                if (writer != null) {
+                    try {
+                        writer.dispose();
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                        // ignore
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * This routine performs the core process for converting jpeg file using the output filepath,buffered image specified as parameter.
+     *
+     * @param outputPath
+     * @param bimg
+     */
+    private void instanceExportAsJpeg(String outputPath, BufferedImage bimg) {
+        OutputStream output = null;
+        try {
+            File outputJpegFile = new File(outputPath + ".jpg");
+            BufferedImage jpegImage = bimg;
+            if (System.getProperty("os.name").startsWith("Mac")) {
+                output = new BufferedOutputStream(new FileOutputStream(outputJpegFile));
+                JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(output);
+                encoder.encode(jpegImage);
+                // output.close();
+            } else {
+                //For linux and windows
+                exportInstance(outputJpegFile, jpegImage);
+            }
+        } catch (IOException ex) {
+            Logger.getLogger(MainScreen.class.getName()).log(Level.SEVERE, null, ex);
+        } catch (Exception ex) {
+            Logger.getLogger(MainScreen.class.getName()).log(Level.SEVERE, null, ex);
+        } finally {
+            try {
+                if (output != null) {
+                    output.close();
+                }
+            } catch (IOException ex) {
+                ex.printStackTrace();
+                //Logger.getLogger(MainScreen.class.getName()).log(Level.SEVERE, null, ex);
+            }
+        }
+
+    }
+
+    public void exportInstance(File outputJpegFile, BufferedImage jpegImage) {
+        FileImageOutputStream ios = null;
+        ImageWriter writer = null;
+        try {
+            Iterator it = ImageIO.getImageWritersByFormatName("jpeg");
+            writer = (ImageWriter) it.next();
+            ImageWriteParam param = writer.getDefaultWriteParam();
+            param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
+            param.setCompressionQuality(1);
+            ios = new FileImageOutputStream(outputJpegFile);
+            writer.setOutput(ios);
+            IIOImage iioImage = new IIOImage(jpegImage, null, null);
+            writer.write(null, iioImage, param);             
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (ios != null) {
+                try {
+                    ios.close();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                    // ignore
+                }
+                if (writer != null) {
+                    try {
+                        writer.dispose();
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                        // ignore
+                    }
+                }
+            }
+        }
+    }
+}
diff --git a/src/in/raster/mayam/delegate/LocalizerDelegate.java b/src/in/raster/mayam/delegate/LocalizerDelegate.java
new file mode 100644
index 0000000..8a37108
--- /dev/null
+++ b/src/in/raster/mayam/delegate/LocalizerDelegate.java
@@ -0,0 +1,160 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.delegate;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.form.ImagePanel;
+import in.raster.mayam.form.LayeredCanvas;
+import in.raster.mayam.util.localizer.SliceLocator;
+import in.raster.mayam.model.ScoutLineInfoModel;
+import javax.swing.JPanel;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.6
+ *
+ */
+public class LocalizerDelegate {
+
+    private SliceLocator locator = new SliceLocator();
+
+    public LocalizerDelegate() {
+    }
+
+    public boolean drawScoutLine() {
+        boolean retVal = false;
+        if (ApplicationContext.imgPanel != null) {
+            if (!ApplicationContext.imgPanel.isLocalizer()) {
+                for (int j = 0; j < ((JPanel) ApplicationContext.imgView.jTabbedPane1.getSelectedComponent()).getComponentCount(); j++) {
+                    try {
+                        if (ApplicationContext.imgPanel.getReferencedSOPInstanceUID().equalsIgnoreCase(((LayeredCanvas) ((JPanel) ApplicationContext.imgView.jTabbedPane1.getSelectedComponent()).getComponent(j)).imgpanel.getInstanceUID())) {
+                            String scoutPos = ((LayeredCanvas) ((JPanel) ApplicationContext.imgView.jTabbedPane1.getSelectedComponent()).getComponent(j)).imgpanel.getImagePosition();
+                            String scoutOrientation = ((LayeredCanvas) ((JPanel) ApplicationContext.imgView.jTabbedPane1.getSelectedComponent()).getComponent(j)).imgpanel.getImageOrientation();
+                            String scoutPixelSpacing = ((LayeredCanvas) ((JPanel) ApplicationContext.imgView.jTabbedPane1.getSelectedComponent()).getComponent(j)).imgpanel.getPixelSpacing();
+                            int scoutRow = ((LayeredCanvas) ((JPanel) ApplicationContext.imgView.jTabbedPane1.getSelectedComponent()).getComponent(j)).imgpanel.getRow();
+                            int scoutColumn = ((LayeredCanvas) ((JPanel) ApplicationContext.imgView.jTabbedPane1.getSelectedComponent()).getComponent(j)).imgpanel.getColumn();
+                            String imgPos = ApplicationContext.imgPanel.getImagePosition();
+                            String imgOrientation = ApplicationContext.imgPanel.getImageOrientation();
+                            String imgPixelSpacing = ApplicationContext.imgPanel.getPixelSpacing();
+                            int imgRow = ApplicationContext.imgPanel.getRow();
+                            int imgColumn = ApplicationContext.imgPanel.getColumn();
+                            locator.projectSlice(scoutPos, scoutOrientation, scoutPixelSpacing, scoutRow, scoutColumn, imgPos, imgOrientation, imgPixelSpacing, imgRow, imgColumn);
+                            ((LayeredCanvas) ((JPanel) ApplicationContext.imgView.jTabbedPane1.getSelectedComponent()).getComponent(j)).imgpanel.setScoutCoordinates((int) locator.getBoxUlx(), (int) locator.getBoxUly(), (int) locator.getBoxLlx(), (int) locator.getBoxLly(), (int) locator.getBoxUrx(), (int) locator.getBoxUry(), (int) locator.getBoxLrx(), (int) locator.getBoxLry());
+                            retVal = true;
+                        }
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
+                }
+            }
+        }
+        return retVal;
+    }
+
+    public static void hideScoutLine() {
+        if (ApplicationContext.imgPanel != null) {
+            if (!ApplicationContext.imgPanel.isLocalizer()) {
+                for (int j = 0; j < ((JPanel) ApplicationContext.imgView.jTabbedPane1.getSelectedComponent()).getComponentCount(); j++) {
+                    try {
+                        LayeredCanvas temp = ((LayeredCanvas) ((JPanel) ApplicationContext.imgView.jTabbedPane1.getSelectedComponent()).getComponent(j));
+                        if (ApplicationContext.imgPanel.getReferencedSOPInstanceUID() != null && temp.imgpanel != null && ApplicationContext.imgPanel.getReferencedSOPInstanceUID().equalsIgnoreCase(temp.imgpanel.getInstanceUID())) {
+                            if (ApplicationContext.imgPanel.getFrameOfReferenceUID().equalsIgnoreCase(temp.imgpanel.getFrameOfReferenceUID())) {
+                                temp.imgpanel.repaint();
+                            }
+                        }
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
+                }
+            }
+        }
+    }
+
+    public boolean drawScoutLineWithBorder() {
+        boolean retVal = false;
+        if (ApplicationContext.imgPanel != null) {
+            if (!ApplicationContext.imgPanel.isLocalizer()) {
+                ImagePanel.setDisplayScout(true);
+                for (int j = 0; j < ((JPanel) ApplicationContext.imgView.jTabbedPane1.getSelectedComponent()).getComponentCount(); j++) {
+                    try {
+                        LayeredCanvas temp = ((LayeredCanvas) ((JPanel) ApplicationContext.imgView.jTabbedPane1.getSelectedComponent()).getComponent(j));
+                        if (ApplicationContext.imgPanel.getReferencedSOPInstanceUID() != null && temp.imgpanel != null && ApplicationContext.imgPanel.getReferencedSOPInstanceUID().equalsIgnoreCase(temp.imgpanel.getInstanceUID())) {
+                            projectSlice(temp);
+
+                        } else {
+                            if (temp.imgpanel != null && temp.imgpanel.isLocalizer()) {
+                                if (ApplicationContext.imgPanel.getFrameOfReferenceUID().equalsIgnoreCase(temp.imgpanel.getFrameOfReferenceUID())) {
+                                    projectSlice(temp);
+                                }
+                            }
+                        }
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
+                }
+            }
+        }
+        return retVal;
+    }
+
+    private boolean projectSlice(LayeredCanvas temp) {
+        String scoutPos = temp.imgpanel.getImagePosition();
+        String scoutOrientation = temp.imgpanel.getImageOrientation();
+        String scoutPixelSpacing = temp.imgpanel.getPixelSpacing();
+        int scoutRow = temp.imgpanel.getRow();
+        int scoutColumn = temp.imgpanel.getColumn();
+        String imgPos = ApplicationContext.imgPanel.getImagePosition();
+        String imgOrientation = ApplicationContext.imgPanel.getImageOrientation();
+        String imgPixelSpacing = ApplicationContext.imgPanel.getPixelSpacing();
+        int imgRow = ApplicationContext.imgPanel.getRow();
+        int imgColumn = ApplicationContext.imgPanel.getColumn();
+        ScoutLineInfoModel[] borderLineArray = ApplicationContext.imgPanel.getScoutBorder();
+        locator.projectSlice(scoutPos, scoutOrientation, scoutPixelSpacing, scoutRow, scoutColumn, borderLineArray[0].getImagePosition(), borderLineArray[0].getImageOrientation(), borderLineArray[0].getImagePixelSpacing(), borderLineArray[0].getImageRow(), borderLineArray[0].getImageColumn());
+        temp.imgpanel.setScoutBorder1Coordinates((int) locator.getBoxUlx(), (int) locator.getBoxUly(), (int) locator.getBoxLlx(), (int) locator.getBoxLly());
+        temp.imgpanel.setAxis1Coordinates((int) locator.getmAxisLeftx(), (int) locator.getmAxisLefty(), (int) locator.getmAxisRightx(), (int) locator.getmAxisRighty(), (int) locator.getmAxisTopx(), (int) locator.getmAxisTopy(), (int) locator.getmAxisBottomx(), (int) locator.getmAxisBottomy());
+        locator.projectSlice(scoutPos, scoutOrientation, scoutPixelSpacing, scoutRow, scoutColumn, borderLineArray[1].getImagePosition(), borderLineArray[1].getImageOrientation(), borderLineArray[1].getImagePixelSpacing(), borderLineArray[1].getImageRow(), borderLineArray[1].getImageColumn());
+        temp.imgpanel.setScoutBorder2Coordinates((int) locator.getBoxUlx(), (int) locator.getBoxUly(), (int) locator.getBoxLlx(), (int) locator.getBoxLly());
+        temp.imgpanel.setAxis2Coordinates((int) locator.getmAxisLeftx(), (int) locator.getmAxisLefty(), (int) locator.getmAxisRightx(), (int) locator.getmAxisRighty(), (int) locator.getmAxisTopx(), (int) locator.getmAxisTopy(), (int) locator.getmAxisBottomx(), (int) locator.getmAxisBottomy());
+        locator.projectSlice(scoutPos, scoutOrientation, scoutPixelSpacing, scoutRow, scoutColumn, imgPos, imgOrientation, imgPixelSpacing, imgRow, imgColumn);
+        temp.imgpanel.setScoutCoordinates((int) locator.getBoxUlx(), (int) locator.getBoxUly(), (int) locator.getBoxLlx(), (int) locator.getBoxLly(), (int) locator.getBoxUrx(), (int) locator.getBoxUry(), (int) locator.getBoxLrx(), (int) locator.getBoxLry());
+        temp.imgpanel.setAxisCoordinates((int) locator.getmAxisLeftx(), (int) locator.getmAxisLefty(), (int) locator.getmAxisRightx(), (int) locator.getmAxisRighty(), (int) locator.getmAxisTopx(), (int) locator.getmAxisTopy(), (int) locator.getmAxisBottomx(), (int) locator.getmAxisBottomy());
+        return true;
+    }
+}
diff --git a/src/in/raster/mayam/delegate/MoveDelegate.java b/src/in/raster/mayam/delegate/MoveDelegate.java
new file mode 100644
index 0000000..ea1b7dc
--- /dev/null
+++ b/src/in/raster/mayam/delegate/MoveDelegate.java
@@ -0,0 +1,76 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.delegate;
+
+
+import in.raster.mayam.util.core.MoveScu;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class MoveDelegate extends Thread{
+   String moveArg[];
+    public MoveDelegate(String moveArg[]) {      
+     this.moveArg=moveArg;
+        this.start();
+    }
+    /**
+     * This routine used to perform CMove
+     * @param moveArg
+     */
+    public void move(String moveArg[])
+    {
+        try {
+            MoveScu.main(moveArg);           
+        } catch (Exception ex) {
+            Logger.getLogger(MoveDelegate.class.getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+    public void run()
+    {
+        move(this.moveArg);
+    }
+   
+}
diff --git a/src/in/raster/mayam/delegate/NetworkQueueUpdateDelegate.java b/src/in/raster/mayam/delegate/NetworkQueueUpdateDelegate.java
new file mode 100644
index 0000000..2c41713
--- /dev/null
+++ b/src/in/raster/mayam/delegate/NetworkQueueUpdateDelegate.java
@@ -0,0 +1,144 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.delegate;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.form.MainScreen;
+import in.raster.mayam.form.SendReceivePanel;
+import java.io.EOFException;
+import java.io.File;
+import java.io.IOException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.swing.SwingUtilities;
+import javax.swing.table.DefaultTableModel;
+import org.dcm4che2.data.BasicDicomObject;
+import org.dcm4che2.data.DicomObject;
+import org.dcm4che2.data.Tag;
+import org.dcm4che2.io.DicomInputStream;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class NetworkQueueUpdateDelegate {
+
+    public DefaultTableModel receiveTableModel;
+    public DefaultTableModel sendTableModel;
+    private boolean rowAlreadyPresent;
+
+    public NetworkQueueUpdateDelegate() {
+        receiveTableModel = SendReceivePanel.receiveTableModel;
+        sendTableModel = SendReceivePanel.sendTableModel;
+    }
+
+    /**
+     * This routine used to update the receiver table in the network queue.
+     * @param fileObj
+     * @param calledAET
+     */
+    public void updateReceiveTable(File fileObj, String calledAET) {
+        DicomInputStream dis = null;
+        try {
+            File parseFile = fileObj;
+            try {
+                dis = new DicomInputStream(parseFile);
+            } catch (IOException ex) {
+                Logger.getLogger(NetworkQueueUpdateDelegate.class.getName()).log(Level.SEVERE, null, ex);
+            }
+            DicomObject data = new BasicDicomObject();
+            try {
+                data = dis.readDicomObject();
+            } catch (EOFException e) {
+                e.printStackTrace();
+            }
+            if (data != null) {
+                ApplicationContext.databaseRef.writeDataToDatabase(data);
+                rowAlreadyPresent = false;
+                if (SendReceivePanel.receiveTableModel.getRowCount() > 0) {
+                    for (int i = 0; i < SendReceivePanel.receiveTableModel.getRowCount(); i++) {
+                        if (SendReceivePanel.receiveTableModel.getValueAt(i, 3).toString().equalsIgnoreCase(data.getString(Tag.StudyDate)) && SendReceivePanel.receiveTableModel.getValueAt(i, 1).toString().equalsIgnoreCase(data.getString(Tag.PatientID).toString())) {
+                            DateFormat df = new SimpleDateFormat("kk:mm:ss");
+                            Date d = new Date();
+                            int receivedCount = ApplicationContext.databaseRef.getReceiveCount(data.getString(Tag.StudyInstanceUID));
+                            //receivedCount = receivedCount;
+                            SendReceivePanel.receiveTableModel.setValueAt(df.format(d), i, 8);
+                            SendReceivePanel.receiveTableModel.setValueAt(String.valueOf(receivedCount), i, 5);
+                            SendReceivePanel.receiveTableModel.setValueAt(String.valueOf(receivedCount), i, 6);
+                            rowAlreadyPresent = true;
+                        }
+                    }
+                }
+                if (!rowAlreadyPresent) {
+                    SwingUtilities.invokeLater(new Runnable() {
+
+                        public void run() {
+                            MainScreen.refreshLocalDBStorage();
+                        }
+                    });
+                    SendReceivePanel.receiveTableModel.insertRow(SendReceivePanel.receiveTableModel.getRowCount(), new Object[]{calledAET, data.getString(Tag.PatientID), data.getString(Tag.PatientName), data.getString(Tag.StudyDate), data.getString(Tag.StudyDescription), "1", "1", "", getCurrentTime(), ""});
+                }
+            }           
+        } catch (IOException ex) {
+            ex.printStackTrace();
+            //  Logger.getLogger(NetworkQueueUpdate.clas   s.getName()).log(Level.SEVERE, null, ex);
+        } finally {
+            if (dis != null) {
+                try {
+                    dis.close();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                    // ignore
+                }
+            }
+        }
+
+    }
+
+    public static String getCurrentTime() {
+        DateFormat df = new SimpleDateFormat("kk:mm:ss");
+        Date d = new Date();
+        return df.format(d);
+    }
+}
diff --git a/src/in/raster/mayam/delegate/QueryInstanceService.java b/src/in/raster/mayam/delegate/QueryInstanceService.java
new file mode 100644
index 0000000..519e7c0
--- /dev/null
+++ b/src/in/raster/mayam/delegate/QueryInstanceService.java
@@ -0,0 +1,161 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.delegate;
+
+import de.iftm.dcm4che.services.CDimseService;
+import de.iftm.dcm4che.services.ConfigProperties;
+import de.iftm.dcm4che.services.StorageService;
+import in.raster.mayam.context.ApplicationContext;
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+import java.text.ParseException;
+import java.util.Vector;
+import org.dcm4che.util.DcmURL;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.7
+ *
+ */
+public class QueryInstanceService {
+
+    private int numberofInstances;
+    private Vector datasetVector;
+
+    public QueryInstanceService() {
+        String[] s = ApplicationContext.databaseRef.getListenerDetails();
+        CDimseService.DEFAULT_CALLING_AET = s[0];
+    }
+
+    /**
+     * Queries(cFIND) the Patient/Study informations from the machine(dcmProtocol://aeTitle@hostName:port).
+     *
+     * @param searchPatientID
+     * @param SearchPatientName
+     * @param searchDob
+     * @param searchtoday
+     * @param searchsterday
+     * @param searchModality
+     */
+    @SuppressWarnings("unchecked")
+    public void callFindWithQuery(String patientID, String studyInstanceUID, String seriesInstanceUID, DcmURL url) {
+
+        ConfigProperties cfgCDimseService;
+        boolean isOpen;
+        // Vector object to keep the queried Datasets.
+
+        CDimseService cDimseService;
+
+        // Load configuration properties of the server
+        try {
+            cfgCDimseService = new ConfigProperties(StorageService.class.getResource("/resources/Image.cfg"));
+        } catch (IOException e) {
+            System.out.println(e.getMessage());
+            System.out.println("Unable to create ConfigProperties instance");
+            return;
+        }
+
+        /*
+         * Setting filter values for query such as patientId, patientName etc.
+         */
+        try {
+            cfgCDimseService.put("key.PatientID", patientID);
+            cfgCDimseService.put("key.StudyInstanceUID", studyInstanceUID);
+            cfgCDimseService.put("key.SeriesInstanceUID", seriesInstanceUID);
+        } catch (Exception e) {
+            System.out.println("Unable to set Key values for query");
+        }
+
+        try {
+            cDimseService = new CDimseService(cfgCDimseService, url);
+
+        } catch (ParseException e) {
+            System.out.println("Unable to create CDimseService instance");
+            return;
+
+        }
+
+        // Open association
+        try {
+            isOpen = cDimseService.aASSOCIATE();
+            if (!isOpen) {
+                return;
+            }
+        } catch (IOException e) {
+            System.out.println(e.getMessage());
+            return;
+        } catch (GeneralSecurityException e) {
+            System.out.println(e.getMessage());
+            return;
+        }
+        // cFIND (Queries for datasets).
+        try {
+            datasetVector = cDimseService.cFIND();
+
+
+        } catch (Exception e) {
+            System.out.println(e.getMessage());
+            return;
+        }
+
+        numberofInstances = datasetVector.size();
+        /*
+         * Gets the Dataset form the datasetVector and adds it to the
+         * patientList and adds the studies to the corresponding patientList.
+         */
+
+        try {
+            cDimseService.aRELEASE(true);
+        } catch (IOException e) {
+            System.out.println(e.getMessage());
+        } catch (InterruptedException e) {
+            System.out.println(e.getMessage());
+        }
+
+    }
+
+    public Vector getDatasetVector() {
+        return datasetVector;
+    }
+
+    public void setDatasetVector(Vector datasetVector) {
+        this.datasetVector = datasetVector;
+    }
+}
diff --git a/src/in/raster/mayam/delegate/QuerySeriesService.java b/src/in/raster/mayam/delegate/QuerySeriesService.java
new file mode 100644
index 0000000..2945a32
--- /dev/null
+++ b/src/in/raster/mayam/delegate/QuerySeriesService.java
@@ -0,0 +1,162 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.delegate;
+
+import de.iftm.dcm4che.services.CDimseService;
+import de.iftm.dcm4che.services.ConfigProperties;
+import de.iftm.dcm4che.services.StorageService;
+import in.raster.mayam.context.ApplicationContext;
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+import java.text.ParseException;
+import java.util.Vector;
+import org.dcm4che.util.DcmURL;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.7
+ *
+ */
+public class QuerySeriesService {
+
+    private int numberofSeries;
+    private Vector datasetVector;
+
+    public QuerySeriesService() {
+        String[] s = ApplicationContext.databaseRef.getListenerDetails();
+        CDimseService.DEFAULT_CALLING_AET = s[0];
+    }
+
+    /**
+     * Queries(cFIND) the Patient/Study informations from the machine(dcmProtocol://aeTitle@hostName:port).
+     *
+     * @param searchPatientID
+     * @param SearchPatientName
+     * @param searchDob
+     * @param searchtoday
+     * @param searchsterday
+     * @param searchModality
+     */
+    @SuppressWarnings("unchecked")
+    public void callFindWithQuery(String patientID, String studyInstanceUID, DcmURL url) {
+
+        ConfigProperties cfgCDimseService;
+        boolean isOpen;
+        // Vector object to keep the queried Datasets.
+
+        CDimseService cDimseService;
+
+        // Load configuration properties of the server
+        try {
+            cfgCDimseService = new ConfigProperties(StorageService.class.getResource("/resources/Series.cfg"));
+        } catch (IOException e) {
+            System.out.println(e.getMessage());
+            System.out.println("Unable to create ConfigProperties instance");
+            return;
+        }
+
+        /*
+         * Setting filter values for query such as patientId, patientName etc.
+         */
+        try {
+            if(patientID!=null)
+            cfgCDimseService.put("key.PatientID", patientID);
+            if(studyInstanceUID!=null)
+            cfgCDimseService.put("key.StudyInstanceUID", studyInstanceUID);
+        } catch (Exception e) {
+            System.out.println("Unable to set Key values for query");
+        }
+
+        try {
+            cDimseService = new CDimseService(cfgCDimseService, url);
+
+        } catch (ParseException e) {
+            System.out.println("Unable to create CDimseService instance");
+            return;
+
+        }
+
+        // Open association
+        try {
+            isOpen = cDimseService.aASSOCIATE();
+            if (!isOpen) {
+                return;
+            }
+        } catch (IOException e) {
+            System.out.println(e.getMessage());
+            return;
+        } catch (GeneralSecurityException e) {
+            System.out.println(e.getMessage());
+            return;
+        }
+        // cFIND (Queries for datasets).
+        try {
+            datasetVector = cDimseService.cFIND();
+
+
+        } catch (Exception e) {
+            System.out.println(e.getMessage());
+            return;
+        }
+
+        numberofSeries = datasetVector.size();
+        /*
+         * Gets the Dataset form the datasetVector and adds it to the
+         * patientList and adds the studies to the corresponding patientList.
+         */
+
+        try {
+            cDimseService.aRELEASE(true);
+        } catch (IOException e) {
+            System.out.println(e.getMessage());
+        } catch (InterruptedException e) {
+            System.out.println(e.getMessage());
+        }
+
+    }
+
+    public Vector getDatasetVector() {
+        return datasetVector;
+    }
+
+    public void setDatasetVector(Vector datasetVector) {
+        this.datasetVector = datasetVector;
+    }
+}
diff --git a/src/in/raster/mayam/delegate/QueryService.java b/src/in/raster/mayam/delegate/QueryService.java
new file mode 100644
index 0000000..b4aec2a
--- /dev/null
+++ b/src/in/raster/mayam/delegate/QueryService.java
@@ -0,0 +1,183 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.delegate;
+
+
+import de.iftm.dcm4che.services.CDimseService;
+import de.iftm.dcm4che.services.ConfigProperties;
+import de.iftm.dcm4che.services.StorageService;
+import in.raster.mayam.context.ApplicationContext;
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+import java.text.ParseException;
+import java.util.Vector;
+import org.dcm4che.util.DcmURL;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class QueryService {
+
+    private int numberofStudies;
+    private Vector datasetVector;
+
+    public QueryService() {
+        String[] s = ApplicationContext.databaseRef.getListenerDetails();
+        CDimseService.DEFAULT_CALLING_AET=s[0];
+    }
+    /**
+     * Queries(cFIND) the Patient/Study informations from the machine(dcmProtocol://aeTitle@hostName:port).
+     *
+     * @param searchPatientID
+     * @param SearchPatientName
+     * @param searchDob
+     * @param searchtoday
+     * @param searchsterday
+     * @param searchModality
+     */
+    @SuppressWarnings("unchecked")
+    public void callFindWithQuery(String searchPatientID,
+            String SearchPatientName, String searchDob, String searchtoday,
+            String searchModality,String searchAccNo,String studyUID, DcmURL url) {
+
+        ConfigProperties cfgCDimseService;
+        boolean isOpen;
+        // Vector object to keep the queried Datasets.
+
+        CDimseService cDimseService;
+
+        // Load configuration properties of the server
+        try {
+            cfgCDimseService = new ConfigProperties(StorageService.class.getResource("/resources/CDimseService.cfg"));
+        } catch (IOException e) {
+            System.out.println(e.getMessage());
+            System.out.println("Unable to create ConfigProperties instance");
+            return;
+        }
+
+        /*
+         * Setting filter values for query such as patientId, patientName etc.
+         */
+        try {
+            if(searchPatientID!=null)
+            cfgCDimseService.put("key.PatientID", searchPatientID);
+
+            if(SearchPatientName!=null)
+            cfgCDimseService.put("key.PatientName", SearchPatientName + "*");
+
+            if (searchtoday!=null && searchtoday.length() > 0) {
+                cfgCDimseService.put("key.StudyDate", searchtoday);
+            }
+
+            if (searchDob!=null && searchDob.length() > 0) {
+                cfgCDimseService.put("key.PatientBirthDate", searchDob);
+            }
+             if (searchAccNo!=null && searchAccNo.length() > 0) {
+                cfgCDimseService.put("key.AccessionNumber", searchAccNo);
+            }
+            if (searchModality!=null ) {
+                searchModality = searchModality.toUpperCase();            
+                cfgCDimseService.put("key.ModalitiesInStudy", searchModality);
+            }
+              if(studyUID!=null)
+            cfgCDimseService.put("key.StudyInstanceUID", studyUID);
+
+        } catch (Exception e) {           
+            System.out.println("Unable to set Key values for query");
+        }
+
+        try {
+            cDimseService = new CDimseService(cfgCDimseService, url);
+
+        } catch (ParseException e) {
+            System.out.println("Unable to create CDimseService instance");
+            return;
+
+        }
+
+        // Open association
+        try {
+            isOpen = cDimseService.aASSOCIATE();
+            if (!isOpen) {
+                return;
+            }
+        } catch (IOException e) {
+            System.out.println(e.getMessage());
+            return;
+        } catch (GeneralSecurityException e) {
+            System.out.println(e.getMessage());
+            return;
+        }
+        // cFIND (Queries for datasets).
+        try {
+            datasetVector = cDimseService.cFIND();
+
+
+        } catch (Exception e) {
+            System.out.println(e.getMessage());
+            return;
+        }
+
+        numberofStudies = datasetVector.size();
+        /*
+         * Gets the Dataset form the datasetVector and adds it to the
+         * patientList and adds the studies to the corresponding patientList.
+         */
+
+        try {
+            cDimseService.aRELEASE(true);
+        } catch (IOException e) {
+            System.out.println(e.getMessage());
+        } catch (InterruptedException e) {
+            System.out.println(e.getMessage());
+        }
+
+    }
+
+    public Vector getDatasetVector() {
+        return datasetVector;
+    }
+
+    public void setDatasetVector(Vector datasetVector) {
+        this.datasetVector = datasetVector;
+    }
+}
diff --git a/src/in/raster/mayam/delegate/ReceiveDelegate.java b/src/in/raster/mayam/delegate/ReceiveDelegate.java
new file mode 100644
index 0000000..6678407
--- /dev/null
+++ b/src/in/raster/mayam/delegate/ReceiveDelegate.java
@@ -0,0 +1,94 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.delegate;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.util.core.DcmRcv;
+import in.raster.mayam.util.core.MoveScu;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class ReceiveDelegate {
+
+    private DcmRcv dcmrcv = null;
+    private int port;
+
+    public ReceiveDelegate() {
+        try {
+            InetAddress thisIp = InetAddress.getLocalHost();
+            String[] s = ApplicationContext.databaseRef.getListenerDetails();
+            dcmrcv = new DcmRcv();
+            dcmrcv.setAEtitle(s[0]);
+            dcmrcv.setHostname("0.0.0.0");
+            dcmrcv.setPort(Integer.parseInt(s[1]));
+            this.port = Integer.parseInt(s[1]);
+            dcmrcv.setDestination(s[2]);
+            dcmrcv.setPackPDV(false);
+            dcmrcv.setTcpNoDelay(false);
+            dcmrcv.initTransferCapability();
+            dcmrcv.setTlsNeedClientAuth(false);
+            MoveScu.maskNull(s[0]);
+        } catch (UnknownHostException ex) {
+            Logger.getLogger(ReceiveDelegate.class.getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+
+    public void start() throws Exception {
+        dcmrcv.start();
+    }
+
+    public void stop() {
+        if (dcmrcv != null) {
+            dcmrcv.stop();
+            dcmrcv = null;
+        }
+    }
+
+    public int getPort() {
+        return port;
+    }
+}
diff --git a/src/in/raster/mayam/delegate/RemoveStudy.java b/src/in/raster/mayam/delegate/RemoveStudy.java
new file mode 100644
index 0000000..712996e
--- /dev/null
+++ b/src/in/raster/mayam/delegate/RemoveStudy.java
@@ -0,0 +1,90 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.delegate;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.form.LayoutManagerPanel;
+import in.raster.mayam.form.MainScreen;
+import in.raster.mayam.model.Series;
+import in.raster.mayam.model.Study;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.6
+ *
+ */
+public class RemoveStudy {
+
+    public RemoveStudy() {
+    }
+
+    public synchronized static void removeStudyFromStudylist(Study study) {
+        if (MainScreen.selectedStudy.equalsIgnoreCase(study.getStudyInstanceUID())) {
+            if(!LayoutManagerPanel.updateSeries){
+            for (Study tempStudy : MainScreen.studyList) {
+                synchronized (MainScreen.studyList) {
+                    if (tempStudy.getStudyInstanceUID().equalsIgnoreCase(study.getStudyInstanceUID())) {
+                        synchronized (tempStudy.getSeriesList()) {
+                            Series notTobeDeleted = null;
+                            for (Series series : tempStudy.getSeriesList()) {
+                                if (series.getSeriesInstanceUID().equalsIgnoreCase(MainScreen.selectedSeries)) {
+                                    notTobeDeleted = series;
+                                    break;
+                                }
+                            }
+                            tempStudy.getSeriesList().clear();
+                            tempStudy.addSeries(notTobeDeleted);
+                            notTobeDeleted = null;
+                        }
+                    }
+                }
+            }
+            }
+            else
+            {
+                MainScreen.studyList.remove(study);               
+                ApplicationContext.mainScreen.showThumbnails();              
+                LayoutManagerPanel.updateSeries=false;
+            }
+        } else {
+            MainScreen.studyList.remove(study);
+        }
+    }
+}
diff --git a/src/in/raster/mayam/delegate/SendingDelegate.java b/src/in/raster/mayam/delegate/SendingDelegate.java
new file mode 100644
index 0000000..1bbaa69
--- /dev/null
+++ b/src/in/raster/mayam/delegate/SendingDelegate.java
@@ -0,0 +1,120 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.delegate;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.form.display.Display;
+import in.raster.mayam.model.AEModel;
+import in.raster.mayam.model.Instance;
+import in.raster.mayam.model.Series;
+import in.raster.mayam.util.core.DcmSnd;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class SendingDelegate extends Thread {
+
+    String forwardAET = "";
+    String forwardHost = "";
+    int forwardPort;
+    String studyIUID = "";
+    AEModel ae = null;
+
+    public SendingDelegate(String studyIUID, AEModel ae) {
+
+        this.studyIUID = studyIUID;
+        this.ae = ae;
+        this.start();
+    }
+
+    /**
+     * This routine used to send the study to the specified AE
+     * @param studyIUID
+     * @param ae
+     */
+    public void send(String studyIUID, AEModel ae) {
+        ApplicationContext.sendingProgress.updateBar(0);
+        forwardAET = ae.getAeTitle();
+        forwardHost = ae.getHostName();
+        forwardPort = ae.getPort();
+        int count = 0;
+        ApplicationContext.sendingProgress.setProgressMaximum(ApplicationContext.databaseRef.getStudyLevelInstance(studyIUID));
+        Display.alignScreen(ApplicationContext.sendingProgress);
+        ApplicationContext.sendingProgress.setVisible(true);
+        ArrayList<Series> seriesList = ApplicationContext.databaseRef.getSeriesList(studyIUID);
+        Iterator<Series> seriesItr = seriesList.iterator();
+        while (seriesItr.hasNext()) {
+            Series series = seriesItr.next();
+            Iterator<Instance> imgitr = series.getImageList().iterator();
+            while (imgitr.hasNext()) {
+                Instance img = imgitr.next();
+                File temp = new File(ApplicationContext.getAppDirectory() + File.separator + img.getFilepath());
+                String forwardParam[];
+                if (temp.isFile()) {
+                    forwardParam = new String[]{forwardAET + "@" + forwardHost + ":" + forwardPort, temp.getAbsolutePath()};
+                } else {
+                    temp = new File(img.getFilepath());
+                    forwardParam = new String[]{forwardAET + "@" + forwardHost + ":" + forwardPort, temp.getAbsolutePath()};
+
+                }
+                DcmSnd.main(forwardParam);
+                count++;
+                ApplicationContext.sendingProgress.updateBar(count);
+            }
+        }
+        try {
+            this.sleep(1000);
+        } catch (InterruptedException ex) {
+            Logger.getLogger(SendingDelegate.class.getName()).log(Level.SEVERE, null, ex);
+        }
+        ApplicationContext.sendingProgress.setVisible(false);
+    }
+
+    public void run() {
+        send(this.studyIUID, this.ae);
+    }
+}
diff --git a/src/in/raster/mayam/delegate/SeriesChooserDelegate.java b/src/in/raster/mayam/delegate/SeriesChooserDelegate.java
new file mode 100644
index 0000000..d0eba5d
--- /dev/null
+++ b/src/in/raster/mayam/delegate/SeriesChooserDelegate.java
@@ -0,0 +1,174 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.delegate;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.form.LayeredCanvas;
+import in.raster.mayam.form.MainScreen;
+import in.raster.mayam.model.Instance;
+import in.raster.mayam.model.Series;
+import in.raster.mayam.model.Study;
+import java.io.File;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class SeriesChooserDelegate extends Thread {
+
+    private String studyUID;
+    private String seriesUID;
+    private boolean multiframe;
+    private String instanceUID;
+    private LayeredCanvas canvas;
+
+    public SeriesChooserDelegate() {
+    }
+
+    public SeriesChooserDelegate(String studyUID, String seriesUID, LayeredCanvas canvas) {
+        this.studyUID = studyUID;
+        this.seriesUID = seriesUID;
+        this.canvas = canvas;
+        this.start();
+    }
+
+    public SeriesChooserDelegate(String studyUID, String seriesUID, boolean multiframe, String instanceUID, LayeredCanvas canvas) {
+        this.studyUID = studyUID;
+        this.seriesUID = seriesUID;
+        this.multiframe = multiframe;
+        this.instanceUID = instanceUID;
+        this.canvas = canvas;
+        this.start();
+    }
+
+    /**
+     * This routine used to change the series in the tile.
+     */
+    private void changeSeries() {
+        if (ApplicationContext.databaseRef.getMultiframeStatus()) {
+            changeSeries_SepMulti();
+        } else {
+            changeSeries_Normal();
+            
+        }
+        canvas.revalidate();
+        canvas.repaint();
+    }
+
+    public void changeSeries_Normal() {
+        for (Study study : MainScreen.studyList) {
+            if (study.getStudyInstanceUID().equalsIgnoreCase(studyUID)) {
+                for (Series series : study.getSeriesList()) {
+                    if (series.getSeriesInstanceUID().equalsIgnoreCase(seriesUID)) {
+                        for (Instance instance : series.getImageList()) {
+                            File file = new File(ApplicationContext.getAppDirectory() + File.separator + instance.getFilepath());
+                            if (file.exists()) {
+                                canvas.createSubComponents(ApplicationContext.getAppDirectory() + File.separator + instance.getFilepath());
+                                canvas.annotationPanel.setAnnotation(instance.getAnnotation());
+                            } else {
+                                canvas.createSubComponents(instance.getFilepath());
+                                canvas.annotationPanel.setAnnotation(instance.getAnnotation());
+                            }
+                            break;
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * This routine used to change the series in the tile.
+     */
+    private void changeSeries_SepMulti() {
+        for (Study study : MainScreen.studyList) {
+            if (study.getStudyInstanceUID().equalsIgnoreCase(studyUID)) {
+                for (Series series : study.getSeriesList()) {
+                    if (!this.multiframe) {
+                        multiframeProcess(series);
+                    } else {
+                        stillImageProcess(series);
+                    }
+                }//for loop series closed.
+            }
+            if(canvas.getCanvas()!=null)
+            canvas.getCanvas().setSelection();
+        }
+    }
+
+    public void run() {
+        changeSeries();
+    }
+
+    private void multiframeProcess(Series series) {
+        if (!series.isMultiframe() && series.getSeriesInstanceUID().equalsIgnoreCase(seriesUID)) {
+            for (Instance instance : series.getImageList()) {
+                File file = new File(ApplicationContext.getAppDirectory() + File.separator + instance.getFilepath());
+                if (file.exists()) {
+                    canvas.createSubComponents(ApplicationContext.getAppDirectory() + File.separator + instance.getFilepath());
+                    canvas.annotationPanel.setAnnotation(instance.getAnnotation());
+                } else {
+                    canvas.createSubComponents(instance.getFilepath());
+                    canvas.annotationPanel.setAnnotation(instance.getAnnotation());
+                }
+                break;
+            }
+        }
+    }
+
+    private void stillImageProcess(Series series) {
+        if (series.isMultiframe() && series.getSeriesInstanceUID().equalsIgnoreCase(seriesUID) && series.getInstanceUID().equalsIgnoreCase(instanceUID)) {
+            for (Instance instance : series.getImageList()) {
+                File file = new File(ApplicationContext.getAppDirectory()+ File.separator + instance.getFilepath());
+                if (file.exists()) {
+                    canvas.createSubComponents(ApplicationContext.getAppDirectory() + File.separator + instance.getFilepath());
+                    if(instance.getAnnotations()!=null&&instance.getAnnotations().get(0)!=null)
+                    canvas.annotationPanel.setAnnotation(instance.getAnnotations().get(0));
+                } else {
+                    canvas.createSubComponents(instance.getFilepath());
+                    if(instance.getAnnotations()!=null&&instance.getAnnotations().get(0)!=null)
+                    canvas.annotationPanel.setAnnotation(instance.getAnnotations().get(0));
+                }
+                break;
+            }
+        }
+    }
+}
diff --git a/src/in/raster/mayam/delegate/SeriesListUpdator.java b/src/in/raster/mayam/delegate/SeriesListUpdator.java
new file mode 100644
index 0000000..50bcb83
--- /dev/null
+++ b/src/in/raster/mayam/delegate/SeriesListUpdator.java
@@ -0,0 +1,366 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.delegate;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.form.LayeredCanvas;
+import in.raster.mayam.form.MainScreen;
+import in.raster.mayam.model.Instance;
+import in.raster.mayam.model.Series;
+import in.raster.mayam.model.Study;
+import in.raster.mayam.util.measurement.Annotation;
+import in.raster.mayam.util.measurement.InstanceAnnotation;
+import in.raster.mayam.util.measurement.SeriesAnnotation;
+import in.raster.mayam.util.measurement.StudyAnnotation;
+import java.io.File;
+import java.util.ConcurrentModificationException;
+import java.util.Iterator;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.imageio.ImageIO;
+import javax.imageio.ImageReader;
+import javax.imageio.stream.ImageInputStream;
+import javax.swing.JPanel;
+import org.dcm4che.data.Dataset;
+import org.dcm4che.dict.Tags;
+import org.dcm4che.imageio.plugins.DcmMetadata;
+import org.dcm4che2.data.Tag;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class SeriesListUpdator extends Thread {
+
+    Study tempStudy = null;
+    boolean studyAlreadyPresent = false;
+    private String studyUID;
+    private String seriesUID;
+    private boolean skipStudyParsing;
+    private StudyAnnotation studyAnnotation = null;
+    private ImageReader reader = null;
+    private boolean multiframeStatus;
+    private String instanceUID;
+
+    public SeriesListUpdator() {
+    }
+
+    public SeriesListUpdator(String studyUID, String seriesUID, String instanceUID, boolean multiframeStatus, boolean skipStudyParsing) {
+        this.studyUID = studyUID;
+        this.seriesUID = seriesUID;
+        this.skipStudyParsing = skipStudyParsing;
+        this.instanceUID = instanceUID;
+        this.multiframeStatus = multiframeStatus;
+        this.start();
+    }
+
+    @Override
+    public void run() {
+        this.setDicomReader();
+        if (ApplicationContext.databaseRef.getMultiframeStatus()) {
+            this.addSeriesToStudyList(studyUID, seriesUID, multiframeStatus, instanceUID, false);
+        } else {
+            this.addSeriesToStudyList(studyUID, seriesUID, false);
+        }
+    }
+
+    /**
+     * This routine used to update the series object to the studylist array
+     * @param studyUID
+     * @param seriesUID
+     * @param skipStudyParsing
+     */
+    public void addSeriesToStudyList(String studyUID, String seriesUID, boolean skipStudyParsing) {
+
+        boolean seriesAlreadyPresent = false;
+        this.studyUID = studyUID;
+        if (!skipStudyParsing) {
+            findStudyFromStudyList(studyUID);
+        }
+        if (tempStudy != null) {
+            for (Series series : tempStudy.getSeriesList()) {
+                if (series.getSeriesInstanceUID().equalsIgnoreCase(seriesUID)) {
+                    seriesAlreadyPresent = true;
+                    try {
+                        Thread.sleep(1000);
+                    } catch (InterruptedException ex) {
+                        Logger.getLogger(SeriesListUpdator.class.getName()).log(Level.SEVERE, null, ex);
+                    }
+                    updateAnnotation(series);
+                }
+            }
+        }
+        if (!seriesAlreadyPresent) {
+            Series series = ApplicationContext.databaseRef.getSeries(studyUID, seriesUID);
+            if (!studyAlreadyPresent) {
+                tempStudy = new Study(studyUID);
+                MainScreen.studyList.add(tempStudy);
+            }
+            tempStudy.addSeries(series);
+
+            try {
+                for (Instance img : series.getImageList()) {
+                    readDicomFile(img);
+                }
+                updateAnnotation(series);
+
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    /**
+     * This routine used to update the series object to the studylist array
+     * @param studyUID
+     * @param seriesUID
+     * @param skipStudyParsing
+     */
+    public void addSeriesToStudyList(String studyUID, String seriesUID, boolean multiframe, String instanceUID, boolean skipStudyParsing) {
+
+        boolean seriesAlreadyPresent = false;
+        this.studyUID = studyUID;
+        if (!skipStudyParsing) {
+            findStudyFromStudyList(studyUID);
+        }
+
+        if (tempStudy != null) {
+            for (Series series : tempStudy.getSeriesList()) {
+                if (multiframe) {
+                    if (series.isMultiframe() && series.getSeriesInstanceUID().equalsIgnoreCase(seriesUID) && series.getInstanceUID().equalsIgnoreCase(instanceUID)) {
+                        seriesAlreadyPresent = true;
+                        try {
+                            Thread.sleep(1000);
+                        } catch (InterruptedException ex) {
+                            Logger.getLogger(SeriesListUpdator.class.getName()).log(Level.SEVERE, null, ex);
+                        }
+                        updateAnnotation(series);
+                    }
+                } else {
+                    if (!series.isMultiframe() && series.getSeriesInstanceUID().equalsIgnoreCase(seriesUID)) {
+                        seriesAlreadyPresent = true;
+                        try {
+                            Thread.sleep(1000);
+                        } catch (InterruptedException ex) {
+                            Logger.getLogger(SeriesListUpdator.class.getName()).log(Level.SEVERE, null, ex);
+                        }
+                        updateAnnotation(series);
+                    }
+                }
+            }
+        }
+        if (!seriesAlreadyPresent) {
+            Series series = ApplicationContext.databaseRef.getSeries(studyUID, seriesUID, multiframe, instanceUID);
+            if (!studyAlreadyPresent) {
+                tempStudy = new Study(studyUID);
+                MainScreen.studyList.add(tempStudy);
+            }
+            tempStudy.addSeries(series);
+            try {
+                for (Instance img : series.getImageList()) {
+                    readDicomFile(img);
+                }
+                updateAnnotation(series);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    /**
+     * This routine used to parse the study list
+     * @param studyUID
+     */
+    public void findStudyFromStudyList(String studyUID) {
+        studyAlreadyPresent = false;
+        for (Study study : MainScreen.studyList) {
+            if (study.getStudyInstanceUID().equalsIgnoreCase(studyUID)) {
+                tempStudy = study;
+                studyAlreadyPresent = true;
+            }
+        }
+    }
+
+    public void updateAnnotation(Series series) {
+        if (studyAnnotation != null) {
+            SeriesAnnotation seriesAnnotation = (SeriesAnnotation) studyAnnotation.getSeriesAnnotation().get(series.getSeriesInstanceUID());
+            int i = 0;
+            Instance firstInstance = null;
+            for (Instance instance : series.getImageList()) {
+                if (i == 0) {
+                    firstInstance = instance;
+                    i++;
+                }
+                if (seriesAnnotation != null && seriesAnnotation.getInstanceArray() != null) {
+                    InstanceAnnotation instanceAnnotation = (InstanceAnnotation) seriesAnnotation.getInstanceArray().get(instance.getSop_iuid());
+
+                    if (instanceAnnotation != null && instanceAnnotation.getAnnotations() != null) {
+                        if (instance.isMultiframe()) {
+                            if (ApplicationContext.databaseRef.getMultiframeStatus()) {
+                                instance.setAnnotations(instanceAnnotation.getAnnotations());
+                            } else {
+                                instance.setAnnotation((Annotation) instanceAnnotation.getAnnotations().get(instance.getCurrentFrameNum()));
+                            }
+                        } else {
+                            instance.setAnnotation(instanceAnnotation.getAnnotation());
+                        }
+                    }
+                }
+            }
+            updateFirstInstanceAnnotation(firstInstance, series.getSeriesInstanceUID());
+        }
+    }
+
+    private void updateFirstInstanceAnnotation(Instance instance, String seriesUID) {
+        boolean matchingTab = false;
+        if (ApplicationContext.imgView != null && ApplicationContext.imgView.jTabbedPane1 != null) {
+            for (int x = 0; x < ApplicationContext.imgView.jTabbedPane1.getComponentCount(); x++) {
+                for (int y = 0; y < ((JPanel) ApplicationContext.imgView.jTabbedPane1.getComponent(x)).getComponentCount(); y++) {
+                    if (((JPanel) ApplicationContext.imgView.jTabbedPane1.getComponent(x)).getComponent(y) instanceof LayeredCanvas) {
+                        LayeredCanvas tempCanvas = ((LayeredCanvas) ((JPanel) ApplicationContext.imgView.jTabbedPane1.getComponent(x)).getComponent(y));
+                        if (tempCanvas.imgpanel != null && tempCanvas.imgpanel.getStudyUID().equalsIgnoreCase(studyUID)) {
+                            matchingTab = true;
+                            if (instance != null && instance.getSop_iuid() != null) {
+                                if (tempCanvas.imgpanel.getSeriesUID().equalsIgnoreCase(seriesUID) && tempCanvas.imgpanel.getInstanceUID().equalsIgnoreCase(instance.getSop_iuid())) {
+                                    SeriesAnnotation seriesAnnotation = (SeriesAnnotation) studyAnnotation.getSeriesAnnotation().get(seriesUID);
+                                    InstanceAnnotation instanceAnnotation = null;
+                                    if (seriesAnnotation!=null && seriesAnnotation.getInstanceArray() != null) {
+                                        instanceAnnotation = ((InstanceAnnotation) seriesAnnotation.getInstanceArray().get(tempCanvas.imgpanel.getInstanceUID()));
+                                    }
+                                    if (instance.isMultiframe()) {
+                                        if (instanceAnnotation != null && instanceAnnotation.getAnnotations() != null) {
+                                            tempCanvas.annotationPanel.setAnnotation(instanceAnnotation.getAnnotations().get(0));
+                                        }
+                                    } else {
+                                        if (instanceAnnotation != null && instanceAnnotation.getAnnotation() != null) {
+                                            tempCanvas.annotationPanel.setAnnotation(instanceAnnotation.getAnnotation());
+                                        }
+                                    }
+                                    break;
+                                }
+                            }
+                        }
+                    }
+                }
+                if (matchingTab) {
+                    break;
+                }
+            }
+        }
+    }
+
+    public void setDicomReader() {
+        try{
+        ImageIO.scanForPlugins();
+        Iterator iter = ImageIO.getImageReadersByFormatName("DICOM");
+        reader = (ImageReader) iter.next();
+        }
+        catch(Exception e){}
+    }
+
+    private synchronized void readDicomFile(Instance img) {
+        ImageInputStream iis = null;
+        Dataset dataset;
+        try {
+            File selFile = new File(ApplicationContext.getAppDirectory() + File.separator + img.getFilepath());
+            if (!selFile.isFile()) {
+                selFile = new File(img.getFilepath());
+            }
+            iis = ImageIO.createImageInputStream(selFile);
+            reader.setInput(iis, false);
+            dataset = ((DcmMetadata) reader.getStreamMetadata()).getDataset();
+            try {
+                if(reader.getNumImages(true)>0)
+                img.setPixelData(reader.read(img.getCurrentFrameNum()));
+                updateInstanceInfo(dataset, img);
+            } catch (NullPointerException e) {
+                e.printStackTrace();
+            } catch (RuntimeException e) {
+                e.printStackTrace();
+            }
+        } catch (ConcurrentModificationException e) {
+            e.printStackTrace();
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                iis.close();                
+            } catch (Exception ex) {//ignore
+            }
+        }
+    }
+
+    private void updateInstanceInfo(Dataset dataset, Instance img) {
+        img.setInstance_no(dataset.getString(Tags.InstanceNumber));
+        String frameOfReferenceUID = dataset.getString(Tags.FrameOfReferenceUID) != null ? dataset.getString(Tags.FrameOfReferenceUID) : "";
+        String imagePosition = dataset.getString(Tags.ImagePosition, 0) != null ? dataset.getString(Tags.ImagePosition, 0) + "\\" + dataset.getString(Tags.ImagePosition, 1) + "\\" + dataset.getString(Tags.ImagePosition, 2) : null;
+        String imageOrientation = dataset.getString(Tags.ImageOrientation) != null ? dataset.getString(Tags.ImageOrientation, 0) + "\\" + dataset.getString(Tags.ImageOrientation, 1) + "\\" + dataset.getString(Tags.ImageOrientation, 2) + "\\" + dataset.getString(Tags.ImageOrientation, 3) + "\\" + dataset.getString(Tags.ImageOrientation, 4) + "\\" + dataset.getString(Tags.ImageOrientation, 5) : null;
+        String[] imageType = dataset.getStrings(Tags.ImageType) != null ? dataset.getStrings(Tags.ImageType) : null;
+        String pixelSpacing = dataset.getString(Tags.PixelSpacing) != null ? dataset.getString(Tags.PixelSpacing, 0) + "\\" + dataset.getString(Tags.PixelSpacing, 1) : null;
+        int row = dataset.getString(Tags.Rows) != null ? Integer.parseInt(dataset.getString(Tags.Rows)) : 0;
+        int column = dataset.getString(Tags.Columns) != null ? Integer.parseInt(dataset.getString(Tags.Columns)) : 0;
+        int instanceNumber=dataset.getString(Tags.InstanceNumber) !=null ? Integer.parseInt(dataset.getString(Tags.InstanceNumber)): 1;
+        String referencedSOPInstanceUID = "";
+        Dataset referencedImageSequence = dataset.getItem(Tag.ReferencedImageSequence);
+        if (referencedImageSequence != null) {
+            referencedSOPInstanceUID = referencedImageSequence.getString(Tag.ReferencedSOPInstanceUID);
+        }
+         String sliceLocation=(dataset.getString(Tags.SliceLocation)!=null)?dataset.getString(Tags.SliceLocation):"";
+        img.setImagePosition(imagePosition);
+        img.setImageOrientation(imageOrientation);
+        img.setImageType(imageType);
+        img.setPixelSpacing(pixelSpacing);
+        img.setRow(row);
+        img.setColumn(column);
+        img.setReferenceSOPInstanceUID(referencedSOPInstanceUID);
+        img.setFrameOfReferenceUID(frameOfReferenceUID);
+        img.setInstanceNumber(instanceNumber);        
+        img.setSliceLocation(sliceLocation);
+    }
+
+    public StudyAnnotation getStudyAnnotation() {
+        return studyAnnotation;
+    }
+
+    public void setStudyAnnotation(StudyAnnotation studyAnnotation) {
+        this.studyAnnotation = studyAnnotation;
+    }
+}
diff --git a/src/in/raster/mayam/delegate/SeriesThumbUpdator.java b/src/in/raster/mayam/delegate/SeriesThumbUpdator.java
new file mode 100644
index 0000000..f8d5d72
--- /dev/null
+++ b/src/in/raster/mayam/delegate/SeriesThumbUpdator.java
@@ -0,0 +1,126 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.delegate;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.util.DicomTags;
+import in.raster.mayam.util.DicomTagsReader;
+import in.raster.mayam.form.MainScreen;
+import in.raster.mayam.form.SeriesPanel;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.io.File;
+import java.util.ArrayList;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class SeriesThumbUpdator{
+
+    private String studyUID;
+    private boolean canRun = true;
+    public static final int thumbnailHeight = 100;
+    public static final int thumbnailWidth = 100;
+
+    public SeriesThumbUpdator(String studyUID) {
+        this.studyUID = studyUID;
+        run();
+    }
+
+    public void run() {
+        showThumbnailDisplay();
+    }
+
+    public boolean isCanRun() {
+        return canRun;
+    }
+
+    public void setCanRun(boolean canRun) {
+        this.canRun = canRun;
+    }
+
+    /**
+     * This routine used to set the thumbnail display panel size.
+     * @param totalInstance
+     */
+    private void setThumbnailDisplayPanelSize(int totalInstance) {
+        MainScreen mainScreenRef = ApplicationContext.mainScreen;
+        int thumbDisplayPanelHeight = totalInstance * thumbnailHeight;
+        int thumbDisplayPanelWidth = (int) mainScreenRef.getThumbnailDisplay().getSize().getWidth();
+        mainScreenRef.getThumbnailDisplay().setPreferredSize(new Dimension(thumbDisplayPanelWidth, thumbDisplayPanelHeight));
+    }
+
+    /**
+     * This routine used to display the thumbnail images in the thumbnail display area.
+     */
+    public void showThumbnailDisplay() {
+        int i = 0;
+        MainScreen mainScreenRef = ApplicationContext.mainScreen;
+        ApplicationContext.mainScreen.getThumbnailDisplay().setLayout(new FlowLayout(FlowLayout.LEFT, 1, 1));
+        ArrayList<File> tempRef = ApplicationContext.databaseRef.getUrlBasedOnStudyIUID(studyUID);
+        setThumbnailDisplayPanelSize(tempRef.size());
+        for (File f : tempRef) {
+            final SeriesPanel thumbnail = new SeriesPanel(f.getAbsolutePath());
+            thumbnail.setPreferredSize(new Dimension((int) mainScreenRef.getThumbnailDisplay().getSize().getWidth() - 1, 96));
+            thumbnail.setVisible(true);
+            if (i == 0) {
+                WindowingPanelLoader.loadImageOnWindowingPanel(thumbnail.getFileUrl());
+                if (ApplicationContext.selectedSeriesPanel != null) {
+                    ApplicationContext.selectedSeriesPanel.setNoSelectionColoring();
+                }
+                ApplicationContext.selectedSeriesPanel = thumbnail;
+                ApplicationContext.selectedSeriesPanel.setSelectionColoring();
+                thumbnail.updateInstanceList();
+                if (MainScreen.dicomTagsViewer.isVisible()) {
+                    ArrayList<DicomTags> dcmTags = DicomTagsReader.getTags(new File(thumbnail.getFileUrl()));
+                    MainScreen.dicomTagsViewer.setDataModelOnTable(dcmTags);
+                }
+            }
+            if (canRun) {
+                mainScreenRef.getThumbnailDisplay().add(thumbnail);
+                mainScreenRef.getThumbnailDisplay().revalidate();
+                mainScreenRef.getThumbnailDisplay().repaint();
+            }
+            i++;
+        }
+    }
+}
diff --git a/src/in/raster/mayam/delegate/ShowComparisonViewerDelegate.java b/src/in/raster/mayam/delegate/ShowComparisonViewerDelegate.java
new file mode 100644
index 0000000..a1391ef
--- /dev/null
+++ b/src/in/raster/mayam/delegate/ShowComparisonViewerDelegate.java
@@ -0,0 +1,138 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.delegate;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.form.tab.component.ButtonTabComp;
+import in.raster.mayam.form.Canvas;
+import in.raster.mayam.form.LayeredCanvas;
+import java.awt.Color;
+import java.awt.GridLayout;
+import java.io.File;
+import java.util.ArrayList;
+import javax.swing.JPanel;
+import javax.swing.JTabbedPane;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.9
+ *
+ */
+public class ShowComparisonViewerDelegate extends Thread {
+
+    private ArrayList tempRef;
+    private int gridRowCount=1;
+    private int gridColCount=2;
+    private int numberOfStudies;
+    private String[] studies;
+    public ShowComparisonViewerDelegate(int numberOfStudies,String[] studies,ArrayList studyURLs) {
+        this.numberOfStudies=numberOfStudies;
+        if((numberOfStudies>=3) && (numberOfStudies<=4))
+        {
+            gridColCount=2;
+            gridRowCount=2;
+        }
+        tempRef=studyURLs;
+        this.studies=studies;
+        this.start();
+    }
+
+    public void run() {
+        showViewer();
+    }
+    /**
+     * This routine used to show the image view with the layout updated based on modality in the database.
+     */
+    private void showViewer() {
+        JPanel container = new JPanel();
+        container.setBackground(Color.BLACK);
+        GridLayout g = new GridLayout(gridRowCount, gridColCount);
+        container.setLayout(g);
+        String patientNameLabel="";
+        for (int i = 0; i < (gridColCount * gridRowCount); i++) {
+            if (i < tempRef.size()) {
+                File file = (File) tempRef.get(i);
+                LayeredCanvas canvas = new LayeredCanvas(file.getAbsolutePath());
+                canvas.setComparedWithStudies(studies);
+                container.add(canvas, i);
+                if(i!=0)
+                    patientNameLabel+=" - ";
+                patientNameLabel+=canvas.imgpanel.getTextOverlayParam().getPatientName();
+
+            } else {
+                LayeredCanvas j = new LayeredCanvas();
+                j.setStudyUID(studies[0]);
+                container.add(j, i);
+            }
+        }
+         container.setName(patientNameLabel);
+        setSelectedImagePanel(container);
+    }
+
+    /**
+     * This routine used to update the selected panel info to ApplicationContext.
+     * @param container
+     */
+    private void setSelectedImagePanel(JPanel container) {
+        ApplicationContext.imgView.jTabbedPane1.add(container);
+        //The following lines are used for tab close button and event
+        ButtonTabComp tabComp = new ButtonTabComp(ApplicationContext.imgView.jTabbedPane1);
+        ApplicationContext.imgView.jTabbedPane1.setTabComponentAt(ApplicationContext.imgView.jTabbedPane1.getTabCount() - 1, tabComp);
+        ApplicationContext.imgView.jTabbedPane1.setTabLayoutPolicy(JTabbedPane.WRAP_TAB_LAYOUT);
+        ApplicationContext.imgPanel = ((LayeredCanvas) ((JPanel) container).getComponent(0)).imgpanel;
+        ApplicationContext.imgView.getImageToolbar().setWindowingTool();
+        ApplicationContext.annotationPanel = ((LayeredCanvas) ((JPanel) container).getComponent(0)).annotationPanel;
+        ApplicationContext.layeredCanvas = ((LayeredCanvas) ((JPanel) container).getComponent(0));
+        ((Canvas) ApplicationContext.imgPanel.getCanvas()).setSelection();
+        ApplicationContext.imgView.jTabbedPane1.setSelectedComponent(container);
+        ApplicationContext.imgView.getImageToolbar().setWindowing();
+        ApplicationContext.imgView.setVisible(true);
+    }
+
+    public String[] getStudies() {
+        return studies;
+    }
+
+    public void setStudies(String[] studies) {
+        this.studies = studies;
+    }
+
+   
+}
diff --git a/src/in/raster/mayam/delegate/ShowImageViewDelegate.java b/src/in/raster/mayam/delegate/ShowImageViewDelegate.java
new file mode 100644
index 0000000..f9068c3
--- /dev/null
+++ b/src/in/raster/mayam/delegate/ShowImageViewDelegate.java
@@ -0,0 +1,94 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.delegate;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.form.tab.component.ButtonTabComp;
+import in.raster.mayam.form.Canvas;
+import in.raster.mayam.form.LayeredCanvas;
+import java.awt.Color;
+import java.awt.GridLayout;
+import javax.swing.JPanel;
+import javax.swing.JTabbedPane;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class ShowImageViewDelegate extends Thread {
+
+    private String filePath;
+
+    public ShowImageViewDelegate(String filePath) {
+        this.filePath = filePath;
+        this.start();
+    }
+
+    public void run() {
+        showImageView();
+    }
+
+    public void showImageView() {
+        JPanel container = new JPanel();
+        container.setBackground(Color.BLACK);
+        GridLayout g = new GridLayout(1, 1);
+        container.setLayout(g);
+        LayeredCanvas canvas = new LayeredCanvas(filePath);
+        container.add(canvas, 0);
+        container.setName(canvas.imgpanel.getTextOverlayParam().getPatientName());
+        setImgpanelToContext(container);
+    }
+
+    private void setImgpanelToContext(JPanel container) {
+        ((JTabbedPane) ApplicationContext.imgView.jTabbedPane1).add(container);
+        //The following lines are used for tab close button and event
+        ButtonTabComp tabComp = new ButtonTabComp(ApplicationContext.imgView.jTabbedPane1);
+        ApplicationContext.imgView.jTabbedPane1.setTabComponentAt(ApplicationContext.imgView.jTabbedPane1.getTabCount() - 1, tabComp);
+        ApplicationContext.imgView.jTabbedPane1.setTabLayoutPolicy(JTabbedPane.WRAP_TAB_LAYOUT);
+        ApplicationContext.imgPanel = ((LayeredCanvas) ((JPanel) container).getComponent(0)).imgpanel;
+        ApplicationContext.annotationPanel = ((LayeredCanvas) ((JPanel) container).getComponent(0)).annotationPanel;
+        ApplicationContext.layeredCanvas = ((LayeredCanvas) ((JPanel) container).getComponent(0));
+        ((Canvas) ApplicationContext.imgPanel.getCanvas()).setSelection();
+        ApplicationContext.imgView.jTabbedPane1.setSelectedComponent(container);
+        ApplicationContext.imgView.getImageToolbar().setWindowing();
+        ApplicationContext.imgView.setVisible(true);
+    }
+}
\ No newline at end of file
diff --git a/src/in/raster/mayam/delegate/ShowViewerDelegate.java b/src/in/raster/mayam/delegate/ShowViewerDelegate.java
new file mode 100644
index 0000000..1218131
--- /dev/null
+++ b/src/in/raster/mayam/delegate/ShowViewerDelegate.java
@@ -0,0 +1,132 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.delegate;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.form.tab.component.ButtonTabComp;
+import in.raster.mayam.form.Canvas;
+import in.raster.mayam.form.LayeredCanvas;
+import java.awt.Color;
+import java.awt.GridLayout;
+import java.io.File;
+import java.util.ArrayList;
+import javax.swing.JPanel;
+import javax.swing.JTabbedPane;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class ShowViewerDelegate extends Thread {
+
+    private ArrayList tempRef;
+    private int gridRowCount;
+    private int gridColCount;
+    private String studyUID;
+
+    public ShowViewerDelegate() {
+    }
+
+    public ShowViewerDelegate(String studyUID, ArrayList tempRef, int gridRowCount, int gridColCount) {
+        this.studyUID = studyUID;
+        this.tempRef = tempRef;
+        this.gridColCount = gridColCount;
+        this.gridRowCount = gridRowCount;
+        this.start();
+    }
+
+    public void run() {
+        showViewer();
+    }
+
+    /**
+     * This routine used to show the image view with the layout updated based on modality in the database.
+     */
+    private void showViewer() {
+        JPanel container = new JPanel();
+        container.setBackground(Color.BLACK);
+        GridLayout g = new GridLayout(gridRowCount, gridColCount);
+        container.setLayout(g);
+        for (int i = 0; i < (gridColCount * gridRowCount); i++) {
+            if (i < tempRef.size()) {
+                File file = (File) tempRef.get(i);
+//                DestinationFinder destFinder=new DestinationFinder();
+//                LayeredCanvas canvas=new LayeredCanvas(destFinder.getFileDestination(file));
+                LayeredCanvas canvas = new LayeredCanvas(file.getAbsolutePath());
+                container.add(canvas, i);
+                container.setName(canvas.imgpanel.getTextOverlayParam().getPatientName());
+            } else {
+                LayeredCanvas j = new LayeredCanvas();
+                j.setStudyUID(studyUID);
+                container.add(j, i);
+            }
+        }
+        setSelectedImagePanel(container);
+    }
+
+    /**
+     * This routine used to update the selected panel info to ApplicationContext.
+     * @param container
+     */
+    private void setSelectedImagePanel(JPanel container) {
+        ApplicationContext.imgView.jTabbedPane1.add(container);
+        //The following lines are used for tab close button and event
+        ButtonTabComp tabComp = new ButtonTabComp(ApplicationContext.imgView.jTabbedPane1);
+        ApplicationContext.imgView.jTabbedPane1.setTabComponentAt(ApplicationContext.imgView.jTabbedPane1.getTabCount() - 1, tabComp);
+        ApplicationContext.imgView.jTabbedPane1.setTabLayoutPolicy(JTabbedPane.WRAP_TAB_LAYOUT);
+        ApplicationContext.imgPanel = ((LayeredCanvas) ((JPanel) container).getComponent(0)).imgpanel;
+        ApplicationContext.imgView.getImageToolbar().setWindowingTool();
+        ApplicationContext.annotationPanel = ((LayeredCanvas) ((JPanel) container).getComponent(0)).annotationPanel;
+        ApplicationContext.layeredCanvas = ((LayeredCanvas) ((JPanel) container).getComponent(0));
+        ((Canvas) ApplicationContext.imgPanel.getCanvas()).setSelection();
+        ApplicationContext.imgView.jTabbedPane1.setSelectedComponent(container);
+        ApplicationContext.imgView.getImageToolbar().setWindowing();
+        ApplicationContext.imgView.setVisible(true);
+    }
+
+    public String getStudyUID() {
+        return studyUID;
+    }
+
+    public void setStudyUID(String studyUID) {
+        this.studyUID = studyUID;
+    }
+}
\ No newline at end of file
diff --git a/src/in/raster/mayam/delegate/StudyListUpdator.java b/src/in/raster/mayam/delegate/StudyListUpdator.java
new file mode 100644
index 0000000..be90d6c
--- /dev/null
+++ b/src/in/raster/mayam/delegate/StudyListUpdator.java
@@ -0,0 +1,144 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.delegate;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.model.Series;
+import in.raster.mayam.model.Study;
+import in.raster.mayam.util.measurement.StudyAnnotation;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.util.ArrayList;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class StudyListUpdator extends Thread {
+
+    private String siuid = "";
+    private ArrayList<Study> studyList;
+    private String studyDir = "";
+    StudyAnnotation studyAnnotation = null;
+
+    public StudyListUpdator() {
+    }
+
+    public void run() {
+        addStudyToStudyList();
+    }
+
+    public void setAnnotationToObject() {
+        File annotationInfo = new File(studyDir, "info.ser");
+        if (annotationInfo.isFile()) {
+            FileInputStream fis = null;
+            ObjectInputStream obs = null;
+            try {
+                fis = new FileInputStream(annotationInfo);
+                obs = new ObjectInputStream(fis);
+                try {
+                    studyAnnotation = (StudyAnnotation) obs.readObject();
+                } catch (ClassNotFoundException ex) {
+                    Logger.getLogger(ShowViewerDelegate.class.getName()).log(Level.SEVERE, null, ex);
+                }
+            } catch (IOException ex) {
+                Logger.getLogger(ShowViewerDelegate.class.getName()).log(Level.SEVERE, null, ex);
+            } catch (Exception ex) {
+                Logger.getLogger(ShowViewerDelegate.class.getName()).log(Level.SEVERE, null, ex);
+            } finally {
+                try {
+                    fis.close();
+                } catch (IOException ex) {
+                    Logger.getLogger(ShowViewerDelegate.class.getName()).log(Level.SEVERE, null, ex);
+                }
+                try {
+                    obs.close();
+                } catch (IOException ex) {
+                    Logger.getLogger(ShowViewerDelegate.class.getName()).log(Level.SEVERE, null, ex);
+                }
+            }
+        }
+    }
+
+    /**
+     * This routine used to add the study object of the specified studyUID to the studylist.
+     * @param siuid
+     * @param studyList
+     */
+    public void addStudyToStudyList(String siuid, ArrayList<Study> studyList, String studyDir) {
+
+        this.siuid = siuid;
+        this.studyList = studyList;
+        this.studyDir = new File(studyDir).getParent();
+        this.start();
+    }
+
+    public void addStudyToStudyList() {
+        ArrayList<Series> seriesList = ApplicationContext.databaseRef.getSeriesList(siuid);
+        setAnnotationToObject();
+        SeriesListUpdator seriesListUpdator = new SeriesListUpdator();
+        seriesListUpdator.setDicomReader();
+        if (studyAnnotation != null) {
+            seriesListUpdator.setStudyAnnotation(studyAnnotation);
+        }
+        int i = 0;
+        for (Series series : seriesList) {
+            if(ApplicationContext.imageViewExist()){
+            if (i == 0) {
+                if(ApplicationContext.databaseRef.getMultiframeStatus())
+                     seriesListUpdator.addSeriesToStudyList(siuid, series.getSeriesInstanceUID(), series.isMultiframe(),series.getInstanceUID(), false);
+                else
+                seriesListUpdator.addSeriesToStudyList(siuid, series.getSeriesInstanceUID(), false);
+            } else {
+                 if(ApplicationContext.databaseRef.getMultiframeStatus())
+                     seriesListUpdator.addSeriesToStudyList(siuid, series.getSeriesInstanceUID(), series.isMultiframe(),series.getInstanceUID(), true);
+                 else
+                seriesListUpdator.addSeriesToStudyList(siuid, series.getSeriesInstanceUID(), true);
+            }
+            i++;
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/in/raster/mayam/delegate/SynchronizationDelegate.java b/src/in/raster/mayam/delegate/SynchronizationDelegate.java
new file mode 100644
index 0000000..46bb774
--- /dev/null
+++ b/src/in/raster/mayam/delegate/SynchronizationDelegate.java
@@ -0,0 +1,98 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.delegate;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.form.ImagePanel;
+import in.raster.mayam.form.LayeredCanvas;
+import javax.swing.JPanel;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.9
+ *
+ */
+public class SynchronizationDelegate {
+
+    public SynchronizationDelegate() {
+    }
+
+    public static void setSyncStartInstanceInAllTiles() {
+        JPanel outerComponent = (JPanel) ApplicationContext.imgPanel.getCanvas().getLayeredCanvas().getParent();
+        for (int i = 0; i < outerComponent.getComponentCount(); i++) {
+            LayeredCanvas layeredCanvas = (LayeredCanvas) outerComponent.getComponent(i);
+            ImagePanel imgPanel = layeredCanvas.imgpanel;
+            if (ApplicationContext.imgPanel != imgPanel) {
+                imgPanel.updateSyncStartInstance();
+            }
+        }
+    }
+
+    public void doTileSync() {
+        JPanel outerComponent = (JPanel) ApplicationContext.imgPanel.getCanvas().getLayeredCanvas().getParent();
+        for (int i = 0; i < outerComponent.getComponentCount(); i++) {
+            LayeredCanvas layeredCanvas = (LayeredCanvas) outerComponent.getComponent(i);
+            ImagePanel imgPanel = layeredCanvas.imgpanel;
+            if (ApplicationContext.imgPanel != imgPanel) {
+                if (ApplicationContext.imgPanel.getStudyUID().equalsIgnoreCase(imgPanel.getStudyUID())) {
+                    if (ApplicationContext.imgPanel.getSeriesUID().equalsIgnoreCase(imgPanel.getSeriesUID()) && !imgPanel.isMulitiFrame()) {
+                        imgPanel.setInstanceArryFromList();
+                        imgPanel.setCurrentInstanceNo(ApplicationContext.imgPanel.getCurrentInstanceNo());
+                        imgPanel.setImage(ApplicationContext.imgPanel.getCurrentInstanceNo());
+                    } else {
+                        if (ApplicationContext.imgPanel.getSliceLocation() != null && !ApplicationContext.imgPanel.getSliceLocation().equalsIgnoreCase("")) {
+                            imgPanel.setInstanceArryFromList();
+                            imgPanel.setImage(ApplicationContext.imgPanel.getSliceLocation());
+                        }
+                    }
+                } else {
+                    if (imgPanel.canBeProcessed()) {
+                        int diff = ApplicationContext.imgPanel.getSyncDifference();
+                        int syncStartInstance = imgPanel.getSyncStartInstance();
+                        int instanceTobeSet = syncStartInstance + diff;
+                        imgPanel.setInstanceArryFromList();
+                        imgPanel.setCurrentInstanceNo(instanceTobeSet);
+                        imgPanel.setImage(instanceTobeSet);
+                    }
+                }
+            }
+        }
+    }
+}
diff --git a/src/in/raster/mayam/delegate/WadoRetrieveDelegate.java b/src/in/raster/mayam/delegate/WadoRetrieveDelegate.java
new file mode 100644
index 0000000..606a191
--- /dev/null
+++ b/src/in/raster/mayam/delegate/WadoRetrieveDelegate.java
@@ -0,0 +1,238 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.delegate;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.model.InputArgumentValues;
+import in.raster.mayam.model.ServerModel;
+import in.raster.mayam.param.WadoParam;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.Calendar;
+import java.util.Vector;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.dcm4che.data.Dataset;
+import org.dcm4che.dict.Tags;
+import org.dcm4che.util.DcmURL;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.7
+ *
+ */
+public class WadoRetrieveDelegate extends Thread {
+
+    private Vector<WadoParam> wadoUrls;
+    private HttpURLConnection httpURLConnection;
+    private String studyUID;
+    private String serverName;
+    private String patientID;
+    private String destinationPath;
+    private ServerModel serverModel = null;
+
+    public WadoRetrieveDelegate() {
+        this.wadoUrls = new Vector();
+    }
+
+    public void run() {
+        getWadoURLList();
+        doDownloadStudy();
+    }
+
+    public void retrieveStudy(String serverName, String patientID, String studyInstanceUID) {
+        this.serverName = serverName;
+        this.patientID = patientID;
+        this.studyUID = studyInstanceUID;
+        this.start();
+    }
+
+    public void retrieveStudy(ServerModel serverModel) {
+        this.serverModel = serverModel;
+        InputArgumentValues inputArgumentValues = null;
+        if (serverModel.getAeTitle() != null) {
+            inputArgumentValues = InputArgumentsParser.inputArgumentValues;             
+            EchoService echoService=new EchoService();
+            DcmURL dcmurl = new DcmURL("dicom://" + inputArgumentValues.getAeTitle() + "@" + inputArgumentValues.getHostName() + ":" + inputArgumentValues.getPort());
+            echoService.checkEcho(dcmurl);
+            if(echoService.getStatus().equalsIgnoreCase("EchoSuccess")){
+            QueryService queryService = new QueryService();
+            queryService.callFindWithQuery(inputArgumentValues.getPatientID(), inputArgumentValues.getPatientName(), null, inputArgumentValues.getSearchDate(), inputArgumentValues.getModality(), inputArgumentValues.getAccessionNumber(),inputArgumentValues.getStudyUID(), dcmurl);
+            for (int dataSetCount = 0; dataSetCount < queryService.getDatasetVector().size(); dataSetCount++) {
+                try {
+                    Dataset dataSet = (Dataset) queryService.getDatasetVector().elementAt(dataSetCount);
+                    this.patientID = dataSet.getString(Tags.PatientID) != null ? dataSet.getString(Tags.PatientID) : "";
+                    this.studyUID = dataSet.getString(Tags.StudyInstanceUID) != null ? dataSet.getString(Tags.StudyInstanceUID) : "";
+                } catch (Exception e) {
+                    System.out.println(e.getMessage());
+                }
+            }
+            this.start();
+        }
+        }
+    }
+
+    private void getWadoURLList() {
+        String seriesInstanceUID;
+        String instanceUID = "";
+        if (wadoUrls != null) {
+            wadoUrls.clear();
+        }
+        if (serverModel == null) {
+            serverModel = ApplicationContext.databaseRef.getServerModel(serverName);
+        }
+        DcmURL url = new DcmURL("dicom://" + serverModel.getAeTitle() + "@" + serverModel.getHostName() + ":" + serverModel.getPort());
+        QuerySeriesService querySeriesService = new QuerySeriesService();       
+        if(patientID!=null || studyUID!=null)
+        querySeriesService.callFindWithQuery(patientID, studyUID, url);       
+        for (int dataSetCount = 0; dataSetCount < querySeriesService.getDatasetVector().size(); dataSetCount++) {
+            try {
+                Dataset dataSet = (Dataset) querySeriesService.getDatasetVector().elementAt(dataSetCount);
+                seriesInstanceUID = dataSet.getString(Tags.SeriesInstanceUID) != null ? dataSet.getString(Tags.SeriesInstanceUID) : "";
+                QueryInstanceService queryInstanceService = new QueryInstanceService();
+                queryInstanceService.callFindWithQuery(patientID, studyUID, seriesInstanceUID, url);
+                for (int instanceCount = 0; instanceCount < queryInstanceService.getDatasetVector().size(); instanceCount++) {
+                    Dataset instanceDataset = (Dataset) queryInstanceService.getDatasetVector().elementAt(instanceCount);
+                    instanceUID = instanceDataset.getString(Tags.SOPInstanceUID) != null ? instanceDataset.getString(Tags.SOPInstanceUID) : "";
+                    WadoParam wadoParam = getWadoParam(serverModel.getWadoProtocol(), serverModel.getAeTitle(), serverModel.getHostName(), serverModel.getWadoPort(), studyUID, seriesInstanceUID, instanceUID, serverModel.getRetrieveTransferSyntax());
+                    wadoUrls.add(wadoParam);
+                }
+
+            } catch (Exception e) {               
+                System.out.println(e.getMessage());
+            }
+        }
+    }
+
+    private WadoParam getWadoParam(String wadoProtocol, String aeTitle, String hostName, int port, String studyUID, String seriesUID, String instanceUID, String retrieveTransferSyntax) {
+        WadoParam wadoParam = new WadoParam();
+        if (wadoProtocol.equalsIgnoreCase("https")) {
+            wadoParam.setSecureQuery(true);
+        } else {
+            wadoParam.setSecureQuery(false);
+        }
+        wadoParam.setAeTitle(aeTitle);
+        wadoParam.setRemoteHostName(hostName);
+        wadoParam.setRemotePort(port);
+        wadoParam.setStudy(studyUID);
+        wadoParam.setSeries(seriesUID);
+        wadoParam.setObject(instanceUID);
+        wadoParam.setRetrieveTrasferSyntax(retrieveTransferSyntax);
+        return wadoParam;
+    }
+
+    public void doDownloadStudy() {
+        for (WadoParam wadoParam : wadoUrls) {
+            String queryString = "";
+            if (wadoParam != null) {
+                queryString = wadoParam.getWadoUrl();
+            }
+            try {
+                URL wadoUrl = new URL(queryString);
+                httpURLConnection = (HttpURLConnection) wadoUrl.openConnection();
+                httpURLConnection.setRequestMethod("GET");
+                httpURLConnection.setInstanceFollowRedirects(false);
+                httpURLConnection.setRequestProperty("Connection", "Keep-Alive");
+                httpURLConnection.setRequestProperty("Content-Type", "application/x-java-serialized-object");
+                try {
+                    httpURLConnection.connect();
+                } catch (RuntimeException e) {
+                    System.out.println("Error while querying " + e.getMessage());
+                }
+                if (httpURLConnection.getResponseCode() == HttpURLConnection.HTTP_OK) {
+                    responseSuccess(wadoParam);
+                } else {
+                    System.out.println("Response Error:" + httpURLConnection.getResponseMessage());
+                }
+            } catch (Exception ex) {
+                Logger.getLogger(WadoRetrieveDelegate.class.getName()).log(Level.SEVERE, null, ex);
+            }
+
+        }
+    }
+
+    private void responseSuccess(WadoParam wadoParam) {
+        InputStream in = null;
+        try {
+            OutputStream out = null;
+            in = httpURLConnection.getInputStream();
+            Calendar today = Calendar.getInstance();
+            setDestination();
+            File struturedDestination = new File(destinationPath + File.separator + today.get(Calendar.YEAR) + File.separator + today.get(Calendar.MONTH) + File.separator + today.get(Calendar.DATE) + File.separator + studyUID);
+            String child[] = struturedDestination.list();
+            if (child == null) {
+                struturedDestination.mkdirs();
+            }
+            File storeLocation = new File(struturedDestination, wadoParam.getObject());
+            out = new FileOutputStream(storeLocation);
+            copy(in, out);
+            NetworkQueueUpdateDelegate networkQueueUpdateDelegate = new NetworkQueueUpdateDelegate();
+            networkQueueUpdateDelegate.updateReceiveTable(storeLocation, wadoParam.getAeTitle());
+        } catch (IOException ex) {
+            Logger.getLogger(WadoRetrieveDelegate.class.getName()).log(Level.SEVERE, null, ex);
+        } finally {
+            try {
+                in.close();
+            } catch (IOException ex) {
+                Logger.getLogger(WadoRetrieveDelegate.class.getName()).log(Level.SEVERE, null, ex);
+            }
+        }
+    }
+
+    public void setDestination() {
+        destinationPath = ApplicationContext.databaseRef.getListenerDetails()[2];;
+    }
+
+    private synchronized void copy(InputStream in, OutputStream out)
+            throws IOException {
+        byte[] buffer = new byte[4 * 1024];
+        int read;
+        while ((read = in.read(buffer)) != -1) {
+            if (out != null) {
+                out.write(buffer, 0, read);
+            }
+        }
+    }
+}
diff --git a/src/in/raster/mayam/delegate/WindowingPanelLoader.java b/src/in/raster/mayam/delegate/WindowingPanelLoader.java
new file mode 100644
index 0000000..bd4e3a5
--- /dev/null
+++ b/src/in/raster/mayam/delegate/WindowingPanelLoader.java
@@ -0,0 +1,74 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.delegate;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.form.MainScreen;
+import in.raster.mayam.form.WindowingLayeredCanvas;
+import java.awt.GridLayout;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class WindowingPanelLoader {
+
+    public WindowingPanelLoader() {
+    }
+    /**
+     * This routine used to load the image on the windowing panel for the quick view.
+     * @param url
+     */
+    public static void loadImageOnWindowingPanel(String url) {
+        MainScreen mainScreenRef = ApplicationContext.mainScreen;
+        for (int i = mainScreenRef.getWindowingPanelCanvas().getComponentCount() - 1; i >= 0; i--) {
+            mainScreenRef.getWindowingPanelCanvas().remove(i);
+        }
+        GridLayout g = new GridLayout(1, 1);
+        WindowingLayeredCanvas canvas = new WindowingLayeredCanvas(url);
+        canvas.imgpanel.tool = "windowing";
+        ApplicationContext.mainScreen.setCanvas(canvas);
+        mainScreenRef.getWindowingPanelCanvas().setLayout(g);
+        mainScreenRef.getWindowingPanelCanvas().add(canvas);
+        mainScreenRef.getWindowingPanelCanvas().revalidate();
+        mainScreenRef.getWindowingPanelCanvas().repaint();
+    }
+}
diff --git a/src/in/raster/mayam/exception/CompressedDcmOnMacException.java b/src/in/raster/mayam/exception/CompressedDcmOnMacException.java
new file mode 100644
index 0000000..18bd956
--- /dev/null
+++ b/src/in/raster/mayam/exception/CompressedDcmOnMacException.java
@@ -0,0 +1,67 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.exception;
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.9
+ *
+ */
+public class CompressedDcmOnMacException extends RuntimeException {
+
+    public CompressedDcmOnMacException(Throwable arg0) {
+        super(arg0);
+    }
+
+    public CompressedDcmOnMacException(String arg0, Throwable arg1) {
+        super(arg0, arg1);
+    }
+
+    public CompressedDcmOnMacException(String arg0) {
+        super(arg0);
+    }
+
+    public CompressedDcmOnMacException() {
+    }
+
+    @Override
+    public String getMessage() {
+        return "Compressed image cannot be opened in Mac";
+    }
+}
diff --git a/src/in/raster/mayam/exception/ImageReadingException.java b/src/in/raster/mayam/exception/ImageReadingException.java
new file mode 100644
index 0000000..482335f
--- /dev/null
+++ b/src/in/raster/mayam/exception/ImageReadingException.java
@@ -0,0 +1,68 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.exception;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class ImageReadingException extends RuntimeException {
+
+    public ImageReadingException(Throwable arg0) {
+        super(arg0);
+    }
+
+    public ImageReadingException(String arg0, Throwable arg1) {
+        super(arg0, arg1);
+    }
+
+    public ImageReadingException(String arg0) {
+        super(arg0);
+    }
+
+    public ImageReadingException() {
+    }
+
+    @Override
+    public String getMessage() {
+        return "Can not read and set image";
+    }
+}
diff --git a/src/in/raster/mayam/facade/ApplicationFacade.java b/src/in/raster/mayam/facade/ApplicationFacade.java
new file mode 100644
index 0000000..03310e3
--- /dev/null
+++ b/src/in/raster/mayam/facade/ApplicationFacade.java
@@ -0,0 +1,110 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.facade;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.delegate.InputArgumentsParser;
+import in.raster.mayam.form.display.Display;
+import in.raster.mayam.form.MainScreen;
+import in.raster.mayam.form.SplashScreen;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.swing.JOptionPane;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class ApplicationFacade {
+
+    public static SplashScreen splash;
+    public static MainScreen mainScreen;
+    //public String applicationName="Mayam";
+    public static String binPath="";
+
+    private ApplicationFacade() {
+    }
+
+    public void createSplash() {
+        splash = new SplashScreen();
+        Display.alignScreen(splash);
+        splash.setVisible(true);
+    }
+    public void createMainScreen()
+    {
+        mainScreen = MainScreen.getInstance();
+    }
+
+    private void setSystemProperties() {
+        if (Platform.getCurrentPlatform().equals(Platform.MAC)) {
+            System.setProperty("apple.laf.useScreenMenuBar", "true");
+            System.setProperty("com.apple.mrj.application.apple.menu.about.name", ApplicationContext.applicationName);
+            System.setProperty("apple.awt.brushMetalLook", "true");
+            System.setProperty("com.sun.media.jai.disableMediaLib", "true");
+            System.setProperty("apple.awt.graphics.EnableLazyPixelConversion.TYPE_3BYTE_BGR", "false");
+            System.setProperty("apple.awt.graphics.EnableLazyDrawing", "false");
+            System.setProperty("apple.awt.rendering", "speed");
+        }
+    }    
+
+    public static void exitApp(String exitString) {
+        if (splash != null) {
+            splash.setVisible(false);
+        }
+        JOptionPane.showMessageDialog(null, exitString, "Application Error", JOptionPane.ERROR_MESSAGE);
+        System.exit(1);
+    }
+
+    public static void main(String[] args) {
+        try {           
+            InputArgumentsParser.parse(args);
+            ApplicationFacade facade = new ApplicationFacade();
+            facade.setSystemProperties();
+            facade.createSplash();
+            facade.createMainScreen();
+            splash.setVisible(false);
+            mainScreen.setVisible(true);
+        } catch (Exception ex) {
+            Logger.getLogger(ApplicationFacade.class.getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+}
+
diff --git a/src/in/raster/mayam/facade/Platform.java b/src/in/raster/mayam/facade/Platform.java
new file mode 100644
index 0000000..c67b1ff
--- /dev/null
+++ b/src/in/raster/mayam/facade/Platform.java
@@ -0,0 +1,96 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.facade;
+
+import java.io.File;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.8
+ *
+ */
+public enum Platform {
+
+    LINUX, WINDOWS, MAC, SOLARIS, NONE;
+
+    public static Platform getCurrentPlatform() {
+        String osName = System.getProperty("os.name").toLowerCase();
+        if (osName.startsWith("mac")) {
+            return MAC;
+        } else if (osName.startsWith("windows")) {
+            return WINDOWS;
+        } else if (osName.startsWith("linux")) {
+            return LINUX;
+        } else if (osName.startsWith("solaris")) {
+            return SOLARIS;
+        }
+        return NONE;
+    }
+
+    public static File getAppDirectory(final String applicationName) {
+        final String userHome = System.getProperty("user.home", ".");
+        final File appDirectory;
+        switch (Platform.getCurrentPlatform()) {
+            case LINUX:
+            case SOLARIS:
+                appDirectory = new File(userHome, '.' + applicationName + File.separator);
+                break;
+            case WINDOWS:
+                final String applicationData = System.getenv("APPDATA");
+                if (applicationData != null) {
+                    appDirectory = new File(applicationData, "." + applicationName + File.separator);
+                } else {
+                    appDirectory = new File(userHome, '.' + applicationName + File.separator);
+                }
+                break;
+            case MAC:
+                appDirectory = new File(userHome, "Library" + File.separator + "Application Support" + File.separator + applicationName);
+                break;
+            default:
+                return new File(".");
+        }
+        if (!appDirectory.exists()) {
+            if (!appDirectory.mkdirs()) {
+                throw new RuntimeException("The working directory could not be created: " + appDirectory.getAbsolutePath());
+            }
+        }
+        return appDirectory;
+    }
+}
diff --git a/src/in/raster/mayam/form/AnnotationPanel.form b/src/in/raster/mayam/form/AnnotationPanel.form
new file mode 100644
index 0000000..92b3c50
--- /dev/null
+++ b/src/in/raster/mayam/form/AnnotationPanel.form
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+  <Events>
+    <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="formMouseClicked"/>
+  </Events>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <EmptySpace min="0" pref="436" max="32767" attributes="0"/>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <EmptySpace min="0" pref="322" max="32767" attributes="0"/>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+</Form>
diff --git a/src/in/raster/mayam/form/AnnotationPanel.java b/src/in/raster/mayam/form/AnnotationPanel.java
new file mode 100644
index 0000000..465c40c
--- /dev/null
+++ b/src/in/raster/mayam/form/AnnotationPanel.java
@@ -0,0 +1,1428 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.form.shapes.ShapeCoordinates;
+import in.raster.mayam.util.measurement.Annotation;
+import in.raster.mayam.util.measurement.AnnotationObj;
+import java.awt.Color;
+import java.awt.Cursor;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Rectangle;
+import java.awt.RenderingHints;
+import java.awt.Shape;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionListener;
+import java.awt.event.MouseWheelEvent;
+import java.awt.event.MouseWheelListener;
+import java.awt.geom.Ellipse2D;
+import java.awt.geom.Line2D;
+import java.awt.geom.Rectangle2D;
+import java.text.NumberFormat;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5 
+ */
+public class AnnotationPanel extends javax.swing.JPanel implements MouseMotionListener, MouseWheelListener, MouseListener, FocusListener {
+
+    private boolean firstTime = true;
+    LayeredCanvas layeredCanvas;
+    private int mouseLocX1;
+    private int mouseLocY1;
+    private int mouseLocX2;
+    private int mouseLocY2;
+    private boolean startAnnotation = true;
+    private boolean showAnnotation = true;
+    private int lineCount = 0;
+    private int rectCount = 0;
+    private int ellipticalCount = 0;
+    private static boolean addLine = false;
+    private static boolean addRect = false;
+    private static boolean addEllipse = false;
+    private boolean deleteMeasurement = false;
+    private boolean resizeMeasurement = false;
+    private static boolean moveMeasurement = false;
+    private float cosninety = 0;
+    private float sineninety = 1;
+    private Shape seletedShape = null;
+    private String selectedShapeType = "";
+    private String selectedShapeDisplayStringValue = "";
+    private Rectangle boundingRect = null;
+    private Cursor curCursor;
+    private ArrayList<AnnotationObj> lineObj;
+    private ArrayList<AnnotationObj> rectObj;
+    private ArrayList<AnnotationObj> ellipseObj;
+    private ArrayList<AnnotationObj> scoutObj;
+    /* All the calculations are based on the following SHAPEORIGIN value.So it should not be changed. 
+     * Zoom level can be adjusted with out changing the component size and SHAPEORIGIN.
+     * So there is no need of changing this SHAPEORIGIN value and component size. 
+     */
+    private final static int SHAPEORIGIN = 256;
+    private Annotation annotation;
+    private boolean focusGained;
+    public static String tool = "";
+
+    /** Creates new form DateFormatPanel */
+    public AnnotationPanel(LayeredCanvas l) {
+        initComponents();
+        setOpaque(false);
+        layeredCanvas = l;
+        this.addFocusListener(this);
+        this.addMouseListener(this);
+        this.addMouseMotionListener(this);
+        this.addMouseWheelListener(this);
+        lineObj = new ArrayList<AnnotationObj>();
+        rectObj = new ArrayList<AnnotationObj>();
+        ellipseObj = new ArrayList<AnnotationObj>();
+        scoutObj = new ArrayList<AnnotationObj>();
+    }
+
+    public void doPan() {
+        if (tool.equalsIgnoreCase("panning")) {
+            tool = "";
+        } else {
+            tool = "panning";
+        }
+    }
+
+    public int getMouseLocX1() {
+        return mouseLocX1;
+    }
+
+    public void setMouseLocX1(int mouseLocX1) {
+        this.mouseLocX1 = mouseLocX1;
+    }
+
+    public int getMouseLocX2() {
+        return mouseLocX2;
+    }
+
+    public void setMouseLocX2(int mouseLocX2) {
+        this.mouseLocX2 = mouseLocX2;
+    }
+
+    public int getMouseLocY1() {
+        return mouseLocY1;
+    }
+
+    public void setMouseLocY1(int mouseLocY1) {
+        this.mouseLocY1 = mouseLocY1;
+    }
+
+    public int getMouseLocY2() {
+        return mouseLocY2;
+    }
+
+    public void setMouseLocY2(int mouseLocY2) {
+        this.mouseLocY2 = mouseLocY2;
+    }
+
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                formMouseClicked(evt);
+            }
+        });
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
+        this.setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(0, 436, Short.MAX_VALUE)
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(0, 322, Short.MAX_VALUE)
+        );
+    }// </editor-fold>//GEN-END:initComponents
+
+    private void formMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseClicked
+        this.layeredCanvas.canvas.requestFocus();
+
+        if (addLine || addRect || addEllipse) {
+            /* if (startAnnotation) {
+            mouseLocX1 = evt.getX();
+            mouseLocY1 = evt.getY();
+            // this.addMouseMotionListener(this);
+            startAnnotation = false;
+            }
+             */
+        } else if (deleteMeasurement) {
+            measurementDelete(evt);
+        } else if (resizeMeasurement) {
+            measurementResize(evt);
+        }
+    }//GEN-LAST:event_formMouseClicked
+    private void measurementDelete(java.awt.event.MouseEvent evt) {
+        deleteRectangle(evt);
+        deleteEllipse(evt);
+        deleteLine(evt);
+    }
+
+    /**
+     * This routine used to deleted the rectangle seleced.
+     * @param evt
+     */
+    private void deleteRectangle(java.awt.event.MouseEvent evt) {
+        Iterator<AnnotationObj> ite1 = rectObj.iterator();
+        while (ite1.hasNext()) {
+            AnnotationObj t = ite1.next();
+            ShapeCoordinates shapeCoordinates = new ShapeCoordinates(t.getX1(), t.getY1(), t.getX2(), t.getY2());
+            Shape test2 = new Rectangle2D.Float(shapeCoordinates.getX(), shapeCoordinates.getY(), shapeCoordinates.getWidth(), shapeCoordinates.getHeight());
+            if (test2.contains(evt.getX() / this.layeredCanvas.imgpanel.getScaleFactor(), evt.getY() / this.layeredCanvas.imgpanel.getScaleFactor())) {
+                rectObj.remove(t);
+                break;
+            }
+        }
+    }
+
+    /**
+     * This routine used to deleted line selected.
+     * @param evt
+     */
+    private void deleteLine(java.awt.event.MouseEvent evt) {
+        Iterator<AnnotationObj> ite = lineObj.iterator();
+        while (ite.hasNext()) {
+            AnnotationObj t = ite.next();
+            ShapeCoordinates shapeCoordinates = new ShapeCoordinates(t.getX1(), t.getY1(), t.getX2(), t.getY2());
+            int mousePointBoxSize = 2;
+            Shape lineObject = new Line2D.Float(t.getX1(), t.getY1(), t.getX2(), t.getY2());
+            int pointX = evt.getX() - mousePointBoxSize / 2;
+            int pointY = evt.getY() - mousePointBoxSize / 2;
+            int width = mousePointBoxSize;
+            int height = mousePointBoxSize;
+            if (lineObject.intersects(pointX, pointY, width, height)) {
+                lineObj.remove(t);
+                break;
+            }
+
+        }
+    }
+
+    /**
+     * This routine used to delete the eclipse.
+     * @param evt
+     */
+    private void deleteEllipse(java.awt.event.MouseEvent evt) {
+        Iterator<AnnotationObj> ite2 = ellipseObj.iterator();
+        while (ite2.hasNext()) {
+            AnnotationObj t = ite2.next();
+            ShapeCoordinates shapeCoordinates = new ShapeCoordinates(t.getX1(), t.getY1(), t.getX2(), t.getY2());
+            Shape test2 = new Ellipse2D.Float(shapeCoordinates.getX(), shapeCoordinates.getY(), shapeCoordinates.getWidth(), shapeCoordinates.getHeight());
+            if (test2.contains(evt.getX() / this.layeredCanvas.imgpanel.getScaleFactor(), evt.getY() / this.layeredCanvas.imgpanel.getScaleFactor())) {
+                ellipseObj.remove(t);
+                break;
+            }
+        }
+    }
+
+    /**
+     * This routine used to resize the measurement.
+     * @param evt
+     */
+    private void measurementResize(java.awt.event.MouseEvent evt) {
+        Iterator<AnnotationObj> ite = lineObj.iterator();
+        while (ite.hasNext()) {
+            AnnotationObj t = ite.next();
+            Shape test = new Line2D.Float(t.getX1(), t.getY1(), t.getX2(), t.getY2());
+            if (test.contains(evt.getX(), evt.getY())) {
+            }
+        }
+        Iterator<AnnotationObj> ite1 = rectObj.iterator();
+        while (ite1.hasNext()) {
+            AnnotationObj t = ite1.next();
+            Shape test2 = new Rectangle2D.Float(t.getX1(), t.getY1(), t.getX2() - t.getX1(), t.getY2() - t.getY1());
+            if (test2.contains(evt.getX(), evt.getY())) {
+                rectObj.remove(t);
+                break;
+            }
+        }
+    }
+
+    /**
+     * This routine used to move the measurement.
+     * @param evt
+     */
+    private void measurementMove(java.awt.event.MouseEvent evt) {
+        addShapeToArray();
+        moveLine(evt);
+        moveRectangle(evt);
+        moveEllipse(evt);
+    }
+    private String selectedShapeOrientation = "left";
+
+    /**
+     * This routine used to move the line.
+     * @param evt
+     */
+    private void moveLine(java.awt.event.MouseEvent evt) {
+        Iterator<AnnotationObj> ite = lineObj.iterator();
+        while (ite.hasNext()) {
+            AnnotationObj t = ite.next();
+            ShapeCoordinates shapeCoordinates = new ShapeCoordinates(t.getX1(), t.getY1(), t.getX2(), t.getY2());
+            int mousePointBoxSize = 2;
+            Shape lineObject = new Line2D.Float(t.getX1(), t.getY1(), t.getX2(), t.getY2());
+            int pointX = evt.getX() - mousePointBoxSize / 2;
+            int pointY = evt.getY() - mousePointBoxSize / 2;
+            int width = mousePointBoxSize;
+            int height = mousePointBoxSize;
+            if (lineObject.intersects(pointX, pointY, width, height)) {
+                Shape test = new Rectangle2D.Float(shapeCoordinates.getX(), shapeCoordinates.getY(), shapeCoordinates.getWidth(), shapeCoordinates.getHeight());
+                int diffX = t.getX2() - t.getX1();
+                int diffY = t.getY2() - t.getY1();
+                if ((diffX < 0 && diffY < 0) || (diffX > 0 && diffY > 0) || (diffX == 0 && diffY > 0) || (diffY == 0 && diffX > 0)) {
+                    selectedShapeOrientation = "left";
+                } else {
+                    selectedShapeOrientation = "right";
+                }
+                boundingRect = test.getBounds();
+                seletedShape = test;
+                selectedShapeType = "line";
+                selectedShapeDisplayStringValue = t.getLength();
+                lineObj.remove(t);
+                break;
+            }
+
+
+        }
+    }
+
+    /**
+     * This routine used to move the rectangle.
+     * @param evt
+     */
+    private void moveRectangle(java.awt.event.MouseEvent evt) {
+        Iterator<AnnotationObj> ite1 = rectObj.iterator();
+        while (ite1.hasNext()) {
+            AnnotationObj t = ite1.next();
+            ShapeCoordinates shapeCoordinates = new ShapeCoordinates(t.getX1(), t.getY1(), t.getX2(), t.getY2());
+            Shape test2 = new Rectangle2D.Float(shapeCoordinates.getX(), shapeCoordinates.getY(), shapeCoordinates.getWidth(), shapeCoordinates.getHeight());
+            if (test2.contains(evt.getX() / this.layeredCanvas.imgpanel.getScaleFactor(), evt.getY() / this.layeredCanvas.imgpanel.getScaleFactor())) {
+                boundingRect = test2.getBounds();
+                seletedShape = test2;
+                selectedShapeType = "rect";
+                selectedShapeDisplayStringValue = t.getArea();
+                rectObj.remove(t);
+                break;
+            }
+        }
+    }
+
+    /**
+     * This routine used to move eclipse.
+     * @param evt
+     */
+    private void moveEllipse(java.awt.event.MouseEvent evt) {
+        Iterator<AnnotationObj> ite2 = ellipseObj.iterator();
+        while (ite2.hasNext()) {
+            AnnotationObj t = ite2.next();
+            ShapeCoordinates shapeCoordinates = new ShapeCoordinates(t.getX1(), t.getY1(), t.getX2(), t.getY2());
+            Shape test2 = new Ellipse2D.Float(shapeCoordinates.getX(), shapeCoordinates.getY(), shapeCoordinates.getWidth(), shapeCoordinates.getHeight());
+            if (test2.contains(evt.getX() / this.layeredCanvas.imgpanel.getScaleFactor(), evt.getY() / this.layeredCanvas.imgpanel.getScaleFactor())) {
+                boundingRect = test2.getBounds();
+                seletedShape = test2;
+                selectedShapeType = "ellipse";
+                selectedShapeDisplayStringValue = t.getArea();
+                ellipseObj.remove(t);
+                break;
+            }
+        }
+    }
+
+    /**
+     * This routine used to add the shape coordinates to the array.
+     */
+    private void addShapeToArray() {
+        //Adding the current selected shape to the array
+        if (seletedShape != null) {
+            if (selectedShapeType.equalsIgnoreCase("line")) {
+                AnnotationObj newLine = new AnnotationObj();
+                newLine.setMidX(SHAPEORIGIN);
+                newLine.setMidY(SHAPEORIGIN);
+                if (selectedShapeOrientation.equalsIgnoreCase("left")) {
+                    newLine.setLocation(seletedShape.getBounds().x, seletedShape.getBounds().y, seletedShape.getBounds().x + seletedShape.getBounds().width, seletedShape.getBounds().y + seletedShape.getBounds().height);
+                } else {
+                    newLine.setLocation(seletedShape.getBounds().x + seletedShape.getBounds().width, seletedShape.getBounds().y, seletedShape.getBounds().x, seletedShape.getBounds().y + seletedShape.getBounds().height);
+                }
+                newLine.setType("line");
+                newLine.setLength(selectedShapeDisplayStringValue);
+                lineObj.add(newLine);
+                lineCount++;
+                seletedShape = null;
+                boundingRect = null;
+            } else if (selectedShapeType.equalsIgnoreCase("rect")) {
+                AnnotationObj newRect = new AnnotationObj();
+                newRect.setMidX(SHAPEORIGIN);
+                newRect.setMidY(SHAPEORIGIN);
+                newRect.setLocation(seletedShape.getBounds().x, seletedShape.getBounds().y, seletedShape.getBounds().x + seletedShape.getBounds().width, seletedShape.getBounds().y + seletedShape.getBounds().height);
+                newRect.setType("rect");
+                newRect.setArea(selectedShapeDisplayStringValue);
+                rectObj.add(newRect);
+                rectCount++;
+                seletedShape = null;
+                boundingRect = null;
+            } else {
+                AnnotationObj newEllipse = new AnnotationObj();
+                newEllipse.setMidX(SHAPEORIGIN);
+                newEllipse.setMidY(SHAPEORIGIN);
+                newEllipse.setLocation(seletedShape.getBounds().x, seletedShape.getBounds().y, seletedShape.getBounds().x + seletedShape.getBounds().width, seletedShape.getBounds().y + seletedShape.getBounds().height);
+                newEllipse.setType("ellipse");
+                newEllipse.setArea(selectedShapeDisplayStringValue);
+                ellipseObj.add(newEllipse);
+                ellipticalCount++;
+                seletedShape = null;
+                boundingRect = null;
+            }
+        }
+    }
+
+    /**
+     * This routine used to delete the measurement.
+     */
+    public void doDeleteMeasurement() {
+        if (deleteMeasurement) {
+            deleteMeasurement = false;
+        } else {
+            deleteMeasurement = true;
+            resizeMeasurement = false;
+            resetSelectionMeasurement();
+            addEllipse = false;
+            addLine = false;
+            addRect = false;
+        }
+    }
+
+    public boolean isDeleteMeasurement() {
+        return this.deleteMeasurement;
+    }
+
+    public void setDeleteMeasurement(boolean deleteMeasurement) {
+        this.deleteMeasurement = deleteMeasurement;
+    }
+
+    /**
+     * This routine used to reset the selected measurement.
+     */
+    private void resetSelectionMeasurement() {
+        if (moveMeasurement) {
+            addShapeToArray();
+            moveMeasurement = false;
+        }
+    }
+
+    /**
+     * This routine used to reset the edited measurement.
+     */
+    public void resetEditMeasurement() {
+        deleteMeasurement = false;
+        resizeMeasurement = false;
+        resetSelectionMeasurement();
+    }
+
+    /**
+     * This routine used to resize the measurement.
+     */
+    public void doResizeMeasurement() {
+        if (resizeMeasurement) {
+            resizeMeasurement = false;
+        } else {
+            resizeMeasurement = true;
+            addEllipse = false;
+            addLine = false;
+            addRect = false;
+            deleteMeasurement = false;
+            moveMeasurement = false;
+        }
+    }
+
+    /**
+     * This routine used to move the measurement.
+     */
+    public void doMoveMeasurement() {
+        if (moveMeasurement) {
+            moveMeasurement = false;
+        } else {
+            moveMeasurement = true;
+            addEllipse = false;
+            addLine = false;
+            addRect = false;
+            deleteMeasurement = false;
+            resizeMeasurement = false;
+        }
+    }
+
+    public static boolean isMoveMeasurement() {
+        return moveMeasurement;
+    }
+
+    public static void setMoveMeasurement(boolean moveMeasurement) {
+        moveMeasurement = moveMeasurement;
+    }
+
+    /**
+     * This routine the used to reset the annotation overlay.
+     */
+    public void reset() {
+        this.setSize(512, 512);
+        firstTime = true;
+        repaint();
+    }
+
+    public void resizeHandler() {
+        firstTime = true;
+        repaint();
+    }
+
+    /**
+     * This routine used to find out the mode whether a ellipse can be added to the overlay.
+     * @return
+     */
+    public boolean isAddEllipse() {
+        return addEllipse;
+    }
+
+    /**
+     * This routine used to set the annotation overlay mode to draw the ellipse based on the coordinates.
+     * @param addEllipse
+     */
+    public void setAddEllipse(boolean addEllipse) {
+        this.addEllipse = addEllipse;
+        resetEditMeasurement();
+    }
+
+    /**
+     * This routine used to find out the mode whether a line can be added to the overlay.
+     * @return
+     */
+    public boolean isAddLine() {
+        return addLine;
+    }
+
+    /**
+     * This routine used to set the annotation overlay mode to draw the line based on the coordinates.
+     * @param addLine
+     */
+    public void setAddLine(boolean addLine) {
+        this.addLine = addLine;
+        resetEditMeasurement();
+    }
+
+    public boolean isAddRect() {
+        return addRect;
+    }
+
+    public void setAddRect(boolean addRect) {
+        this.addRect = addRect;
+        resetEditMeasurement();
+    }
+
+    /**
+     * This routine used to rotate all the annotation to 90 degree right
+     */
+    public void doRotateRight() {
+        addShapeToArray();
+        rotateLineRight();
+        rotateRectangleRight();
+        rotateEllipseRight();
+        resetMousePoints();
+        this.repaint();
+
+    }
+
+    public void resetAnnotation() {
+        if (this.layeredCanvas.imgpanel.isRotate) {
+            if (this.layeredCanvas.imgpanel.rotateRightAngle == 90) {
+                doRotateLeft();
+            } else if (this.layeredCanvas.imgpanel.rotateRightAngle == 180) {
+                doRotateLeft();
+                doRotateLeft();
+            } else if (this.layeredCanvas.imgpanel.rotateRightAngle == 270) {
+                doRotateRight();
+            }
+        }
+        if (this.layeredCanvas.imgpanel.flipHorizontalFlag) {
+            doFlipHorizontal();
+        }
+        if (this.layeredCanvas.imgpanel.flipVerticalFlag) {
+            doFlipVertical();
+        }
+
+    }
+
+    public void setCurrentAnnotation() {
+        if (this.layeredCanvas.imgpanel.isRotate) {
+            if (this.layeredCanvas.imgpanel.rotateRightAngle == 90) {
+                doRotateRight();
+            } else if (this.layeredCanvas.imgpanel.rotateRightAngle == 180) {
+                doRotateRight();
+                doRotateRight();
+            } else if (this.layeredCanvas.imgpanel.rotateRightAngle == 270) {
+                doRotateLeft();
+            }
+        }
+        if (this.layeredCanvas.imgpanel.flipHorizontalFlag) {
+            doFlipHorizontal();
+        }
+        if (this.layeredCanvas.imgpanel.flipVerticalFlag) {
+            doFlipVertical();
+        }
+    }
+
+    /**
+     * This routine used to reset the mouse points stored in the annotation overlay.
+     */
+    private void resetMousePoints() {
+        mouseLocX1 = 0;
+        mouseLocX2 = 0;
+        mouseLocY1 = 0;
+        mouseLocY2 = 0;
+    }
+
+    /**
+     * This routine used to rotate all the line to 90 degree right
+     */
+    private void rotateLineRight() {
+        Iterator<AnnotationObj> ite = lineObj.iterator();
+        while (ite.hasNext()) {
+            AnnotationObj t = ite.next();
+            int x1 = -1 * t.getCenterBasedY1();
+            int y1 = 1 * t.getCenterBasedX1();
+            int x2 = -1 * t.getCenterBasedY2();
+            int y2 = 1 * t.getCenterBasedX2();
+            t.setCenterBasedLocation(x1, y1, x2, y2);
+        }
+    }
+
+    /**
+     * This routine used to rotate the rectangle to 90 degree right
+     */
+    private void rotateRectangleRight() {
+        Iterator<AnnotationObj> ite1 = rectObj.iterator();
+        while (ite1.hasNext()) {
+            AnnotationObj t = ite1.next();
+            int x1 = -1 * t.getCenterBasedY1();
+            int y1 = 1 * t.getCenterBasedX1();
+            int x2 = -1 * t.getCenterBasedY2();
+            int y2 = 1 * t.getCenterBasedX2();
+            t.setCenterBasedLocation(x1, y1, x2, y2);
+        }
+    }
+
+    /**
+     * This routine used to rotate all the ellipse to 90 degree right
+     */
+    private void rotateEllipseRight() {
+        Iterator<AnnotationObj> ite2 = ellipseObj.iterator();
+        while (ite2.hasNext()) {
+            AnnotationObj t = ite2.next();
+            int x1 = -1 * t.getCenterBasedY1();
+            int y1 = 1 * t.getCenterBasedX1();
+            int x2 = -1 * t.getCenterBasedY2();
+            int y2 = 1 * t.getCenterBasedX2();
+            t.setCenterBasedLocation(x1, y1, x2, y2);
+        }
+    }
+
+    /**
+     * This routine used to rotate all the annotation to 90 degree left
+     */
+    public void doRotateLeft() {
+        addShapeToArray();
+        rotateLineLeft();
+        rotateRectangleLeft();
+        rotateEllipseLeft();
+        resetMousePoints();
+        this.repaint();
+    }
+
+    /**
+     * This routine used to rotate all the lines to 90 degree left
+     */
+    private void rotateLineLeft() {
+        Iterator<AnnotationObj> ite = lineObj.iterator();
+        while (ite.hasNext()) {
+            AnnotationObj t = ite.next();
+            int x1 = 1 * t.getCenterBasedY1();
+            int y1 = -1 * t.getCenterBasedX1();
+            int x2 = 1 * t.getCenterBasedY2();
+            int y2 = -1 * t.getCenterBasedX2();
+            t.setCenterBasedLocation(x1, y1, x2, y2);
+        }
+    }
+
+    /**
+     * This routine used to rotate all the rectangle to 90 degree left
+     */
+    private void rotateRectangleLeft() {
+        Iterator<AnnotationObj> ite1 = rectObj.iterator();
+        while (ite1.hasNext()) {
+            AnnotationObj t = ite1.next();
+            int x1 = 1 * t.getCenterBasedY1();
+            int y1 = -1 * t.getCenterBasedX1();
+            int x2 = 1 * t.getCenterBasedY2();
+            int y2 = -1 * t.getCenterBasedX2();
+            t.setCenterBasedLocation(x1, y1, x2, y2);
+        }
+    }
+
+    /**
+     * This routine used to rotate all the ellipse to 90 degree left
+     */
+    private void rotateEllipseLeft() {
+        Iterator<AnnotationObj> ite2 = ellipseObj.iterator();
+        while (ite2.hasNext()) {
+            AnnotationObj t = ite2.next();
+            int x1 = 1 * t.getCenterBasedY1();
+            int y1 = -1 * t.getCenterBasedX1();
+            int x2 = 1 * t.getCenterBasedY2();
+            int y2 = -1 * t.getCenterBasedX2();
+            t.setCenterBasedLocation(x1, y1, x2, y2);
+        }
+    }
+
+    /**
+     * This routine used to flip all annotations vertically
+     */
+    public void doFlipVertical() {
+        addShapeToArray();
+        flipLineVertical();
+        flipRectangleVertical();
+        flipEllipseVertical();
+        resetMousePoints();
+        this.repaint();
+    }
+
+    /**
+     * This routine used to flip all lines vertically
+     */
+    private void flipLineVertical() {
+        Iterator<AnnotationObj> ite = lineObj.iterator();
+        while (ite.hasNext()) {
+            AnnotationObj t = ite.next();
+            int x1 = 1 * t.getCenterBasedX1();
+            int y1 = -1 * t.getCenterBasedY1();
+            int x2 = 1 * t.getCenterBasedX2();
+            int y2 = -1 * t.getCenterBasedY2();
+            t.setCenterBasedLocation(x1, y1, x2, y2);
+        }
+    }
+
+    /**
+     * This routine used to flip all rectangle vertically
+     */
+    private void flipRectangleVertical() {
+        Iterator<AnnotationObj> ite1 = rectObj.iterator();
+        while (ite1.hasNext()) {
+            AnnotationObj t = ite1.next();
+            int x1 = 1 * t.getCenterBasedX1();
+            int y1 = -1 * t.getCenterBasedY1();
+            int x2 = 1 * t.getCenterBasedX2();
+            int y2 = -1 * t.getCenterBasedY2();
+            t.setCenterBasedLocation(x1, y1, x2, y2);
+        }
+    }
+
+    /**
+     * This routine is used to flip all ellipse vertically
+     */
+    private void flipEllipseVertical() {
+        Iterator<AnnotationObj> ite2 = ellipseObj.iterator();
+        while (ite2.hasNext()) {
+            AnnotationObj t = ite2.next();
+            int x1 = 1 * t.getCenterBasedX1();
+            int y1 = -1 * t.getCenterBasedY1();
+            int x2 = 1 * t.getCenterBasedX2();
+            int y2 = -1 * t.getCenterBasedY2();
+            t.setCenterBasedLocation(x1, y1, x2, y2);
+        }
+    }
+
+    /**
+     * This routine used to flip all the annotation horizontally
+     */
+    public void doFlipHorizontal() {
+        addShapeToArray();
+        flipLineHorizontal();
+        flipRectangleHorizontal();
+        flipEllipseHorizontal();
+        resetMousePoints();
+        this.repaint();
+
+    }
+
+    /**
+     * This routine used to flip all the lines horizontally
+     */
+    private void flipLineHorizontal() {
+        Iterator<AnnotationObj> ite = lineObj.iterator();
+        while (ite.hasNext()) {
+            AnnotationObj t = ite.next();
+            int x1 = -1 * t.getCenterBasedX1();
+            int y1 = 1 * t.getCenterBasedY1();
+            int x2 = -1 * t.getCenterBasedX2();
+            int y2 = 1 * t.getCenterBasedY2();
+            t.setCenterBasedLocation(x1, y1, x2, y2);
+        }
+    }
+
+    /**
+     * This routine used to flip all the rectangle vertically
+     */
+    private void flipRectangleHorizontal() {
+        Iterator<AnnotationObj> ite1 = rectObj.iterator();
+        while (ite1.hasNext()) {
+            AnnotationObj t = ite1.next();
+            int x1 = -1 * t.getCenterBasedX1();
+            int y1 = 1 * t.getCenterBasedY1();
+            int x2 = -1 * t.getCenterBasedX2();
+            int y2 = 1 * t.getCenterBasedY2();
+            t.setCenterBasedLocation(x1, y1, x2, y2);
+        }
+    }
+
+    /**
+     * This routine used to flip all the elliptical horizontally
+     */
+    private void flipEllipseHorizontal() {
+        Iterator<AnnotationObj> ite2 = ellipseObj.iterator();
+        while (ite2.hasNext()) {
+            AnnotationObj t = ite2.next();
+            int x1 = -1 * t.getCenterBasedX1();
+            int y1 = 1 * t.getCenterBasedY1();
+            int x2 = -1 * t.getCenterBasedX2();
+            int y2 = 1 * t.getCenterBasedY2();
+            t.setCenterBasedLocation(x1, y1, x2, y2);
+        }
+    }
+    /*
+     * Following code will be helpful in future. 
+     * int x1 = (int) (-cosninety * t.getCenterBasedX1() + sineninety * t.getCenterBasedY1());
+     * int y1 = (int) (-sineninety * t.getCenterBasedX1() - cosninety * t.getCenterBasedY1());
+     * int x2 = (int) (-cosninety * t.getCenterBasedX2() + sineninety * t.getCenterBasedY2());
+     * int y2 = (int) (-sineninety * t.getCenterBasedX2() - cosninety * t.getCenterBasedY2());*/
+
+    /**
+     * This routine used to clear all the measurement from the annotation layer
+     */
+    public void clearAllMeasurement() {
+        lineObj = new ArrayList<AnnotationObj>();
+        rectObj = new ArrayList<AnnotationObj>();
+        ellipseObj = new ArrayList<AnnotationObj>();
+        mouseLocX1 = 0;
+        mouseLocX2 = 0;
+        mouseLocY1 = 0;
+        mouseLocY2 = 0;
+        seletedShape = null;
+        boundingRect = null;
+        this.repaint();
+        this.layeredCanvas.imgpanel.storeAnnotation();
+    }
+
+    public void stopPanning() {
+        if (tool.equalsIgnoreCase("panning")) {
+            tool = "";
+            this.layeredCanvas.imgpanel.tool = "";
+        }
+    }
+
+    public void focusGained(FocusEvent e) {
+        ApplicationContext.annotationPanel = this;
+        focusGained = true;
+        repaint();
+    }
+
+    public void focusLost(FocusEvent e) {
+        focusGained = false;
+        repaint();
+    }
+
+    public boolean isFocusGained() {
+        return focusGained;
+    }
+
+    @Override
+    public void paint(Graphics gs) {
+        super.paint(gs);
+        if (showAnnotation) {
+            Graphics2D g = (Graphics2D) gs;
+            g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+            g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
+
+            if (this.layeredCanvas.imgpanel.isScaleFlag()) {
+                g.scale(this.layeredCanvas.imgpanel.getScaleFactor(), this.layeredCanvas.imgpanel.getScaleFactor());
+            }
+            g.setColor(new Color(255, 138, 0));
+            gs.setColor(new Color(255, 138, 0));
+            //Condition used to draw new line as per the line flag values and coordinates of the annotation mouse point
+            if ((mouseLocX1 != -1 && mouseLocX2 != -1 && mouseLocY1 != -1 && mouseLocY2 != -1) && addLine) {
+                g.drawString("Length:" + calculateDiff((int) (mouseLocX1 / this.layeredCanvas.imgpanel.getScaleFactor()), (int) (mouseLocY1 / this.layeredCanvas.imgpanel.getScaleFactor()), (int) (mouseLocX2 / this.layeredCanvas.imgpanel.getScaleFactor()), (int) (mouseLocY2 / this.layeredCanvas.imgpanel.getScaleFactor())), (int) (mouseLocX1 / this.layeredCanvas.imgpanel.getScaleFactor()), (int) ((mouseLocY1 / this.layeredCanvas.imgpanel.getScaleFactor()) - 20));
+                g.drawLine((int) (mouseLocX1 / this.layeredCanvas.imgpanel.getScaleFactor()), (int) (mouseLocY1 / this.layeredCanvas.imgpanel.getScaleFactor()), (int) (mouseLocX2 / this.layeredCanvas.imgpanel.getScaleFactor()), (int) (mouseLocY2 / this.layeredCanvas.imgpanel.getScaleFactor()));
+                g.fill(new Ellipse2D.Double((mouseLocX1 / this.layeredCanvas.imgpanel.getScaleFactor()) - 3.0, (mouseLocY1 / this.layeredCanvas.imgpanel.getScaleFactor()) - 3.0, 6.0, 6.0));
+                g.fill(new Ellipse2D.Double((mouseLocX2 / this.layeredCanvas.imgpanel.getScaleFactor()) - 3.0, (mouseLocY2 / this.layeredCanvas.imgpanel.getScaleFactor()) - 3.0, 6.0, 6.0));
+            }
+            // As per the lineObj present in the tile it will display the lines
+            Iterator<AnnotationObj> ite = lineObj.iterator();
+            while (ite.hasNext()) {
+                AnnotationObj t = ite.next();
+                g.drawString("Length:" + t.getLength(), t.getX1(), t.getY1() - 20);
+                g.drawLine(t.getX1(), t.getY1(), t.getX2(), t.getY2());
+                g.fill(new Ellipse2D.Double(t.getX1() - 3.0, t.getY1() - 3.0, 6.0, 6.0));
+                g.fill(new Ellipse2D.Double(t.getX2() - 3.0, t.getY2() - 3.0, 6.0, 6.0));
+            }
+            //Condition used to check the coordinate position and rectangle flag
+            if ((mouseLocX1 != -1 && mouseLocX2 != -1 && mouseLocY1 != -1 && mouseLocY2 != -1) && addRect) {
+
+                ShapeCoordinates shapeCoordinates = new ShapeCoordinates((int) (mouseLocX1 / this.layeredCanvas.imgpanel.getScaleFactor()), (int) (mouseLocY1 / this.layeredCanvas.imgpanel.getScaleFactor()), (int) (mouseLocX2 / this.layeredCanvas.imgpanel.getScaleFactor()), (int) (mouseLocY2 / this.layeredCanvas.imgpanel.getScaleFactor()));
+                //Draw new string for area,mean and stddev for the current shape
+                gs.drawString("Area:" + calculateArea((int) (mouseLocX1 / this.layeredCanvas.imgpanel.getScaleFactor()), (int) (mouseLocY1 / this.layeredCanvas.imgpanel.getScaleFactor()), (int) (mouseLocX2 / this.layeredCanvas.imgpanel.getScaleFactor()), (int) (mouseLocY2 / this.layeredCanvas.imgpanel.getScaleFactor())), shapeCoordinates.getX(), shapeCoordinates.getY() - 60);
+                gs.drawString("Mean:", shapeCoordinates.getX(), shapeCoordinates.getY() - 40);
+                gs.drawString("Std Dev:", shapeCoordinates.getX(), shapeCoordinates.getY() - 20);
+                gs.drawRect(shapeCoordinates.getX(), shapeCoordinates.getY(), shapeCoordinates.getWidth(), shapeCoordinates.getHeight());
+            }
+            //As per the rectObj present in the list it will iterate and draw the rectanlge
+            Iterator<AnnotationObj> ite1 = rectObj.iterator();
+            while (ite1.hasNext()) {
+                AnnotationObj t = ite1.next();
+                //Draws new string for area,mean,stddev for the current shape
+                ShapeCoordinates shapeCoordinates = new ShapeCoordinates(t.getX1(), t.getY1(), t.getX2(), t.getY2());
+                gs.drawString("Area:" + t.getArea(), shapeCoordinates.getX(), shapeCoordinates.getY() - 60);
+                gs.drawString("Mean:", shapeCoordinates.getX(), shapeCoordinates.getY() - 40);
+                gs.drawString("Std Dev:", shapeCoordinates.getX(), shapeCoordinates.getY() - 20);
+                gs.drawRect(shapeCoordinates.getX(), shapeCoordinates.getY(), shapeCoordinates.getWidth(), shapeCoordinates.getHeight());
+            }
+            //Condition used to check the current cooridnates and ellipse flag
+            if ((mouseLocX1 != -1 && mouseLocX2 != -1 && mouseLocY1 != -1 && mouseLocY2 != -1) && addEllipse) {
+//           //Draws the strings such as area,mean,stddev for the current shape
+                ShapeCoordinates shapeCoordinates = new ShapeCoordinates((int) (mouseLocX1 / this.layeredCanvas.imgpanel.getScaleFactor()), (int) (mouseLocY1 / this.layeredCanvas.imgpanel.getScaleFactor()), (int) (mouseLocX2 / this.layeredCanvas.imgpanel.getScaleFactor()), (int) (mouseLocY2 / this.layeredCanvas.imgpanel.getScaleFactor()));
+                gs.drawString("Area:" + calculateOvalArea((int) (mouseLocX1 / this.layeredCanvas.imgpanel.getScaleFactor()), (int) (mouseLocY1 / this.layeredCanvas.imgpanel.getScaleFactor()), (int) (mouseLocX2 / this.layeredCanvas.imgpanel.getScaleFactor()), (int) (mouseLocY2 / this.layeredCanvas.imgpanel.getScaleFactor())), shapeCoordinates.getX(), shapeCoordinates.getY() - 60);
+                gs.drawString("Mean:", shapeCoordinates.getX(), shapeCoordinates.getY() - 40);
+                gs.drawString("Std Dev:", shapeCoordinates.getX(), shapeCoordinates.getY() - 20);
+                gs.drawOval(shapeCoordinates.getX(), shapeCoordinates.getY(), shapeCoordinates.getWidth(), shapeCoordinates.getHeight());
+            }
+            //As per the ellipseObj present in the list it will iterate and draw the ellipse
+            Iterator<AnnotationObj> ite2 = ellipseObj.iterator();
+            while (ite2.hasNext()) {
+                AnnotationObj t = ite2.next();
+                //Used to draw the area,mean and std dev values in the annotation panel
+                ShapeCoordinates shapeCoordinates = new ShapeCoordinates(t.getX1(), t.getY1(), t.getX2(), t.getY2());
+                gs.drawString("Area:" + t.getArea(), shapeCoordinates.getX(), shapeCoordinates.getY() - 60);
+                gs.drawString("Mean:", shapeCoordinates.getX(), shapeCoordinates.getY() - 40);
+                gs.drawString("Std Dev:", shapeCoordinates.getX(), shapeCoordinates.getY() - 20);
+                gs.drawOval(shapeCoordinates.getX(), shapeCoordinates.getY(), shapeCoordinates.getWidth(), shapeCoordinates.getHeight());
+            }
+            //Condition used to check the panel is called for the first time
+            if (firstTime) {
+                centerImage();
+                this.setSize(layeredCanvas.imgpanel.getSize().width, layeredCanvas.imgpanel.getSize().height);
+                firstTime = false;
+                this.repaint();
+            }
+            // Selecting the annotations
+            if (boundingRect != null) {
+                if (selectedShapeType.equalsIgnoreCase("line")) {
+                    drawHighlightLines(g, boundingRect);
+                } else {
+                    drawHighlightSquares(g, boundingRect);
+                }
+            }
+            if (curCursor != null) {
+                setCursor(curCursor);
+            }
+            if (seletedShape != null) {
+                if (selectedShapeType.equalsIgnoreCase("line")) {
+                    gs.drawString("Length:" + selectedShapeDisplayStringValue, seletedShape.getBounds().x, seletedShape.getBounds().y - 20);
+                    if (selectedShapeOrientation.equalsIgnoreCase("left")) {
+                        gs.drawLine(seletedShape.getBounds().x, seletedShape.getBounds().y, seletedShape.getBounds().x + seletedShape.getBounds().width, seletedShape.getBounds().y + seletedShape.getBounds().height);
+                    } else {
+                        gs.drawLine(seletedShape.getBounds().x + seletedShape.getBounds().width, seletedShape.getBounds().y, seletedShape.getBounds().x, seletedShape.getBounds().y + seletedShape.getBounds().height);
+                    }
+                    // gs.drawString("Length:" + selectedShapeDisplayStringValue + " cm", seletedShape.getBounds().x, seletedShape.getBounds().y - 20);
+                    // g.draw(seletedShape);
+                } else if (selectedShapeType.equalsIgnoreCase("ellipse")) {
+                    //Used to draw the area,mean and std dev values in the annotation panel                    
+                    gs.drawString("Area:" + selectedShapeDisplayStringValue, seletedShape.getBounds().x, seletedShape.getBounds().y - 60);
+                    gs.drawString("Mean:", seletedShape.getBounds().x, seletedShape.getBounds().y - 40);
+                    gs.drawString("Std Dev:", seletedShape.getBounds().x, seletedShape.getBounds().y - 20);
+                    gs.drawOval(seletedShape.getBounds().x, seletedShape.getBounds().y, seletedShape.getBounds().width, seletedShape.getBounds().height);
+
+                } else {
+                    gs.drawString("Area:" + selectedShapeDisplayStringValue, seletedShape.getBounds().x, seletedShape.getBounds().y - 60);
+                    gs.drawString("Mean:", seletedShape.getBounds().x, seletedShape.getBounds().y - 40);
+                    gs.drawString("Std Dev:", seletedShape.getBounds().x, seletedShape.getBounds().y - 20);
+                    g.draw(seletedShape);
+                }
+            }
+            //this.setBorder(new LineBorder(Color.yellow));
+        }
+
+    }
+
+    /**
+     * This routine used to toggle the annotation overlay visibility.
+     */
+    public void toggleAnnotation() {
+        if (showAnnotation) {
+            showAnnotation = false;
+        } else {
+            showAnnotation = true;
+        }
+
+        this.repaint();
+
+    }
+
+    public boolean isShowAnnotation() {
+        return showAnnotation;
+    }
+
+    /**
+     * This routine used to draw the highlight square around the selected measurement.
+     * @param g2D
+     * @param r
+     */
+    public void drawHighlightSquares(Graphics2D g2D, Rectangle r) {
+        double x = r.getX();
+        double y = r.getY();
+        double w = r.getWidth();
+        double h = r.getHeight();
+        g2D.setColor(Color.RED);
+        g2D.fill(new Rectangle.Double(x - 3.0, y - 3.0, 6.0, 6.0));
+        g2D.fill(new Rectangle.Double(x + w * 0.5 - 3.0, y - 3.0, 6.0, 6.0));
+        g2D.fill(new Rectangle.Double(x + w - 3.0, y - 3.0, 6.0, 6.0));
+        g2D.fill(new Rectangle.Double(x - 3.0, y + h * 0.5 - 3.0, 6.0, 6.0));
+        g2D.fill(new Rectangle.Double(x + w - 3.0, y + h * 0.5 - 3.0, 6.0, 6.0));
+        g2D.fill(new Rectangle.Double(x - 3.0, y + h - 3.0, 6.0, 6.0));
+        g2D.fill(new Rectangle.Double(x + w * 0.5 - 3.0, y + h - 3.0, 6.0, 6.0));
+        g2D.fill(new Rectangle.Double(x + w - 3.0, y + h - 3.0, 6.0, 6.0));
+    }
+
+    public void drawHighlightLines(Graphics2D g2D, Rectangle r) {
+        double x = r.getX();
+        double y = r.getY();
+        double w = r.getWidth();
+        double h = r.getHeight();
+        g2D.setColor(Color.RED);
+        if (selectedShapeOrientation.equalsIgnoreCase("left")) {
+            g2D.fill(new Ellipse2D.Double(x - 3.0, y - 3.0, 6.0, 6.0));
+            g2D.fill(new Ellipse2D.Double(x + w - 3.0, y + h - 3.0, 6.0, 6.0));
+        } else {
+            g2D.fill(new Ellipse2D.Double(x + w - 3.0, y - 3.0, 6.0, 6.0));
+            g2D.fill(new Ellipse2D.Double(x - 3.0, y + h - 3.0, 6.0, 6.0));
+        }
+    }
+
+    public void mouseDragged(MouseEvent e) {
+        if (tool.equalsIgnoreCase("panning")) {
+            mouseLocX2 = e.getX();
+            mouseLocY2 = e.getY();
+            // curCursor = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR);
+            this.setLocation(this.getBounds().x + mouseLocX2 - mouseLocX1, this.getBounds().y + mouseLocY2 - mouseLocY1);
+            repaint();
+        } else if (moveMeasurement) {
+            if (seletedShape != null) {
+                mouseLocX2 = e.getX();
+                mouseLocY2 = e.getY();
+                Shape temp = new Rectangle2D.Float(seletedShape.getBounds().x + mouseLocX2 - mouseLocX1, seletedShape.getBounds().y + mouseLocY2 - mouseLocY1, seletedShape.getBounds().width, seletedShape.getBounds().height);
+                seletedShape = temp;
+                boundingRect = temp.getBounds();
+                mouseLocX1 = mouseLocX2;
+                mouseLocY1 = mouseLocY2;
+                repaint();
+            }
+        } else if (this.isAddEllipse() || this.isAddRect() || this.isAddLine()) {
+            if (!startAnnotation) {
+                mouseLocX2 = e.getX();
+                mouseLocY2 = e.getY();
+                repaint();
+            }
+        } else if (resizeMeasurement) {
+            if (seletedShape != null) {
+            }
+        }
+        this.layeredCanvas.imgpanel.mouseDragged(e);
+    }
+
+    private void centerImage() {
+        int xPosition = (layeredCanvas.getSize().width - this.getSize().width) / 2;
+        int yPosition = (layeredCanvas.getSize().height - this.getSize().height) / 2;
+        this.setBounds(xPosition, yPosition, this.getSize().width, this.getSize().height);
+    }
+
+    public boolean isFirstTime() {
+        return firstTime;
+    }
+
+    public void setFirstTime(boolean firstTime) {
+        this.firstTime = firstTime;
+    }
+
+    public void mouseMoved(MouseEvent e) {
+        if (this.isAddEllipse() || this.isAddRect() || this.isAddLine()) {
+//            if (!startAnnotation) {
+//                mouseLocX2 = e.getX();
+//                mouseLocY2 = e.getY();
+//                repaint();
+//            }
+        } else if (moveMeasurement) {
+        } else {
+            this.layeredCanvas.imgpanel.mouseMoved(e);
+        }
+    }
+
+    public void doZoomIn() {
+        scaleProcess();
+    }
+
+    public void doZoomOut() {
+        if (this.layeredCanvas.imgpanel.getScaleFactor() > 0) {
+            scaleProcess();
+        }
+    }
+
+    public void scaleProcess() {
+        double currentWidth = this.getSize().width;
+        double currentHeight = this.getSize().height;
+        double newWidth = this.layeredCanvas.imgpanel.getOriginalWidth() * this.layeredCanvas.imgpanel.getScaleFactor();
+        double newHeight = this.layeredCanvas.imgpanel.getOriginalHeight() * this.layeredCanvas.imgpanel.getScaleFactor();
+        double widthDiff = newWidth - currentWidth;
+        double heightDiff = newHeight - currentHeight;
+        int currentX = this.getBounds().x;
+        int currentY = this.getBounds().y;
+        double newX = currentX - (widthDiff / 2);
+        double newY = currentY - (heightDiff / 2);
+        this.setBounds((int) newX, (int) newY, (int) newWidth, (int) newHeight);
+        this.revalidate();
+        repaint();
+    }
+
+    /**
+     * This routine used to calculate the difference based on the coordinates passed as parameter.
+     * @param mouseLocX1
+     * @param mouseLocY1
+     * @param mouseLocX2
+     * @param mouseLocY2
+     * @return
+     */
+    private String calculateDiff(int mouseLocX1, int mouseLocY1, int mouseLocX2, int mouseLocY2) {
+        double diff, returnValue;
+        String returnString = "";
+        if (mouseLocX1 == mouseLocX2) {
+            if (this.layeredCanvas.imgpanel.getPixelSpacingY() != 0) {
+                diff = (double) (((mouseLocY2 - mouseLocY1) / this.layeredCanvas.imgpanel.getCurrentScaleFactor()) * (this.layeredCanvas.imgpanel.getPixelSpacingY()));
+            } else {
+                diff = (double) ((mouseLocY2 - mouseLocY1) / this.layeredCanvas.imgpanel.getCurrentScaleFactor());
+            }
+
+        } else if (mouseLocY1 == mouseLocY2) {
+            if (this.layeredCanvas.imgpanel.getPixelSpacingX() != 0) {
+                diff = (double) (((mouseLocX2 - mouseLocX1) / this.layeredCanvas.imgpanel.getCurrentScaleFactor()) * (this.layeredCanvas.imgpanel.getPixelSpacingX()));
+            } else {
+                diff = (double) ((mouseLocX2 - mouseLocX1) / this.layeredCanvas.imgpanel.getCurrentScaleFactor());
+            }
+        } else {
+            if (this.layeredCanvas.imgpanel.getPixelSpacingY() != 0 && this.layeredCanvas.imgpanel.getPixelSpacingX() != 0) {
+                diff = (double) Math.sqrt(Math.pow(((mouseLocY2 - mouseLocY1) / this.layeredCanvas.imgpanel.getCurrentScaleFactor()) * (this.layeredCanvas.imgpanel.getPixelSpacingY()), 2) + Math.pow(((mouseLocX2 - mouseLocX1) / this.layeredCanvas.imgpanel.getCurrentScaleFactor()) * (this.layeredCanvas.imgpanel.getPixelSpacingX()), 2));
+            } else {
+                diff = (double) Math.sqrt(Math.pow(((mouseLocY2 - mouseLocY1) / this.layeredCanvas.imgpanel.getCurrentScaleFactor()), 2) + Math.pow(((mouseLocX2 - mouseLocX1) / this.layeredCanvas.imgpanel.getCurrentScaleFactor()), 2));
+            }
+        }
+        NumberFormat nf = NumberFormat.getInstance();
+        nf.setMaximumFractionDigits(3);
+        if (this.layeredCanvas.imgpanel.getPixelSpacingY() == 0 && this.layeredCanvas.imgpanel.getPixelSpacingX() == 0) {
+            returnString = nf.format(diff) + " pix";
+        } else {
+            returnValue = diff / 10;
+            returnString = nf.format(returnValue) + " cm";
+        }
+        return returnString;
+    }
+
+    /**
+     * This routine used to calculate the area based on coordinates passed as parameter.
+     * @param mouseLocX1
+     * @param mouseLocY1
+     * @param mouseLocX2
+     * @param mouseLocY2
+     * @return
+     */
+    private String calculateArea(int mouseLocX1, int mouseLocY1, int mouseLocX2, int mouseLocY2) {
+        int diffY, diffX;
+        String returnString = "";
+        double diff, diff1;
+        if (mouseLocY2 - mouseLocY1 < 0) {
+            diffY = -(mouseLocY2 - mouseLocY1);
+        } else {
+            diffY = mouseLocY2 - mouseLocY1;
+        }
+        if (mouseLocX2 - mouseLocX1 < 0) {
+            diffX = -(mouseLocX2 - mouseLocX1);
+        } else {
+            diffX = mouseLocX2 - mouseLocX1;
+        }
+        if (this.layeredCanvas.imgpanel.getPixelSpacingY() != 0 && this.layeredCanvas.imgpanel.getPixelSpacingX() != 0) {
+            diff = (double) (((diffY / this.layeredCanvas.imgpanel.getCurrentScaleFactor()) * this.layeredCanvas.imgpanel.getPixelSpacingY()) * ((diffX / this.layeredCanvas.imgpanel.getCurrentScaleFactor()) * this.layeredCanvas.imgpanel.getPixelSpacingX()));
+        } else {
+            diff = (double) ((diffY / this.layeredCanvas.imgpanel.getCurrentScaleFactor()) * ((diffX / this.layeredCanvas.imgpanel.getCurrentScaleFactor())));
+        }
+        NumberFormat nf = NumberFormat.getInstance();
+        nf.setMaximumFractionDigits(3);
+        if (this.layeredCanvas.imgpanel.getPixelSpacingY() == 0 && this.layeredCanvas.imgpanel.getPixelSpacingX() == 0) {
+            returnString = nf.format(diff) + " pix2";
+        } else {
+            diff1 = diff / 100;
+            returnString = nf.format(diff1) + " cm2";
+        }
+        return returnString;
+    }
+
+    /**
+     * This routine used to calculate the oval area based on the coordinates passed as parameter.
+     * @param mouseLocX1
+     * @param mouseLocY1
+     * @param mouseLocX2
+     * @param mouseLocY2
+     * @return
+     */
+    public String calculateOvalArea(int mouseLocX1, int mouseLocY1, int mouseLocX2, int mouseLocY2) {
+        int diffY, diffX;
+        String returnString = "";
+        double diff, diff1;
+        double width, height;
+        if (mouseLocY2 - mouseLocY1 < 0) {
+            diffY = -(mouseLocY2 - mouseLocY1);
+        } else {
+            diffY = mouseLocY2 - mouseLocY1;
+        }
+        if (mouseLocX2 - mouseLocX1 < 0) {
+            diffX = -(mouseLocX2 - mouseLocX1);
+        } else {
+            diffX = mouseLocX2 - mouseLocX1;
+        }
+        if (this.layeredCanvas.imgpanel.getPixelSpacingY() != 0 && this.layeredCanvas.imgpanel.getPixelSpacingX() != 0) {
+            width = ((diffX / this.layeredCanvas.imgpanel.getCurrentScaleFactor()) * this.layeredCanvas.imgpanel.getPixelSpacingX());
+            height = ((diffY / this.layeredCanvas.imgpanel.getCurrentScaleFactor()) * this.layeredCanvas.imgpanel.getPixelSpacingY());
+        } else {
+            width = ((diffX / this.layeredCanvas.imgpanel.getCurrentScaleFactor()));
+            height = ((diffY / this.layeredCanvas.imgpanel.getCurrentScaleFactor()));
+        }
+        diff = (double) (Math.PI * (width * 0.5) * (height * 0.5));
+        NumberFormat nf = NumberFormat.getInstance();
+        nf.setMaximumFractionDigits(3);
+        if (this.layeredCanvas.imgpanel.getPixelSpacingY() == 0 && this.layeredCanvas.imgpanel.getPixelSpacingX() == 0) {
+            returnString = nf.format(diff) + " pix2";
+        } else {
+            //in order to get cm2 values
+            diff1 = diff / 100;
+            returnString = nf.format(diff1) + " cm2";
+        }
+        return returnString;
+    }
+
+    public ArrayList<AnnotationObj> getEllipseObj() {
+        return ellipseObj;
+    }
+
+    public void setEllipseObj(ArrayList<AnnotationObj> ellipseObj) {
+        this.ellipseObj = ellipseObj;
+    }
+
+    public ArrayList<AnnotationObj> getLineObj() {
+        return lineObj;
+    }
+
+    public void setLineObj(ArrayList<AnnotationObj> lineObj) {
+        this.lineObj = lineObj;
+    }
+
+    public ArrayList<AnnotationObj> getRectObj() {
+        return rectObj;
+    }
+
+    public void setRectObj(ArrayList<AnnotationObj> rectObj) {
+        this.rectObj = rectObj;
+    }
+
+    public Annotation getAnnotation() {
+        resetAnnotation();
+        annotation = new Annotation();
+        if (seletedShape != null) {
+            addShapeToArray();
+        }
+        annotation.setEllipse(ellipseObj);
+        annotation.setRect(rectObj);
+        annotation.setLine(lineObj);
+        resetCursorPoints();
+        return annotation;
+    }
+
+    /**
+     * This routine used to reset the cursor points.
+     */
+    public void resetCursorPoints() {
+        mouseLocX1 = -1;
+        mouseLocX2 = -1;
+        mouseLocY1 = -1;
+        mouseLocY2 = -1;
+    }
+
+    public void setAnnotation(Annotation annotation) {
+        if (annotation != null) {
+            this.annotation = annotation;
+            lineObj = annotation.getLine();
+            rectObj = annotation.getRect();
+            ellipseObj = annotation.getEllipse();
+        } else {
+            lineObj = new ArrayList<AnnotationObj>();
+            rectObj = new ArrayList<AnnotationObj>();
+            ellipseObj = new ArrayList<AnnotationObj>();
+        }
+        setCurrentAnnotation();
+        this.repaint();
+    }
+
+    public void mouseClicked(MouseEvent e) {
+    }
+
+    public void mousePressed(MouseEvent e) {
+        this.requestFocus();
+        this.layeredCanvas.imgpanel.mousePressed(e);
+        if (tool.equalsIgnoreCase("panning")) {
+            mouseLocX1 = e.getX();
+            mouseLocY1 = e.getY();
+        } else if (moveMeasurement) {
+            mouseLocX1 = e.getX();
+            mouseLocY1 = e.getY();
+            measurementMove(e);
+        }
+        if (addLine || addRect || addEllipse) {
+            if (startAnnotation) {
+                mouseLocX1 = e.getX();
+                mouseLocY1 = e.getY();
+                mouseLocX2 = e.getX();
+                mouseLocY2 = e.getY();
+                startAnnotation = false;
+            }
+        }
+    }
+
+    public void resetAnnotaionTools() {
+        this.addEllipse = false;
+        this.addLine = false;
+        this.addRect = false;
+    }
+
+    public void mouseReleased(MouseEvent e) {
+        if (addLine || addRect || addEllipse) {
+
+            if (!startAnnotation) {
+                startAnnotation = true;
+
+                if (mouseLocX1 != mouseLocX2 || mouseLocY1 != mouseLocY2) {
+
+                    if (addLine) {
+                        AnnotationObj newLine = new AnnotationObj();
+                        newLine.setMidX(SHAPEORIGIN);
+                        newLine.setMidY(SHAPEORIGIN);
+                        newLine.setLocation((int) (mouseLocX1 / this.layeredCanvas.imgpanel.getScaleFactor()), (int) (mouseLocY1 / this.layeredCanvas.imgpanel.getScaleFactor()), (int) (e.getX() / this.layeredCanvas.imgpanel.getScaleFactor()), (int) (e.getY() / this.layeredCanvas.imgpanel.getScaleFactor()));
+                        newLine.setType("line");
+                        newLine.setLength(calculateDiff((int) (mouseLocX1 / this.layeredCanvas.imgpanel.getScaleFactor()), (int) (mouseLocY1 / this.layeredCanvas.imgpanel.getScaleFactor()), (int) (e.getX() / this.layeredCanvas.imgpanel.getScaleFactor()), (int) (e.getY() / this.layeredCanvas.imgpanel.getScaleFactor())));
+                        lineObj.add(newLine);
+                        lineCount++;
+                    }
+                    if (addRect) {
+                        AnnotationObj newRect = new AnnotationObj();
+                        newRect.setMidX(SHAPEORIGIN);
+                        newRect.setMidY(SHAPEORIGIN);
+                        newRect.setLocation((int) (mouseLocX1 / this.layeredCanvas.imgpanel.getScaleFactor()), (int) (mouseLocY1 / this.layeredCanvas.imgpanel.getScaleFactor()), (int) (e.getX() / this.layeredCanvas.imgpanel.getScaleFactor()), (int) (e.getY() / this.layeredCanvas.imgpanel.getScaleFactor()));
+                        newRect.setType("rect");
+                        newRect.setArea(calculateArea((int) (mouseLocX1 / this.layeredCanvas.imgpanel.getScaleFactor()), (int) (mouseLocY1 / this.layeredCanvas.imgpanel.getScaleFactor()), (int) (e.getX() / this.layeredCanvas.imgpanel.getScaleFactor()), (int) (e.getY() / this.layeredCanvas.imgpanel.getScaleFactor())));
+                        rectObj.add(newRect);
+                        rectCount++;
+                    }
+                    if (addEllipse) {
+                        AnnotationObj newEllipse = new AnnotationObj();
+                        newEllipse.setMidX(SHAPEORIGIN);
+                        newEllipse.setMidY(SHAPEORIGIN);
+                        newEllipse.setLocation((int) (mouseLocX1 / this.layeredCanvas.imgpanel.getScaleFactor()), (int) (mouseLocY1 / this.layeredCanvas.imgpanel.getScaleFactor()), (int) (e.getX() / this.layeredCanvas.imgpanel.getScaleFactor()), (int) (e.getY() / this.layeredCanvas.imgpanel.getScaleFactor()));
+                        newEllipse.setType("ellipse");
+                        newEllipse.setArea(calculateOvalArea((int) (mouseLocX1 / this.layeredCanvas.imgpanel.getScaleFactor()), (int) (mouseLocY1 / this.layeredCanvas.imgpanel.getScaleFactor()), (int) (e.getX() / this.layeredCanvas.imgpanel.getScaleFactor()), (int) (e.getY() / this.layeredCanvas.imgpanel.getScaleFactor())));
+                        ellipseObj.add(newEllipse);
+                        ellipticalCount++;
+                    }
+                } else {
+                    mouseLocX1 = -1;
+                    mouseLocX2 = -1;
+                    mouseLocY1 = -1;
+                    mouseLocY2 = -1;
+                }
+
+            }//
+        }
+        this.layeredCanvas.imgpanel.mouseReleased(e);
+    }
+
+    public void mouseEntered(MouseEvent e) {
+    }
+
+    public void mouseExited(MouseEvent e) {
+    }
+
+    public void mouseWheelMoved(MouseWheelEvent e) {
+        this.requestFocus();
+        this.layeredCanvas.imgpanel.mouseWheelMoved(e);
+    }
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    // End of variables declaration//GEN-END:variables
+}
diff --git a/src/in/raster/mayam/form/Canvas.form b/src/in/raster/mayam/form/Canvas.form
new file mode 100644
index 0000000..d09120f
--- /dev/null
+++ b/src/in/raster/mayam/form/Canvas.form
@@ -0,0 +1,41 @@
+<?xml version="1.1" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+  <Properties>
+    <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+      <Color blue="0" green="0" red="0" type="rgb"/>
+    </Property>
+    <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+      <Color blue="ff" green="ff" red="ff" type="rgb"/>
+    </Property>
+    <Property name="focusCycleRoot" type="boolean" value="true"/>
+    <Property name="focusTraversalPolicyProvider" type="boolean" value="true"/>
+  </Properties>
+  <Events>
+    <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="formMouseClicked"/>
+  </Events>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <EmptySpace min="0" pref="436" max="32767" attributes="0"/>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <EmptySpace min="0" pref="322" max="32767" attributes="0"/>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+</Form>
diff --git a/src/in/raster/mayam/form/Canvas.java b/src/in/raster/mayam/form/Canvas.java
new file mode 100644
index 0000000..5c70f07
--- /dev/null
+++ b/src/in/raster/mayam/form/Canvas.java
@@ -0,0 +1,388 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.delegate.ImageOrientation;
+import java.awt.Color;
+import java.awt.FontMetrics;
+import java.awt.GradientPaint;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class Canvas extends javax.swing.JPanel {
+
+    /** Creates new form DateFormatPanel */
+    public boolean startPan = false;
+    public boolean focusGained = false;
+    private boolean firstTime = true;
+    private LayeredCanvas layeredCanvas;
+    private String columnRight = "";
+    private String columnLeft = "";
+    private String rowTop = "";
+    private String rowDown = "";
+
+    public Canvas(LayeredCanvas canvas) {
+        initComponents();
+        this.layeredCanvas = canvas;
+        setNoSelectionColoring();
+    }
+
+    public Canvas() {
+        initComponents();
+    }
+
+    Canvas(MainScreen ms) {
+    }
+
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        setBackground(new java.awt.Color(0, 0, 0));
+        setForeground(new java.awt.Color(255, 255, 255));
+        setFocusCycleRoot(true);
+        setFocusTraversalPolicyProvider(true);
+        addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                formMouseClicked(evt);
+            }
+        });
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
+        this.setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(0, 436, Short.MAX_VALUE)
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(0, 322, Short.MAX_VALUE)
+        );
+    }// </editor-fold>//GEN-END:initComponents
+
+    private void formMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseClicked
+        setSelection();
+        this.layeredCanvas.annotationPanel.mouseClicked(evt);
+    }//GEN-LAST:event_formMouseClicked
+    public boolean isFocusGained() {
+        return focusGained;
+    }
+
+    @Override
+    public void paint(Graphics g) {
+        super.paint(g);
+        if (firstTime) {
+            this.setSize(layeredCanvas.getSize().width, layeredCanvas.getSize().height);
+            firstTime = false;
+            centerImage();
+            repaint();
+        }
+        if (this.focusGained) {
+            g.setColor(new Color(255, 138, 0));
+        } else {
+            g.setColor(Color.DARK_GRAY);
+        }
+        g.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
+        if (this.layeredCanvas.imgpanel != null) {
+            if (this.layeredCanvas.imgpanel.getPixelSpacingY() != -1 && this.layeredCanvas.imgpanel.getPixelSpacingY() != 0) {
+                int viewScaleHeight = (int) ((int) (100 / this.layeredCanvas.imgpanel.getPixelSpacingY()) * this.layeredCanvas.imgpanel.getScaleFactor() * this.layeredCanvas.imgpanel.getCurrentScaleFactor());
+                int y1 = (this.getHeight() - viewScaleHeight) / 2;
+                int hx = 20;
+                int y2 = y1 + viewScaleHeight;
+                g.setColor(Color.YELLOW);
+                g.drawLine(hx, y1, hx, y2);
+                g.drawLine(hx, y1, hx + 12, y1);
+                g.drawLine(hx, y2, hx + 12, y2);
+                double viewScaleHeightUnit = (viewScaleHeight + 0.000f) / 10;
+                g.drawLine(hx, (int) (y1 + (viewScaleHeightUnit * 1)), hx + 6, (int) (y1 + (viewScaleHeightUnit * 1)));
+                g.drawLine(hx, (int) (y1 + (viewScaleHeightUnit * 2)), hx + 6, (int) (y1 + (viewScaleHeightUnit * 2)));
+                g.drawLine(hx, (int) (y1 + (viewScaleHeightUnit * 3)), hx + 6, (int) (y1 + (viewScaleHeightUnit * 3)));
+                g.drawLine(hx, (int) (y1 + (viewScaleHeightUnit * 4)), hx + 6, (int) (y1 + (viewScaleHeightUnit * 4)));
+                g.drawLine(hx, (int) (y1 + (viewScaleHeightUnit * 5)), hx + 12, (int) (y1 + (viewScaleHeightUnit * 5)));
+                g.drawLine(hx, (int) (y1 + (viewScaleHeightUnit * 6)), hx + 6, (int) (y1 + (viewScaleHeightUnit * 6)));
+                g.drawLine(hx, (int) (y1 + (viewScaleHeightUnit * 7)), hx + 6, (int) (y1 + (viewScaleHeightUnit * 7)));
+                g.drawLine(hx, (int) (y1 + (viewScaleHeightUnit * 8)), hx + 6, (int) (y1 + (viewScaleHeightUnit * 8)));
+                g.drawLine(hx, (int) (y1 + (viewScaleHeightUnit * 9)), hx + 6, (int) (y1 + (viewScaleHeightUnit * 9)));
+                int viewScaleWidth = (int) ((int) (100 / this.layeredCanvas.imgpanel.getPixelSpacingX()) * this.layeredCanvas.imgpanel.getScaleFactor() * this.layeredCanvas.imgpanel.getCurrentScaleFactor());
+                int wx1 = (this.getWidth() - viewScaleWidth) / 2;
+                int wy = this.getHeight() - 20;
+                int wx2 = wx1 + viewScaleWidth;
+                g.drawLine(wx1, wy, wx2, wy);
+                g.drawLine(wx1, wy, wx1, wy - 12);
+                g.drawLine(wx2, wy, wx2, wy - 12);
+                double viewScaleWidthUnit = (viewScaleWidth + 0.000f) / 10;
+                g.drawLine((int) (wx1 + (viewScaleWidthUnit * 5)), wy, (int) (wx1 + (viewScaleWidthUnit * 5)), wy - 12);
+                g.drawLine((int) (wx1 + (viewScaleWidthUnit * 1)), wy, (int) (wx1 + (viewScaleWidthUnit * 1)), wy - 6);
+                g.drawLine((int) (wx1 + (viewScaleWidthUnit * 2)), wy, (int) (wx1 + (viewScaleWidthUnit * 2)), wy - 6);
+                g.drawLine((int) (wx1 + (viewScaleWidthUnit * 3)), wy, (int) (wx1 + (viewScaleWidthUnit * 3)), wy - 6);
+                g.drawLine((int) (wx1 + (viewScaleWidthUnit * 4)), wy, (int) (wx1 + (viewScaleWidthUnit * 4)), wy - 6);
+                g.drawLine((int) (wx1 + (viewScaleWidthUnit * 6)), wy, (int) (wx1 + (viewScaleWidthUnit * 6)), wy - 6);
+                g.drawLine((int) (wx1 + (viewScaleWidthUnit * 7)), wy, (int) (wx1 + (viewScaleWidthUnit * 7)), wy - 6);
+                g.drawLine((int) (wx1 + (viewScaleWidthUnit * 8)), wy, (int) (wx1 + (viewScaleWidthUnit * 8)), wy - 6);
+                g.drawLine((int) (wx1 + (viewScaleWidthUnit * 9)), wy, (int) (wx1 + (viewScaleWidthUnit * 9)), wy - 6);
+            }
+            Graphics2D g2d = (Graphics2D) g;
+            int gradientHeight = 260;
+            int gradientWidth = 30;
+            int fromRight = 40;
+            GradientPaint gp1 = null;
+
+            gp1 = new GradientPaint(this.getSize().width - fromRight, ((this.getSize().height / 2) - (gradientHeight / 2)), Color.WHITE, (this.getSize().width - fromRight) + gradientWidth, ((this.getSize().height / 2) - (gradientHeight / 2)) + gradientHeight, Color.BLACK);
+            g2d.setPaint(gp1);
+            if (this.layeredCanvas.imgpanel.isInvertFlag()) {
+                gp1 = new GradientPaint(this.getSize().width - fromRight, ((this.getSize().height / 2) - (gradientHeight / 2)), Color.BLACK, (this.getSize().width - fromRight) + gradientWidth, ((this.getSize().height / 2) - (gradientHeight / 2)) + gradientHeight, Color.WHITE);
+                g2d.setPaint(gp1);
+            }
+
+            g2d.fillRect(this.getSize().width - fromRight, ((this.getSize().height / 2) - (gradientHeight / 2)), gradientWidth, gradientHeight);
+            g.setColor(Color.gray);
+            g.drawRect(this.getSize().width - fromRight, ((this.getSize().height / 2) - (gradientHeight / 2)), gradientWidth, gradientHeight);
+            FontMetrics font = g.getFontMetrics();
+            g.setColor(Color.white);
+            int wMin = this.layeredCanvas.imgpanel.getWindowLevel() - (this.layeredCanvas.imgpanel.getWindowWidth() / 2);
+            int wMax = this.layeredCanvas.imgpanel.getWindowLevel() + (this.layeredCanvas.imgpanel.getWindowWidth() / 2);
+            int windowCenter=this.layeredCanvas.imgpanel.getWindowLevel();
+            if(this.layeredCanvas.imgpanel.getWindowLevel()==0&&this.layeredCanvas.imgpanel.getWindowWidth()==0)
+            {
+                wMin=0;
+                wMax=255;
+                windowCenter=128;
+            }
+            int wlWdith = font.stringWidth(Integer.toString(windowCenter));
+            int wMinWidth = font.stringWidth(Integer.toString(wMin));
+            int wMaxWidth = font.stringWidth(Integer.toString(wMax));
+            g.drawString(Integer.toString(wMax), this.getSize().width - fromRight - wMaxWidth - 2, ((this.getSize().height / 2) - (gradientHeight / 2)));
+            g.drawString(Integer.toString(wMin), this.getSize().width - fromRight - wMinWidth - 2, ((this.getSize().height / 2) + (gradientHeight / 2)));
+            g.drawString(Integer.toString(windowCenter), this.getSize().width - fromRight - wlWdith - 2, ((this.getSize().height / 2)));
+
+            if (this.layeredCanvas.imgpanel.getImageOrientation() != null) {
+                this.getOrientation(this.layeredCanvas.imgpanel.getImageOrientation());
+                columnLeft = getOppositeOrientation(columnRight);
+                rowTop = getOppositeOrientation(rowDown);
+                if (this.layeredCanvas.imgpanel.isFlipHorizontalFlag()) {
+                    flipOrientationToHorizontal();
+                }
+                if (this.layeredCanvas.imgpanel.isFlipVerticalFlag()) {
+
+                    flipOrientationToVertical();
+                }
+                if (this.layeredCanvas.imgpanel.isIsRotate()) {
+                    if (this.layeredCanvas.imgpanel.getRotateRightAngle() == 90 || this.layeredCanvas.imgpanel.getRotateLeftAngle() == -270) {
+                        changeOrientationTo90();
+                    } else if (this.layeredCanvas.imgpanel.getRotateRightAngle() == 180 || this.layeredCanvas.imgpanel.getRotateLeftAngle() == -180) {
+                        changeOrientationTo180();
+                    } else if (this.layeredCanvas.imgpanel.getRotateRightAngle() == 270 || this.layeredCanvas.imgpanel.getRotateLeftAngle() == -90) {
+                        changeOrientationTo270();
+                    }
+                }
+                g.drawString(rowTop, (this.getSize().width / 2) - 1, 20);
+                g.drawString(rowDown, (this.getSize().width / 2) - 1, this.getSize().height - 7);
+                g.drawString(columnLeft, 10, (this.getSize().height / 2) - 1);
+                g.drawString(columnRight, this.getSize().width - 30, (this.getSize().height / 2) - 1);
+            }
+        }
+    }
+
+    @Override
+    protected void paintBorder(Graphics g) {
+        super.paintBorder(g);
+
+    }
+
+    public void resizeHandler() {
+        this.firstTime = true;
+        repaint();
+    }
+
+    /**
+     * This routine used to center the image.
+     */
+    private void centerImage() {
+        int xPosition = (this.getSize().width - this.getComponent(0).getSize().width) / 2;
+        int yPosition = (this.getSize().height - this.getComponent(0).getSize().height) / 2;
+        this.getComponent(0).setBounds(xPosition, yPosition, this.getComponent(0).getSize().width, this.getComponent(0).getSize().height);
+    }
+
+    public LayeredCanvas getLayeredCanvas() {
+        return layeredCanvas;
+    }
+
+    public void setLayeredCanvas(LayeredCanvas layeredCanvas) {
+        this.layeredCanvas = layeredCanvas;
+    }
+
+    /**
+     * This routine used to set the selection coloring.
+     */
+    public void setSelectionColoring() {
+        focusGained = true;
+        repaint();
+    }
+
+    public void changeOrientationTo90() {
+        String tempLeft, tempRight, tempTop, tempBottom;
+        tempLeft = columnLeft;
+        tempRight = columnRight;
+        tempTop = rowTop;
+        tempBottom = rowDown;
+        columnLeft = tempBottom;
+        rowTop = tempLeft;
+        columnRight = tempTop;
+        rowDown = tempRight;
+    }
+
+    public void changeOrientationTo180() {
+        String tempLeft, tempRight, tempTop, tempBottom;
+        tempLeft = columnLeft;
+        tempRight = columnRight;
+        tempTop = rowTop;
+        tempBottom = rowDown;
+        columnLeft = tempRight;
+        rowTop = tempBottom;
+        columnRight = tempLeft;
+        rowDown = tempTop;
+    }
+
+    public void changeOrientationTo270() {
+        String tempLeft, tempRight, tempTop, tempBottom;
+        tempLeft = columnLeft;
+        tempRight = columnRight;
+        tempTop = rowTop;
+        tempBottom = rowDown;
+        columnLeft = tempTop;
+        rowTop = tempRight;
+        columnRight = tempBottom;
+        rowDown = tempLeft;
+    }
+
+    public void flipOrientationToHorizontal() {
+        String tempLeft, tempRight;
+        tempLeft = columnLeft;
+        tempRight = columnRight;
+        columnLeft = tempRight;
+        columnRight = tempLeft;
+    }
+
+    public void flipOrientationToVertical() {
+        String tempTop, tempBottom;
+        tempTop = rowTop;
+        tempBottom = rowDown;
+        rowTop = tempBottom;
+        rowDown = tempTop;
+    }
+
+    public void getOrientation(String imageOrientation) {
+        String imageOrientationArray[];
+        imageOrientationArray = imageOrientation.split("\\\\");
+        float _imgRowCosx = Float.parseFloat(imageOrientationArray[0]);
+        float _imgRowCosy = Float.parseFloat(imageOrientationArray[1]);
+        float _imgRowCosz = Float.parseFloat(imageOrientationArray[2]);
+        float _imgColCosx = Float.parseFloat(imageOrientationArray[3]);
+        float _imgColCosy = Float.parseFloat(imageOrientationArray[4]);
+        float _imgColCosz = Float.parseFloat(imageOrientationArray[5]);
+        columnRight = ImageOrientation.getOrientation(_imgRowCosx, _imgRowCosy, _imgRowCosz);
+        rowDown = ImageOrientation.getOrientation(_imgColCosx, _imgColCosy, _imgColCosz);
+    }
+
+    public String getOppositeOrientation(String orientation) {
+        String oppositePrcl = "";
+        char[] temp = orientation.toCharArray();
+        for (char c : temp) {
+            oppositePrcl += getOpposite(c);
+        }
+        return oppositePrcl;
+    }
+
+    public char getOpposite(char c) {
+        char opposite = ' ';
+        switch (c) {
+            case 'L':
+                return 'R';
+            case 'R':
+                return 'L';
+            case 'P':
+                return 'A';
+            case 'A':
+                return 'P';
+            case 'H':
+                return 'F';
+            case 'F':
+                return 'H';
+        }
+        return opposite;
+    }
+
+    /**
+     * This routine used to remove the selection coloring.
+     */
+    public void setNoSelectionColoring() {
+        focusGained = false;
+        repaint();
+    }
+
+    public void setSelection() {
+        if (ApplicationContext.layeredCanvas != null) {
+            if (ApplicationContext.layeredCanvas.getCanvas() != null) {
+                ApplicationContext.layeredCanvas.getCanvas().setNoSelectionColoring();
+            } else {
+                ApplicationContext.layeredCanvas.setNoSelectionColoring();
+            }
+        }
+        ApplicationContext.imgPanel = (ImagePanel) this.getComponent(0);
+        ApplicationContext.layeredCanvas = this.layeredCanvas;
+        ApplicationContext.annotationPanel = this.layeredCanvas.annotationPanel;
+        ApplicationContext.layeredCanvas.getCanvas().setSelectionColoring();
+        if (ApplicationContext.imageViewExist()) {
+            ApplicationContext.imgView.getImageToolbar().refreshToolsDisplay();
+        }
+    }
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    // End of variables declaration//GEN-END:variables
+}
diff --git a/src/in/raster/mayam/form/DateFormatPanel.form b/src/in/raster/mayam/form/DateFormatPanel.form
new file mode 100644
index 0000000..fb4f1f2
--- /dev/null
+++ b/src/in/raster/mayam/form/DateFormatPanel.form
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Component id="jLabel1" alignment="0" pref="437" max="32767" attributes="0"/>
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace min="-2" pref="22" max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Component id="jRadioButton2" alignment="0" min="-2" max="-2" attributes="0"/>
+                  <Component id="jRadioButton1" alignment="0" min="-2" max="-2" attributes="0"/>
+                  <Group type="102" alignment="0" attributes="0">
+                      <Component id="jRadioButton3" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace type="unrelated" max="-2" attributes="0"/>
+                      <Group type="103" groupAlignment="0" max="-2" attributes="0">
+                          <Component id="jTextField1" alignment="0" max="32767" attributes="1"/>
+                          <Component id="jComboBox1" alignment="0" pref="190" max="32767" attributes="1"/>
+                      </Group>
+                  </Group>
+              </Group>
+              <EmptySpace pref="132" max="32767" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="0" attributes="0">
+              <Component id="jLabel1" min="-2" pref="22" max="-2" attributes="0"/>
+              <EmptySpace type="unrelated" max="-2" attributes="0"/>
+              <Component id="jRadioButton1" min="-2" max="-2" attributes="0"/>
+              <EmptySpace type="unrelated" max="-2" attributes="0"/>
+              <Component id="jRadioButton2" min="-2" max="-2" attributes="0"/>
+              <EmptySpace type="unrelated" max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="3" attributes="0">
+                  <Component id="jRadioButton3" alignment="3" min="-2" max="-2" attributes="0"/>
+                  <Component id="jComboBox1" alignment="3" min="-2" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace type="unrelated" max="-2" attributes="0"/>
+              <Component id="jTextField1" min="-2" max="-2" attributes="0"/>
+              <EmptySpace pref="163" max="32767" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Component class="javax.swing.JLabel" name="jLabel1">
+      <Properties>
+        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="ff" green="99" red="99" type="rgb"/>
+        </Property>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Tahoma" size="14" style="1"/>
+        </Property>
+        <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="ff" green="ff" red="ff" type="rgb"/>
+        </Property>
+        <Property name="text" type="java.lang.String" value=" Date Format"/>
+        <Property name="opaque" type="boolean" value="true"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JRadioButton" name="jRadioButton1">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Short Date(System)"/>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jRadioButton1ActionPerformed"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JRadioButton" name="jRadioButton2">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Long Date(System)"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JRadioButton" name="jRadioButton3">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Custom"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JComboBox" name="jComboBox1">
+      <Properties>
+        <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
+          <StringArray count="4">
+            <StringItem index="0" value="Item 1"/>
+            <StringItem index="1" value="Item 2"/>
+            <StringItem index="2" value="Item 3"/>
+            <StringItem index="3" value="Item 4"/>
+          </StringArray>
+        </Property>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JTextField" name="jTextField1">
+    </Component>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/DateFormatPanel.java b/src/in/raster/mayam/form/DateFormatPanel.java
new file mode 100644
index 0000000..2321dd0
--- /dev/null
+++ b/src/in/raster/mayam/form/DateFormatPanel.java
@@ -0,0 +1,138 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class DateFormatPanel extends javax.swing.JPanel {
+    
+    /** Creates new form DateFormatPanel */
+    public DateFormatPanel() {
+        initComponents();
+    }
+    
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        jLabel1 = new javax.swing.JLabel();
+        jRadioButton1 = new javax.swing.JRadioButton();
+        jRadioButton2 = new javax.swing.JRadioButton();
+        jRadioButton3 = new javax.swing.JRadioButton();
+        jComboBox1 = new javax.swing.JComboBox();
+        jTextField1 = new javax.swing.JTextField();
+
+        jLabel1.setBackground(new java.awt.Color(153, 153, 255));
+        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14));
+        jLabel1.setForeground(new java.awt.Color(255, 255, 255));
+        jLabel1.setText(" Date Format");
+        jLabel1.setOpaque(true);
+
+        jRadioButton1.setText("Short Date(System)");
+        jRadioButton1.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                jRadioButton1ActionPerformed(evt);
+            }
+        });
+
+        jRadioButton2.setText("Long Date(System)");
+
+        jRadioButton3.setText("Custom");
+
+        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
+        this.setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 411, Short.MAX_VALUE)
+            .add(layout.createSequentialGroup()
+                .add(22, 22, 22)
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                    .add(jRadioButton2)
+                    .add(jRadioButton1)
+                    .add(layout.createSequentialGroup()
+                        .add(jRadioButton3)
+                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
+                            .add(jTextField1)
+                            .add(jComboBox1, 0, 190, Short.MAX_VALUE))))
+                .addContainerGap(132, Short.MAX_VALUE))
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(layout.createSequentialGroup()
+                .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 22, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+                .add(jRadioButton1)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+                .add(jRadioButton2)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+                    .add(jRadioButton3)
+                    .add(jComboBox1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+                .add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addContainerGap(163, Short.MAX_VALUE))
+        );
+    }// </editor-fold>//GEN-END:initComponents
+
+    private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton1ActionPerformed
+        // TODO add your handling code here:
+    }//GEN-LAST:event_jRadioButton1ActionPerformed
+    
+    
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JComboBox jComboBox1;
+    private javax.swing.JLabel jLabel1;
+    private javax.swing.JRadioButton jRadioButton1;
+    private javax.swing.JRadioButton jRadioButton2;
+    private javax.swing.JRadioButton jRadioButton3;
+    private javax.swing.JTextField jTextField1;
+    // End of variables declaration//GEN-END:variables
+    
+}
diff --git a/src/in/raster/mayam/form/DicomListenerPanel.form b/src/in/raster/mayam/form/DicomListenerPanel.form
new file mode 100644
index 0000000..0567ebe
--- /dev/null
+++ b/src/in/raster/mayam/form/DicomListenerPanel.form
@@ -0,0 +1,83 @@
+<?xml version="1.1" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Component id="jLabel1" alignment="0" pref="446" max="32767" attributes="0"/>
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace min="-2" pref="155" max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Component id="jLabel3" alignment="0" min="-2" max="-2" attributes="0"/>
+                  <Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/>
+                  <Group type="103" alignment="0" groupAlignment="1" max="-2" attributes="0">
+                      <Component id="portText" alignment="0" max="32767" attributes="1"/>
+                      <Component id="aetitleText" alignment="0" min="-2" pref="131" max="-2" attributes="1"/>
+                  </Group>
+              </Group>
+              <EmptySpace pref="160" max="32767" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="0" attributes="0">
+              <Component id="jLabel1" min="-2" pref="24" max="-2" attributes="0"/>
+              <EmptySpace min="-2" pref="41" max="-2" attributes="0"/>
+              <Component id="jLabel2" min="-2" max="-2" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="aetitleText" min="-2" max="-2" attributes="0"/>
+              <EmptySpace min="-2" pref="29" max="-2" attributes="0"/>
+              <Component id="jLabel3" min="-2" max="-2" attributes="0"/>
+              <EmptySpace type="unrelated" max="-2" attributes="0"/>
+              <Component id="portText" min="-2" max="-2" attributes="0"/>
+              <EmptySpace pref="130" max="32767" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Component class="javax.swing.JLabel" name="jLabel1">
+      <Properties>
+        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="0" green="0" red="0" type="rgb"/>
+        </Property>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Courier New" size="16" style="1"/>
+        </Property>
+        <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="0" green="8a" red="ff" type="rgb"/>
+        </Property>
+        <Property name="horizontalAlignment" type="int" value="2"/>
+        <Property name="text" type="java.lang.String" value="DICOM Listener"/>
+        <Property name="opaque" type="boolean" value="true"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="jLabel2">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="AE Title"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JTextField" name="aetitleText">
+    </Component>
+    <Component class="javax.swing.JLabel" name="jLabel3">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Port"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JTextField" name="portText">
+    </Component>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/DicomListenerPanel.java b/src/in/raster/mayam/form/DicomListenerPanel.java
new file mode 100644
index 0000000..a37e5a6
--- /dev/null
+++ b/src/in/raster/mayam/form/DicomListenerPanel.java
@@ -0,0 +1,146 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form;
+
+import javax.swing.JTextField;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class DicomListenerPanel extends javax.swing.JPanel {
+    
+    /** Creates new form DicomListenerPanel */
+    public DicomListenerPanel() {
+        initComponents();
+
+    }
+
+    public JTextField getAetitleText() {
+        return aetitleText;
+    }
+
+    public void setAetitleText(JTextField aetitleText) {
+        this.aetitleText = aetitleText;
+    }
+
+    public JTextField getPortText() {
+        return portText;
+    }
+
+    public void setPortText(JTextField portText) {
+        this.portText = portText;
+    }
+    public void setAeTitle(String aet)
+    {
+        this.aetitleText.setText(aet);
+    }
+    public void setPort(String port)
+    {
+        this.portText.setText(port);
+    }
+    
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        jLabel1 = new javax.swing.JLabel();
+        jLabel2 = new javax.swing.JLabel();
+        aetitleText = new javax.swing.JTextField();
+        jLabel3 = new javax.swing.JLabel();
+        portText = new javax.swing.JTextField();
+
+        jLabel1.setBackground(new java.awt.Color(0, 0, 0));
+        jLabel1.setFont(new java.awt.Font("Courier New", 1, 16)); // NOI18N
+        jLabel1.setForeground(new java.awt.Color(255, 138, 0));
+        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
+        jLabel1.setText("DICOM Listener");
+        jLabel1.setOpaque(true);
+
+        jLabel2.setText("AE Title");
+
+        jLabel3.setText("Port");
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
+        this.setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 446, Short.MAX_VALUE)
+            .add(layout.createSequentialGroup()
+                .add(155, 155, 155)
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                    .add(jLabel3)
+                    .add(jLabel2)
+                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
+                        .add(org.jdesktop.layout.GroupLayout.LEADING, portText)
+                        .add(org.jdesktop.layout.GroupLayout.LEADING, aetitleText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 131, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
+                .addContainerGap(160, Short.MAX_VALUE))
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(layout.createSequentialGroup()
+                .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 24, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .add(41, 41, 41)
+                .add(jLabel2)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(aetitleText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .add(29, 29, 29)
+                .add(jLabel3)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+                .add(portText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addContainerGap(130, Short.MAX_VALUE))
+        );
+    }// </editor-fold>//GEN-END:initComponents
+    
+    
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JTextField aetitleText;
+    private javax.swing.JLabel jLabel1;
+    private javax.swing.JLabel jLabel2;
+    private javax.swing.JLabel jLabel3;
+    private javax.swing.JTextField portText;
+    // End of variables declaration//GEN-END:variables
+    
+}
diff --git a/src/in/raster/mayam/form/DicomTagsViewer.form b/src/in/raster/mayam/form/DicomTagsViewer.form
new file mode 100644
index 0000000..198d4a5
--- /dev/null
+++ b/src/in/raster/mayam/form/DicomTagsViewer.form
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
+  <Properties>
+    <Property name="title" type="java.lang.String" value="Meta Data"/>
+    <Property name="iconImage" type="java.awt.Image" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+      <Connection code="Toolkit.getDefaultToolkit().getImage(getClass().getResource("/in/raster/mayam/form/images/fav_mayam.png"))" type="code"/>
+    </Property>
+  </Properties>
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Component id="jButton1" alignment="1" min="-2" max="-2" attributes="0"/>
+                  <Component id="jScrollPane1" alignment="0" pref="749" max="32767" attributes="0"/>
+              </Group>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="1" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="jScrollPane1" pref="571" max="32767" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="jButton1" min="-2" max="-2" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Container class="javax.swing.JScrollPane" name="jScrollPane1">
+      <AuxValues>
+        <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+      </AuxValues>
+
+      <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+      <SubComponents>
+        <Component class="javax.swing.JTable" name="dicomTagTable">
+          <Properties>
+            <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
+              <Table columnCount="6" rowCount="4">
+                <Column editable="true" title="Tag" type="java.lang.Object"/>
+                <Column editable="true" title="Name" type="java.lang.Object"/>
+                <Column editable="true" title="VR" type="java.lang.Object"/>
+                <Column editable="true" title="Length" type="java.lang.Object"/>
+                <Column editable="true" title="VM" type="java.lang.Object"/>
+                <Column editable="true" title="Value" type="java.lang.Object"/>
+              </Table>
+            </Property>
+            <Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor">
+              <TableColumnModel selectionModel="0">
+                <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
+                  <Title/>
+                  <Editor/>
+                  <Renderer/>
+                </Column>
+                <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
+                  <Title/>
+                  <Editor/>
+                  <Renderer/>
+                </Column>
+                <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
+                  <Title/>
+                  <Editor/>
+                  <Renderer/>
+                </Column>
+                <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
+                  <Title/>
+                  <Editor/>
+                  <Renderer/>
+                </Column>
+                <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
+                  <Title/>
+                  <Editor/>
+                  <Renderer/>
+                </Column>
+                <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
+                  <Title/>
+                  <Editor/>
+                  <Renderer/>
+                </Column>
+              </TableColumnModel>
+            </Property>
+            <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor">
+              <TableHeader reorderingAllowed="true" resizingAllowed="true"/>
+            </Property>
+          </Properties>
+          <AuxValues>
+            <AuxValue name="JavaCodeGenerator_InitCodePost" type="java.lang.String" value="dicomTagTable.setDefaultRenderer(Object.class, new CellRenderer());"/>
+          </AuxValues>
+        </Component>
+      </SubComponents>
+    </Container>
+    <Component class="javax.swing.JButton" name="jButton1">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Close"/>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
+      </Events>
+    </Component>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/DicomTagsViewer.java b/src/in/raster/mayam/form/DicomTagsViewer.java
new file mode 100644
index 0000000..79ec222
--- /dev/null
+++ b/src/in/raster/mayam/form/DicomTagsViewer.java
@@ -0,0 +1,153 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form;
+
+import in.raster.mayam.util.DicomTags;
+import in.raster.mayam.model.table.TagsTableDataModel;
+import in.raster.mayam.model.table.renderer.CellRenderer;
+import java.awt.Toolkit;
+import java.util.ArrayList;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class DicomTagsViewer extends javax.swing.JFrame {
+
+    /** Creates new form DicomTagsViewer */
+    public DicomTagsViewer() {
+        initComponents();
+    }
+
+    public DicomTagsViewer(ArrayList<DicomTags> dcmTags) {
+        initComponents();
+        setDataModelOnTable(dcmTags);
+    }
+
+    public void setDataModelOnTable(ArrayList dcmTags) {
+        TagsTableDataModel dataModel = new TagsTableDataModel();
+        dataModel.setData(dcmTags);
+        dicomTagTable.setModel(dataModel);
+        dicomTagTable.repaint();
+    }
+
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    @SuppressWarnings("unchecked")
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        jScrollPane1 = new javax.swing.JScrollPane();
+        dicomTagTable = new javax.swing.JTable();
+        jButton1 = new javax.swing.JButton();
+
+        setTitle("Meta Data");
+        setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/in/raster/mayam/form/images/fav_mayam.png")));
+
+        dicomTagTable.setModel(new javax.swing.table.DefaultTableModel(
+            new Object [][] {
+                {null, null, null, null, null, null},
+                {null, null, null, null, null, null},
+                {null, null, null, null, null, null},
+                {null, null, null, null, null, null}
+            },
+            new String [] {
+                "Tag", "Name", "VR", "Length", "VM", "Value"
+            }
+        ));
+        dicomTagTable.setDefaultRenderer(Object.class, new CellRenderer());
+        jScrollPane1.setViewportView(dicomTagTable);
+
+        jButton1.setText("Close");
+        jButton1.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                jButton1ActionPerformed(evt);
+            }
+        });
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+        getContentPane().setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(layout.createSequentialGroup()
+                .addContainerGap()
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jButton1)
+                    .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 749, Short.MAX_VALUE))
+                .addContainerGap())
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+                .addContainerGap()
+                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 571, Short.MAX_VALUE)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(jButton1)
+                .addContainerGap())
+        );
+
+        pack();
+    }// </editor-fold>//GEN-END:initComponents
+
+    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
+        this.dispose();
+    }//GEN-LAST:event_jButton1ActionPerformed
+
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String args[]) {
+        java.awt.EventQueue.invokeLater(new Runnable() {
+
+            public void run() {
+                new DicomTagsViewer().setVisible(true);
+            }
+        });
+    }
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JTable dicomTagTable;
+    private javax.swing.JButton jButton1;
+    private javax.swing.JScrollPane jScrollPane1;
+    // End of variables declaration//GEN-END:variables
+}
diff --git a/src/in/raster/mayam/form/ExportingProgress.form b/src/in/raster/mayam/form/ExportingProgress.form
new file mode 100644
index 0000000..5b83716
--- /dev/null
+++ b/src/in/raster/mayam/form/ExportingProgress.form
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
+  <Properties>
+    <Property name="alwaysOnTop" type="boolean" value="true"/>
+    <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+      <Color blue="66" green="66" red="66" type="rgb"/>
+    </Property>
+    <Property name="resizable" type="boolean" value="false"/>
+    <Property name="undecorated" type="boolean" value="true"/>
+  </Properties>
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Component id="jLabel1" alignment="0" pref="306" max="32767" attributes="0"/>
+          <Group type="102" alignment="1" attributes="0">
+              <EmptySpace pref="88" max="32767" attributes="0"/>
+              <Component id="jProgressBar1" min="-2" max="-2" attributes="0"/>
+              <EmptySpace min="-2" pref="72" max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
+              <EmptySpace type="separate" max="-2" attributes="0"/>
+              <Component id="jProgressBar1" min="-2" max="-2" attributes="0"/>
+              <EmptySpace pref="35" max="32767" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Component class="javax.swing.JLabel" name="jLabel1">
+      <Properties>
+        <Property name="horizontalAlignment" type="int" value="0"/>
+        <Property name="text" type="java.lang.String" value="Exporting ..."/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JProgressBar" name="jProgressBar1">
+      <Properties>
+        <Property name="value" type="int" value="1"/>
+      </Properties>
+    </Component>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/ExportingProgress.java b/src/in/raster/mayam/form/ExportingProgress.java
new file mode 100644
index 0000000..19295af
--- /dev/null
+++ b/src/in/raster/mayam/form/ExportingProgress.java
@@ -0,0 +1,127 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class ExportingProgress extends javax.swing.JFrame  {
+    
+    /** Creates new form SendReceiveFrame */
+    public ExportingProgress() {
+        initComponents();    
+    }
+    
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        jLabel1 = new javax.swing.JLabel();
+        jProgressBar1 = new javax.swing.JProgressBar();
+
+        setAlwaysOnTop(true);
+        setBackground(new java.awt.Color(102, 102, 102));
+        setResizable(false);
+        setUndecorated(true);
+
+        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+        jLabel1.setText("Exporting ...");
+
+        jProgressBar1.setValue(1);
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+        getContentPane().setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 306, Short.MAX_VALUE)
+            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+                .addContainerGap(88, Short.MAX_VALUE)
+                .add(jProgressBar1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .add(72, 72, 72))
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(layout.createSequentialGroup()
+                .addContainerGap()
+                .add(jLabel1)
+                .add(18, 18, 18)
+                .add(jProgressBar1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addContainerGap(35, Short.MAX_VALUE))
+        );
+
+        pack();
+    }// </editor-fold>//GEN-END:initComponents
+    public void updateBar(int value)
+    {
+        jProgressBar1.setValue(value);
+        jProgressBar1.repaint();
+
+    }
+    public void setProgressMaximum(int max)
+    {
+        jProgressBar1.setMinimum(1);
+        jProgressBar1.setMaximum(max);
+
+    }
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String args[]) {
+        java.awt.EventQueue.invokeLater(new Runnable() {
+            public void run() {
+                new ExportingProgress().setVisible(true);
+            }
+        });
+    }
+    
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JLabel jLabel1;
+    private javax.swing.JProgressBar jProgressBar1;
+    // End of variables declaration//GEN-END:variables
+
+   
+    
+}
diff --git a/src/in/raster/mayam/form/ImagePanel.form b/src/in/raster/mayam/form/ImagePanel.form
new file mode 100644
index 0000000..10b6e75
--- /dev/null
+++ b/src/in/raster/mayam/form/ImagePanel.form
@@ -0,0 +1,43 @@
+<?xml version="1.1" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+  <NonVisualComponents>
+    <Container class="javax.swing.JPopupMenu" name="jPopupMenu1">
+
+      <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
+        <Property name="useNullLayout" type="boolean" value="true"/>
+      </Layout>
+    </Container>
+  </NonVisualComponents>
+  <Properties>
+    <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+      <Color blue="0" green="0" red="0" type="rgb"/>
+    </Property>
+    <Property name="componentPopupMenu" type="javax.swing.JPopupMenu" editor="org.netbeans.modules.form.ComponentChooserEditor">
+      <ComponentRef name="jPopupMenu1"/>
+    </Property>
+    <Property name="doubleBuffered" type="boolean" value="false"/>
+    <Property name="focusCycleRoot" type="boolean" value="true"/>
+    <Property name="opaque" type="boolean" value="false"/>
+    <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+      <Dimension value="[512, 512]"/>
+    </Property>
+  </Properties>
+  <Events>
+    <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="formMouseClicked"/>
+  </Events>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+    <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,-112"/>
+  </AuxValues>
+
+  <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
+</Form>
diff --git a/src/in/raster/mayam/form/ImagePanel.java b/src/in/raster/mayam/form/ImagePanel.java
new file mode 100644
index 0000000..c0abe2e
--- /dev/null
+++ b/src/in/raster/mayam/form/ImagePanel.java
@@ -0,0 +1,2444 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form;
+
+import com.sun.pdfview.PDFFile;
+import com.sun.pdfview.PDFPage;
+import com.sun.pdfview.PagePanel;
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.delegate.ImageOrientation;
+import in.raster.mayam.delegate.LocalizerDelegate;
+import in.raster.mayam.delegate.SeriesChooserDelegate;
+import in.raster.mayam.delegate.SynchronizationDelegate;
+import in.raster.mayam.model.Instance;
+import in.raster.mayam.model.ScoutLineInfoModel;
+import in.raster.mayam.model.Series;
+import in.raster.mayam.model.Study;
+import in.raster.mayam.param.TextOverlayParam;
+import java.awt.event.ActionEvent;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseWheelEvent;
+import java.io.File;
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.dcm4che.dict.Tags;
+import org.dcm4che2.data.BasicDicomObject;
+import org.dcm4che2.data.DicomObject;
+import org.dcm4che2.io.DicomInputStream;
+import org.dcm4che.image.ColorModelFactory;
+import org.dcm4che.image.ColorModelParam;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.Rectangle;
+import java.awt.RenderingHints;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionListener;
+import java.awt.event.MouseWheelListener;
+import java.awt.image.BufferedImage;
+import java.awt.image.BufferedImageOp;
+import java.awt.image.ByteLookupTable;
+import java.awt.image.LookupOp;
+import java.awt.image.ColorModel;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Iterator;
+import javax.imageio.ImageIO;
+import javax.imageio.ImageReader;
+import javax.imageio.stream.ImageInputStream;
+import javax.swing.ImageIcon;
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+import javax.swing.JPopupMenu;
+import org.dcm4che.data.Dataset;
+import org.dcm4che.imageio.plugins.DcmMetadata;
+import org.dcm4che2.data.Tag;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5 
+ *
+ */
+public class ImagePanel extends javax.swing.JPanel implements MouseWheelListener,
+        MouseMotionListener, MouseListener {
+
+    private Canvas canvas;
+    //Image manipulation Flags
+    public boolean isRotate = false;
+    public boolean flipHorizontalFlag = false;
+    public boolean flipVerticalFlag = false;
+    private boolean invertFlag = false;
+    private boolean newBufferedImage = false;
+    private boolean scaleFlag = false;
+    private boolean firstTime = true;
+    private boolean mousePressed = false;
+    private static boolean widowingFlag = false;
+    private static boolean probeFlag;
+    private double scaleFactor = 1;
+    public int rotateRightAngle = 0;
+    private int rotateLeftAngle = 0;
+    public static String tool = "windowing";
+    //Windowing, Hu related variables
+    private int windowLevel;
+    private int windowWidth;
+    private int WC;
+    private int WW;
+    private String rescaleSlope;
+    private String rescaleIntercept;
+    private double pixelSpacingX;
+    private double pixelSpacingY;
+    //Unique id variables
+    private String studyUID;
+    private String seriesUID;
+    private String instanceUID;
+    private String seriesNo;
+    private String modality;
+    private String studyDesc;
+    //ImageIO variables
+    private Image loadedImage;
+    private BufferedImage currentbufferedimage;
+    private BufferedImage image;
+    private ImageIcon imageIcon;
+    private ImageInputStream iis;
+    private Iterator iter;
+    private ImageReader reader;
+    private Dataset dataset;
+    //Mouse pointer variables
+    private int mouseLocX1;
+    private int mouseLocX2;
+    private int mouseLocY1;
+    private int mouseLocY2;
+    //ColorModel variables
+    private ColorModelParam cmParam = null;
+    private static final ColorModelFactory cmFactory = ColorModelFactory.getInstance();
+    private ColorModel cm = null;
+    private int windowingMultiplier = 1;
+    private int[] pixelValueArray;
+    private int pixelValue;
+    private String hu = "";
+    private int originalWidth;
+    private int originalHeight;
+    private String dicomFileUrl;
+    //Multiframe image related variables
+    private int nFrames = 0;
+    private int currentFrame = 0;
+    private boolean mulitiFrame = false;
+    private int currentInstanceNo = 0;
+    private int totalInstance;
+    boolean canStart = true;
+    private ArrayList<Instance> instanceArray = null;
+    //TextOverlay 
+    private TextOverlayParam textOverlayParam;
+    private String[] aspectRatio;
+    private float floatAspectRatio;
+    //Scout Param
+    private String frameOfReferenceUID;
+    private String imagePosition;
+    private String imageOrientation;
+    private String[] imageType;
+    private String referencedSOPInstanceUID = "";
+    private String pixelSpacing;
+    private int row;
+    private int column;
+    private boolean isLocalizer = false;
+    private static boolean displayScout = false;
+    private int scoutLine1X1;
+    private int scoutLine1Y1;
+    private int scoutLine1X2;
+    private int scoutLine1Y2;
+    private int scoutLine2X1;
+    private int scoutLine2Y1;
+    private int scoutLine2X2;
+    private int scoutLine2Y2;
+    private String orientationLabel = "";
+    private int boundaryLine1X1;
+    private int boundaryLine1Y1;
+    private int boundaryLine1X2;
+    private int boundaryLine1Y2;
+    private int boundaryLine2X1;
+    private int boundaryLine2Y1;
+    private int boundaryLine2X2;
+    private int boundaryLine2Y2;
+    private int thumbWidth = 512;
+    private int thumbHeight = 512;
+    private int maxHeight = 512;
+    private int maxWidth = 512;
+    private double thumbRatio;
+    private int startX = 0;
+    private int startY = 0;
+    private double currentScaleFactor = 1;
+    private double initialPixelSpacingX;
+    private double initialPixelSpacingY;
+    private int axis1LeftX;
+    private int axis1LeftY;
+    private int axis1RightX;
+    private int axis1RightY;
+    private int axis1BottomX;
+    private int axis1BottomY;
+    private int axis1TopX;
+    private int axis1TopY;
+    private int axis2LeftX;
+    private int axis2LeftY;
+    private int axis2RightX;
+    private int axis2RightY;
+    private int axis2BottomX;
+    private int axis2BottomY;
+    private int axis2TopX;
+    private int axis2TopY;
+    private int axisLeftX;
+    private int axisLeftY;
+    private int axisRightX;
+    private int axisRightY;
+    private int axisBottomX;
+    private int axisBottomY;
+    private int axisTopX;
+    private int axisTopY;
+    private int instanceNumber;
+    private String sliceLocation;
+    public static boolean synchornizeTiles = false;
+    public int syncStartInstance;
+    private PDFFile curFile = null;
+    public PagePanel page = null;
+    private int curpage = -1;
+    private boolean isEncapsulatedDocument = false;
+
+    public ImagePanel() {
+        initComponents();
+    }
+
+    /**
+     * Constructs the imagepanel by passing file url and outer canvas
+     * @param dicomFileUrl
+     * @param canvas
+     */
+    public ImagePanel(String dicomFileUrl, Canvas canvas) {
+        this.dicomFileUrl = dicomFileUrl;
+        this.canvas = canvas;
+        readDicomFile(new File(dicomFileUrl));
+        retriveTagInfo();
+        initComponents();
+        addlisteners();
+        retrieveInstanceInformation();
+        retrieveScoutParam();
+        setTotalInstacne();
+        retriveTextOverlayParam();
+        // designContext();
+    }
+
+    /**
+     * Constructs the imagepanel by passing file url parameter
+     * @param dicomFileUrl
+     */
+    public ImagePanel(String dicomFileUrl) {
+        readDicomFile(new File(dicomFileUrl));
+        retriveTagInfo();
+        initComponents();
+        addlisteners();
+        retrieveInstanceInformation();
+        retrieveScoutParam();
+        setTotalInstacne();
+        retriveTextOverlayParam();
+
+    }
+
+    /**
+     * This routine used to retrive the text overlay related information from the dataset
+     */
+    private void retriveTextOverlayParam() {
+        textOverlayParam = new TextOverlayParam();
+        textOverlayParam.setPatientName(dataset.getString(Tags.PatientName));
+        textOverlayParam.setPatientID(dataset.getString(Tags.PatientID));
+        textOverlayParam.setSex(dataset.getString(Tags.PatientSex));
+        textOverlayParam.setStudyDate(dataset.getString(Tags.StudyDate));
+        textOverlayParam.setStudyDescription(dataset.getString(Tags.StudyDescription) != null ? dataset.getString(Tags.StudyDescription) : "");
+        textOverlayParam.setSeriesDescription(dataset.getString(Tags.SeriesDescription) != null ? dataset.getString(Tags.SeriesDescription) : "");
+        textOverlayParam.setInstanceNumber(dataset.getString(Tags.InstanceNumber) != null ? dataset.getString(Tags.InstanceNumber) : "");
+        textOverlayParam.setBodyPartExamined(dataset.getString(Tags.BodyPartExamined));
+        textOverlayParam.setSlicePosition(dataset.getString(Tags.SliceLocation));
+        textOverlayParam.setPatientPosition(dataset.getString(Tags.PatientPosition));
+        textOverlayParam.setInstitutionName(dataset.getString(Tags.InstitutionName));
+        textOverlayParam.setWindowLevel(dataset.getString(Tags.WindowCenter) != null ? dataset.getString(Tags.WindowCenter) : "");
+        textOverlayParam.setWindowWidth(dataset.getString(Tags.WindowWidth) != null ? dataset.getString(Tags.WindowWidth) : "");
+        textOverlayParam.setCurrentInstance(currentInstanceNo);
+        textOverlayParam.setTotalInstance(Integer.toString(totalInstance));
+
+    }
+
+    /**
+     * This routine used to retrive some other tag information from the dataset
+     */
+    private void retriveTagInfo() {
+        studyUID = dataset.getString(Tags.StudyInstanceUID);
+        seriesUID = dataset.getString(Tags.SeriesInstanceUID);
+        instanceUID = dataset.getString(Tags.SOPInstanceUID);
+        modality = dataset.getString(Tags.Modality);
+        seriesNo = dataset.getString(Tags.SeriesNumber);
+        studyDesc = dataset.getString(Tags.StudyDescription);
+        rescaleSlope = dataset.getString(Tags.RescaleSlope);
+        rescaleIntercept = dataset.getString(Tags.RescaleIntercept);
+        aspectRatio = dataset.getStrings(Tags.PixelAspectRatio);
+        sliceLocation = (dataset.getString(Tag.SliceLocation) != null) ? dataset.getString(Tag.SliceLocation) : "";
+        try {
+            currentInstanceNo = Integer.parseInt(dataset.getString(Tags.InstanceNumber));
+        } catch (NumberFormatException e) {
+            System.out.println("Instance Number format error ");
+            currentInstanceNo = 1;
+        } catch (NullPointerException e) {
+            System.out.println("Instance Number is null, set to 1");
+            currentInstanceNo = 1;
+        }
+    }
+
+    private void retrieveScoutParam() {
+        try {
+            frameOfReferenceUID = dataset.getString(Tags.FrameOfReferenceUID) != null ? dataset.getString(Tags.FrameOfReferenceUID) : "";
+            imagePosition = dataset.getString(Tags.ImagePosition, 0) != null ? dataset.getString(Tags.ImagePosition, 0) + "\\" + dataset.getString(Tags.ImagePosition, 1) + "\\" + dataset.getString(Tags.ImagePosition, 2) : null;
+            imageOrientation = dataset.getString(Tags.ImageOrientation) != null ? dataset.getString(Tags.ImageOrientation, 0) + "\\" + dataset.getString(Tags.ImageOrientation, 1) + "\\" + dataset.getString(Tags.ImageOrientation, 2) + "\\" + dataset.getString(Tags.ImageOrientation, 3) + "\\" + dataset.getString(Tags.ImageOrientation, 4) + "\\" + dataset.getString(Tags.ImageOrientation, 5) : null;
+            imageType = dataset.getStrings(Tags.ImageType) != null ? dataset.getStrings(Tags.ImageType) : null;
+            pixelSpacing = dataset.getString(Tags.PixelSpacing) != null ? dataset.getString(Tags.PixelSpacing, 0) + "\\" + dataset.getString(Tags.PixelSpacing, 1) : null;
+            row = dataset.getString(Tags.Rows) != null ? Integer.parseInt(dataset.getString(Tags.Rows)) : 0;
+            column = dataset.getString(Tags.Columns) != null ? Integer.parseInt(dataset.getString(Tags.Columns)) : 0;
+            Dataset referencedImageSequence = dataset.getItem(Tag.ReferencedImageSequence) != null ? dataset.getItem(Tag.ReferencedImageSequence) : null;
+            if (imageType != null) {
+                if (imageType.length >= 3 && imageType[2].equalsIgnoreCase("LOCALIZER")) {
+                    isLocalizer = true;
+                } else {
+                    if (referencedImageSequence != null) {
+                        referencedSOPInstanceUID = referencedImageSequence.getString(Tag.ReferencedSOPInstanceUID);
+                    }
+                    isLocalizer = false;
+                }
+            }
+            findOrientation();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+    }
+
+    /**
+     * This routine used to retrive the instance related information
+     */
+    private void retrieveInstanceInformation() {
+
+        String inverted = dataset.getString(Tags.PhotometricInterpretation, null);
+        if ("MONOCHROME1".equals(inverted) || "MONOCHROME2".equals(inverted)) {
+            cmParam = cmFactory.makeParam(dataset);
+            int bits = dataset.getInt(Tags.BitsStored, 8);
+            int size = 1 << bits;
+            int signed = dataset.getInt(Tags.PixelRepresentation, 0);
+            int min = dataset.getInt(Tags.SmallestImagePixelValue,
+                    signed == 0 ? 0 : -(size >> 1));
+            int max = dataset.getInt(Tags.LargestImagePixelValue,
+                    signed == 0 ? size - 1 : (size >> 1) - 1);
+            int c = (int) cmParam.toMeasureValue((min + max) >> 1);
+            int cMin = (int) cmParam.toMeasureValue(min);
+            int cMax = (int) cmParam.toMeasureValue(max - 1);
+            int wMax = cMax - cMin;
+            int w = wMax;
+            try {
+                initialPixelSpacingY = pixelSpacingY = Double.parseDouble(dataset.getString(
+                        Tags.PixelSpacing, 0));
+                initialPixelSpacingX = pixelSpacingX = Double.parseDouble(dataset.getString(
+                        Tags.PixelSpacing, 1));
+
+            } catch (NullPointerException e) {
+                initialPixelSpacingX = 0;
+                initialPixelSpacingY = 0;
+            }
+            int nWindow = cmParam.getNumberOfWindows();
+            if (nWindow > 0) {
+                WC = windowLevel = c = (int) cmParam.getWindowCenter(0);
+                WW = windowWidth = w = (int) cmParam.getWindowWidth(0);
+            } else {
+                WW = windowWidth = w = (int) Math.pow(2, bits);
+                WC = windowLevel = c = (int) w / 2;
+            }
+        }
+    }
+
+    /**
+     *
+     * @return textoverlayParam-It return the text overlay param
+     */
+    public TextOverlayParam getTextOverlayParam() {
+        return textOverlayParam;
+    }
+
+    /**
+     *
+     * @param textOverlayParam-It sets the textOverlayParam
+     */
+    public void setTextOverlayParam(TextOverlayParam textOverlayParam) {
+        this.textOverlayParam = textOverlayParam;
+    }
+
+    /**
+     * This routine used to check the multiframe status
+     * @return
+     */
+    public boolean isMulitiFrame() {
+        return mulitiFrame;
+    }
+
+    /**
+     * This routine used to set the multiframe status
+     * @param mulitiFrame
+     */
+    public void setMulitiFrame(boolean mulitiFrame) {
+        this.mulitiFrame = mulitiFrame;
+    }
+
+    /**
+     * This routine used to return the dicom file url
+     * @return dicomFileUrl-It returns the dicom file url of the current image
+     */
+    public String getDicomFileUrl() {
+        return dicomFileUrl;
+    }
+
+    public int getnFrames() {
+        return nFrames;
+    }
+
+    public void setnFrames(int nFrames) {
+        this.nFrames = nFrames;
+    }
+
+    /**
+     * This routine used to set the dicom file url for the current image box
+     * @param dicomFileUrl-dicom file url
+     */
+    public void setDicomFileUrl(String dicomFileUrl) {
+        this.dicomFileUrl = dicomFileUrl;
+    }
+
+    /**
+     * This routine used to set the flag for panning
+     */
+    public void doPan() {
+        if (tool.equalsIgnoreCase("panning")) {
+            tool = "";
+        } else {
+            tool = "panning";
+        }
+    }
+
+    /**
+     * Tdhis routine used to return the canvas of the image box
+     * @return
+     */
+    public Canvas getCanvas() {
+        return canvas;
+    }
+
+    /**
+     * This routine used to get the study uid value for the current image box
+     * @return
+     */
+    public String getStudyUID() {
+        return studyUID;
+    }
+
+    /**
+     * This routine used to set teh study uid value for the current image box
+     * @param studyUID
+     */
+    public void setStudyUID(String studyUID) {
+        this.studyUID = studyUID;
+    }
+
+    /**
+     * This routine used to read the dicom file
+     * @param selFile-This the file to be read
+     */
+    private void readDicomFile(File selFile) {
+        try {
+            iis = ImageIO.createImageInputStream(selFile);
+            iter = ImageIO.getImageReadersByFormatName("DICOM");
+            reader = (ImageReader) iter.next();
+            this.reader.setInput(iis, false);
+            dataset = ((DcmMetadata) reader.getStreamMetadata()).getDataset();
+            try {
+                if (reader.getNumImages(true) > 0) {
+                    currentbufferedimage = reader.read(0);
+                    floatAspectRatio = reader.getAspectRatio(0);
+                }
+                nFrames = reader.getNumImages(true);
+                if (nFrames - 1 > 0) {
+                    mulitiFrame = true;
+                    this.totalInstance = nFrames;
+                }
+                if (reader.getNumImages(true) > 0) {
+                    imageIcon = new ImageIcon();
+                    imageIcon.setImage(currentbufferedimage);
+                    loadedImage = imageIcon.getImage();
+                    image = new BufferedImage(loadedImage.getWidth(null), loadedImage.getHeight(null), BufferedImage.TYPE_INT_RGB);
+                    Graphics2D g2 = image.createGraphics();
+                    g2.drawImage(loadedImage, 0, 0, null);
+                }
+                if (dataset.getString(Tags.SOPClassUID).equalsIgnoreCase("1.2.840.10008.5.1.4.1.1.104.1")) {
+                    readDicom(selFile);
+                }
+                repaint();
+            } catch (RuntimeException e) {
+                e.printStackTrace();
+            }
+        } catch (Exception e) {
+            System.out.println("io exception");
+        }
+
+    }
+
+    public void readDicom(File file) {
+        try {
+            DicomInputStream din = new DicomInputStream(new File(file.getAbsolutePath()));
+            DicomObject dcmObject = din.readDicomObject();
+            byte[] buf = dcmObject.getBytes(Tags.EncapsulatedDocument);
+            ByteBuffer byteBuffer = ByteBuffer.wrap(buf);
+            openPDFByteBuffer(byteBuffer, null, null);
+            isEncapsulatedDocument = true;
+        } catch (IOException ex) {
+            Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+
+    private void openPDFByteBuffer(ByteBuffer buf, String path, String name) {
+        PDFFile newfile = null;
+        try {
+            newfile = new PDFFile(buf);
+        } catch (IOException ioe) {
+            return;
+        }
+        this.curFile = newfile;
+        forceGotoPage(0);
+    }
+    PDFPage pg = null;
+
+    public void forceGotoPage(int pagenum) {
+        if (pagenum <= 0) {
+            pagenum = 0;
+        } else if (pagenum >= curFile.getNumPages()) {
+            pagenum = curFile.getNumPages() - 1;
+        }
+        totalInstance = curFile.getNumPages();
+        curpage = pagenum;
+        pg = curFile.getPage(pagenum + 1);
+        Rectangle rect = new Rectangle(0, 0,
+                (int) pg.getBBox().getWidth(),
+                (int) pg.getBBox().getHeight());
+
+        //generate the image
+        Image current = pg.getImage(
+                rect.width, rect.height, //width & height
+                rect, // clip rect
+                null, // null for the ImageObserver
+                true, // fill background with white
+                true // block until drawing is done
+                );
+        imageIcon = new ImageIcon();
+        imageIcon.setImage(current);
+        loadedImage = imageIcon.getImage();
+        currentbufferedimage = new BufferedImage(loadedImage.getWidth(null), loadedImage.getHeight(null), BufferedImage.TYPE_INT_RGB);
+        Graphics2D g2 = currentbufferedimage.createGraphics();
+        g2.drawImage(loadedImage, 0, 0, null);
+        image = null;
+    }
+    public ArrayList createPDFArray() {
+        ArrayList<BufferedImage> temp = new ArrayList<BufferedImage>();
+        for (int pagenum = 0; pagenum < curFile.getNumPages(); pagenum++) {
+            PDFPage pdfPage = curFile.getPage(pagenum + 1);
+            Rectangle rect = new Rectangle(0, 0,
+                    (int) pdfPage.getBBox().getWidth(),
+                    (int) pdfPage.getBBox().getHeight());
+
+            //generate the image
+            Image current = pdfPage.getImage(
+                    rect.width, rect.height, //width & height
+                    rect, // clip rect
+                    null, // null for the ImageObserver
+                    true, // fill background with white
+                    true // block until drawing is done
+                    );
+            imageIcon = new ImageIcon();
+            imageIcon.setImage(current);
+            Image tempImage = imageIcon.getImage();
+            BufferedImage tempBufferedImage = new BufferedImage(tempImage.getWidth(null), tempImage.getHeight(null), BufferedImage.TYPE_INT_RGB);
+            Graphics2D g2 = tempBufferedImage.createGraphics();
+            g2.drawImage(tempImage, 0, 0, null);
+            temp.add(tempBufferedImage);
+        }
+        return temp;
+    }
+
+    public boolean isIsEncapsulatedDocument() {
+        return isEncapsulatedDocument;
+    }
+
+    private void calculateResolutionForPdfDicom(double imageWidthParam, double imageHeightParam) {
+        thumbHeight = 512;
+        thumbWidth = 512;
+        thumbRatio = thumbWidth / thumbHeight;
+        double imageWidth = imageWidthParam;
+        double imageHeight = imageHeightParam;
+        double imageRatio = (double) imageWidth / (double) imageHeight;
+        if (thumbRatio < imageRatio) {
+            thumbHeight = (int) Math.round((thumbWidth + 0.00f) / imageRatio);
+        } else {
+            thumbWidth = (int) Math.round((thumbHeight + 0.00f) * imageRatio);
+        }
+        startX = (maxWidth - thumbWidth) / 2;
+        startY = (maxHeight - thumbHeight) / 2;
+    }
+
+    public void showNextFrame() {
+        currentFrame++;
+        if (currentFrame == nFrames) {
+            currentFrame = 0;
+        }
+        currentInstanceNo = currentFrame;
+        totalInstance = nFrames;
+        try {
+            currentbufferedimage = reader.read(currentFrame);
+            convertToRGBImage();
+            repaint();
+            this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setCurrentInstance(this.currentInstanceNo);
+            this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setTotalInstance(Integer.toString(this.totalInstance));
+            Instance instance = instanceArray.get(0);
+            this.getCanvas().getLayeredCanvas().annotationPanel.setAnnotation(instance.getMultiframeAnnotation(currentInstanceNo));
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            Logger.getLogger(ImagePanel.class.getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+
+    public void showPreviousFrame() {
+        if (currentFrame == 0) {
+            currentFrame = nFrames;
+        }
+        currentFrame--;
+        currentInstanceNo = currentFrame;
+        totalInstance = nFrames;
+        try {
+            currentbufferedimage = reader.read(currentFrame);
+            convertToRGBImage();
+            repaint();
+            this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setCurrentInstance(this.currentInstanceNo);
+            this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setTotalInstance(Integer.toString(this.totalInstance));
+            Instance instance = instanceArray.get(0);
+            this.getCanvas().getLayeredCanvas().annotationPanel.setAnnotation(instance.getMultiframeAnnotation(currentInstanceNo));
+        } catch (IOException ex) {
+            ex.printStackTrace();
+            Logger.getLogger(ImagePanel.class.getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+
+    /**
+     * This routine used to set the image of this image box
+     * @param newImg
+     */
+    public void setImage(BufferedImage newImg) {
+        try {
+            newBufferedImage = true;
+            currentbufferedimage = newImg;
+            windowChanged(this.windowLevel, this.windowWidth);
+        } catch (RuntimeException e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * This routine used to retrive the buffered image of the current image box
+     * @return
+     */
+    public BufferedImage getCurrentbufferedimage() {
+        return currentbufferedimage;
+    }
+
+    /**
+     * This routine used to get the instance uid value for the current image box
+     * @return
+     */
+    public String getInstanceUID() {
+        return instanceUID;
+    }
+
+    /**
+     * This routine used to get the series instance uid value for the current image box
+     * @return
+     */
+    public String getSeriesUID() {
+        return seriesUID;
+    }
+
+    /**
+     * This routine used to apply the filter to the image box
+     * @param op
+     */
+    private void filter(BufferedImageOp op) {
+        if (image != null) {
+            BufferedImage filteredImage = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_RGB);
+            op.filter(image, filteredImage);
+            image = filteredImage;
+            repaint();
+        }
+    }
+    /*
+    private void convolve(float[] elements) {
+    Kernel kernel = new Kernel(3, 3, elements);
+    ConvolveOp op = new ConvolveOp(kernel);
+    filter(op);*
+    }
+
+    public void blur() {
+    float weight = 1.0f / 9.0f;
+    float[] elements = new float[9];
+    for (int i = 0; i < 9; i++) {
+    elements[i] = weight;
+    }
+    convolve(elements);
+    }
+
+    public void sharpen() {
+    float[] elements = {0.0f, -1.0f, 0.0f, -1.0f, 5.f, -1.0f, 0.0f, -1.0f,
+    0.0f};
+    convolve(elements);
+    }
+
+    public void edgeDetect() {
+    float[] elements = {0.0f, -1.0f, 0.0f, -1.0f, 4.f, -1.0f, 0.0f, -1.0f,
+    0.0f};
+    convolve(elements);
+    }
+
+    public void brighten() {
+    float a = 1.5f;
+    float b = -20.0f;
+    RescaleOp op = new RescaleOp(a, b, null);
+    filter(op);
+    }
+     */
+
+    /**
+     * This routine will be invoked to invert the image box
+     */
+    public void negative() {
+        convertToRGBImage();
+        if (invertFlag) {
+
+            invertFlag = false;
+            repaint();
+        } else {
+            byte negative[] = new byte[256];
+            for (int i = 0; i < 256; i++) {
+                negative[i] = (byte) (255 - i);
+            }
+            ByteLookupTable table = new ByteLookupTable(0, negative);
+            LookupOp op = new LookupOp(table, null);
+            filter(op);
+            invertFlag = true;
+        }
+        widowingFlag = false;
+        newBufferedImage = false;
+        this.getCanvas().repaint();
+
+    }
+
+    /**
+     * This routine used to rotate the image box ninety degree right
+     */
+    public void rotateRight() {
+        isRotate = true;
+        rotateRightAngle = rotateRightAngle + 90;
+        if (rotateRightAngle == 360) {
+            rotateRightAngle = 0;
+            rotateLeftAngle = 0;
+        } else if (rotateRightAngle == 90) {
+            rotateLeftAngle = -270;
+        } else if (rotateRightAngle == 180) {
+            rotateLeftAngle = -180;
+        } else if (rotateRightAngle == 270) {
+            rotateLeftAngle = -90;
+        }
+        widowingFlag = false;
+        newBufferedImage = false;
+        this.repaint();
+        repaintTextOverlay();
+    }
+
+    /**
+     * This routine used to rotate the image box ninety degree left
+     */
+    public void rotateLeft() {
+        isRotate = true;
+        rotateLeftAngle = rotateLeftAngle - 90;
+        if (rotateLeftAngle == -360) {
+            rotateRightAngle = 0;
+            rotateLeftAngle = 0;
+        } else if (rotateLeftAngle == -90) {
+            rotateRightAngle = 270;
+        } else if (rotateLeftAngle == -180) {
+            rotateRightAngle = 180;
+        } else if (rotateLeftAngle == -270) {
+            rotateRightAngle = 90;
+        }
+        widowingFlag = false;
+        newBufferedImage = false;
+        this.repaint();
+        repaintTextOverlay();
+
+    }
+    /*
+    static AffineTransform mirrorHorizontalTransform;
+
+    static { // Create and initialize the AffineTransform
+    mirrorHorizontalTransform = AffineTransform.getTranslateInstance(512, 0);
+    mirrorHorizontalTransform.scale(-1.0, 1.0); // flip horizontally
+    }
+    static AffineTransform mirrorVerticalTransform;
+
+    static { // Create and initialize the AffineTransform
+    mirrorVerticalTransform = AffineTransform.getTranslateInstance(0, 512);
+    mirrorVerticalTransform.scale(1.0, -1.0); // flip horizontally
+    }
+     */
+
+    /**
+     * This routine flips the image box horizontally
+     */
+    public void flipHorizontal() {
+        if ((rotateRightAngle == 90) || (rotateRightAngle == 270) || (rotateLeftAngle == -90) || (rotateLeftAngle == -270)) {
+            flipV();
+        } else {
+            flipH();
+        }
+    }
+
+    /**
+     * This routine flips the image box vertically
+     */
+    public void flipVertical() {
+        if ((rotateRightAngle == 90) || (rotateRightAngle == 270) || (rotateLeftAngle == -90) || (rotateLeftAngle == -270)) {
+            flipH();
+        } else {
+            flipV();
+        }
+    }
+
+    private void flipV() {
+        if (flipVerticalFlag) {
+            flipVerticalFlag = false;
+        } else {
+            flipVerticalFlag = true;
+        }
+        widowingFlag = false;
+        newBufferedImage = false;
+
+    }
+
+    private void flipH() {
+        if (flipHorizontalFlag) {
+            flipHorizontalFlag = false;
+        } else {
+            flipHorizontalFlag = true;
+        }
+        widowingFlag = false;
+        newBufferedImage = false;
+    }
+
+    /**
+     * This routine used to reset the image box with the original buffered image
+     */
+    public void reset() {
+        this.getCanvas().getLayeredCanvas().annotationPanel.resetAnnotation();
+        windowLevel = (int) WC;
+        windowWidth = (int) WW;
+        windowChanged(windowLevel, windowWidth);
+        firstTime = true;
+        scaleFactor = 1;
+        scaleProcess();
+        this.getCanvas().getLayeredCanvas().annotationPanel.scaleProcess();
+        invertFlag = false;
+        flipHorizontalFlag = false;
+        flipVerticalFlag = false;
+        isRotate = false;
+        rotateLeftAngle = 0;
+        rotateRightAngle = 0;
+        currentInstanceNo = 0;
+        canvas.setBackground(Color.BLACK);
+        canvas.setForeground(Color.WHITE);
+        repaint();
+        if (!firstTime) {
+            repaint();
+        }
+        selectFirstInstance();
+        this.getCanvas().getLayeredCanvas().annotationPanel.resetAnnotaionTools();
+        this.tool = "windowing";
+    }
+
+    public void resizeHandler() {
+        repaint();
+        centerImage();
+        this.canvas.setSelection();
+    }
+
+    /**
+     * This routine used to reset the windowing values of the current image box
+     */
+    public void resetWindowing() {
+        windowLevel = (int) WC;
+        windowWidth = (int) WW;
+        windowChanged(windowLevel, windowWidth);
+    }
+
+    /**
+     * This routine used to select the first instance of series
+     */
+    public void selectFirstInstance() {
+        Iterator<Study> studyItr = MainScreen.studyList.iterator();
+        while (studyItr.hasNext()) {
+            Study study = studyItr.next();
+            if (study.getStudyInstanceUID().equalsIgnoreCase(ApplicationContext.imgPanel.getStudyUID())) {
+                ArrayList<Series> seriesList = (ArrayList<Series>) study.getSeriesList();
+                for (int i = 0; i < seriesList.size(); i++) {
+                    Series series = seriesList.get(i);
+                    if (series.getSeriesInstanceUID().equalsIgnoreCase(this.seriesUID)) {
+                        Instance instance = series.getImageList().get(0);
+                        setImage(instance.getPixelData());
+                        setInstanceInfo(instance);
+                        this.getCanvas().getLayeredCanvas().annotationPanel.setAnnotation(instance.getAnnotation());
+                    }
+                }
+            }
+        }
+        this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setCurrentInstance(this.currentInstanceNo);
+        this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setInstanceNumber("" + this.instanceNumber);
+    }
+
+    /**
+     * This routine used to set the windowing tool enabled
+     */
+    public void doWindowing() {
+        if (tool.equalsIgnoreCase("windowing")) {
+            tool = "";
+        } else {
+            tool = "windowing";
+        }
+    }
+
+    public void setWindowingToolsAsDefault() {
+        if (!(tool.equalsIgnoreCase("windowing"))) {
+            tool = "windowing";
+        }
+    }
+
+    public boolean isWindowingSelected() {
+        return (tool.equalsIgnoreCase("windowing"));
+    }
+
+    /**
+     * This routine used to get the dataset value of the current image box
+     * @return
+     */
+    public Dataset getDataset() {
+        return dataset;
+    }
+
+    /**
+     *  This routine used to set the dataset values of the current image box
+     * @param dataset
+     */
+    public void setDataset(Dataset dataset) {
+        this.dataset = dataset;
+    }
+
+    /**
+     * This routine used to check the horizontal flip flag for the current image box
+     * @return
+     */
+    public boolean isFlipHorizontalFlag() {
+        return flipHorizontalFlag;
+    }
+
+    /**
+     * This routine used to set the horizontal flip flag for the current image box
+     * @param flipHorizontalFlag
+     */
+    public void setFlipHorizontalFlag(boolean flipHorizontalFlag) {
+        this.flipHorizontalFlag = flipHorizontalFlag;
+    }
+
+    /**
+     * This routine used to check the vertical flip flag for the current image box
+     * @return
+     */
+    public boolean isFlipVerticalFlag() {
+        return flipVerticalFlag;
+    }
+
+    /**
+     * This routine used to set tej vertical flip flag for the current image box
+     * @param flipVerticalFlag
+     */
+    public void setFlipVerticalFlag(boolean flipVerticalFlag) {
+        this.flipVerticalFlag = flipVerticalFlag;
+    }
+
+    /**
+     * This routine used to check status of rotate of the image box
+     * @return
+     */
+    public boolean isIsRotate() {
+        return isRotate;
+    }
+
+    /**
+     * This routine used to set the rotate flag for the current image box
+     * @param isRotate
+     */
+    public void setIsRotate(boolean isRotate) {
+        this.isRotate = isRotate;
+    }
+
+    public int getRotateLeftAngle() {
+        return rotateLeftAngle;
+    }
+
+    public void setRotateLeftAngle(int rotateLeftAngle) {
+        this.rotateLeftAngle = rotateLeftAngle;
+    }
+
+    public int getRotateRightAngle() {
+        return rotateRightAngle;
+    }
+
+    public void setRotateRightAngle(int rotateRightAngle) {
+        this.rotateRightAngle = rotateRightAngle;
+    }
+
+    public double getScaleFactor() {
+        return scaleFactor;
+    }
+
+    public void setScaleFactor(double scaleFactor) {
+        this.scaleFactor = scaleFactor;
+    }
+
+    public boolean isScaleFlag() {
+        return scaleFlag;
+    }
+
+    public void setScaleFlag(boolean scaleFlag) {
+        this.scaleFlag = scaleFlag;
+    }
+
+    /**
+     * This override routine used to paint the image box
+     * @param gs
+     */
+    @Override
+    public void paintComponent(Graphics gs) {
+        Graphics2D g = (Graphics2D) gs;
+        g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
+        if (isRotate) {
+            if (rotateRightAngle == 90) {
+                g.rotate(Math.PI / 2, this.getSize().width / 2, this.getSize().height / 2);
+            } else if (rotateRightAngle == 180) {
+                g.rotate(Math.PI, this.getSize().width / 2, this.getSize().height / 2);
+            } else if (rotateRightAngle == 270) {
+                g.rotate((Math.PI * 3) / 2, this.getSize().width / 2, this.getSize().height / 2);
+            }
+        }
+        if (flipHorizontalFlag) {
+            g.translate(this.getSize().width, 0);
+            g.scale(-1, 1);
+        }
+        if (flipVerticalFlag) {
+            g.translate(0, this.getSize().height);
+            g.scale(1, -1);
+        }
+        if (scaleFlag) {
+            g.scale(scaleFactor, scaleFactor);
+        }
+        if (image != null) {
+            if ((widowingFlag && invertFlag) || (newBufferedImage && invertFlag)) {
+                byte[] negative = new byte[256];
+                for (int i = 0; i < 256; i++) {
+                    negative[i] = (byte) (255 - i);
+                }
+                ByteLookupTable table = new ByteLookupTable(0, negative);
+                LookupOp op = new LookupOp(table, null);
+
+                convertToRGBImage();
+
+                BufferedImage filteredImage = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_RGB);
+                op.filter(image, filteredImage);
+                image = filteredImage;
+            }
+            calculateNewHeightAndWidthBasedonAspectRatio();
+            g.drawImage(image, startX, startY, thumbWidth, thumbHeight, null);
+            if (displayScout) {
+                g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+                g.setColor(Color.YELLOW);
+                if (orientationLabel.equalsIgnoreCase("SAGITTAL")) {
+                    g.drawLine((int) (boundaryLine1X1 * this.getCurrentScaleFactor() + startX), (int) (boundaryLine1Y1 * this.getCurrentScaleFactor() + startY), (int) (boundaryLine1X2 * this.getCurrentScaleFactor() + startX), (int) (boundaryLine1Y2 * this.getCurrentScaleFactor() + startY));
+                    g.drawLine((int) (boundaryLine2X1 * this.getCurrentScaleFactor() + startX), (int) (boundaryLine2Y1 * this.getCurrentScaleFactor() + startY), (int) (boundaryLine2X2 * this.getCurrentScaleFactor() + startX), (int) (boundaryLine2Y2 * this.getCurrentScaleFactor() + startY));
+                    g.setColor(Color.GREEN);
+                    g.drawLine((int) (scoutLine1X1 * this.getCurrentScaleFactor() + startX), (int) (scoutLine1Y1 * this.getCurrentScaleFactor() + startY), (int) (scoutLine1X2 * this.getCurrentScaleFactor() + startX), (int) (scoutLine1Y2 * this.getCurrentScaleFactor() + startY));
+                    g.drawLine((int) (scoutLine2X1 * this.getCurrentScaleFactor() + startX), (int) (scoutLine2Y1 * this.getCurrentScaleFactor() + startY), (int) (scoutLine2X2 * this.getCurrentScaleFactor() + startX), (int) (scoutLine2Y2 * this.getCurrentScaleFactor() + startY));
+                } else if (orientationLabel.equalsIgnoreCase("CORONAL")) {
+                    g.drawLine((int) (axis1LeftX * this.getCurrentScaleFactor() + startX), (int) (axis1LeftY * this.getCurrentScaleFactor() + startY), (int) (axis1RightX * this.getCurrentScaleFactor() + startX), (int) (axis1RightY * this.getCurrentScaleFactor() + startY));
+                    g.drawLine((int) (axis2LeftX * this.getCurrentScaleFactor() + startX), (int) (axis2LeftY * this.getCurrentScaleFactor() + startY), (int) (axis2RightX * this.getCurrentScaleFactor() + startX), (int) (axis2RightY * this.getCurrentScaleFactor() + startY));
+                    g.setColor(Color.GREEN);
+                    g.drawLine((int) (axisLeftX * this.getCurrentScaleFactor() + startX), (int) (axisLeftY * this.getCurrentScaleFactor() + startY), (int) (axisRightX * this.getCurrentScaleFactor() + startX), (int) (axisRightY * this.getCurrentScaleFactor() + startY));
+                }
+            }
+        }
+        if (dataset.getString(Tags.SOPClassUID).equalsIgnoreCase("1.2.840.10008.5.1.4.1.1.104.1")) {
+            calculateResolutionForPdfDicom(loadedImage.getWidth(null), loadedImage.getHeight(null));
+            this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setCurrentInstance(curpage);
+            this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setTotalInstance(Integer.toString(totalInstance));
+            g.drawImage(loadedImage, startX, startY, thumbWidth, thumbHeight, null);
+            ApplicationContext.imgView.getImageToolbar().hideAnnotationTools();
+        }
+        if (firstTime) {
+            centerImage();
+            originalHeight = this.getSize().height;
+            originalWidth = this.getSize().width;
+            firstTime = false;
+        }
+    }
+
+    public void setScoutCoordinates(int line1X1, int line1Y1, int line1X2, int line1Y2, int line2X1, int line2Y1, int line2X2, int line2Y2) {
+        displayScout = true;
+        scoutLine1X1 = line1X1;
+        scoutLine1X2 = line1X2;
+        scoutLine1Y1 = line1Y1;
+        scoutLine1Y2 = line1Y2;
+        scoutLine2X1 = line2X1;
+        scoutLine2X2 = line2X2;
+        scoutLine2Y1 = line2Y1;
+        scoutLine2Y2 = line2Y2;
+        repaint();
+    }
+
+    private void calculateNewHeightAndWidthBasedonAspectRatio() {
+        thumbRatio = thumbWidth / thumbHeight;
+        double imageWidth = image.getWidth();
+        double imageHeight = image.getHeight();
+        double imageRatio = (double) imageWidth / (double) imageHeight;
+        if (imageRatio < floatAspectRatio) {
+            imageHeight = (imageWidth + 0.00f) / floatAspectRatio;
+            pixelSpacingY = ((initialPixelSpacingY * image.getHeight()) / imageHeight);
+            pixelSpacing = pixelSpacingY + "\\" + pixelSpacingX;
+        } else {
+            imageWidth = (imageHeight + 0.00f) * floatAspectRatio;
+            pixelSpacingX = (initialPixelSpacingX * image.getWidth()) / imageWidth;
+            pixelSpacing = pixelSpacingY + "\\" + pixelSpacingX;
+        }
+        this.row = (int) Math.round(imageHeight);
+        this.column = (int) Math.round(imageWidth);
+        imageRatio = imageWidth / imageHeight;
+        if (thumbRatio < imageRatio) {
+            thumbHeight = (int) Math.round((thumbWidth + 0.00f) / imageRatio);
+        } else {
+            thumbWidth = (int) Math.round((thumbHeight + 0.00f) * imageRatio);
+        }
+        startX = (maxWidth - thumbWidth) / 2;
+        startY = (maxHeight - thumbHeight) / 2;
+        displayZoomLevel();
+    }
+
+    private void displayZoomLevel() {
+        int currentZoomLevel = (int) Math.round(this.scaleFactor * currentScaleFactor * 100);
+        this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setZoomLevel(" Zoom: " + currentZoomLevel + "%");
+    }
+
+    public double getCurrentScaleFactor() {
+        double imageWidth = image.getWidth();
+        double imageHeight = image.getHeight();
+        double imageRatio = imageWidth / imageHeight;
+        if (imageRatio < floatAspectRatio) {
+            imageHeight = (imageWidth + 0.00f) / floatAspectRatio;
+        } else {
+            imageWidth = (imageHeight + 0.00f) * floatAspectRatio;
+        }
+        currentScaleFactor = (thumbHeight + 0.000f) / imageHeight;
+        return currentScaleFactor;
+    }
+
+    public void setScoutBorder1Coordinates(int line1X1, int line1Y1, int line1X2, int line1Y2) {
+        boundaryLine1X1 = line1X1;
+        boundaryLine1X2 = line1X2;
+        boundaryLine1Y1 = line1Y1;
+        boundaryLine1Y2 = line1Y2;
+    }
+
+    public void setScoutBorder2Coordinates(int line1X1, int line1Y1, int line1X2, int line1Y2) {
+        boundaryLine2X1 = line1X1;
+        boundaryLine2X2 = line1X2;
+        boundaryLine2Y1 = line1Y1;
+        boundaryLine2Y2 = line1Y2;
+    }
+
+    public void setAxis1Coordinates(int leftx, int lefty, int rightx, int righty, int topx, int topy, int bottomx, int bottomy) {
+        axis1LeftX = leftx;
+        axis1LeftY = lefty;
+        axis1RightX = rightx;
+        axis1RightY = righty;
+        axis1TopX = topx;
+        axis1TopY = topy;
+        axis1BottomX = bottomx;
+        axis1BottomY = bottomy;
+    }
+
+    public void setAxis2Coordinates(int leftx, int lefty, int rightx, int righty, int topx, int topy, int bottomx, int bottomy) {
+        axis2LeftX = leftx;
+        axis2LeftY = lefty;
+        axis2RightX = rightx;
+        axis2RightY = righty;
+        axis2TopX = topx;
+        axis2TopY = topy;
+        axis2BottomX = bottomx;
+        axis2BottomY = bottomy;
+    }
+
+    public void setAxisCoordinates(int leftx, int lefty, int rightx, int righty, int topx, int topy, int bottomx, int bottomy) {
+        axisLeftX = leftx;
+        axisLeftY = lefty;
+        axisRightX = rightx;
+        axisRightY = righty;
+        axisTopX = topx;
+        axisTopY = topy;
+        axisBottomX = bottomx;
+        axisBottomY = bottomy;
+    }
+
+    private void findOrientation() {
+        String imageOrientationArray[];
+        if (imageOrientation != null) {
+            imageOrientationArray = imageOrientation.split("\\\\");
+            float _imgRowCosx = Float.parseFloat(imageOrientationArray[0]);
+            float _imgRowCosy = Float.parseFloat(imageOrientationArray[1]);
+            float _imgRowCosz = Float.parseFloat(imageOrientationArray[2]);
+            float _imgColCosx = Float.parseFloat(imageOrientationArray[3]);
+            float _imgColCosy = Float.parseFloat(imageOrientationArray[4]);
+            float _imgColCosz = Float.parseFloat(imageOrientationArray[5]);
+            orientationLabel = getOrientationLabelFromImageOrientation(_imgRowCosx, _imgRowCosy, _imgRowCosz, _imgColCosx, _imgColCosy, _imgColCosz);
+            if (orientationLabel.equalsIgnoreCase("CORONAL") || orientationLabel.equalsIgnoreCase("SAGITTAL")) {
+                isLocalizer = true;
+            }
+        }
+    }
+
+    public String getOrientationLabelFromImageOrientation(double rowX, double rowY, double rowZ, double colX, double colY, double colZ) {
+        String label = null;
+        String ColumnRight = ImageOrientation.getOrientation(rowX, rowY, rowZ);
+        String rowDown = ImageOrientation.getOrientation(colX, colY, colZ);
+        String axis1 = ColumnRight.substring(0, 1);
+        String axis2 = rowDown.substring(0, 1);
+        if ((axis1 != null) && (axis2 != null)) {
+            if ((((axis1.equals("R")) || (axis1.equals("L")))) && (((axis2.equals("A")) || (axis2.equals("P"))))) {
+                label = "AXIAL";
+            } else if ((((axis2.equals("R")) || (axis2.equals("L")))) && (((axis1.equals("A")) || (axis1.equals("P"))))) {
+                label = "AXIAL";
+            } else if ((((axis1.equals("R")) || (axis1.equals("L")))) && (((axis2.equals("H")) || (axis2.equals("F"))))) {
+                label = "CORONAL";
+            } else if ((((axis2.equals("R")) || (axis2.equals("L")))) && (((axis1.equals("H")) || (axis1.equals("F"))))) {
+                label = "CORONAL";
+            } else if ((((axis1.equals("A")) || (axis1.equals("P")))) && (((axis2.equals("H")) || (axis2.equals("F"))))) {
+                label = "SAGITTAL";
+            } else if ((((axis2.equals("A")) || (axis2.equals("P")))) && (((axis1.equals("H")) || (axis1.equals("F"))))) {
+                label = "SAGITTAL";
+            }
+
+        } else {
+            label = "OBLIQUE";
+        }
+
+        return label;
+    }
+
+    private void setEnclosingSizes(int finalWidth, int finalHeight) {
+        this.getCanvas().getLayeredCanvas().getAnnotationPanel().setSize(finalWidth, finalHeight);
+        this.getCanvas().getLayeredCanvas().getAnnotationPanel().setBounds(xPosition, yPosition, this.getSize().width, this.getSize().height);
+    }
+
+    /**
+     * This routine used to zoom in the image box using the scale factor
+     */
+    public void doZoomIn() {
+        scaleFlag = true;
+        scaleFactor = scaleFactor + 0.5;
+        displayZoomLevel();
+        scaleProcess();
+        this.getCanvas().repaint();
+
+    }
+
+    public void convertToRGBImage() {
+        imageIcon = new ImageIcon();
+        if (currentbufferedimage != null) {
+            imageIcon.setImage(currentbufferedimage);
+            loadedImage = imageIcon.getImage();
+            image = new BufferedImage(loadedImage.getWidth(null), loadedImage.getHeight(null), BufferedImage.TYPE_INT_RGB);
+            Graphics2D g2 = image.createGraphics();
+            g2.drawImage(loadedImage, 0, 0, null);
+        }
+    }
+
+    /**
+     * This routine used to zoom out the image box using the scale factor
+     */
+    public void doZoomOut() {
+        scaleFlag = true;
+        scaleFactor = scaleFactor - 0.5;
+        if (scaleFactor > 0) {
+            scaleProcess();
+        } else {
+            scaleFactor = 0.5;
+        }
+        displayZoomLevel();
+        this.getCanvas().repaint();
+    }
+
+    /**
+     * This routine used to enable the stack process
+     */
+    public void doStack() {
+        if (tool.equalsIgnoreCase("stack")) {
+            tool = "";
+        } else {
+            tool = "stack";
+        }
+    }
+
+    public boolean isStackSelected() {
+        return (tool.equalsIgnoreCase("stack"));
+    }
+
+    public void setToolsToNull() {
+        tool = "";
+    }
+
+    private void scaleProcess() {
+        double currentWidth = this.getSize().width;
+        double currentHeight = this.getSize().height;
+        double newWidth = originalWidth * scaleFactor;
+        double newHeight = originalHeight * scaleFactor;
+        double widthDiff = newWidth - currentWidth;
+        double heightDiff = newHeight - currentHeight;
+        int currentX = this.getBounds().x;
+        int currentY = this.getBounds().y;
+        double newX = currentX - (widthDiff / 2);
+        double newY = currentY - (heightDiff / 2);
+        this.setBounds((int) newX, (int) newY, (int) newWidth, (int) newHeight);
+        this.revalidate();
+        repaint();
+    }
+
+    public double getOriginalHeight() {
+        return originalHeight;
+    }
+
+    public void setOriginalHeight(int originalHeight) {
+        this.originalHeight = originalHeight;
+    }
+
+    public double getOriginalWidth() {
+        return originalWidth;
+    }
+
+    public void setOriginalWidth(int originalWidth) {
+        this.originalWidth = originalWidth;
+    }
+
+    private void moveComponent(int x, int y) {
+        this.setBounds(x, y, this.getSize().width, this.getSize().height);
+    }
+    int xPosition;
+    int yPosition;
+
+    /**
+     * This routine used to calculate the x and y position of the image box to be placed in the
+     * outer canvas and set the bounds
+     */
+    private void centerImage() {
+        xPosition = (canvas.getSize().width - this.getSize().width) / 2;
+        yPosition = (canvas.getSize().height - this.getSize().height) / 2;
+        this.setBounds(xPosition, yPosition, this.getSize().width, this.getSize().height);
+
+    }
+
+    /**
+     * This routine erase the drawing in the outer canvas
+     */
+    private void clearCanvas() {
+        Graphics g = canvas.getGraphics();
+        Dimension d = canvas.getSize();
+        Color c = canvas.getBackground();
+        g.setColor(c);
+        g.fillRect(0, 0, d.width, d.height);
+    }
+
+    /**
+     * This method creates the color model based on the window level and width
+     * and apply the values to the image box
+     * @param windowCenter
+     * @param windowWidth
+     */
+    public void windowChanged(int windowCenter, int windowWidth) {
+        try {
+            widowingFlag = true;
+            if (cmParam != null) {
+                cmParam = cmParam.update(windowCenter, windowWidth, cmParam.isInverse());
+                cm = cmFactory.getColorModel(cmParam);
+                currentbufferedimage = new BufferedImage(cm, currentbufferedimage.getRaster(), false, null);
+                this.windowLevel = windowCenter;
+                this.windowWidth = windowWidth;
+            }
+            convertToRGBImage();
+            repaint();
+            changeTextOverlay();
+
+
+        } catch (Exception e) {
+            System.out.println("Windowing can't be applied");
+        }
+    }
+
+    public void repaintTextOverlay() {
+        this.getCanvas().getLayeredCanvas().textOverlay.repaint();
+    }
+
+    public ColorModel getColorModel() {
+        if(cmParam!=null){
+        cmParam = cmParam.update(this.windowLevel,
+                this.windowWidth, cmParam.isInverse());
+        cm = cmFactory.getColorModel(cmParam);
+        }
+        return cm;
+    }
+
+    /**
+     * This routine used to change the text overlay of the image box
+     */
+    public void changeTextOverlay() {
+        this.getCanvas().getLayeredCanvas().textOverlay.setWindowingParameter(Integer.toString(this.windowLevel), Integer.toString(this.windowWidth));
+    }
+
+    /**
+     * This routine used to get the dataset object from the file specified
+     * @param filePath
+     * @return
+     */
+    public DicomObject getDatasetFromFile(String filePath) {
+
+        DicomInputStream dis = null;
+        DicomObject data = null;
+        try {
+            File parseFile = new File(filePath);
+            dis = new DicomInputStream(parseFile);
+            data = new BasicDicomObject();
+            data = dis.readDicomObject();
+
+        } catch (IOException ex) {
+            ex.printStackTrace();
+            // Logger.getLogger(ModelUpdator.class.getName()).log(Level.SEVERE, null, ex);
+        } finally {
+            try {
+                dis.close();
+            } catch (IOException ex) {
+                ex.printStackTrace();
+                //   Logger.getLogger(ModelUpdator.class.getName()).log(Level.SEVERE, null, ex);
+            }
+        }
+        return data;
+    }
+
+    private void addlisteners() {
+        addMouseListener(this);
+        addMouseMotionListener(this);
+        addMouseWheelListener(this);
+    }
+
+    /**
+     *
+     */
+    public void probe() {
+        if (!probeFlag) {
+            probeFlag = true;
+            this.getCanvas().getLayeredCanvas().textOverlay.repaint();
+        } else {
+            probeFlag = false;
+            this.getCanvas().getLayeredCanvas().textOverlay.repaint();
+        }
+    }
+
+    public boolean isInvertFlag() {
+        return invertFlag;
+    }
+
+    public void setInvertFlag(boolean invertFlag) {
+        this.invertFlag = invertFlag;
+    }
+
+    public static boolean isProbeFlag() {
+        return probeFlag;
+    }
+
+    public double getPixelSpacingX() {
+        return pixelSpacingX;
+    }
+
+    public void setPixelSpacingX(double pixelSpacingX) {
+        this.pixelSpacingX = pixelSpacingX;
+    }
+
+    public double getPixelSpacingY() {
+        return pixelSpacingY;
+    }
+
+    public void setPixelSpacingY(double pixelSpacingY) {
+        this.pixelSpacingY = pixelSpacingY;
+    }
+
+    public int getWindowLevel() {
+        return windowLevel;
+    }
+
+    public void setWindowLevel(int windowLevel) {
+        this.windowLevel = windowLevel;
+    }
+
+    public int getWindowWidth() {
+        return windowWidth;
+    }
+
+    public void setWindowWidth(int windowWidth) {
+        this.windowWidth = windowWidth;
+    }
+
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        jPopupMenu1 = new javax.swing.JPopupMenu();
+
+        setBackground(new java.awt.Color(0, 0, 0));
+        setComponentPopupMenu(jPopupMenu1);
+        setDoubleBuffered(false);
+        setFocusCycleRoot(true);
+        setOpaque(false);
+        setPreferredSize(new java.awt.Dimension(512, 512));
+        addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                formMouseClicked(evt);
+            }
+        });
+        setLayout(new java.awt.BorderLayout());
+    }// </editor-fold>//GEN-END:initComponents
+
+    private void formMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseClicked
+        this.canvas.requestFocus();
+    }//GEN-LAST:event_formMouseClicked
+    private void setTotalInstacne() {
+        if (ApplicationContext.databaseRef.getMultiframeStatus()) {
+            if (!isMulitiFrame()) {
+                totalInstance = ApplicationContext.databaseRef.getSeriesLevelInstance(this.studyUID, this.seriesUID);
+                currentInstanceNo = 0;
+            } else {
+                totalInstance = nFrames;
+                currentInstanceNo = 0;
+            }
+        } else {
+            totalInstance = ApplicationContext.databaseRef.getSeriesLevelInstance(this.studyUID, this.seriesUID);
+            currentInstanceNo = 0;
+        }
+        if (dataset.getString(Tags.SOPClassUID).equalsIgnoreCase("1.2.840.10008.5.1.4.1.1.104.1")) {
+            totalInstance = curFile.getNumPages();
+            currentInstanceNo = 0;
+        }
+    }
+
+    public void mouseWheelMoved(MouseWheelEvent e) {
+        this.requestFocus();
+        this.canvas.setSelection();
+        this.storeAnnotation();
+        int notches = e.getWheelRotation();
+        if (notches < 0) {
+            doPrevious();
+        } else {
+            doNext();
+        }
+    }
+
+    private void nextofEncapsulatedDocument() {
+        if (dataset.getString(Tags.SOPClassUID).equalsIgnoreCase("1.2.840.10008.5.1.4.1.1.104.1")) {
+            forceGotoPage(curpage + 1);
+        }
+    }
+
+    private void previousofEncapsulatedDocument() {
+        if (dataset.getString(Tags.SOPClassUID).equalsIgnoreCase("1.2.840.10008.5.1.4.1.1.104.1")) {
+            forceGotoPage(curpage - 1);
+        }
+    }
+
+    public void moveToNextInstance() {
+        this.storeAnnotation();
+        doNext();
+    }
+
+    public void moveToPreviousInstance() {
+        this.storeAnnotation();
+        doPrevious();
+
+    }
+
+    public void doPrevious() {
+        if (isEncapsulatedDocument) {
+            previousofEncapsulatedDocument();
+
+        } else if (ApplicationContext.databaseRef.getMultiframeStatus() && isMulitiFrame()) {
+            if (instanceArray == null) {
+                previousFrame();
+            } else {
+                showPreviousFrame();
+            }
+        } else {
+            if (instanceArray == null) {
+                previousInstance();
+            } else {
+                selectPreviousInstance();
+            }
+        }
+    }
+
+    public void doNext() {
+        if (isEncapsulatedDocument) {
+            nextofEncapsulatedDocument();
+
+        } else if (ApplicationContext.databaseRef.getMultiframeStatus() && isMulitiFrame()) {
+            if (instanceArray == null) {
+                nextFrame();
+            } else {
+                showNextFrame();
+            }
+        } else {
+            if (instanceArray == null) {
+                nextInstance();
+            } else {
+                selectNextInstance();
+            }
+        }
+    }
+
+    private void setInstanceArray() {
+        for (Study study : MainScreen.studyList) {
+            if (study.getStudyInstanceUID().equalsIgnoreCase(this.studyUID)) {
+                for (Series series : study.getSeriesList()) {
+                    if (mulitiFrame) {
+                        if (series.isMultiframe() && series.getSeriesInstanceUID().equalsIgnoreCase(seriesUID) && series.getInstanceUID().equalsIgnoreCase(instanceUID)) {
+                            instanceArray = (ArrayList<Instance>) series.getImageList();
+                        } else {
+                            if (series.getSeriesInstanceUID().equalsIgnoreCase(seriesUID)) {
+                                for (Instance instance : series.getImageList()) {
+                                    if (instance.getSop_iuid().equalsIgnoreCase(this.instanceUID)) {
+                                        ArrayList<Instance> temp = new ArrayList<Instance>();
+                                        temp.add(instance);
+                                        instanceArray = temp;
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    public void previousFrame() {
+        for (Study study : MainScreen.studyList) {
+            if (study.getStudyInstanceUID().equalsIgnoreCase(this.studyUID)) {
+                for (Series series : study.getSeriesList()) {
+                    if (mulitiFrame) {
+                        if (ApplicationContext.databaseRef.getMultiframeStatus()) {
+                            if (series.isMultiframe() && series.getSeriesInstanceUID().equalsIgnoreCase(seriesUID) && series.getInstanceUID().equalsIgnoreCase(instanceUID)) {
+                                instanceArray = (ArrayList<Instance>) series.getImageList();
+                                showPreviousFrame();
+                            }
+                        } else {
+                            if (series.getSeriesInstanceUID().equalsIgnoreCase(seriesUID)) {
+                                for (Instance instance : series.getImageList()) {
+                                    if (instance.getSop_iuid().equalsIgnoreCase(this.instanceUID)) {
+                                        ArrayList<Instance> temp = new ArrayList<Instance>();
+                                        temp.add(instance);
+                                        instanceArray = temp;
+                                    }
+                                }
+                            }
+                            showPreviousFrame();
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    public void nextFrame() {
+        for (Study study : MainScreen.studyList) {
+            if (study.getStudyInstanceUID().equalsIgnoreCase(studyUID)) {
+                for (Series series : study.getSeriesList()) {
+                    if (mulitiFrame) {
+                        if (ApplicationContext.databaseRef.getMultiframeStatus()) {
+                            if (series.isMultiframe() && series.getSeriesInstanceUID().equalsIgnoreCase(seriesUID) && series.getInstanceUID().equalsIgnoreCase(instanceUID)) {
+                                instanceArray = (ArrayList<Instance>) series.getImageList();
+                                showNextFrame();
+                            }
+                        } else {
+                            if (series.getSeriesInstanceUID().equalsIgnoreCase(seriesUID)) {
+                                for (Instance instance : series.getImageList()) {
+                                    if (instance.getSop_iuid().equalsIgnoreCase(this.instanceUID)) {
+                                        ArrayList<Instance> temp = new ArrayList<Instance>();
+                                        temp.add(instance);
+                                        instanceArray = temp;
+                                    }
+                                }
+                            }
+                            showNextFrame();
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    public void storeAnnotation() {
+        Iterator<Study> studyItr = MainScreen.studyList.iterator();
+        while (studyItr.hasNext()) {
+            Study study = studyItr.next();
+            if (study.getStudyInstanceUID().equalsIgnoreCase(studyUID)) {
+                ArrayList<Series> seriesList = (ArrayList<Series>) study.getSeriesList();
+                Iterator<Series> seriesItr = seriesList.iterator();
+                while (seriesItr.hasNext()) {
+                    Series series = seriesItr.next();
+                    if (!ApplicationContext.databaseRef.getMultiframeStatus()) {
+                        if (series.getSeriesInstanceUID().equalsIgnoreCase(seriesUID)) {
+                            Instance instance = series.getImageList().get(currentInstanceNo);
+                            instance.setAnnotation(this.getCanvas().getLayeredCanvas().annotationPanel.getAnnotation());
+                        }
+                    } else {
+                        if (!isMulitiFrame()) {
+                            if (!series.isMultiframe() && series.getSeriesInstanceUID().equalsIgnoreCase(seriesUID)) {
+                                Instance instance = series.getImageList().get(currentInstanceNo);
+                                instance.setAnnotation(this.getCanvas().getLayeredCanvas().annotationPanel.getAnnotation());
+                            }
+                        }//for multiframe instance setAnnotations should be there it can be of hash map with index values.
+                        else {
+                            if (series.isMultiframe() && series.getSeriesInstanceUID().equalsIgnoreCase(seriesUID) && series.getInstanceUID().equalsIgnoreCase(instanceUID)) {
+                                Instance instance = series.getImageList().get(0);//becuase multiframe series contains single instance.
+                                instance.addMultiframeAnnotation(currentInstanceNo, this.getCanvas().getLayeredCanvas().annotationPanel.getAnnotation());
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    public String[] getInstancesFilePath() {
+        String[] s = null;
+        Iterator studyItr = MainScreen.studyList.iterator();
+        while (studyItr.hasNext()) {
+            Study study = (Study) studyItr.next();
+            if (study.getStudyInstanceUID().equalsIgnoreCase(ApplicationContext.imgPanel.getStudyUID())) {
+                ArrayList seriesList = (ArrayList) study.getSeriesList();
+                for (int i = 0; i < seriesList.size(); ++i) {
+                    Series series = (Series) seriesList.get(i);
+                    if (series.getSeriesInstanceUID().equalsIgnoreCase(this.seriesUID)) {
+                        s = new String[series.getImageList().size()];
+                        int x = 0;
+                        for (Iterator i$ = series.getImageList().iterator(); i$.hasNext();) {
+                            Instance instance = (Instance) i$.next();
+
+                            s[x] = instance.getFilepath();
+                            ++x;
+                        }
+                    }
+                }
+            }
+
+        }
+
+        return s;
+    }
+
+    public void mouseClicked(MouseEvent e) {
+    }
+
+    public void mousePressed(MouseEvent e) {
+        selectSeries(e);
+    }
+
+    private void selectSeries(MouseEvent e) {
+        this.canvas.setSelection();
+        mouseLocX1 = e.getX();
+        mouseLocY1 = e.getY();
+        mousePressed = true;
+        if (e.isPopupTrigger()) {
+            designContext();
+            jPopupMenu1.show(this, e.getX(), e.getY());
+        }
+    }
+
+    public void mouseReleased(MouseEvent e) {
+        selectSeries(e);
+    }
+
+    public void mouseEntered(MouseEvent e) {
+    }
+
+    public void mouseExited(MouseEvent e) {
+    }
+
+    public void mouseDragged(MouseEvent e) {
+        mouseLocX2 = e.getX();
+        mouseLocY2 = e.getY();
+
+        if (tool.equalsIgnoreCase("windowing")) {
+            if (canStart) {
+                canStart = false;
+                mouseDragWindowing(mouseLocX2, mouseLocY2);
+                canStart = true;
+            }
+        } else if (tool.equalsIgnoreCase("panning")) {
+            this.setLocation(this.getBounds().x + mouseLocX2 - mouseLocX1, this.getBounds().y + mouseLocY2 - mouseLocY1);
+            repaint();
+            this.getCanvas().repaint();
+        } else if (tool.equalsIgnoreCase("stack")) {
+            mouseDragStack(mouseLocX2, mouseLocY2);
+        }
+    }
+
+    private void mouseDragWindowing(int mouseLocX2, int mouseLocY2) {
+        int mouseLocDiffX = (int) ((mouseLocX2 - mouseLocX1)) * windowingMultiplier;
+        int mouseLocDiffY = (int) ((mouseLocY1 - mouseLocY2)) * windowingMultiplier;
+        mouseLocX1 = mouseLocX2;
+        mouseLocY1 = mouseLocY2;
+        double newWindowWidth = windowWidth + mouseLocDiffX * 5;
+        if (newWindowWidth < 1.0) {
+            newWindowWidth = 1.0;
+        }
+        double newWindowLevel = windowLevel + mouseLocDiffY * 5;
+        windowChanged((int) newWindowLevel, (int) newWindowWidth);
+    }
+
+    private void mouseDragStack(int mouseLocX2, int mouseLocY2) {
+        int mouseLocDiffY = (int) ((mouseLocY2 - mouseLocY1));
+        if (mouseLocDiffY < -12) {
+            mouseLocX1 = mouseLocX2;
+            mouseLocY1 = mouseLocY2;
+            if (ApplicationContext.databaseRef.getMultiframeStatus() && isMulitiFrame()) {
+                if (instanceArray == null) {
+                    previousFrame();
+                } else {
+                    showPreviousFrame();
+                }
+            } else {
+                if (instanceArray == null) {
+                    previousInstance();
+                } else {
+                    selectPreviousInstance();
+                }
+            }
+        } else if (mouseLocDiffY > 12) {
+            mouseLocX1 = mouseLocX2;
+            mouseLocY1 = mouseLocY2;
+            if (ApplicationContext.databaseRef.getMultiframeStatus() && isMulitiFrame()) {
+                if (instanceArray == null) {
+                    nextFrame();
+                } else {
+                    showNextFrame();
+                }
+            } else {
+                if (instanceArray == null) {
+                    nextInstance();
+                } else {
+                    selectNextInstance();
+                }
+            }
+        }
+    }
+
+    private void selectPreviousInstance() {
+        if (currentInstanceNo == 0) {
+            currentInstanceNo = totalInstance;
+        }
+        currentInstanceNo--;
+        Instance instance = instanceArray.get(currentInstanceNo);
+        if (instance.isMultiframe()) {
+            this.getCanvas().getLayeredCanvas().textOverlay.multiframeStatusDisplay(true);
+            this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setFramePosition((instance.getCurrentFrameNum() + 1) + "/" + instance.getTotalNumFrames());
+        } else {
+            this.getCanvas().getLayeredCanvas().textOverlay.multiframeStatusDisplay(false);
+            this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setFramePosition("");
+        }
+        setImage(instance.getPixelData());
+        setInstanceInfo(instance);
+        if (displayScout) {
+            findOrientation();
+            if (!this.isLocalizer) {
+                LocalizerDelegate localizer = new LocalizerDelegate();
+                localizer.drawScoutLineWithBorder();
+            }
+        }
+        this.getCanvas().getLayeredCanvas().annotationPanel.setAnnotation(instance.getAnnotation());
+        if (!ApplicationContext.databaseRef.getMultiframeStatus()) {
+            this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setCurrentInstance(instance.getSeriesLevelIndex());
+        } else {
+            this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setCurrentInstance(this.currentInstanceNo);
+        }
+        this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setInstanceNumber("" + this.instanceNumber);
+        this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setSlicePosition(sliceLocation);
+        if (synchornizeTiles && !isMulitiFrame() && modality.startsWith("CT")) {
+            SynchronizationDelegate synchronizationDelegate = new SynchronizationDelegate();
+            synchronizationDelegate.doTileSync();
+        }
+    }
+
+    public void selectNextInstance() {
+        currentInstanceNo++;
+        if (currentInstanceNo == totalInstance) {
+            currentInstanceNo = 0;
+        }
+        Instance instance = instanceArray.get(currentInstanceNo);
+        if (instance.isMultiframe()) {
+            this.getCanvas().getLayeredCanvas().textOverlay.multiframeStatusDisplay(true);
+            this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setFramePosition((instance.getCurrentFrameNum() + 1) + "/" + instance.getTotalNumFrames());
+        } else {
+            this.getCanvas().getLayeredCanvas().textOverlay.multiframeStatusDisplay(false);
+            this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setFramePosition("");
+        }
+        setImage(instance.getPixelData());
+        setInstanceInfo(instance);
+        if (displayScout) {
+            findOrientation();
+            if (!this.isLocalizer) {
+                LocalizerDelegate localizer = new LocalizerDelegate();
+                localizer.drawScoutLineWithBorder();
+            }
+        }
+        this.getCanvas().getLayeredCanvas().annotationPanel.setAnnotation(instance.getAnnotation());
+        //this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setCurrentInstance(this.currentInstanceNo);
+        if (!ApplicationContext.databaseRef.getMultiframeStatus()) {
+            this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setCurrentInstance(instance.getSeriesLevelIndex());
+        } else {
+            this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setCurrentInstance(this.currentInstanceNo);
+        }
+        this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setInstanceNumber("" + this.instanceNumber);
+        this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setSlicePosition(sliceLocation);
+        if (synchornizeTiles && !isMulitiFrame() && modality.startsWith("CT")) {
+            SynchronizationDelegate synchronizationDelegate = new SynchronizationDelegate();
+            synchronizationDelegate.doTileSync();
+        }
+    }
+
+    public void setImage(String sliceLocation) {
+        /**
+         * This mehtod has been added for synchronized scroll it will not support for multiframe sync scroll. so that
+         * instance number can be set directly to instanceNumber and currentInstanceNo variable.
+         */
+        int instanceNo = ApplicationContext.databaseRef.getInstaneNumberBasedOnSliceLocation(studyUID, seriesUID, instanceUID, sliceLocation);
+        instanceNo--;
+        if (instanceNumber != -1) {
+            if (instanceNo > -1 && instanceNo < instanceArray.size()) {
+                setImage(instanceArray.get(instanceNo).getPixelData());
+                setInstanceInfo(instanceArray.get(instanceNo));
+                this.instanceNumber = instanceNo;
+                currentInstanceNo = instanceNo - 1;
+                updateTextoverlay();
+            }
+        }
+    }
+
+    public void setImage(int instanceNo) {
+        /**
+         * This mehtod has been added for synchronized scroll it will not support for multiframe sync scroll. so that
+         * instance number can be set directly to instanceNumber and currentInstanceNo variable.
+         */
+        if (instanceNo > -1 && instanceNo < instanceArray.size()) {
+            setImage(instanceArray.get(instanceNo).getPixelData());
+            setInstanceInfo(instanceArray.get(instanceNo));
+            this.instanceNumber = instanceNo + 1;
+            currentInstanceNo = instanceNo;
+            updateTextoverlay();
+        }
+    }
+
+    public void updateTextoverlay() {
+        this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setCurrentInstance(this.currentInstanceNo);
+        this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setInstanceNumber("" + this.instanceNumber);
+        this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setSlicePosition(sliceLocation);
+    }
+
+    public void setInstanceArryFromList() {
+        if (instanceArray == null) {
+            for (Study study : MainScreen.studyList) {
+                if (study.getStudyInstanceUID().equalsIgnoreCase(this.studyUID)) {
+                    for (Series series : study.getSeriesList()) {
+                        if (ApplicationContext.databaseRef.getMultiframeStatus()) {
+                            if (!series.isMultiframe() && series.getSeriesInstanceUID().equalsIgnoreCase(seriesUID)) {
+                                totalInstance = series.getImageList().size();
+                                instanceArray = (ArrayList<Instance>) series.getImageList();
+                            }
+                        } else {
+                            if (series.getSeriesInstanceUID().equalsIgnoreCase(seriesUID)) {
+                                totalInstance = series.getImageList().size();
+                                instanceArray = (ArrayList<Instance>) series.getImageList();
+                            }
+                        }
+                    }
+                }
+
+            }
+        }
+    }
+
+    public String getSliceLocation() {
+        return sliceLocation;
+    }
+
+    private void setInstanceInfo(Instance img) {
+        try {
+            this.instanceUID = img.getSop_iuid();
+            this.imagePosition = img.getImagePosition();
+            this.imageOrientation = img.getImageOrientation();
+            this.imageType = img.getImageType();
+            this.pixelSpacing = img.getPixelSpacing();
+            this.row = img.getRow();
+            this.column = img.getColumn();
+            this.frameOfReferenceUID = img.getFrameOfReferenceUID().equalsIgnoreCase("") ? "" : img.getFrameOfReferenceUID();
+            this.referencedSOPInstanceUID = img.getReferenceSOPInstanceUID().equalsIgnoreCase("") ? "" : img.getReferenceSOPInstanceUID();
+            this.instanceNumber = img.getInstanceNumber();
+            this.sliceLocation = img.getSliceLocation();
+        } catch (Exception e) {
+            System.out.println("[ImagePanel]" + e.getMessage());
+        }
+    }
+
+    public void previousInstance() {
+        for (Study study : MainScreen.studyList) {
+            if (study.getStudyInstanceUID().equalsIgnoreCase(this.studyUID)) {
+                for (Series series : study.getSeriesList()) {
+                    if (ApplicationContext.databaseRef.getMultiframeStatus()) {
+                        if (!series.isMultiframe() && series.getSeriesInstanceUID().equalsIgnoreCase(seriesUID)) {
+                            totalInstance = series.getImageList().size();
+                            instanceArray = (ArrayList<Instance>) series.getImageList();
+                            selectPreviousInstance();
+                        }
+                    } else {
+                        if (series.getSeriesInstanceUID().equalsIgnoreCase(seriesUID)) {
+                            totalInstance = series.getImageList().size();
+                            instanceArray = (ArrayList<Instance>) series.getImageList();
+                            selectPreviousInstance();
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    public void nextInstance() {
+        for (Study study : MainScreen.studyList) {
+            if (study.getStudyInstanceUID().equalsIgnoreCase(studyUID)) {
+                for (Series series : study.getSeriesList()) {
+                    if (ApplicationContext.databaseRef.getMultiframeStatus()) {
+                        if (!series.isMultiframe() && series.getSeriesInstanceUID().equalsIgnoreCase(seriesUID)) {
+                            totalInstance = series.getImageList().size();
+                            instanceArray = (ArrayList<Instance>) series.getImageList();
+                            selectNextInstance();
+                        }
+                    } else {
+                        if (series.getSeriesInstanceUID().equalsIgnoreCase(seriesUID)) {
+                            totalInstance = series.getImageList().size();
+                            instanceArray = (ArrayList<Instance>) series.getImageList();
+                            selectNextInstance();
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    public ScoutLineInfoModel[] getScoutBorder() {
+        ScoutLineInfoModel[] borderArray = null;
+        for (Study study : MainScreen.studyList) {
+            if (study.getStudyInstanceUID().equalsIgnoreCase(studyUID)) {
+                for (Series series : study.getSeriesList()) {
+                    if (series.getSeriesInstanceUID().equalsIgnoreCase(seriesUID)) {
+                        totalInstance = series.getImageList().size();
+                        instanceArray = (ArrayList<Instance>) series.getImageList();
+                        borderArray = prepareScoutBorder();
+                    }
+                }
+            }
+        }
+        return borderArray;
+    }
+
+    private ScoutLineInfoModel[] prepareScoutBorder() {
+        Instance firstInstance = instanceArray.get(0);
+        Instance lastInstance = instanceArray.get(this.totalInstance - 1);
+        ScoutLineInfoModel borderLine1 = new ScoutLineInfoModel();
+        ScoutLineInfoModel borderLine2 = new ScoutLineInfoModel();
+
+        borderLine1.setImagePosition(firstInstance.getImagePosition());
+        borderLine1.setImageOrientation(firstInstance.getImageOrientation());
+        borderLine1.setImagePixelSpacing(firstInstance.getPixelSpacing());
+        borderLine1.setImageRow(firstInstance.getRow());
+        borderLine1.setImageColumn(firstInstance.getColumn());
+        borderLine1.setImageFrameofReferenceUID(firstInstance.getFrameOfReferenceUID());
+        borderLine1.setImageReferenceSOPInstanceUID(firstInstance.getReferenceSOPInstanceUID());
+
+        borderLine2.setImagePosition(lastInstance.getImagePosition());
+        borderLine2.setImageOrientation(lastInstance.getImageOrientation());
+        borderLine2.setImagePixelSpacing(lastInstance.getPixelSpacing());
+        borderLine2.setImageRow(lastInstance.getRow());
+        borderLine2.setImageColumn(lastInstance.getColumn());
+        borderLine2.setImageFrameofReferenceUID(lastInstance.getFrameOfReferenceUID());
+        borderLine2.setImageReferenceSOPInstanceUID(lastInstance.getReferenceSOPInstanceUID());
+
+        ScoutLineInfoModel[] borderArray = new ScoutLineInfoModel[2];
+        borderArray[0] = borderLine1;
+        borderArray[1] = borderLine2;
+        return borderArray;
+    }
+
+    public int getTotalInstance() {
+        return totalInstance;
+    }
+
+    public void setTotalInstance(int totalInstance) {
+        this.totalInstance = totalInstance;
+    }
+
+    public int getCurrentInstanceNo() {
+        return currentInstanceNo;
+    }
+
+    public void setCurrentInstanceNo(int currentInstanceNo) {
+        this.currentInstanceNo = currentInstanceNo;
+    }
+
+    public static boolean isDisplayScout() {
+        return displayScout;
+    }
+
+    public static void setDisplayScout(boolean displayScout) {
+        ImagePanel.displayScout = displayScout;
+    }
+
+    private void clearProbeValues() {
+
+        Graphics g = this.getCanvas().getLayeredCanvas().textOverlay.getGraphics();
+        Color c = this.getCanvas().getLayeredCanvas().textOverlay.getBackground();
+        g.setColor(Color.white);
+        g.fillRect(0, this.getCanvas().getLayeredCanvas().textOverlay.getHeight() - 70, 200, 30);
+    }
+
+    private String calculateHU(int x, int y) {
+        try {
+            pixelValueArray = currentbufferedimage.getSampleModel().getPixel(
+                    x, y, (int[]) null,
+                    currentbufferedimage.getRaster().getDataBuffer());
+            pixelValue = pixelValueArray[0];
+            try {
+                hu = Integer.toString(pixelValue * Integer.parseInt(rescaleSlope) + Integer.parseInt(rescaleIntercept));
+            } catch (Exception e) {
+                hu = Integer.toString(pixelValue * 1 - 1024);
+            }
+        } catch (Exception e) {
+            System.out.println("Array index out of bound exception");
+        }
+
+        return hu;
+    }
+
+    public int[] getPixels(int x, int y, int w, int h) {
+        return currentbufferedimage.getSampleModel().getPixels(x, y, w, h, (int[]) null, currentbufferedimage.getRaster().getDataBuffer());
+    }
+
+    public void mouseMoved(MouseEvent e) {
+        mouseLocX2 = e.getX();
+        mouseLocY2 = e.getY();
+        if (probeFlag) {
+            String probeParameter[] = new String[3];
+            probeParameter[0] = Integer.toString((int) Math.round(mouseLocX2 / this.scaleFactor));
+            probeParameter[1] = Integer.toString((int) Math.round(mouseLocY2 / this.scaleFactor));
+            probeParameter[2] = calculateHU((int) Math.round(mouseLocX2 / this.scaleFactor), (int) Math.round(mouseLocY2 / this.scaleFactor));
+            this.getCanvas().getLayeredCanvas().textOverlay.setProbeParameters(probeParameter);
+        }
+    }
+
+    public float getRescaleIntercept() {
+        if (rescaleIntercept != null && !rescaleIntercept.equalsIgnoreCase("")) {
+            return Float.parseFloat(rescaleIntercept);
+        } else {
+            return 0.0f;
+        }
+    }
+
+    public void setRescaleIntercept(String rescaleIntercept) {
+        this.rescaleIntercept = rescaleIntercept;
+    }
+
+    public float getRescaleSlope() {
+        if (rescaleSlope != null && !rescaleSlope.equalsIgnoreCase("")) {
+            return Float.parseFloat(rescaleSlope);
+        } else {
+            return 0.0f;
+        }
+    }
+
+    public void setRescaleSlope(String rescaleSlope) {
+        this.rescaleSlope = rescaleSlope;
+    }
+
+    public String getModality() {
+        return modality;
+    }
+
+    public void setModality(String modality) {
+        this.modality = modality;
+    }
+
+    public boolean isLocalizer() {
+        return isLocalizer;
+    }
+
+    public String getFrameOfReferenceUID() {
+        return frameOfReferenceUID;
+    }
+
+    public String getImageOrientation() {
+        return imageOrientation;
+    }
+
+    public String getImagePosition() {
+        return imagePosition;
+    }
+
+    public String getPixelSpacing() {
+        return pixelSpacing;
+    }
+
+    public int getColumn() {
+        return column;
+    }
+
+    public int getRow() {
+        return row;
+    }
+
+    public String getReferencedSOPInstanceUID() {
+        return referencedSOPInstanceUID;
+    }
+
+    private void designContext() {
+        ArrayList<Series> seriesList = ApplicationContext.databaseRef.getSeriesList(this.studyUID);
+        JMenu menu;
+        if ((this.studyDesc == null) || (this.studyDesc.equalsIgnoreCase(""))) {
+            menu = new JMenu(this.studyUID);
+        } else {
+            menu = new JMenu(this.studyDesc);
+        }
+        JMenu menu1 = new JMenu("Multiframe(s)");
+        for (final Series series : seriesList) {
+            JMenuItem menuitem = null;
+            if (series.isMultiframe()) {
+                if (Integer.parseInt(series.getImageList().get(0).getInstance_no()) < 10) {
+                    menuitem = new JMenuItem(series.getImageList().get(0).getInstance_no() + "   - Frames  " + series.getImageList().get(0).getTotalNumFrames());
+                } else {
+                    menuitem = new JMenuItem(series.getImageList().get(0).getInstance_no() + " - Frames  " + series.getImageList().get(0).getTotalNumFrames());
+                }
+                menu1.add(menuitem);
+            } else if (!series.getSeriesDesc().equalsIgnoreCase("null")) {
+                menuitem = new JMenuItem(series.getSeriesDesc());
+            } else if (!series.getBodyPartExamined().equalsIgnoreCase("null")) {
+                menuitem = new JMenuItem(series.getBodyPartExamined());
+            } else {
+                menuitem = new JMenuItem(series.getSeriesInstanceUID());
+            }
+            if (!series.isMultiframe()) {
+                menu.add(menuitem);
+            } else {
+                menu.add(menu1);
+            }
+            menuitem.addActionListener(new java.awt.event.ActionListener() {
+
+                public void actionPerformed(ActionEvent arg0) {
+                    if (ApplicationContext.databaseRef.getMultiframeStatus()) {
+                        changeSeries(arg0, series.getStudyInstanceUID(), series.getSeriesInstanceUID(), series.isMultiframe(), series.getInstanceUID());
+                    } else {
+                        changeSeries(arg0, series.getStudyInstanceUID(), series.getSeriesInstanceUID());
+                    }
+                }
+            });
+        }
+        jPopupMenu1.removeAll();
+        jPopupMenu1.add(menu);
+
+        createOtherPatientStudiesMenu(jPopupMenu1);
+        this.setComponentPopupMenu(jPopupMenu1);
+    }
+    JMenu studyMenu = null;
+
+    public void createOtherPatientStudiesMenu(JPopupMenu mainMenu) {
+
+        if (canvas.getLayeredCanvas().getComparedWithStudies() != null) {
+            //Other Studies
+            mainMenu.addSeparator();
+            for (String s : canvas.getLayeredCanvas().getComparedWithStudies()) {
+                if (!s.equalsIgnoreCase(this.studyUID)) {
+                    studyMenu = new JMenu(ApplicationContext.databaseRef.getPatientNameBasedonStudyUID(s));
+                    ArrayList<Series> seriesList = ApplicationContext.databaseRef.getSeriesList(s);
+                    JMenu menu1 = new JMenu("Multiframe(s)");
+                    for (final Series series : seriesList) {
+                        JMenuItem menuitem = null;
+                        if (series.isMultiframe()) {
+                            if (Integer.parseInt(series.getImageList().get(0).getInstance_no()) < 10) {
+                                menuitem = new JMenuItem(series.getImageList().get(0).getInstance_no() + "   - Frames  " + series.getImageList().get(0).getTotalNumFrames());
+                            } else {
+                                menuitem = new JMenuItem(series.getImageList().get(0).getInstance_no() + " - Frames  " + series.getImageList().get(0).getTotalNumFrames());
+                            }
+                            menu1.add(menuitem);
+                        } else if (!series.getSeriesDesc().equalsIgnoreCase("null")) {
+                            menuitem = new JMenuItem(series.getSeriesDesc());
+                        } else if (!series.getBodyPartExamined().equalsIgnoreCase("null")) {
+                            menuitem = new JMenuItem(series.getBodyPartExamined());
+                        } else {
+                            menuitem = new JMenuItem(series.getSeriesInstanceUID());
+                        }
+                        if (!series.isMultiframe()) {
+                            studyMenu.add(menuitem);
+                        } else {
+                            studyMenu.add(menu1);
+                        }
+                        menuitem.addActionListener(new java.awt.event.ActionListener() {
+
+                            public void actionPerformed(ActionEvent arg0) {
+                                if (ApplicationContext.databaseRef.getMultiframeStatus()) {
+                                    changeSeries(arg0, series.getStudyInstanceUID(), series.getSeriesInstanceUID(), series.isMultiframe(), series.getInstanceUID());
+                                } else {
+                                    changeSeries(arg0, series.getStudyInstanceUID(), series.getSeriesInstanceUID());
+                                }
+                            }
+                        });
+                    }
+
+                    mainMenu.add(studyMenu);
+                }
+            }
+
+        }
+    }
+
+    public boolean isInstanceArray() {
+        if (this.instanceArray != null) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    public static boolean isSynchornizeTiles() {
+        return synchornizeTiles;
+    }
+
+    public void doSynchronize() {
+        if (synchornizeTiles) {
+            synchornizeTiles = false;
+        } else {
+            synchornizeTiles = true;
+            syncStartInstance = this.currentInstanceNo;
+            SynchronizationDelegate.setSyncStartInstanceInAllTiles();
+        }
+    }
+
+    public boolean canBeProcessed() {
+        boolean temp = false;
+        if (modality.startsWith("CT")) {
+            temp = true;
+        }
+        return temp;
+    }
+
+    public int getSyncDifference() {
+        return currentInstanceNo - syncStartInstance;
+    }
+
+    public void updateSyncStartInstance() {
+        syncStartInstance = this.currentInstanceNo;
+    }
+
+    public int getSyncStartInstance() {
+        return syncStartInstance;
+    }
+
+    private void changeSeries(ActionEvent e, String studyUID, String seriesUID) {
+        SeriesChooserDelegate seriesChooser = new SeriesChooserDelegate(studyUID, seriesUID, this.getCanvas().getLayeredCanvas());
+    }
+
+    private void changeSeries(ActionEvent e, String studyUID, String seriesUID, boolean multiframe, String instanceUID) {
+        SeriesChooserDelegate seriesChooser = new SeriesChooserDelegate(studyUID, seriesUID, multiframe, instanceUID, this.getCanvas().getLayeredCanvas());
+    }
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JPopupMenu jPopupMenu1;
+    // End of variables declaration//GEN-END:variables
+}
diff --git a/src/in/raster/mayam/form/ImageToolbar.form b/src/in/raster/mayam/form/ImageToolbar.form
new file mode 100644
index 0000000..6dc9fb3
--- /dev/null
+++ b/src/in/raster/mayam/form/ImageToolbar.form
@@ -0,0 +1,634 @@
+<?xml version="1.1" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+  <NonVisualComponents>
+    <Container class="javax.swing.JPopupMenu" name="jPopupMenu1">
+
+      <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
+        <Property name="useNullLayout" type="boolean" value="true"/>
+      </Layout>
+    </Container>
+    <Container class="javax.swing.JPopupMenu" name="jPopupMenu2">
+
+      <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
+        <Property name="useNullLayout" type="boolean" value="true"/>
+      </Layout>
+    </Container>
+    <Component class="javax.swing.ButtonGroup" name="toolsButtonGroup">
+    </Component>
+    <Container class="javax.swing.JPopupMenu" name="jPopupMenu3">
+
+      <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
+        <Property name="useNullLayout" type="boolean" value="true"/>
+      </Layout>
+    </Container>
+    <Container class="javax.swing.JPopupMenu" name="jPopupMenu4">
+
+      <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
+        <Property name="useNullLayout" type="boolean" value="true"/>
+      </Layout>
+    </Container>
+  </NonVisualComponents>
+  <Properties>
+    <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+      <Color blue="66" green="66" red="66" type="rgb"/>
+    </Property>
+  </Properties>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Component id="jToolBar3" alignment="0" pref="1151" max="32767" attributes="0"/>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Component id="jToolBar3" alignment="0" pref="59" max="32767" attributes="0"/>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Container class="javax.swing.JToolBar" name="jToolBar3">
+      <Properties>
+        <Property name="rollover" type="boolean" value="true"/>
+      </Properties>
+
+      <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/>
+      <SubComponents>
+        <Component class="javax.swing.JButton" name="layoutButton">
+          <Properties>
+            <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+              <Image iconType="3" name="/in/raster/mayam/form/images/layout.png"/>
+            </Property>
+            <Property name="toolTipText" type="java.lang.String" value="Layout"/>
+            <Property name="componentPopupMenu" type="javax.swing.JPopupMenu" editor="org.netbeans.modules.form.ComponentChooserEditor">
+              <ComponentRef name="jPopupMenu1"/>
+            </Property>
+            <Property name="focusable" type="boolean" value="false"/>
+            <Property name="horizontalTextPosition" type="int" value="0"/>
+            <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[45, 45]"/>
+            </Property>
+            <Property name="requestFocusEnabled" type="boolean" value="false"/>
+            <Property name="verticalTextPosition" type="int" value="3"/>
+          </Properties>
+          <Events>
+            <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="layoutButtonMouseClicked"/>
+          </Events>
+        </Component>
+        <Component class="javax.swing.JButton" name="windowing">
+          <Properties>
+            <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+              <Image iconType="3" name="/in/raster/mayam/form/images/windowing.png"/>
+            </Property>
+            <Property name="toolTipText" type="java.lang.String" value="Windowing"/>
+            <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
+              <ComponentRef name="toolsButtonGroup"/>
+            </Property>
+            <Property name="focusPainted" type="boolean" value="false"/>
+            <Property name="focusable" type="boolean" value="false"/>
+            <Property name="horizontalTextPosition" type="int" value="0"/>
+            <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[45, 45]"/>
+            </Property>
+            <Property name="requestFocusEnabled" type="boolean" value="false"/>
+            <Property name="verticalTextPosition" type="int" value="3"/>
+          </Properties>
+          <Events>
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="windowingActionPerformed"/>
+          </Events>
+        </Component>
+        <Component class="javax.swing.JButton" name="presetButton">
+          <Properties>
+            <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+              <Image iconType="3" name="/in/raster/mayam/form/images/drop_down.png"/>
+            </Property>
+            <Property name="toolTipText" type="java.lang.String" value="Preset"/>
+            <Property name="componentPopupMenu" type="javax.swing.JPopupMenu" editor="org.netbeans.modules.form.ComponentChooserEditor">
+              <ComponentRef name="jPopupMenu2"/>
+            </Property>
+            <Property name="focusable" type="boolean" value="false"/>
+            <Property name="horizontalTextPosition" type="int" value="0"/>
+            <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[12, 24]"/>
+            </Property>
+            <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[12, 24]"/>
+            </Property>
+            <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[45, 45]"/>
+            </Property>
+            <Property name="requestFocusEnabled" type="boolean" value="false"/>
+            <Property name="verticalTextPosition" type="int" value="3"/>
+          </Properties>
+          <Events>
+            <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="presetButtonMouseClicked"/>
+          </Events>
+        </Component>
+        <Component class="javax.swing.JComboBox" name="jComboBox1">
+          <Properties>
+            <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+              <Connection code="new WindowingComboModel(ApplicationContext.databaseRef.getPresets())" type="code"/>
+            </Property>
+            <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[20, 3]"/>
+            </Property>
+            <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[47, 3]"/>
+            </Property>
+          </Properties>
+          <Events>
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jComboBox1ActionPerformed"/>
+          </Events>
+        </Component>
+        <Component class="javax.swing.JButton" name="probeButton">
+          <Properties>
+            <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+              <Image iconType="3" name="/in/raster/mayam/form/images/probe.png"/>
+            </Property>
+            <Property name="toolTipText" type="java.lang.String" value="Probe"/>
+            <Property name="focusable" type="boolean" value="false"/>
+            <Property name="horizontalTextPosition" type="int" value="0"/>
+            <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[45, 45]"/>
+            </Property>
+            <Property name="requestFocusEnabled" type="boolean" value="false"/>
+            <Property name="verticalTextPosition" type="int" value="3"/>
+          </Properties>
+          <Events>
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="probeButtonActionPerformed"/>
+          </Events>
+        </Component>
+        <Component class="javax.swing.JButton" name="verticalFlip">
+          <Properties>
+            <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+              <Image iconType="3" name="/in/raster/mayam/form/images/flip_vertical.png"/>
+            </Property>
+            <Property name="toolTipText" type="java.lang.String" value="Vertical Flip"/>
+            <Property name="focusable" type="boolean" value="false"/>
+            <Property name="horizontalTextPosition" type="int" value="0"/>
+            <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[45, 45]"/>
+            </Property>
+            <Property name="verticalTextPosition" type="int" value="3"/>
+          </Properties>
+          <Events>
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="verticalFlipActionPerformed"/>
+          </Events>
+        </Component>
+        <Component class="javax.swing.JButton" name="horizontalFlip">
+          <Properties>
+            <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+              <Image iconType="3" name="/in/raster/mayam/form/images/flip_horizontal.png"/>
+            </Property>
+            <Property name="toolTipText" type="java.lang.String" value="Horizontal Flip"/>
+            <Property name="focusable" type="boolean" value="false"/>
+            <Property name="horizontalTextPosition" type="int" value="0"/>
+            <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[45, 45]"/>
+            </Property>
+            <Property name="requestFocusEnabled" type="boolean" value="false"/>
+            <Property name="verticalTextPosition" type="int" value="3"/>
+          </Properties>
+          <Events>
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="horizontalFlipActionPerformed"/>
+          </Events>
+        </Component>
+        <Component class="javax.swing.JButton" name="leftRotate">
+          <Properties>
+            <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+              <Image iconType="3" name="/in/raster/mayam/form/images/rotate_left.png"/>
+            </Property>
+            <Property name="toolTipText" type="java.lang.String" value="Rotate Left"/>
+            <Property name="focusable" type="boolean" value="false"/>
+            <Property name="horizontalTextPosition" type="int" value="0"/>
+            <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[45, 45]"/>
+            </Property>
+            <Property name="verticalTextPosition" type="int" value="3"/>
+          </Properties>
+          <Events>
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="leftRotateActionPerformed"/>
+          </Events>
+        </Component>
+        <Component class="javax.swing.JButton" name="rightRotate">
+          <Properties>
+            <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+              <Image iconType="3" name="/in/raster/mayam/form/images/rotate_right.png"/>
+            </Property>
+            <Property name="toolTipText" type="java.lang.String" value="Rotate Right"/>
+            <Property name="focusable" type="boolean" value="false"/>
+            <Property name="horizontalTextPosition" type="int" value="0"/>
+            <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[45, 45]"/>
+            </Property>
+            <Property name="verticalTextPosition" type="int" value="3"/>
+          </Properties>
+          <Events>
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="rightRotateActionPerformed"/>
+          </Events>
+        </Component>
+        <Component class="javax.swing.JButton" name="zoomin">
+          <Properties>
+            <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+              <Image iconType="3" name="/in/raster/mayam/form/images/zoomin.png"/>
+            </Property>
+            <Property name="toolTipText" type="java.lang.String" value="Zoom In"/>
+            <Property name="focusable" type="boolean" value="false"/>
+            <Property name="horizontalTextPosition" type="int" value="0"/>
+            <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[45, 45]"/>
+            </Property>
+            <Property name="verticalTextPosition" type="int" value="3"/>
+          </Properties>
+          <Events>
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="zoominActionPerformed"/>
+          </Events>
+        </Component>
+        <Component class="javax.swing.JButton" name="zoomoutButton">
+          <Properties>
+            <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+              <Image iconType="3" name="/in/raster/mayam/form/images/zoomout.png"/>
+            </Property>
+            <Property name="toolTipText" type="java.lang.String" value="Zoom Out"/>
+            <Property name="focusable" type="boolean" value="false"/>
+            <Property name="horizontalTextPosition" type="int" value="0"/>
+            <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[45, 45]"/>
+            </Property>
+            <Property name="verticalTextPosition" type="int" value="3"/>
+          </Properties>
+          <Events>
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="zoomoutButtonActionPerformed"/>
+          </Events>
+        </Component>
+        <Component class="javax.swing.JButton" name="panButton">
+          <Properties>
+            <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+              <Image iconType="3" name="/in/raster/mayam/form/images/pan.png"/>
+            </Property>
+            <Property name="toolTipText" type="java.lang.String" value="Pan"/>
+            <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
+              <ComponentRef name="toolsButtonGroup"/>
+            </Property>
+            <Property name="focusable" type="boolean" value="false"/>
+            <Property name="horizontalTextPosition" type="int" value="0"/>
+            <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[45, 45]"/>
+            </Property>
+            <Property name="requestFocusEnabled" type="boolean" value="false"/>
+            <Property name="verticalTextPosition" type="int" value="3"/>
+          </Properties>
+          <Events>
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="panButtonActionPerformed"/>
+          </Events>
+        </Component>
+        <Component class="javax.swing.JButton" name="invert">
+          <Properties>
+            <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+              <Image iconType="3" name="/in/raster/mayam/form/images/invert.png"/>
+            </Property>
+            <Property name="toolTipText" type="java.lang.String" value="Invert"/>
+            <Property name="focusable" type="boolean" value="false"/>
+            <Property name="horizontalTextPosition" type="int" value="0"/>
+            <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[45, 45]"/>
+            </Property>
+            <Property name="requestFocusEnabled" type="boolean" value="false"/>
+            <Property name="verticalTextPosition" type="int" value="3"/>
+          </Properties>
+          <Events>
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="invertActionPerformed"/>
+          </Events>
+        </Component>
+        <Component class="javax.swing.JButton" name="rulerButton">
+          <Properties>
+            <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+              <Image iconType="3" name="/in/raster/mayam/form/images/ruler.png"/>
+            </Property>
+            <Property name="toolTipText" type="java.lang.String" value="Ruler"/>
+            <Property name="actionCommand" type="java.lang.String" value="ruler"/>
+            <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
+              <ComponentRef name="toolsButtonGroup"/>
+            </Property>
+            <Property name="focusable" type="boolean" value="false"/>
+            <Property name="horizontalTextPosition" type="int" value="0"/>
+            <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[45, 45]"/>
+            </Property>
+            <Property name="requestFocusEnabled" type="boolean" value="false"/>
+            <Property name="verticalTextPosition" type="int" value="3"/>
+          </Properties>
+          <Events>
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="rulerButtonActionPerformed"/>
+          </Events>
+        </Component>
+        <Component class="javax.swing.JButton" name="rectangleButton">
+          <Properties>
+            <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+              <Image iconType="3" name="/in/raster/mayam/form/images/rectangle.png"/>
+            </Property>
+            <Property name="toolTipText" type="java.lang.String" value="Rectangle ROI"/>
+            <Property name="actionCommand" type="java.lang.String" value="rectangle"/>
+            <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
+              <ComponentRef name="toolsButtonGroup"/>
+            </Property>
+            <Property name="focusable" type="boolean" value="false"/>
+            <Property name="horizontalTextPosition" type="int" value="0"/>
+            <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[45, 45]"/>
+            </Property>
+            <Property name="requestFocusEnabled" type="boolean" value="false"/>
+            <Property name="verticalTextPosition" type="int" value="3"/>
+          </Properties>
+          <Events>
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="rectangleButtonActionPerformed"/>
+          </Events>
+        </Component>
+        <Component class="javax.swing.JButton" name="ellipseButton">
+          <Properties>
+            <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+              <Image iconType="3" name="/in/raster/mayam/form/images/ellipse.png"/>
+            </Property>
+            <Property name="toolTipText" type="java.lang.String" value="Elliptical ROI"/>
+            <Property name="actionCommand" type="java.lang.String" value="ellipse"/>
+            <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
+              <ComponentRef name="toolsButtonGroup"/>
+            </Property>
+            <Property name="focusable" type="boolean" value="false"/>
+            <Property name="horizontalTextPosition" type="int" value="0"/>
+            <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[45, 45]"/>
+            </Property>
+            <Property name="requestFocusEnabled" type="boolean" value="false"/>
+            <Property name="verticalTextPosition" type="int" value="3"/>
+          </Properties>
+          <Events>
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="ellipseButtonActionPerformed"/>
+          </Events>
+        </Component>
+        <Component class="javax.swing.JButton" name="clearAllMeasurement">
+          <Properties>
+            <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+              <Image iconType="3" name="/in/raster/mayam/form/images/clear_all_annotation.png"/>
+            </Property>
+            <Property name="toolTipText" type="java.lang.String" value="Clear All Measurement"/>
+            <Property name="actionCommand" type="java.lang.String" value="clearAll"/>
+            <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[45, 45]"/>
+            </Property>
+            <Property name="requestFocusEnabled" type="boolean" value="false"/>
+          </Properties>
+          <Events>
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="clearAllMeasurementActionPerformed"/>
+          </Events>
+        </Component>
+        <Component class="javax.swing.JButton" name="deleteMeasurement">
+          <Properties>
+            <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+              <Image iconType="3" name="/in/raster/mayam/form/images/delete_annotation.png"/>
+            </Property>
+            <Property name="toolTipText" type="java.lang.String" value="Delete Measurement"/>
+            <Property name="actionCommand" type="java.lang.String" value="deleteMeasurement"/>
+            <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
+              <ComponentRef name="toolsButtonGroup"/>
+            </Property>
+            <Property name="focusable" type="boolean" value="false"/>
+            <Property name="horizontalTextPosition" type="int" value="0"/>
+            <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[45, 45]"/>
+            </Property>
+            <Property name="requestFocusEnabled" type="boolean" value="false"/>
+            <Property name="verticalTextPosition" type="int" value="3"/>
+          </Properties>
+          <Events>
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="deleteMeasurementActionPerformed"/>
+          </Events>
+        </Component>
+        <Component class="javax.swing.JButton" name="moveMeasurement">
+          <Properties>
+            <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+              <Image iconType="3" name="/in/raster/mayam/form/images/annotation_selection.png"/>
+            </Property>
+            <Property name="toolTipText" type="java.lang.String" value="Measurement Selection"/>
+            <Property name="actionCommand" type="java.lang.String" value="moveMeasurement"/>
+            <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
+              <ComponentRef name="toolsButtonGroup"/>
+            </Property>
+            <Property name="doubleBuffered" type="boolean" value="true"/>
+            <Property name="focusable" type="boolean" value="false"/>
+            <Property name="horizontalTextPosition" type="int" value="0"/>
+            <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[45, 45]"/>
+            </Property>
+            <Property name="requestFocusEnabled" type="boolean" value="false"/>
+            <Property name="verticalTextPosition" type="int" value="3"/>
+          </Properties>
+          <Events>
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="moveMeasurementActionPerformed"/>
+          </Events>
+        </Component>
+        <Component class="javax.swing.JButton" name="annotationVisibility">
+          <Properties>
+            <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+              <Image iconType="3" name="/in/raster/mayam/form/images/annotation_overlay.png"/>
+            </Property>
+            <Property name="toolTipText" type="java.lang.String" value="Annotation Overlay"/>
+            <Property name="focusable" type="boolean" value="false"/>
+            <Property name="horizontalTextPosition" type="int" value="0"/>
+            <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[45, 45]"/>
+            </Property>
+            <Property name="verticalTextPosition" type="int" value="3"/>
+          </Properties>
+          <Events>
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="annotationVisibilityActionPerformed"/>
+          </Events>
+        </Component>
+        <Component class="javax.swing.JButton" name="textOverlay">
+          <Properties>
+            <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+              <Image iconType="3" name="/in/raster/mayam/form/images/textoverlay.png"/>
+            </Property>
+            <Property name="toolTipText" type="java.lang.String" value="Text Overlay"/>
+            <Property name="focusable" type="boolean" value="false"/>
+            <Property name="horizontalTextPosition" type="int" value="0"/>
+            <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[45, 45]"/>
+            </Property>
+            <Property name="verticalTextPosition" type="int" value="3"/>
+          </Properties>
+          <Events>
+            <EventHandler event="mousePressed" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="textOverlayMousePressed"/>
+          </Events>
+        </Component>
+        <Component class="javax.swing.JButton" name="reset">
+          <Properties>
+            <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+              <Image iconType="3" name="/in/raster/mayam/form/images/reset.png"/>
+            </Property>
+            <Property name="toolTipText" type="java.lang.String" value="Reset"/>
+            <Property name="focusable" type="boolean" value="false"/>
+            <Property name="horizontalTextPosition" type="int" value="0"/>
+            <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[45, 45]"/>
+            </Property>
+            <Property name="verticalTextPosition" type="int" value="3"/>
+          </Properties>
+          <Events>
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="resetActionPerformed"/>
+          </Events>
+        </Component>
+        <Component class="javax.swing.JButton" name="exportButton">
+          <Properties>
+            <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+              <Image iconType="3" name="/in/raster/mayam/form/images/export_series.png"/>
+            </Property>
+            <Property name="toolTipText" type="java.lang.String" value="Export"/>
+            <Property name="focusable" type="boolean" value="false"/>
+            <Property name="horizontalTextPosition" type="int" value="0"/>
+            <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[45, 45]"/>
+            </Property>
+            <Property name="verticalTextPosition" type="int" value="3"/>
+          </Properties>
+          <Events>
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="exportButtonActionPerformed"/>
+          </Events>
+        </Component>
+        <Component class="javax.swing.JButton" name="metaDataButton">
+          <Properties>
+            <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+              <Image iconType="3" name="/in/raster/mayam/form/images/metadata_viewerpage.png"/>
+            </Property>
+            <Property name="toolTipText" type="java.lang.String" value="Meta Data"/>
+            <Property name="focusable" type="boolean" value="false"/>
+            <Property name="horizontalTextPosition" type="int" value="0"/>
+            <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[45, 45]"/>
+            </Property>
+            <Property name="verticalTextPosition" type="int" value="3"/>
+          </Properties>
+          <Events>
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="metaDataButtonActionPerformed"/>
+          </Events>
+        </Component>
+        <Component class="javax.swing.JButton" name="stackButton">
+          <Properties>
+            <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+              <Image iconType="3" name="/in/raster/mayam/form/images/stack.png"/>
+            </Property>
+            <Property name="toolTipText" type="java.lang.String" value="Stack"/>
+            <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
+              <ComponentRef name="toolsButtonGroup"/>
+            </Property>
+            <Property name="focusable" type="boolean" value="false"/>
+            <Property name="horizontalTextPosition" type="int" value="0"/>
+            <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[45, 45]"/>
+            </Property>
+            <Property name="verticalTextPosition" type="int" value="3"/>
+          </Properties>
+          <Events>
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="stackButtonActionPerformed"/>
+          </Events>
+        </Component>
+        <Component class="javax.swing.JButton" name="scoutButton">
+          <Properties>
+            <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+              <Image iconType="3" name="/in/raster/mayam/form/images/scout.png"/>
+            </Property>
+            <Property name="toolTipText" type="java.lang.String" value="ScoutLine"/>
+            <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
+              <ComponentRef name="toolsButtonGroup"/>
+            </Property>
+            <Property name="focusable" type="boolean" value="false"/>
+            <Property name="horizontalTextPosition" type="int" value="0"/>
+            <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[45, 45]"/>
+            </Property>
+            <Property name="verticalTextPosition" type="int" value="3"/>
+          </Properties>
+          <Events>
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="scoutButtonActionPerformed"/>
+          </Events>
+        </Component>
+        <Component class="javax.swing.JButton" name="cube3DButton">
+          <Properties>
+            <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+              <Image iconType="3" name="/in/raster/mayam/form/images/Cube3D.png"/>
+            </Property>
+            <Property name="toolTipText" type="java.lang.String" value="3D"/>
+            <Property name="componentPopupMenu" type="javax.swing.JPopupMenu" editor="org.netbeans.modules.form.ComponentChooserEditor">
+              <ComponentRef name="jPopupMenu4"/>
+            </Property>
+            <Property name="focusable" type="boolean" value="false"/>
+            <Property name="horizontalTextPosition" type="int" value="0"/>
+            <Property name="verticalTextPosition" type="int" value="3"/>
+          </Properties>
+          <Events>
+            <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="cube3DButtonMouseClicked"/>
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cube3DButtonActionPerformed"/>
+          </Events>
+        </Component>
+        <Component class="javax.swing.JButton" name="synchronizeButton">
+          <Properties>
+            <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+              <Image iconType="3" name="/in/raster/mayam/form/images/Link.png"/>
+            </Property>
+            <Property name="toolTipText" type="java.lang.String" value="Synchronize"/>
+            <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
+              <ComponentRef name="toolsButtonGroup"/>
+            </Property>
+            <Property name="focusable" type="boolean" value="false"/>
+            <Property name="horizontalTextPosition" type="int" value="0"/>
+            <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[45, 45]"/>
+            </Property>
+            <Property name="verticalTextPosition" type="int" value="3"/>
+          </Properties>
+          <Events>
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="synchronizeButtonActionPerformed"/>
+          </Events>
+        </Component>
+        <Component class="javax.swing.JCheckBox" name="loopCheckbox">
+          <Properties>
+            <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+              <Font name="Lucida Grande" size="12" style="1"/>
+            </Property>
+            <Property name="text" type="java.lang.String" value="Loop"/>
+            <Property name="focusable" type="boolean" value="false"/>
+            <Property name="horizontalTextPosition" type="int" value="4"/>
+            <Property name="verticalTextPosition" type="int" value="3"/>
+          </Properties>
+          <Events>
+            <EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="loopCheckboxStateChanged"/>
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="loopCheckboxActionPerformed"/>
+          </Events>
+        </Component>
+        <Component class="javax.swing.JSlider" name="loopSlider">
+          <Properties>
+            <Property name="maximum" type="int" value="9"/>
+            <Property name="paintTicks" type="boolean" value="true"/>
+            <Property name="value" type="int" value="6"/>
+            <Property name="doubleBuffered" type="boolean" value="true"/>
+          </Properties>
+          <Events>
+            <EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="loopSliderStateChanged"/>
+          </Events>
+        </Component>
+      </SubComponents>
+    </Container>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/ImageToolbar.java b/src/in/raster/mayam/form/ImageToolbar.java
new file mode 100644
index 0000000..8f8bf55
--- /dev/null
+++ b/src/in/raster/mayam/form/ImageToolbar.java
@@ -0,0 +1,1645 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.delegate.LocalizerDelegate;
+import in.raster.mayam.form.dialog.ExportDialog;
+import in.raster.mayam.util.DicomTags;
+import in.raster.mayam.util.DicomTagsReader;
+import in.raster.mayam.form.display.Display;
+import in.raster.mayam.delegate.CineTimer;
+import in.raster.mayam.delegate.DestinationFinder;
+import in.raster.mayam.form.dcm3d.DicomMIP;
+import in.raster.mayam.form.dcm3d.DicomMPR2D;
+import in.raster.mayam.form.dcm3d.DicomMPR3DSlider;
+import in.raster.mayam.form.dcm3d.DicomVolumeRendering;
+import in.raster.mayam.form.dcm3d.SurfaceRendering;
+import in.raster.mayam.model.Instance;
+import in.raster.mayam.model.PresetModel;
+import in.raster.mayam.model.Series;
+import in.raster.mayam.model.Study;
+import in.raster.mayam.model.combo.WindowingComboModel;
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.Graphics;
+import java.awt.GridLayout;
+import java.awt.KeyEventDispatcher;
+import java.awt.KeyboardFocusManager;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseEvent;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Timer;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class ImageToolbar extends javax.swing.JPanel {
+
+    /** Creates new form ImageToolbar */
+    CineTimer cineTimer;
+    Timer timer;
+    ImageView imgView;
+    SurfaceRendering surface = null;
+    DicomMIP dcmMip = null;
+    DicomMPR2D dcmMPR2D = null;
+    DicomMPR3DSlider mpr3DSlider = null;
+    DicomVolumeRendering dicomVolumeRendering = null;
+
+    public ImageToolbar() {
+        initComponents();
+        cineTimer = new CineTimer();
+        addKeyEventDispatcher();
+    }
+
+    public ImageToolbar(ImageView imgView) {
+        initComponents();
+        cineTimer = new CineTimer();
+        this.imgView = imgView;
+        designPopup();
+        textOverlayContext();
+        // presetButton.setVisible(false);
+        jComboBox1.setVisible(false);
+        addKeyEventDispatcher();
+    }
+
+    public void addKeyEventDispatcher() {
+        KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(new KeyEventDispatcher() {
+
+            public boolean dispatchKeyEvent(KeyEvent e) {
+                if (e.getID() == KeyEvent.KEY_PRESSED) {
+                    if (!ApplicationContext.mainScreen.getQueryScreen().isFocused()) {
+                        boolean status = false;
+                        if (ApplicationContext.mainScreen.getPreference() != null) {
+                            status = ApplicationContext.mainScreen.getPreference().isFocused();
+                        }
+                        if (!status) {
+
+                            keyEventProcessor(e);
+                        }
+                    }
+                }
+                boolean discardEvent = false;
+                return discardEvent;
+            }
+        });
+    }
+
+    private void keyEventProcessor(KeyEvent e) {
+        if (e.getKeyCode() == KeyEvent.VK_UP || e.getKeyCode() == KeyEvent.VK_LEFT) {
+            ApplicationContext.imgPanel.moveToPreviousInstance();
+        } else if (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_RIGHT) {
+            ApplicationContext.imgPanel.moveToNextInstance();
+        } else if (e.getKeyCode() == KeyEvent.VK_O) {
+            doScout();
+        } else if (e.getKeyCode() == KeyEvent.VK_I) {
+            doTextOverlay();
+        } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
+            doReset();
+        } else if (e.getKeyCode() == KeyEvent.VK_C) {
+            if (!loopCheckbox.isSelected()) {
+                loopCheckbox.setSelected(true);
+            } else {
+                loopCheckbox.setSelected(false);
+            }
+            doCineLoop();
+        } else if (e.getKeyCode() == KeyEvent.VK_S) {
+            doStack();
+        } else if (e.getKeyCode() == KeyEvent.VK_D) {
+            doRuler();
+        } else if (e.getKeyCode() == KeyEvent.VK_T) {
+            doPan();
+        }
+    }
+
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        jPopupMenu1 = new javax.swing.JPopupMenu();
+        jPopupMenu2 = new javax.swing.JPopupMenu();
+        toolsButtonGroup = new javax.swing.ButtonGroup();
+        jPopupMenu3 = new javax.swing.JPopupMenu();
+        jPopupMenu4 = new javax.swing.JPopupMenu();
+        jToolBar3 = new javax.swing.JToolBar();
+        layoutButton = new javax.swing.JButton();
+        windowing = new javax.swing.JButton();
+        presetButton = new javax.swing.JButton();
+        jComboBox1 = new javax.swing.JComboBox();
+        probeButton = new javax.swing.JButton();
+        verticalFlip = new javax.swing.JButton();
+        horizontalFlip = new javax.swing.JButton();
+        leftRotate = new javax.swing.JButton();
+        rightRotate = new javax.swing.JButton();
+        zoomin = new javax.swing.JButton();
+        zoomoutButton = new javax.swing.JButton();
+        panButton = new javax.swing.JButton();
+        invert = new javax.swing.JButton();
+        rulerButton = new javax.swing.JButton();
+        rectangleButton = new javax.swing.JButton();
+        ellipseButton = new javax.swing.JButton();
+        clearAllMeasurement = new javax.swing.JButton();
+        deleteMeasurement = new javax.swing.JButton();
+        moveMeasurement = new javax.swing.JButton();
+        annotationVisibility = new javax.swing.JButton();
+        textOverlay = new javax.swing.JButton();
+        reset = new javax.swing.JButton();
+        exportButton = new javax.swing.JButton();
+        metaDataButton = new javax.swing.JButton();
+        stackButton = new javax.swing.JButton();
+        scoutButton = new javax.swing.JButton();
+        cube3DButton = new javax.swing.JButton();
+        synchronizeButton = new javax.swing.JButton();
+        loopCheckbox = new javax.swing.JCheckBox();
+        loopSlider = new javax.swing.JSlider();
+
+        setBackground(new java.awt.Color(102, 102, 102));
+
+        jToolBar3.setRollover(true);
+
+        layoutButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/layout.png"))); // NOI18N
+        layoutButton.setToolTipText("Layout");
+        layoutButton.setComponentPopupMenu(jPopupMenu1);
+        layoutButton.setFocusable(false);
+        layoutButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+        layoutButton.setPreferredSize(new java.awt.Dimension(45, 45));
+        layoutButton.setRequestFocusEnabled(false);
+        layoutButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        layoutButton.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                layoutButtonMouseClicked(evt);
+            }
+        });
+        jToolBar3.add(layoutButton);
+
+        windowing.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/windowing.png"))); // NOI18N
+        windowing.setToolTipText("Windowing");
+        toolsButtonGroup.add(windowing);
+        windowing.setFocusPainted(false);
+        windowing.setFocusable(false);
+        windowing.setHorizontalTextPosition(0);
+        windowing.setPreferredSize(new java.awt.Dimension(45, 45));
+        windowing.setRequestFocusEnabled(false);
+        windowing.setVerticalTextPosition(3);
+        windowing.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                windowingActionPerformed(evt);
+            }
+        });
+        jToolBar3.add(windowing);
+
+        presetButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/drop_down.png"))); // NOI18N
+        presetButton.setToolTipText("Preset");
+        presetButton.setComponentPopupMenu(jPopupMenu2);
+        presetButton.setFocusable(false);
+        presetButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+        presetButton.setMaximumSize(new java.awt.Dimension(12, 24));
+        presetButton.setMinimumSize(new java.awt.Dimension(12, 24));
+        presetButton.setPreferredSize(new java.awt.Dimension(45, 45));
+        presetButton.setRequestFocusEnabled(false);
+        presetButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        presetButton.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                presetButtonMouseClicked(evt);
+            }
+        });
+        jToolBar3.add(presetButton);
+
+        jComboBox1.setModel(new WindowingComboModel(ApplicationContext.databaseRef.getPresets()));
+        jComboBox1.setMinimumSize(new java.awt.Dimension(20, 3));
+        jComboBox1.setPreferredSize(new java.awt.Dimension(47, 3));
+        jComboBox1.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                jComboBox1ActionPerformed(evt);
+            }
+        });
+        jToolBar3.add(jComboBox1);
+
+        probeButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/probe.png"))); // NOI18N
+        probeButton.setToolTipText("Probe");
+        probeButton.setFocusable(false);
+        probeButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+        probeButton.setPreferredSize(new java.awt.Dimension(45, 45));
+        probeButton.setRequestFocusEnabled(false);
+        probeButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        probeButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                probeButtonActionPerformed(evt);
+            }
+        });
+        jToolBar3.add(probeButton);
+
+        verticalFlip.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/flip_vertical.png"))); // NOI18N
+        verticalFlip.setToolTipText("Vertical Flip");
+        verticalFlip.setFocusable(false);
+        verticalFlip.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+        verticalFlip.setPreferredSize(new java.awt.Dimension(45, 45));
+        verticalFlip.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        verticalFlip.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                verticalFlipActionPerformed(evt);
+            }
+        });
+        jToolBar3.add(verticalFlip);
+
+        horizontalFlip.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/flip_horizontal.png"))); // NOI18N
+        horizontalFlip.setToolTipText("Horizontal Flip");
+        horizontalFlip.setFocusable(false);
+        horizontalFlip.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+        horizontalFlip.setPreferredSize(new java.awt.Dimension(45, 45));
+        horizontalFlip.setRequestFocusEnabled(false);
+        horizontalFlip.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        horizontalFlip.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                horizontalFlipActionPerformed(evt);
+            }
+        });
+        jToolBar3.add(horizontalFlip);
+
+        leftRotate.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/rotate_left.png"))); // NOI18N
+        leftRotate.setToolTipText("Rotate Left");
+        leftRotate.setFocusable(false);
+        leftRotate.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+        leftRotate.setPreferredSize(new java.awt.Dimension(45, 45));
+        leftRotate.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        leftRotate.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                leftRotateActionPerformed(evt);
+            }
+        });
+        jToolBar3.add(leftRotate);
+
+        rightRotate.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/rotate_right.png"))); // NOI18N
+        rightRotate.setToolTipText("Rotate Right");
+        rightRotate.setFocusable(false);
+        rightRotate.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+        rightRotate.setPreferredSize(new java.awt.Dimension(45, 45));
+        rightRotate.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        rightRotate.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                rightRotateActionPerformed(evt);
+            }
+        });
+        jToolBar3.add(rightRotate);
+
+        zoomin.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/zoomin.png"))); // NOI18N
+        zoomin.setToolTipText("Zoom In");
+        zoomin.setFocusable(false);
+        zoomin.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+        zoomin.setPreferredSize(new java.awt.Dimension(45, 45));
+        zoomin.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        zoomin.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                zoominActionPerformed(evt);
+            }
+        });
+        jToolBar3.add(zoomin);
+
+        zoomoutButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/zoomout.png"))); // NOI18N
+        zoomoutButton.setToolTipText("Zoom Out");
+        zoomoutButton.setFocusable(false);
+        zoomoutButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+        zoomoutButton.setPreferredSize(new java.awt.Dimension(45, 45));
+        zoomoutButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        zoomoutButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                zoomoutButtonActionPerformed(evt);
+            }
+        });
+        jToolBar3.add(zoomoutButton);
+
+        panButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/pan.png"))); // NOI18N
+        panButton.setToolTipText("Pan");
+        toolsButtonGroup.add(panButton);
+        panButton.setFocusable(false);
+        panButton.setHorizontalTextPosition(0);
+        panButton.setPreferredSize(new java.awt.Dimension(45, 45));
+        panButton.setRequestFocusEnabled(false);
+        panButton.setVerticalTextPosition(3);
+        panButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                panButtonActionPerformed(evt);
+            }
+        });
+        jToolBar3.add(panButton);
+
+        invert.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/invert.png"))); // NOI18N
+        invert.setToolTipText("Invert");
+        invert.setFocusable(false);
+        invert.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+        invert.setPreferredSize(new java.awt.Dimension(45, 45));
+        invert.setRequestFocusEnabled(false);
+        invert.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        invert.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                invertActionPerformed(evt);
+            }
+        });
+        jToolBar3.add(invert);
+
+        rulerButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/ruler.png"))); // NOI18N
+        rulerButton.setToolTipText("Ruler");
+        rulerButton.setActionCommand("ruler");
+        toolsButtonGroup.add(rulerButton);
+        rulerButton.setFocusable(false);
+        rulerButton.setHorizontalTextPosition(0);
+        rulerButton.setPreferredSize(new java.awt.Dimension(45, 45));
+        rulerButton.setRequestFocusEnabled(false);
+        rulerButton.setVerticalTextPosition(3);
+        rulerButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                rulerButtonActionPerformed(evt);
+            }
+        });
+        jToolBar3.add(rulerButton);
+
+        rectangleButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/rectangle.png"))); // NOI18N
+        rectangleButton.setToolTipText("Rectangle ROI");
+        rectangleButton.setActionCommand("rectangle");
+        toolsButtonGroup.add(rectangleButton);
+        rectangleButton.setFocusable(false);
+        rectangleButton.setHorizontalTextPosition(0);
+        rectangleButton.setPreferredSize(new java.awt.Dimension(45, 45));
+        rectangleButton.setRequestFocusEnabled(false);
+        rectangleButton.setVerticalTextPosition(3);
+        rectangleButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                rectangleButtonActionPerformed(evt);
+            }
+        });
+        jToolBar3.add(rectangleButton);
+
+        ellipseButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/ellipse.png"))); // NOI18N
+        ellipseButton.setToolTipText("Elliptical ROI");
+        ellipseButton.setActionCommand("ellipse");
+        toolsButtonGroup.add(ellipseButton);
+        ellipseButton.setFocusable(false);
+        ellipseButton.setHorizontalTextPosition(0);
+        ellipseButton.setPreferredSize(new java.awt.Dimension(45, 45));
+        ellipseButton.setRequestFocusEnabled(false);
+        ellipseButton.setVerticalTextPosition(3);
+        ellipseButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                ellipseButtonActionPerformed(evt);
+            }
+        });
+        jToolBar3.add(ellipseButton);
+
+        clearAllMeasurement.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/clear_all_annotation.png"))); // NOI18N
+        clearAllMeasurement.setToolTipText("Clear All Measurement");
+        clearAllMeasurement.setActionCommand("clearAll");
+        clearAllMeasurement.setPreferredSize(new java.awt.Dimension(45, 45));
+        clearAllMeasurement.setRequestFocusEnabled(false);
+        clearAllMeasurement.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                clearAllMeasurementActionPerformed(evt);
+            }
+        });
+        jToolBar3.add(clearAllMeasurement);
+
+        deleteMeasurement.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/delete_annotation.png"))); // NOI18N
+        deleteMeasurement.setToolTipText("Delete Measurement");
+        deleteMeasurement.setActionCommand("deleteMeasurement");
+        toolsButtonGroup.add(deleteMeasurement);
+        deleteMeasurement.setFocusable(false);
+        deleteMeasurement.setHorizontalTextPosition(0);
+        deleteMeasurement.setPreferredSize(new java.awt.Dimension(45, 45));
+        deleteMeasurement.setRequestFocusEnabled(false);
+        deleteMeasurement.setVerticalTextPosition(3);
+        deleteMeasurement.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                deleteMeasurementActionPerformed(evt);
+            }
+        });
+        jToolBar3.add(deleteMeasurement);
+
+        moveMeasurement.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/annotation_selection.png"))); // NOI18N
+        moveMeasurement.setToolTipText("Measurement Selection");
+        moveMeasurement.setActionCommand("moveMeasurement");
+        toolsButtonGroup.add(moveMeasurement);
+        moveMeasurement.setDoubleBuffered(true);
+        moveMeasurement.setFocusable(false);
+        moveMeasurement.setHorizontalTextPosition(0);
+        moveMeasurement.setPreferredSize(new java.awt.Dimension(45, 45));
+        moveMeasurement.setRequestFocusEnabled(false);
+        moveMeasurement.setVerticalTextPosition(3);
+        moveMeasurement.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                moveMeasurementActionPerformed(evt);
+            }
+        });
+        jToolBar3.add(moveMeasurement);
+
+        annotationVisibility.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/annotation_overlay.png"))); // NOI18N
+        annotationVisibility.setToolTipText("Annotation Overlay");
+        annotationVisibility.setFocusable(false);
+        annotationVisibility.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+        annotationVisibility.setPreferredSize(new java.awt.Dimension(45, 45));
+        annotationVisibility.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        annotationVisibility.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                annotationVisibilityActionPerformed(evt);
+            }
+        });
+        jToolBar3.add(annotationVisibility);
+
+        textOverlay.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/textoverlay.png"))); // NOI18N
+        textOverlay.setToolTipText("Text Overlay");
+        textOverlay.setFocusable(false);
+        textOverlay.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+        textOverlay.setPreferredSize(new java.awt.Dimension(45, 45));
+        textOverlay.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        textOverlay.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mousePressed(java.awt.event.MouseEvent evt) {
+                textOverlayMousePressed(evt);
+            }
+        });
+        jToolBar3.add(textOverlay);
+
+        reset.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/reset.png"))); // NOI18N
+        reset.setToolTipText("Reset");
+        reset.setFocusable(false);
+        reset.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+        reset.setPreferredSize(new java.awt.Dimension(45, 45));
+        reset.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        reset.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                resetActionPerformed(evt);
+            }
+        });
+        jToolBar3.add(reset);
+
+        exportButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/export_series.png"))); // NOI18N
+        exportButton.setToolTipText("Export");
+        exportButton.setFocusable(false);
+        exportButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+        exportButton.setPreferredSize(new java.awt.Dimension(45, 45));
+        exportButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        exportButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                exportButtonActionPerformed(evt);
+            }
+        });
+        jToolBar3.add(exportButton);
+
+        metaDataButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/metadata_viewerpage.png"))); // NOI18N
+        metaDataButton.setToolTipText("Meta Data");
+        metaDataButton.setFocusable(false);
+        metaDataButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+        metaDataButton.setPreferredSize(new java.awt.Dimension(45, 45));
+        metaDataButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        metaDataButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                metaDataButtonActionPerformed(evt);
+            }
+        });
+        jToolBar3.add(metaDataButton);
+
+        stackButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/stack.png"))); // NOI18N
+        stackButton.setToolTipText("Stack");
+        toolsButtonGroup.add(stackButton);
+        stackButton.setFocusable(false);
+        stackButton.setHorizontalTextPosition(0);
+        stackButton.setPreferredSize(new java.awt.Dimension(45, 45));
+        stackButton.setVerticalTextPosition(3);
+        stackButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                stackButtonActionPerformed(evt);
+            }
+        });
+        jToolBar3.add(stackButton);
+
+        scoutButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/scout.png"))); // NOI18N
+        scoutButton.setToolTipText("ScoutLine");
+        toolsButtonGroup.add(scoutButton);
+        scoutButton.setFocusable(false);
+        scoutButton.setHorizontalTextPosition(0);
+        scoutButton.setPreferredSize(new java.awt.Dimension(45, 45));
+        scoutButton.setVerticalTextPosition(3);
+        scoutButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                scoutButtonActionPerformed(evt);
+            }
+        });
+        jToolBar3.add(scoutButton);
+
+        cube3DButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/Cube3D.png"))); // NOI18N
+        cube3DButton.setToolTipText("3D");
+        cube3DButton.setComponentPopupMenu(jPopupMenu4);
+        cube3DButton.setFocusable(false);
+        cube3DButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+        cube3DButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        cube3DButton.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                cube3DButtonMouseClicked(evt);
+            }
+        });
+        cube3DButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                cube3DButtonActionPerformed(evt);
+            }
+        });
+        jToolBar3.add(cube3DButton);
+
+        synchronizeButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/Link.png"))); // NOI18N
+        synchronizeButton.setToolTipText("Synchronize");
+        toolsButtonGroup.add(synchronizeButton);
+        synchronizeButton.setFocusable(false);
+        synchronizeButton.setHorizontalTextPosition(0);
+        synchronizeButton.setPreferredSize(new java.awt.Dimension(45, 45));
+        synchronizeButton.setVerticalTextPosition(3);
+        synchronizeButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                synchronizeButtonActionPerformed(evt);
+            }
+        });
+        jToolBar3.add(synchronizeButton);
+
+        loopCheckbox.setFont(new java.awt.Font("Lucida Grande", 1, 12));
+        loopCheckbox.setText("Loop");
+        loopCheckbox.setFocusable(false);
+        loopCheckbox.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
+        loopCheckbox.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        loopCheckbox.addChangeListener(new javax.swing.event.ChangeListener() {
+            public void stateChanged(javax.swing.event.ChangeEvent evt) {
+                loopCheckboxStateChanged(evt);
+            }
+        });
+        loopCheckbox.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                loopCheckboxActionPerformed(evt);
+            }
+        });
+        jToolBar3.add(loopCheckbox);
+
+        loopSlider.setMaximum(9);
+        loopSlider.setPaintTicks(true);
+        loopSlider.setValue(6);
+        loopSlider.setDoubleBuffered(true);
+        loopSlider.addChangeListener(new javax.swing.event.ChangeListener() {
+            public void stateChanged(javax.swing.event.ChangeEvent evt) {
+                loopSliderStateChanged(evt);
+            }
+        });
+        jToolBar3.add(loopSlider);
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
+        this.setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(jToolBar3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 1151, Short.MAX_VALUE)
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(jToolBar3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 59, Short.MAX_VALUE)
+        );
+    }// </editor-fold>//GEN-END:initComponents
+
+    private void rightRotateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rightRotateActionPerformed
+        if (ApplicationContext.annotationPanel != null && ApplicationContext.imgPanel != null) {
+            ApplicationContext.imgPanel.rotateRight();
+            ApplicationContext.annotationPanel.doRotateRight();
+        } else {
+            JOptionPane.showMessageDialog(this, "Tile selected is not valid for this process");
+        }
+}//GEN-LAST:event_rightRotateActionPerformed
+
+    private void leftRotateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_leftRotateActionPerformed
+        if (ApplicationContext.annotationPanel != null && ApplicationContext.imgPanel != null) {
+            ApplicationContext.imgPanel.rotateLeft();
+            ApplicationContext.annotationPanel.doRotateLeft();
+        } else {
+            JOptionPane.showMessageDialog(ImageToolbar.this, "Tile selected is not valid for this process");
+        }
+}//GEN-LAST:event_leftRotateActionPerformed
+
+    private void invertActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_invertActionPerformed
+        if (ApplicationContext.annotationPanel != null && ApplicationContext.imgPanel != null) {
+            ApplicationContext.imgPanel.negative();
+
+        } else {
+            JOptionPane.showMessageDialog(ImageToolbar.this, "Tile selected is not valid for this process");
+        }
+}//GEN-LAST:event_invertActionPerformed
+
+    private void horizontalFlipActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_horizontalFlipActionPerformed
+        if (ApplicationContext.annotationPanel != null && ApplicationContext.imgPanel != null) {
+            ApplicationContext.imgPanel.flipHorizontal();
+            ApplicationContext.annotationPanel.doFlipHorizontal();
+            ApplicationContext.imgPanel.repaint();
+            ApplicationContext.layeredCanvas.textOverlay.repaint();
+        } else {
+            JOptionPane.showMessageDialog(ImageToolbar.this, "Tile selected is not valid for this process");
+        }
+}//GEN-LAST:event_horizontalFlipActionPerformed
+
+    private void verticalFlipActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_verticalFlipActionPerformed
+        if (ApplicationContext.annotationPanel != null && ApplicationContext.imgPanel != null) {
+            ApplicationContext.imgPanel.flipVertical();
+            ApplicationContext.annotationPanel.doFlipVertical();
+            ApplicationContext.imgPanel.repaint();
+            ApplicationContext.layeredCanvas.textOverlay.repaint();
+        } else {
+            JOptionPane.showMessageDialog(ImageToolbar.this, "Tile selected is not valid for this process");
+        }
+}//GEN-LAST:event_verticalFlipActionPerformed
+
+    private void windowingActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_windowingActionPerformed
+        setWindowingTool();
+}//GEN-LAST:event_windowingActionPerformed
+
+    private void zoominActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_zoominActionPerformed
+        if (ApplicationContext.annotationPanel != null && ApplicationContext.imgPanel != null) {
+            resetTools();
+            ApplicationContext.imgPanel.doZoomIn();
+            ApplicationContext.annotationPanel.doZoomIn();
+            ApplicationContext.imgPanel.repaint();
+        } else {
+            JOptionPane.showMessageDialog(ImageToolbar.this, "Tile selected is not valid for this process");
+        }
+    }//GEN-LAST:event_zoominActionPerformed
+
+    private void resetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_resetActionPerformed
+        doReset();
+}//GEN-LAST:event_resetActionPerformed
+
+    public void doReset() {
+        if (ApplicationContext.annotationPanel != null && ApplicationContext.imgPanel != null) {
+            ApplicationContext.imgPanel.reset();
+            ApplicationContext.annotationPanel.reset();
+            setWindowing();
+            // ApplicationContext.annotationPanel.clearAllMeasurement();
+        } else {
+            JOptionPane.showMessageDialog(ImageToolbar.this, "Tile selected is not valid for this process");
+        }
+    }
+    private void probeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_probeButtonActionPerformed
+        if (ApplicationContext.annotationPanel != null && ApplicationContext.imgPanel != null) {
+            ApplicationContext.annotationPanel.setAddLine(false);
+            ApplicationContext.annotationPanel.setAddEllipse(false);
+            ApplicationContext.annotationPanel.setAddRect(false);
+            ApplicationContext.annotationPanel.stopPanning();
+            ApplicationContext.imgPanel.probe();
+        } else {
+            JOptionPane.showMessageDialog(ImageToolbar.this, "Tile selected is not valid for this process");
+        }
+}//GEN-LAST:event_probeButtonActionPerformed
+
+    private void panButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_panButtonActionPerformed
+        doPan();
+    }//GEN-LAST:event_panButtonActionPerformed
+
+    public void doPan() {
+        toolsButtonGroup.clearSelection();
+        if (ApplicationContext.annotationPanel != null && ApplicationContext.imgPanel != null) {
+            ApplicationContext.annotationPanel.setAddLine(false);
+            ApplicationContext.annotationPanel.setAddEllipse(false);
+            ApplicationContext.annotationPanel.setAddRect(false);
+            ApplicationContext.imgPanel.doPan();
+            ApplicationContext.annotationPanel.doPan();
+            toolsButtonGroup.setSelected(panButton.getModel(), true);
+        } else {
+            JOptionPane.showMessageDialog(ImageToolbar.this, "Tile selected is not valid for this process");
+        }
+    }
+    private void zoomoutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_zoomoutButtonActionPerformed
+        if (ApplicationContext.annotationPanel != null && ApplicationContext.imgPanel != null) {
+            resetTools();
+            ApplicationContext.imgPanel.doZoomOut();
+            ApplicationContext.annotationPanel.doZoomOut();
+            ApplicationContext.imgPanel.repaint();
+        } else {
+            JOptionPane.showMessageDialog(ImageToolbar.this, "Tile selected is not valid for this process");
+        }
+}//GEN-LAST:event_zoomoutButtonActionPerformed
+    private void resetTools() {
+        if (ApplicationContext.annotationPanel != null && ApplicationContext.imgPanel != null) {
+            ApplicationContext.annotationPanel.setMouseLocX1(-1);
+        } else {
+            JOptionPane.showMessageDialog(ImageToolbar.this, "Tile selected is not valid for this process");
+        }
+    }
+    private void rulerButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rulerButtonActionPerformed
+
+        doRuler();
+}//GEN-LAST:event_rulerButtonActionPerformed
+
+    public void doRuler() {
+        if (ApplicationContext.annotationPanel != null && ApplicationContext.imgPanel != null) {
+            ApplicationContext.annotationPanel.stopPanning();
+            ApplicationContext.imgPanel.setToolsToNull();
+            ApplicationContext.annotationPanel.setMouseLocX1(-1);
+            toolsButtonGroup.clearSelection();
+            if (!ApplicationContext.annotationPanel.isAddLine()) {
+                ApplicationContext.annotationPanel.setAddLine(true);
+                ApplicationContext.annotationPanel.setAddEllipse(false);
+                ApplicationContext.annotationPanel.setAddRect(false);
+            } else {
+                ApplicationContext.annotationPanel.setAddLine(false);
+            }
+            toolsButtonGroup.setSelected(rulerButton.getModel(), true);
+        } else {
+            JOptionPane.showMessageDialog(ImageToolbar.this, "Tile selected is not valid for this process");
+        }
+    }
+
+    public void refreshToolsDisplay() {
+        if (!windowing.isEnabled()) {
+            enableAllTools();
+        } else {
+            setAnnotationToolsStatus();
+            layoutToolStatus();
+        }
+    }
+
+    private void layoutToolStatus() {
+        if (ApplicationContext.imgPanel.getCanvas().getLayeredCanvas().getComparedWithStudies() != null) {
+            layoutButton.setEnabled(false);
+        } else {
+            layoutButton.setEnabled(true);
+        }
+    }
+
+    private void enableAllTools() {
+        layoutToolStatus();
+        windowing.setEnabled(true);
+        presetButton.setEnabled(true);
+        probeButton.setEnabled(true);
+        verticalFlip.setEnabled(true);
+        horizontalFlip.setEnabled(true);
+        leftRotate.setEnabled(true);
+        rightRotate.setEnabled(true);
+        zoomin.setEnabled(true);
+        zoomoutButton.setEnabled(true);
+        panButton.setEnabled(true);
+        invert.setEnabled(true);
+        annotationVisibility.setEnabled(true);
+        textOverlay.setEnabled(true);
+        reset.setEnabled(true);
+        exportButton.setEnabled(true);
+        metaDataButton.setEnabled(true);
+        stackButton.setEnabled(true);
+        scoutButton.setEnabled(true);
+        cube3DButton.setEnabled(true);
+        synchronizeButton.setEnabled(true);
+        setAnnotationToolsStatus();
+    }
+
+    public void disableAllTools() {
+        layoutButton.setEnabled(false);
+        windowing.setEnabled(false);
+        presetButton.setEnabled(false);
+        probeButton.setEnabled(false);
+        verticalFlip.setEnabled(false);
+        horizontalFlip.setEnabled(false);
+        leftRotate.setEnabled(false);
+        rightRotate.setEnabled(false);
+        zoomin.setEnabled(false);
+        zoomoutButton.setEnabled(false);
+        panButton.setEnabled(false);
+        invert.setEnabled(false);
+        rulerButton.setEnabled(false);
+        rectangleButton.setEnabled(false);
+        ellipseButton.setEnabled(false);
+        clearAllMeasurement.setEnabled(false);
+        deleteMeasurement.setEnabled(false);
+        moveMeasurement.setEnabled(false);
+        annotationVisibility.setEnabled(false);
+        textOverlay.setEnabled(false);
+        reset.setEnabled(false);
+        exportButton.setEnabled(false);
+        metaDataButton.setEnabled(false);
+        stackButton.setEnabled(false);
+        scoutButton.setEnabled(false);
+        cube3DButton.setEnabled(false);
+        synchronizeButton.setEnabled(false);
+    }
+    private void stackButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stackButtonActionPerformed
+        doStack();
+}//GEN-LAST:event_stackButtonActionPerformed
+
+    public void doStack() {
+        toolsButtonGroup.clearSelection();
+        if (ApplicationContext.annotationPanel != null && ApplicationContext.imgPanel != null) {
+            ApplicationContext.annotationPanel.stopPanning();
+            storeAnnotationHook();
+            ApplicationContext.annotationPanel.setAddLine(false);
+            ApplicationContext.annotationPanel.setAddEllipse(false);
+            ApplicationContext.annotationPanel.setAddRect(false);
+            ApplicationContext.imgPanel.doStack();
+            ApplicationContext.imgPanel.repaint();
+            if (ApplicationContext.imgPanel.isStackSelected()) {
+                toolsButtonGroup.setSelected(stackButton.getModel(), true);
+            }
+        } else {
+            JOptionPane.showMessageDialog(ImageToolbar.this, "Tile selected is not valid for this process");
+        }
+    }
+    private void loopSliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_loopSliderStateChanged
+
+        try {
+            if (ApplicationContext.annotationPanel != null && ApplicationContext.imgPanel != null) {
+                if (loopCheckbox.isSelected()) {
+                    if (timer != null) {
+                        timer.cancel();
+                        timer = new Timer();
+                        timer.scheduleAtFixedRate(new CineTimer(), 0, (11 - loopSlider.getValue()) * 100);//
+
+                    } else {
+                        timer = new Timer();
+                        timer.scheduleAtFixedRate(new CineTimer(), 0, (11 - loopSlider.getValue()) * 100);//
+                    }
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+
+
+}//GEN-LAST:event_loopSliderStateChanged
+
+    private void loopCheckboxStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_loopCheckboxStateChanged
+}//GEN-LAST:event_loopCheckboxStateChanged
+
+    private void loopCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loopCheckboxActionPerformed
+        doCineLoop();
+}//GEN-LAST:event_loopCheckboxActionPerformed
+
+    public void doCineLoop() {
+        if (ApplicationContext.annotationPanel != null && ApplicationContext.imgPanel != null) {
+            if (loopCheckbox.isSelected()) {
+                storeAnnotationHook();
+                try {
+                    timer = new Timer();
+                    timer.scheduleAtFixedRate(new CineTimer(), 0, (11 - loopSlider.getValue()) * 100);//
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            } else {
+                if (timer != null) {
+                    timer.cancel();
+                }
+            }
+        } else {
+            loopCheckbox.setSelected(false);
+        }
+    }
+
+    public void resetCineTimer() {
+        if (timer != null) {
+            timer.cancel();
+        }
+    }
+    private void rectangleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rectangleButtonActionPerformed
+        toolsButtonGroup.clearSelection();
+        if (ApplicationContext.annotationPanel != null && ApplicationContext.imgPanel != null) {
+            ApplicationContext.annotationPanel.stopPanning();
+            ApplicationContext.imgPanel.setToolsToNull();
+            ApplicationContext.annotationPanel.setMouseLocX1(-1);
+            if (!ApplicationContext.annotationPanel.isAddRect()) {
+                ApplicationContext.annotationPanel.setAddLine(false);
+                ApplicationContext.annotationPanel.setAddEllipse(false);
+                ApplicationContext.annotationPanel.setAddRect(true);
+            } else {
+                ApplicationContext.annotationPanel.setAddRect(false);
+            }
+            toolsButtonGroup.setSelected(rectangleButton.getModel(), true);
+        } else {
+            JOptionPane.showMessageDialog(ImageToolbar.this, "Tile selected is not valid for this process");
+        }
+
+}//GEN-LAST:event_rectangleButtonActionPerformed
+
+    private void ellipseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ellipseButtonActionPerformed
+        toolsButtonGroup.clearSelection();
+        if (ApplicationContext.annotationPanel != null && ApplicationContext.imgPanel != null) {
+            ApplicationContext.annotationPanel.stopPanning();
+            ApplicationContext.imgPanel.setToolsToNull();
+            ApplicationContext.annotationPanel.setMouseLocX1(-1);
+            if (!ApplicationContext.annotationPanel.isAddEllipse()) {
+                ApplicationContext.annotationPanel.setAddLine(false);
+                ApplicationContext.annotationPanel.setAddEllipse(true);
+                ApplicationContext.annotationPanel.setAddRect(false);
+            } else {
+                ApplicationContext.annotationPanel.setAddEllipse(false);
+            }
+            toolsButtonGroup.setSelected(ellipseButton.getModel(), true);
+        } else {
+            JOptionPane.showMessageDialog(ImageToolbar.this, "Tile selected is not valid for this process");
+        }
+}//GEN-LAST:event_ellipseButtonActionPerformed
+
+    private void clearAllMeasurementActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clearAllMeasurementActionPerformed
+        if (ApplicationContext.annotationPanel != null) {
+            ApplicationContext.annotationPanel.clearAllMeasurement();
+        } else {
+            JOptionPane.showMessageDialog(ImageToolbar.this, "Tile selected is not valid for this process");
+        }
+    }//GEN-LAST:event_clearAllMeasurementActionPerformed
+
+    private void annotationVisibilityActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_annotationVisibilityActionPerformed
+        if (ApplicationContext.annotationPanel != null) {
+            ApplicationContext.annotationPanel.toggleAnnotation();
+            setAnnotationToolsStatus();
+        } else {
+            JOptionPane.showMessageDialog(ImageToolbar.this, "Tile selected is not valid for this process");
+        }
+}//GEN-LAST:event_annotationVisibilityActionPerformed
+
+    public void showAnnotationTools() {
+        rulerButton.setEnabled(true);
+        rectangleButton.setEnabled(true);
+        ellipseButton.setEnabled(true);
+        clearAllMeasurement.setEnabled(true);
+        deleteMeasurement.setEnabled(true);
+        moveMeasurement.setEnabled(true);
+    }
+
+    public void hideAnnotationTools() {
+        rulerButton.setEnabled(false);
+        rectangleButton.setEnabled(false);
+        ellipseButton.setEnabled(false);
+        clearAllMeasurement.setEnabled(false);
+        deleteMeasurement.setEnabled(false);
+        moveMeasurement.setEnabled(false);
+        String actionCommand=null;
+        if(toolsButtonGroup!=null && toolsButtonGroup.getSelection()!=null)
+        actionCommand = toolsButtonGroup.getSelection().getActionCommand();
+        if (ApplicationContext.annotationPanel != null && ApplicationContext.imgPanel != null) {
+            if (actionCommand != null) {
+                if (actionCommand.equalsIgnoreCase("ruler") || actionCommand.equalsIgnoreCase("rectangle") || actionCommand.equalsIgnoreCase("ellipse") || actionCommand.equalsIgnoreCase("deleteMeasurement") || actionCommand.equalsIgnoreCase("moveMeasurement")) {
+                    ApplicationContext.annotationPanel.setAddLine(false);
+                    ApplicationContext.annotationPanel.setAddEllipse(false);
+                    ApplicationContext.annotationPanel.setAddRect(false);
+                    ApplicationContext.annotationPanel.stopPanning();
+                    ApplicationContext.imgPanel.doWindowing();
+                    toolsButtonGroup.clearSelection();
+                    toolsButtonGroup.setSelected(windowing.getModel(), true);
+                }
+            }
+        }
+    }
+
+    public void setWindowingTool() {
+        toolsButtonGroup.clearSelection();
+        if (ApplicationContext.annotationPanel != null && ApplicationContext.imgPanel != null) {
+            ApplicationContext.annotationPanel.setAddLine(false);
+            ApplicationContext.annotationPanel.setAddEllipse(false);
+            ApplicationContext.annotationPanel.setAddRect(false);
+            ApplicationContext.annotationPanel.stopPanning();
+            ApplicationContext.imgPanel.doWindowing();
+            if (ApplicationContext.imgPanel.isWindowingSelected()) {
+                toolsButtonGroup.setSelected(windowing.getModel(), true);
+            }
+        }
+    }
+
+    public void setWindowing() {
+        if (ApplicationContext.annotationPanel != null && ApplicationContext.imgPanel != null) {
+            ApplicationContext.imgPanel.setWindowingToolsAsDefault();
+            if (ApplicationContext.imgPanel.isWindowingSelected()) {
+                toolsButtonGroup.setSelected(windowing.getModel(), true);
+            }
+        }
+    }
+
+    public void setAnnotationToolsStatus() {
+        if (ApplicationContext.annotationPanel.isShowAnnotation()) {
+            ApplicationContext.imgView.getImageToolbar().showAnnotationTools();
+        } else {
+            ApplicationContext.imgView.getImageToolbar().hideAnnotationTools();
+        }
+    }
+
+    private void deleteMeasurementActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteMeasurementActionPerformed
+        toolsButtonGroup.clearSelection();
+        if (ApplicationContext.annotationPanel != null) {
+            ApplicationContext.annotationPanel.doDeleteMeasurement();
+            if (ApplicationContext.annotationPanel.isDeleteMeasurement()) {
+                toolsButtonGroup.setSelected(deleteMeasurement.getModel(), true);
+            }
+        } else {
+            JOptionPane.showMessageDialog(ImageToolbar.this, "Tile selected is not valid for this process");
+        }
+}//GEN-LAST:event_deleteMeasurementActionPerformed
+
+    private void moveMeasurementActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_moveMeasurementActionPerformed
+        toolsButtonGroup.clearSelection();
+        if (ApplicationContext.annotationPanel != null && ApplicationContext.imgPanel != null) {
+            ApplicationContext.imgPanel.tool = "";
+            ApplicationContext.annotationPanel.tool = "";
+            ApplicationContext.annotationPanel.doMoveMeasurement();
+            if (ApplicationContext.annotationPanel.isMoveMeasurement()) {
+                toolsButtonGroup.setSelected(moveMeasurement.getModel(), true);
+            }
+        } else {
+            JOptionPane.showMessageDialog(ImageToolbar.this, "Tile selected is not valid for this process");
+        }
+}//GEN-LAST:event_moveMeasurementActionPerformed
+
+    private void layoutButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_layoutButtonMouseClicked
+        if (layoutButton.isEnabled()) {
+            int x = evt.getX();
+            int y = evt.getY();
+            long z = evt.getWhen();
+            int mo = evt.getModifiers();
+            int cc = evt.getClickCount();
+            layoutButton.dispatchEvent(new java.awt.event.MouseEvent(this.layoutButton, MouseEvent.MOUSE_CLICKED, z, mo, x, y, cc, true));
+            storeAnnotationHook();
+        }
+}//GEN-LAST:event_layoutButtonMouseClicked
+
+    private void exportButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportButtonActionPerformed
+        if (ApplicationContext.annotationPanel != null && ApplicationContext.imgPanel != null) {
+            ExportDialog jpegConvertor = new ExportDialog(ApplicationContext.imgView, true);
+            Display.alignScreen(jpegConvertor);
+            jpegConvertor.setVisible(true);
+        } else {
+            JOptionPane.showMessageDialog(this, "Tile selected is not valid for this process");
+        }
+    }//GEN-LAST:event_exportButtonActionPerformed
+
+    private void presetButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_presetButtonMouseClicked
+        if (presetButton.isEnabled()) {
+            int x = evt.getX();
+            int y = evt.getY();
+            long z = evt.getWhen();
+            int mo = evt.getModifiers();
+            int cc = evt.getClickCount();
+            designPresetContext();
+            presetButton.dispatchEvent(new java.awt.event.MouseEvent(this.presetButton, MouseEvent.MOUSE_CLICKED, z, mo, x, y, cc, true));
+        }
+    }//GEN-LAST:event_presetButtonMouseClicked
+
+    private void metaDataButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_metaDataButtonActionPerformed
+        if (ApplicationContext.annotationPanel != null && ApplicationContext.imgPanel != null) {
+            ArrayList<DicomTags> dcmTags = DicomTagsReader.getTags(new File(ApplicationContext.imgPanel.getDicomFileUrl()));
+            DicomTagsViewer dicomTagsViewer = new DicomTagsViewer(dcmTags);
+            Display.alignScreen(dicomTagsViewer);
+            dicomTagsViewer.setVisible(true);
+        } else {
+            JOptionPane.showMessageDialog(this, "Tile selected is not valid for this process");
+        }
+    }//GEN-LAST:event_metaDataButtonActionPerformed
+
+    private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
+        PresetModel presetModel = ApplicationContext.databaseRef.getPreset((String) ((JComboBox) evt.getSource()).getSelectedItem());
+        if (presetModel.getPresetName() != null) {
+            ApplicationContext.imgPanel.windowChanged(Integer.parseInt(presetModel.getWindowLevel()), Integer.parseInt(presetModel.getWindowWidth()));
+        } else {
+            ApplicationContext.imgPanel.resetWindowing();
+        }
+    }//GEN-LAST:event_jComboBox1ActionPerformed
+
+    private void scoutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_scoutButtonActionPerformed
+        doScout();
+    }//GEN-LAST:event_scoutButtonActionPerformed
+
+    public void doScout() {
+        if (!ImagePanel.isDisplayScout()) {
+            ImagePanel.setDisplayScout(true);
+            LocalizerDelegate localizer = new LocalizerDelegate();
+            localizer.drawScoutLineWithBorder();
+        } else {
+            ImagePanel.setDisplayScout(false);
+            LocalizerDelegate.hideScoutLine();
+        }
+    }
+    private void textOverlayMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_textOverlayMousePressed
+        if (textOverlay.isEnabled()) {
+            int x = evt.getX();
+            int y = evt.getY();
+            long z = evt.getWhen();
+            int mo = evt.getModifiers();
+            int cc = evt.getClickCount();
+            textOverlay.dispatchEvent(new java.awt.event.MouseEvent(this.textOverlay, MouseEvent.MOUSE_CLICKED, z, mo, x, y, cc, true));
+        }
+    }//GEN-LAST:event_textOverlayMousePressed
+
+    private void cube3DButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_cube3DButtonMouseClicked
+
+        int x = evt.getX();
+        int y = evt.getY();
+        long z = evt.getWhen();
+        int mo = evt.getModifiers();
+        int cc = evt.getClickCount();
+        design3DPopup();
+        cube3DButton.dispatchEvent(new java.awt.event.MouseEvent(this.cube3DButton, MouseEvent.MOUSE_CLICKED, z, mo, x, y, cc, true));
+}//GEN-LAST:event_cube3DButtonMouseClicked
+
+    private void cube3DButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cube3DButtonActionPerformed
+}//GEN-LAST:event_cube3DButtonActionPerformed
+
+    private void synchronizeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_synchronizeButtonActionPerformed
+        ApplicationContext.imgPanel.doSynchronize();
+    }//GEN-LAST:event_synchronizeButtonActionPerformed
+    private void designPresetContext() {
+        if (ApplicationContext.annotationPanel != null && ApplicationContext.imgPanel != null) {
+            ArrayList presetList = ApplicationContext.databaseRef.getPresetValueForModality(ApplicationContext.imgPanel.getModality());
+            jPopupMenu2.removeAll();
+            JMenuItem menu = new JMenuItem("PRESETS") {
+
+                @Override
+                protected void paintComponent(Graphics grphcs) {
+                    grphcs.setFont(new Font("Arial", Font.BOLD, 12));
+                    grphcs.setColor(Color.blue);
+                    grphcs.drawString(this.getText(), 32, 14);
+                }
+            };
+            menu.setEnabled(false);
+            jPopupMenu2.add(menu);
+            jPopupMenu2.addSeparator();
+            for (int i = 0; i < presetList.size(); i++) {
+                final PresetModel presetModel = (PresetModel) presetList.get(i);
+                if (!presetModel.getPresetName().equalsIgnoreCase("PRESETNAME")) {
+                    JMenuItem menu1 = new JMenuItem(presetModel.getPresetName());
+                    jPopupMenu2.add(menu1);
+                    menu1.addActionListener(new ActionListener() {
+
+                        public void actionPerformed(ActionEvent e) {
+                            ApplicationContext.imgPanel.windowChanged(Integer.parseInt(presetModel.getWindowLevel()), Integer.parseInt(presetModel.getWindowWidth()));
+
+                        }
+                    });
+                }
+            }
+            this.setComponentPopupMenu(jPopupMenu1);
+        } else {
+            JOptionPane.showMessageDialog(this, "Tile selected is not valid for this process");
+        }
+    }
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JButton annotationVisibility;
+    private javax.swing.JButton clearAllMeasurement;
+    private javax.swing.JButton cube3DButton;
+    private javax.swing.JButton deleteMeasurement;
+    private javax.swing.JButton ellipseButton;
+    private javax.swing.JButton exportButton;
+    private javax.swing.JButton horizontalFlip;
+    private javax.swing.JButton invert;
+    private javax.swing.JComboBox jComboBox1;
+    private javax.swing.JPopupMenu jPopupMenu1;
+    private javax.swing.JPopupMenu jPopupMenu2;
+    private javax.swing.JPopupMenu jPopupMenu3;
+    private javax.swing.JPopupMenu jPopupMenu4;
+    private javax.swing.JToolBar jToolBar3;
+    private javax.swing.JButton layoutButton;
+    private javax.swing.JButton leftRotate;
+    private javax.swing.JCheckBox loopCheckbox;
+    private javax.swing.JSlider loopSlider;
+    private javax.swing.JButton metaDataButton;
+    private javax.swing.JButton moveMeasurement;
+    private javax.swing.JButton panButton;
+    private javax.swing.JButton presetButton;
+    private javax.swing.JButton probeButton;
+    private javax.swing.JButton rectangleButton;
+    private javax.swing.JButton reset;
+    private javax.swing.JButton rightRotate;
+    private javax.swing.JButton rulerButton;
+    private javax.swing.JButton scoutButton;
+    private javax.swing.JButton stackButton;
+    private javax.swing.JButton synchronizeButton;
+    private javax.swing.JButton textOverlay;
+    private javax.swing.ButtonGroup toolsButtonGroup;
+    private javax.swing.JButton verticalFlip;
+    private javax.swing.JButton windowing;
+    private javax.swing.JButton zoomin;
+    private javax.swing.JButton zoomoutButton;
+    // End of variables declaration//GEN-END:variables
+
+    public void designPopup() {
+        JPanel jp = new JPanel(new GridLayout(3, 3));
+        JButton jb1 = new JButton("1x1");
+        JButton jb2 = new JButton("1x2");
+        JButton jb3 = new JButton("1x3");
+        JButton jb4 = new JButton("2x1");
+        JButton jb5 = new JButton("2x2");
+        JButton jb6 = new JButton("2x3");
+        JButton jb7 = new JButton("3x1");
+        JButton jb8 = new JButton("3x2");
+        JButton jb9 = new JButton("3x3");
+        jp.add(jb1);
+        jp.add(jb2);
+        jp.add(jb3);
+        jp.add(jb4);
+        jp.add(jb5);
+        jp.add(jb6);
+        jp.add(jb7);
+        jp.add(jb8);
+        jp.add(jb9);
+        jp.setBounds(0, 0, 200, 400);
+        jPopupMenu1.add(jp);
+
+        jb1.addActionListener(new java.awt.event.ActionListener() {
+
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                jb1ActionPerformed(evt);
+            }
+        });
+        jb2.addActionListener(new java.awt.event.ActionListener() {
+
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                jb2ActionPerformed(evt);
+            }
+        });
+        jb3.addActionListener(new java.awt.event.ActionListener() {
+
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                jb3ActionPerformed(evt);
+            }
+        });
+        jb4.addActionListener(new java.awt.event.ActionListener() {
+
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                jb4ActionPerformed(evt);
+            }
+        });
+        jb5.addActionListener(new java.awt.event.ActionListener() {
+
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                jb5ActionPerformed(evt);
+            }
+        });
+        jb6.addActionListener(new java.awt.event.ActionListener() {
+
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                jb6ActionPerformed(evt);
+            }
+        });
+        jb7.addActionListener(new java.awt.event.ActionListener() {
+
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                jb7ActionPerformed(evt);
+            }
+        });
+        jb8.addActionListener(new java.awt.event.ActionListener() {
+
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                jb8ActionPerformed(evt);
+            }
+        });
+        jb9.addActionListener(new java.awt.event.ActionListener() {
+
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                jb9ActionPerformed(evt);
+            }
+        });
+
+    }
+
+    public void jb1ActionPerformed(ActionEvent e) {
+        changeLayout(1, 1);
+
+    }
+
+    public void storeAnnotationHook() {
+        for (int i = 0; i < ApplicationContext.imgView.jTabbedPane1.getComponentCount(); i++) {
+            for (int j = 0; j < ((JPanel) ApplicationContext.imgView.jTabbedPane1.getComponent(i)).getComponentCount(); j++) {
+                try {
+                    if (((JPanel) ApplicationContext.imgView.jTabbedPane1.getComponent(i)).getComponent(j) instanceof LayeredCanvas) {
+                        LayeredCanvas tempCanvas = ((LayeredCanvas) ((JPanel) ApplicationContext.imgView.jTabbedPane1.getComponent(i)).getComponent(j));
+                        if (tempCanvas.imgpanel != null) {
+                            tempCanvas.imgpanel.storeAnnotation();
+                        }
+                    }
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+
+    private void removeAllPanelsFromSelectedTab() {
+        for (int i = ((JPanel) ApplicationContext.imgView.jTabbedPane1.getSelectedComponent()).getComponentCount() - 1; i >= 0; i--) {
+            ((JPanel) ApplicationContext.imgView.jTabbedPane1.getSelectedComponent()).remove(i);
+        }
+    }
+
+    public void changeLayout(int row, int col) {
+        String siuid;
+        LayeredCanvas tempCanvas = null;
+        if (((JPanel) ApplicationContext.imgView.jTabbedPane1.getSelectedComponent()).getComponent(0) instanceof LayeredCanvas) {
+            tempCanvas = ((LayeredCanvas) ((JPanel) ApplicationContext.imgView.jTabbedPane1.getSelectedComponent()).getComponent(0));
+            siuid = tempCanvas.imgpanel.getStudyUID();
+        } else {
+            tempCanvas = ((LayeredCanvas) ((JPanel) ApplicationContext.imgView.jTabbedPane1.getSelectedComponent()).getComponent(1));
+            siuid = tempCanvas.imgpanel.getStudyUID();
+        }
+        GridLayout g = new GridLayout(row, col);
+        ArrayList<Instance> instanceArray = getInstanceArray();
+        ArrayList tempRef = ApplicationContext.databaseRef.getUrlBasedOnStudyIUID(siuid);
+        for (int i = ((JPanel) ApplicationContext.imgView.jTabbedPane1.getSelectedComponent()).getComponentCount() - 1; i >= 0; i--) {
+            ((JPanel) ApplicationContext.imgView.jTabbedPane1.getSelectedComponent()).remove(i);
+
+        }
+        ((JPanel) ApplicationContext.imgView.jTabbedPane1.getSelectedComponent()).setLayout(g);
+        for (int i = 0; i < (row * col); i++) {
+            if (i < tempRef.size()) {
+                File file = (File) tempRef.get(i);
+                LayeredCanvas canvas = new LayeredCanvas(file.getAbsolutePath());
+                ((JPanel) ApplicationContext.imgView.jTabbedPane1.getSelectedComponent()).add(canvas, i);
+                for (int x = 0; x < instanceArray.size(); x++) {
+                    if (file.getAbsolutePath().equalsIgnoreCase(new DestinationFinder().getFileDestination(instanceArray.get(x).getFilepath()))) {
+                        LayeredCanvas tempCanvas1 = ((LayeredCanvas) ((JPanel) ApplicationContext.imgView.jTabbedPane1.getSelectedComponent()).getComponent(i));
+
+                        if (ApplicationContext.databaseRef.getMultiframeStatus() && tempCanvas1.imgpanel.isMulitiFrame()) {
+                            if (instanceArray != null && instanceArray.get(x) != null && instanceArray.get(x).getAnnotations() != null && instanceArray.get(x).getAnnotations().get(0) != null) {
+                                tempCanvas1.annotationPanel.setAnnotation(instanceArray.get(x).getAnnotations().get(0));
+                            }
+                        } else {
+                            if (instanceArray != null && instanceArray.get(x) != null && instanceArray.get(x).getAnnotation() != null) {
+                                tempCanvas1.annotationPanel.setAnnotation(instanceArray.get(x).getAnnotation());
+                            }
+                        }
+                        break;
+                    }
+                }
+
+            } else {
+                LayeredCanvas j = new LayeredCanvas();
+                j.setStudyUID(siuid);
+                ((JPanel) ApplicationContext.imgView.jTabbedPane1.getSelectedComponent()).add(j, i);
+            }
+        }
+        ((JPanel) ApplicationContext.imgView.jTabbedPane1.getSelectedComponent()).revalidate();
+        ((JPanel) ApplicationContext.imgView.jTabbedPane1.getSelectedComponent()).repaint();
+        ApplicationContext.imgPanel = ((LayeredCanvas) ((JPanel) ApplicationContext.imgView.jTabbedPane1.getSelectedComponent()).getComponent(0)).imgpanel;
+        ApplicationContext.annotationPanel = ((LayeredCanvas) ((JPanel) ApplicationContext.imgView.jTabbedPane1.getSelectedComponent()).getComponent(0)).annotationPanel;
+        ApplicationContext.layeredCanvas = ((LayeredCanvas) ((JPanel) ApplicationContext.imgView.jTabbedPane1.getSelectedComponent()).getComponent(0));
+        hideLayoutSelectionPopup();
+        ((Canvas) ApplicationContext.imgPanel.getCanvas()).setSelection();
+        //storeAnnotationHook();
+    }
+
+    private void hideLayoutSelectionPopup() {
+        jPopupMenu1.setVisible(false);
+    }
+
+    public ArrayList getInstanceArray() {
+        ArrayList<Instance> instanceArray = new ArrayList<Instance>();
+        String studyUID = "";
+        if (ApplicationContext.imgPanel != null) {
+            studyUID = ApplicationContext.imgPanel.getStudyUID();
+        } else {
+            studyUID = ApplicationContext.layeredCanvas.getStudyUID();
+        }
+        for (Study study : MainScreen.studyList) {
+            if (study.getStudyInstanceUID().equalsIgnoreCase(studyUID)) {
+                ArrayList<Series> seriesList = (ArrayList<Series>) study.getSeriesList();
+                for (int i = 0; i < seriesList.size(); i++) {
+                    Series series = seriesList.get(i);
+                    Instance instance = series.getImageList().get(0);
+                    instanceArray.add(instance);
+                    //   this.getCanvas().getLayeredCanvas().annotationPanel.setAnnotation(instance.getAnnotation());
+                }
+            }
+        }
+        return instanceArray;
+    }
+
+    public void jb2ActionPerformed(ActionEvent e) {
+        changeLayout(1, 2);
+    }
+
+    public void jb3ActionPerformed(ActionEvent e) {
+        changeLayout(1, 3);
+    }
+
+    public void jb4ActionPerformed(ActionEvent e) {
+        changeLayout(2, 1);
+    }
+
+    public void jb5ActionPerformed(ActionEvent e) {
+        changeLayout(2, 2);
+    }
+
+    public void jb6ActionPerformed(ActionEvent e) {
+        changeLayout(2, 3);
+    }
+
+    public void jb7ActionPerformed(ActionEvent e) {
+        changeLayout(3, 1);
+    }
+
+    public void jb8ActionPerformed(ActionEvent e) {
+        changeLayout(3, 2);
+    }
+
+    public void jb9ActionPerformed(ActionEvent e) {
+        changeLayout(3, 3);
+    }
+    public String seriesDir = "";
+    public String studyDir = "";
+
+    private void design3DPopup() {
+
+        JMenuItem mpr = new JMenuItem("2D Orthogonal MPR");
+        JMenuItem mpr3D = new JMenuItem("3D MPR");
+        JMenuItem mip = new JMenuItem("3D MIP");
+        JMenuItem surfaceRendering = new JMenuItem("3D Surface Rendering");
+        JMenuItem volumeRendering = new JMenuItem("Volume Rendering");
+
+        jPopupMenu4.removeAll();
+        jPopupMenu4.add(mpr);
+        jPopupMenu4.addSeparator();
+        jPopupMenu4.add(mpr3D);
+        jPopupMenu4.add(mip);
+        jPopupMenu4.add(surfaceRendering);
+        jPopupMenu4.add(volumeRendering);
+
+        LayeredCanvas tempCanvas = null;
+        surfaceRendering.addActionListener(new ActionListener() {
+
+            public void actionPerformed(ActionEvent ae) {
+                doFileCopy();
+                surface = new SurfaceRendering();
+                surface.readDicomDir(seriesDir);
+                surface.setLocationRelativeTo(ImageToolbar.this);
+                surface.setVisible(true);
+            }
+        });
+        mip.addActionListener(new ActionListener() {
+
+            public void actionPerformed(ActionEvent ae) {
+                doFileCopy();
+                dcmMip = new DicomMIP();
+                dcmMip.readDicomDir(seriesDir);
+                dcmMip.setLocationRelativeTo(ImageToolbar.this);
+                dcmMip.setVisible(true);
+            }
+        });
+        mpr.addActionListener(new ActionListener() {
+
+            public void actionPerformed(ActionEvent ae) {
+                doFileCopy();
+                dcmMPR2D = new DicomMPR2D();
+                dcmMPR2D.readDicomDir(seriesDir);
+                dcmMPR2D.setLocationRelativeTo(ImageToolbar.this);
+                dcmMPR2D.setVisible(true);
+            }
+        });
+        mpr3D.addActionListener(new ActionListener() {
+
+            public void actionPerformed(ActionEvent e) {
+                doFileCopy();
+                mpr3DSlider = new DicomMPR3DSlider();
+                mpr3DSlider.readDicom(seriesDir);
+                mpr3DSlider.setLocationRelativeTo(ImageToolbar.this);
+                mpr3DSlider.setVisible(true);
+            }
+        });
+        volumeRendering.addActionListener(new ActionListener() {
+
+            public void actionPerformed(ActionEvent e) {
+                doFileCopy();
+                dicomVolumeRendering = new DicomVolumeRendering();
+                dicomVolumeRendering.readDicomDir(seriesDir);
+                dicomVolumeRendering.setLocationRelativeTo(ImageToolbar.this);
+                dicomVolumeRendering.setVisible(true);
+
+            }
+        });
+
+    }
+
+    public void doFileCopy() {
+        String filePath = ApplicationContext.imgPanel.getDicomFileUrl();
+        studyDir = new File(filePath).getParent();
+        String seriesUID = ApplicationContext.imgPanel.getSeriesUID();
+        String instancePath[] = ApplicationContext.imgPanel.getInstancesFilePath();
+        DestinationFinder finder = new DestinationFinder();
+        for (int i = 0; i < instancePath.length; i++) {
+            try {
+                File sourceFile = new File(finder.getFileDestination(instancePath[i]));
+                FileInputStream fis = new FileInputStream(sourceFile);
+                seriesDir = studyDir + File.separator + seriesUID;
+                File seriesFolder = new File(seriesDir);
+                if (!seriesFolder.exists()) {
+                    seriesFolder.mkdir();
+                }
+                FileOutputStream fout = new FileOutputStream(new File(seriesFolder, sourceFile.getName()));
+                copy(fis, fout);
+            } catch (IOException ex) {
+                Logger.getLogger(ImageToolbar.class.getName()).log(Level.SEVERE, null, ex);
+            } catch (Exception ex) {
+                Logger.getLogger(ImageToolbar.class.getName()).log(Level.SEVERE, null, ex);
+            }
+
+        }
+    }
+
+    private void copy(InputStream in, OutputStream out)
+            throws IOException {
+        byte[] buffer = new byte[8 * 1024];
+        int read;
+        while ((read = in.read(buffer)) != -1) {
+            if (out != null) {
+                out.write(buffer, 0, read);
+            }
+        }
+        in.close();
+        out.close();
+    }
+
+    public void doTextOverlay() {
+        if (ApplicationContext.annotationPanel != null && ApplicationContext.imgPanel != null) {
+            ApplicationContext.layeredCanvas.textOverlay.toggleTextOverlay();
+
+        } else {
+            JOptionPane.showMessageDialog(ImageToolbar.this, "Tile selected is not valid for this process");
+        }
+    }
+
+    public void textOverlayContext() {
+        JMenuItem currentFrame = new JMenuItem("Selected");
+        JMenuItem allFrame = new JMenuItem("All");
+        jPopupMenu3.add(currentFrame);
+        jPopupMenu3.add(allFrame);
+        textOverlay.setComponentPopupMenu(jPopupMenu3);
+        allFrame.addActionListener(new ActionListener() {
+
+            public void actionPerformed(ActionEvent e) {
+                LayeredCanvas tempCanvas = null;
+                int childCount = ((JPanel) ApplicationContext.imgView.jTabbedPane1.getSelectedComponent()).getComponentCount();
+                for (int i = 0; i < childCount; i++) {
+                    if (((JPanel) ApplicationContext.imgView.jTabbedPane1.getSelectedComponent()).getComponent(i) instanceof LayeredCanvas) {
+                        tempCanvas = ((LayeredCanvas) ((JPanel) ApplicationContext.imgView.jTabbedPane1.getSelectedComponent()).getComponent(i));
+                        if (tempCanvas.textOverlay != null) {
+                            tempCanvas.textOverlay.toggleTextOverlay();
+                        }
+                    }
+                }
+            }
+        });
+        currentFrame.addActionListener(new ActionListener() {
+
+            public void actionPerformed(ActionEvent e) {
+                if (ApplicationContext.annotationPanel != null && ApplicationContext.imgPanel != null) {
+                    ApplicationContext.layeredCanvas.textOverlay.toggleTextOverlay();
+
+                } else {
+                    JOptionPane.showMessageDialog(ImageToolbar.this, "Tile selected is not valid for this process");
+                }
+            }
+        });
+    }
+}
diff --git a/src/in/raster/mayam/form/ImageView.form b/src/in/raster/mayam/form/ImageView.form
new file mode 100644
index 0000000..17528fb
--- /dev/null
+++ b/src/in/raster/mayam/form/ImageView.form
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
+  <Properties>
+    <Property name="defaultCloseOperation" type="int" value="2"/>
+    <Property name="title" type="java.lang.String" value="Image View"/>
+    <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+      <Color blue="0" green="0" red="0" type="rgb"/>
+    </Property>
+    <Property name="iconImage" type="java.awt.Image" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+      <Connection code="Toolkit.getDefaultToolkit().getImage(getClass().getResource("/in/raster/mayam/form/images/fav_mayam.png"))" type="code"/>
+    </Property>
+  </Properties>
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <Events>
+    <EventHandler event="windowClosed" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="windowCloseHandler"/>
+  </Events>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Component id="imageToolbar1" alignment="0" pref="1212" max="32767" attributes="1"/>
+          <Component id="jTabbedPane1" alignment="0" pref="1212" max="32767" attributes="3"/>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="1" attributes="0">
+              <Component id="imageToolbar1" min="-2" pref="45" max="-2" attributes="0"/>
+              <EmptySpace min="-2" max="-2" attributes="0"/>
+              <Component id="jTabbedPane1" pref="471" max="32767" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Component class="in.raster.mayam.form.ImageToolbar" name="imageToolbar1">
+      <AuxValues>
+        <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new in.raster.mayam.form.ImageToolbar(this)"/>
+      </AuxValues>
+    </Component>
+    <Container class="javax.swing.JTabbedPane" name="jTabbedPane1">
+      <Properties>
+        <Property name="focusable" type="boolean" value="false"/>
+        <Property name="opaque" type="boolean" value="true"/>
+      </Properties>
+      <AuxValues>
+        <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="1"/>
+      </AuxValues>
+
+      <Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/>
+    </Container>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/ImageView.java b/src/in/raster/mayam/form/ImageView.java
new file mode 100644
index 0000000..684ce12
--- /dev/null
+++ b/src/in/raster/mayam/form/ImageView.java
@@ -0,0 +1,159 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.delegate.AnnotationDelegate;
+import java.awt.Toolkit;
+import javax.swing.JFrame;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class ImageView extends javax.swing.JFrame {
+
+    /** Creates new form ImageView */
+    String openedFilePath = "";
+    public static boolean annotationAlreadyStored = false;
+
+    public ImageView() {
+        initComponents();
+        setExtendedState(JFrame.MAXIMIZED_BOTH);
+    }
+
+    public ImageView(String openedFilePath) {
+        this.openedFilePath = openedFilePath;
+        setExtendedState(JFrame.MAXIMIZED_BOTH);
+        initComponents();
+
+    }
+
+
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        imageToolbar1 = new in.raster.mayam.form.ImageToolbar(this);
+        jTabbedPane1 = new javax.swing.JTabbedPane();
+
+        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+        setTitle("Image View");
+        setBackground(new java.awt.Color(0, 0, 0));
+        setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/in/raster/mayam/form/images/fav_mayam.png")));
+        addWindowListener(new java.awt.event.WindowAdapter() {
+            public void windowClosed(java.awt.event.WindowEvent evt) {
+                windowCloseHandler(evt);
+            }
+        });
+
+        jTabbedPane1.setFocusable(false);
+        jTabbedPane1.setOpaque(true);
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+        getContentPane().setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(imageToolbar1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 1212, Short.MAX_VALUE)
+            .add(jTabbedPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 1212, Short.MAX_VALUE)
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+                .add(imageToolbar1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 45, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(jTabbedPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 471, Short.MAX_VALUE))
+        );
+
+        pack();
+    }// </editor-fold>//GEN-END:initComponents
+
+    private void windowCloseHandler(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_windowCloseHandler
+        saveAnnotationOfTabs();
+        ApplicationContext.imgView = null;
+        if (LayoutManagerPanel.updateSeries) {
+            if (LayoutManagerPanel.updatePropertiesDetails) {
+                ApplicationContext.databaseRef.updatePropertiesDetail("true");
+            } else {
+                ApplicationContext.databaseRef.updatePropertiesDetail("false");
+            }
+            ApplicationContext.mainScreen.showThumbnails();
+            LayoutManagerPanel.updateSeries = false;
+        }
+    }//GEN-LAST:event_windowCloseHandler
+    public void saveAnnotationOfTabs() {
+        imageToolbar1.resetCineTimer();
+        if (!annotationAlreadyStored) {
+            if (ApplicationContext.imgView != null && ApplicationContext.imgView.jTabbedPane1 != null) {
+                int count = ApplicationContext.imgView.jTabbedPane1.getComponentCount();
+                AnnotationDelegate annotationDelegate = new AnnotationDelegate();
+                for (int x = 0; x < count; x++) {
+                    annotationDelegate.storeAnnotationHook(x);
+                    annotationDelegate.saveAnnotation(x);
+                }
+            }
+        }
+        annotationAlreadyStored = false;
+    }
+    public ImageToolbar getImageToolbar()
+    {
+        return this.imageToolbar1;
+    }
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String args[]) {
+        java.awt.EventQueue.invokeLater(new Runnable() {
+
+            public void run() {
+                new ImageView().setVisible(true);
+            }
+        });
+    }
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private in.raster.mayam.form.ImageToolbar imageToolbar1;
+    public javax.swing.JTabbedPane jTabbedPane1;
+    // End of variables declaration//GEN-END:variables
+}
diff --git a/src/in/raster/mayam/form/ImportingProgress.form b/src/in/raster/mayam/form/ImportingProgress.form
new file mode 100644
index 0000000..3308c39
--- /dev/null
+++ b/src/in/raster/mayam/form/ImportingProgress.form
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
+  <Properties>
+    <Property name="alwaysOnTop" type="boolean" value="true"/>
+    <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+      <Color blue="66" green="66" red="66" type="rgb"/>
+    </Property>
+    <Property name="resizable" type="boolean" value="false"/>
+    <Property name="undecorated" type="boolean" value="true"/>
+  </Properties>
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Component id="jLabel1" alignment="0" pref="306" max="32767" attributes="0"/>
+          <Group type="102" alignment="1" attributes="0">
+              <EmptySpace pref="88" max="32767" attributes="0"/>
+              <Component id="jProgressBar1" min="-2" max="-2" attributes="0"/>
+              <EmptySpace min="-2" pref="72" max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
+              <EmptySpace type="separate" max="-2" attributes="0"/>
+              <Component id="jProgressBar1" min="-2" max="-2" attributes="0"/>
+              <EmptySpace pref="35" max="32767" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Component class="javax.swing.JLabel" name="jLabel1">
+      <Properties>
+        <Property name="horizontalAlignment" type="int" value="0"/>
+        <Property name="text" type="java.lang.String" value="Importing ..."/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JProgressBar" name="jProgressBar1">
+      <Properties>
+        <Property name="value" type="int" value="1"/>
+      </Properties>
+    </Component>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/ImportingProgress.java b/src/in/raster/mayam/form/ImportingProgress.java
new file mode 100644
index 0000000..8332c86
--- /dev/null
+++ b/src/in/raster/mayam/form/ImportingProgress.java
@@ -0,0 +1,129 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class ImportingProgress extends javax.swing.JFrame {
+
+    /** Creates new form SendReceiveFrame */
+    public ImportingProgress() {
+        initComponents();
+    }
+
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        jLabel1 = new javax.swing.JLabel();
+        jProgressBar1 = new javax.swing.JProgressBar();
+
+        setAlwaysOnTop(true);
+        setBackground(new java.awt.Color(102, 102, 102));
+        setResizable(false);
+        setUndecorated(true);
+
+        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+        jLabel1.setText("Importing ...");
+
+        jProgressBar1.setValue(1);
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+        getContentPane().setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 306, Short.MAX_VALUE)
+            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+                .addContainerGap(88, Short.MAX_VALUE)
+                .add(jProgressBar1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .add(72, 72, 72))
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(layout.createSequentialGroup()
+                .addContainerGap()
+                .add(jLabel1)
+                .add(18, 18, 18)
+                .add(jProgressBar1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addContainerGap(35, Short.MAX_VALUE))
+        );
+
+        pack();
+    }// </editor-fold>//GEN-END:initComponents
+
+    public void updateBar(int value) {
+        jProgressBar1.setValue(value);
+        jProgressBar1.repaint();
+
+    }
+
+    public void setProgressMaximum(int max) {
+        jProgressBar1.setMinimum(1);
+        jProgressBar1.setMaximum(max);
+
+    }
+
+    public int getProgressMaximum() {
+        return jProgressBar1.getMaximum();
+    }
+
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String args[]) {
+        java.awt.EventQueue.invokeLater(new Runnable() {
+
+            public void run() {
+                new ImportingProgress().setVisible(true);
+            }
+        });
+    }
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JLabel jLabel1;
+    private javax.swing.JProgressBar jProgressBar1;
+    // End of variables declaration//GEN-END:variables
+}
diff --git a/src/in/raster/mayam/form/LayeredCanvas.java b/src/in/raster/mayam/form/LayeredCanvas.java
new file mode 100644
index 0000000..796798b
--- /dev/null
+++ b/src/in/raster/mayam/form/LayeredCanvas.java
@@ -0,0 +1,324 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.delegate.SeriesChooserDelegate;
+import in.raster.mayam.model.Series;
+import in.raster.mayam.model.Study;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.event.ActionEvent;
+import java.awt.event.ComponentEvent;
+import java.awt.event.ComponentListener;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.util.ArrayList;
+import javax.swing.JLayeredPane;
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
+import javax.swing.border.LineBorder;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class LayeredCanvas extends JLayeredPane implements FocusListener, MouseListener, ComponentListener {
+
+    private static int ImageHeight = 512;
+    private static int ImageWidth = 512;
+    public ImagePanel imgpanel;
+    public AnnotationPanel annotationPanel;
+    public TextOverlay textOverlay;
+    public Canvas canvas;
+    public boolean focusGained = false;
+    public boolean fileIsNull = false;
+    private String studyUID = "";
+    private String[] comparedWithStudies;
+
+    public LayeredCanvas() {
+        this.addFocusListener(this);
+        this.addMouseListener(this);
+        this.addComponentListener(this);
+        this.setBorder(new LineBorder(Color.DARK_GRAY));
+        fileIsNull = true;
+    }
+
+    public LayeredCanvas(String filePath) {
+        this.setBackground(Color.BLACK);
+        this.setLayout(null);
+        createImageCanvas(filePath);
+        createAnnotationOverlay();
+        createTextOverlay();
+        setTextOverlayParam();
+        findMultiframeStatus();
+        createLayers();
+        this.addComponentListener(this);
+    }
+
+    /**
+     * This routine used to create the component once again for another series.
+     * @param filePath
+     */
+    public void createSubComponents(String filePath) {
+        if (textOverlay != null) {
+            this.remove(textOverlay);
+        }
+        if (annotationPanel != null) {
+            this.remove(annotationPanel);
+        }
+        if (canvas != null) {
+            this.remove(canvas);
+        }
+        createImageCanvas(filePath);
+        createAnnotationOverlay();
+        createTextOverlay();
+        setTextOverlayParam();
+        findMultiframeStatus();
+        createLayers();
+        this.imgpanel.revalidate();
+        this.imgpanel.repaint();
+        this.annotationPanel.revalidate();
+        this.annotationPanel.repaint();
+        this.textOverlay.revalidate();
+        this.textOverlay.repaint();
+    }
+
+    private void createLayers() {
+        this.add(canvas, Integer.valueOf(0));
+        this.add(annotationPanel, Integer.valueOf(2));
+        this.add(textOverlay, Integer.valueOf(1));
+    }
+
+    private void createImageCanvas(String filePath) {
+        canvas = new Canvas(this);
+        canvas.setSize(514, 514);
+        imgpanel = new ImagePanel(filePath, canvas);
+        imgpanel.setSize(ImageWidth, ImageHeight);
+        canvas.add(imgpanel);
+    }
+
+    private void createAnnotationOverlay() {
+        annotationPanel = new AnnotationPanel(this);
+        annotationPanel.setForeground(Color.white);
+        annotationPanel.setSize(new Dimension(ImageWidth, ImageHeight));
+    }
+
+    private void createTextOverlay() {
+        textOverlay = new TextOverlay(this);
+        textOverlay.setForeground(Color.white);
+        textOverlay.setSize(new Dimension(ImageWidth, ImageHeight));
+    }
+
+    public boolean isFocusGained() {
+        return focusGained;
+    }
+
+    public void setFocusGained(boolean focusGained) {
+        this.focusGained = focusGained;
+        repaint();
+    }
+
+    public void findMultiframeStatus() {
+        if (imgpanel.isMulitiFrame()) {
+            textOverlay.multiframeStatusDisplay(true);
+            if (!ApplicationContext.databaseRef.getMultiframeStatus()) {
+                textOverlay.getTextOverlayParam().setFramePosition("1/" + imgpanel.getnFrames());
+            }
+        } else {
+            textOverlay.multiframeStatusDisplay(false);
+        }
+
+    }
+
+    private void setTextOverlayParam() {
+        textOverlay.setTextOverlayParam(imgpanel.getTextOverlayParam());
+    }
+
+    public void centerImagePanel() {
+        int xPosition = (this.getSize().width - imgpanel.getSize().width) / 2;
+        int yPosition = (this.getSize().height - imgpanel.getSize().height) / 2;
+        imgpanel.setBounds(xPosition, yPosition, imgpanel.getSize().width, imgpanel.getSize().height);
+    }
+
+    public void focusGained(FocusEvent arg0) {
+        this.setBorder(new LineBorder(Color.YELLOW));
+    }
+
+    public void focusLost(FocusEvent arg0) {
+        this.setBorder(new LineBorder(Color.DARK_GRAY));
+    }
+
+    public void mouseClicked(MouseEvent arg0) {
+        if (fileIsNull) {
+            setSelection();
+            designContext();
+
+        }
+
+    }
+
+    /**
+     * This routine used to set the selection coloring.
+     */
+    public void setSelectionColoring() {
+        this.setBorder(new LineBorder(new Color(255, 138, 0)));
+        ApplicationContext.imgView.getImageToolbar().disableAllTools();
+    }
+
+    /**
+     * This routine used to remove the selection coloring.
+     */
+    public void setNoSelectionColoring() {
+        this.setBorder(new LineBorder(Color.DARK_GRAY));
+    }
+
+    public void setSelection() {
+        if (ApplicationContext.layeredCanvas != null) {
+            if (ApplicationContext.layeredCanvas.getCanvas() != null) {
+                ApplicationContext.layeredCanvas.getCanvas().setNoSelectionColoring();
+            } else {
+                ApplicationContext.layeredCanvas.setNoSelectionColoring();
+            }
+        }
+        ApplicationContext.imgPanel = this.imgpanel;
+        ApplicationContext.layeredCanvas = this;
+        ApplicationContext.annotationPanel = this.annotationPanel;
+        ApplicationContext.layeredCanvas.setSelectionColoring();
+    }
+
+    public void mousePressed(MouseEvent arg0) {
+    }
+
+    public void mouseReleased(MouseEvent arg0) {
+    }
+
+    public void mouseEntered(MouseEvent arg0) {
+    }
+
+    public void mouseExited(MouseEvent arg0) {
+    }
+
+    private void designContext() {
+        final LayeredCanvas ref = this;
+        ArrayList<Study> studyList = null;
+        if (((JPanel) ApplicationContext.imgView.jTabbedPane1.getSelectedComponent()).getName() != null) {
+            String patientName = ((JPanel) ApplicationContext.imgView.jTabbedPane1.getSelectedComponent()).getName();
+            studyList = ApplicationContext.databaseRef.getStudyUIDBasedOnPatientName(patientName);
+        }
+        JPopupMenu jPopupMenu2 = new JPopupMenu();
+        for (Study study : studyList) {
+            ArrayList<Series> seriesList = ApplicationContext.databaseRef.getSeriesList(study.getStudyInstanceUID());
+            JMenu menu = new JMenu(study.getStudyDesc());
+            for (final Series series : seriesList) {
+                JMenuItem menuitem = new JMenuItem(series.getSeriesDesc());
+                menu.add(menuitem);
+                menuitem.addActionListener(new java.awt.event.ActionListener() {
+
+                    public void actionPerformed(ActionEvent arg0) {
+                        if (ApplicationContext.databaseRef.getMultiframeStatus()) {
+                            SeriesChooserDelegate seriesChooser = new SeriesChooserDelegate(series.getStudyInstanceUID(), series.getSeriesInstanceUID(), series.isMultiframe(), series.getInstanceUID(), ref);
+                        } else {
+                            SeriesChooserDelegate seriesChooser = new SeriesChooserDelegate(series.getStudyInstanceUID(), series.getSeriesInstanceUID(), ref);
+                        }
+                    }
+                });
+            }
+            jPopupMenu2.add(menu);
+        }
+        this.setComponentPopupMenu(jPopupMenu2);
+    }
+
+    public Canvas getCanvas() {
+        return canvas;
+    }
+
+    public String getStudyUID() {
+        return studyUID;
+    }
+
+    public void setStudyUID(String studyUID) {
+        this.studyUID = studyUID;
+    }
+
+    public AnnotationPanel getAnnotationPanel() {
+        return annotationPanel;
+    }
+
+    public TextOverlay getTextOverlay() {
+        return textOverlay;
+    }
+
+    public void componentResized(ComponentEvent e) {
+        try {
+            if (canvas != null) {
+                this.canvas.resizeHandler();
+                this.imgpanel.resizeHandler();
+                this.textOverlay.resizeHandler();
+                this.annotationPanel.resizeHandler();
+            }
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+    }
+
+    public void componentMoved(ComponentEvent e) {
+    }
+
+    public void componentShown(ComponentEvent e) {
+    }
+
+    public void componentHidden(ComponentEvent e) {
+    }
+
+    public String[] getComparedWithStudies() {
+        return comparedWithStudies;
+    }
+
+    public void setComparedWithStudies(String[] comparedWithStudies) {
+        this.comparedWithStudies = comparedWithStudies;
+    }
+
+}
diff --git a/src/in/raster/mayam/form/LayoutManagerPanel.form b/src/in/raster/mayam/form/LayoutManagerPanel.form
new file mode 100644
index 0000000..ffb571d
--- /dev/null
+++ b/src/in/raster/mayam/form/LayoutManagerPanel.form
@@ -0,0 +1,156 @@
+<?xml version="1.1" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Component id="jLabel1" alignment="0" pref="437" max="32767" attributes="0"/>
+          <Group type="102" alignment="1" attributes="0">
+              <EmptySpace pref="96" max="32767" attributes="0"/>
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Group type="102" alignment="0" attributes="0">
+                      <EmptySpace min="-2" pref="7" max="-2" attributes="0"/>
+                      <Group type="103" groupAlignment="0" max="-2" attributes="0">
+                          <Component id="jPanel1" alignment="0" max="32767" attributes="1"/>
+                          <Component id="jComboBox1" alignment="0" min="-2" pref="79" max="-2" attributes="0"/>
+                          <Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/>
+                      </Group>
+                  </Group>
+                  <Component id="multiframe" alignment="0" min="-2" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace min="-2" pref="80" max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="0" attributes="0">
+              <Component id="jLabel1" min="-2" pref="24" max="-2" attributes="0"/>
+              <EmptySpace type="unrelated" max="-2" attributes="0"/>
+              <Component id="jLabel2" min="-2" max="-2" attributes="0"/>
+              <EmptySpace type="unrelated" max="-2" attributes="0"/>
+              <Component id="jComboBox1" min="-2" max="-2" attributes="0"/>
+              <EmptySpace type="separate" max="-2" attributes="0"/>
+              <Component id="jPanel1" min="-2" max="-2" attributes="0"/>
+              <EmptySpace type="separate" max="-2" attributes="0"/>
+              <Component id="multiframe" min="-2" max="-2" attributes="0"/>
+              <EmptySpace pref="142" max="32767" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Component class="javax.swing.JLabel" name="jLabel1">
+      <Properties>
+        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="0" green="0" red="0" type="rgb"/>
+        </Property>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Courier New" size="16" style="1"/>
+        </Property>
+        <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="0" green="8a" red="ff" type="rgb"/>
+        </Property>
+        <Property name="text" type="java.lang.String" value="Layout"/>
+        <Property name="opaque" type="boolean" value="true"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="jLabel2">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Modality"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JComboBox" name="jComboBox1">
+      <Properties>
+        <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+          <Connection code="new ModalityComboModel(ApplicationContext.databaseRef.getModalities())" type="code"/>
+        </Property>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jComboBox1ActionPerformed"/>
+      </Events>
+    </Component>
+    <Container class="javax.swing.JPanel" name="jPanel1">
+      <Properties>
+        <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+          <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
+            <TitledBorder title="Tile"/>
+          </Border>
+        </Property>
+      </Properties>
+
+      <Layout>
+        <DimensionLayout dim="0">
+          <Group type="103" groupAlignment="0" attributes="0">
+              <Group type="102" alignment="0" attributes="0">
+                  <EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
+                  <Group type="103" groupAlignment="0" attributes="0">
+                      <Component id="jLabel3" alignment="0" min="-2" max="-2" attributes="0"/>
+                      <Component id="jSpinner1" alignment="0" min="-2" pref="46" max="-2" attributes="0"/>
+                  </Group>
+                  <EmptySpace pref="51" max="32767" attributes="0"/>
+                  <Group type="103" groupAlignment="0" attributes="0">
+                      <Component id="jSpinner2" alignment="0" min="-2" pref="46" max="-2" attributes="0"/>
+                      <Component id="jLabel5" alignment="0" min="-2" max="-2" attributes="0"/>
+                  </Group>
+                  <EmptySpace min="-2" pref="45" max="-2" attributes="0"/>
+              </Group>
+          </Group>
+        </DimensionLayout>
+        <DimensionLayout dim="1">
+          <Group type="103" groupAlignment="0" attributes="0">
+              <Group type="102" alignment="0" attributes="0">
+                  <EmptySpace max="-2" attributes="0"/>
+                  <Group type="103" groupAlignment="3" attributes="0">
+                      <Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
+                      <Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/>
+                  </Group>
+                  <EmptySpace max="-2" attributes="0"/>
+                  <Group type="103" groupAlignment="3" attributes="0">
+                      <Component id="jSpinner1" alignment="3" min="-2" max="-2" attributes="0"/>
+                      <Component id="jSpinner2" alignment="3" min="-2" max="-2" attributes="0"/>
+                  </Group>
+                  <EmptySpace max="32767" attributes="0"/>
+              </Group>
+          </Group>
+        </DimensionLayout>
+      </Layout>
+      <SubComponents>
+        <Component class="javax.swing.JLabel" name="jLabel3">
+          <Properties>
+            <Property name="text" type="java.lang.String" value="Rows"/>
+          </Properties>
+        </Component>
+        <Component class="javax.swing.JLabel" name="jLabel5">
+          <Properties>
+            <Property name="text" type="java.lang.String" value="Columns"/>
+          </Properties>
+        </Component>
+        <Component class="javax.swing.JSpinner" name="jSpinner1">
+        </Component>
+        <Component class="javax.swing.JSpinner" name="jSpinner2">
+        </Component>
+      </SubComponents>
+    </Container>
+    <Component class="javax.swing.JCheckBox" name="multiframe">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Show multiframe instances as series"/>
+      </Properties>
+      <Events>
+        <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="multiframeItemStateChanged"/>
+      </Events>
+    </Component>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/LayoutManagerPanel.java b/src/in/raster/mayam/form/LayoutManagerPanel.java
new file mode 100644
index 0000000..a333991
--- /dev/null
+++ b/src/in/raster/mayam/form/LayoutManagerPanel.java
@@ -0,0 +1,245 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.model.Study;
+import in.raster.mayam.model.combo.ModalityComboModel;
+import javax.swing.JComboBox;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class LayoutManagerPanel extends javax.swing.JPanel {
+
+    /** Creates new form LayoutManagerPanel */
+    private boolean multiframeStatus;
+    public static boolean updateSeries = false;
+    public static boolean updatePropertiesDetails;
+
+    public LayoutManagerPanel() {
+        initComponents();
+        initializeDefault();
+    }
+
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        jLabel1 = new javax.swing.JLabel();
+        jLabel2 = new javax.swing.JLabel();
+        jComboBox1 = new javax.swing.JComboBox();
+        jPanel1 = new javax.swing.JPanel();
+        jLabel3 = new javax.swing.JLabel();
+        jLabel5 = new javax.swing.JLabel();
+        jSpinner1 = new javax.swing.JSpinner();
+        jSpinner2 = new javax.swing.JSpinner();
+        multiframe = new javax.swing.JCheckBox();
+
+        jLabel1.setBackground(new java.awt.Color(0, 0, 0));
+        jLabel1.setFont(new java.awt.Font("Courier New", 1, 16)); // NOI18N
+        jLabel1.setForeground(new java.awt.Color(255, 138, 0));
+        jLabel1.setText("Layout");
+        jLabel1.setOpaque(true);
+
+        jLabel2.setText("Modality");
+
+        jComboBox1.setModel(new ModalityComboModel(ApplicationContext.databaseRef.getModalities()));
+        jComboBox1.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                jComboBox1ActionPerformed(evt);
+            }
+        });
+
+        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Tile"));
+
+        jLabel3.setText("Rows");
+
+        jLabel5.setText("Columns");
+
+        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
+        jPanel1.setLayout(jPanel1Layout);
+        jPanel1Layout.setHorizontalGroup(
+            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(jPanel1Layout.createSequentialGroup()
+                .add(18, 18, 18)
+                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                    .add(jLabel3)
+                    .add(jSpinner1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 46, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 51, Short.MAX_VALUE)
+                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                    .add(jSpinner2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 46, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                    .add(jLabel5))
+                .add(45, 45, 45))
+        );
+        jPanel1Layout.setVerticalGroup(
+            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(jPanel1Layout.createSequentialGroup()
+                .addContainerGap()
+                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+                    .add(jLabel3)
+                    .add(jLabel5))
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+                    .add(jSpinner1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                    .add(jSpinner2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+        );
+
+        multiframe.setText("Show multiframe instances as series");
+        multiframe.addItemListener(new java.awt.event.ItemListener() {
+            public void itemStateChanged(java.awt.event.ItemEvent evt) {
+                multiframeItemStateChanged(evt);
+            }
+        });
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
+        this.setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 437, Short.MAX_VALUE)
+            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+                .addContainerGap(96, Short.MAX_VALUE)
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                    .add(layout.createSequentialGroup()
+                        .add(7, 7, 7)
+                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
+                            .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                            .add(jComboBox1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 79, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                            .add(jLabel2)))
+                    .add(multiframe))
+                .add(80, 80, 80))
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(layout.createSequentialGroup()
+                .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 24, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+                .add(jLabel2)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+                .add(jComboBox1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .add(18, 18, 18)
+                .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .add(18, 18, 18)
+                .add(multiframe)
+                .addContainerGap(142, Short.MAX_VALUE))
+        );
+    }// </editor-fold>//GEN-END:initComponents
+
+    private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
+        int rowColumn[] = ApplicationContext.databaseRef.getRowColumnForModality((String) ((JComboBox) evt.getSource()).getSelectedItem());
+        jSpinner1.setValue(rowColumn[0]);
+        jSpinner2.setValue(rowColumn[1]);
+    }//GEN-LAST:event_jComboBox1ActionPerformed
+
+    private void multiframeItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_multiframeItemStateChanged
+        if (multiframe.isSelected()) {
+            updatePropertiesDetails = true;
+        } else {
+            updatePropertiesDetails = false;
+        }
+    }//GEN-LAST:event_multiframeItemStateChanged
+    public void initializeDefault() {
+        jComboBox1.setSelectedIndex(0);
+        int rowColumn[] = ApplicationContext.databaseRef.getRowColumnForModality((String) jComboBox1.getSelectedItem());
+        jSpinner1.setValue(rowColumn[0]);
+        jSpinner2.setValue(rowColumn[1]);
+        multiframeStatus = ApplicationContext.databaseRef.getMultiframeStatus();
+        multiframe.setSelected(ApplicationContext.databaseRef.getMultiframeStatus());
+    }
+
+    public void updateSeriesDisplayModification() {
+        if (multiframeStatus != multiframe.isSelected()) {
+            if (ApplicationContext.imageViewExist()) {
+                updateSeries = true;
+                ApplicationContext.imgView.dispose();
+            } else {
+
+                if (updatePropertiesDetails) {
+                    ApplicationContext.databaseRef.updatePropertiesDetail("true");
+                } else {
+                    ApplicationContext.databaseRef.updatePropertiesDetail("false");
+                }
+                for (Study study : MainScreen.studyList) {
+                    if (study.getStudyInstanceUID().equalsIgnoreCase(MainScreen.selectedStudy)) {
+                        MainScreen.studyList.remove(study);
+                        ApplicationContext.mainScreen.showThumbnails();
+                    }
+                }
+            }
+        }
+    }
+
+    private void updateSeriesDisplay() {
+    }
+
+    public String[] getModalityLayoutDetail() {
+        String temp[] = new String[3];
+        String modality = (String) jComboBox1.getSelectedItem();
+        String rowCount = jSpinner1.getValue().toString();
+        String columnCount = jSpinner2.getValue().toString();
+        temp[0] = modality;
+        temp[1] = rowCount;
+        temp[2] = columnCount;
+        return temp;
+
+    }
+
+    public JComboBox getModalityCombo() {
+        return jComboBox1;
+    }
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JComboBox jComboBox1;
+    private javax.swing.JLabel jLabel1;
+    private javax.swing.JLabel jLabel2;
+    private javax.swing.JLabel jLabel3;
+    private javax.swing.JLabel jLabel5;
+    private javax.swing.JPanel jPanel1;
+    private javax.swing.JSpinner jSpinner1;
+    private javax.swing.JSpinner jSpinner2;
+    private javax.swing.JCheckBox multiframe;
+    // End of variables declaration//GEN-END:variables
+}
\ No newline at end of file
diff --git a/src/in/raster/mayam/form/MainScreen.form b/src/in/raster/mayam/form/MainScreen.form
new file mode 100644
index 0000000..7779aaf
--- /dev/null
+++ b/src/in/raster/mayam/form/MainScreen.form
@@ -0,0 +1,666 @@
+<?xml version="1.1" encoding="UTF-8" ?>
+
+<Form version="1.6" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
+  <NonVisualComponents>
+    <Menu class="javax.swing.JMenuBar" name="menuBar">
+      <SubComponents>
+        <Menu class="javax.swing.JMenu" name="jMenu1">
+          <Properties>
+            <Property name="text" type="java.lang.String" value="File"/>
+          </Properties>
+          <SubComponents>
+            <MenuItem class="javax.swing.JMenuItem" name="importMenuItem">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="Import"/>
+              </Properties>
+              <Events>
+                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="importMenuItemActionPerformed"/>
+              </Events>
+            </MenuItem>
+            <MenuItem class="javax.swing.JMenuItem" name="exportMenuItem">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="Export"/>
+              </Properties>
+              <Events>
+                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="exportMenuItemActionPerformed"/>
+              </Events>
+            </MenuItem>
+            <MenuItem class="javax.swing.JSeparator" name="jSeparator2">
+            </MenuItem>
+            <MenuItem class="javax.swing.JMenuItem" name="deleteExamMenuItem">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="Delete Selected Exam"/>
+              </Properties>
+              <Events>
+                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="deleteExamMenuItemActionPerformed"/>
+              </Events>
+            </MenuItem>
+            <MenuItem class="javax.swing.JMenuItem" name="jMenuItem8">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="Anonymize"/>
+                <Property name="enabled" type="boolean" value="false"/>
+              </Properties>
+            </MenuItem>
+            <MenuItem class="javax.swing.JSeparator" name="jSeparator3">
+            </MenuItem>
+            <MenuItem class="javax.swing.JMenuItem" name="resetMenuItem">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="Reset DB"/>
+              </Properties>
+              <Events>
+                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="resetMenuItemActionPerformed"/>
+              </Events>
+            </MenuItem>
+            <MenuItem class="javax.swing.JSeparator" name="jSeparator4">
+            </MenuItem>
+            <MenuItem class="javax.swing.JMenuItem" name="exitMenuItem">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="Exit"/>
+              </Properties>
+              <Events>
+                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="exitMenuItemActionPerformed"/>
+              </Events>
+            </MenuItem>
+          </SubComponents>
+        </Menu>
+        <Menu class="javax.swing.JMenu" name="jMenu2">
+          <Properties>
+            <Property name="text" type="java.lang.String" value="Tools"/>
+          </Properties>
+          <SubComponents>
+            <MenuItem class="javax.swing.JMenuItem" name="preferenceMenuItem">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="Preferences"/>
+              </Properties>
+              <Events>
+                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="preferenceMenuItemActionPerformed"/>
+              </Events>
+            </MenuItem>
+          </SubComponents>
+        </Menu>
+        <Menu class="javax.swing.JMenu" name="jMenu3">
+          <Properties>
+            <Property name="text" type="java.lang.String" value="Network"/>
+          </Properties>
+          <SubComponents>
+            <MenuItem class="javax.swing.JMenuItem" name="queueMenuItem">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="Queue"/>
+              </Properties>
+              <Events>
+                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="queueMenuItemActionPerformed"/>
+              </Events>
+            </MenuItem>
+            <MenuItem class="javax.swing.JMenuItem" name="sendMenuItem">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="Send"/>
+              </Properties>
+              <Events>
+                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="sendMenuItemActionPerformed"/>
+              </Events>
+            </MenuItem>
+            <MenuItem class="javax.swing.JMenuItem" name="QRMenuItem1">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="Query/Retrieve"/>
+              </Properties>
+              <Events>
+                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="QRMenuItem1ActionPerformed"/>
+              </Events>
+            </MenuItem>
+          </SubComponents>
+        </Menu>
+        <Menu class="javax.swing.JMenu" name="jMenu5">
+          <Properties>
+            <Property name="text" type="java.lang.String" value="Theme"/>
+          </Properties>
+          <SubComponents>
+            <MenuItem class="javax.swing.JMenuItem" name="nimrodLFMenu">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="Nimrod"/>
+              </Properties>
+              <Events>
+                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="nimrodLFMenuActionPerformed"/>
+              </Events>
+            </MenuItem>
+            <MenuItem class="javax.swing.JMenuItem" name="motifLFMenu">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="Motif"/>
+              </Properties>
+              <Events>
+                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="motifLFMenuActionPerformed"/>
+              </Events>
+            </MenuItem>
+            <MenuItem class="javax.swing.JMenuItem" name="systemLFmenu">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="System L&F"/>
+              </Properties>
+              <Events>
+                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="systemLFmenuActionPerformed"/>
+              </Events>
+            </MenuItem>
+          </SubComponents>
+        </Menu>
+        <Menu class="javax.swing.JMenu" name="jMenu4">
+          <Properties>
+            <Property name="text" type="java.lang.String" value="Help"/>
+          </Properties>
+          <SubComponents>
+            <MenuItem class="javax.swing.JMenuItem" name="userManualItem">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="User Manual"/>
+              </Properties>
+            </MenuItem>
+            <MenuItem class="javax.swing.JMenuItem" name="aboutMenu">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="About"/>
+              </Properties>
+              <Events>
+                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="aboutMenuActionPerformed"/>
+              </Events>
+            </MenuItem>
+          </SubComponents>
+        </Menu>
+      </SubComponents>
+    </Menu>
+  </NonVisualComponents>
+  <Properties>
+    <Property name="defaultCloseOperation" type="int" value="3"/>
+    <Property name="title" type="java.lang.String" value="Mayam"/>
+    <Property name="iconImage" type="java.awt.Image" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+      <Connection code="Toolkit.getDefaultToolkit().getImage(getClass().getResource("/in/raster/mayam/form/images/fav_mayam.png"))" type="code"/>
+    </Property>
+  </Properties>
+  <SyntheticProperties>
+    <SyntheticProperty name="menuBar" type="java.lang.String" value="menuBar"/>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Component id="container" alignment="0" max="32767" attributes="0"/>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Component id="container" alignment="0" max="32767" attributes="0"/>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Container class="javax.swing.JPanel" name="container">
+
+      <Layout>
+        <DimensionLayout dim="0">
+          <Group type="103" groupAlignment="0" attributes="0">
+              <Component id="contentArea" alignment="0" max="32767" attributes="1"/>
+              <Component id="headerPanel" alignment="0" pref="1025" max="32767" attributes="1"/>
+          </Group>
+        </DimensionLayout>
+        <DimensionLayout dim="1">
+          <Group type="103" groupAlignment="0" attributes="0">
+              <Group type="102" alignment="0" attributes="0">
+                  <Component id="headerPanel" min="-2" max="-2" attributes="0"/>
+                  <EmptySpace max="-2" attributes="0"/>
+                  <Component id="contentArea" max="32767" attributes="0"/>
+                  <EmptySpace max="-2" attributes="0"/>
+              </Group>
+          </Group>
+        </DimensionLayout>
+      </Layout>
+      <SubComponents>
+        <Container class="javax.swing.JPanel" name="contentArea">
+
+          <Layout>
+            <DimensionLayout dim="0">
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Group type="102" alignment="0" attributes="0">
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Group type="103" groupAlignment="0" attributes="0">
+                          <Component id="jSplitPane1" alignment="0" pref="985" max="32767" attributes="0"/>
+                          <Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
+                      </Group>
+                      <EmptySpace max="-2" attributes="0"/>
+                  </Group>
+              </Group>
+            </DimensionLayout>
+            <DimensionLayout dim="1">
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Group type="102" alignment="0" attributes="0">
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="jSplitPane1" pref="761" max="32767" attributes="0"/>
+                  </Group>
+              </Group>
+            </DimensionLayout>
+          </Layout>
+          <SubComponents>
+            <Component class="javax.swing.JLabel" name="jLabel1">
+              <Properties>
+                <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+                  <Font name="Courier New" size="16" style="1"/>
+                </Property>
+                <Property name="text" type="java.lang.String" value=" Local Database"/>
+              </Properties>
+            </Component>
+            <Container class="javax.swing.JSplitPane" name="jSplitPane1">
+              <Properties>
+                <Property name="dividerLocation" type="int" value="256"/>
+                <Property name="dividerSize" type="int" value="4"/>
+                <Property name="orientation" type="int" value="0"/>
+              </Properties>
+
+              <Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/>
+              <SubComponents>
+                <Container class="javax.swing.JScrollPane" name="studyTableScroll">
+                  <AuxValues>
+                    <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+                  </AuxValues>
+                  <Constraints>
+                    <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
+                      <JSplitPaneConstraints position="top"/>
+                    </Constraint>
+                  </Constraints>
+
+                  <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+                  <SubComponents>
+                    <Component class="javax.swing.JTable" name="studyListTable">
+                      <Properties>
+                        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+                          <Font name="Courier" size="13" style="0"/>
+                        </Property>
+                        <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+                          <Color blue="0" green="8a" red="fc" type="rgb"/>
+                        </Property>
+                        <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+                          <Connection code="new StudyListModel()" type="code"/>
+                        </Property>
+                        <Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor">
+                          <TableColumnModel selectionModel="0"/>
+                        </Property>
+                        <Property name="showGrid" type="boolean" value="true"/>
+                      </Properties>
+                      <Events>
+                        <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="studyListTableMouseClicked"/>
+                      </Events>
+                      <AuxValues>
+                        <AuxValue name="JavaCodeGenerator_InitCodePost" type="java.lang.String" value="studyListTable.setDefaultRenderer(Object.class, new CellRenderer());"/>
+                        <AuxValue name="JavaCodeGenerator_ListenersCodePost" type="java.lang.String" value="studyListTable.getTableHeader().setPreferredSize(new Dimension(this.getWidth(), 25));&#xa;Font f=new Font("Courier New",Font.BOLD,14);&#xa;studyListTable.getTableHeader().setFont(new Font(f.getName(),Font.BOLD,14));&#xa;studyListTable.setRowHeight(25);&#xa;studyListTable.getTableHeader().setForeground(new Color(255,138,0));&#xa;studyListTable.getTableHeader().setBackgroun [...]
+                        <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="9"/>
+                      </AuxValues>
+                    </Component>
+                  </SubComponents>
+                </Container>
+                <Container class="javax.swing.JPanel" name="studyAndSeriesDisplayPanel">
+                  <Constraints>
+                    <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
+                      <JSplitPaneConstraints position="right"/>
+                    </Constraint>
+                  </Constraints>
+
+                  <Layout>
+                    <DimensionLayout dim="0">
+                      <Group type="103" groupAlignment="0" attributes="0">
+                          <Group type="102" attributes="0">
+                              <Group type="103" groupAlignment="0" max="-2" attributes="0">
+                                  <Component id="thumbnailScroll" pref="330" max="32767" attributes="1"/>
+                                  <Component id="jLabel2" alignment="1" pref="330" max="32767" attributes="1"/>
+                              </Group>
+                              <EmptySpace min="-2" max="-2" attributes="0"/>
+                              <Component id="windowingPanelCanvas" pref="641" max="32767" attributes="0"/>
+                          </Group>
+                      </Group>
+                    </DimensionLayout>
+                    <DimensionLayout dim="1">
+                      <Group type="103" groupAlignment="0" attributes="0">
+                          <Group type="102" alignment="0" attributes="1">
+                              <Component id="jLabel2" min="-2" pref="20" max="-2" attributes="0"/>
+                              <EmptySpace max="-2" attributes="0"/>
+                              <Component id="thumbnailScroll" pref="471" max="32767" attributes="0"/>
+                          </Group>
+                          <Component id="windowingPanelCanvas" alignment="0" pref="499" max="32767" attributes="2"/>
+                      </Group>
+                    </DimensionLayout>
+                  </Layout>
+                  <SubComponents>
+                    <Container class="javax.swing.JPanel" name="windowingPanelCanvas">
+                      <Properties>
+                        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+                          <Color blue="0" green="0" red="0" type="rgb"/>
+                        </Property>
+                        <Property name="autoscrolls" type="boolean" value="true"/>
+                        <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+                          <Dimension value="[50, 50]"/>
+                        </Property>
+                      </Properties>
+
+                      <Layout>
+                        <DimensionLayout dim="0">
+                          <Group type="103" groupAlignment="0" attributes="0">
+                              <EmptySpace min="0" pref="641" max="32767" attributes="0"/>
+                          </Group>
+                        </DimensionLayout>
+                        <DimensionLayout dim="1">
+                          <Group type="103" groupAlignment="0" attributes="0">
+                              <EmptySpace min="0" pref="499" max="32767" attributes="0"/>
+                          </Group>
+                        </DimensionLayout>
+                      </Layout>
+                    </Container>
+                    <Container class="javax.swing.JScrollPane" name="thumbnailScroll">
+                      <Properties>
+                        <Property name="verticalScrollBarPolicy" type="int" value="22"/>
+                      </Properties>
+                      <AuxValues>
+                        <AuxValue name="JavaCodeGenerator_InitCodePost" type="java.lang.String" value="thumbnailScroll.getVerticalScrollBar().setUnitIncrement(24);&#xa;"/>
+                      </AuxValues>
+
+                      <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+                      <SubComponents>
+                        <Container class="javax.swing.JPanel" name="thumbnailDisplay">
+                          <Properties>
+                            <Property name="autoscrolls" type="boolean" value="true"/>
+                            <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
+                              <Color id="Default Cursor"/>
+                            </Property>
+                            <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+                              <Dimension value="[1000, 1000]"/>
+                            </Property>
+                            <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+                              <Dimension value="[13, 2]"/>
+                            </Property>
+                          </Properties>
+
+                          <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
+                        </Container>
+                      </SubComponents>
+                    </Container>
+                    <Component class="javax.swing.JLabel" name="jLabel2">
+                      <Properties>
+                        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+                          <Color blue="0" green="0" red="0" type="rgb"/>
+                        </Property>
+                        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+                          <Font name="Courier New" size="16" style="1"/>
+                        </Property>
+                        <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+                          <Color blue="0" green="8a" red="ff" type="rgb"/>
+                        </Property>
+                        <Property name="text" type="java.lang.String" value="Series "/>
+                        <Property name="opaque" type="boolean" value="true"/>
+                      </Properties>
+                    </Component>
+                  </SubComponents>
+                </Container>
+              </SubComponents>
+            </Container>
+          </SubComponents>
+        </Container>
+        <Container class="javax.swing.JPanel" name="headerPanel">
+          <Properties>
+            <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+              <Border info="org.netbeans.modules.form.compat2.border.MatteColorBorderInfo">
+                <MatteColorBorder bottom="1" left="0" right="0" top="0">
+                  <Color PropertyName="color" blue="d" green="d" red="d" type="rgb"/>
+                </MatteColorBorder>
+              </Border>
+            </Property>
+          </Properties>
+
+          <Layout>
+            <DimensionLayout dim="0">
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Group type="102" attributes="0">
+                      <EmptySpace min="-2" pref="5" max="-2" attributes="0"/>
+                      <Component id="importButton" min="-2" pref="79" max="-2" attributes="0"/>
+                      <EmptySpace type="unrelated" max="-2" attributes="0"/>
+                      <Component id="exportButton" min="-2" pref="79" max="-2" attributes="0"/>
+                      <EmptySpace type="unrelated" max="-2" attributes="0"/>
+                      <Component id="cdImportButton" min="-2" pref="85" max="-2" attributes="0"/>
+                      <EmptySpace type="unrelated" max="-2" attributes="0"/>
+                      <Component id="deleteButton" min="-2" pref="78" max="-2" attributes="0"/>
+                      <EmptySpace type="unrelated" max="-2" attributes="0"/>
+                      <Component id="metaDataButton" min="-2" pref="114" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="sendButton" min="-2" pref="69" max="-2" attributes="0"/>
+                      <EmptySpace type="unrelated" max="-2" attributes="0"/>
+                      <Component id="queryRetrieveButton" min="-2" pref="78" max="-2" attributes="0"/>
+                      <EmptySpace type="unrelated" max="-2" attributes="0"/>
+                      <Component id="viewerButton" min="-2" pref="79" max="-2" attributes="0"/>
+                      <EmptySpace type="unrelated" max="-2" attributes="0"/>
+                      <Component id="queueButton" min="-2" pref="78" max="-2" attributes="0"/>
+                      <EmptySpace min="-2" pref="277" max="-2" attributes="0"/>
+                  </Group>
+              </Group>
+            </DimensionLayout>
+            <DimensionLayout dim="1">
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Group type="102" alignment="0" attributes="0">
+                      <EmptySpace min="-2" pref="5" max="-2" attributes="0"/>
+                      <Group type="103" groupAlignment="0" attributes="0">
+                          <Component id="metaDataButton" linkSize="1" alignment="0" min="-2" max="-2" attributes="0"/>
+                          <Component id="exportButton" linkSize="1" alignment="0" min="-2" max="-2" attributes="0"/>
+                          <Component id="importButton" linkSize="1" alignment="0" min="-2" max="-2" attributes="0"/>
+                          <Component id="deleteButton" linkSize="1" alignment="0" min="-2" max="-2" attributes="0"/>
+                          <Component id="sendButton" linkSize="1" alignment="0" min="-2" max="-2" attributes="0"/>
+                          <Component id="queryRetrieveButton" linkSize="1" alignment="0" min="-2" max="-2" attributes="0"/>
+                          <Component id="viewerButton" linkSize="1" alignment="0" min="-2" max="-2" attributes="0"/>
+                          <Component id="queueButton" linkSize="1" alignment="0" min="-2" max="-2" attributes="0"/>
+                          <Component id="cdImportButton" linkSize="1" alignment="0" min="-2" max="-2" attributes="0"/>
+                      </Group>
+                      <EmptySpace max="32767" attributes="0"/>
+                  </Group>
+              </Group>
+            </DimensionLayout>
+          </Layout>
+          <SubComponents>
+            <Component class="javax.swing.JButton" name="importButton">
+              <Properties>
+                <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+                  <Image iconType="3" name="/in/raster/mayam/form/images/import.png"/>
+                </Property>
+                <Property name="text" type="java.lang.String" value="Import"/>
+                <Property name="toolTipText" type="java.lang.String" value="Import"/>
+                <Property name="borderPainted" type="boolean" value="false"/>
+                <Property name="contentAreaFilled" type="boolean" value="false"/>
+                <Property name="horizontalTextPosition" type="int" value="0"/>
+                <Property name="rolloverIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+                  <Image iconType="3" name="/in/raster/mayam/form/images/import1.png"/>
+                </Property>
+                <Property name="verticalTextPosition" type="int" value="3"/>
+              </Properties>
+              <Events>
+                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="importButtonActionPerformed"/>
+              </Events>
+            </Component>
+            <Component class="javax.swing.JButton" name="exportButton">
+              <Properties>
+                <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+                  <Image iconType="3" name="/in/raster/mayam/form/images/export_study.png"/>
+                </Property>
+                <Property name="text" type="java.lang.String" value="Export"/>
+                <Property name="toolTipText" type="java.lang.String" value="Export"/>
+                <Property name="borderPainted" type="boolean" value="false"/>
+                <Property name="contentAreaFilled" type="boolean" value="false"/>
+                <Property name="defaultCapable" type="boolean" value="false"/>
+                <Property name="horizontalTextPosition" type="int" value="0"/>
+                <Property name="rolloverIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+                  <Image iconType="3" name="/in/raster/mayam/form/images/export_study1.png"/>
+                </Property>
+                <Property name="verticalTextPosition" type="int" value="3"/>
+              </Properties>
+              <Events>
+                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="exportButtonActionPerformed"/>
+              </Events>
+            </Component>
+            <Component class="javax.swing.JButton" name="cdImportButton">
+              <Properties>
+                <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+                  <Image iconType="3" name="/in/raster/mayam/form/images/cd_import.png"/>
+                </Property>
+                <Property name="text" type="java.lang.String" value="CD-Rom"/>
+                <Property name="toolTipText" type="java.lang.String" value="CD-Rom"/>
+                <Property name="borderPainted" type="boolean" value="false"/>
+                <Property name="contentAreaFilled" type="boolean" value="false"/>
+                <Property name="defaultCapable" type="boolean" value="false"/>
+                <Property name="horizontalTextPosition" type="int" value="0"/>
+                <Property name="rolloverIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+                  <Image iconType="3" name="/in/raster/mayam/form/images/cd_import1.png"/>
+                </Property>
+                <Property name="verticalTextPosition" type="int" value="3"/>
+              </Properties>
+              <Events>
+                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cdImportButtonActionPerformed"/>
+              </Events>
+            </Component>
+            <Component class="javax.swing.JButton" name="deleteButton">
+              <Properties>
+                <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+                  <Image iconType="3" name="/in/raster/mayam/form/images/delete_study.png"/>
+                </Property>
+                <Property name="text" type="java.lang.String" value="Delete"/>
+                <Property name="toolTipText" type="java.lang.String" value="Delete"/>
+                <Property name="borderPainted" type="boolean" value="false"/>
+                <Property name="contentAreaFilled" type="boolean" value="false"/>
+                <Property name="horizontalTextPosition" type="int" value="0"/>
+                <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+                  <Dimension value="[52, 50]"/>
+                </Property>
+                <Property name="rolloverIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+                  <Image iconType="3" name="/in/raster/mayam/form/images/delete_study1.png"/>
+                </Property>
+                <Property name="verticalTextPosition" type="int" value="3"/>
+              </Properties>
+              <Events>
+                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="deleteButtonActionPerformed"/>
+              </Events>
+            </Component>
+            <Component class="javax.swing.JButton" name="metaDataButton">
+              <Properties>
+                <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+                  <Image iconType="3" name="/in/raster/mayam/form/images/metadata_mainpage.png"/>
+                </Property>
+                <Property name="text" type="java.lang.String" value="Meta Data"/>
+                <Property name="toolTipText" type="java.lang.String" value="Meta Data"/>
+                <Property name="borderPainted" type="boolean" value="false"/>
+                <Property name="contentAreaFilled" type="boolean" value="false"/>
+                <Property name="horizontalTextPosition" type="int" value="0"/>
+                <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+                  <Dimension value="[52, 50]"/>
+                </Property>
+                <Property name="rolloverIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+                  <Image iconType="3" name="/in/raster/mayam/form/images/metadata_mainpage1.png"/>
+                </Property>
+                <Property name="verticalTextPosition" type="int" value="3"/>
+              </Properties>
+              <Events>
+                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="metaDataButtonActionPerformed"/>
+              </Events>
+            </Component>
+            <Component class="javax.swing.JButton" name="sendButton">
+              <Properties>
+                <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+                  <Image iconType="3" name="/in/raster/mayam/form/images/send.png"/>
+                </Property>
+                <Property name="text" type="java.lang.String" value="Send"/>
+                <Property name="toolTipText" type="java.lang.String" value="Send"/>
+                <Property name="borderPainted" type="boolean" value="false"/>
+                <Property name="contentAreaFilled" type="boolean" value="false"/>
+                <Property name="horizontalTextPosition" type="int" value="0"/>
+                <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+                  <Dimension value="[52, 50]"/>
+                </Property>
+                <Property name="rolloverIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+                  <Image iconType="3" name="/in/raster/mayam/form/images/send1.png"/>
+                </Property>
+                <Property name="verticalTextPosition" type="int" value="3"/>
+              </Properties>
+              <Events>
+                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="sendButtonActionPerformed"/>
+              </Events>
+            </Component>
+            <Component class="javax.swing.JButton" name="queryRetrieveButton">
+              <Properties>
+                <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+                  <Image iconType="3" name="/in/raster/mayam/form/images/query.png"/>
+                </Property>
+                <Property name="text" type="java.lang.String" value="Query"/>
+                <Property name="toolTipText" type="java.lang.String" value="Query"/>
+                <Property name="borderPainted" type="boolean" value="false"/>
+                <Property name="contentAreaFilled" type="boolean" value="false"/>
+                <Property name="horizontalTextPosition" type="int" value="0"/>
+                <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+                  <Dimension value="[52, 50]"/>
+                </Property>
+                <Property name="rolloverIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+                  <Image iconType="3" name="/in/raster/mayam/form/images/query1.png"/>
+                </Property>
+                <Property name="verticalTextPosition" type="int" value="3"/>
+              </Properties>
+              <Events>
+                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="queryRetrieveButtonActionPerformed"/>
+              </Events>
+            </Component>
+            <Component class="javax.swing.JButton" name="viewerButton">
+              <Properties>
+                <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+                  <Image iconType="3" name="/in/raster/mayam/form/images/viewer.png"/>
+                </Property>
+                <Property name="text" type="java.lang.String" value="Viewer"/>
+                <Property name="toolTipText" type="java.lang.String" value="Viewer"/>
+                <Property name="borderPainted" type="boolean" value="false"/>
+                <Property name="contentAreaFilled" type="boolean" value="false"/>
+                <Property name="horizontalTextPosition" type="int" value="0"/>
+                <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+                  <Dimension value="[52, 50]"/>
+                </Property>
+                <Property name="rolloverIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+                  <Image iconType="3" name="/in/raster/mayam/form/images/viewer1.png"/>
+                </Property>
+                <Property name="verticalTextPosition" type="int" value="3"/>
+              </Properties>
+              <Events>
+                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="viewerButtonActionPerformed"/>
+              </Events>
+            </Component>
+            <Component class="javax.swing.JButton" name="queueButton">
+              <Properties>
+                <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+                  <Image iconType="3" name="/in/raster/mayam/form/images/queue.png"/>
+                </Property>
+                <Property name="text" type="java.lang.String" value="Queue"/>
+                <Property name="toolTipText" type="java.lang.String" value="Queue"/>
+                <Property name="borderPainted" type="boolean" value="false"/>
+                <Property name="contentAreaFilled" type="boolean" value="false"/>
+                <Property name="focusPainted" type="boolean" value="false"/>
+                <Property name="horizontalTextPosition" type="int" value="0"/>
+                <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+                  <Dimension value="[52, 50]"/>
+                </Property>
+                <Property name="rolloverIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+                  <Image iconType="3" name="/in/raster/mayam/form/images/queue1.png"/>
+                </Property>
+                <Property name="verticalTextPosition" type="int" value="3"/>
+              </Properties>
+              <Events>
+                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="queueButtonActionPerformed"/>
+              </Events>
+            </Component>
+          </SubComponents>
+        </Container>
+      </SubComponents>
+    </Container>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/MainScreen.java b/src/in/raster/mayam/form/MainScreen.java
new file mode 100644
index 0000000..34c11c9
--- /dev/null
+++ b/src/in/raster/mayam/form/MainScreen.java
@@ -0,0 +1,1222 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form;
+
+import com.nilo.plaf.nimrod.NimRODLookAndFeel;
+import com.sun.java.swing.plaf.motif.MotifLookAndFeel;
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.delegate.ImportDcmDirDelegate;
+import in.raster.mayam.delegate.InputArgumentsParser;
+import in.raster.mayam.delegate.ReceiveDelegate;
+import in.raster.mayam.delegate.SendingDelegate;
+import in.raster.mayam.delegate.SeriesThumbUpdator;
+import in.raster.mayam.delegate.ShowComparisonViewerDelegate;
+import in.raster.mayam.delegate.ShowViewerDelegate;
+import in.raster.mayam.delegate.StudyListUpdator;
+import in.raster.mayam.delegate.WadoRetrieveDelegate;
+import in.raster.mayam.form.dialog.About;
+import in.raster.mayam.form.dialog.ConfirmDelete;
+import in.raster.mayam.form.dialog.FileChooserDialog;
+import in.raster.mayam.form.dialog.ExportLocationChooser;
+import in.raster.mayam.form.dialog.ServerListDialog;
+import in.raster.mayam.form.dialog.SettingsDialog;
+import in.raster.mayam.util.DicomTags;
+import in.raster.mayam.util.DicomTagsReader;
+import in.raster.mayam.model.AEModel;
+import in.raster.mayam.model.InputArgumentValues;
+import in.raster.mayam.model.ServerModel;
+import in.raster.mayam.model.Study;
+import in.raster.mayam.model.table.StudyListModel;
+import in.raster.mayam.model.table.renderer.CellRenderer;
+import java.awt.Color;
+import java.awt.Cursor;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.Toolkit;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.swing.JFrame;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+import javax.swing.SwingUtilities;
+import javax.swing.UIDefaults;
+import javax.swing.table.TableModel;
+import javax.swing.table.TableRowSorter;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class MainScreen extends javax.swing.JFrame {
+
+    /** Creates new form MainScreen */
+    private MainScreen() {
+        initComponents();
+        initAppDefaults();
+    }
+
+    private void initAppDefaults() {
+        setExtendedState(JFrame.MAXIMIZED_BOTH);
+        ApplicationContext.mainScreen = this;
+        checkLogFileExist();
+        initDB();
+        initQR();
+        startListening();
+        showLocalDBStorage();
+        showThumbnails();
+        initNetworkQueue();
+        initSendingProgress();
+        setTheme();
+        ImportDcmDirDelegate.findAndLoadDcmDirFiles();
+        loadStudiesBasedOnInputParameter();
+
+    }
+
+    private void setTheme() {
+        systemLFmenu.setText(System.getProperty("os.name"));
+        String activeTheme = ApplicationContext.databaseRef.getActiveTheme();
+        if (activeTheme.equalsIgnoreCase("Nimrod")) {
+            setNimrodTheme();
+        } else if (activeTheme.equalsIgnoreCase("Motif")) {
+            setMotifTheme();
+        } else if (activeTheme.equalsIgnoreCase("System")) {
+            setSystemTheme();
+        }
+    }
+
+    public void loadStudiesBasedOnInputParameter() {
+        InputArgumentValues inputArgumentValues = InputArgumentsParser.inputArgumentValues;
+        if (inputArgumentValues.getAeTitle() != null && inputArgumentValues.getPort() != 0 && inputArgumentValues.getHostName() != null && inputArgumentValues.getWadoContext() != null && inputArgumentValues.getWadoPort() != 0 && inputArgumentValues.getWadoProtocol() != null) {
+            ServerModel serverModel = new ServerModel();
+            serverModel.setAeTitle(inputArgumentValues.getAeTitle());
+            serverModel.setHostName(inputArgumentValues.getHostName());
+            serverModel.setPort(inputArgumentValues.getPort());
+            serverModel.setWadoContextPath(inputArgumentValues.getWadoContext());
+            serverModel.setWadoPort(inputArgumentValues.getWadoPort());
+            serverModel.setWadoProtocol(inputArgumentValues.getWadoProtocol());
+            WadoRetrieveDelegate wadoRetrieveDelegate = new WadoRetrieveDelegate();
+            wadoRetrieveDelegate.retrieveStudy(serverModel);
+        }
+    }
+
+    /**
+     * This routine used to initialize the sending progress
+     */
+    private void initSendingProgress() {
+        SendingProgress sendingProgress = new SendingProgress();
+        ApplicationContext.sendingProgress = sendingProgress;
+    }
+
+    /**
+     * This routine used to initialize the query
+     */
+    private void initQR() {
+        queryRetrieve = new QueryRetrieve();
+        queryRetrieve.setLocationRelativeTo(this);
+    }
+
+    /**
+     * This routine used to initialize the network queue
+     */
+    public void initNetworkQueue() {
+        sndRcvFrm = new SendReceiveFrame();
+        sndRcvFrm.setLocationRelativeTo(this);
+        sndRcvFrm.setVisible(false);
+    }
+
+    /**
+     * This routine used to initialize the database
+     */
+    public void initDB() {
+        ApplicationContext.openOrCreateDB();
+    }
+
+    /**
+     * This routine used to find out whether log file exist or not in the application
+     */
+    public void checkLogFileExist() {
+        ApplicationContext.createLogFile();
+    }
+
+    /**
+     * This routine used to start the receiver
+     */
+    private void startListening() {
+        try {
+            startReceiver();
+            System.out.println("Start Server listening on port " + receiveDelegate.getPort());
+        } catch (Exception e) {
+            ApplicationContext.writeLog(e.toString());
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * This routine used to start the receiver
+     */
+    public void startReceiver() throws Exception {
+        receiveDelegate = new ReceiveDelegate();
+        receiveDelegate.start();
+    }
+
+    /**
+     * This routine used to stop the receiver
+     */
+    public void stopReceiver() {
+        receiveDelegate.stop();
+    }
+
+    /**
+     * This routine is used to restart the receiver
+     */
+    public void restartReceiver() {
+        try {
+            stopReceiver();
+            System.out.println("Stop Server listening on port " + receiveDelegate.getPort());
+            startReceiver();
+            System.out.println("Start Server listening on port " + receiveDelegate.getPort());
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * This routine is used to update the local database storage
+     */
+    public static void showLocalDBStorage() {
+        refreshLocalDBStorage();
+        if (studyListTable.getRowCount() > 0) {
+            studyListTable.setRowSelectionInterval(0, 0);
+        }
+    }
+
+    /**
+     * This routine used to refresh the local database study list.
+     */
+    public synchronized static void refreshLocalDBStorage() {
+        int i = 0;
+        if (studyListTable.getRowCount() > 2) {
+            i = studyListTable.getSelectedRow();
+        }
+        StudyListModel studyListModel = new StudyListModel();
+        studyListModel.setData(ApplicationContext.databaseRef.listAllStudiesOfDB());
+        studyListTable.setModel((TableModel) studyListModel);
+        TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(studyListModel);
+        studyListTable.setRowSorter(sorter);
+        if (studyListTable.getRowCount() > 0) {
+            if (i < studyListTable.getRowCount()) {
+                studyListTable.setRowSelectionInterval(i, i);
+            } else {
+                studyListTable.setRowSelectionInterval(i - 1, i - 1);
+            }
+        }
+    }
+
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        container = new javax.swing.JPanel();
+        contentArea = new javax.swing.JPanel();
+        jLabel1 = new javax.swing.JLabel();
+        jSplitPane1 = new javax.swing.JSplitPane();
+        studyTableScroll = new javax.swing.JScrollPane();
+        studyListTable = new javax.swing.JTable();
+        studyAndSeriesDisplayPanel = new javax.swing.JPanel();
+        windowingPanelCanvas = new javax.swing.JPanel();
+        thumbnailScroll = new javax.swing.JScrollPane();
+        thumbnailDisplay = new javax.swing.JPanel();
+        jLabel2 = new javax.swing.JLabel();
+        headerPanel = new javax.swing.JPanel();
+        importButton = new javax.swing.JButton();
+        exportButton = new javax.swing.JButton();
+        cdImportButton = new javax.swing.JButton();
+        deleteButton = new javax.swing.JButton();
+        metaDataButton = new javax.swing.JButton();
+        sendButton = new javax.swing.JButton();
+        queryRetrieveButton = new javax.swing.JButton();
+        viewerButton = new javax.swing.JButton();
+        queueButton = new javax.swing.JButton();
+        menuBar = new javax.swing.JMenuBar();
+        jMenu1 = new javax.swing.JMenu();
+        importMenuItem = new javax.swing.JMenuItem();
+        exportMenuItem = new javax.swing.JMenuItem();
+        jSeparator2 = new javax.swing.JSeparator();
+        deleteExamMenuItem = new javax.swing.JMenuItem();
+        jMenuItem8 = new javax.swing.JMenuItem();
+        jSeparator3 = new javax.swing.JSeparator();
+        resetMenuItem = new javax.swing.JMenuItem();
+        jSeparator4 = new javax.swing.JSeparator();
+        exitMenuItem = new javax.swing.JMenuItem();
+        jMenu2 = new javax.swing.JMenu();
+        preferenceMenuItem = new javax.swing.JMenuItem();
+        jMenu3 = new javax.swing.JMenu();
+        queueMenuItem = new javax.swing.JMenuItem();
+        sendMenuItem = new javax.swing.JMenuItem();
+        QRMenuItem1 = new javax.swing.JMenuItem();
+        jMenu5 = new javax.swing.JMenu();
+        nimrodLFMenu = new javax.swing.JMenuItem();
+        motifLFMenu = new javax.swing.JMenuItem();
+        systemLFmenu = new javax.swing.JMenuItem();
+        jMenu4 = new javax.swing.JMenu();
+        userManualItem = new javax.swing.JMenuItem();
+        aboutMenu = new javax.swing.JMenuItem();
+
+        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
+        setTitle("Mayam");
+        setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/in/raster/mayam/form/images/fav_mayam.png")));
+
+        jLabel1.setFont(new java.awt.Font("Courier New", 1, 16));
+        jLabel1.setText(" Local Database");
+
+        jSplitPane1.setDividerLocation(256);
+        jSplitPane1.setDividerSize(4);
+        jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
+
+        studyListTable.setFont(new java.awt.Font("Courier", 0, 13)); // NOI18N
+        studyListTable.setForeground(new java.awt.Color(252, 138, 0));
+        studyListTable.setModel(new StudyListModel());
+        studyListTable.setShowGrid(true);
+        studyListTable.setDefaultRenderer(Object.class, new CellRenderer());
+        studyListTable.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                studyListTableMouseClicked(evt);
+            }
+        });
+        studyListTable.getTableHeader().setPreferredSize(new Dimension(this.getWidth(), 25));
+        Font f=new Font("Courier New",Font.BOLD,14);
+        studyListTable.getTableHeader().setFont(new Font(f.getName(),Font.BOLD,14));
+        studyListTable.setRowHeight(25);
+        studyListTable.getTableHeader().setForeground(new Color(255,138,0));
+        studyListTable.getTableHeader().setBackground(new Color(0,0,0));
+        studyTableScroll.setViewportView(studyListTable);
+
+        jSplitPane1.setTopComponent(studyTableScroll);
+
+        windowingPanelCanvas.setBackground(new java.awt.Color(0, 0, 0));
+        windowingPanelCanvas.setAutoscrolls(true);
+        windowingPanelCanvas.setPreferredSize(new java.awt.Dimension(50, 50));
+
+        org.jdesktop.layout.GroupLayout windowingPanelCanvasLayout = new org.jdesktop.layout.GroupLayout(windowingPanelCanvas);
+        windowingPanelCanvas.setLayout(windowingPanelCanvasLayout);
+        windowingPanelCanvasLayout.setHorizontalGroup(
+            windowingPanelCanvasLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(0, 641, Short.MAX_VALUE)
+        );
+        windowingPanelCanvasLayout.setVerticalGroup(
+            windowingPanelCanvasLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(0, 499, Short.MAX_VALUE)
+        );
+
+        thumbnailScroll.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
+        thumbnailScroll.getVerticalScrollBar().setUnitIncrement(24);
+
+        thumbnailDisplay.setAutoscrolls(true);
+        thumbnailDisplay.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
+        thumbnailDisplay.setMaximumSize(new java.awt.Dimension(1000, 1000));
+        thumbnailDisplay.setMinimumSize(new java.awt.Dimension(13, 2));
+        thumbnailScroll.setViewportView(thumbnailDisplay);
+
+        jLabel2.setBackground(new java.awt.Color(0, 0, 0));
+        jLabel2.setFont(new java.awt.Font("Courier New", 1, 16)); // NOI18N
+        jLabel2.setForeground(new java.awt.Color(255, 138, 0));
+        jLabel2.setText("Series ");
+        jLabel2.setOpaque(true);
+
+        org.jdesktop.layout.GroupLayout studyAndSeriesDisplayPanelLayout = new org.jdesktop.layout.GroupLayout(studyAndSeriesDisplayPanel);
+        studyAndSeriesDisplayPanel.setLayout(studyAndSeriesDisplayPanelLayout);
+        studyAndSeriesDisplayPanelLayout.setHorizontalGroup(
+            studyAndSeriesDisplayPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(studyAndSeriesDisplayPanelLayout.createSequentialGroup()
+                .add(studyAndSeriesDisplayPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
+                    .add(thumbnailScroll, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 330, Short.MAX_VALUE)
+                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 330, Short.MAX_VALUE))
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(windowingPanelCanvas, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 641, Short.MAX_VALUE))
+        );
+        studyAndSeriesDisplayPanelLayout.setVerticalGroup(
+            studyAndSeriesDisplayPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(studyAndSeriesDisplayPanelLayout.createSequentialGroup()
+                .add(jLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(thumbnailScroll, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 471, Short.MAX_VALUE))
+            .add(windowingPanelCanvas, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 499, Short.MAX_VALUE)
+        );
+
+        jSplitPane1.setRightComponent(studyAndSeriesDisplayPanel);
+
+        org.jdesktop.layout.GroupLayout contentAreaLayout = new org.jdesktop.layout.GroupLayout(contentArea);
+        contentArea.setLayout(contentAreaLayout);
+        contentAreaLayout.setHorizontalGroup(
+            contentAreaLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(contentAreaLayout.createSequentialGroup()
+                .addContainerGap()
+                .add(contentAreaLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                    .add(jSplitPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 985, Short.MAX_VALUE)
+                    .add(jLabel1))
+                .addContainerGap())
+        );
+        contentAreaLayout.setVerticalGroup(
+            contentAreaLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(contentAreaLayout.createSequentialGroup()
+                .addContainerGap()
+                .add(jLabel1)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(jSplitPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 761, Short.MAX_VALUE))
+        );
+
+        headerPanel.setBorder(javax.swing.BorderFactory.createMatteBorder(0, 0, 1, 0, new java.awt.Color(13, 13, 13)));
+
+        importButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/import.png"))); // NOI18N
+        importButton.setText("Import");
+        importButton.setToolTipText("Import");
+        importButton.setBorderPainted(false);
+        importButton.setContentAreaFilled(false);
+        importButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+        importButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/import1.png"))); // NOI18N
+        importButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        importButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                importButtonActionPerformed(evt);
+            }
+        });
+
+        exportButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/export_study.png"))); // NOI18N
+        exportButton.setText("Export");
+        exportButton.setToolTipText("Export");
+        exportButton.setBorderPainted(false);
+        exportButton.setContentAreaFilled(false);
+        exportButton.setDefaultCapable(false);
+        exportButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+        exportButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/export_study1.png"))); // NOI18N
+        exportButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        exportButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                exportButtonActionPerformed(evt);
+            }
+        });
+
+        cdImportButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/cd_import.png"))); // NOI18N
+        cdImportButton.setText("CD-Rom");
+        cdImportButton.setToolTipText("CD-Rom");
+        cdImportButton.setBorderPainted(false);
+        cdImportButton.setContentAreaFilled(false);
+        cdImportButton.setDefaultCapable(false);
+        cdImportButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+        cdImportButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/cd_import1.png"))); // NOI18N
+        cdImportButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        cdImportButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                cdImportButtonActionPerformed(evt);
+            }
+        });
+
+        deleteButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/delete_study.png"))); // NOI18N
+        deleteButton.setText("Delete");
+        deleteButton.setToolTipText("Delete");
+        deleteButton.setBorderPainted(false);
+        deleteButton.setContentAreaFilled(false);
+        deleteButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+        deleteButton.setPreferredSize(new java.awt.Dimension(52, 50));
+        deleteButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/delete_study1.png"))); // NOI18N
+        deleteButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        deleteButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                deleteButtonActionPerformed(evt);
+            }
+        });
+
+        metaDataButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/metadata_mainpage.png"))); // NOI18N
+        metaDataButton.setText("Meta Data");
+        metaDataButton.setToolTipText("Meta Data");
+        metaDataButton.setBorderPainted(false);
+        metaDataButton.setContentAreaFilled(false);
+        metaDataButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+        metaDataButton.setPreferredSize(new java.awt.Dimension(52, 50));
+        metaDataButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/metadata_mainpage1.png"))); // NOI18N
+        metaDataButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        metaDataButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                metaDataButtonActionPerformed(evt);
+            }
+        });
+
+        sendButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/send.png"))); // NOI18N
+        sendButton.setText("Send");
+        sendButton.setToolTipText("Send");
+        sendButton.setBorderPainted(false);
+        sendButton.setContentAreaFilled(false);
+        sendButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+        sendButton.setPreferredSize(new java.awt.Dimension(52, 50));
+        sendButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/send1.png"))); // NOI18N
+        sendButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        sendButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                sendButtonActionPerformed(evt);
+            }
+        });
+
+        queryRetrieveButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/query.png"))); // NOI18N
+        queryRetrieveButton.setText("Query");
+        queryRetrieveButton.setToolTipText("Query");
+        queryRetrieveButton.setBorderPainted(false);
+        queryRetrieveButton.setContentAreaFilled(false);
+        queryRetrieveButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+        queryRetrieveButton.setPreferredSize(new java.awt.Dimension(52, 50));
+        queryRetrieveButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/query1.png"))); // NOI18N
+        queryRetrieveButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        queryRetrieveButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                queryRetrieveButtonActionPerformed(evt);
+            }
+        });
+
+        viewerButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/viewer.png"))); // NOI18N
+        viewerButton.setText("Viewer");
+        viewerButton.setToolTipText("Viewer");
+        viewerButton.setBorderPainted(false);
+        viewerButton.setContentAreaFilled(false);
+        viewerButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+        viewerButton.setPreferredSize(new java.awt.Dimension(52, 50));
+        viewerButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/viewer1.png"))); // NOI18N
+        viewerButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        viewerButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                viewerButtonActionPerformed(evt);
+            }
+        });
+
+        queueButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/queue.png"))); // NOI18N
+        queueButton.setText("Queue");
+        queueButton.setToolTipText("Queue");
+        queueButton.setBorderPainted(false);
+        queueButton.setContentAreaFilled(false);
+        queueButton.setFocusPainted(false);
+        queueButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+        queueButton.setPreferredSize(new java.awt.Dimension(52, 50));
+        queueButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/queue1.png"))); // NOI18N
+        queueButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        queueButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                queueButtonActionPerformed(evt);
+            }
+        });
+
+        org.jdesktop.layout.GroupLayout headerPanelLayout = new org.jdesktop.layout.GroupLayout(headerPanel);
+        headerPanel.setLayout(headerPanelLayout);
+        headerPanelLayout.setHorizontalGroup(
+            headerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(headerPanelLayout.createSequentialGroup()
+                .add(5, 5, 5)
+                .add(importButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 79, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+                .add(exportButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 79, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+                .add(cdImportButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 85, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+                .add(deleteButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 78, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+                .add(metaDataButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 114, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(sendButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 69, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+                .add(queryRetrieveButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 78, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+                .add(viewerButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 79, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+                .add(queueButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 78, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .add(277, 277, 277))
+        );
+        headerPanelLayout.setVerticalGroup(
+            headerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(headerPanelLayout.createSequentialGroup()
+                .add(5, 5, 5)
+                .add(headerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                    .add(metaDataButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                    .add(exportButton)
+                    .add(importButton)
+                    .add(deleteButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                    .add(sendButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                    .add(queryRetrieveButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                    .add(viewerButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                    .add(queueButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                    .add(cdImportButton))
+                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+        );
+
+        headerPanelLayout.linkSize(new java.awt.Component[] {cdImportButton, deleteButton, exportButton, importButton, metaDataButton, queryRetrieveButton, queueButton, sendButton, viewerButton}, org.jdesktop.layout.GroupLayout.VERTICAL);
+
+        org.jdesktop.layout.GroupLayout containerLayout = new org.jdesktop.layout.GroupLayout(container);
+        container.setLayout(containerLayout);
+        containerLayout.setHorizontalGroup(
+            containerLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(contentArea, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+            .add(headerPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 1025, Short.MAX_VALUE)
+        );
+        containerLayout.setVerticalGroup(
+            containerLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(containerLayout.createSequentialGroup()
+                .add(headerPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(contentArea, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                .addContainerGap())
+        );
+
+        jMenu1.setText("File");
+
+        importMenuItem.setText("Import");
+        importMenuItem.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                importMenuItemActionPerformed(evt);
+            }
+        });
+        jMenu1.add(importMenuItem);
+
+        exportMenuItem.setText("Export");
+        exportMenuItem.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                exportMenuItemActionPerformed(evt);
+            }
+        });
+        jMenu1.add(exportMenuItem);
+        jMenu1.add(jSeparator2);
+
+        deleteExamMenuItem.setText("Delete Selected Exam");
+        deleteExamMenuItem.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                deleteExamMenuItemActionPerformed(evt);
+            }
+        });
+        jMenu1.add(deleteExamMenuItem);
+
+        jMenuItem8.setText("Anonymize");
+        jMenuItem8.setEnabled(false);
+        jMenu1.add(jMenuItem8);
+        jMenu1.add(jSeparator3);
+
+        resetMenuItem.setText("Reset DB");
+        resetMenuItem.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                resetMenuItemActionPerformed(evt);
+            }
+        });
+        jMenu1.add(resetMenuItem);
+        jMenu1.add(jSeparator4);
+
+        exitMenuItem.setText("Exit");
+        exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                exitMenuItemActionPerformed(evt);
+            }
+        });
+        jMenu1.add(exitMenuItem);
+
+        menuBar.add(jMenu1);
+
+        jMenu2.setText("Tools");
+
+        preferenceMenuItem.setText("Preferences");
+        preferenceMenuItem.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                preferenceMenuItemActionPerformed(evt);
+            }
+        });
+        jMenu2.add(preferenceMenuItem);
+
+        menuBar.add(jMenu2);
+
+        jMenu3.setText("Network");
+
+        queueMenuItem.setText("Queue");
+        queueMenuItem.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                queueMenuItemActionPerformed(evt);
+            }
+        });
+        jMenu3.add(queueMenuItem);
+
+        sendMenuItem.setText("Send");
+        sendMenuItem.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                sendMenuItemActionPerformed(evt);
+            }
+        });
+        jMenu3.add(sendMenuItem);
+
+        QRMenuItem1.setText("Query/Retrieve");
+        QRMenuItem1.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                QRMenuItem1ActionPerformed(evt);
+            }
+        });
+        jMenu3.add(QRMenuItem1);
+
+        menuBar.add(jMenu3);
+
+        jMenu5.setText("Theme");
+
+        nimrodLFMenu.setText("Nimrod");
+        nimrodLFMenu.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                nimrodLFMenuActionPerformed(evt);
+            }
+        });
+        jMenu5.add(nimrodLFMenu);
+
+        motifLFMenu.setText("Motif");
+        motifLFMenu.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                motifLFMenuActionPerformed(evt);
+            }
+        });
+        jMenu5.add(motifLFMenu);
+
+        systemLFmenu.setText("System L&F");
+        systemLFmenu.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                systemLFmenuActionPerformed(evt);
+            }
+        });
+        jMenu5.add(systemLFmenu);
+
+        menuBar.add(jMenu5);
+
+        jMenu4.setText("Help");
+
+        userManualItem.setText("User Manual");
+        jMenu4.add(userManualItem);
+
+        aboutMenu.setText("About");
+        aboutMenu.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                aboutMenuActionPerformed(evt);
+            }
+        });
+        jMenu4.add(aboutMenu);
+
+        menuBar.add(jMenu4);
+
+        setJMenuBar(menuBar);
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+        getContentPane().setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(container, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(container, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+        );
+
+        pack();
+    }// </editor-fold>//GEN-END:initComponents
+
+    private void importButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_importButtonActionPerformed
+        importHandler();
+    }//GEN-LAST:event_importButtonActionPerformed
+    private void importHandler() {
+        FileChooserDialog fcd = new FileChooserDialog(this, true);
+        fcd.setLocationRelativeTo(this);
+        fcd.setVisible(true);
+    }
+    private void queryRetrieveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_queryRetrieveButtonActionPerformed
+        queryRetrieve.setVisible(true);
+    }//GEN-LAST:event_queryRetrieveButtonActionPerformed
+
+    private void exportButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportButtonActionPerformed
+        exportHandler();
+    }//GEN-LAST:event_exportButtonActionPerformed
+    private void exportHandler() {
+        if (studyListTable.getSelectedRow() != -1) {
+            int selection = studyListTable.convertRowIndexToModel(studyListTable.getSelectedRow());
+            String siuid = ((StudyListModel) studyListTable.getModel()).getValueAt(selection, 8);
+            ExportLocationChooser jpegChooser = new ExportLocationChooser(ApplicationContext.imgView, true);
+            jpegChooser.setLocationRelativeTo(this);
+            jpegChooser.setSeriesOrInstanceLevel(false);
+            jpegChooser.setStudyUID(siuid);
+            jpegChooser.setVisible(true);
+        }
+    }
+    private void deleteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteButtonActionPerformed
+        if (studyListTable.getSelectedRow() != -1) {
+            ConfirmDelete confirmDelete = new ConfirmDelete(this, true);
+            confirmDelete.setLocationRelativeTo(this);
+            confirmDelete.setVisible(true);
+        }
+        removeThumbnailComponents();
+        removeWindowingImage();
+        showThumbnails();
+    }//GEN-LAST:event_deleteButtonActionPerformed
+    private void sendButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sendButtonActionPerformed
+       doSend();
+    }//GEN-LAST:event_sendButtonActionPerformed
+    private void viewerButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewerButtonActionPerformed
+        if (studyListTable.getSelectedRow() != -1) {
+
+            int index[] = studyListTable.getSelectedRows();
+            if (index.length > 1) {
+                String[] studies = new String[index.length];
+                for (int j = 0; j < index.length; j++) {
+                    index[j] = studyListTable.convertRowIndexToModel(index[j]);
+                }
+                for (int tempI = 0; tempI < index.length; tempI++) {
+                    studies[tempI] = ((StudyListModel) studyListTable.getModel()).getValueAt(index[tempI], 8);
+                }
+                ArrayList tempRef1 = ApplicationContext.databaseRef.getFirstInstanceListFromMultipleStudies(studies);
+
+                openComparisonView(index.length, studies, tempRef1);
+                for (String studyUID : studies) {
+                    StudyListUpdator studyListUpdator = new StudyListUpdator();
+                    studyListUpdator.addStudyToStudyList(studyUID, studyList, ((File) tempRef1.get(0)).getAbsolutePath());
+                }
+
+            } else {
+
+
+                int selection = studyListTable.convertRowIndexToModel(studyListTable.getSelectedRow());
+                String siuid = ((StudyListModel) studyListTable.getModel()).getValueAt(selection, 8);
+                int rowColumnArray[] = new int[2];
+                try {
+                    rowColumnArray = ApplicationContext.databaseRef.getRowColumnBasedStudyUID(siuid);
+                } catch (Exception e) {
+                    rowColumnArray[0] = 1;
+                    rowColumnArray[1] = 1;
+                }
+                ArrayList tempRef = ApplicationContext.databaseRef.getUrlBasedOnStudyIUID(siuid);
+                openImageView(siuid, tempRef, rowColumnArray[0], rowColumnArray[1]);
+                StudyListUpdator studyListUpdator = new StudyListUpdator();
+                studyListUpdator.addStudyToStudyList(siuid, studyList, ((File) tempRef.get(0)).getAbsolutePath());
+            }
+        }
+    }//GEN-LAST:event_viewerButtonActionPerformed
+    /**
+     * This routine used to process the exit menu
+     * @param evt
+     */
+    private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMenuItemActionPerformed
+        System.exit(2);
+    }//GEN-LAST:event_exitMenuItemActionPerformed
+    private void queueButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_queueButtonActionPerformed
+        sndRcvFrm.setLocationRelativeTo(this);
+        sndRcvFrm.setVisible(true);
+    }//GEN-LAST:event_queueButtonActionPerformed
+    private void preferenceMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_preferenceMenuItemActionPerformed
+        showPreference();
+    }//GEN-LAST:event_preferenceMenuItemActionPerformed
+    /**
+     * This routine used to show the preference dialogue
+     */
+    private void showPreference() {
+        settingsDialog = new SettingsDialog(this, true);
+        settingsDialog.setLocationRelativeTo(this);
+        settingsDialog.setVisible(true);
+    }
+
+    private void doSend()
+    {
+        String forwardAET = "";
+        String forwardHost = "";
+        int forwardPort;
+        ServerListDialog configuredServer = new ServerListDialog(this, true);
+        configuredServer.setLocationRelativeTo(this);
+        configuredServer.setVisible(true);
+        if (configuredServer.getAe() != null) {
+            AEModel ae = configuredServer.getAe();
+            forwardAET = ae.getAeTitle();
+            forwardHost = ae.getHostName();
+            forwardPort = ae.getPort();
+            if (studyListTable.getSelectedRow() != -1) {
+                int index[] = studyListTable.getSelectedRows();
+                for (int j = 0; j < index.length; j++) {
+                    index[j] = studyListTable.convertRowIndexToModel(index[j]);
+                }
+                for (int tempI = 0; tempI < index.length; tempI++) {
+                    String studyIUID = (String) studyListTable.getModel().getValueAt(index[tempI], 8);
+                    SendingDelegate sendingDelegate = new SendingDelegate(studyIUID, ae);
+                }
+            }
+        }
+    }
+    public SettingsDialog getPreference() {
+        return settingsDialog;
+    }
+
+    /**
+     * This routine used to get the query screen
+     * @return
+     */
+    public QueryRetrieve getQueryScreen() {
+        return this.queryRetrieve;
+    }
+
+    /**
+     * This routine is used to process the mouse event for the study list table
+     * @param evt
+     */
+    private void studyListTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_studyListTableMouseClicked
+        if (evt.getClickCount() == 2) {
+            if (studyListTable.getSelectedRow() != -1) {
+                int selection = studyListTable.convertRowIndexToModel(studyListTable.getSelectedRow());
+                String siuid = ((StudyListModel) studyListTable.getModel()).getValueAt(selection, 8);
+                int rowColumnArray[] = ApplicationContext.databaseRef.getRowColumnBasedStudyUID(siuid);
+                ArrayList tempRef = ApplicationContext.databaseRef.getUrlBasedOnStudyIUID(siuid);
+                openImageView(siuid, tempRef, rowColumnArray[0], rowColumnArray[1]);
+                StudyListUpdator studyListUpdator = new StudyListUpdator();
+                studyListUpdator.addStudyToStudyList(siuid, studyList, ((File) tempRef.get(0)).getAbsolutePath());
+            }
+        } else {
+            showThumbnails();
+        }
+    }//GEN-LAST:event_studyListTableMouseClicked
+    private void metaDataButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_metaDataButtonActionPerformed
+        try {
+            if (studyListTable.getSelectedRow() != -1) {
+                int selection = studyListTable.convertRowIndexToModel(studyListTable.getSelectedRow());
+                String siuid = ((StudyListModel) studyListTable.getModel()).getValueAt(selection, 8);
+                ArrayList<DicomTags> dcmTags = DicomTagsReader.getTags(new File(this.canvas.getFilePath()));
+                dicomTagsViewer.setDataModelOnTable(dcmTags);
+                dicomTagsViewer.setLocationRelativeTo(this);
+                dicomTagsViewer.setVisible(true);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }//GEN-LAST:event_metaDataButtonActionPerformed
+    private void aboutMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aboutMenuActionPerformed
+        About about = new About(null, true);
+        about.setLocationRelativeTo(this);
+        about.setVisible(true);
+    }//GEN-LAST:event_aboutMenuActionPerformed
+    private void importMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_importMenuItemActionPerformed
+        importHandler();
+    }//GEN-LAST:event_importMenuItemActionPerformed
+    private void exportMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportMenuItemActionPerformed
+        exportHandler();
+    }//GEN-LAST:event_exportMenuItemActionPerformed
+    private void queueMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_queueMenuItemActionPerformed
+        sndRcvFrm.setLocationRelativeTo(this);
+        sndRcvFrm.setVisible(true);
+    }//GEN-LAST:event_queueMenuItemActionPerformed
+
+    private void resetMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_resetMenuItemActionPerformed
+          int resetDB=0;
+        resetDB=JOptionPane.showConfirmDialog(this,"Are you sure want to reset the database", "Confirmation Dialog", JOptionPane.YES_NO_OPTION);
+        if(resetDB==0){
+        ApplicationContext.databaseRef.rebuild();
+        MainScreen.showLocalDBStorage();
+        removeThumbnailComponents();
+        removeWindowingImage();
+        }
+    }//GEN-LAST:event_resetMenuItemActionPerformed
+    private void deleteExamMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteExamMenuItemActionPerformed
+        if (studyListTable.getSelectedRow() != -1) {
+            ConfirmDelete confirmDelete = new ConfirmDelete(this, true);
+            confirmDelete.setLocationRelativeTo(this);
+            confirmDelete.setVisible(true);
+        }
+        removeThumbnailComponents();
+        removeWindowingImage();
+        showThumbnails();
+    }//GEN-LAST:event_deleteExamMenuItemActionPerformed
+    /**
+     * This routine used to remove the windowing image panel
+     */
+    private void removeWindowingImage() {
+        for (int i = windowingPanelCanvas.getComponentCount() - 1; i >= 0; i--) {
+            windowingPanelCanvas.remove(i);
+        }
+        windowingPanelCanvas.repaint();
+    }
+
+    /***
+     * This is cd import action handler used to import the dicom files.
+     * @param evt
+     */
+    private void cdImportButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cdImportButtonActionPerformed
+        ImportDcmDirDelegate importDcmDirDelegate = new ImportDcmDirDelegate();
+        importDcmDirDelegate.setCopyAsLink(true);
+        importDcmDirDelegate.findAndRun();
+    }//GEN-LAST:event_cdImportButtonActionPerformed
+
+    private void systemLFmenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_systemLFmenuActionPerformed
+        setSystemTheme();
+        updateThemeStatus("System");
+    }//GEN-LAST:event_systemLFmenuActionPerformed
+
+    private void motifLFMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_motifLFMenuActionPerformed
+        setMotifTheme();
+        updateThemeStatus("Motif");
+    }//GEN-LAST:event_motifLFMenuActionPerformed
+
+    private void nimrodLFMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nimrodLFMenuActionPerformed
+        setNimrodTheme();
+        updateThemeStatus("Nimrod");
+
+    }//GEN-LAST:event_nimrodLFMenuActionPerformed
+
+    private void sendMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sendMenuItemActionPerformed
+      doSend();
+    }//GEN-LAST:event_sendMenuItemActionPerformed
+
+    private void QRMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_QRMenuItem1ActionPerformed
+      queryRetrieve.setVisible(true);
+    }//GEN-LAST:event_QRMenuItem1ActionPerformed
+
+    private void setNimrodTheme() {
+        try {
+            UIManager.setLookAndFeel(new NimRODLookAndFeel());
+            UIDefaults uIDefaults=UIManager.getDefaults();
+            uIDefaults.put("Menu.font",new Font("Courier New",Font.BOLD,13));
+            uIDefaults.put("MenuItem.font", new Font("Courier New",Font.BOLD,13));
+            uIDefaults.put("Button.font", new Font("Courier New",Font.BOLD,13));
+            uIDefaults.put("Label.font", new Font("Courier New",Font.BOLD,13));
+            uIDefaults.put("RadioButton.font",new Font("Courier New",Font.BOLD,13));
+             uIDefaults.put("CheckBox.font",new Font("Courier New",Font.BOLD,13));
+            uIDefaults.put("Table.font",new Font("Courier New",Font.BOLD,13));
+            updateComponentsTreeUI();
+        } catch (UnsupportedLookAndFeelException ex) {
+            Logger.getLogger(MainScreen.class.getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+
+    private void setMotifTheme() {
+        try {
+            UIManager.setLookAndFeel(new MotifLookAndFeel());
+            updateComponentsTreeUI();
+        } catch (UnsupportedLookAndFeelException ex) {
+            Logger.getLogger(MainScreen.class.getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+
+    private void setSystemTheme() {
+        try {
+            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+            updateComponentsTreeUI();
+        } catch (ClassNotFoundException ex) {
+            Logger.getLogger(MainScreen.class.getName()).log(Level.SEVERE, null, ex);
+        } catch (InstantiationException ex) {
+            Logger.getLogger(MainScreen.class.getName()).log(Level.SEVERE, null, ex);
+        } catch (IllegalAccessException ex) {
+            Logger.getLogger(MainScreen.class.getName()).log(Level.SEVERE, null, ex);
+        } catch (UnsupportedLookAndFeelException ex) {
+            Logger.getLogger(MainScreen.class.getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+
+    private void updateComponentsTreeUI() {
+        SwingUtilities.updateComponentTreeUI(this);
+        SwingUtilities.updateComponentTreeUI(queryRetrieve);
+        if (ApplicationContext.imageViewExist()) {
+            SwingUtilities.updateComponentTreeUI(ApplicationContext.imgView);
+        }
+        SwingUtilities.updateComponentTreeUI(sndRcvFrm);
+        SwingUtilities.updateComponentTreeUI(dicomTagsViewer);
+    }
+
+    private void updateThemeStatus(String themeName) {
+        ApplicationContext.databaseRef.updateThemeStatus(themeName);
+    }
+    SeriesThumbUpdator thumbUpdator;
+
+    public void showThumbnails() {
+        try {
+            this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+            if (studyListTable.getSelectedRow() != -1) {
+                if (thumbUpdator != null) {
+                    thumbUpdator.setCanRun(false);
+                    removeThumbnailComponents();
+                }
+                int selection = studyListTable.convertRowIndexToModel(studyListTable.getSelectedRow());
+                String studyUID = ((StudyListModel) studyListTable.getModel()).getValueAt(selection, 8);
+                selectedStudy = studyUID;
+                thumbUpdator = new SeriesThumbUpdator(studyUID);
+            }
+        } finally {
+            this.setCursor(Cursor.getDefaultCursor());
+        }
+    }
+
+    public void openImageView(String studyUID, ArrayList tempRef, int gridRowCount, int gridColCount) {
+        if (!ApplicationContext.imageViewExist()) {
+            ApplicationContext.createImageView();
+        }
+        ShowViewerDelegate showViewer = new ShowViewerDelegate(studyUID, tempRef, gridRowCount, gridColCount);
+    }
+
+    public void openComparisonView(int numberOfStudies, String[] studies, ArrayList tempRef) {
+        if (!ApplicationContext.imageViewExist()) {
+            ApplicationContext.createImageView();
+        }
+        ShowComparisonViewerDelegate showComparisonViewerDelegate = new ShowComparisonViewerDelegate(numberOfStudies, studies, tempRef);
+    }
+
+    private void removeThumbnailComponents() {
+        for (int i = thumbnailDisplay.getComponentCount() - 1; i >= 0; i--) {
+            SeriesPanel thumbImage = (SeriesPanel) thumbnailDisplay.getComponent(i);
+            thumbImage.clearAllMemoryReference();
+            thumbnailDisplay.remove(thumbImage);
+            thumbImage = null;
+        }
+        thumbnailDisplay.repaint();
+    }
+
+    /**
+     * Getter method for thumbnailDisplay.
+     * @return
+     */
+    public JPanel getThumbnailDisplay() {
+        return thumbnailDisplay;
+    }
+
+    public JScrollPane getThumbnailScroll() {
+        return this.thumbnailScroll;
+    }
+
+    /**
+     * Getter method for windowingPanelCanvas.
+     * @return
+     */
+    public JPanel getWindowingPanelCanvas() {
+        return windowingPanelCanvas;
+    }
+
+    /**
+     * Setter method for the instance of WindowingLayeredCanvas.
+     * @param canvas
+     */
+    public void setCanvas(WindowingLayeredCanvas canvas) {
+        this.canvas = canvas;
+    }
+
+    /**
+     * Setter method for the instance of WindowingLayeredCanvas.
+     * @param canvas
+     */
+    public WindowingLayeredCanvas getCanvas() {
+        return canvas;
+    }
+
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String args[]) {
+        java.awt.EventQueue.invokeLater(new Runnable() {
+
+            public void run() {
+                new MainScreen().setVisible(true);
+            }
+        });
+    }
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JMenuItem QRMenuItem1;
+    private javax.swing.JMenuItem aboutMenu;
+    private javax.swing.JButton cdImportButton;
+    private javax.swing.JPanel container;
+    private javax.swing.JPanel contentArea;
+    private javax.swing.JButton deleteButton;
+    private javax.swing.JMenuItem deleteExamMenuItem;
+    private javax.swing.JMenuItem exitMenuItem;
+    private javax.swing.JButton exportButton;
+    private javax.swing.JMenuItem exportMenuItem;
+    private javax.swing.JPanel headerPanel;
+    private javax.swing.JButton importButton;
+    private javax.swing.JMenuItem importMenuItem;
+    private javax.swing.JLabel jLabel1;
+    private javax.swing.JLabel jLabel2;
+    private javax.swing.JMenu jMenu1;
+    private javax.swing.JMenu jMenu2;
+    private javax.swing.JMenu jMenu3;
+    private javax.swing.JMenu jMenu4;
+    private javax.swing.JMenu jMenu5;
+    private javax.swing.JMenuItem jMenuItem8;
+    private javax.swing.JSeparator jSeparator2;
+    private javax.swing.JSeparator jSeparator3;
+    private javax.swing.JSeparator jSeparator4;
+    private javax.swing.JSplitPane jSplitPane1;
+    private javax.swing.JMenuBar menuBar;
+    private javax.swing.JButton metaDataButton;
+    private javax.swing.JMenuItem motifLFMenu;
+    private javax.swing.JMenuItem nimrodLFMenu;
+    private javax.swing.JMenuItem preferenceMenuItem;
+    private javax.swing.JButton queryRetrieveButton;
+    private javax.swing.JButton queueButton;
+    private javax.swing.JMenuItem queueMenuItem;
+    private javax.swing.JMenuItem resetMenuItem;
+    private javax.swing.JButton sendButton;
+    private javax.swing.JMenuItem sendMenuItem;
+    private javax.swing.JPanel studyAndSeriesDisplayPanel;
+    public static javax.swing.JTable studyListTable;
+    private javax.swing.JScrollPane studyTableScroll;
+    private javax.swing.JMenuItem systemLFmenu;
+    private javax.swing.JPanel thumbnailDisplay;
+    private javax.swing.JScrollPane thumbnailScroll;
+    private javax.swing.JMenuItem userManualItem;
+    private javax.swing.JButton viewerButton;
+    private javax.swing.JPanel windowingPanelCanvas;
+    // End of variables declaration//GEN-END:variables
+    private ReceiveDelegate receiveDelegate = null;
+    public static ArrayList<Study> studyList = new ArrayList<Study>();
+    private QueryRetrieve queryRetrieve = null;
+    public static SendReceiveFrame sndRcvFrm;
+    private WindowingLayeredCanvas canvas = null;
+    public static MainScreen mainScreenObj;
+    public static DicomTagsViewer dicomTagsViewer = new DicomTagsViewer();
+    public static String selectedStudy = "";
+    public static String selectedSeries = "";
+    public SettingsDialog settingsDialog = null;
+
+    public static MainScreen getInstance() {
+        if (mainScreenObj == null) {
+            mainScreenObj = new MainScreen();
+        }
+        return mainScreenObj;
+    }
+}
diff --git a/src/in/raster/mayam/form/QueryRetrieve.form b/src/in/raster/mayam/form/QueryRetrieve.form
new file mode 100644
index 0000000..5a35cc0
--- /dev/null
+++ b/src/in/raster/mayam/form/QueryRetrieve.form
@@ -0,0 +1,691 @@
+<?xml version="1.1" encoding="UTF-8" ?>
+
+<Form version="1.5" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
+  <NonVisualComponents>
+    <Component class="javax.swing.ButtonGroup" name="searchDaysGroup">
+    </Component>
+    <Component class="javax.swing.ButtonGroup" name="modalityGroup">
+    </Component>
+  </NonVisualComponents>
+  <Properties>
+    <Property name="title" type="java.lang.String" value="Query/Retrieve"/>
+    <Property name="iconImage" type="java.awt.Image" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+      <Connection code="Toolkit.getDefaultToolkit().getImage(getClass().getResource("/in/raster/mayam/form/images/fav_mayam.png"))" type="code"/>
+    </Property>
+  </Properties>
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="0" attributes="0">
+              <Component id="jPanel9" max="32767" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Component id="jPanel9" alignment="0" max="32767" attributes="0"/>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Container class="javax.swing.JPanel" name="jPanel9">
+      <Properties>
+        <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+          <Dimension value="[1200, 1400]"/>
+        </Property>
+      </Properties>
+
+      <Layout>
+        <DimensionLayout dim="0">
+          <Group type="103" groupAlignment="0" attributes="0">
+              <Group type="102" alignment="1" attributes="0">
+                  <EmptySpace min="-2" max="-2" attributes="0"/>
+                  <Group type="103" groupAlignment="1" attributes="0">
+                      <Component id="jScrollPane2" alignment="0" pref="1163" max="32767" attributes="2"/>
+                      <Group type="102" alignment="1" attributes="0">
+                          <Group type="103" groupAlignment="0" attributes="0">
+                              <Component id="serverlistScroll" pref="535" max="32767" attributes="1"/>
+                              <Component id="serverNameLabel" alignment="1" pref="535" max="32767" attributes="2"/>
+                              <Component id="headerLabel" alignment="0" pref="535" max="32767" attributes="2"/>
+                          </Group>
+                          <EmptySpace max="-2" attributes="0"/>
+                          <Group type="103" groupAlignment="0" max="-2" attributes="0">
+                              <Component id="jLabel1" alignment="0" max="32767" attributes="1"/>
+                              <Component id="jPanel7" alignment="0" pref="618" max="32767" attributes="1"/>
+                              <Component id="jPanel8" alignment="0" max="32767" attributes="1"/>
+                          </Group>
+                      </Group>
+                  </Group>
+              </Group>
+          </Group>
+        </DimensionLayout>
+        <DimensionLayout dim="1">
+          <Group type="103" groupAlignment="0" attributes="0">
+              <Group type="102" alignment="0" attributes="0">
+                  <Group type="103" groupAlignment="3" attributes="0">
+                      <Component id="headerLabel" alignment="3" min="-2" pref="20" max="-2" attributes="0"/>
+                      <Component id="jLabel1" alignment="3" min="-2" pref="20" max="-2" attributes="0"/>
+                  </Group>
+                  <EmptySpace min="-2" max="-2" attributes="0"/>
+                  <Group type="103" groupAlignment="0" attributes="0">
+                      <Component id="serverlistScroll" pref="234" max="32767" attributes="1"/>
+                      <Component id="jPanel7" alignment="0" max="32767" attributes="1"/>
+                  </Group>
+                  <EmptySpace max="-2" attributes="0"/>
+                  <Group type="103" groupAlignment="0" attributes="0">
+                      <Component id="serverNameLabel" min="-2" pref="23" max="-2" attributes="0"/>
+                      <Component id="jPanel8" min="-2" max="-2" attributes="0"/>
+                  </Group>
+                  <EmptySpace max="-2" attributes="0"/>
+                  <Component id="jScrollPane2" pref="517" max="32767" attributes="2"/>
+                  <EmptySpace max="-2" attributes="0"/>
+              </Group>
+          </Group>
+        </DimensionLayout>
+      </Layout>
+      <SubComponents>
+        <Container class="javax.swing.JPanel" name="jPanel7">
+          <Properties>
+            <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+              <Border info="org.netbeans.modules.form.compat2.border.SoftBevelBorderInfo">
+                <BevelBorder/>
+              </Border>
+            </Property>
+          </Properties>
+
+          <Layout>
+            <DimensionLayout dim="0">
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Group type="102" alignment="0" attributes="0">
+                      <EmptySpace min="-2" pref="9" max="-2" attributes="0"/>
+                      <Component id="jPanel1" min="-2" pref="157" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="jPanel10" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="jPanel2" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace min="-2" pref="36" max="-2" attributes="0"/>
+                  </Group>
+              </Group>
+            </DimensionLayout>
+            <DimensionLayout dim="1">
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Group type="102" attributes="0">
+                      <Group type="103" groupAlignment="0" attributes="0">
+                          <Component id="jPanel2" alignment="0" min="-2" max="-2" attributes="1"/>
+                          <Group type="102" alignment="0" attributes="0">
+                              <EmptySpace min="-2" pref="8" max="-2" attributes="0"/>
+                              <Component id="jPanel10" min="-2" max="-2" attributes="1"/>
+                          </Group>
+                          <Component id="jPanel1" alignment="0" min="-2" max="-2" attributes="1"/>
+                      </Group>
+                      <EmptySpace max="32767" attributes="0"/>
+                  </Group>
+              </Group>
+            </DimensionLayout>
+          </Layout>
+          <SubComponents>
+            <Container class="javax.swing.JPanel" name="jPanel1">
+              <Properties>
+                <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+                  <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
+                    <EmptyBorder/>
+                  </Border>
+                </Property>
+              </Properties>
+
+              <Layout>
+                <DimensionLayout dim="0">
+                  <Group type="103" groupAlignment="0" attributes="0">
+                      <Group type="102" alignment="0" max="-2" attributes="0">
+                          <Group type="103" groupAlignment="0" max="-2" attributes="0">
+                              <Component id="todayRadio" linkSize="6" alignment="0" min="-2" max="-2" attributes="0"/>
+                              <Component id="anydateRadio" linkSize="6" alignment="0" min="-2" max="-2" attributes="0"/>
+                              <Component id="yesterdayRadio" linkSize="6" alignment="0" min="-2" max="-2" attributes="0"/>
+                              <Component id="lastweekRadio" linkSize="6" alignment="0" min="-2" max="-2" attributes="0"/>
+                              <Component id="lastmonthRadio" linkSize="6" alignment="0" min="-2" max="-2" attributes="0"/>
+                              <Component id="betweenRadio" linkSize="6" alignment="0" min="-2" max="-2" attributes="0"/>
+                              <Group type="102" alignment="0" max="-2" attributes="0">
+                                  <EmptySpace min="-2" pref="25" max="-2" attributes="0"/>
+                                  <Group type="103" groupAlignment="0" max="-2" attributes="0">
+                                      <Component id="toSpinner" alignment="1" pref="119" max="32767" attributes="1"/>
+                                      <Component id="fromSpinner" alignment="0" pref="119" max="32767" attributes="1"/>
+                                  </Group>
+                              </Group>
+                          </Group>
+                          <EmptySpace max="32767" attributes="0"/>
+                      </Group>
+                  </Group>
+                </DimensionLayout>
+                <DimensionLayout dim="1">
+                  <Group type="103" groupAlignment="0" attributes="0">
+                      <Group type="102" alignment="0" attributes="0">
+                          <Component id="anydateRadio" linkSize="5" min="-2" pref="15" max="-2" attributes="0"/>
+                          <EmptySpace min="-2" max="-2" attributes="0"/>
+                          <Component id="todayRadio" linkSize="5" min="-2" pref="23" max="-2" attributes="0"/>
+                          <EmptySpace min="-2" max="-2" attributes="0"/>
+                          <Component id="yesterdayRadio" linkSize="5" min="-2" pref="10" max="-2" attributes="0"/>
+                          <EmptySpace min="-2" max="-2" attributes="0"/>
+                          <Component id="lastweekRadio" linkSize="5" min="-2" max="-2" attributes="0"/>
+                          <EmptySpace min="-2" max="-2" attributes="0"/>
+                          <Component id="lastmonthRadio" linkSize="5" min="-2" pref="17" max="-2" attributes="0"/>
+                          <EmptySpace min="-2" max="-2" attributes="0"/>
+                          <Component id="betweenRadio" linkSize="5" min="-2" pref="19" max="-2" attributes="0"/>
+                          <EmptySpace min="-2" max="-2" attributes="0"/>
+                          <Component id="fromSpinner" min="-2" pref="21" max="-2" attributes="0"/>
+                          <EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
+                          <Component id="toSpinner" min="-2" max="-2" attributes="0"/>
+                      </Group>
+                  </Group>
+                </DimensionLayout>
+              </Layout>
+              <SubComponents>
+                <Component class="javax.swing.JRadioButton" name="anydateRadio">
+                  <Properties>
+                    <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
+                      <ComponentRef name="searchDaysGroup"/>
+                    </Property>
+                    <Property name="selected" type="boolean" value="true"/>
+                    <Property name="text" type="java.lang.String" value="Any date"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JRadioButton" name="todayRadio">
+                  <Properties>
+                    <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
+                      <ComponentRef name="searchDaysGroup"/>
+                    </Property>
+                    <Property name="text" type="java.lang.String" value="Today"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JRadioButton" name="yesterdayRadio">
+                  <Properties>
+                    <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
+                      <ComponentRef name="searchDaysGroup"/>
+                    </Property>
+                    <Property name="text" type="java.lang.String" value="Yesterday"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JRadioButton" name="lastweekRadio">
+                  <Properties>
+                    <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
+                      <ComponentRef name="searchDaysGroup"/>
+                    </Property>
+                    <Property name="text" type="java.lang.String" value="Last week"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JRadioButton" name="lastmonthRadio">
+                  <Properties>
+                    <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
+                      <ComponentRef name="searchDaysGroup"/>
+                    </Property>
+                    <Property name="text" type="java.lang.String" value="Last month"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JRadioButton" name="betweenRadio">
+                  <Properties>
+                    <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
+                      <ComponentRef name="searchDaysGroup"/>
+                    </Property>
+                    <Property name="text" type="java.lang.String" value="Between"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JSpinner" name="fromSpinner">
+                  <Properties>
+                    <Property name="enabled" type="boolean" value="false"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JSpinner" name="toSpinner">
+                  <Properties>
+                    <Property name="enabled" type="boolean" value="false"/>
+                  </Properties>
+                </Component>
+              </SubComponents>
+            </Container>
+            <Container class="javax.swing.JPanel" name="jPanel10">
+              <Properties>
+                <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+                  <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
+                    <EmptyBorder/>
+                  </Border>
+                </Property>
+              </Properties>
+
+              <Layout>
+                <DimensionLayout dim="0">
+                  <Group type="103" groupAlignment="0" attributes="0">
+                      <Group type="102" attributes="0">
+                          <EmptySpace max="-2" attributes="0"/>
+                          <Group type="103" groupAlignment="0" attributes="0">
+                              <Component id="jLabel5" min="-2" max="-2" attributes="0"/>
+                              <Component id="jLabel4" alignment="0" min="-2" max="-2" attributes="0"/>
+                              <Component id="jLabel3" alignment="0" min="-2" max="-2" attributes="0"/>
+                              <Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/>
+                          </Group>
+                          <Group type="103" groupAlignment="1" attributes="0">
+                              <Group type="102" attributes="0">
+                                  <EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
+                                  <Group type="103" groupAlignment="1" attributes="0">
+                                      <Component id="patientNameText" alignment="0" pref="126" max="32767" attributes="0"/>
+                                      <Component id="patientIDText" alignment="0" pref="126" max="32767" attributes="0"/>
+                                  </Group>
+                              </Group>
+                              <Group type="102" alignment="1" attributes="0">
+                                  <EmptySpace max="-2" attributes="0"/>
+                                  <Group type="103" groupAlignment="0" max="-2" attributes="0">
+                                      <Component id="jTextField3" alignment="1" max="32767" attributes="1"/>
+                                      <Component id="birthDateSpinner" alignment="1" min="-2" pref="125" max="-2" attributes="1"/>
+                                  </Group>
+                              </Group>
+                          </Group>
+                          <EmptySpace min="-2" pref="28" max="-2" attributes="0"/>
+                      </Group>
+                  </Group>
+                </DimensionLayout>
+                <DimensionLayout dim="1">
+                  <Group type="103" groupAlignment="0" attributes="0">
+                      <Group type="102" alignment="0" attributes="0">
+                          <Group type="103" groupAlignment="3" attributes="0">
+                              <Component id="patientNameText" alignment="3" min="-2" max="-2" attributes="0"/>
+                              <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
+                          </Group>
+                          <EmptySpace max="-2" attributes="0"/>
+                          <Group type="103" groupAlignment="3" attributes="0">
+                              <Component id="patientIDText" alignment="3" min="-2" max="-2" attributes="0"/>
+                              <Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
+                          </Group>
+                          <EmptySpace max="-2" attributes="0"/>
+                          <Group type="103" groupAlignment="3" attributes="0">
+                              <Component id="jTextField3" alignment="3" min="-2" max="-2" attributes="0"/>
+                              <Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
+                          </Group>
+                          <EmptySpace max="-2" attributes="0"/>
+                          <Group type="103" groupAlignment="0" attributes="0">
+                              <Component id="birthDateSpinner" max="32767" attributes="1"/>
+                              <Component id="jLabel5" alignment="0" pref="28" max="32767" attributes="1"/>
+                          </Group>
+                          <EmptySpace min="-2" pref="20" max="-2" attributes="0"/>
+                      </Group>
+                  </Group>
+                </DimensionLayout>
+              </Layout>
+              <SubComponents>
+                <Component class="javax.swing.JLabel" name="jLabel5">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="Date Of Birth"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JSpinner" name="birthDateSpinner">
+                  <Properties>
+                    <Property name="enabled" type="boolean" value="false"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JLabel" name="jLabel2">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="Patient Name"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JTextField" name="patientNameText">
+                </Component>
+                <Component class="javax.swing.JLabel" name="jLabel3">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="Patient ID"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JTextField" name="patientIDText">
+                </Component>
+                <Component class="javax.swing.JLabel" name="jLabel4">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="Accession #"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JTextField" name="jTextField3">
+                </Component>
+              </SubComponents>
+            </Container>
+            <Container class="javax.swing.JPanel" name="jPanel2">
+              <Properties>
+                <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+                  <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
+                    <EmptyBorder/>
+                  </Border>
+                </Property>
+              </Properties>
+
+              <Layout>
+                <DimensionLayout dim="0">
+                  <Group type="103" groupAlignment="0" attributes="0">
+                      <Group type="102" alignment="0" attributes="0">
+                          <Group type="103" groupAlignment="0" attributes="0">
+                              <Component id="ctCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
+                              <Component id="mrCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
+                              <Component id="xaCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
+                              <Component id="crCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
+                              <Component id="scCheckBox" min="-2" max="-2" attributes="0"/>
+                          </Group>
+                          <EmptySpace max="-2" attributes="0"/>
+                          <Group type="103" groupAlignment="0" attributes="0">
+                              <Component id="nmCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
+                              <Component id="rfCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
+                              <Component id="dxCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
+                              <Component id="pxCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
+                              <Component id="usCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
+                          </Group>
+                          <EmptySpace max="-2" attributes="0"/>
+                          <Group type="103" groupAlignment="0" attributes="0">
+                              <Component id="otCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
+                              <Component id="drCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
+                              <Component id="srCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
+                              <Component id="mgCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
+                              <Component id="rgCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
+                          </Group>
+                      </Group>
+                      <Group type="102" alignment="0" attributes="0">
+                          <EmptySpace min="20" pref="20" max="20" attributes="0"/>
+                          <Component id="modalityText" min="-2" pref="119" max="-2" attributes="0"/>
+                      </Group>
+                  </Group>
+                </DimensionLayout>
+                <DimensionLayout dim="1">
+                  <Group type="103" groupAlignment="0" attributes="0">
+                      <Group type="102" alignment="0" attributes="0">
+                          <Group type="103" groupAlignment="1" attributes="0">
+                              <Group type="102" alignment="1" attributes="0">
+                                  <Component id="otCheckBox" min="-2" max="-2" attributes="0"/>
+                                  <EmptySpace max="-2" attributes="0"/>
+                                  <Component id="drCheckBox" min="-2" max="-2" attributes="0"/>
+                                  <EmptySpace max="-2" attributes="0"/>
+                                  <Component id="srCheckBox" min="-2" max="-2" attributes="0"/>
+                                  <EmptySpace max="-2" attributes="0"/>
+                                  <Component id="mgCheckBox" min="-2" max="-2" attributes="0"/>
+                                  <EmptySpace max="-2" attributes="0"/>
+                                  <Component id="rgCheckBox" min="-2" max="-2" attributes="0"/>
+                              </Group>
+                              <Group type="103" alignment="1" groupAlignment="0" attributes="0">
+                                  <Group type="102" alignment="0" attributes="0">
+                                      <Component id="nmCheckBox" min="-2" max="-2" attributes="0"/>
+                                      <EmptySpace max="-2" attributes="0"/>
+                                      <Component id="rfCheckBox" min="-2" max="-2" attributes="0"/>
+                                      <EmptySpace max="-2" attributes="0"/>
+                                      <Component id="dxCheckBox" min="-2" max="-2" attributes="0"/>
+                                      <EmptySpace max="-2" attributes="0"/>
+                                      <Component id="pxCheckBox" min="-2" max="-2" attributes="0"/>
+                                      <EmptySpace max="-2" attributes="0"/>
+                                      <Group type="103" groupAlignment="3" attributes="0">
+                                          <Component id="usCheckBox" alignment="3" min="-2" max="-2" attributes="0"/>
+                                          <Component id="scCheckBox" alignment="3" min="-2" max="-2" attributes="0"/>
+                                      </Group>
+                                  </Group>
+                                  <Group type="102" alignment="0" attributes="0">
+                                      <Component id="ctCheckBox" min="-2" max="-2" attributes="0"/>
+                                      <EmptySpace max="-2" attributes="0"/>
+                                      <Component id="mrCheckBox" min="-2" max="-2" attributes="0"/>
+                                      <EmptySpace max="-2" attributes="0"/>
+                                      <Component id="xaCheckBox" min="-2" max="-2" attributes="0"/>
+                                      <EmptySpace max="-2" attributes="0"/>
+                                      <Component id="crCheckBox" min="-2" max="-2" attributes="0"/>
+                                  </Group>
+                              </Group>
+                          </Group>
+                          <EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
+                          <Component id="modalityText" min="-2" max="-2" attributes="0"/>
+                      </Group>
+                  </Group>
+                </DimensionLayout>
+              </Layout>
+              <SubComponents>
+                <Component class="javax.swing.JCheckBox" name="ctCheckBox">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="CT"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JCheckBox" name="mrCheckBox">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="MR"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JCheckBox" name="xaCheckBox">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="XA"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JCheckBox" name="crCheckBox">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="CR"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JCheckBox" name="scCheckBox">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="SC"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JCheckBox" name="nmCheckBox">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="NM"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JCheckBox" name="rfCheckBox">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="RF"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JCheckBox" name="dxCheckBox">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="DX"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JCheckBox" name="pxCheckBox">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="PX"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JCheckBox" name="usCheckBox">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="US"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JCheckBox" name="otCheckBox">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="OT"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JCheckBox" name="drCheckBox">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="DR"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JCheckBox" name="srCheckBox">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="SR"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JCheckBox" name="mgCheckBox">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="MG"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JCheckBox" name="rgCheckBox">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="RG"/>
+                  </Properties>
+                </Component>
+                <Component class="javax.swing.JTextField" name="modalityText">
+                </Component>
+              </SubComponents>
+            </Container>
+          </SubComponents>
+        </Container>
+        <Container class="javax.swing.JScrollPane" name="serverlistScroll">
+          <AuxValues>
+            <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+          </AuxValues>
+
+          <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+          <SubComponents>
+            <Component class="javax.swing.JTable" name="serverListTable">
+              <Properties>
+                <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+                  <Font name="Courier" size="12" style="1"/>
+                </Property>
+                <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+                  <Connection code="new ServerTableModel()" type="code"/>
+                </Property>
+              </Properties>
+              <AuxValues>
+                <AuxValue name="JavaCodeGenerator_InitCodePost" type="java.lang.String" value="serverListTable.setDefaultRenderer(Object.class, new CellRenderer());&#xa;serverListTable.getTableHeader().setPreferredSize(new Dimension(this.getWidth(), 25));&#xa;Font ff=new Font("Courier New",Font.BOLD,12);&#xa;serverListTable.getTableHeader().setFont(ff);&#xa;serverListTable.setRowHeight(20);&#xa;serverListTable.getTableHeader().setForeground(new Color(255,138,0));&#xa;serverList [...]
+              </AuxValues>
+            </Component>
+          </SubComponents>
+        </Container>
+        <Container class="javax.swing.JPanel" name="jPanel8">
+
+          <Layout>
+            <DimensionLayout dim="0">
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Group type="102" alignment="0" attributes="0">
+                      <Component id="verifyButton" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace min="-2" max="-2" attributes="0"/>
+                      <Component id="queryButton" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace min="-2" max="-2" attributes="0"/>
+                      <Component id="retrieveButton" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace min="-2" pref="47" max="-2" attributes="0"/>
+                      <Component id="jLabel6" min="-2" pref="198" max="-2" attributes="0"/>
+                      <EmptySpace pref="106" max="32767" attributes="0"/>
+                  </Group>
+              </Group>
+            </DimensionLayout>
+            <DimensionLayout dim="1">
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Group type="103" groupAlignment="3" attributes="0">
+                      <Component id="verifyButton" alignment="3" min="-2" max="-2" attributes="0"/>
+                      <Component id="queryButton" alignment="3" min="-2" max="-2" attributes="0"/>
+                      <Component id="retrieveButton" alignment="3" min="-2" max="-2" attributes="0"/>
+                      <Component id="jLabel6" alignment="3" min="-2" pref="21" max="-2" attributes="0"/>
+                  </Group>
+              </Group>
+            </DimensionLayout>
+          </Layout>
+          <SubComponents>
+            <Component class="javax.swing.JButton" name="verifyButton">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="Verify"/>
+              </Properties>
+              <Events>
+                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="verifyButtonActionPerformed"/>
+              </Events>
+            </Component>
+            <Component class="javax.swing.JButton" name="queryButton">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="Query"/>
+              </Properties>
+              <Events>
+                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="queryButtonActionPerformed"/>
+              </Events>
+            </Component>
+            <Component class="javax.swing.JButton" name="retrieveButton">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="Retrieve"/>
+              </Properties>
+              <Events>
+                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="retrieveButtonActionPerformed"/>
+              </Events>
+            </Component>
+            <Component class="javax.swing.JLabel" name="jLabel6">
+            </Component>
+          </SubComponents>
+        </Container>
+        <Container class="javax.swing.JScrollPane" name="jScrollPane2">
+          <AuxValues>
+            <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+          </AuxValues>
+
+          <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+          <SubComponents>
+            <Component class="javax.swing.JTable" name="studyListTable">
+              <Properties>
+                <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+                  <Font name="Courier" size="13" style="0"/>
+                </Property>
+                <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+                  <Connection code="new StudyListModel()" type="code"/>
+                </Property>
+                <Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor">
+                  <TableColumnModel selectionModel="0"/>
+                </Property>
+              </Properties>
+              <Events>
+                <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="studyListTableMouseClicked"/>
+              </Events>
+              <AuxValues>
+                <AuxValue name="JavaCodeGenerator_InitCodePost" type="java.lang.String" value="studyListTable.setDefaultRenderer(Object.class, new CellRenderer());"/>
+                <AuxValue name="JavaCodeGenerator_ListenersCodePost" type="java.lang.String" value="studyListTable.getTableHeader().setPreferredSize(new Dimension(this.getWidth(), 25));&#xa;Font f=new Font("Courier New",Font.BOLD,14);&#xa;studyListTable.getTableHeader().setFont(new Font(f.getName(),Font.BOLD,14));&#xa;studyListTable.setRowHeight(25);&#xa;studyListTable.getTableHeader().setForeground(new Color(255,138,0));&#xa;studyListTable.getTableHeader().setBackground(new Co [...]
+              </AuxValues>
+            </Component>
+          </SubComponents>
+        </Container>
+        <Component class="javax.swing.JLabel" name="serverNameLabel">
+          <Properties>
+            <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+              <Color blue="0" green="0" red="0" type="rgb"/>
+            </Property>
+            <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+              <Font name="Courier New" size="16" style="1"/>
+            </Property>
+            <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+              <Color blue="0" green="8a" red="ff" type="rgb"/>
+            </Property>
+            <Property name="horizontalAlignment" type="int" value="0"/>
+            <Property name="text" type="java.lang.String" value=" Server Name"/>
+            <Property name="opaque" type="boolean" value="true"/>
+          </Properties>
+        </Component>
+        <Component class="javax.swing.JLabel" name="headerLabel">
+          <Properties>
+            <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+              <Color blue="0" green="0" red="0" type="rgb"/>
+            </Property>
+            <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+              <Font name="Courier New" size="16" style="1"/>
+            </Property>
+            <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+              <Color blue="0" green="8a" red="ff" type="rgb"/>
+            </Property>
+            <Property name="horizontalAlignment" type="int" value="0"/>
+            <Property name="text" type="java.lang.String" value=" DICOM Nodes "/>
+            <Property name="opaque" type="boolean" value="true"/>
+          </Properties>
+        </Component>
+        <Component class="javax.swing.JLabel" name="jLabel1">
+          <Properties>
+            <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+              <Color blue="0" green="0" red="0" type="rgb"/>
+            </Property>
+            <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+              <Font name="Courier New" size="16" style="1"/>
+            </Property>
+            <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+              <Color blue="0" green="8a" red="ff" type="rgb"/>
+            </Property>
+            <Property name="horizontalAlignment" type="int" value="0"/>
+            <Property name="text" type="java.lang.String" value="Query Filter"/>
+            <Property name="opaque" type="boolean" value="true"/>
+          </Properties>
+        </Component>
+      </SubComponents>
+    </Container>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/QueryRetrieve.java b/src/in/raster/mayam/form/QueryRetrieve.java
new file mode 100644
index 0000000..6fe2942
--- /dev/null
+++ b/src/in/raster/mayam/form/QueryRetrieve.java
@@ -0,0 +1,1043 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.delegate.CgetDelegate;
+import in.raster.mayam.delegate.DicomServerDelegate;
+import in.raster.mayam.delegate.EchoService;
+import in.raster.mayam.delegate.QueryService;
+import in.raster.mayam.delegate.MoveDelegate;
+import in.raster.mayam.delegate.WadoRetrieveDelegate;
+import in.raster.mayam.form.dialog.EchoStatus;
+import in.raster.mayam.form.display.Display;
+import in.raster.mayam.model.AEModel;
+import in.raster.mayam.model.StudyModel;
+import in.raster.mayam.model.table.ServerTableModel;
+import in.raster.mayam.model.table.StudyListModel;
+import in.raster.mayam.param.QueryParam;
+import java.awt.Color;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Vector;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.swing.JRadioButton;
+import javax.swing.JSpinner;
+import javax.swing.SpinnerDateModel;
+import javax.swing.UIManager;
+import javax.swing.border.BevelBorder;
+import javax.swing.border.Border;
+import javax.swing.event.ListSelectionEvent;
+import org.dcm4che.data.Dataset;
+import org.dcm4che.util.DcmURL;
+import in.raster.mayam.model.table.renderer.CellRenderer;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.Toolkit;
+import javax.swing.JOptionPane;
+import javax.swing.event.ListSelectionListener;
+import javax.swing.table.TableModel;
+import javax.swing.table.TableRowSorter;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class QueryRetrieve extends javax.swing.JFrame implements ServerChangeListener, ListSelectionListener {
+
+    /** Creates new form QueryRetrieve */
+    public QueryRetrieve() {
+        initComponents();
+        refreshModels();
+        addSearchDateitemListener();
+        addModalityitemListener();
+    }
+
+    private void addSearchDateitemListener() {
+        SearchDaysHandler searchDaysHandler = new SearchDaysHandler();
+        betweenRadio.addItemListener(searchDaysHandler);
+        lastmonthRadio.addItemListener(searchDaysHandler);
+        lastweekRadio.addItemListener(searchDaysHandler);
+        yesterdayRadio.addItemListener(searchDaysHandler);
+        todayRadio.addItemListener(searchDaysHandler);
+        anydateRadio.addItemListener(searchDaysHandler);
+    }
+
+    private void addModalityitemListener() {
+        ModalityHandler modalityHandler = new ModalityHandler();
+        ctCheckBox.addItemListener(modalityHandler);
+        mrCheckBox.addItemListener(modalityHandler);
+        xaCheckBox.addItemListener(modalityHandler);
+        crCheckBox.addItemListener(modalityHandler);
+        scCheckBox.addItemListener(modalityHandler);
+        nmCheckBox.addItemListener(modalityHandler);
+        rfCheckBox.addItemListener(modalityHandler);
+        dxCheckBox.addItemListener(modalityHandler);
+        pxCheckBox.addItemListener(modalityHandler);
+        usCheckBox.addItemListener(modalityHandler);
+        otCheckBox.addItemListener(modalityHandler);
+        drCheckBox.addItemListener(modalityHandler);
+        srCheckBox.addItemListener(modalityHandler);
+        mgCheckBox.addItemListener(modalityHandler);
+        rgCheckBox.addItemListener(modalityHandler);
+    }
+
+    public void refreshModels() {
+        setServerTableModel();
+        setServerName();
+        setSpinnerDateModel();
+    }
+
+    private void setServerTableModel() {
+        ServerTableModel serverTableModel = new ServerTableModel();
+        serverTableModel.setEditable(false);
+        serverTableModel.setData(ApplicationContext.databaseRef.getServerList());
+        serverListTable.setModel(serverTableModel);
+        serverListTable.getSelectionModel().addListSelectionListener(this);
+        serverListTable.getColumnModel().getSelectionModel().addListSelectionListener(this);
+        if (this.serverListTable.getRowCount() > 0) {
+            serverListTable.setRowSelectionInterval(0, 0);
+        }
+    }
+
+    private void setSpinnerDateModel() {
+        SpinnerDateModel spm1 = new SpinnerDateModel();
+        SpinnerDateModel spm2 = new SpinnerDateModel();
+        SpinnerDateModel spm3 = new SpinnerDateModel();
+        fromSpinner.setModel(spm1);
+        fromSpinner.setEditor(new JSpinner.DateEditor(fromSpinner, "dd/MM/yyyy"));
+        toSpinner.setModel(spm2);
+        toSpinner.setEditor(new JSpinner.DateEditor(toSpinner, "dd/MM/yyyy"));
+        birthDateSpinner.setModel(spm3);
+        birthDateSpinner.setEditor(new JSpinner.DateEditor(birthDateSpinner, "dd/MM/yyyy"));
+    }
+
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        searchDaysGroup = new javax.swing.ButtonGroup();
+        modalityGroup = new javax.swing.ButtonGroup();
+        jPanel9 = new javax.swing.JPanel();
+        jPanel7 = new javax.swing.JPanel();
+        jPanel1 = new javax.swing.JPanel();
+        anydateRadio = new javax.swing.JRadioButton();
+        todayRadio = new javax.swing.JRadioButton();
+        yesterdayRadio = new javax.swing.JRadioButton();
+        lastweekRadio = new javax.swing.JRadioButton();
+        lastmonthRadio = new javax.swing.JRadioButton();
+        betweenRadio = new javax.swing.JRadioButton();
+        fromSpinner = new javax.swing.JSpinner();
+        toSpinner = new javax.swing.JSpinner();
+        jPanel10 = new javax.swing.JPanel();
+        jLabel5 = new javax.swing.JLabel();
+        birthDateSpinner = new javax.swing.JSpinner();
+        jLabel2 = new javax.swing.JLabel();
+        patientNameText = new javax.swing.JTextField();
+        jLabel3 = new javax.swing.JLabel();
+        patientIDText = new javax.swing.JTextField();
+        jLabel4 = new javax.swing.JLabel();
+        jTextField3 = new javax.swing.JTextField();
+        jPanel2 = new javax.swing.JPanel();
+        ctCheckBox = new javax.swing.JCheckBox();
+        mrCheckBox = new javax.swing.JCheckBox();
+        xaCheckBox = new javax.swing.JCheckBox();
+        crCheckBox = new javax.swing.JCheckBox();
+        scCheckBox = new javax.swing.JCheckBox();
+        nmCheckBox = new javax.swing.JCheckBox();
+        rfCheckBox = new javax.swing.JCheckBox();
+        dxCheckBox = new javax.swing.JCheckBox();
+        pxCheckBox = new javax.swing.JCheckBox();
+        usCheckBox = new javax.swing.JCheckBox();
+        otCheckBox = new javax.swing.JCheckBox();
+        drCheckBox = new javax.swing.JCheckBox();
+        srCheckBox = new javax.swing.JCheckBox();
+        mgCheckBox = new javax.swing.JCheckBox();
+        rgCheckBox = new javax.swing.JCheckBox();
+        modalityText = new javax.swing.JTextField();
+        serverlistScroll = new javax.swing.JScrollPane();
+        serverListTable = new javax.swing.JTable();
+        jPanel8 = new javax.swing.JPanel();
+        verifyButton = new javax.swing.JButton();
+        queryButton = new javax.swing.JButton();
+        retrieveButton = new javax.swing.JButton();
+        jLabel6 = new javax.swing.JLabel();
+        jScrollPane2 = new javax.swing.JScrollPane();
+        studyListTable = new javax.swing.JTable();
+        serverNameLabel = new javax.swing.JLabel();
+        headerLabel = new javax.swing.JLabel();
+        jLabel1 = new javax.swing.JLabel();
+
+        setTitle("Query/Retrieve");
+        setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/in/raster/mayam/form/images/fav_mayam.png")));
+
+        jPanel9.setMaximumSize(new java.awt.Dimension(1200, 1400));
+
+        jPanel7.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
+
+        jPanel1.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
+
+        searchDaysGroup.add(anydateRadio);
+        anydateRadio.setSelected(true);
+        anydateRadio.setText("Any date");
+
+        searchDaysGroup.add(todayRadio);
+        todayRadio.setText("Today");
+
+        searchDaysGroup.add(yesterdayRadio);
+        yesterdayRadio.setText("Yesterday");
+
+        searchDaysGroup.add(lastweekRadio);
+        lastweekRadio.setText("Last week");
+
+        searchDaysGroup.add(lastmonthRadio);
+        lastmonthRadio.setText("Last month");
+
+        searchDaysGroup.add(betweenRadio);
+        betweenRadio.setText("Between");
+
+        fromSpinner.setEnabled(false);
+
+        toSpinner.setEnabled(false);
+
+        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
+        jPanel1.setLayout(jPanel1Layout);
+        jPanel1Layout.setHorizontalGroup(
+            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(jPanel1Layout.createSequentialGroup()
+                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
+                    .add(todayRadio)
+                    .add(anydateRadio)
+                    .add(yesterdayRadio)
+                    .add(lastweekRadio)
+                    .add(lastmonthRadio)
+                    .add(betweenRadio)
+                    .add(jPanel1Layout.createSequentialGroup()
+                        .add(25, 25, 25)
+                        .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
+                            .add(org.jdesktop.layout.GroupLayout.TRAILING, toSpinner, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE)
+                            .add(fromSpinner, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE))))
+                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+        );
+
+        jPanel1Layout.linkSize(new java.awt.Component[] {anydateRadio, betweenRadio, lastmonthRadio, lastweekRadio, todayRadio, yesterdayRadio}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
+
+        jPanel1Layout.setVerticalGroup(
+            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(jPanel1Layout.createSequentialGroup()
+                .add(anydateRadio, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 15, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(todayRadio, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 23, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(yesterdayRadio, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(lastweekRadio)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(lastmonthRadio, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 17, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(betweenRadio, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 19, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(fromSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 21, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+                .add(toSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+        );
+
+        jPanel1Layout.linkSize(new java.awt.Component[] {anydateRadio, betweenRadio, lastmonthRadio, lastweekRadio, todayRadio, yesterdayRadio}, org.jdesktop.layout.GroupLayout.VERTICAL);
+
+        jPanel10.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
+
+        jLabel5.setText("Date Of Birth");
+
+        birthDateSpinner.setEnabled(false);
+
+        jLabel2.setText("Patient Name");
+
+        jLabel3.setText("Patient ID");
+
+        jLabel4.setText("Accession #");
+
+        org.jdesktop.layout.GroupLayout jPanel10Layout = new org.jdesktop.layout.GroupLayout(jPanel10);
+        jPanel10.setLayout(jPanel10Layout);
+        jPanel10Layout.setHorizontalGroup(
+            jPanel10Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(jPanel10Layout.createSequentialGroup()
+                .addContainerGap()
+                .add(jPanel10Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                    .add(jLabel5)
+                    .add(jLabel4)
+                    .add(jLabel3)
+                    .add(jLabel2))
+                .add(jPanel10Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+                    .add(jPanel10Layout.createSequentialGroup()
+                        .add(18, 18, 18)
+                        .add(jPanel10Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+                            .add(org.jdesktop.layout.GroupLayout.LEADING, patientNameText, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 126, Short.MAX_VALUE)
+                            .add(org.jdesktop.layout.GroupLayout.LEADING, patientIDText, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 126, Short.MAX_VALUE)))
+                    .add(jPanel10Layout.createSequentialGroup()
+                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                        .add(jPanel10Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
+                            .add(org.jdesktop.layout.GroupLayout.TRAILING, jTextField3)
+                            .add(org.jdesktop.layout.GroupLayout.TRAILING, birthDateSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 125, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
+                .add(28, 28, 28))
+        );
+        jPanel10Layout.setVerticalGroup(
+            jPanel10Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(jPanel10Layout.createSequentialGroup()
+                .add(jPanel10Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+                    .add(patientNameText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                    .add(jLabel2))
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(jPanel10Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+                    .add(patientIDText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                    .add(jLabel3))
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(jPanel10Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+                    .add(jTextField3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                    .add(jLabel4))
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(jPanel10Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                    .add(birthDateSpinner)
+                    .add(jLabel5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 28, Short.MAX_VALUE))
+                .add(20, 20, 20))
+        );
+
+        jPanel2.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
+
+        ctCheckBox.setText("CT");
+
+        mrCheckBox.setText("MR");
+
+        xaCheckBox.setText("XA");
+
+        crCheckBox.setText("CR");
+
+        scCheckBox.setText("SC");
+
+        nmCheckBox.setText("NM");
+
+        rfCheckBox.setText("RF");
+
+        dxCheckBox.setText("DX");
+
+        pxCheckBox.setText("PX");
+
+        usCheckBox.setText("US");
+
+        otCheckBox.setText("OT");
+
+        drCheckBox.setText("DR");
+
+        srCheckBox.setText("SR");
+
+        mgCheckBox.setText("MG");
+
+        rgCheckBox.setText("RG");
+
+        org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
+        jPanel2.setLayout(jPanel2Layout);
+        jPanel2Layout.setHorizontalGroup(
+            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(jPanel2Layout.createSequentialGroup()
+                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                    .add(ctCheckBox)
+                    .add(mrCheckBox)
+                    .add(xaCheckBox)
+                    .add(crCheckBox)
+                    .add(scCheckBox))
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                    .add(nmCheckBox)
+                    .add(rfCheckBox)
+                    .add(dxCheckBox)
+                    .add(pxCheckBox)
+                    .add(usCheckBox))
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                    .add(otCheckBox)
+                    .add(drCheckBox)
+                    .add(srCheckBox)
+                    .add(mgCheckBox)
+                    .add(rgCheckBox)))
+            .add(jPanel2Layout.createSequentialGroup()
+                .add(20, 20, 20)
+                .add(modalityText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 119, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+        );
+        jPanel2Layout.setVerticalGroup(
+            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(jPanel2Layout.createSequentialGroup()
+                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+                    .add(jPanel2Layout.createSequentialGroup()
+                        .add(otCheckBox)
+                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                        .add(drCheckBox)
+                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                        .add(srCheckBox)
+                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                        .add(mgCheckBox)
+                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                        .add(rgCheckBox))
+                    .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                        .add(jPanel2Layout.createSequentialGroup()
+                            .add(nmCheckBox)
+                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                            .add(rfCheckBox)
+                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                            .add(dxCheckBox)
+                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                            .add(pxCheckBox)
+                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                            .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+                                .add(usCheckBox)
+                                .add(scCheckBox)))
+                        .add(jPanel2Layout.createSequentialGroup()
+                            .add(ctCheckBox)
+                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                            .add(mrCheckBox)
+                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                            .add(xaCheckBox)
+                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                            .add(crCheckBox))))
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+                .add(modalityText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+        );
+
+        org.jdesktop.layout.GroupLayout jPanel7Layout = new org.jdesktop.layout.GroupLayout(jPanel7);
+        jPanel7.setLayout(jPanel7Layout);
+        jPanel7Layout.setHorizontalGroup(
+            jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(jPanel7Layout.createSequentialGroup()
+                .add(9, 9, 9)
+                .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 157, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(jPanel10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .add(36, 36, 36))
+        );
+        jPanel7Layout.setVerticalGroup(
+            jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(jPanel7Layout.createSequentialGroup()
+                .add(jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                    .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                    .add(jPanel7Layout.createSequentialGroup()
+                        .add(8, 8, 8)
+                        .add(jPanel10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+                    .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+        );
+
+        serverListTable.setFont(new java.awt.Font("Courier", 1, 12)); // NOI18N
+        serverListTable.setModel(new ServerTableModel());
+        serverListTable.setDefaultRenderer(Object.class, new CellRenderer());
+        serverListTable.getTableHeader().setPreferredSize(new Dimension(this.getWidth(), 25));
+        Font ff=new Font("Courier New",Font.BOLD,12);
+        serverListTable.getTableHeader().setFont(ff);
+        serverListTable.setRowHeight(20);
+        serverListTable.getTableHeader().setForeground(new Color(255,138,0));
+        serverListTable.getTableHeader().setBackground(new Color(0,0,0));
+        serverlistScroll.setViewportView(serverListTable);
+
+        verifyButton.setText("Verify");
+        verifyButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                verifyButtonActionPerformed(evt);
+            }
+        });
+
+        queryButton.setText("Query");
+        queryButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                queryButtonActionPerformed(evt);
+            }
+        });
+
+        retrieveButton.setText("Retrieve");
+        retrieveButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                retrieveButtonActionPerformed(evt);
+            }
+        });
+
+        org.jdesktop.layout.GroupLayout jPanel8Layout = new org.jdesktop.layout.GroupLayout(jPanel8);
+        jPanel8.setLayout(jPanel8Layout);
+        jPanel8Layout.setHorizontalGroup(
+            jPanel8Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(jPanel8Layout.createSequentialGroup()
+                .add(verifyButton)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(queryButton)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(retrieveButton)
+                .add(47, 47, 47)
+                .add(jLabel6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 198, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addContainerGap(106, Short.MAX_VALUE))
+        );
+        jPanel8Layout.setVerticalGroup(
+            jPanel8Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(jPanel8Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+                .add(verifyButton)
+                .add(queryButton)
+                .add(retrieveButton)
+                .add(jLabel6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 21, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+        );
+
+        studyListTable.setFont(new java.awt.Font("Courier", 0, 13)); // NOI18N
+        studyListTable.setModel(new StudyListModel());
+        studyListTable.setDefaultRenderer(Object.class, new CellRenderer());
+        studyListTable.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                studyListTableMouseClicked(evt);
+            }
+        });
+        studyListTable.getTableHeader().setPreferredSize(new Dimension(this.getWidth(), 25));
+        Font f=new Font("Courier New",Font.BOLD,14);
+        studyListTable.getTableHeader().setFont(new Font(f.getName(),Font.BOLD,14));
+        studyListTable.setRowHeight(25);
+        studyListTable.getTableHeader().setForeground(new Color(255,138,0));
+        studyListTable.getTableHeader().setBackground(new Color(0,0,0));
+        jScrollPane2.setViewportView(studyListTable);
+
+        serverNameLabel.setBackground(new java.awt.Color(0, 0, 0));
+        serverNameLabel.setFont(new java.awt.Font("Courier New", 1, 16)); // NOI18N
+        serverNameLabel.setForeground(new java.awt.Color(255, 138, 0));
+        serverNameLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+        serverNameLabel.setText(" Server Name");
+        serverNameLabel.setOpaque(true);
+
+        headerLabel.setBackground(new java.awt.Color(0, 0, 0));
+        headerLabel.setFont(new java.awt.Font("Courier New", 1, 16));
+        headerLabel.setForeground(new java.awt.Color(255, 138, 0));
+        headerLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+        headerLabel.setText(" DICOM Nodes ");
+        headerLabel.setOpaque(true);
+
+        jLabel1.setBackground(new java.awt.Color(0, 0, 0));
+        jLabel1.setFont(new java.awt.Font("Courier New", 1, 16)); // NOI18N
+        jLabel1.setForeground(new java.awt.Color(255, 138, 0));
+        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+        jLabel1.setText("Query Filter");
+        jLabel1.setOpaque(true);
+
+        org.jdesktop.layout.GroupLayout jPanel9Layout = new org.jdesktop.layout.GroupLayout(jPanel9);
+        jPanel9.setLayout(jPanel9Layout);
+        jPanel9Layout.setHorizontalGroup(
+            jPanel9Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel9Layout.createSequentialGroup()
+                .addContainerGap()
+                .add(jPanel9Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+                    .add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 1163, Short.MAX_VALUE)
+                    .add(jPanel9Layout.createSequentialGroup()
+                        .add(jPanel9Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                            .add(serverlistScroll, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 535, Short.MAX_VALUE)
+                            .add(org.jdesktop.layout.GroupLayout.TRAILING, serverNameLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 535, Short.MAX_VALUE)
+                            .add(headerLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 535, Short.MAX_VALUE))
+                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                        .add(jPanel9Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
+                            .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                            .add(jPanel7, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 618, Short.MAX_VALUE)
+                            .add(jPanel8, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))))
+        );
+        jPanel9Layout.setVerticalGroup(
+            jPanel9Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(jPanel9Layout.createSequentialGroup()
+                .add(jPanel9Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+                    .add(headerLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                    .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(jPanel9Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                    .add(serverlistScroll, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 234, Short.MAX_VALUE)
+                    .add(jPanel7, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(jPanel9Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                    .add(serverNameLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 23, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                    .add(jPanel8, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 517, Short.MAX_VALUE)
+                .addContainerGap())
+        );
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+        getContentPane().setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(layout.createSequentialGroup()
+                .add(jPanel9, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                .addContainerGap())
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(jPanel9, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+        );
+
+        pack();
+    }// </editor-fold>//GEN-END:initComponents
+
+    private void setPatientInfoToQueryParam() {
+        queryParam.setPatientId(patientIDText.getText());
+        queryParam.setPatientName(patientNameText.getText());
+        queryParam.setAccessionNo(jTextField3.getText());
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
+        Date d1 = (Date) birthDateSpinner.getModel().getValue();
+        String dateOfBirth = sdf.format(d1);
+        queryParam.setBirthDate(dateOfBirth);
+        if (!queryParam.getSearchDays().equalsIgnoreCase("Between")) {
+            resetFromAndToDate();
+        } else {
+            setFromToDate();
+        }
+
+    }
+    private boolean startSearch = false;
+    private void queryButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_queryButtonActionPerformed
+        String serverName = ((ServerTableModel) serverListTable.getModel()).getValueAt(serverListTable.getSelectedRow(), 0);
+        try {
+            startSearch = true;
+            int noFilterQuery = 0;
+            AEModel ae = ApplicationContext.databaseRef.getServerDetail(serverName);
+            DcmURL url = new DcmURL("dicom://" + ae.getAeTitle() + "@" + ae.getHostName() + ":" + ae.getPort());
+            EchoService echo = new EchoService();
+            echo.checkEcho(url);
+            if (echo.getStatus().trim().equalsIgnoreCase("EchoSuccess")) {
+                doQuery(ae, url, noFilterQuery);
+            } else {
+                JOptionPane.showMessageDialog(this, "Server is not available", "Server Status", JOptionPane.INFORMATION_MESSAGE);
+            }
+        } catch (Exception e) {
+            System.out.println("Select a Server");
+            e.printStackTrace();
+        }
+
+        startSearch = false;
+}//GEN-LAST:event_queryButtonActionPerformed
+    private void doQuery(AEModel ae, DcmURL url, int noFilterQuery) {
+        QueryService qs = new QueryService();
+        setPatientInfoToQueryParam();
+        if (queryParam.getPatientId().equalsIgnoreCase("") && queryParam.getPatientName().equalsIgnoreCase("") && queryParam.getSearchDate().equalsIgnoreCase("") && modalityText.getText().equalsIgnoreCase("") && queryParam.getAccessionNo().equalsIgnoreCase("")) {
+            noFilterQuery = JOptionPane.showConfirmDialog(this, "No filters have been selected. It will take long time to query and display result...!", "Confirm Dialog", JOptionPane.YES_NO_OPTION);
+        }
+        if (noFilterQuery == 0) {
+            qs.callFindWithQuery(queryParam.getPatientId(), queryParam.getPatientName(), "", queryParam.getSearchDate(), modalityText.getText(), queryParam.getAccessionNo(), null, url);
+            Vector studyList = new Vector();
+            for (int dataSetCount = 0; dataSetCount < qs.getDatasetVector().size(); dataSetCount++) {
+                try {
+                    Dataset dataSet = (Dataset) qs.getDatasetVector().elementAt(dataSetCount);
+                    StudyModel studyModel = new StudyModel(dataSet);
+                    studyList.addElement(studyModel);
+                } catch (Exception e) {
+                    System.out.println(e.getMessage());
+                }
+            }
+            StudyListModel studyListModel = new StudyListModel();
+            studyListModel.setData(studyList);
+            studyListTable.setModel(studyListModel);
+            TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(studyListModel);
+            studyListTable.setRowSorter(sorter);
+            boolean dicomServerDetailAlreadyPresentInArray = false;
+            jLabel6.setText(qs.getDatasetVector().size() + " Studies found");
+            if (dicomServerArray != null) {
+                for (int i = 0; i < dicomServerArray.size(); i++) {
+                    if (dicomServerArray.get(i).getName().equalsIgnoreCase(ae.getServerName())) {
+                        dicomServerDetailAlreadyPresentInArray = true;
+                        dicomServerArray.get(i).setAe(ae);
+                        dicomServerArray.get(i).setStudyListModel(studyListModel);
+                    }
+                }
+            }
+            if (!dicomServerDetailAlreadyPresentInArray) {
+                DicomServerDelegate dsd = new DicomServerDelegate(ae.getServerName());
+                dsd.setAe(ae);
+                dsd.setStudyListModel(studyListModel);
+                dicomServerArray.add(dsd);
+            }
+        }
+    }
+
+    /**
+     * This routine is the handler for retrieve button.
+     * @param evt
+     */
+    private void retrieveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_retrieveButtonActionPerformed
+        String serverName = ((ServerTableModel) serverListTable.getModel()).getValueAt(serverListTable.getSelectedRow(), 0);
+        String[] s = ApplicationContext.databaseRef.getListenerDetails();
+        if (dicomServerArray != null) {
+            for (int i = 0; i < dicomServerArray.size(); i++) {
+                if (dicomServerArray.get(i).getName().equalsIgnoreCase(serverName)) {
+                    int index[] = studyListTable.getSelectedRows();
+                    for (int j = 0; j < index.length; j++) {
+                        index[j] = studyListTable.convertRowIndexToModel(index[j]);
+                    }
+                    for (int tempI = 0; tempI < index.length; tempI++) {
+
+                        String cmoveParam[] = new String[]{
+                            "dicom" + "://" + dicomServerArray.get(i).getAe().getAeTitle() + "@" + dicomServerArray.get(i).getAe().getHostName() + ":" + dicomServerArray.get(i).getAe().getPort(),
+                            "--dest", s[0], "--pid", dicomServerArray.get(i).getStudyListModel().getValueAt(index[tempI], 0), "--suid",
+                            dicomServerArray.get(i).getStudyListModel().getValueAt(index[tempI], 8)};
+
+                        String cgetParam[] = new String[]{"-L", s[0] + ":" + s[1], dicomServerArray.get(i).getAe().getAeTitle() + "@" + dicomServerArray.get(i).getAe().getHostName() + ":" + dicomServerArray.get(i).getAe().getPort(),
+                            "-cget", "-qModalitiesInStudy=" + dicomServerArray.get(i).getStudyListModel().getValueAt(index[tempI], 6), "-qStudyInstanceUID=" + dicomServerArray.get(i).getStudyListModel().getValueAt(index[tempI], 8),
+                            "-qPatientID=" + dicomServerArray.get(i).getStudyListModel().getValueAt(index[tempI], 0), "-rel"};
+                        try {
+                            if (!ApplicationContext.databaseRef.checkRecordExists("study", "StudyInstanceUID", dicomServerArray.get(i).getStudyListModel().getValueAt(index[tempI], 8))) {
+                                MainScreen.sndRcvFrm.setVisible(true);
+                                MoveDelegate moveDelegate = null;
+                                CgetDelegate cgetDelegate = null;
+                                if (dicomServerArray.get(i).getAe().getRetrieveType().equalsIgnoreCase("C-MOVE")) {
+                                    moveDelegate = new MoveDelegate(cmoveParam);
+                                } else if (dicomServerArray.get(i).getAe().getRetrieveType().equalsIgnoreCase("WADO")) {
+                                    WadoRetrieveDelegate wadoRetrieveDelegate = new WadoRetrieveDelegate();
+                                    wadoRetrieveDelegate.retrieveStudy(serverName, dicomServerArray.get(i).getStudyListModel().getValueAt(index[tempI], 0), dicomServerArray.get(i).getStudyListModel().getValueAt(index[tempI], 8));
+                                } else if (dicomServerArray.get(i).getAe().getRetrieveType().equalsIgnoreCase("C-GET")) {
+                                    cgetDelegate = new CgetDelegate(cgetParam);
+                                }
+                            } else {
+                                MainScreen.sndRcvFrm.setVisible(true);
+                            }
+                        } catch (Exception ex) {
+                            Logger.getLogger(MainScreen.class.getName()).log(Level.SEVERE, null, ex);
+                        }
+                    }
+                }
+            }
+        }
+    }//GEN-LAST:event_retrieveButtonActionPerformed
+
+    /**
+     * This routine used to set the server name
+     */
+    private void setServerName() {
+        if (serverListTable.getSelectedRow() == -1) {
+            serverNameLabel.setText(((ServerTableModel) serverListTable.getModel()).getValueAt(0, 0));
+        } else {
+            serverNameLabel.setText(((ServerTableModel) serverListTable.getModel()).getValueAt(serverListTable.getSelectedRow(), 0));
+        }
+    }
+    private void verifyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_verifyButtonActionPerformed
+        try {
+            String serverName = ((ServerTableModel) serverListTable.getModel()).getValueAt(serverListTable.getSelectedRow(), 0);
+            AEModel ae = ApplicationContext.databaseRef.getServerDetail(serverName);
+            DcmURL url = new DcmURL("dicom://" + ae.getAeTitle() + "@" + ae.getHostName() + ":" + ae.getPort());
+            EchoService echo = new EchoService();
+            EchoStatus echoStatus = new EchoStatus(this, true);
+            Display.alignScreen(echoStatus);
+            echo.checkEcho(url);
+            echoStatus.setTitle("Echo Status");
+            try {
+                if (echo.getStatus().trim().equalsIgnoreCase("EchoSuccess")) {
+                    echoStatus.status.setText("Echo dicom://" + ae.getAeTitle() + "@" + ae.getHostName() + ":" + ae.getPort() + " successfully!");
+                    echoStatus.setVisible(true);
+                } else {
+                    echoStatus.status.setText("Echo dicom://" + ae.getAeTitle() + "@" + ae.getHostName() + ":" + ae.getPort() + " not successfully!");
+                    echoStatus.setVisible(true);
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        } catch (Exception e) {
+            System.out.println("Select a Server");
+        }
+    }//GEN-LAST:event_verifyButtonActionPerformed
+
+    private void serverSelectionPerformed() {
+        setServerName();
+        StudyListModel studyList = new StudyListModel();
+        studyListTable.setModel(studyList);
+        if (serverListTable.getSelectedRow() > -1) {
+            if (dicomServerArray != null) {
+                for (int i = 0; i < dicomServerArray.size(); i++) {
+                    if (dicomServerArray.get(i).getName().equalsIgnoreCase(((ServerTableModel) serverListTable.getModel()).getValueAt(serverListTable.getSelectedRow(), 0))) {
+                        studyListTable.setModel(dicomServerArray.get(i).getStudyListModel());
+                        TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(studyList);
+                        studyListTable.setRowSorter(sorter);
+                    }
+                }
+            }
+        }
+    }
+    private void studyListTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_studyListTableMouseClicked
+        String serverName = ((ServerTableModel) serverListTable.getModel()).getValueAt(serverListTable.getSelectedRow(), 0);
+        String[] s = ApplicationContext.databaseRef.getListenerDetails();
+        if (evt.getClickCount() == 2) {
+            if (dicomServerArray != null) {
+                for (int i = 0; i < dicomServerArray.size(); i++) {
+                    if (dicomServerArray.get(i).getName().equalsIgnoreCase(serverName)) {
+                        int index[] = studyListTable.getSelectedRows();
+                        for (int j = 0; j < index.length; j++) {
+                            index[j] = studyListTable.convertRowIndexToModel(index[j]);
+                        }
+                        for (int tempI = 0; tempI < index.length; tempI++) {
+
+                            String cmoveParam[] = new String[]{
+                                "dicom" + "://" + dicomServerArray.get(i).getAe().getAeTitle() + "@" + dicomServerArray.get(i).getAe().getHostName() + ":" + dicomServerArray.get(i).getAe().getPort(),
+                                "--dest", s[0], "--pid", dicomServerArray.get(i).getStudyListModel().getValueAt(index[tempI], 0), "--suid",
+                                dicomServerArray.get(i).getStudyListModel().getValueAt(index[tempI], 8)};
+
+                            String cgetParam[] = new String[]{"-L", s[0] + ":" + s[1], dicomServerArray.get(i).getAe().getAeTitle() + "@" + dicomServerArray.get(i).getAe().getHostName() + ":" + dicomServerArray.get(i).getAe().getPort(),
+                                "-cget", "-qModalitiesInStudy=" + dicomServerArray.get(i).getStudyListModel().getValueAt(index[tempI], 6), "-qStudyInstanceUID=" + dicomServerArray.get(i).getStudyListModel().getValueAt(index[tempI], 8),
+                                "-qPatientID=" + dicomServerArray.get(i).getStudyListModel().getValueAt(index[tempI], 0), "-rel"};
+                            try {
+                                if (!ApplicationContext.databaseRef.checkRecordExists("study", "StudyInstanceUID", dicomServerArray.get(i).getStudyListModel().getValueAt(index[tempI], 8))) {
+                                    MainScreen.sndRcvFrm.setVisible(true);
+                                    MoveDelegate moveDelegate = null;
+                                    CgetDelegate cgetDelegate = null;
+                                    if (dicomServerArray.get(i).getAe().getRetrieveType().equalsIgnoreCase("C-MOVE")) {
+                                        moveDelegate = new MoveDelegate(cmoveParam);
+                                    } else if (dicomServerArray.get(i).getAe().getRetrieveType().equalsIgnoreCase("WADO")) {
+                                        WadoRetrieveDelegate wadoRetrieveDelegate = new WadoRetrieveDelegate();
+                                        wadoRetrieveDelegate.retrieveStudy(serverName, dicomServerArray.get(i).getStudyListModel().getValueAt(index[tempI], 0), dicomServerArray.get(i).getStudyListModel().getValueAt(index[tempI], 8));
+                                    } else if (dicomServerArray.get(i).getAe().getRetrieveType().equalsIgnoreCase("C-GET")) {
+                                        cgetDelegate = new CgetDelegate(cgetParam);
+                                    }
+                                } else {
+                                    MainScreen.sndRcvFrm.setVisible(true);
+                                }
+                            } catch (Exception ex) {
+                                Logger.getLogger(MainScreen.class.getName()).log(Level.SEVERE, null, ex);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }//GEN-LAST:event_studyListTableMouseClicked
+
+    private class SearchDaysHandler implements ItemListener {
+
+        public void itemStateChanged(ItemEvent e) {
+            if (e.getStateChange() == ItemEvent.SELECTED) {
+                if (searchDaysGroup.getSelection() == ((JRadioButton) e.getItem()).getModel()) {
+                    if (((JRadioButton) e.getItem()).getActionCommand().equalsIgnoreCase("Between")) {
+                        fromSpinner.setEnabled(true);
+                        toSpinner.setEnabled(true);
+                    } else {
+                        fromSpinner.setEnabled(false);
+                        toSpinner.setEnabled(false);
+                    }
+                    queryParam.setSearchDays(((JRadioButton) e.getItem()).getActionCommand());
+                }
+            }
+        }
+    }
+
+    private class ModalityHandler implements ItemListener {
+
+        public void itemStateChanged(ItemEvent e) {
+            String selectedModality = getModality();
+            if (selectedModality.startsWith("\\")) {
+                selectedModality = selectedModality.substring(1);
+            }
+            modalityText.setText(selectedModality);
+        }
+    }
+
+    private String getModality() {
+        String modalityString = "";
+        if (ctCheckBox.isSelected()) {
+            modalityString = ctCheckBox.getActionCommand();
+        }
+        if (mrCheckBox.isSelected()) {
+            modalityString += "\\" + mrCheckBox.getActionCommand();
+        }
+        if (xaCheckBox.isSelected()) {
+            modalityString += "\\" + xaCheckBox.getActionCommand();
+        }
+        if (crCheckBox.isSelected()) {
+            modalityString += "\\" + crCheckBox.getActionCommand();
+        }
+        if (scCheckBox.isSelected()) {
+            modalityString += "\\" + scCheckBox.getActionCommand();
+        }
+        if (nmCheckBox.isSelected()) {
+            modalityString += "\\" + nmCheckBox.getActionCommand();
+        }
+        if (rfCheckBox.isSelected()) {
+            modalityString += "\\" + rfCheckBox.getActionCommand();
+        }
+        if (dxCheckBox.isSelected()) {
+            modalityString += "\\" + dxCheckBox.getActionCommand();
+        }
+        if (pxCheckBox.isSelected()) {
+            modalityString += "\\" + pxCheckBox.getActionCommand();
+        }
+        if (usCheckBox.isSelected()) {
+            modalityString += "\\" + usCheckBox.getActionCommand();
+        }
+        if (otCheckBox.isSelected()) {
+            modalityString += "\\" + otCheckBox.getActionCommand();
+        }
+        if (drCheckBox.isSelected()) {
+            modalityString += "\\" + drCheckBox.getActionCommand();
+        }
+        if (srCheckBox.isSelected()) {
+            modalityString += "\\" + srCheckBox.getActionCommand();
+        }
+        if (mgCheckBox.isSelected()) {
+            modalityString += "\\" + mgCheckBox.getActionCommand();
+        }
+        if (rgCheckBox.isSelected()) {
+            modalityString += "\\" + rgCheckBox.getActionCommand();
+        }
+
+        return modalityString;
+    }
+
+    private void osSpecifics() {
+        this.setSize(1030, 750);
+        if (System.getProperty("os.name").startsWith("Mac")) {
+            Border border = UIManager.getBorder("InsetBorder.aquaVariant");
+            if (border == null) {
+                border = new BevelBorder(1);
+            }
+            jPanel1.setBorder(border);
+            jPanel2.setBorder(border);
+            jPanel9.setBackground(new Color(216, 216, 216));
+            jPanel1.setBackground(new Color(216, 216, 216));
+            jPanel2.setBackground(new Color(216, 216, 216));
+            jPanel7.setBackground(new Color(216, 216, 216));
+            jPanel8.setBackground(new Color(216, 216, 216));
+            serverlistScroll.setBackground(new Color(216, 216, 216));
+        }
+    }
+
+    /**
+     * This is implemented handler method for ServerChangeListener.
+     */
+    public void onServerChange() {
+        setServerTableModel();
+        setServerName();
+    }
+
+    public void valueChanged(ListSelectionEvent e) {
+        serverSelectionPerformed();
+    }
+
+    public void setFromToDate() {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
+        Date d1 = (Date) fromSpinner.getModel().getValue();
+        Date d2 = (Date) toSpinner.getModel().getValue();
+        String from = sdf.format(d1);
+        String to = sdf.format(d2);
+        queryParam.setFrom(from);
+        queryParam.setTo(to);
+    }
+
+    /**
+     *This routine used to reset the from and to date.
+     */
+    public void resetFromAndToDate() {
+        queryParam.setFrom(null);
+        queryParam.setTo(null);
+    }
+
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String args[]) {
+        java.awt.EventQueue.invokeLater(new Runnable() {
+
+            public void run() {
+                new QueryRetrieve().setVisible(true);
+            }
+        });
+    }
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JRadioButton anydateRadio;
+    private javax.swing.JRadioButton betweenRadio;
+    private javax.swing.JSpinner birthDateSpinner;
+    private javax.swing.JCheckBox crCheckBox;
+    private javax.swing.JCheckBox ctCheckBox;
+    private javax.swing.JCheckBox drCheckBox;
+    private javax.swing.JCheckBox dxCheckBox;
+    private javax.swing.JSpinner fromSpinner;
+    private javax.swing.JLabel headerLabel;
+    private javax.swing.JLabel jLabel1;
+    private javax.swing.JLabel jLabel2;
+    private javax.swing.JLabel jLabel3;
+    private javax.swing.JLabel jLabel4;
+    private javax.swing.JLabel jLabel5;
+    private javax.swing.JLabel jLabel6;
+    private javax.swing.JPanel jPanel1;
+    private javax.swing.JPanel jPanel10;
+    private javax.swing.JPanel jPanel2;
+    private javax.swing.JPanel jPanel7;
+    private javax.swing.JPanel jPanel8;
+    private javax.swing.JPanel jPanel9;
+    private javax.swing.JScrollPane jScrollPane2;
+    private javax.swing.JTextField jTextField3;
+    private javax.swing.JRadioButton lastmonthRadio;
+    private javax.swing.JRadioButton lastweekRadio;
+    private javax.swing.JCheckBox mgCheckBox;
+    private javax.swing.ButtonGroup modalityGroup;
+    private javax.swing.JTextField modalityText;
+    private javax.swing.JCheckBox mrCheckBox;
+    private javax.swing.JCheckBox nmCheckBox;
+    private javax.swing.JCheckBox otCheckBox;
+    private javax.swing.JTextField patientIDText;
+    private javax.swing.JTextField patientNameText;
+    private javax.swing.JCheckBox pxCheckBox;
+    private javax.swing.JButton queryButton;
+    private javax.swing.JButton retrieveButton;
+    private javax.swing.JCheckBox rfCheckBox;
+    private javax.swing.JCheckBox rgCheckBox;
+    private javax.swing.JCheckBox scCheckBox;
+    private javax.swing.ButtonGroup searchDaysGroup;
+    private javax.swing.JTable serverListTable;
+    private javax.swing.JLabel serverNameLabel;
+    private javax.swing.JScrollPane serverlistScroll;
+    private javax.swing.JCheckBox srCheckBox;
+    private javax.swing.JTable studyListTable;
+    private javax.swing.JSpinner toSpinner;
+    private javax.swing.JRadioButton todayRadio;
+    private javax.swing.JCheckBox usCheckBox;
+    private javax.swing.JButton verifyButton;
+    private javax.swing.JCheckBox xaCheckBox;
+    private javax.swing.JRadioButton yesterdayRadio;
+    // End of variables declaration//GEN-END:variables
+    public ArrayList<DicomServerDelegate> dicomServerArray = new ArrayList<DicomServerDelegate>();
+    private QueryParam queryParam = new QueryParam();
+}
diff --git a/src/in/raster/mayam/form/SendReceiveFrame.form b/src/in/raster/mayam/form/SendReceiveFrame.form
new file mode 100644
index 0000000..98bec9c
--- /dev/null
+++ b/src/in/raster/mayam/form/SendReceiveFrame.form
@@ -0,0 +1,54 @@
+<?xml version="1.1" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
+  <Properties>
+    <Property name="title" type="java.lang.String" value="Job Queue"/>
+    <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+      <Color blue="66" green="66" red="66" type="rgb"/>
+    </Property>
+    <Property name="iconImage" type="java.awt.Image" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+      <Connection code="Toolkit.getDefaultToolkit().getImage(getClass().getResource("/in/raster/mayam/form/images/fav_mayam.png"))" type="code"/>
+    </Property>
+  </Properties>
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="sendReceivePanel1" pref="797" max="32767" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="1" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="sendReceivePanel1" pref="426" max="32767" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Component class="in.raster.mayam.form.SendReceivePanel" name="sendReceivePanel1">
+      <AuxValues>
+        <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="1"/>
+      </AuxValues>
+    </Component>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/SendReceiveFrame.java b/src/in/raster/mayam/form/SendReceiveFrame.java
new file mode 100644
index 0000000..5e49931
--- /dev/null
+++ b/src/in/raster/mayam/form/SendReceiveFrame.java
@@ -0,0 +1,104 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form;
+
+import java.awt.Toolkit;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class SendReceiveFrame extends javax.swing.JFrame {
+    
+    /** Creates new form SendReceiveFrame */
+    public SendReceiveFrame() {
+        initComponents();
+    }
+    
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        sendReceivePanel1 = new in.raster.mayam.form.SendReceivePanel();
+
+        setTitle("Job Queue");
+        setBackground(new java.awt.Color(102, 102, 102));
+        setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/in/raster/mayam/form/images/fav_mayam.png")));
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+        getContentPane().setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(layout.createSequentialGroup()
+                .addContainerGap()
+                .add(sendReceivePanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 797, Short.MAX_VALUE)
+                .addContainerGap())
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+                .addContainerGap()
+                .add(sendReceivePanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 426, Short.MAX_VALUE))
+        );
+
+        pack();
+    }// </editor-fold>//GEN-END:initComponents
+    
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String args[]) {
+        java.awt.EventQueue.invokeLater(new Runnable() {
+            public void run() {
+                new SendReceiveFrame().setVisible(true);
+            }
+        });
+    }
+    
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    public in.raster.mayam.form.SendReceivePanel sendReceivePanel1;
+    // End of variables declaration//GEN-END:variables
+    
+}
diff --git a/src/in/raster/mayam/form/SendReceivePanel.form b/src/in/raster/mayam/form/SendReceivePanel.form
new file mode 100644
index 0000000..c2b4678
--- /dev/null
+++ b/src/in/raster/mayam/form/SendReceivePanel.form
@@ -0,0 +1,139 @@
+<?xml version="1.1" encoding="UTF-8" ?>
+
+<Form version="1.5" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Component id="jLabel1" alignment="0" pref="719" max="32767" attributes="0"/>
+          <Component id="jScrollPane1" alignment="0" pref="719" max="32767" attributes="0"/>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" attributes="0">
+              <Component id="jLabel1" min="-2" pref="24" max="-2" attributes="0"/>
+              <EmptySpace min="-2" max="-2" attributes="0"/>
+              <Component id="jScrollPane1" pref="298" max="32767" attributes="0"/>
+              <EmptySpace min="-2" max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Component class="javax.swing.JLabel" name="jLabel1">
+      <Properties>
+        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="0" green="0" red="0" type="rgb"/>
+        </Property>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Courier New" size="16" style="1"/>
+        </Property>
+        <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="0" green="8a" red="fa" type="rgb"/>
+        </Property>
+        <Property name="text" type="java.lang.String" value="  Receive"/>
+        <Property name="opaque" type="boolean" value="true"/>
+      </Properties>
+    </Component>
+    <Container class="javax.swing.JScrollPane" name="jScrollPane1">
+      <AuxValues>
+        <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+      </AuxValues>
+
+      <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+      <SubComponents>
+        <Component class="javax.swing.JTable" name="receiveTable">
+          <Properties>
+            <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
+              <Table columnCount="10" rowCount="0">
+                <Column editable="true" title="From" type="java.lang.Object"/>
+                <Column editable="true" title="Patient Id" type="java.lang.Object"/>
+                <Column editable="true" title="Patient Name" type="java.lang.Object"/>
+                <Column editable="true" title="Study Date" type="java.lang.Object"/>
+                <Column editable="true" title="Study Description" type="java.lang.Object"/>
+                <Column editable="true" title="Received" type="java.lang.Object"/>
+                <Column editable="true" title="Available" type="java.lang.Object"/>
+                <Column editable="true" title="Failed" type="java.lang.Object"/>
+                <Column editable="true" title="Last Active" type="java.lang.Object"/>
+                <Column editable="true" title="Message" type="java.lang.Object"/>
+              </Table>
+            </Property>
+            <Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor">
+              <TableColumnModel selectionModel="0">
+                <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
+                  <Title/>
+                  <Editor/>
+                  <Renderer/>
+                </Column>
+                <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
+                  <Title/>
+                  <Editor/>
+                  <Renderer/>
+                </Column>
+                <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
+                  <Title/>
+                  <Editor/>
+                  <Renderer/>
+                </Column>
+                <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
+                  <Title/>
+                  <Editor/>
+                  <Renderer/>
+                </Column>
+                <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
+                  <Title/>
+                  <Editor/>
+                  <Renderer/>
+                </Column>
+                <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
+                  <Title/>
+                  <Editor/>
+                  <Renderer/>
+                </Column>
+                <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
+                  <Title/>
+                  <Editor/>
+                  <Renderer/>
+                </Column>
+                <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
+                  <Title/>
+                  <Editor/>
+                  <Renderer/>
+                </Column>
+                <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
+                  <Title/>
+                  <Editor/>
+                  <Renderer/>
+                </Column>
+                <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
+                  <Title/>
+                  <Editor/>
+                  <Renderer/>
+                </Column>
+              </TableColumnModel>
+            </Property>
+            <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor">
+              <TableHeader reorderingAllowed="true" resizingAllowed="true"/>
+            </Property>
+          </Properties>
+          <AuxValues>
+            <AuxValue name="JavaCodeGenerator_InitCodePost" type="java.lang.String" value="receiveTable.setDefaultRenderer(Object.class, new CellRenderer());&#xa;//receiveTable.getTableHeader().setPreferredSize(new Dimension(this.getWidth(), 20));&#xa;//Font receiveFont=receiveTable.getTableHeader().getFont();&#xa;//receiveTable.getTableHeader().setFont(new Font(receiveFont.getName(),Font.PLAIN,11));&#xa;//receiveTable.setRowHeight(20);&#xa;&#xa;receiveTable.getTableHeader().setPreferred [...]
+            <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="1"/>
+          </AuxValues>
+        </Component>
+      </SubComponents>
+    </Container>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/SendReceivePanel.java b/src/in/raster/mayam/form/SendReceivePanel.java
new file mode 100644
index 0000000..9315f05
--- /dev/null
+++ b/src/in/raster/mayam/form/SendReceivePanel.java
@@ -0,0 +1,126 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form;
+
+import in.raster.mayam.model.table.renderer.CellRenderer;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Font;
+import javax.swing.table.DefaultTableModel;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class SendReceivePanel extends javax.swing.JPanel {
+
+    /** Creates new form SendReceivePanel */
+    public static DefaultTableModel receiveTableModel;
+    public static DefaultTableModel sendTableModel;
+
+    public SendReceivePanel() {
+        initComponents();
+        receiveTableModel = (DefaultTableModel) this.receiveTable.getModel();
+
+    }
+
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        jLabel1 = new javax.swing.JLabel();
+        jScrollPane1 = new javax.swing.JScrollPane();
+        receiveTable = new javax.swing.JTable();
+
+        jLabel1.setBackground(new java.awt.Color(0, 0, 0));
+        jLabel1.setFont(new java.awt.Font("Courier New", 1, 16)); // NOI18N
+        jLabel1.setForeground(new java.awt.Color(250, 138, 0));
+        jLabel1.setText("  Receive");
+        jLabel1.setOpaque(true);
+
+        receiveTable.setModel(new javax.swing.table.DefaultTableModel(
+            new Object [][] {
+
+            },
+            new String [] {
+                "From", "Patient Id", "Patient Name", "Study Date", "Study Description", "Received", "Available", "Failed", "Last Active", "Message"
+            }
+        ));
+        receiveTable.setDefaultRenderer(Object.class, new CellRenderer());
+        //receiveTable.getTableHeader().setPreferredSize(new Dimension(this.getWidth(), 20));
+        //Font receiveFont=receiveTable.getTableHeader().getFont();
+        //receiveTable.getTableHeader().setFont(new Font(receiveFont.getName(),Font.PLAIN,11));
+        //receiveTable.setRowHeight(20);
+
+        receiveTable.getTableHeader().setPreferredSize(new Dimension(this.getWidth(), 23));
+        Font f=new Font("Courier New",Font.BOLD,12);
+        receiveTable.getTableHeader().setFont(f);
+        receiveTable.setRowHeight(23);
+        receiveTable.getTableHeader().setForeground(new Color(255,138,0));
+        receiveTable.getTableHeader().setBackground(new Color(0,0,0));
+        jScrollPane1.setViewportView(receiveTable);
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
+        this.setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 719, Short.MAX_VALUE)
+            .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 719, Short.MAX_VALUE)
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(layout.createSequentialGroup()
+                .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 24, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 298, Short.MAX_VALUE)
+                .addContainerGap())
+        );
+    }// </editor-fold>//GEN-END:initComponents
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JLabel jLabel1;
+    private javax.swing.JScrollPane jScrollPane1;
+    public javax.swing.JTable receiveTable;
+    // End of variables declaration//GEN-END:variables
+}
diff --git a/src/in/raster/mayam/form/SendingProgress.form b/src/in/raster/mayam/form/SendingProgress.form
new file mode 100644
index 0000000..7d1906a
--- /dev/null
+++ b/src/in/raster/mayam/form/SendingProgress.form
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
+  <Properties>
+    <Property name="alwaysOnTop" type="boolean" value="true"/>
+    <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+      <Color blue="66" green="66" red="66" type="rgb"/>
+    </Property>
+    <Property name="resizable" type="boolean" value="false"/>
+    <Property name="undecorated" type="boolean" value="true"/>
+  </Properties>
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Component id="jLabel1" alignment="0" pref="306" max="32767" attributes="0"/>
+          <Group type="102" alignment="1" attributes="0">
+              <EmptySpace pref="88" max="32767" attributes="0"/>
+              <Component id="jProgressBar1" min="-2" max="-2" attributes="0"/>
+              <EmptySpace min="-2" pref="72" max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
+              <EmptySpace type="separate" max="-2" attributes="0"/>
+              <Component id="jProgressBar1" min="-2" max="-2" attributes="0"/>
+              <EmptySpace pref="35" max="32767" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Component class="javax.swing.JLabel" name="jLabel1">
+      <Properties>
+        <Property name="horizontalAlignment" type="int" value="0"/>
+        <Property name="text" type="java.lang.String" value="Sending ..."/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JProgressBar" name="jProgressBar1">
+      <Properties>
+        <Property name="value" type="int" value="1"/>
+      </Properties>
+    </Component>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/SendingProgress.java b/src/in/raster/mayam/form/SendingProgress.java
new file mode 100644
index 0000000..d3c5bb3
--- /dev/null
+++ b/src/in/raster/mayam/form/SendingProgress.java
@@ -0,0 +1,127 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class SendingProgress extends javax.swing.JFrame  {
+    
+    /** Creates new form SendReceiveFrame */
+    public SendingProgress() {
+        initComponents();    
+    }
+    
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        jLabel1 = new javax.swing.JLabel();
+        jProgressBar1 = new javax.swing.JProgressBar();
+
+        setAlwaysOnTop(true);
+        setBackground(new java.awt.Color(102, 102, 102));
+        setResizable(false);
+        setUndecorated(true);
+
+        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+        jLabel1.setText("Sending ...");
+
+        jProgressBar1.setValue(1);
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+        getContentPane().setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 306, Short.MAX_VALUE)
+            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+                .addContainerGap(88, Short.MAX_VALUE)
+                .add(jProgressBar1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .add(72, 72, 72))
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(layout.createSequentialGroup()
+                .addContainerGap()
+                .add(jLabel1)
+                .add(18, 18, 18)
+                .add(jProgressBar1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addContainerGap(35, Short.MAX_VALUE))
+        );
+
+        pack();
+    }// </editor-fold>//GEN-END:initComponents
+    public void updateBar(int value)
+    {
+        jProgressBar1.setValue(value);
+        jProgressBar1.repaint();
+
+    }
+    public void setProgressMaximum(int max)
+    {
+        jProgressBar1.setMinimum(1);
+        jProgressBar1.setMaximum(max);
+
+    }
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String args[]) {
+        java.awt.EventQueue.invokeLater(new Runnable() {
+            public void run() {
+                new SendingProgress().setVisible(true);
+            }
+        });
+    }
+    
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JLabel jLabel1;
+    private javax.swing.JProgressBar jProgressBar1;
+    // End of variables declaration//GEN-END:variables
+
+   
+    
+}
diff --git a/src/in/raster/mayam/form/SeriesPanel.form b/src/in/raster/mayam/form/SeriesPanel.form
new file mode 100644
index 0000000..942ba21
--- /dev/null
+++ b/src/in/raster/mayam/form/SeriesPanel.form
@@ -0,0 +1,72 @@
+<?xml version="1.1" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace min="-2" pref="112" max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Component id="totalImagesText" alignment="0" pref="146" max="32767" attributes="1"/>
+                  <Component id="seriesDescriptionText" alignment="0" pref="146" max="32767" attributes="1"/>
+                  <Component id="modalityText" alignment="0" pref="146" max="32767" attributes="1"/>
+                  <Component id="institutionText" alignment="1" pref="146" max="32767" attributes="1"/>
+              </Group>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace min="-2" pref="10" max="-2" attributes="0"/>
+              <Component id="seriesDescriptionText" min="-2" max="-2" attributes="0"/>
+              <EmptySpace min="-2" pref="2" max="-2" attributes="0"/>
+              <Component id="modalityText" min="-2" max="-2" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="institutionText" min="-2" max="-2" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="totalImagesText" min="-2" max="-2" attributes="0"/>
+              <EmptySpace pref="36" max="32767" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Component class="javax.swing.JLabel" name="seriesDescriptionText">
+      <Properties>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Lucida Grande" size="13" style="1"/>
+        </Property>
+        <Property name="text" type="java.lang.String" value="s"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="modalityText">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="s"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="institutionText">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="s"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="totalImagesText">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="s"/>
+      </Properties>
+    </Component>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/SeriesPanel.java b/src/in/raster/mayam/form/SeriesPanel.java
new file mode 100644
index 0000000..c2bc2ea
--- /dev/null
+++ b/src/in/raster/mayam/form/SeriesPanel.java
@@ -0,0 +1,412 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.delegate.SeriesListUpdator;
+import in.raster.mayam.delegate.ShowImageViewDelegate;
+import in.raster.mayam.delegate.WindowingPanelLoader;
+import in.raster.mayam.util.DicomTags;
+import in.raster.mayam.util.DicomTagsReader;
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.Toolkit;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import javax.imageio.ImageIO;
+import javax.imageio.ImageReader;
+import javax.imageio.stream.ImageInputStream;
+import javax.swing.ImageIcon;
+import javax.swing.border.LineBorder;
+import org.dcm4che.data.Dataset;
+import org.dcm4che.dict.Tags;
+import org.dcm4che.imageio.plugins.DcmMetadata;
+import org.dcm4che2.data.Tag;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class SeriesPanel extends javax.swing.JPanel implements MouseListener {
+
+    /** Creates new form SeriesPanel */
+    //Image Reading variables.
+    private Iterator iter;
+    private ImageReader reader;
+    private ImageInputStream iis;
+    //Variables to store series details.
+    private String studyUID = "";
+    private String seriesUID = "";
+    private String seriesDesc = "";
+    private String modality = "";
+    private String institutionName = "";
+    private int totalInstace;
+    private Dataset dataset;
+    //Variables to store the series thumbnail image file path.
+    private String fileUrl;
+    //Variables to store the buffered image
+    private Image loadedImage;
+    private ImageIcon imageIcon;
+    private BufferedImage currentbufferedimage;
+    private BufferedImage image;
+    private Thumbnail imageLabel;
+    private boolean instanceListAdded = false;
+    private int nFrames = 0;
+    private boolean mulitiFrame = false;
+    private String instanceUID = "";
+    private boolean isEncapsulatedDocument = false;
+
+    public SeriesPanel() {
+        initComponents();
+    }
+
+    public SeriesPanel(String dicomFileUrl) {
+        fileUrl = dicomFileUrl;
+        try {
+            readDicomFile(new File(dicomFileUrl));
+            retrieveInfo();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        initComponents();
+        this.addListeners();
+        setHeaders();
+        setNoSelectionColoring();
+
+
+    }
+
+    /**
+     * This routine used to add the image in this container.
+     */
+    private void addImage() {
+        imageLabel = new Thumbnail(image);
+        imageLabel.setSize(96, 96);
+        this.add(imageLabel);
+        imageLabel.addMouseListener(this);
+        imageLabel.setBounds(1, 1, 96, 96);
+    }
+
+    /**
+     *
+     */
+    private void addListeners() {
+        this.addMouseListener(this);
+    }
+
+    /**
+     * This routine used to retrieve the dicom related details
+     */
+    private void retrieveInfo() {
+
+        studyUID = dataset.getString(Tags.StudyInstanceUID);
+        seriesUID = dataset.getString(Tags.SeriesInstanceUID);
+        if (ApplicationContext.databaseRef.getMultiframeStatus()) {
+            setTotalInstacne();
+        } else {
+            totalInstace = ApplicationContext.databaseRef.getSeriesLevelInstance(studyUID, seriesUID);
+        }
+        seriesDesc = dataset.getString(Tags.SeriesDescription);
+        modality = dataset.getString(Tags.Modality);
+        institutionName = dataset.getString(Tags.InstitutionName);
+        instanceUID = dataset.getString(Tags.SOPInstanceUID);
+
+    }
+
+    /**
+     * This routine used to update the instance list in the studylist array
+     */
+    public void updateInstanceList() {
+        SeriesListUpdator series = new SeriesListUpdator(studyUID, seriesUID, instanceUID, isMulitiFrame(), false);
+    }
+
+    /**
+     * This routine used to read the dicom file
+     * @param selFile
+     */
+    private void readDicomFile(File selFile) {
+        try {
+            iis = ImageIO.createImageInputStream(selFile);
+            ImageIO.scanForPlugins();
+            iter = ImageIO.getImageReadersByFormatName("DICOM");
+            reader = (ImageReader) iter.next();
+            reader.setInput(iis, false);
+            dataset = ((DcmMetadata) reader.getStreamMetadata()).getDataset();
+            try {
+                if (reader.getNumImages(true) > 0) {
+                    currentbufferedimage = reader.read(0);
+                }
+                nFrames = reader.getNumImages(true);
+                if (nFrames - 1 > 0) {
+                    mulitiFrame = true;
+                }
+                if (reader.getNumImages(true) > 0) {
+                    imageIcon = new ImageIcon();
+                    imageIcon.setImage(currentbufferedimage);
+                    loadedImage = imageIcon.getImage();
+                    image = new BufferedImage(loadedImage.getWidth(null), loadedImage.getHeight(null), BufferedImage.TYPE_INT_RGB);
+                    Graphics2D g2 = image.createGraphics();
+                    g2.drawImage(loadedImage, 0, 0, null);
+                }
+                if (dataset.getString(Tag.SOPClassUID).equalsIgnoreCase("1.2.840.10008.5.1.4.1.1.104.1")) {
+                    isEncapsulatedDocument = true;
+                    imageIcon = new ImageIcon();
+                    imageIcon.setImage(Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("/in/raster/mayam/form/images/pdficon.png")));
+                    loadedImage = imageIcon.getImage();
+                    image = new BufferedImage(loadedImage.getWidth(null), loadedImage.getHeight(null), BufferedImage.TYPE_INT_RGB);
+                    Graphics2D g2 = image.createGraphics();
+                    g2.drawImage(loadedImage, 0, 0, null);
+
+                }
+                addImage();
+            } catch (RuntimeException e) {
+                e.printStackTrace();
+                System.out.println("while Reading Image " + e.getMessage());
+            }
+        } catch (Exception e) {
+            System.out.println(e.toString());
+        } finally {
+            try {
+                iis.close();
+                iter = null;
+                currentbufferedimage = null;
+                imageIcon = null;
+                loadedImage = null;
+            } catch (Exception ex) {
+                ex.printStackTrace();
+                // Logger.getLogger(ThumbnailImage.class.getName()).log(Level.SEVERE, null, ex);
+            }
+        }
+    }
+
+    /**
+     * This routine used to open the single image in the imageview.
+     * @param filePath
+     */
+    public void openSingleImage(String filePath) {
+        if (!ApplicationContext.imageViewExist()) {
+            ApplicationContext.createImageView();
+        }
+        ShowImageViewDelegate showImgView = new ShowImageViewDelegate(filePath);
+    }
+
+    /**
+     * This routine used to set the selection coloring
+     */
+    public void setSelectionColoring() {
+        this.setBorder(new LineBorder(Color.BLACK, 2));
+        this.setBackground(Color.black);
+        seriesDescriptionText.setForeground(new Color(255, 195, 0));
+        totalImagesText.setForeground(new Color(255, 195, 0));
+        modalityText.setForeground(new Color(255, 195, 0));
+        institutionText.setForeground(new Color(255, 195, 0));
+    }
+
+    /**
+     * This routine used to remove the selection coloring.
+     */
+    public void setNoSelectionColoring() {
+        this.setBackground(new Color(51, 51, 51));
+        this.setBorder(new LineBorder(new Color(101, 101, 101)));
+        seriesDescriptionText.setForeground(Color.gray);
+        totalImagesText.setForeground(Color.gray);
+        modalityText.setForeground(Color.gray);
+        institutionText.setForeground(Color.gray);
+    }
+
+    private void setTotalInstacne() {
+
+        if (!isMulitiFrame()) {
+            totalInstace = ApplicationContext.databaseRef.getSeriesLevelInstance(this.studyUID, this.seriesUID);
+
+        } else {
+            totalInstace = nFrames;
+        }
+    }
+
+    public boolean isMulitiFrame() {
+        return mulitiFrame;
+    }
+
+    /**
+     * This routine used to get the file url for this instance.
+     * @return
+     */
+    public String getFileUrl() {
+        return fileUrl;
+    }
+
+    /**
+     * This routine used to set the file url for a specific instance.
+     * @param fileUrl
+     */
+    public void setFileUrl(String fileUrl) {
+        this.fileUrl = fileUrl;
+    }
+
+    private void setHeaders() {
+        seriesDescriptionText.setText("" + seriesDesc != null ? seriesDesc : "");
+        if (!isEncapsulatedDocument) {
+            totalImagesText.setText(this.totalInstace + " Images");
+        } else {
+            totalImagesText.setText("");
+        }
+        modalityText.setText("" + modality != null ? modality : "");
+        institutionText.setText(institutionName != null ? institutionName : "");
+
+    }
+
+    public void mouseClicked(MouseEvent e) {
+        if (ApplicationContext.selectedSeriesPanel != null) {
+            ApplicationContext.selectedSeriesPanel.setNoSelectionColoring();
+        }
+        ApplicationContext.selectedSeriesPanel = this;
+        ApplicationContext.selectedSeriesPanel.setSelectionColoring();
+        if (e.getClickCount() == 2) {
+            // openSingleImage(this.fileUrl);
+        }
+    }
+
+    public void mousePressed(MouseEvent e) {
+        if (!ApplicationContext.mainScreen.getCanvas().getFilePath().equalsIgnoreCase(this.getFileUrl())) {
+            WindowingPanelLoader.loadImageOnWindowingPanel(this.getFileUrl());
+            if (MainScreen.dicomTagsViewer.isVisible()) {
+                ArrayList<DicomTags> dcmTags = DicomTagsReader.getTags(new File(this.getFileUrl()));
+                MainScreen.dicomTagsViewer.setDataModelOnTable(dcmTags);
+            }
+        }
+        if (!instanceListAdded) {
+            updateInstanceList();
+        }
+    }
+
+    public void mouseReleased(MouseEvent e) {
+    }
+
+    public void mouseEntered(MouseEvent e) {
+    }
+
+    public void mouseExited(MouseEvent e) {
+    }
+
+    public void clearAllMemoryReference() {
+        this.removeMouseListener(this);
+        this.removeAll();
+        iter = null;
+        reader = null;
+        iis = null;
+        dataset = null;
+        loadedImage = null;
+        imageIcon = null;
+        currentbufferedimage = null;
+        if (image != null) {
+            image.flush();
+        }
+        image = null;
+        fileUrl = null;
+    }
+
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    @SuppressWarnings("unchecked")
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        seriesDescriptionText = new javax.swing.JLabel();
+        modalityText = new javax.swing.JLabel();
+        institutionText = new javax.swing.JLabel();
+        totalImagesText = new javax.swing.JLabel();
+
+        seriesDescriptionText.setFont(new java.awt.Font("Lucida Grande", 1, 13)); // NOI18N
+        seriesDescriptionText.setText("s");
+
+        modalityText.setText("s");
+
+        institutionText.setText("s");
+
+        totalImagesText.setText("s");
+
+        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
+        this.setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGroup(layout.createSequentialGroup()
+                .addGap(112, 112, 112)
+                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                    .addGroup(layout.createSequentialGroup()
+                        .addComponent(totalImagesText, javax.swing.GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE)
+                        .addContainerGap())
+                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
+                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+                            .addComponent(seriesDescriptionText, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE)
+                            .addComponent(modalityText, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE)
+                            .addComponent(institutionText, javax.swing.GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE))
+                        .addContainerGap())))
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGroup(layout.createSequentialGroup()
+                .addGap(10, 10, 10)
+                .addComponent(seriesDescriptionText)
+                .addGap(2, 2, 2)
+                .addComponent(modalityText)
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                .addComponent(institutionText)
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                .addComponent(totalImagesText)
+                .addContainerGap(36, Short.MAX_VALUE))
+        );
+    }// </editor-fold>//GEN-END:initComponents
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JLabel institutionText;
+    private javax.swing.JLabel modalityText;
+    private javax.swing.JLabel seriesDescriptionText;
+    private javax.swing.JLabel totalImagesText;
+    // End of variables declaration//GEN-END:variables
+}
diff --git a/src/in/raster/mayam/form/ServerChangeListener.java b/src/in/raster/mayam/form/ServerChangeListener.java
new file mode 100644
index 0000000..1cd86ab
--- /dev/null
+++ b/src/in/raster/mayam/form/ServerChangeListener.java
@@ -0,0 +1,51 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public interface ServerChangeListener {
+
+    public void onServerChange();
+
+}
diff --git a/src/in/raster/mayam/form/ServerManager.form b/src/in/raster/mayam/form/ServerManager.form
new file mode 100644
index 0000000..ffbce3d
--- /dev/null
+++ b/src/in/raster/mayam/form/ServerManager.form
@@ -0,0 +1,144 @@
+<?xml version="1.1" encoding="UTF-8" ?>
+
+<Form version="1.5" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Component id="jLabel1" alignment="0" pref="557" max="32767" attributes="0"/>
+          <Group type="102" alignment="1" attributes="0">
+              <EmptySpace pref="261" max="32767" attributes="0"/>
+              <Component id="jButton1" linkSize="1" min="-2" max="-2" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="addButton" linkSize="1" min="-2" max="-2" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="DeleteButton" linkSize="1" min="-2" pref="89" max="-2" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="jScrollPane1" pref="517" max="32767" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="0" attributes="0">
+              <Component id="jLabel1" min="-2" pref="24" max="-2" attributes="0"/>
+              <EmptySpace min="-2" pref="30" max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="3" attributes="0">
+                  <Component id="DeleteButton" alignment="3" min="-2" max="-2" attributes="0"/>
+                  <Component id="addButton" alignment="3" min="-2" max="-2" attributes="0"/>
+                  <Component id="jButton1" alignment="3" min="-2" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="jScrollPane1" pref="187" max="32767" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Component class="javax.swing.JLabel" name="jLabel1">
+      <Properties>
+        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="0" green="0" red="0" type="rgb"/>
+        </Property>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Courier New" size="16" style="1"/>
+        </Property>
+        <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="0" green="8a" red="ff" type="rgb"/>
+        </Property>
+        <Property name="text" type="java.lang.String" value="Servers"/>
+        <Property name="opaque" type="boolean" value="true"/>
+      </Properties>
+    </Component>
+    <Container class="javax.swing.JScrollPane" name="jScrollPane1">
+      <AuxValues>
+        <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+      </AuxValues>
+
+      <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+      <SubComponents>
+        <Component class="javax.swing.JTable" name="serverListTable">
+          <Properties>
+            <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+              <Font name="Courier" size="12" style="1"/>
+            </Property>
+            <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+              <Connection code="new PresetTableModel()" type="code"/>
+            </Property>
+            <Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor">
+              <TableColumnModel selectionModel="0">
+                <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
+                  <Title/>
+                  <Editor/>
+                  <Renderer/>
+                </Column>
+                <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
+                  <Title/>
+                  <Editor/>
+                  <Renderer/>
+                </Column>
+                <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
+                  <Title/>
+                  <Editor/>
+                  <Renderer/>
+                </Column>
+              </TableColumnModel>
+            </Property>
+            <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor">
+              <TableHeader reorderingAllowed="true" resizingAllowed="true"/>
+            </Property>
+          </Properties>
+          <AuxValues>
+            <AuxValue name="JavaCodeGenerator_ListenersCodePost" type="java.lang.String" value="serverListTable.setDefaultRenderer(Object.class, new CellRenderer());&#xa;//serverListTable.getTableHeader().setPreferredSize(new Dimension(jScrollPane1.WIDTH,25));&#xa;//serverListTable.setRowHeight(25);&#xa;&#xa;serverListTable.getTableHeader().setPreferredSize(new Dimension(this.getWidth(), 25));&#xa;Font ff=new Font("Courier New",Font.BOLD,12);&#xa;serverListTable.getTableHeader( [...]
+          </AuxValues>
+        </Component>
+      </SubComponents>
+    </Container>
+    <Component class="javax.swing.JButton" name="addButton">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Add"/>
+        <Property name="focusable" type="boolean" value="false"/>
+        <Property name="horizontalTextPosition" type="int" value="0"/>
+        <Property name="verticalTextPosition" type="int" value="3"/>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="addButtonActionPerformed"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JButton" name="jButton1">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Verify"/>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JButton" name="DeleteButton">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Delete"/>
+        <Property name="focusable" type="boolean" value="false"/>
+        <Property name="horizontalTextPosition" type="int" value="0"/>
+        <Property name="verticalTextPosition" type="int" value="3"/>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="DeleteButtonActionPerformed"/>
+      </Events>
+    </Component>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/ServerManager.java b/src/in/raster/mayam/form/ServerManager.java
new file mode 100644
index 0000000..8074415
--- /dev/null
+++ b/src/in/raster/mayam/form/ServerManager.java
@@ -0,0 +1,368 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.delegate.EchoService;
+import in.raster.mayam.form.dialog.EchoStatus;
+import in.raster.mayam.form.display.Display;
+import in.raster.mayam.model.AEModel;
+import in.raster.mayam.model.ServerModel;
+import in.raster.mayam.model.table.PresetTableModel;
+import in.raster.mayam.model.table.ServerTableModel;
+import in.raster.mayam.model.table.renderer.CellRenderer;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.DefaultCellEditor;
+import javax.swing.InputMap;
+import javax.swing.JComboBox;
+import javax.swing.JFrame;
+import javax.swing.JOptionPane;
+import javax.swing.JTable;
+import javax.swing.KeyStroke;
+import javax.swing.table.TableCellEditor;
+import org.dcm4che.util.DcmURL;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class ServerManager extends javax.swing.JPanel implements KeyListener {
+
+    /** Creates new form WindowingManagerPanel */
+    private JFrame outerContainer;
+    private ServerChangeListener serverChangeListener;
+
+    public ServerManager(JFrame outerContainer) {
+        this.outerContainer = outerContainer;
+        initComponents();
+        initializeDefault();
+    }
+
+    public ServerManager() {
+        initComponents();
+        initializeDefault();
+    }
+
+    public void initializeDefault() {
+        setServerTableModel();
+        serverListTable.addKeyListener(this);
+        changeTabActionForTable(serverListTable);
+
+    }
+
+    public void addServerChangeListener(ServerChangeListener serverChangeListener) {
+        this.serverChangeListener = serverChangeListener;
+        ((ServerTableModel) serverListTable.getModel()).addChangeListener(serverChangeListener);
+    }
+
+    public void addListenerToModel() {
+        ((ServerTableModel) serverListTable.getModel()).addChangeListener(serverChangeListener);
+    }
+
+    private void setServerTableModel() {
+        ServerTableModel serverTableModel = new ServerTableModel();
+        serverTableModel.setData(ApplicationContext.databaseRef.getServerList());
+        serverListTable.setModel(serverTableModel);
+        setServerRetrieveComboEditor();
+        serverListTable.getColumnModel().getColumn(0).setMinWidth(80);
+        serverListTable.getColumnModel().getColumn(1).setMinWidth(80);
+        serverListTable.getColumnModel().getColumn(2).setMinWidth(110);
+        serverListTable.getColumnModel().getColumn(3).setMaxWidth(55);
+        if (serverChangeListener != null) {
+            addListenerToModel();
+        }
+
+    }
+
+    private void setServerRetrieveComboEditor() {
+        String[] retrieveTypeArray = {"C-MOVE", "C-GET", "WADO"};
+        JComboBox comboBox = new JComboBox(retrieveTypeArray);
+        comboBox.setMaximumRowCount(4);
+        TableCellEditor editor = new DefaultCellEditor(comboBox);
+        serverListTable.getColumnModel().getColumn(4).setCellEditor(editor);
+    }
+
+    private void addOrDeleteServerNotification() {
+        serverChangeListener.onServerChange();
+    }
+
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        jLabel1 = new javax.swing.JLabel();
+        jScrollPane1 = new javax.swing.JScrollPane();
+        serverListTable = new javax.swing.JTable();
+        addButton = new javax.swing.JButton();
+        jButton1 = new javax.swing.JButton();
+        DeleteButton = new javax.swing.JButton();
+
+        jLabel1.setBackground(new java.awt.Color(0, 0, 0));
+        jLabel1.setFont(new java.awt.Font("Courier New", 1, 16)); // NOI18N
+        jLabel1.setForeground(new java.awt.Color(255, 138, 0));
+        jLabel1.setText("Servers");
+        jLabel1.setOpaque(true);
+
+        serverListTable.setFont(new java.awt.Font("Courier", 1, 12)); // NOI18N
+        serverListTable.setModel(new PresetTableModel());
+        serverListTable.setDefaultRenderer(Object.class, new CellRenderer());
+        //serverListTable.getTableHeader().setPreferredSize(new Dimension(jScrollPane1.WIDTH,25));
+        //serverListTable.setRowHeight(25);
+
+        serverListTable.getTableHeader().setPreferredSize(new Dimension(this.getWidth(), 25));
+        Font ff=new Font("Courier New",Font.BOLD,12);
+        serverListTable.getTableHeader().setFont(ff);
+        serverListTable.setRowHeight(20);
+        serverListTable.getTableHeader().setForeground(new Color(255,138,0));
+        serverListTable.getTableHeader().setBackground(new Color(0,0,0));
+        jScrollPane1.setViewportView(serverListTable);
+
+        addButton.setText("Add");
+        addButton.setFocusable(false);
+        addButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+        addButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        addButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                addButtonActionPerformed(evt);
+            }
+        });
+
+        jButton1.setText("Verify");
+        jButton1.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                jButton1ActionPerformed(evt);
+            }
+        });
+
+        DeleteButton.setText("Delete");
+        DeleteButton.setFocusable(false);
+        DeleteButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+        DeleteButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        DeleteButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                DeleteButtonActionPerformed(evt);
+            }
+        });
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
+        this.setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 557, Short.MAX_VALUE)
+            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+                .addContainerGap(261, Short.MAX_VALUE)
+                .add(jButton1)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(addButton)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(DeleteButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 89, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addContainerGap())
+            .add(layout.createSequentialGroup()
+                .addContainerGap()
+                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 517, Short.MAX_VALUE)
+                .addContainerGap())
+        );
+
+        layout.linkSize(new java.awt.Component[] {DeleteButton, addButton, jButton1}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
+
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(layout.createSequentialGroup()
+                .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 24, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .add(30, 30, 30)
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+                    .add(DeleteButton)
+                    .add(addButton)
+                    .add(jButton1))
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE)
+                .addContainerGap())
+        );
+    }// </editor-fold>//GEN-END:initComponents
+
+    public void changeTabActionForTable(JTable table) {
+        InputMap im = table.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
+
+        //  Have the enter key work the same as the tab key
+
+        KeyStroke tab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0);
+        //  KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
+        // im.put(enter, im.get(tab));
+
+        //  Disable the right arrow key
+
+        KeyStroke right = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0);
+        im.put(right, "none");
+
+        //  Override the default tab behaviour
+        //  Tab to the next editable cell. When no editable cells goto next cell.
+
+        final Action oldTabAction = table.getActionMap().get(im.get(tab));
+        Action tabAction = new AbstractAction() {
+
+            public void actionPerformed(ActionEvent e) {
+                oldTabAction.actionPerformed(e);
+                JTable table = (JTable) e.getSource();
+                int rowCount = table.getRowCount();
+                int columnCount = table.getColumnCount();
+                int row = table.getSelectedRow();
+                int column = table.getSelectedColumn();
+
+                while (!table.isCellEditable(row, column)) {
+                    column += 1;
+
+                    if (column == columnCount) {
+                        column = 0;
+                        row += 1;
+                    }
+
+                    if (row == rowCount) {
+                        row = 0;
+                    }
+
+                    //  Back to where we started, get out.
+
+                    if (row == table.getSelectedRow()
+                            && column == table.getSelectedColumn()) {
+                        break;
+                    }
+                }
+                table.changeSelection(row, column, true, false);
+            }
+        };
+        table.getActionMap().put(im.get(tab), tabAction);
+    }
+
+    private void addButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addButtonActionPerformed
+        ServerModel serverModel = new ServerModel();
+        serverModel.setServerName("Description");
+        serverModel.setAeTitle("AETITLE");
+        serverModel.setHostName("localhost");
+        serverModel.setPort(104);
+        serverModel.setRetrieveType("C-MOVE");
+        serverModel.setWadoContextPath("wado");
+        serverModel.setWadoPort(0);
+        serverModel.setWadoProtocol("http");
+        serverModel.setRetrieveTransferSyntax("");
+        ApplicationContext.databaseRef.insertServer(serverModel);
+        setServerTableModel();
+        addOrDeleteServerNotification();
+
+}//GEN-LAST:event_addButtonActionPerformed
+
+    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
+        try {
+            String serverName = ((ServerTableModel) serverListTable.getModel()).getValueAt(serverListTable.getSelectedRow(), 0);
+            AEModel ae = ApplicationContext.databaseRef.getServerDetail(serverName);
+            DcmURL url = new DcmURL("dicom://" + ae.getAeTitle() + "@" + ae.getHostName() + ":" + ae.getPort());
+            EchoService echo = new EchoService();
+            EchoStatus echoStatus = new EchoStatus(outerContainer, true);
+            Display.alignScreen(echoStatus);
+            echo.checkEcho(url);
+            echoStatus.setTitle("Echo Status");
+            try {
+                if (echo.getStatus().trim().equalsIgnoreCase("EchoSuccess")) {
+                    echoStatus.status.setText("Echo dicom://" + ae.getAeTitle() + "@" + ae.getHostName() + ":" + ae.getPort() + " successfully!");
+                    echoStatus.setVisible(true);
+                } else {
+                    echoStatus.status.setText("Echo dicom://" + ae.getAeTitle() + "@" + ae.getHostName() + ":" + ae.getPort() + " not successfully!");
+                    echoStatus.setVisible(true);
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }//GEN-LAST:event_jButton1ActionPerformed
+
+    private void DeleteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DeleteButtonActionPerformed
+        if (serverListTable.getSelectedRow() != -1) {
+            int canDelete = 0;
+            canDelete = JOptionPane.showConfirmDialog(null, "Are you sure want to delete the server", "Delete Confirmation", JOptionPane.YES_NO_OPTION);
+            if (canDelete == 0) {
+                ServerModel serverModel = ((ServerTableModel) serverListTable.getModel()).getRow(serverListTable.getSelectedRow());
+                ApplicationContext.databaseRef.deleteServer(serverModel);
+                setServerTableModel();
+                addOrDeleteServerNotification();
+            }
+        }
+    }//GEN-LAST:event_DeleteButtonActionPerformed
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JButton DeleteButton;
+    private javax.swing.JButton addButton;
+    private javax.swing.JButton jButton1;
+    private javax.swing.JLabel jLabel1;
+    private javax.swing.JScrollPane jScrollPane1;
+    private javax.swing.JTable serverListTable;
+    // End of variables declaration//GEN-END:variables
+
+    public void keyTyped(KeyEvent e) {
+    }
+
+    public void keyPressed(KeyEvent e) {
+        if (e.getKeyCode() == KeyEvent.VK_DELETE) {
+            int canDelete = 0;
+            canDelete = JOptionPane.showConfirmDialog(null, "Are you sure want to delete the server", "Delete Confirmation", JOptionPane.YES_NO_OPTION);
+            if (canDelete == 0) {
+                if (serverListTable.getSelectedRow() != -1) {
+                    ServerModel serverModel = ((ServerTableModel) serverListTable.getModel()).getRow(serverListTable.getSelectedRow());
+                    ApplicationContext.databaseRef.deleteServer(serverModel);
+                    setServerTableModel();
+                    addOrDeleteServerNotification();
+                }
+            }
+        }
+    }
+    public void keyReleased(KeyEvent e) {
+    }
+}
diff --git a/src/in/raster/mayam/form/ServerManagerFrame.form b/src/in/raster/mayam/form/ServerManagerFrame.form
new file mode 100644
index 0000000..1559595
--- /dev/null
+++ b/src/in/raster/mayam/form/ServerManagerFrame.form
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="serverManager1" min="-2" max="-2" attributes="0"/>
+              <EmptySpace max="32767" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace min="-2" pref="26" max="-2" attributes="0"/>
+              <Component id="serverManager1" min="-2" max="-2" attributes="0"/>
+              <EmptySpace pref="31" max="32767" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Component class="in.raster.mayam.form.ServerManager" name="serverManager1">
+      <AuxValues>
+        <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new in.raster.mayam.form.ServerManager(this)"/>
+      </AuxValues>
+    </Component>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/ServerManagerFrame.java b/src/in/raster/mayam/form/ServerManagerFrame.java
new file mode 100644
index 0000000..538c28c
--- /dev/null
+++ b/src/in/raster/mayam/form/ServerManagerFrame.java
@@ -0,0 +1,99 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class ServerManagerFrame extends javax.swing.JFrame {
+    
+    /** Creates new form ServerManagerFrame */
+    public ServerManagerFrame() {
+        initComponents();
+    }
+    
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        serverManager1 = new in.raster.mayam.form.ServerManager(this);
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+        getContentPane().setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(layout.createSequentialGroup()
+                .addContainerGap()
+                .add(serverManager1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(layout.createSequentialGroup()
+                .add(26, 26, 26)
+                .add(serverManager1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addContainerGap(31, Short.MAX_VALUE))
+        );
+
+        pack();
+    }// </editor-fold>//GEN-END:initComponents
+    
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String args[]) {
+        java.awt.EventQueue.invokeLater(new Runnable() {
+            public void run() {
+                new ServerManagerFrame().setVisible(true);
+            }
+        });
+    }
+    
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private in.raster.mayam.form.ServerManager serverManager1;
+    // End of variables declaration//GEN-END:variables
+    
+}
diff --git a/src/in/raster/mayam/form/SplashScreen.form b/src/in/raster/mayam/form/SplashScreen.form
new file mode 100644
index 0000000..40aa7fb
--- /dev/null
+++ b/src/in/raster/mayam/form/SplashScreen.form
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
+  <Properties>
+    <Property name="alwaysOnTop" type="boolean" value="true"/>
+    <Property name="undecorated" type="boolean" value="true"/>
+  </Properties>
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Component id="splashLabel" min="-2" pref="584" max="-2" attributes="0"/>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Component id="splashLabel" max="32767" attributes="0"/>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Component class="javax.swing.JLabel" name="splashLabel">
+      <Properties>
+        <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+          <Image iconType="3" name="/in/raster/mayam/form/images/mayam.png"/>
+        </Property>
+      </Properties>
+    </Component>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/SplashScreen.java b/src/in/raster/mayam/form/SplashScreen.java
new file mode 100644
index 0000000..a22d463
--- /dev/null
+++ b/src/in/raster/mayam/form/SplashScreen.java
@@ -0,0 +1,86 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class SplashScreen extends javax.swing.JFrame {
+    
+    public SplashScreen() {
+        initComponents();       
+    }
+    
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        splashLabel = new javax.swing.JLabel();
+
+        setAlwaysOnTop(true);
+        setUndecorated(true);
+
+        splashLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/mayam.png"))); // NOI18N
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+        getContentPane().setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(splashLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 584, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(splashLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+        );
+
+        pack();
+    }// </editor-fold>//GEN-END:initComponents
+    
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JLabel splashLabel;
+    // End of variables declaration//GEN-END:variables
+    
+}
diff --git a/src/in/raster/mayam/form/TextOverlay.form b/src/in/raster/mayam/form/TextOverlay.form
new file mode 100644
index 0000000..0b9e4c8
--- /dev/null
+++ b/src/in/raster/mayam/form/TextOverlay.form
@@ -0,0 +1,360 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="1" max="-2" attributes="0">
+                  <Component id="instanceNoLabel" alignment="0" min="-2" pref="178" max="-2" attributes="0"/>
+                  <Component id="patientNameLabel" alignment="0" min="-2" pref="167" max="-2" attributes="0"/>
+                  <Component id="patientIDLabel" alignment="0" min="-2" pref="152" max="-2" attributes="0"/>
+                  <Component id="huLabel" alignment="0" min="-2" pref="187" max="-2" attributes="0"/>
+                  <Component id="windowingLabel" alignment="0" min="-2" pref="234" max="-2" attributes="0"/>
+                  <Component id="slicePositionLabel" alignment="0" min="-2" pref="185" max="-2" attributes="0"/>
+                  <Component id="patientSexLabel" alignment="0" min="-2" pref="91" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace min="-2" max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="1" attributes="0">
+                  <Component id="jLabel8" pref="257" max="32767" attributes="1"/>
+                  <Group type="102" alignment="1" attributes="0">
+                      <Component id="studyDateLabel" min="-2" pref="118" max="-2" attributes="1"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                  </Group>
+                  <Group type="102" alignment="1" attributes="0">
+                      <Component id="multiframeStatusText" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                  </Group>
+                  <Group type="102" alignment="1" attributes="0">
+                      <Component id="frameNumberText" min="-2" pref="147" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                  </Group>
+                  <Group type="102" alignment="1" attributes="0">
+                      <Component id="zoomLabel" min="-2" pref="95" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                  </Group>
+                  <Group type="102" alignment="1" attributes="0">
+                      <Component id="patientPositionLabel" min="-2" pref="151" max="-2" attributes="1"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                  </Group>
+                  <Group type="102" alignment="1" attributes="0">
+                      <Component id="institutionLabel" min="-2" pref="237" max="-2" attributes="2"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                  </Group>
+                  <Group type="102" alignment="0" attributes="1">
+                      <Component id="seriesDescLabel" pref="237" max="32767" attributes="0"/>
+                      <EmptySpace min="20" pref="20" max="20" attributes="0"/>
+                  </Group>
+                  <Group type="102" alignment="0" attributes="0">
+                      <Component id="studyDescLabel" pref="237" max="32767" attributes="1"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                  </Group>
+                  <Group type="102" alignment="0" attributes="0">
+                      <Component id="instanceNum" pref="237" max="32767" attributes="0"/>
+                      <EmptySpace min="20" pref="20" max="20" attributes="0"/>
+                  </Group>
+              </Group>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="3" attributes="0">
+                  <Component id="patientNameLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+                  <Component id="institutionLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="3" attributes="0">
+                  <Component id="patientIDLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+                  <Component id="studyDateLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="3" attributes="0">
+                  <Component id="patientSexLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+                  <Component id="studyDescLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="seriesDescLabel" min="-2" max="-2" attributes="0"/>
+              <EmptySpace max="32767" attributes="0"/>
+              <Group type="103" groupAlignment="1" max="-2" attributes="0">
+                  <Group type="102" attributes="0">
+                      <Component id="huLabel" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="instanceNoLabel" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="windowingLabel" min="-2" pref="17" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="slicePositionLabel" min="-2" pref="17" max="-2" attributes="0"/>
+                  </Group>
+                  <Group type="102" alignment="0" attributes="1">
+                      <EmptySpace min="-2" pref="16" max="-2" attributes="0"/>
+                      <Component id="jLabel8" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="instanceNum" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="32767" attributes="0"/>
+                      <Component id="multiframeStatusText" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="frameNumberText" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="zoomLabel" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="patientPositionLabel" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace min="-2" pref="8" max="-2" attributes="0"/>
+                  </Group>
+              </Group>
+              <EmptySpace min="-2" max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Component class="javax.swing.JLabel" name="patientNameLabel">
+      <Properties>
+        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="0" green="0" red="0" type="rgb"/>
+        </Property>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Lucida Grande" size="14" style="0"/>
+        </Property>
+        <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="ff" green="ff" red="ff" type="rgb"/>
+        </Property>
+        <Property name="text" type="java.lang.String" value="Name"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="patientSexLabel">
+      <Properties>
+        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="0" green="0" red="0" type="rgb"/>
+        </Property>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Lucida Grande" size="14" style="0"/>
+        </Property>
+        <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="ff" green="ff" red="ff" type="rgb"/>
+        </Property>
+        <Property name="text" type="java.lang.String" value="Sex"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="patientIDLabel">
+      <Properties>
+        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="0" green="0" red="0" type="rgb"/>
+        </Property>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Lucida Grande" size="14" style="0"/>
+        </Property>
+        <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="ff" green="ff" red="ff" type="rgb"/>
+        </Property>
+        <Property name="text" type="java.lang.String" value="ID"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="huLabel">
+      <Properties>
+        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="0" green="0" red="0" type="rgb"/>
+        </Property>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Lucida Grande" size="14" style="0"/>
+        </Property>
+        <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="ff" green="ff" red="ff" type="rgb"/>
+        </Property>
+        <Property name="text" type="java.lang.String" value="hu"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="studyDescLabel">
+      <Properties>
+        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="0" green="0" red="0" type="rgb"/>
+        </Property>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Lucida Grande" size="14" style="0"/>
+        </Property>
+        <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="ff" green="ff" red="ff" type="rgb"/>
+        </Property>
+        <Property name="horizontalAlignment" type="int" value="4"/>
+        <Property name="text" type="java.lang.String" value="Study Desc"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="studyDateLabel">
+      <Properties>
+        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="0" green="0" red="0" type="rgb"/>
+        </Property>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Lucida Grande" size="14" style="0"/>
+        </Property>
+        <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="ff" green="ff" red="ff" type="rgb"/>
+        </Property>
+        <Property name="horizontalAlignment" type="int" value="4"/>
+        <Property name="text" type="java.lang.String" value="Study Date"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="institutionLabel">
+      <Properties>
+        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="0" green="0" red="0" type="rgb"/>
+        </Property>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Lucida Grande" size="14" style="0"/>
+        </Property>
+        <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="ff" green="ff" red="ff" type="rgb"/>
+        </Property>
+        <Property name="horizontalAlignment" type="int" value="4"/>
+        <Property name="text" type="java.lang.String" value="Institution"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="jLabel8">
+      <Properties>
+        <Property name="horizontalAlignment" type="int" value="4"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="patientPositionLabel">
+      <Properties>
+        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="0" green="0" red="0" type="rgb"/>
+        </Property>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Lucida Grande" size="14" style="0"/>
+        </Property>
+        <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="ff" green="ff" red="ff" type="rgb"/>
+        </Property>
+        <Property name="horizontalAlignment" type="int" value="4"/>
+        <Property name="text" type="java.lang.String" value="Patient Position"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="instanceNoLabel">
+      <Properties>
+        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="0" green="0" red="0" type="rgb"/>
+        </Property>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Lucida Grande" size="14" style="0"/>
+        </Property>
+        <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="ff" green="ff" red="ff" type="rgb"/>
+        </Property>
+        <Property name="text" type="java.lang.String" value="Im"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="windowingLabel">
+      <Properties>
+        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="0" green="0" red="0" type="rgb"/>
+        </Property>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Lucida Grande" size="14" style="0"/>
+        </Property>
+        <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="ff" green="ff" red="ff" type="rgb"/>
+        </Property>
+        <Property name="text" type="java.lang.String" value="Windowing"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="slicePositionLabel">
+      <Properties>
+        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="0" green="0" red="0" type="rgb"/>
+        </Property>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Lucida Grande" size="14" style="0"/>
+        </Property>
+        <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="ff" green="ff" red="ff" type="rgb"/>
+        </Property>
+        <Property name="text" type="java.lang.String" value="Slice Position"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="zoomLabel">
+      <Properties>
+        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="0" green="0" red="0" type="rgb"/>
+        </Property>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Lucida Grande" size="14" style="0"/>
+        </Property>
+        <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="ff" green="ff" red="ff" type="rgb"/>
+        </Property>
+        <Property name="horizontalAlignment" type="int" value="4"/>
+        <Property name="text" type="java.lang.String" value="Zoom"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="multiframeStatusText">
+      <Properties>
+        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="99" green="ff" red="ff" type="rgb"/>
+        </Property>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Lucida Grande" size="14" style="0"/>
+        </Property>
+        <Property name="horizontalAlignment" type="int" value="4"/>
+        <Property name="text" type="java.lang.String" value="Multiframe"/>
+        <Property name="opaque" type="boolean" value="true"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="frameNumberText">
+      <Properties>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Lucida Grande" size="14" style="0"/>
+        </Property>
+        <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="ff" green="ff" id="white" palette="1" red="ff" type="palette"/>
+        </Property>
+        <Property name="horizontalAlignment" type="int" value="4"/>
+        <Property name="text" type="java.lang.String" value="Frame"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="seriesDescLabel">
+      <Properties>
+        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="0" green="0" red="0" type="rgb"/>
+        </Property>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Lucida Grande" size="14" style="0"/>
+        </Property>
+        <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="ff" green="ff" red="ff" type="rgb"/>
+        </Property>
+        <Property name="horizontalAlignment" type="int" value="4"/>
+        <Property name="text" type="java.lang.String" value="Series Desc"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="instanceNum">
+      <Properties>
+        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="0" green="0" red="0" type="rgb"/>
+        </Property>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Lucida Grande" size="14" style="0"/>
+        </Property>
+        <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="ff" green="ff" red="ff" type="rgb"/>
+        </Property>
+        <Property name="horizontalAlignment" type="int" value="4"/>
+        <Property name="text" type="java.lang.String" value="Instance Number"/>
+      </Properties>
+    </Component>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/TextOverlay.java b/src/in/raster/mayam/form/TextOverlay.java
new file mode 100644
index 0000000..f2b73ce
--- /dev/null
+++ b/src/in/raster/mayam/form/TextOverlay.java
@@ -0,0 +1,407 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.param.TextOverlayParam;
+import java.awt.Graphics;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class TextOverlay extends javax.swing.JPanel {
+
+    /** Creates new form DateFormatPanel */
+    private TextOverlayParam textOverlayParam;
+    LayeredCanvas layeredCanvas;
+    private boolean firstTime = true;
+    private boolean textOverlay = true;
+    private boolean showProbeFlag = false;
+
+    public TextOverlay(LayeredCanvas l) {
+        initComponents();
+        textOverlayParam = new TextOverlayParam();
+        this.setOpaque(false);
+        layeredCanvas = l;
+    }
+
+    public void setProbeParameters(String[] probeParameters) {
+        textOverlayParam.setProbeParameters(probeParameters);
+        this.showProbeFlag = true;
+        this.repaint();
+    }
+
+    public void setWindowingParameter(String WL, String WW) {
+        textOverlayParam.setWindowingParameter(WL, WW);
+        this.repaint();
+    }
+
+    public TextOverlayParam getTextOverlayParam() {
+        return textOverlayParam;
+    }
+
+    public void setTextOverlayParam(TextOverlayParam textOverlayParam) {
+        this.textOverlayParam = textOverlayParam;
+    }
+
+    public void toggleTextOverlay() {
+        if (textOverlay) {
+            textOverlay = false;
+            this.repaint();
+        } else {
+            textOverlay = true;
+            this.repaint();
+        }
+    }
+
+    public void updateCurrentInstanceNo(int currentInstanceNo) {
+        textOverlayParam.setCurrentInstance(currentInstanceNo);
+        this.repaint();
+    }
+
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        patientNameLabel = new javax.swing.JLabel();
+        patientSexLabel = new javax.swing.JLabel();
+        patientIDLabel = new javax.swing.JLabel();
+        huLabel = new javax.swing.JLabel();
+        studyDescLabel = new javax.swing.JLabel();
+        studyDateLabel = new javax.swing.JLabel();
+        institutionLabel = new javax.swing.JLabel();
+        jLabel8 = new javax.swing.JLabel();
+        patientPositionLabel = new javax.swing.JLabel();
+        instanceNoLabel = new javax.swing.JLabel();
+        windowingLabel = new javax.swing.JLabel();
+        slicePositionLabel = new javax.swing.JLabel();
+        zoomLabel = new javax.swing.JLabel();
+        multiframeStatusText = new javax.swing.JLabel();
+        frameNumberText = new javax.swing.JLabel();
+        seriesDescLabel = new javax.swing.JLabel();
+        instanceNum = new javax.swing.JLabel();
+
+        patientNameLabel.setBackground(new java.awt.Color(0, 0, 0));
+        patientNameLabel.setFont(new java.awt.Font("Lucida Grande", 0, 14));
+        patientNameLabel.setForeground(new java.awt.Color(255, 255, 255));
+        patientNameLabel.setText("Name");
+
+        patientSexLabel.setBackground(new java.awt.Color(0, 0, 0));
+        patientSexLabel.setFont(new java.awt.Font("Lucida Grande", 0, 14));
+        patientSexLabel.setForeground(new java.awt.Color(255, 255, 255));
+        patientSexLabel.setText("Sex");
+
+        patientIDLabel.setBackground(new java.awt.Color(0, 0, 0));
+        patientIDLabel.setFont(new java.awt.Font("Lucida Grande", 0, 14));
+        patientIDLabel.setForeground(new java.awt.Color(255, 255, 255));
+        patientIDLabel.setText("ID");
+
+        huLabel.setBackground(new java.awt.Color(0, 0, 0));
+        huLabel.setFont(new java.awt.Font("Lucida Grande", 0, 14));
+        huLabel.setForeground(new java.awt.Color(255, 255, 255));
+        huLabel.setText("hu");
+
+        studyDescLabel.setBackground(new java.awt.Color(0, 0, 0));
+        studyDescLabel.setFont(new java.awt.Font("Lucida Grande", 0, 14));
+        studyDescLabel.setForeground(new java.awt.Color(255, 255, 255));
+        studyDescLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
+        studyDescLabel.setText("Study Desc");
+
+        studyDateLabel.setBackground(new java.awt.Color(0, 0, 0));
+        studyDateLabel.setFont(new java.awt.Font("Lucida Grande", 0, 14));
+        studyDateLabel.setForeground(new java.awt.Color(255, 255, 255));
+        studyDateLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
+        studyDateLabel.setText("Study Date");
+
+        institutionLabel.setBackground(new java.awt.Color(0, 0, 0));
+        institutionLabel.setFont(new java.awt.Font("Lucida Grande", 0, 14));
+        institutionLabel.setForeground(new java.awt.Color(255, 255, 255));
+        institutionLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
+        institutionLabel.setText("Institution");
+
+        jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
+
+        patientPositionLabel.setBackground(new java.awt.Color(0, 0, 0));
+        patientPositionLabel.setFont(new java.awt.Font("Lucida Grande", 0, 14));
+        patientPositionLabel.setForeground(new java.awt.Color(255, 255, 255));
+        patientPositionLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
+        patientPositionLabel.setText("Patient Position");
+
+        instanceNoLabel.setBackground(new java.awt.Color(0, 0, 0));
+        instanceNoLabel.setFont(new java.awt.Font("Lucida Grande", 0, 14));
+        instanceNoLabel.setForeground(new java.awt.Color(255, 255, 255));
+        instanceNoLabel.setText("Im");
+
+        windowingLabel.setBackground(new java.awt.Color(0, 0, 0));
+        windowingLabel.setFont(new java.awt.Font("Lucida Grande", 0, 14));
+        windowingLabel.setForeground(new java.awt.Color(255, 255, 255));
+        windowingLabel.setText("Windowing");
+
+        slicePositionLabel.setBackground(new java.awt.Color(0, 0, 0));
+        slicePositionLabel.setFont(new java.awt.Font("Lucida Grande", 0, 14));
+        slicePositionLabel.setForeground(new java.awt.Color(255, 255, 255));
+        slicePositionLabel.setText("Slice Position");
+
+        zoomLabel.setBackground(new java.awt.Color(0, 0, 0));
+        zoomLabel.setFont(new java.awt.Font("Lucida Grande", 0, 14));
+        zoomLabel.setForeground(new java.awt.Color(255, 255, 255));
+        zoomLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
+        zoomLabel.setText("Zoom");
+
+        multiframeStatusText.setBackground(new java.awt.Color(255, 255, 153));
+        multiframeStatusText.setFont(new java.awt.Font("Lucida Grande", 0, 14));
+        multiframeStatusText.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
+        multiframeStatusText.setText("Multiframe");
+        multiframeStatusText.setOpaque(true);
+
+        frameNumberText.setFont(new java.awt.Font("Lucida Grande", 0, 14));
+        frameNumberText.setForeground(java.awt.Color.white);
+        frameNumberText.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
+        frameNumberText.setText("Frame");
+
+        seriesDescLabel.setBackground(new java.awt.Color(0, 0, 0));
+        seriesDescLabel.setFont(new java.awt.Font("Lucida Grande", 0, 14));
+        seriesDescLabel.setForeground(new java.awt.Color(255, 255, 255));
+        seriesDescLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
+        seriesDescLabel.setText("Series Desc");
+
+        instanceNum.setBackground(new java.awt.Color(0, 0, 0));
+        instanceNum.setFont(new java.awt.Font("Lucida Grande", 0, 14)); // NOI18N
+        instanceNum.setForeground(new java.awt.Color(255, 255, 255));
+        instanceNum.setHorizontalAlignment(4);
+        instanceNum.setText("Instance Number");
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
+        this.setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(layout.createSequentialGroup()
+                .addContainerGap()
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
+                    .add(org.jdesktop.layout.GroupLayout.LEADING, instanceNoLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 178, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                    .add(org.jdesktop.layout.GroupLayout.LEADING, patientNameLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 167, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                    .add(org.jdesktop.layout.GroupLayout.LEADING, patientIDLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 152, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                    .add(org.jdesktop.layout.GroupLayout.LEADING, huLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 187, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                    .add(org.jdesktop.layout.GroupLayout.LEADING, windowingLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 234, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                    .add(org.jdesktop.layout.GroupLayout.LEADING, slicePositionLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 185, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                    .add(org.jdesktop.layout.GroupLayout.LEADING, patientSexLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 91, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+                    .add(jLabel8, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 257, Short.MAX_VALUE)
+                    .add(layout.createSequentialGroup()
+                        .add(studyDateLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 118, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                        .addContainerGap())
+                    .add(layout.createSequentialGroup()
+                        .add(multiframeStatusText)
+                        .addContainerGap())
+                    .add(layout.createSequentialGroup()
+                        .add(frameNumberText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 147, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                        .addContainerGap())
+                    .add(layout.createSequentialGroup()
+                        .add(zoomLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 95, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                        .addContainerGap())
+                    .add(layout.createSequentialGroup()
+                        .add(patientPositionLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 151, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                        .addContainerGap())
+                    .add(layout.createSequentialGroup()
+                        .add(institutionLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 237, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                        .addContainerGap())
+                    .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
+                        .add(seriesDescLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 237, Short.MAX_VALUE)
+                        .add(20, 20, 20))
+                    .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
+                        .add(studyDescLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 237, Short.MAX_VALUE)
+                        .addContainerGap())
+                    .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
+                        .add(instanceNum, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 237, Short.MAX_VALUE)
+                        .add(20, 20, 20))))
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(layout.createSequentialGroup()
+                .addContainerGap()
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+                    .add(patientNameLabel)
+                    .add(institutionLabel))
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+                    .add(patientIDLabel)
+                    .add(studyDateLabel))
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+                    .add(patientSexLabel)
+                    .add(studyDescLabel))
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(seriesDescLabel)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
+                    .add(layout.createSequentialGroup()
+                        .add(huLabel)
+                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                        .add(instanceNoLabel)
+                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                        .add(windowingLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 17, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                        .add(slicePositionLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 17, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+                    .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
+                        .add(16, 16, 16)
+                        .add(jLabel8)
+                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                        .add(instanceNum)
+                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                        .add(multiframeStatusText)
+                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                        .add(frameNumberText)
+                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                        .add(zoomLabel)
+                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                        .add(patientPositionLabel)
+                        .add(8, 8, 8)))
+                .addContainerGap())
+        );
+    }// </editor-fold>//GEN-END:initComponents
+
+    private void setTextOverlay() {
+        patientNameLabel.setText(" " + textOverlayParam.getPatientName() != null ? textOverlayParam.getPatientName() : "");
+        patientIDLabel.setText("" + "ID: " + textOverlayParam.getPatientID());
+        if (textOverlayParam.getSex() != null && !textOverlayParam.getSex().equalsIgnoreCase("")) {
+            patientSexLabel.setText("Sex: " + textOverlayParam.getSex());
+        } else {
+            patientSexLabel.setText("");
+        }
+        patientPositionLabel.setText(textOverlayParam.getPatientPosition() != null ? "Position: " + textOverlayParam.getPatientPosition() : "" + " ");
+        studyDateLabel.setText("Study Date: " + textOverlayParam.getStudyDate() != null ? textOverlayParam.getStudyDate() : "" + " ");
+        // studyTimeLabel.setText("Study Time: " + textOverlayParam.getStudyTime() != null ? textOverlayParam.getStudyTime() : "" + " ");
+        studyDescLabel.setText("Study Desc: "+textOverlayParam.getStudyDescription()!=null ? textOverlayParam.getStudyDescription(): "");
+        seriesDescLabel.setText("Series Desc: "+textOverlayParam.getSeriesDescription()!=null ? textOverlayParam.getSeriesDescription(): "");
+        slicePositionLabel.setText(textOverlayParam.getSlicePosition() != null ? " Slice pos: " + textOverlayParam.getSlicePosition() : "");
+        instanceNum.setText(textOverlayParam.getInstanceNumber()!=null ? "Instance Number : "+textOverlayParam.getInstanceNumber() :"");
+        if (ImagePanel.isProbeFlag()) {
+            huLabel.setText(" " + "X:  " + textOverlayParam.getXPosition() + "  Y:  " + textOverlayParam.getYPosition() + "  Px:  " + textOverlayParam.getPxValue());
+        } else {
+            huLabel.setText("");
+        }
+        int currentInstanceNo;
+        if (!ApplicationContext.databaseRef.getMultiframeStatus()) {
+            currentInstanceNo = (textOverlayParam.getCurrentInstance() != 0) ? textOverlayParam.getCurrentInstance() : 1;
+        } else {
+            currentInstanceNo = textOverlayParam.getCurrentInstance() + 1;
+        }
+        int totalNo = Integer.parseInt(textOverlayParam.getTotalInstance());
+        instanceNoLabel.setText(" " + "Im :" + currentInstanceNo + "/" + totalNo);
+        institutionLabel.setText(textOverlayParam.getInstitutionName() != null ? textOverlayParam.getInstitutionName() : "" + " ");
+        windowingLabel.setText(" " + "W " + textOverlayParam.getWindowWidth() + "/ C " + textOverlayParam.getWindowLevel());
+        zoomLabel.setText(textOverlayParam.getZoomLevel());
+        if (!textOverlayParam.getFramePosition().equalsIgnoreCase("")) {
+            frameNumberText.setText("Frame: " + textOverlayParam.getFramePosition());
+        } else {
+            frameNumberText.setText("");
+        }
+    }
+
+    private void setTextOverlayToNull() {
+        patientNameLabel.setText("");
+        patientIDLabel.setText("");
+        patientSexLabel.setText("");
+        patientPositionLabel.setText("");
+        studyDateLabel.setText("");
+        studyDescLabel.setText("");
+        seriesDescLabel.setText("");
+        slicePositionLabel.setText("");
+        instanceNum.setText("");
+        huLabel.setText("");
+        instanceNoLabel.setText("");
+        institutionLabel.setText("");
+        windowingLabel.setText("");
+        zoomLabel.setText("");
+
+    }
+
+    public void resizeHandler() {
+        firstTime = true;
+        repaint();
+    }
+
+    public void multiframeStatusDisplay(boolean status) {
+        multiframeStatusText.setVisible(status);
+    }
+
+    @Override
+    public void paint(Graphics g) {
+        super.paint(g);
+        if (textOverlay) {
+            setTextOverlay();
+        } else {
+            setTextOverlayToNull();
+        }
+        if (firstTime) {
+            this.setSize(layeredCanvas.getSize().width, layeredCanvas.getSize().height);
+            firstTime = false;
+            setTextOverlayToNull();
+            repaint();
+        }
+        showProbeFlag = false;
+    }
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JLabel frameNumberText;
+    private javax.swing.JLabel huLabel;
+    private javax.swing.JLabel instanceNoLabel;
+    private javax.swing.JLabel instanceNum;
+    private javax.swing.JLabel institutionLabel;
+    private javax.swing.JLabel jLabel8;
+    private javax.swing.JLabel multiframeStatusText;
+    private javax.swing.JLabel patientIDLabel;
+    private javax.swing.JLabel patientNameLabel;
+    private javax.swing.JLabel patientPositionLabel;
+    private javax.swing.JLabel patientSexLabel;
+    private javax.swing.JLabel seriesDescLabel;
+    private javax.swing.JLabel slicePositionLabel;
+    private javax.swing.JLabel studyDateLabel;
+    private javax.swing.JLabel studyDescLabel;
+    private javax.swing.JLabel windowingLabel;
+    private javax.swing.JLabel zoomLabel;
+    // End of variables declaration//GEN-END:variables
+}
diff --git a/src/in/raster/mayam/form/Thumbnail.java b/src/in/raster/mayam/form/Thumbnail.java
new file mode 100644
index 0000000..028c12c
--- /dev/null
+++ b/src/in/raster/mayam/form/Thumbnail.java
@@ -0,0 +1,123 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form;
+
+import javax.swing.JLabel;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.image.BufferedImage;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class Thumbnail extends JLabel{
+
+    private BufferedImage image = null;
+    private int thumbWidth=96;
+    private int thumbHeight=96;
+    private int maxWidth=96;
+    private int maxHeight=96;
+    private double thumbRatio;
+    private int x;
+    private int y;
+     int imageWidth;
+     int imageHeight;
+
+    public Thumbnail(BufferedImage image) {
+        this.image = image;
+        if(image!=null){
+        imageWidth=image.getWidth();
+        imageHeight=image.getHeight();
+        calculateAspectRatioBasedSize();
+        }
+        initComponents();
+        
+    }
+    private void calculateAspectRatioBasedSize()
+    {
+        thumbRatio=(double)thumbWidth/thumbHeight;          
+        double imageRatio=(double)imageWidth/(double)imageHeight;
+        if(thumbRatio<imageRatio)        
+            thumbHeight=(int)(thumbWidth/imageRatio);       
+        else      
+            thumbWidth=(int)(thumbHeight*imageRatio);
+        
+        x=(maxWidth-thumbWidth)/2;
+        y=(maxHeight-thumbHeight)/2;
+        
+    }
+
+    /**
+     * This override routine used to paint the image box
+     * @param gs
+     */
+    @Override
+    public void paintComponent(Graphics gs) {
+        Graphics2D g = (Graphics2D) gs;
+        g.setRenderingHint( RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
+        g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,RenderingHints.VALUE_INTERPOLATION_BICUBIC);
+        g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
+        if (image != null) {
+            //calculateAspectRatioBasedSize();
+            g.drawImage(image, x,y, thumbWidth,thumbHeight, null);
+        }
+    }
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">
+    private void initComponents() {
+
+
+        setBackground(new java.awt.Color(0, 0, 0));
+        setDoubleBuffered(false);
+        setOpaque(false);
+        setPreferredSize(new java.awt.Dimension(128, 128));
+        this.setFont(new java.awt.Font("Times", 0, 10));
+        this.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+
+    }// </editor-fold>
+
+}
diff --git a/src/in/raster/mayam/form/ThumbnailImage.form b/src/in/raster/mayam/form/ThumbnailImage.form
new file mode 100644
index 0000000..f2b0239
--- /dev/null
+++ b/src/in/raster/mayam/form/ThumbnailImage.form
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+  <Properties>
+    <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+      <Color blue="0" green="0" red="0" type="rgb"/>
+    </Property>
+    <Property name="doubleBuffered" type="boolean" value="false"/>
+    <Property name="opaque" type="boolean" value="false"/>
+    <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+      <Dimension value="[128, 128]"/>
+    </Property>
+  </Properties>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Component id="seriesDescriptionLabel" alignment="0" pref="128" max="32767" attributes="0"/>
+          <Component id="totalImagesLabel" alignment="0" pref="128" max="32767" attributes="0"/>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="seriesDescriptionLabel" min="-2" max="-2" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="totalImagesLabel" min="-2" pref="11" max="-2" attributes="0"/>
+              <EmptySpace pref="88" max="32767" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Component class="javax.swing.JLabel" name="seriesDescriptionLabel">
+      <Properties>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Times" size="10" style="0"/>
+        </Property>
+        <Property name="horizontalAlignment" type="int" value="0"/>
+        <Property name="text" type="java.lang.String" value="Series Discription"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="totalImagesLabel">
+      <Properties>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Times" size="10" style="0"/>
+        </Property>
+        <Property name="horizontalAlignment" type="int" value="0"/>
+        <Property name="text" type="java.lang.String" value="Total Images"/>
+      </Properties>
+    </Component>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/ThumbnailImage.java b/src/in/raster/mayam/form/ThumbnailImage.java
new file mode 100644
index 0000000..8039f79
--- /dev/null
+++ b/src/in/raster/mayam/form/ThumbnailImage.java
@@ -0,0 +1,320 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.delegate.SeriesListUpdator;
+import in.raster.mayam.delegate.ShowImageViewDelegate;
+import in.raster.mayam.model.Instance;
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.imageio.ImageIO;
+import javax.imageio.ImageReader;
+import javax.imageio.stream.ImageInputStream;
+import javax.swing.ImageIcon;
+import javax.swing.border.LineBorder;
+import org.dcm4che.data.Dataset;
+import org.dcm4che.dict.Tags;
+import org.dcm4che.imageio.plugins.DcmMetadata;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class ThumbnailImage extends javax.swing.JPanel implements MouseListener, FocusListener {
+    
+    private Iterator iter;
+    private ImageReader reader;
+    private ImageInputStream iis;
+    private Dataset dataset;
+    private Image loadedImage;
+    private ImageIcon imageIcon;
+    private BufferedImage currentbufferedimage;
+    private BufferedImage image;
+    private String fileUrl;   
+    private String instanceNo="";
+    private String totalInstace = "";
+    public boolean focusGained = false;
+    private Instance img=null;
+    private boolean instanceListAdded=false;
+
+    private int nFrames = 0;
+    private boolean mulitiFrame = false;
+
+    public ThumbnailImage()
+    {       
+    }
+    public ThumbnailImage(String dicomFileUrl) {
+        fileUrl = dicomFileUrl;
+        try {
+            readDicomFile(new File(dicomFileUrl));
+            retrieveInfo();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        initComponents();
+        this.addListeners();
+    }
+    public ThumbnailImage(Instance img)
+    {
+        this.img=img;
+        instanceNo=img.getInstance_no();
+        fileUrl=img.getFilepath();        
+                image = new BufferedImage(img.getPixelData().getWidth(null), img.getPixelData().getHeight(null), BufferedImage.TYPE_INT_RGB);
+                Graphics2D g2 = image.createGraphics();
+                g2.drawImage(img.getPixelData(),0,0,null);     
+        initComponents();
+        this.addListeners();
+    }
+
+    private void addListeners() {
+        this.addFocusListener(this);
+        this.addMouseListener(this);
+    }
+
+    private void retrieveInfo() {        
+        totalInstace = dataset.getString(Tags.NumberOfSeriesRelatedInstances);
+        instanceNo = dataset.getString(Tags.InstanceNumber);
+    }
+    public void updateInstanceList()
+    {
+        SeriesListUpdator series=new SeriesListUpdator();
+        String studyUID=dataset.getString(Tags.StudyInstanceUID);
+        String seriesUID=dataset.getString(Tags.SeriesInstanceUID);
+        String instanceUID=dataset.getString(Tags.SOPInstanceUID);
+        if(ApplicationContext.databaseRef.getMultiframeStatus())
+        {
+            series.addSeriesToStudyList(studyUID,seriesUID,mulitiFrame,instanceUID,false);
+        }
+        else
+        series.addSeriesToStudyList(studyUID,seriesUID,false);
+    }
+
+    private void readDicomFile(File selFile) {
+        try {
+            iis = ImageIO.createImageInputStream(selFile);
+            iter = ImageIO.getImageReadersByFormatName("DICOM");
+            reader = (ImageReader) iter.next();
+            reader.setInput(iis, false);
+            dataset = ((DcmMetadata) reader.getStreamMetadata()).getDataset();
+            try {                
+                currentbufferedimage = reader.read(0);
+                nFrames = reader.getNumImages(true);
+                if (nFrames - 1 > 0) {
+                    mulitiFrame = true;
+                }
+                imageIcon = new ImageIcon();
+                imageIcon.setImage(currentbufferedimage);
+                loadedImage = imageIcon.getImage();
+                image = new BufferedImage(loadedImage.getWidth(null), loadedImage.getHeight(null), BufferedImage.TYPE_INT_RGB);
+                Graphics2D g2 = image.createGraphics();
+                g2.drawImage(loadedImage,0,0,null);
+            } catch (RuntimeException e) {
+                System.out.println("while Reading Image " + e.getMessage());
+            }
+        } catch (Exception e) {            
+            System.out.println(e.toString());
+        }
+        finally
+        {
+            try {
+                iis.close();
+                iter=null;                
+                currentbufferedimage=null;
+                imageIcon=null;
+                loadedImage=null;
+
+            } catch (IOException ex) {
+                Logger.getLogger(ThumbnailImage.class.getName()).log(Level.SEVERE, null, ex);
+            }
+        }
+    }  
+
+    public void openSingleImage(String filePath) {      
+         if(!ApplicationContext.imageViewExist())
+        {
+            ApplicationContext.createImageView();
+        }
+        ShowImageViewDelegate showImgView = new ShowImageViewDelegate(filePath);
+    }
+
+    public String getFileUrl() {
+        return fileUrl;
+    }
+
+    public void setFileUrl(String fileUrl) {
+        this.fileUrl = fileUrl;
+    }
+    private void setHeaders() {
+        String seriesDesc=dataset.getString(Tags.SeriesDescription);
+        String totalInstance=dataset.getString(Tags.NumberOfSeriesRelatedInstances)==null?"":dataset.getString(Tags.NumberOfSeriesRelatedInstances);
+        seriesDescriptionLabel.setText(""+seriesDesc);
+        totalImagesLabel.setText(totalInstance+" Images");       
+    }
+
+    /**
+     * This override routine used to paint the image box
+     * @param gs
+     */
+    @Override
+    public void paintComponent(Graphics gs) {
+        Graphics2D g = (Graphics2D) gs;
+        setHeaders();
+        if (image != null) {
+            g.drawImage(image, (this.getSize().width - 70) / 2, 35, 70, 70, null);
+        }
+        if (focusGained) {
+            g.setColor(Color.YELLOW);
+        } else {
+            g.setColor(Color.BLACK);
+        }
+        g.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
+        this.currentbufferedimage = null;
+    }
+
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        seriesDescriptionLabel = new javax.swing.JLabel();
+        totalImagesLabel = new javax.swing.JLabel();
+
+        setBackground(new java.awt.Color(0, 0, 0));
+        setDoubleBuffered(false);
+        setOpaque(false);
+        setPreferredSize(new java.awt.Dimension(128, 128));
+
+        seriesDescriptionLabel.setFont(new java.awt.Font("Times", 0, 10));
+        seriesDescriptionLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+        seriesDescriptionLabel.setText("Series Discription");
+
+        totalImagesLabel.setFont(new java.awt.Font("Times", 0, 10));
+        totalImagesLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+        totalImagesLabel.setText("Total Images");
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
+        this.setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(seriesDescriptionLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 128, Short.MAX_VALUE)
+            .add(totalImagesLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 128, Short.MAX_VALUE)
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(layout.createSequentialGroup()
+                .addContainerGap()
+                .add(seriesDescriptionLabel)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(totalImagesLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 11, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addContainerGap(94, Short.MAX_VALUE))
+        );
+    }// </editor-fold>//GEN-END:initComponents
+
+    public void mouseClicked(MouseEvent e) {
+        this.requestFocus();
+        if (e.getClickCount() == 2) {
+           // openSingleImage(this.fileUrl);
+        }
+    }
+
+    public void mousePressed(MouseEvent e) {
+        if(!instanceListAdded)
+            updateInstanceList();
+    }
+
+    public void mouseReleased(MouseEvent e) {
+    }
+
+    public void mouseEntered(MouseEvent e) {
+    }
+
+    public void mouseExited(MouseEvent e) {
+    }
+
+    public void focusGained(FocusEvent e) {     
+         this.setBorder(new LineBorder(Color.BLUE));       
+    }
+
+    public void focusLost(FocusEvent e) {      
+         this.setBorder(new LineBorder(Color.DARK_GRAY));      
+    }
+    public void clearAll() {
+        this.removeFocusListener(this);
+        this.removeMouseListener(this);
+        this.removeAll();
+        iter = null;
+        reader = null;
+        iis = null;
+        dataset = null;
+        loadedImage = null;
+        imageIcon = null;
+        currentbufferedimage = null;
+        image.flush();
+        image = null;
+        fileUrl = null;
+        instanceNo = null;
+        totalInstace = null;
+        focusGained = false;
+        img = null;
+        seriesDescriptionLabel=null;
+        totalImagesLabel=null;
+    }
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JLabel seriesDescriptionLabel;
+    private javax.swing.JLabel totalImagesLabel;
+    // End of variables declaration//GEN-END:variables
+}
diff --git a/src/in/raster/mayam/form/Tile.form b/src/in/raster/mayam/form/Tile.form
new file mode 100644
index 0000000..473203a
--- /dev/null
+++ b/src/in/raster/mayam/form/Tile.form
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+  <Properties>
+    <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+      <Color blue="0" green="0" red="0" type="rgb"/>
+    </Property>
+  </Properties>
+  <Events>
+    <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="formMouseClicked"/>
+  </Events>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <EmptySpace min="0" pref="400" max="32767" attributes="0"/>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <EmptySpace min="0" pref="300" max="32767" attributes="0"/>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+</Form>
diff --git a/src/in/raster/mayam/form/Tile.java b/src/in/raster/mayam/form/Tile.java
new file mode 100644
index 0000000..b6f2eef
--- /dev/null
+++ b/src/in/raster/mayam/form/Tile.java
@@ -0,0 +1,164 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.model.Series;
+import in.raster.mayam.model.Study;
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.event.ActionEvent;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.util.ArrayList;
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class Tile extends javax.swing.JPanel implements FocusListener {
+
+    /** Creates new form Tile */
+    public boolean focusGained = false;    
+
+    public Tile() {
+        initComponents();        
+        this.addFocusListener(this);
+    }
+
+    @Override
+    public void paint(Graphics g) {
+        super.paint(g);
+        if (this.focusGained) {
+            g.setColor(Color.YELLOW);
+        } else {
+            g.setColor(Color.BLACK);
+            g.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
+            g.drawRect(1, 1, getWidth() - 3, getHeight() - 3);
+            g.setColor(Color.DARK_GRAY);
+        }
+        g.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
+        g.drawRect(1, 1, getWidth() - 3, getHeight() - 3);
+    }
+
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    @SuppressWarnings("unchecked")
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        setBackground(new java.awt.Color(0, 0, 0));
+        addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                formMouseClicked(evt);
+            }
+        });
+
+        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
+        this.setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGap(0, 400, Short.MAX_VALUE)
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGap(0, 300, Short.MAX_VALUE)
+        );
+    }// </editor-fold>//GEN-END:initComponents
+
+    private void formMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseClicked
+        this.requestFocus();
+        designContext();       
+    }//GEN-LAST:event_formMouseClicked
+
+    public boolean isFocusGained() {
+        return focusGained;
+    }
+
+    public void setFocusGained(boolean focusGained) {
+        this.focusGained = focusGained;
+        repaint();
+    }
+
+    public void focusGained(FocusEvent arg0) {
+        setFocusGained(true);
+    }
+
+    public void focusLost(FocusEvent arg0) {
+        setFocusGained(false);
+    }
+    /**
+     *
+     */
+    private void designContext() {
+        ArrayList<Study> studyList = null;
+        if (((JPanel) ApplicationContext.imgView.jTabbedPane1.getSelectedComponent()).getName() != null) {
+            String patientName = ((JPanel) ApplicationContext.imgView.jTabbedPane1.getSelectedComponent()).getName();
+            studyList = ApplicationContext.databaseRef.getStudyUIDBasedOnPatientName(patientName);
+        }
+        JPopupMenu jPopupMenu2=new JPopupMenu();
+        for (Study study : studyList) {
+            ArrayList<Series> seriesList = ApplicationContext.databaseRef.getSeriesList(study.getStudyInstanceUID());
+            JMenu menu = new JMenu(study.getStudyDesc());
+            for (final Series series : seriesList) {
+                JMenuItem menuitem = new JMenuItem(series.getSeriesDesc());
+                menu.add(menuitem);
+                menuitem.addActionListener(new java.awt.event.ActionListener() {
+                    public void actionPerformed(ActionEvent arg0) {
+                        // container.add(canvas, i);
+                        //changeSeries(arg0, series.getStudyInstanceUID(), series.getSeriesInstanceUID());
+                    }
+                });
+            }
+            jPopupMenu2.add(menu);
+        }
+        this.setComponentPopupMenu(jPopupMenu2);
+    }
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    // End of variables declaration//GEN-END:variables
+}
diff --git a/src/in/raster/mayam/form/WindowConfigurationPanel.form b/src/in/raster/mayam/form/WindowConfigurationPanel.form
new file mode 100644
index 0000000..0d0d8b6
--- /dev/null
+++ b/src/in/raster/mayam/form/WindowConfigurationPanel.form
@@ -0,0 +1,118 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+  <NonVisualComponents>
+    <Component class="javax.swing.ButtonGroup" name="windowConfigurationText">
+    </Component>
+    <Component class="javax.swing.ButtonGroup" name="buttonGroup1">
+    </Component>
+  </NonVisualComponents>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Component id="jLabel1" alignment="0" pref="479" max="32767" attributes="0"/>
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace min="10" pref="10" max="10" attributes="0"/>
+              <Component id="jPanel1" min="-2" max="-2" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="0" attributes="0">
+              <Component id="jLabel1" min="-2" pref="27" max="-2" attributes="0"/>
+              <EmptySpace type="separate" max="-2" attributes="0"/>
+              <Component id="jPanel1" min="-2" max="-2" attributes="0"/>
+              <EmptySpace pref="162" max="32767" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Component class="javax.swing.JLabel" name="jLabel1">
+      <Properties>
+        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="cc" green="cc" red="cc" type="rgb"/>
+        </Property>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Tahoma" size="14" style="1"/>
+        </Property>
+        <Property name="text" type="java.lang.String" value=" Window Configuration"/>
+        <Property name="opaque" type="boolean" value="true"/>
+      </Properties>
+    </Component>
+    <Container class="javax.swing.JPanel" name="jPanel1">
+      <Properties>
+        <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+          <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
+            <TitledBorder title="Desktop Window Behaviour"/>
+          </Border>
+        </Property>
+      </Properties>
+
+      <Layout>
+        <DimensionLayout dim="0">
+          <Group type="103" groupAlignment="0" attributes="0">
+              <Group type="102" alignment="0" attributes="0">
+                  <EmptySpace min="-2" pref="27" max="-2" attributes="0"/>
+                  <Group type="103" groupAlignment="0" attributes="0">
+                      <Component id="jRadioButton2" alignment="0" min="-2" max="-2" attributes="0"/>
+                      <Component id="jRadioButton1" alignment="0" min="-2" max="-2" attributes="0"/>
+                  </Group>
+                  <EmptySpace max="32767" attributes="0"/>
+              </Group>
+          </Group>
+        </DimensionLayout>
+        <DimensionLayout dim="1">
+          <Group type="103" groupAlignment="0" attributes="0">
+              <Group type="102" alignment="0" attributes="0">
+                  <EmptySpace max="-2" attributes="0"/>
+                  <Component id="jRadioButton1" min="-2" max="-2" attributes="0"/>
+                  <EmptySpace type="unrelated" max="-2" attributes="0"/>
+                  <Component id="jRadioButton2" min="-2" max="-2" attributes="0"/>
+                  <EmptySpace max="32767" attributes="0"/>
+              </Group>
+          </Group>
+        </DimensionLayout>
+      </Layout>
+      <SubComponents>
+        <Component class="javax.swing.JRadioButton" name="jRadioButton1">
+          <Properties>
+            <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
+              <ComponentRef name="buttonGroup1"/>
+            </Property>
+            <Property name="text" type="java.lang.String" value="Always open images in single window"/>
+          </Properties>
+          <Events>
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jRadioButton1ActionPerformed"/>
+          </Events>
+        </Component>
+        <Component class="javax.swing.JRadioButton" name="jRadioButton2">
+          <Properties>
+            <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
+              <ComponentRef name="buttonGroup1"/>
+            </Property>
+            <Property name="selected" type="boolean" value="true"/>
+            <Property name="text" type="java.lang.String" value="Always open images in separate window"/>
+          </Properties>
+          <Events>
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jRadioButton2ActionPerformed"/>
+          </Events>
+        </Component>
+      </SubComponents>
+    </Container>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/WindowConfigurationPanel.java b/src/in/raster/mayam/form/WindowConfigurationPanel.java
new file mode 100644
index 0000000..8e4ee91
--- /dev/null
+++ b/src/in/raster/mayam/form/WindowConfigurationPanel.java
@@ -0,0 +1,170 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class WindowConfigurationPanel extends javax.swing.JPanel {
+    
+    /** Creates new form WindowConfigurationPanel */
+    String modeOfWindow="";
+    public WindowConfigurationPanel() {
+        initComponents();
+    }
+
+ public String getWindowConfiguration()
+ {
+     if(jRadioButton1.isSelected())
+     {
+         modeOfWindow="single";
+     }
+     else
+         modeOfWindow="separate";
+     
+     return modeOfWindow;
+         
+ }
+     
+
+
+    
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        windowConfigurationText = new javax.swing.ButtonGroup();
+        buttonGroup1 = new javax.swing.ButtonGroup();
+        jLabel1 = new javax.swing.JLabel();
+        jPanel1 = new javax.swing.JPanel();
+        jRadioButton1 = new javax.swing.JRadioButton();
+        jRadioButton2 = new javax.swing.JRadioButton();
+
+        jLabel1.setBackground(new java.awt.Color(204, 204, 204));
+        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
+        jLabel1.setText(" Window Configuration");
+        jLabel1.setOpaque(true);
+
+        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Desktop Window Behaviour"));
+
+        buttonGroup1.add(jRadioButton1);
+        jRadioButton1.setText("Always open images in single window");
+        jRadioButton1.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                jRadioButton1ActionPerformed(evt);
+            }
+        });
+
+        buttonGroup1.add(jRadioButton2);
+        jRadioButton2.setSelected(true);
+        jRadioButton2.setText("Always open images in separate window");
+        jRadioButton2.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                jRadioButton2ActionPerformed(evt);
+            }
+        });
+
+        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
+        jPanel1.setLayout(jPanel1Layout);
+        jPanel1Layout.setHorizontalGroup(
+            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(jPanel1Layout.createSequentialGroup()
+                .add(27, 27, 27)
+                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                    .add(jRadioButton2)
+                    .add(jRadioButton1))
+                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+        );
+        jPanel1Layout.setVerticalGroup(
+            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(jPanel1Layout.createSequentialGroup()
+                .addContainerGap()
+                .add(jRadioButton1)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+                .add(jRadioButton2)
+                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+        );
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
+        this.setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 479, Short.MAX_VALUE)
+            .add(layout.createSequentialGroup()
+                .add(10, 10, 10)
+                .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addContainerGap())
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(layout.createSequentialGroup()
+                .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 27, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .add(18, 18, 18)
+                .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addContainerGap(162, Short.MAX_VALUE))
+        );
+    }// </editor-fold>//GEN-END:initComponents
+
+    private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton1ActionPerformed
+       
+        
+    }//GEN-LAST:event_jRadioButton1ActionPerformed
+
+    private void jRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton2ActionPerformed
+       
+    }//GEN-LAST:event_jRadioButton2ActionPerformed
+    
+    
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.ButtonGroup buttonGroup1;
+    private javax.swing.JLabel jLabel1;
+    private javax.swing.JPanel jPanel1;
+    private javax.swing.JRadioButton jRadioButton1;
+    private javax.swing.JRadioButton jRadioButton2;
+    private javax.swing.ButtonGroup windowConfigurationText;
+    // End of variables declaration//GEN-END:variables
+    
+}
diff --git a/src/in/raster/mayam/form/WindowingCanvas.form b/src/in/raster/mayam/form/WindowingCanvas.form
new file mode 100644
index 0000000..8cfdc31
--- /dev/null
+++ b/src/in/raster/mayam/form/WindowingCanvas.form
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+  <Properties>
+    <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+      <Color blue="0" green="0" red="0" type="rgb"/>
+    </Property>
+    <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+      <Color blue="ff" green="ff" red="ff" type="rgb"/>
+    </Property>
+    <Property name="focusCycleRoot" type="boolean" value="true"/>
+    <Property name="focusTraversalPolicyProvider" type="boolean" value="true"/>
+  </Properties>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <EmptySpace min="0" pref="436" max="32767" attributes="0"/>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <EmptySpace min="0" pref="322" max="32767" attributes="0"/>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+</Form>
diff --git a/src/in/raster/mayam/form/WindowingCanvas.java b/src/in/raster/mayam/form/WindowingCanvas.java
new file mode 100644
index 0000000..3c1c183
--- /dev/null
+++ b/src/in/raster/mayam/form/WindowingCanvas.java
@@ -0,0 +1,275 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form;
+
+import in.raster.mayam.delegate.ImageOrientation;
+import java.awt.Color;
+import java.awt.Graphics;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class WindowingCanvas extends javax.swing.JPanel {
+
+    /** Creates new form DateFormatPanel */
+    private boolean firstTime = true;
+    private WindowingLayeredCanvas layeredCanvas;
+    private String columnRight = "";
+    private String columnLeft = "";
+    private String rowTop = "";
+    private String rowDown = "";
+
+    public WindowingCanvas(WindowingLayeredCanvas canvas) {
+        initComponents();
+        this.layeredCanvas = canvas;
+    }
+
+    public WindowingCanvas() {
+        initComponents();
+    }
+
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        setBackground(new java.awt.Color(0, 0, 0));
+        setForeground(new java.awt.Color(255, 255, 255));
+        setFocusCycleRoot(true);
+        setFocusTraversalPolicyProvider(true);
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
+        this.setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(0, 436, Short.MAX_VALUE)
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(0, 322, Short.MAX_VALUE)
+        );
+    }// </editor-fold>//GEN-END:initComponents
+
+    public void setFirstTime(boolean firstTime) {
+        this.firstTime = firstTime;
+    }
+
+    @Override
+    public void paint(Graphics g) {
+        super.paint(g);
+        if (firstTime) {           
+            this.setSize(layeredCanvas.getSize().width, layeredCanvas.getSize().height);
+            firstTime = false;
+            centerImage();
+            repaint();
+        }        
+         if (this.layeredCanvas.imgpanel != null) {
+            if (this.layeredCanvas.imgpanel.getPixelSpacingY() != -1&&this.layeredCanvas.imgpanel.getPixelSpacingY() != 0) {
+                int viewScaleHeight = (int) ((int) (100 / this.layeredCanvas.imgpanel.getPixelSpacingY()) * this.layeredCanvas.imgpanel.getScaleFactor() * this.layeredCanvas.imgpanel.getCurrentScaleFactor());
+                int y1 = (this.getHeight() - viewScaleHeight) / 2;
+                int hx = 20;
+                int y2 = y1 + viewScaleHeight;
+                g.setColor(Color.YELLOW);
+                g.drawLine(hx, y1, hx, y2);
+                g.drawLine(hx, y1, hx + 12, y1);
+                g.drawLine(hx, y2, hx + 12, y2);
+                double viewScaleHeightUnit = (viewScaleHeight + 0.000f) / 10;
+                g.drawLine(hx, (int) (y1 + (viewScaleHeightUnit * 1)), hx + 6, (int) (y1 + (viewScaleHeightUnit * 1)));
+                g.drawLine(hx, (int) (y1 + (viewScaleHeightUnit * 2)), hx + 6, (int) (y1 + (viewScaleHeightUnit * 2)));
+                g.drawLine(hx, (int) (y1 + (viewScaleHeightUnit * 3)), hx + 6, (int) (y1 + (viewScaleHeightUnit * 3)));
+                g.drawLine(hx, (int) (y1 + (viewScaleHeightUnit * 4)), hx + 6, (int) (y1 + (viewScaleHeightUnit * 4)));
+                g.drawLine(hx, (int) (y1 + (viewScaleHeightUnit * 5)), hx + 12, (int) (y1 + (viewScaleHeightUnit * 5)));
+                g.drawLine(hx, (int) (y1 + (viewScaleHeightUnit * 6)), hx + 6, (int) (y1 + (viewScaleHeightUnit * 6)));
+                g.drawLine(hx, (int) (y1 + (viewScaleHeightUnit * 7)), hx + 6, (int) (y1 + (viewScaleHeightUnit * 7)));
+                g.drawLine(hx, (int) (y1 + (viewScaleHeightUnit * 8)), hx + 6, (int) (y1 + (viewScaleHeightUnit * 8)));
+                g.drawLine(hx, (int) (y1 + (viewScaleHeightUnit * 9)), hx + 6, (int) (y1 + (viewScaleHeightUnit * 9)));
+                int viewScaleWidth = (int) ((int) (100 / this.layeredCanvas.imgpanel.getPixelSpacingX()) * this.layeredCanvas.imgpanel.getScaleFactor() * this.layeredCanvas.imgpanel.getCurrentScaleFactor());
+                int wx1 = (this.getWidth() - viewScaleWidth) / 2;
+                int wy = this.getHeight() - 20;
+                int wx2 = wx1 + viewScaleWidth;
+                g.drawLine(wx1, wy, wx2, wy);
+                g.drawLine(wx1, wy, wx1, wy - 12);
+                g.drawLine(wx2, wy, wx2, wy - 12);
+                double viewScaleWidthUnit = (viewScaleWidth + 0.000f) / 10;
+                g.drawLine((int) (wx1 + (viewScaleWidthUnit * 5)), wy, (int) (wx1 + (viewScaleWidthUnit * 5)), wy - 12);
+                g.drawLine((int) (wx1 + (viewScaleWidthUnit * 1)), wy, (int) (wx1 + (viewScaleWidthUnit * 1)), wy - 6);
+                g.drawLine((int) (wx1 + (viewScaleWidthUnit * 2)), wy, (int) (wx1 + (viewScaleWidthUnit * 2)), wy - 6);
+                g.drawLine((int) (wx1 + (viewScaleWidthUnit * 3)), wy, (int) (wx1 + (viewScaleWidthUnit * 3)), wy - 6);
+                g.drawLine((int) (wx1 + (viewScaleWidthUnit * 4)), wy, (int) (wx1 + (viewScaleWidthUnit * 4)), wy - 6);
+                g.drawLine((int) (wx1 + (viewScaleWidthUnit * 6)), wy, (int) (wx1 + (viewScaleWidthUnit * 6)), wy - 6);
+                g.drawLine((int) (wx1 + (viewScaleWidthUnit * 7)), wy, (int) (wx1 + (viewScaleWidthUnit * 7)), wy - 6);
+                g.drawLine((int) (wx1 + (viewScaleWidthUnit * 8)), wy, (int) (wx1 + (viewScaleWidthUnit * 8)), wy - 6);
+                g.drawLine((int) (wx1 + (viewScaleWidthUnit * 9)), wy, (int) (wx1 + (viewScaleWidthUnit * 9)), wy - 6);
+                  if (this.layeredCanvas.imgpanel.getImageOrientation() != null) {
+                g.setColor(Color.WHITE);
+                this.getOrientation(this.layeredCanvas.imgpanel.getImageOrientation());
+                columnLeft = getOppositeOrientation(columnRight);
+                rowTop = getOppositeOrientation(rowDown);                
+                g.drawString(rowTop, (this.getSize().width / 2) - 1, 20);
+                g.drawString(rowDown, (this.getSize().width / 2) - 1, this.getSize().height - 7);
+                g.drawString(columnLeft, 10, (this.getSize().height / 2) - 1);
+                g.drawString(columnRight, this.getSize().width - 30, (this.getSize().height / 2) - 1);
+            }
+            }
+        }
+    }
+
+    @Override
+    protected void paintBorder(Graphics g) {
+        super.paintBorder(g);
+    }
+
+    public void resizeHandler() {
+        this.firstTime = true;
+        repaint();
+    }
+
+    private void centerImage() {
+        int xPosition = (this.getSize().width - this.getComponent(0).getSize().width) / 2;
+        int yPosition = (this.getSize().height - this.getComponent(0).getSize().height) / 2;
+        this.getComponent(0).setBounds(xPosition, yPosition, this.getComponent(0).getSize().width, this.getComponent(0).getSize().height);
+    }
+     public void changeOrientationTo90() {
+        String tempLeft, tempRight, tempTop, tempBottom;
+        tempLeft = columnLeft;
+        tempRight = columnRight;
+        tempTop = rowTop;
+        tempBottom = rowDown;
+        columnLeft = tempBottom;
+        rowTop = tempLeft;
+        columnRight = tempTop;
+        rowDown = tempRight;
+    }
+
+    public void changeOrientationTo180() {
+        String tempLeft, tempRight, tempTop, tempBottom;
+        tempLeft = columnLeft;
+        tempRight = columnRight;
+        tempTop = rowTop;
+        tempBottom = rowDown;
+        columnLeft = tempRight;
+        rowTop = tempBottom;
+        columnRight = tempLeft;
+        rowDown = tempTop;
+    }
+
+    public void changeOrientationTo270() {
+        String tempLeft, tempRight, tempTop, tempBottom;
+        tempLeft = columnLeft;
+        tempRight = columnRight;
+        tempTop = rowTop;
+        tempBottom = rowDown;
+        columnLeft = tempTop;
+        rowTop = tempRight;
+        columnRight = tempBottom;
+        rowDown = tempLeft;
+    }
+
+    public void flipOrientationToHorizontal() {
+        String tempLeft, tempRight;
+        tempLeft = columnLeft;
+        tempRight = columnRight;
+        columnLeft = tempRight;
+        columnRight = tempLeft;
+    }
+
+    public void flipOrientationToVertical() {
+        String tempTop, tempBottom;
+        tempTop = rowTop;
+        tempBottom = rowDown;
+        rowTop = tempBottom;
+        rowDown = tempTop;
+    }
+
+    public void getOrientation(String imageOrientation) {
+        String imageOrientationArray[];
+        imageOrientationArray = imageOrientation.split("\\\\");
+        float _imgRowCosx = Float.parseFloat(imageOrientationArray[0]);
+        float _imgRowCosy = Float.parseFloat(imageOrientationArray[1]);
+        float _imgRowCosz = Float.parseFloat(imageOrientationArray[2]);
+        float _imgColCosx = Float.parseFloat(imageOrientationArray[3]);
+        float _imgColCosy = Float.parseFloat(imageOrientationArray[4]);
+        float _imgColCosz = Float.parseFloat(imageOrientationArray[5]);
+        columnRight = ImageOrientation.getOrientation(_imgRowCosx, _imgRowCosy, _imgRowCosz);
+        rowDown = ImageOrientation.getOrientation(_imgColCosx, _imgColCosy, _imgColCosz);
+    }
+
+    public String getOppositeOrientation(String orientation) {
+        String oppositePrcl = "";
+        char[] temp = orientation.toCharArray();
+        for (char c : temp) {
+            oppositePrcl += getOpposite(c);
+        }
+        return oppositePrcl;
+    }
+
+    public char getOpposite(char c) {
+        char opposite = ' ';
+        switch (c) {
+            case 'L':
+                return 'R';
+            case 'R':
+                return 'L';
+            case 'P':
+                return 'A';
+            case 'A':
+                return 'P';
+            case 'H':
+                return 'F';
+            case 'F':
+                return 'H';
+        }
+        return opposite;
+    }
+    public WindowingLayeredCanvas getLayeredCanvas() {
+        return layeredCanvas;
+    }
+
+    public void setLayeredCanvas(WindowingLayeredCanvas layeredCanvas) {
+        this.layeredCanvas = layeredCanvas;
+    }
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    // End of variables declaration//GEN-END:variables
+}
diff --git a/src/in/raster/mayam/form/WindowingImagePanel.form b/src/in/raster/mayam/form/WindowingImagePanel.form
new file mode 100644
index 0000000..f243dbe
--- /dev/null
+++ b/src/in/raster/mayam/form/WindowingImagePanel.form
@@ -0,0 +1,31 @@
+<?xml version="1.1" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+  <Properties>
+    <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+      <Color blue="0" green="0" red="0" type="rgb"/>
+    </Property>
+    <Property name="focusCycleRoot" type="boolean" value="true"/>
+    <Property name="opaque" type="boolean" value="false"/>
+    <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+      <Dimension value="[512, 512]"/>
+    </Property>
+  </Properties>
+  <Events>
+    <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="formMouseClicked"/>
+  </Events>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+    <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,-112"/>
+  </AuxValues>
+
+  <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
+</Form>
diff --git a/src/in/raster/mayam/form/WindowingImagePanel.java b/src/in/raster/mayam/form/WindowingImagePanel.java
new file mode 100644
index 0000000..e7a36ff
--- /dev/null
+++ b/src/in/raster/mayam/form/WindowingImagePanel.java
@@ -0,0 +1,1107 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form;
+
+import com.sun.pdfview.PDFFile;
+import com.sun.pdfview.PDFPage;
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.delegate.ShowImageViewDelegate;
+import in.raster.mayam.delegate.StudyListUpdator;
+import in.raster.mayam.exception.ImageReadingException;
+import in.raster.mayam.model.Instance;
+import in.raster.mayam.model.Series;
+import in.raster.mayam.model.Study;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseWheelEvent;
+import java.io.File;
+import org.dcm4che.dict.Tags;
+import org.dcm4che.image.ColorModelFactory;
+import org.dcm4che.image.ColorModelParam;
+
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.Rectangle;
+import java.awt.RenderingHints;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionListener;
+import java.awt.event.MouseWheelListener;
+import java.awt.image.BufferedImage;
+import java.awt.image.ColorModel;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.imageio.ImageIO;
+import javax.imageio.ImageReader;
+import javax.imageio.stream.ImageInputStream;
+import javax.swing.ImageIcon;
+import org.dcm4che.data.Dataset;
+import org.dcm4che.imageio.plugins.DcmMetadata;
+import org.dcm4che2.data.DicomObject;
+import org.dcm4che2.io.DicomInputStream;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5 
+ *
+ */
+public class WindowingImagePanel extends javax.swing.JPanel implements MouseWheelListener,
+        MouseMotionListener, MouseListener {
+
+    private WindowingCanvas canvas;
+    private boolean newBufferedImage = false;
+    private boolean firstTime = true;
+    public static String tool = "";
+    private String patientName;
+    private int windowLevel;
+    private int windowWidth;
+    private int WC;
+    private int WW;
+    private double pixelSpacingX;
+    private double pixelSpacingY;
+    private String patientID;
+    private String sex;
+    private String studyDate;
+    private String studyTime;
+    private String modality;
+    private String studyUID;
+    private String seriesUID;
+    private String instanceUID;
+    private String bodyPartExamined;
+    private String slicePosition;
+    private String patientPosition;
+    private String institutionName;
+    private Image loadedImage;
+    private ImageInputStream iis;
+    private Iterator iter;
+    private ImageReader reader;
+    private Dataset dataset;
+    private BufferedImage currentbufferedimage;
+    private BufferedImage image;
+    private int mouseLocX1;
+    private int mouseLocX2;
+    private int mouseLocY1;
+    private int mouseLocY2;
+    private ColorModelParam cmParam = null;
+    private static final ColorModelFactory cmFactory = ColorModelFactory.getInstance();
+    private int windowingMultiplier = 1;
+    private int originalWidth;
+    private int originalHeight;
+    private ColorModel cm = null;
+    private ImageIcon imageIcon;
+    private String aspectRatio[];
+    private float floatAspectRatio;
+    // private MediaTracker tracker;
+    private String dicomFileUrl;
+    private ArrayList<Instance> instanceArray = null;
+    private int thumbWidth = 384;
+    private int thumbHeight = 384;
+    private int maxHeight = 384;
+    private int maxWidth = 384;
+    private double thumbRatio;
+    private int startX = 0;
+    private int startY = 0;
+    //multiframe variables
+    private int nFrames = 0;
+    private int currentFrame = 0;
+    private boolean mulitiFrame = false;
+    private double currentScaleFactor = 1;
+    private double initialPixelSpacingX;
+    private double initialPixelSpacingY;
+    private String pixelSpacing;
+    private int row;
+    private int column;
+    private double scaleFactor = 1;
+    private String imageOrientation;
+    private PDFFile curFile = null;
+    private int curpage = -1;
+    private boolean isEncapsulatedDocument = false;
+
+    public WindowingImagePanel() {
+        initComponents();
+    }
+
+    /**
+     * Constructs the imagepanel by passing file url and outer canvas
+     * @param dicomFileUrl
+     * @param canvas
+     */
+    public WindowingImagePanel(String dicomFileUrl, WindowingCanvas canvas) {
+        this.dicomFileUrl = dicomFileUrl;
+        this.canvas = canvas;
+        try {
+            initComponents();
+            readDicomFile(new File(dicomFileUrl));
+            retrievePatientInformation();
+            retrieveInstanceInformation();
+            addlisteners();
+            setTotalInstance();
+            //setSizing();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void setSizing() {
+        this.thumbHeight = this.getSize().height;
+        this.thumbWidth = this.getSize().width;
+    }
+
+    /**
+     * Constructs the imagepanel by passing file url parameter
+     * @param dicomFileUrl
+     */
+    public WindowingImagePanel(String dicomFileUrl) {
+        this.dicomFileUrl = dicomFileUrl;
+        try {
+            readDicomFile(new File(dicomFileUrl));
+            retrievePatientInformation();
+            initComponents();
+            addlisteners();
+            retrieveInstanceInformation();
+            setTotalInstance();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * This routine used to retrive the patient related information
+     */
+    private void retrievePatientInformation() {
+        patientName = dataset.getString(Tags.PatientName);
+        patientID = dataset.getString(Tags.PatientID);
+        sex = dataset.getString(Tags.PatientSex);
+        modality = dataset.getString(Tags.Modality);
+        studyDate = dataset.getString(Tags.StudyDate);
+        studyTime = dataset.getString(Tags.StudyTime);
+        studyUID = dataset.getString(Tags.StudyInstanceUID);
+        seriesUID = dataset.getString(Tags.SeriesInstanceUID);
+        MainScreen.selectedSeries = seriesUID;
+        bodyPartExamined = dataset.getString(Tags.BodyPartExamined);
+        slicePosition = dataset.getString(Tags.SliceLocation);
+        patientPosition = dataset.getString(Tags.PatientPosition);
+        institutionName = dataset.getString(Tags.InstitutionName);
+        instanceUID = dataset.getString(Tags.SOPInstanceUID);
+        aspectRatio = dataset.getStrings(Tags.PixelAspectRatio);
+        try {
+
+            currentInstanceNo = Integer.parseInt(dataset.getString(Tags.InstanceNumber));
+        } catch (NumberFormatException e) {
+            System.out.println("Instance Number format error currentInstanceNo: " + currentInstanceNo);
+            currentInstanceNo = 0; // if Number error correct and put a correct number (1)
+        } catch (NullPointerException e) {
+            System.out.println("Instance number Null pointer error");
+            currentInstanceNo = 0; // if Number error correct and put a correct number (1)
+        }
+    }
+
+    /**
+     * This routine used to retrive the instance related information
+     */
+    private void retrieveInstanceInformation() {
+        String inverted = dataset.getString(Tags.PhotometricInterpretation, null);
+        if ("MONOCHROME1".equals(inverted) || "MONOCHROME2".equals(inverted)) {
+
+            cmParam = cmFactory.makeParam(dataset);
+            int bits = dataset.getInt(Tags.BitsStored, 8);
+            int size = 1 << bits;
+            int signed = dataset.getInt(Tags.PixelRepresentation, 0);
+            int min = dataset.getInt(Tags.SmallestImagePixelValue,
+                    signed == 0 ? 0 : -(size >> 1));
+            int max = dataset.getInt(Tags.LargestImagePixelValue,
+                    signed == 0 ? size - 1 : (size >> 1) - 1);
+            int c = (int) cmParam.toMeasureValue((min + max) >> 1);
+            int cMin = (int) cmParam.toMeasureValue(min);
+            int cMax = (int) cmParam.toMeasureValue(max - 1);
+            int wMax = cMax - cMin;
+            int w = wMax;
+            try {
+                initialPixelSpacingY = pixelSpacingY = Double.parseDouble(dataset.getString(
+                        Tags.PixelSpacing, 0));
+                initialPixelSpacingX = pixelSpacingX = Double.parseDouble(dataset.getString(
+                        Tags.PixelSpacing, 1));
+
+            } catch (NullPointerException e) {
+                initialPixelSpacingX = 0;
+                initialPixelSpacingY = 0;
+            }
+            int nWindow = cmParam.getNumberOfWindows();
+            if (nWindow > 0) {
+                windowLevel = c = (int) cmParam.getWindowCenter(0);
+                windowWidth = w = (int) cmParam.getWindowWidth(0);
+            } else {
+                WW = windowWidth = w = (int) Math.pow(2, bits);
+                WC = windowLevel = c = (int) w / 2;
+            }
+        }
+        imageOrientation = dataset.getString(Tags.ImageOrientation) != null ? dataset.getString(Tags.ImageOrientation, 0) + "\\" + dataset.getString(Tags.ImageOrientation, 1) + "\\" + dataset.getString(Tags.ImageOrientation, 2) + "\\" + dataset.getString(Tags.ImageOrientation, 3) + "\\" + dataset.getString(Tags.ImageOrientation, 4) + "\\" + dataset.getString(Tags.ImageOrientation, 5) : null;
+    }
+
+    public void readDicom(File file) {
+        try {
+            DicomInputStream din = new DicomInputStream(new File(file.getAbsolutePath()));
+            DicomObject dcmObject = din.readDicomObject();
+            byte[] buf = dcmObject.getBytes(Tags.EncapsulatedDocument);
+            ByteBuffer byteBuffer = ByteBuffer.wrap(buf);
+            openPDFByteBuffer(byteBuffer, null, null);
+            isEncapsulatedDocument = true;
+        } catch (IOException ex) {
+            Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+
+    private void openPDFByteBuffer(ByteBuffer buf, String path, String name) {
+        PDFFile newfile = null;
+        try {
+            newfile = new PDFFile(buf);
+        } catch (IOException ioe) {
+            return;
+        }
+        this.curFile = newfile;
+        forceGotoPage(0);
+    }
+
+    public void forceGotoPage(int pagenum) {
+        if (pagenum <= 0) {
+            pagenum = 0;
+        } else if (pagenum >= curFile.getNumPages()) {
+            pagenum = curFile.getNumPages() - 1;
+        }
+        totalInstance = curFile.getNumPages();
+        curpage = pagenum;
+        PDFPage pg = curFile.getPage(pagenum + 1, true);
+
+        Rectangle rect = new Rectangle(0, 0,
+                (int) pg.getBBox().getWidth(),
+                (int) pg.getBBox().getHeight());
+
+        //generate the image
+        Image current = pg.getImage(
+                rect.width, rect.height, //width & height
+                rect, // clip rect
+                null, // null for the ImageObserver
+                true, // fill background with white
+                true // block until drawing is done
+                );
+        Image img = pg.getImage(rect.width, rect.height, rect, null, true, true);
+        imageIcon = new ImageIcon();
+        imageIcon.setImage(current);
+        loadedImage = imageIcon.getImage();
+        image = null;
+        repaint();
+    }
+
+    private void calculateResolutionForPdfDicom(double imageWidthParam, double imageHeightParam) {
+        thumbHeight = 384;
+        thumbWidth = 384;
+        thumbRatio = thumbWidth / thumbHeight;
+        double imageWidth = imageWidthParam;
+        double imageHeight = imageHeightParam;
+        double imageRatio = (double) imageWidth / (double) imageHeight;
+        if (thumbRatio < imageRatio) {
+            thumbHeight = (int) Math.round((thumbWidth + 0.00f) / imageRatio);
+        } else {
+            thumbWidth = (int) Math.round((thumbHeight + 0.00f) * imageRatio);
+        }
+        startX = (maxWidth - thumbWidth) / 2;
+        startY = (maxHeight - thumbHeight) / 2;
+    }
+
+    private void nextofEncapsulatedDocument() {
+        if (dataset.getString(Tags.SOPClassUID).equalsIgnoreCase("1.2.840.10008.5.1.4.1.1.104.1")) {
+            forceGotoPage(curpage + 1);
+        }
+    }
+
+    private void previousofEncapsulatedDocument() {
+        if (dataset.getString(Tags.SOPClassUID).equalsIgnoreCase("1.2.840.10008.5.1.4.1.1.104.1")) {
+            forceGotoPage(curpage - 1);
+        }
+    }
+
+    /**
+     * Tdhis routine used to return the canvas of the image box
+     * @return
+     */
+    public WindowingCanvas getCanvas() {
+        return canvas;
+    }
+
+    public String getPatientName() {
+        return patientName;
+    }
+
+    public void setPatientName(String patientName) {
+        this.patientName = patientName;
+    }
+
+    public String getStudyUID() {
+        return studyUID;
+    }
+
+    public void setStudyUID(String studyUID) {
+        this.studyUID = studyUID;
+    }
+
+    /**
+     * This routine used to read the dicom file
+     * @param selFile-This the file to be read
+     */
+    private void readDicomFile(File selFile) {
+
+        try {
+            iis = ImageIO.createImageInputStream(selFile);
+            iter = ImageIO.getImageReadersByFormatName("DICOM");
+            reader = (ImageReader) iter.next();
+            reader.setInput(iis, false);
+            dataset = ((DcmMetadata) reader.getStreamMetadata()).getDataset();
+            try {
+                if (reader.getNumImages(true) > 0) {
+                    currentbufferedimage = reader.read(0);
+                    floatAspectRatio = reader.getAspectRatio(0);
+                }
+                nFrames = reader.getNumImages(true);
+                if (nFrames - 1 > 0) {
+                    mulitiFrame = true;
+                    this.totalInstance = nFrames;
+                }
+                if (reader.getNumImages(true) > 0) {
+                    imageIcon = new ImageIcon();
+                    imageIcon.setImage(currentbufferedimage);
+                    loadedImage = imageIcon.getImage();
+                    image = new BufferedImage(loadedImage.getWidth(null), loadedImage.getHeight(null), BufferedImage.TYPE_INT_RGB);
+                    Graphics2D g2 = image.createGraphics();
+                    g2.drawImage(loadedImage, 0, 0, null);
+                }
+                if (dataset.getString(Tags.SOPClassUID).equalsIgnoreCase("1.2.840.10008.5.1.4.1.1.104.1")) {
+                    readDicom(selFile);
+                }
+                repaint();
+            } catch (RuntimeException e) {
+                e.printStackTrace();
+            } finally {
+                if (!isMulitiFrame()) {
+                    iis.close();
+                    iter = null;
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * This routine used to set the image of this image box
+     * @param newImg
+     */
+    public void setImage(BufferedImage newImg) {
+        try {
+            newBufferedImage = true;
+            currentbufferedimage = newImg;
+            windowChanged(this.windowLevel, this.windowWidth);
+        } catch (ImageReadingException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void setImage(Instance instance) {
+        try {
+            newBufferedImage = true;
+            currentbufferedimage = instance.getPixelData();
+            windowChanged(this.windowLevel, this.windowWidth);
+            imageOrientation = instance.getImageOrientation();
+        } catch (ImageReadingException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public BufferedImage getCurrentbufferedimage() {
+        return currentbufferedimage;
+    }
+
+    public String getInstanceUID() {
+        return instanceUID;
+    }
+
+    public String getSeriesUID() {
+        return seriesUID;
+    }
+
+    public int getnFrames() {
+        return nFrames;
+    }
+
+    public void setnFrames(int nFrames) {
+        this.nFrames = nFrames;
+    }
+
+    /**
+     * This routine used to select the first instance of series
+     */
+    public void selectFirstInstance() {
+        for (Study study : MainScreen.studyList) {
+            if (study.getStudyInstanceUID().equalsIgnoreCase(ApplicationContext.imgPanel.getStudyUID())) {
+                ArrayList<Series> seriesList = (ArrayList<Series>) study.getSeriesList();
+                for (int i = 0; i < seriesList.size(); i++) {
+                    Series series = seriesList.get(i);
+                    if (series.getSeriesInstanceUID().equalsIgnoreCase(this.seriesUID)) {
+                        Instance instance = series.getImageList().get(0);
+                        //setImage(instance.getPixelData());
+                        setImage(instance);
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * This routine used to set the windowing tool enabled
+     */
+    public void doWindowing() {
+        if (tool.equalsIgnoreCase("windowing")) {
+            tool = "";
+        } else {
+            tool = "windowing";
+        }
+    }
+
+    public Dataset getDataset() {
+        return dataset;
+    }
+
+    public void setDataset(Dataset dataset) {
+        this.dataset = dataset;
+    }
+
+    /**
+     * This override routine used to paint the image box
+     * @param gs
+     */
+    @Override
+    public void paintComponent(Graphics gs) {
+        super.paintComponent(gs);
+        Graphics2D g = (Graphics2D) gs;
+        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+        g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
+        if (image != null) {
+            calculateNewHeightAndWidthBasedonAspectRatio();
+            g.drawImage(image, startX, startY, thumbWidth, thumbHeight, null);
+
+        }
+        if (firstTime) {
+            centerImage();
+            originalHeight = this.getSize().height;
+            originalWidth = this.getSize().width;
+            firstTime = false;
+        }
+        if (dataset.getString(Tags.SOPClassUID).equalsIgnoreCase("1.2.840.10008.5.1.4.1.1.104.1")) {
+            calculateResolutionForPdfDicom(loadedImage.getWidth(null), loadedImage.getHeight(null));
+            this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setCurrentInstance(curpage);
+            this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setTotalInstance(Integer.toString(totalInstance));
+            g.drawImage(loadedImage, startX, startY, thumbWidth, thumbHeight, null);
+
+        }
+    }
+    int finalHeight;
+    int finalWidth;
+
+    private void calculateNewHeightAndWidthBasedonAspectRatio() {
+        thumbRatio = thumbWidth / thumbHeight;
+        double imageWidth = image.getWidth();
+        double imageHeight = image.getHeight();
+        double imageRatio = (double) imageWidth / (double) imageHeight;
+        if (imageRatio < floatAspectRatio) {
+            imageHeight = (imageWidth + 0.00f) / floatAspectRatio;
+            pixelSpacingY = ((initialPixelSpacingY * image.getHeight()) / imageHeight);
+            pixelSpacing = pixelSpacingY + "\\" + pixelSpacingX;
+        } else {
+            imageWidth = (imageHeight + 0.00f) * floatAspectRatio;
+            pixelSpacingX = (initialPixelSpacingX * image.getWidth()) / imageWidth;
+            pixelSpacing = pixelSpacingY + "\\" + pixelSpacingX;
+        }
+        this.row = (int) Math.round(imageHeight);
+        this.column = (int) Math.round(imageWidth);
+        imageRatio = imageWidth / imageHeight;
+        if (thumbRatio < imageRatio) {
+            thumbHeight = (int) Math.round((thumbWidth + 0.00f) / imageRatio);
+        } else {
+            thumbWidth = (int) Math.round((thumbHeight + 0.00f) * imageRatio);
+        }
+        startX = (maxWidth - thumbWidth) / 2;
+        startY = (maxHeight - thumbHeight) / 2;
+    }
+
+    public double getCurrentScaleFactor() {
+        double imageWidth = image.getWidth();
+        double imageHeight = image.getHeight();
+        double imageRatio = imageWidth / imageHeight;
+        if (imageRatio < floatAspectRatio) {
+            imageHeight = (imageWidth + 0.00f) / floatAspectRatio;
+        } else {
+            imageWidth = (imageHeight + 0.00f) * floatAspectRatio;
+        }
+        currentScaleFactor = (thumbHeight + 0.000f) / imageHeight;
+        return currentScaleFactor;
+    }
+
+    /**
+     * This routine used to convert the rgb image
+     */
+    public void convertToRGBImage() {
+
+        imageIcon = new ImageIcon(currentbufferedimage);
+        loadedImage = imageIcon.getImage();
+        image = new BufferedImage(loadedImage.getWidth(null), loadedImage.getHeight(null), BufferedImage.TYPE_INT_RGB);
+        Graphics2D g2 = image.createGraphics();
+        g2.drawImage(loadedImage, 0, 0, null);
+        imageIcon = null;
+        loadedImage = null;
+
+    }
+
+    public void resizeHandler() {
+        repaint();
+        centerImage();
+    }
+
+    /**
+     *This routine used to set the tool as null
+     */
+    public void setToolsToNull() {
+        tool = "";
+    }
+
+    public double getOriginalHeight() {
+        return originalHeight;
+    }
+
+    public void setOriginalHeight(int originalHeight) {
+        this.originalHeight = originalHeight;
+    }
+
+    public double getOriginalWidth() {
+        return originalWidth;
+    }
+
+    public void setOriginalWidth(int originalWidth) {
+        this.originalWidth = originalWidth;
+    }
+
+    /**
+     * This routine used to calculate the x and y position of the image box to be placed in the
+     * outer canvas and set the bounds
+     */
+    private void centerImage() {
+        int xPosition = (canvas.getSize().width - this.getSize().width) / 2;
+        int yPosition = (canvas.getSize().height - this.getSize().height) / 2;
+        this.setBounds(xPosition, yPosition, this.getSize().width, this.getSize().height);
+
+    }
+
+    /**
+     * This method creates the color model based on the window level and width
+     * and apply the values to the image box
+     * @param windowCenter
+     * @param windowWidth
+     */
+    public void windowChanged(int windowCenter, int windowWidth) {
+        try {
+            if (cmParam != null) {
+                cmParam = cmParam.update(windowCenter,
+                        windowWidth, cmParam.isInverse());
+                cm = cmFactory.getColorModel(cmParam);
+                currentbufferedimage = new BufferedImage(cm, currentbufferedimage.getRaster(), false, null);
+                this.windowLevel = windowCenter;
+                this.windowWidth = windowWidth;
+            }
+            convertToRGBImage();
+            repaint();
+            changeTextOverlay();
+        } catch (Exception e) {
+            System.out.println("Windowing can't be changed");
+        }
+
+    }
+
+    public ColorModel getColorModel() {
+        cmParam = cmParam.update(this.windowLevel,
+                this.windowWidth, cmParam.isInverse());
+        cm = cmFactory.getColorModel(cmParam);
+        return cm;
+    }
+
+    /**
+     * This routine used to change the text overlay of the image box
+     */
+    public void changeTextOverlay() {
+        this.getCanvas().getLayeredCanvas().textOverlay.setWindowingParameter(Integer.toString(this.windowLevel), Integer.toString(this.windowWidth));
+    }
+
+    private void addlisteners() {
+        addMouseListener(this);
+        addMouseMotionListener(this);
+        addMouseWheelListener(this);
+    }
+
+    public double getPixelSpacingX() {
+        return pixelSpacingX;
+    }
+
+    public void setPixelSpacingX(double pixelSpacingX) {
+        this.pixelSpacingX = pixelSpacingX;
+    }
+
+    public double getPixelSpacingY() {
+        return pixelSpacingY;
+    }
+
+    public void setPixelSpacingY(double pixelSpacingY) {
+        this.pixelSpacingY = pixelSpacingY;
+    }
+
+    public String getBodyPartExamined() {
+        return bodyPartExamined;
+    }
+
+    public void setBodyPartExamined(String bodyPartExamined) {
+        this.bodyPartExamined = bodyPartExamined;
+    }
+
+    public String getInstitutionName() {
+        return institutionName;
+    }
+
+    public void setInstitutionName(String institutionName) {
+        this.institutionName = institutionName;
+    }
+
+    public String getPatientID() {
+        return patientID;
+    }
+
+    public void setPatientID(String patientID) {
+        this.patientID = patientID;
+    }
+
+    public String getPatientPosition() {
+        return patientPosition;
+    }
+
+    public void setPatientPosition(String patientPosition) {
+        this.patientPosition = patientPosition;
+    }
+
+    public String getSex() {
+        return sex;
+    }
+
+    public void setSex(String sex) {
+        this.sex = sex;
+    }
+
+    public String getSlicePosition() {
+        return slicePosition;
+    }
+
+    public void setSlicePosition(String slicePosition) {
+        this.slicePosition = slicePosition;
+    }
+
+    public String getStudyDate() {
+        return studyDate;
+    }
+
+    public void setStudyDate(String studyDate) {
+        this.studyDate = studyDate;
+    }
+
+    public String getStudyTime() {
+        return studyTime;
+    }
+
+    public void setStudyTime(String studyTime) {
+        this.studyTime = studyTime;
+    }
+
+    public int getWindowLevel() {
+        return windowLevel;
+    }
+
+    public void setWindowLevel(int windowLevel) {
+        this.windowLevel = windowLevel;
+    }
+
+    public int getWindowWidth() {
+        return windowWidth;
+    }
+
+    public void setWindowWidth(int windowWidth) {
+        this.windowWidth = windowWidth;
+    }
+
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        setBackground(new java.awt.Color(0, 0, 0));
+        setFocusCycleRoot(true);
+        setOpaque(false);
+        setPreferredSize(new java.awt.Dimension(512, 512));
+        addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                formMouseClicked(evt);
+            }
+        });
+        setLayout(new java.awt.BorderLayout());
+    }// </editor-fold>//GEN-END:initComponents
+
+    public void openSingleImage(String filePath) {
+        if (!ApplicationContext.imageViewExist()) {
+            ApplicationContext.createImageView();
+        }
+        ShowImageViewDelegate showImgView = new ShowImageViewDelegate(filePath);
+        StudyListUpdator studyListUpdator = new StudyListUpdator();
+        studyListUpdator.addStudyToStudyList(this.studyUID, MainScreen.studyList, filePath);
+
+    }
+    private void formMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseClicked
+    }//GEN-LAST:event_formMouseClicked
+    public double getScaleFactor() {
+        return scaleFactor;
+    }
+
+    public void setScaleFactor(double scaleFactor) {
+        this.scaleFactor = scaleFactor;
+    }
+
+    private void setTotalInstance() {
+        if (ApplicationContext.databaseRef.getMultiframeStatus()) {
+            if (!isMulitiFrame()) {
+                totalInstance = ApplicationContext.databaseRef.getSeriesLevelInstance(this.studyUID, this.seriesUID);
+                currentInstanceNo = 0;
+            } else {
+                totalInstance = nFrames;
+                currentInstanceNo = 0;
+            }
+        } else {
+            totalInstance = ApplicationContext.databaseRef.getSeriesLevelInstance(this.studyUID, this.seriesUID);
+            currentInstanceNo = 0;
+        }
+        if (dataset.getString(Tags.SOPClassUID).equalsIgnoreCase("1.2.840.10008.5.1.4.1.1.104.1")) {
+            totalInstance = curFile.getNumPages();
+            currentInstanceNo = 0;
+        }
+    }
+
+    public void mouseWheelMoved(MouseWheelEvent e) {
+        int notches = e.getWheelRotation();
+        if (notches < 0) {
+            if (ApplicationContext.databaseRef.getMultiframeStatus() && isMulitiFrame()) {
+                showPreviousFrame();
+            } else if (isEncapsulatedDocument) {
+                previousofEncapsulatedDocument();
+
+            } else {
+                if (instanceArray == null) {
+                    previousInstance();
+                } else {
+                    selectPreviousInstance();
+                }
+            }
+        } else {
+
+            if (ApplicationContext.databaseRef.getMultiframeStatus() && isMulitiFrame()) {
+                showNextFrame();
+            } else if (isEncapsulatedDocument) {
+                nextofEncapsulatedDocument();
+
+            } else {
+                if (instanceArray == null) {
+                    nextInstance();
+                } else {
+                    selectNextInstance();
+                }
+            }
+        }
+    }
+
+    public boolean isMulitiFrame() {
+        return mulitiFrame;
+    }
+
+    public void showNextFrame() {
+        currentFrame++;
+        if (currentFrame == nFrames) {
+            currentFrame = 0;
+        }
+        currentInstanceNo = currentFrame;
+        totalInstance = nFrames;
+        try {
+            currentbufferedimage = reader.read(currentFrame);
+            convertToRGBImage();
+            repaint();
+            this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setCurrentInstance(this.currentInstanceNo);
+            this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setTotalInstance(Integer.toString(this.totalInstance));
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            Logger.getLogger(ImagePanel.class.getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+
+    public void showPreviousFrame() {
+        if (currentFrame == 0) {
+            currentFrame = nFrames;
+        }
+        currentFrame--;
+        currentInstanceNo = currentFrame;
+        totalInstance = nFrames;
+        try {
+            currentbufferedimage = reader.read(currentFrame);
+            convertToRGBImage();
+            repaint();
+            this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setCurrentInstance(this.currentInstanceNo);
+            this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setTotalInstance(Integer.toString(this.totalInstance));
+        } catch (IOException ex) {
+            ex.printStackTrace();
+            Logger.getLogger(ImagePanel.class.getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+
+    private void selectPreviousInstance() {
+        if (currentInstanceNo == 0) {
+            currentInstanceNo = totalInstance;
+        }
+        currentInstanceNo--;
+        Instance instance = instanceArray.get(currentInstanceNo);
+        dicomFileUrl = instance.getFilepath();
+        if (instance.isMultiframe()) {
+            this.getCanvas().getLayeredCanvas().textOverlay.multiframeStatusDisplay(true);
+            this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setFramePosition((instance.getCurrentFrameNum() + 1) + "/" + instance.getTotalNumFrames());
+        } else {
+            this.getCanvas().getLayeredCanvas().textOverlay.multiframeStatusDisplay(false);
+            this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setFramePosition("");
+        }
+        setImage(instance);
+        if (!ApplicationContext.databaseRef.getMultiframeStatus()) {
+            this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setCurrentInstance(instance.getSeriesLevelIndex());
+        } else {
+            this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setCurrentInstance(this.currentInstanceNo);
+        }
+    }
+
+    private void selectNextInstance() {
+        currentInstanceNo++;
+        if (currentInstanceNo == totalInstance) {
+            currentInstanceNo = 0;
+        }
+        Instance instance = instanceArray.get(currentInstanceNo);
+        dicomFileUrl = instance.getFilepath();
+        if (instance.isMultiframe()) {
+            this.getCanvas().getLayeredCanvas().textOverlay.multiframeStatusDisplay(true);
+            this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setFramePosition((instance.getCurrentFrameNum() + 1) + "/" + instance.getTotalNumFrames());
+        } else {
+            this.getCanvas().getLayeredCanvas().textOverlay.multiframeStatusDisplay(false);
+            this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setFramePosition("");
+        }
+        setImage(instance);
+        if (!ApplicationContext.databaseRef.getMultiframeStatus()) {
+            this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setCurrentInstance(instance.getSeriesLevelIndex());
+        } else {
+            this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setCurrentInstance(this.currentInstanceNo);
+        }
+    }
+
+    public void showMultiframeInfo() {
+        Instance instance = instanceArray.get(currentInstanceNo);
+        if (instance.isMultiframe()) {
+            this.getCanvas().getLayeredCanvas().textOverlay.multiframeStatusDisplay(true);
+            this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setFramePosition((instance.getCurrentFrameNum() + 1) + "/" + instance.getTotalNumFrames());
+        } else {
+            this.getCanvas().getLayeredCanvas().textOverlay.multiframeStatusDisplay(false);
+            this.getCanvas().getLayeredCanvas().textOverlay.getTextOverlayParam().setFramePosition("");
+        }
+    }
+
+    private void previousInstance() {
+        for (Study study : MainScreen.studyList) {
+            if (study.getStudyInstanceUID().equalsIgnoreCase(this.studyUID)) {
+                for (Series series : study.getSeriesList()) {
+                    if (ApplicationContext.databaseRef.getMultiframeStatus()) {
+                        if (!series.isMultiframe() && series.getSeriesInstanceUID().equalsIgnoreCase(seriesUID)) {
+                            totalInstance = series.getImageList().size();
+                            instanceArray = (ArrayList<Instance>) series.getImageList();
+                            selectPreviousInstance();
+                        }
+                    } else {
+                        if (series.getSeriesInstanceUID().equalsIgnoreCase(seriesUID)) {
+                            totalInstance = series.getImageList().size();
+                            instanceArray = (ArrayList<Instance>) series.getImageList();
+                            selectPreviousInstance();
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    private void nextInstance() {
+        for (Study study : MainScreen.studyList) {
+            if (study.getStudyInstanceUID().equalsIgnoreCase(studyUID)) {
+                for (Series series : study.getSeriesList()) {
+                    if (ApplicationContext.databaseRef.getMultiframeStatus()) {
+                        if (!series.isMultiframe() && series.getSeriesInstanceUID().equalsIgnoreCase(seriesUID)) {
+                            totalInstance = series.getImageList().size();
+                            instanceArray = (ArrayList<Instance>) series.getImageList();
+                            selectNextInstance();
+                        }
+                    } else {
+                        if (series.getSeriesInstanceUID().equalsIgnoreCase(seriesUID)) {
+                            totalInstance = series.getImageList().size();
+                            instanceArray = (ArrayList<Instance>) series.getImageList();
+                            selectNextInstance();
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    public String getImageOrientation() {
+        return imageOrientation;
+    }
+
+    public void setImageOrientation(String imageOrientation) {
+        this.imageOrientation = imageOrientation;
+    }
+
+    public void setFirstTime(boolean firstTime) {
+        this.firstTime = firstTime;
+    }
+
+    public void mouseClicked(MouseEvent e) {
+        if (e.getClickCount() == 2) {
+            openSingleImage(dicomFileUrl);
+        }
+    }
+
+    public void mousePressed(MouseEvent e) {
+        this.canvas.requestFocus();
+        mouseLocX1 = e.getX();
+        mouseLocY1 = e.getY();
+    }
+
+    public void mouseReleased(MouseEvent e) {
+    }
+
+    public void mouseEntered(MouseEvent e) {
+    }
+
+    public void mouseExited(MouseEvent e) {
+    }
+
+    public void mouseDragged(MouseEvent e) {
+        mouseLocX2 = e.getX();
+        mouseLocY2 = e.getY();
+        if (tool.equalsIgnoreCase("windowing")) {
+            if (canStart) {
+                canStart = false;
+                mouseDragWindowing(mouseLocX2, mouseLocY2);
+                canStart = true;
+            }
+        }
+    }
+
+    private void mouseDragWindowing(int mouseLocX2, int mouseLocY2) {
+        int mouseLocDiffX = (int) ((mouseLocX2 - mouseLocX1)) * windowingMultiplier;
+        int mouseLocDiffY = (int) ((mouseLocY1 - mouseLocY2)) * windowingMultiplier;
+        mouseLocX1 = mouseLocX2;
+        mouseLocY1 = mouseLocY2;
+        double newWindowWidth = windowWidth + mouseLocDiffX * 5;
+        if (newWindowWidth < 1.0) {
+            newWindowWidth = 1.0;
+        }
+        double newWindowLevel = windowLevel + mouseLocDiffY * 5;
+        windowChanged(windowLevel, windowWidth);
+        windowLevel = (int) newWindowLevel;
+        windowWidth = (int) newWindowWidth;
+    }
+
+    public int getTotalInstance() {
+        return totalInstance;
+    }
+
+    public void setTotalInstance(int totalInstance) {
+        this.totalInstance = totalInstance;
+    }
+
+    public int getCurrentInstanceNo() {
+        return currentInstanceNo;
+    }
+
+    public void setCurrentInstanceNo(int currentInstanceNo) {
+        this.currentInstanceNo = currentInstanceNo;
+    }
+
+    public void mouseMoved(MouseEvent e) {
+        mouseLocX2 = e.getX();
+        mouseLocY2 = e.getY();
+    }
+
+    public String getModality() {
+        return modality;
+    }
+
+    public void setModality(String modality) {
+        this.modality = modality;
+    }
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    // End of variables declaration//GEN-END:variables
+    private int currentInstanceNo = 0;
+    private int totalInstance = 1;
+    private boolean canStart = true;
+}
diff --git a/src/in/raster/mayam/form/WindowingLayeredCanvas.java b/src/in/raster/mayam/form/WindowingLayeredCanvas.java
new file mode 100644
index 0000000..196987b
--- /dev/null
+++ b/src/in/raster/mayam/form/WindowingLayeredCanvas.java
@@ -0,0 +1,211 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.param.TextOverlayParam;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.event.ComponentEvent;
+import java.awt.event.ComponentListener;
+import javax.swing.JLayeredPane;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class WindowingLayeredCanvas extends JLayeredPane implements ComponentListener {
+
+    private static final int ImageHeight = 384;
+    private static final int ImageWidth = 384;
+    public WindowingImagePanel imgpanel;
+    public WindowingTextOverlay textOverlay;
+    public WindowingCanvas canvas;
+    private String filePath = "";
+
+    public WindowingLayeredCanvas() {
+    }
+
+    public WindowingLayeredCanvas(String filePath) {
+        this.filePath = filePath;
+        constitudeChild();
+    }
+
+    private void constitudeChild() {
+        this.setBackground(Color.BLACK);
+        this.setLayout(null);
+        createImageCanvas(filePath);
+        createTextOverlay();
+        setTextOverlayParam();
+        findMultiframeStatus();
+        createLayers();
+        this.addComponentListener(this);
+    }
+
+    private void createLayers() {
+        this.add(canvas, Integer.valueOf(0));
+        this.add(textOverlay, Integer.valueOf(1));
+    }
+
+    private void createImageCanvas(String filePath) {
+        canvas = new WindowingCanvas(this);
+        canvas.setSize(ImageWidth, ImageHeight);
+        imgpanel = new WindowingImagePanel(filePath, canvas);
+        imgpanel.setSize(ImageWidth, ImageHeight);
+        canvas.add(imgpanel);
+    }
+
+    private void createTextOverlay() {
+        textOverlay = new WindowingTextOverlay(this);
+        textOverlay.setForeground(Color.white);
+        textOverlay.setSize(new Dimension(ImageWidth, ImageHeight));
+    }
+
+    private void setTextOverlayParam() {
+        TextOverlayParam textOverlayParam = new TextOverlayParam();
+        if (imgpanel.getPatientID() != null) {
+            textOverlayParam.setPatientID(imgpanel.getPatientID());
+        }
+
+        if (imgpanel.getPatientName() != null) {
+            textOverlayParam.setPatientName(imgpanel.getPatientName());
+        }
+
+        if (imgpanel.getInstitutionName() != null) {
+            textOverlayParam.setInstitutionName(imgpanel.getInstitutionName());
+        }
+
+        if (imgpanel.getBodyPartExamined() != null) {
+            textOverlayParam.setBodyPartExamined(imgpanel.getBodyPartExamined());
+        }
+
+        if (imgpanel.getPatientPosition() != null) {
+            textOverlayParam.setPatientPosition(imgpanel.getPatientPosition());
+        }
+
+
+        if (imgpanel.getSex() != null) {
+            textOverlayParam.setSex(imgpanel.getSex());
+        }
+
+        if (imgpanel.getStudyDate() != null) {
+            textOverlayParam.setStudyDate(imgpanel.getStudyDate());
+        }
+
+        if (imgpanel.getStudyTime() != null) {
+            textOverlayParam.setStudyTime(imgpanel.getStudyTime());
+        }
+
+        if (imgpanel.getWindowLevel() != -1) {
+            textOverlayParam.setWindowLevel(Integer.toString(imgpanel.getWindowLevel()));
+        }
+
+        if (imgpanel.getWindowWidth() != -1) {
+            textOverlayParam.setWindowWidth(Integer.toString(imgpanel.getWindowWidth()));
+        }
+
+        if (imgpanel.getCurrentInstanceNo() != -1) {            
+            textOverlayParam.setCurrentInstance(imgpanel.getCurrentInstanceNo());
+        }
+
+        if (imgpanel.getTotalInstance() != -1) {
+            textOverlayParam.setTotalInstance(Integer.toString(imgpanel.getTotalInstance()));
+        }
+
+        textOverlay.setTextOverlayParam(textOverlayParam);
+    }
+    public void findMultiframeStatus()
+    {
+        if (imgpanel.isMulitiFrame()) {
+          textOverlay.multiframeStatusDisplay(true);
+           if(!ApplicationContext.databaseRef.getMultiframeStatus())
+          textOverlay.getTextOverlayParam().setFramePosition("1/"+imgpanel.getnFrames());
+        }
+        else
+            textOverlay.multiframeStatusDisplay(false);
+       
+
+    }
+    public void centerImagePanel() {
+        int xPosition = (this.getSize().width - imgpanel.getSize().width) / 2;
+        int yPosition = (this.getSize().height - imgpanel.getSize().height) / 2;
+        imgpanel.setBounds(xPosition, yPosition, imgpanel.getSize().width, imgpanel.getSize().height);
+    }
+
+    public String getFilePath() {
+        return filePath;
+    }
+
+    public void setFilePath(String filePath) {
+        this.filePath = filePath;
+    }
+
+    public void clearAll() {
+        imgpanel.removeAll();
+        textOverlay.removeAll();
+        canvas.removeAll();
+        this.removeAll();
+    }
+
+    public void componentResized(ComponentEvent e) {
+        try {
+            this.canvas.resizeHandler();
+            this.imgpanel.resizeHandler();
+            this.textOverlay.resizeHandler();
+        } catch (Exception ex) {ex.printStackTrace();
+        }
+
+    }
+
+    public void componentMoved(ComponentEvent e) {
+    }
+
+    public void componentShown(ComponentEvent e) {
+    }
+
+    public void componentHidden(ComponentEvent e) {
+    }
+
+    public WindowingImagePanel getImgpanel() {
+        return imgpanel;
+    }
+
+}
diff --git a/src/in/raster/mayam/form/WindowingManagerPanel.form b/src/in/raster/mayam/form/WindowingManagerPanel.form
new file mode 100644
index 0000000..c760140
--- /dev/null
+++ b/src/in/raster/mayam/form/WindowingManagerPanel.form
@@ -0,0 +1,146 @@
+<?xml version="1.1" encoding="UTF-8" ?>
+
+<Form version="1.5" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Component id="jLabel1" alignment="0" pref="452" max="32767" attributes="0"/>
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="jLabel2" min="-2" max="-2" attributes="0"/>
+              <EmptySpace pref="378" max="32767" attributes="0"/>
+          </Group>
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="jComboBox1" min="-2" pref="97" max="-2" attributes="0"/>
+              <EmptySpace pref="338" max="32767" attributes="0"/>
+          </Group>
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="jScrollPane1" pref="412" max="32767" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+          <Group type="102" alignment="1" attributes="0">
+              <EmptySpace pref="327" max="32767" attributes="0"/>
+              <Component id="addButton" min="-2" max="-2" attributes="0"/>
+              <EmptySpace min="-2" pref="50" max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="0" attributes="0">
+              <Component id="jLabel1" min="-2" pref="24" max="-2" attributes="0"/>
+              <EmptySpace type="unrelated" max="-2" attributes="0"/>
+              <Component id="jLabel2" min="-2" max="-2" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="jComboBox1" min="-2" max="-2" attributes="0"/>
+              <EmptySpace min="-2" pref="13" max="-2" attributes="0"/>
+              <Component id="addButton" min="-2" max="-2" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="jScrollPane1" pref="167" max="32767" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Component class="javax.swing.JLabel" name="jLabel1">
+      <Properties>
+        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="0" green="0" red="0" type="rgb"/>
+        </Property>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Courier New" size="16" style="1"/>
+        </Property>
+        <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="0" green="8a" red="ff" type="rgb"/>
+        </Property>
+        <Property name="text" type="java.lang.String" value="Preset"/>
+        <Property name="opaque" type="boolean" value="true"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="jLabel2">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Modality"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JComboBox" name="jComboBox1">
+      <Properties>
+        <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+          <Connection code="new ModalityComboModel(ApplicationContext.databaseRef.getModalities())" type="code"/>
+        </Property>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jComboBox1ActionPerformed"/>
+      </Events>
+    </Component>
+    <Container class="javax.swing.JScrollPane" name="jScrollPane1">
+      <AuxValues>
+        <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+      </AuxValues>
+
+      <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+      <SubComponents>
+        <Component class="javax.swing.JTable" name="jTable1">
+          <Properties>
+            <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+              <Font name="Courier" size="12" style="1"/>
+            </Property>
+            <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor" postCode="jTable1.setDefaultRenderer(Object.class, new CellRenderer());&#xa;//jTable1.getTableHeader().setPreferredSize(new Dimension(jScrollPane1.WIDTH,24));;&#xa;//Font f=jTable1.getFont();&#xa;//jTable1.getTableHeader().setFont(new Font(f.getName(),Font.PLAIN,12));;&#xa;//jTable1.setRowHeight(24);">
+              <Connection code="new PresetTableModel()" type="code"/>
+            </Property>
+            <Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor">
+              <TableColumnModel selectionModel="0">
+                <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
+                  <Title/>
+                  <Editor/>
+                  <Renderer/>
+                </Column>
+                <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
+                  <Title/>
+                  <Editor/>
+                  <Renderer/>
+                </Column>
+                <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
+                  <Title/>
+                  <Editor/>
+                  <Renderer/>
+                </Column>
+              </TableColumnModel>
+            </Property>
+            <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor">
+              <TableHeader reorderingAllowed="true" resizingAllowed="true"/>
+            </Property>
+          </Properties>
+          <AuxValues>
+            <AuxValue name="JavaCodeGenerator_InitCodePost" type="java.lang.String" value="jTable1.getTableHeader().setPreferredSize(new Dimension(this.getWidth(), 25));&#xa;Font ff=new Font("Courier New",Font.BOLD,12);&#xa;jTable1.getTableHeader().setFont(ff);&#xa;jTable1.setRowHeight(20);&#xa;jTable1.getTableHeader().setForeground(new Color(255,138,0));&#xa;jTable1.getTableHeader().setBackground(new Color(0,0,0));"/>
+          </AuxValues>
+        </Component>
+      </SubComponents>
+    </Container>
+    <Component class="javax.swing.JButton" name="addButton">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Add"/>
+        <Property name="focusable" type="boolean" value="false"/>
+        <Property name="horizontalTextPosition" type="int" value="0"/>
+        <Property name="verticalTextPosition" type="int" value="3"/>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="addButtonActionPerformed"/>
+      </Events>
+    </Component>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/WindowingManagerPanel.java b/src/in/raster/mayam/form/WindowingManagerPanel.java
new file mode 100644
index 0000000..5f5d7fe
--- /dev/null
+++ b/src/in/raster/mayam/form/WindowingManagerPanel.java
@@ -0,0 +1,213 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.model.PresetModel;
+import in.raster.mayam.model.combo.ModalityComboModel;
+import in.raster.mayam.model.table.PresetTableModel;
+import in.raster.mayam.model.table.renderer.CellRenderer;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import javax.swing.JOptionPane;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class WindowingManagerPanel extends javax.swing.JPanel implements KeyListener {
+
+    /** Creates new form WindowingManagerPanel */
+    public WindowingManagerPanel() {
+        initComponents();
+        initializeDefault();
+    }
+
+    public void initializeDefault() {
+        jComboBox1.setSelectedIndex(0);
+        setPresetTableModel();
+        jTable1.addKeyListener(this);
+
+    }
+
+    private void setPresetTableModel() {
+        PresetTableModel presetTableModel = new PresetTableModel();
+        presetTableModel.setData(ApplicationContext.databaseRef.getPresetValueForModality((String) jComboBox1.getSelectedItem()));
+        jTable1.setModel(presetTableModel);
+
+    }
+
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        jLabel1 = new javax.swing.JLabel();
+        jLabel2 = new javax.swing.JLabel();
+        jComboBox1 = new javax.swing.JComboBox();
+        jScrollPane1 = new javax.swing.JScrollPane();
+        jTable1 = new javax.swing.JTable();
+        addButton = new javax.swing.JButton();
+
+        jLabel1.setBackground(new java.awt.Color(0, 0, 0));
+        jLabel1.setFont(new java.awt.Font("Courier New", 1, 16)); // NOI18N
+        jLabel1.setForeground(new java.awt.Color(255, 138, 0));
+        jLabel1.setText("Preset");
+        jLabel1.setOpaque(true);
+
+        jLabel2.setText("Modality");
+
+        jComboBox1.setModel(new ModalityComboModel(ApplicationContext.databaseRef.getModalities()));
+        jComboBox1.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                jComboBox1ActionPerformed(evt);
+            }
+        });
+
+        jTable1.setFont(new java.awt.Font("Courier", 1, 12)); // NOI18N
+        jTable1.setModel(new PresetTableModel());
+        jTable1.setDefaultRenderer(Object.class, new CellRenderer());
+        //jTable1.getTableHeader().setPreferredSize(new Dimension(jScrollPane1.WIDTH,24));;
+        //Font f=jTable1.getFont();
+        //jTable1.getTableHeader().setFont(new Font(f.getName(),Font.PLAIN,12));;
+        //jTable1.setRowHeight(24);
+        jTable1.getTableHeader().setPreferredSize(new Dimension(this.getWidth(), 25));
+        Font ff=new Font("Courier New",Font.BOLD,12);
+        jTable1.getTableHeader().setFont(ff);
+        jTable1.setRowHeight(20);
+        jTable1.getTableHeader().setForeground(new Color(255,138,0));
+        jTable1.getTableHeader().setBackground(new Color(0,0,0));
+        jScrollPane1.setViewportView(jTable1);
+
+        addButton.setText("Add");
+        addButton.setFocusable(false);
+        addButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+        addButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        addButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                addButtonActionPerformed(evt);
+            }
+        });
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
+        this.setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 452, Short.MAX_VALUE)
+            .add(layout.createSequentialGroup()
+                .addContainerGap()
+                .add(jLabel2)
+                .addContainerGap(378, Short.MAX_VALUE))
+            .add(layout.createSequentialGroup()
+                .addContainerGap()
+                .add(jComboBox1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 97, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addContainerGap(338, Short.MAX_VALUE))
+            .add(layout.createSequentialGroup()
+                .addContainerGap()
+                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 412, Short.MAX_VALUE)
+                .addContainerGap())
+            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+                .addContainerGap(327, Short.MAX_VALUE)
+                .add(addButton)
+                .add(50, 50, 50))
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(layout.createSequentialGroup()
+                .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 24, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+                .add(jLabel2)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(jComboBox1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .add(13, 13, 13)
+                .add(addButton)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 167, Short.MAX_VALUE)
+                .addContainerGap())
+        );
+    }// </editor-fold>//GEN-END:initComponents
+
+    private void addButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addButtonActionPerformed
+        PresetModel presetModel = new PresetModel();
+        presetModel.setPresetName("PRESETNAME");
+        presetModel.setWindowLevel("0");
+        presetModel.setWindowWidth("0");
+        ApplicationContext.databaseRef.insertPreset(presetModel, (String) jComboBox1.getSelectedItem());
+        setPresetTableModel();
+}//GEN-LAST:event_addButtonActionPerformed
+
+    private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
+        setPresetTableModel();
+    }//GEN-LAST:event_jComboBox1ActionPerformed
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JButton addButton;
+    private javax.swing.JComboBox jComboBox1;
+    private javax.swing.JLabel jLabel1;
+    private javax.swing.JLabel jLabel2;
+    private javax.swing.JScrollPane jScrollPane1;
+    private javax.swing.JTable jTable1;
+    // End of variables declaration//GEN-END:variables
+
+    public void keyTyped(KeyEvent e) {
+    }
+
+    public void keyPressed(KeyEvent e) {
+        if (e.getKeyCode() == KeyEvent.VK_DELETE) {
+            int deletePreset = 0;
+            deletePreset = JOptionPane.showConfirmDialog(this, "Are you sure want to delete the preset", "Confirmation Dialog", JOptionPane.YES_NO_OPTION);
+            if (deletePreset == 0) {
+                if (jTable1.getSelectedRow() != -1) {
+                    PresetModel presetModel = ((PresetTableModel) jTable1.getModel()).getRow(jTable1.getSelectedRow());
+                    ApplicationContext.databaseRef.deletePreset(presetModel);
+                    setPresetTableModel();
+                }
+            }
+        }
+    }
+    public void keyReleased(KeyEvent e) {
+    }
+}
diff --git a/src/in/raster/mayam/form/WindowingTextOverlay.form b/src/in/raster/mayam/form/WindowingTextOverlay.form
new file mode 100644
index 0000000..8509125
--- /dev/null
+++ b/src/in/raster/mayam/form/WindowingTextOverlay.form
@@ -0,0 +1,283 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Component id="patientNameLabel" alignment="0" pref="185" max="32767" attributes="0"/>
+                  <Group type="102" alignment="0" attributes="0">
+                      <Component id="patientIDLabel" min="-2" pref="150" max="-2" attributes="0"/>
+                      <EmptySpace pref="35" max="-2" attributes="0"/>
+                  </Group>
+                  <Component id="windowingLabel" alignment="0" pref="185" max="32767" attributes="0"/>
+                  <Component id="slicePositionLabel" alignment="0" pref="185" max="32767" attributes="0"/>
+                  <Component id="instanceNoLabel" alignment="0" pref="185" max="32767" attributes="0"/>
+              </Group>
+              <EmptySpace max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Component id="frameNumberText" alignment="1" min="-2" pref="147" max="-2" attributes="0"/>
+                  <Component id="patientPositionLabel" alignment="1" pref="160" max="32767" attributes="1"/>
+                  <Component id="multiframeStatusText" alignment="1" min="-2" pref="77" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
+          </Group>
+          <Group type="102" alignment="1" attributes="0">
+              <EmptySpace pref="151" max="32767" attributes="0"/>
+              <Component id="studyTimeLabel" pref="204" max="32767" attributes="1"/>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+          <Group type="102" alignment="1" attributes="0">
+              <EmptySpace pref="152" max="32767" attributes="0"/>
+              <Component id="studyDateLabel" pref="203" max="32767" attributes="1"/>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+          <Group type="102" attributes="0">
+              <EmptySpace min="300" pref="300" max="300" attributes="0"/>
+              <Group type="103" groupAlignment="1" attributes="0">
+                  <Component id="jLabel8" alignment="0" min="-2" max="-2" attributes="1"/>
+                  <Group type="102" alignment="1" attributes="0">
+                      <Component id="institutionLabel" max="32767" attributes="1"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                  </Group>
+              </Group>
+          </Group>
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="patientSexLabel" min="-2" pref="71" max="-2" attributes="0"/>
+              <EmptySpace pref="286" max="32767" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Group type="102" attributes="0">
+                      <Component id="institutionLabel" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="studyDateLabel" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="studyTimeLabel" linkSize="1" min="-2" max="-2" attributes="0"/>
+                  </Group>
+                  <Group type="102" attributes="1">
+                      <Component id="patientNameLabel" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="patientIDLabel" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace min="-2" pref="5" max="-2" attributes="0"/>
+                      <Component id="patientSexLabel" linkSize="1" max="32767" attributes="0"/>
+                  </Group>
+              </Group>
+              <EmptySpace min="-2" max="-2" attributes="0"/>
+              <Component id="jLabel8" min="-2" max="-2" attributes="0"/>
+              <EmptySpace pref="40" max="32767" attributes="0"/>
+              <Group type="103" groupAlignment="1" attributes="0">
+                  <Group type="102" alignment="0" attributes="0">
+                      <Component id="instanceNoLabel" linkSize="2" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="windowingLabel" linkSize="2" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="slicePositionLabel" linkSize="2" min="-2" pref="16" max="-2" attributes="0"/>
+                  </Group>
+                  <Group type="102" alignment="0" attributes="0">
+                      <Component id="multiframeStatusText" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="frameNumberText" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="patientPositionLabel" min="-2" max="-2" attributes="0"/>
+                  </Group>
+              </Group>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Component class="javax.swing.JLabel" name="patientNameLabel">
+      <Properties>
+        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="0" green="0" red="0" type="rgb"/>
+        </Property>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Lucida Grande" size="12" style="0"/>
+        </Property>
+        <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="ff" green="ff" red="ff" type="rgb"/>
+        </Property>
+        <Property name="text" type="java.lang.String" value="Name"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="patientSexLabel">
+      <Properties>
+        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="0" green="0" red="0" type="rgb"/>
+        </Property>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Lucida Grande" size="12" style="0"/>
+        </Property>
+        <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="ff" green="ff" red="ff" type="rgb"/>
+        </Property>
+        <Property name="text" type="java.lang.String" value="Sex"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="patientIDLabel">
+      <Properties>
+        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="0" green="0" red="0" type="rgb"/>
+        </Property>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Lucida Grande" size="12" style="0"/>
+        </Property>
+        <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="ff" green="ff" red="ff" type="rgb"/>
+        </Property>
+        <Property name="text" type="java.lang.String" value="ID"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="studyTimeLabel">
+      <Properties>
+        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="0" green="0" red="0" type="rgb"/>
+        </Property>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Lucida Grande" size="12" style="0"/>
+        </Property>
+        <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="ff" green="ff" red="ff" type="rgb"/>
+        </Property>
+        <Property name="horizontalAlignment" type="int" value="4"/>
+        <Property name="text" type="java.lang.String" value="Study Time"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="studyDateLabel">
+      <Properties>
+        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="0" green="0" red="0" type="rgb"/>
+        </Property>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Lucida Grande" size="12" style="0"/>
+        </Property>
+        <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="ff" green="ff" red="ff" type="rgb"/>
+        </Property>
+        <Property name="horizontalAlignment" type="int" value="4"/>
+        <Property name="text" type="java.lang.String" value="Study Date"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="institutionLabel">
+      <Properties>
+        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="0" green="0" red="0" type="rgb"/>
+        </Property>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Lucida Grande" size="12" style="0"/>
+        </Property>
+        <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="ff" green="ff" red="ff" type="rgb"/>
+        </Property>
+        <Property name="horizontalAlignment" type="int" value="4"/>
+        <Property name="text" type="java.lang.String" value="Institution"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="jLabel8">
+      <Properties>
+        <Property name="horizontalAlignment" type="int" value="4"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="patientPositionLabel">
+      <Properties>
+        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="0" green="0" red="0" type="rgb"/>
+        </Property>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Lucida Grande" size="12" style="0"/>
+        </Property>
+        <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="ff" green="ff" red="ff" type="rgb"/>
+        </Property>
+        <Property name="horizontalAlignment" type="int" value="4"/>
+        <Property name="text" type="java.lang.String" value="Patient Position"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="instanceNoLabel">
+      <Properties>
+        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="0" green="0" red="0" type="rgb"/>
+        </Property>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Lucida Grande" size="12" style="0"/>
+        </Property>
+        <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="ff" green="ff" red="ff" type="rgb"/>
+        </Property>
+        <Property name="text" type="java.lang.String" value="Im"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="windowingLabel">
+      <Properties>
+        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="0" green="0" red="0" type="rgb"/>
+        </Property>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Lucida Grande" size="12" style="0"/>
+        </Property>
+        <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="ff" green="ff" red="ff" type="rgb"/>
+        </Property>
+        <Property name="text" type="java.lang.String" value="Windowing"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="slicePositionLabel">
+      <Properties>
+        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="0" green="0" red="0" type="rgb"/>
+        </Property>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Lucida Grande" size="12" style="0"/>
+        </Property>
+        <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="ff" green="ff" red="ff" type="rgb"/>
+        </Property>
+        <Property name="text" type="java.lang.String" value="Slice Position"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="frameNumberText">
+      <Properties>
+        <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="ff" green="ff" id="white" palette="1" red="ff" type="palette"/>
+        </Property>
+        <Property name="horizontalAlignment" type="int" value="4"/>
+        <Property name="text" type="java.lang.String" value="Frame"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="multiframeStatusText">
+      <Properties>
+        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="99" green="ff" red="ff" type="rgb"/>
+        </Property>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Lucida Grande" size="14" style="0"/>
+        </Property>
+        <Property name="horizontalAlignment" type="int" value="4"/>
+        <Property name="text" type="java.lang.String" value="Multiframe"/>
+        <Property name="opaque" type="boolean" value="true"/>
+      </Properties>
+    </Component>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/WindowingTextOverlay.java b/src/in/raster/mayam/form/WindowingTextOverlay.java
new file mode 100644
index 0000000..accd378
--- /dev/null
+++ b/src/in/raster/mayam/form/WindowingTextOverlay.java
@@ -0,0 +1,352 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.param.TextOverlayParam;
+import java.awt.Graphics;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class WindowingTextOverlay extends javax.swing.JPanel {
+
+    /** Creates new form DateFormatPanel */
+    private TextOverlayParam textOverlayParam;
+    WindowingLayeredCanvas layeredCanvas;
+    private boolean firstTime = true;
+    private boolean textOverlay = true;
+    private boolean showProbeFlag = false;
+
+    public WindowingTextOverlay(WindowingLayeredCanvas l) {
+        initComponents();
+        textOverlayParam = new TextOverlayParam();
+        this.setOpaque(false);
+        layeredCanvas = l;
+    }
+
+    public void setWindowingParameter(String WL, String WW) {
+        textOverlayParam.setWindowingParameter(WL, WW);
+        this.repaint();
+    }
+
+    public TextOverlayParam getTextOverlayParam() {
+        return textOverlayParam;
+    }
+
+    public void setTextOverlayParam(TextOverlayParam textOverlayParam) {
+        this.textOverlayParam = textOverlayParam;
+    }
+
+    public void doTextOverlay() {
+        if (textOverlay) {
+            textOverlay = false;
+            this.repaint();
+        } else {
+            textOverlay = true;
+            this.repaint();
+        }
+    }
+
+    public void updateCurrentInstanceNo(int currentInstanceNo) {
+        textOverlayParam.setCurrentInstance(currentInstanceNo);
+        this.repaint();
+    }
+
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        patientNameLabel = new javax.swing.JLabel();
+        patientSexLabel = new javax.swing.JLabel();
+        patientIDLabel = new javax.swing.JLabel();
+        studyTimeLabel = new javax.swing.JLabel();
+        studyDateLabel = new javax.swing.JLabel();
+        institutionLabel = new javax.swing.JLabel();
+        jLabel8 = new javax.swing.JLabel();
+        patientPositionLabel = new javax.swing.JLabel();
+        instanceNoLabel = new javax.swing.JLabel();
+        windowingLabel = new javax.swing.JLabel();
+        slicePositionLabel = new javax.swing.JLabel();
+        frameNumberText = new javax.swing.JLabel();
+        multiframeStatusText = new javax.swing.JLabel();
+
+        patientNameLabel.setBackground(new java.awt.Color(0, 0, 0));
+        patientNameLabel.setFont(new java.awt.Font("Lucida Grande", 0, 12));
+        patientNameLabel.setForeground(new java.awt.Color(255, 255, 255));
+        patientNameLabel.setText("Name");
+
+        patientSexLabel.setBackground(new java.awt.Color(0, 0, 0));
+        patientSexLabel.setFont(new java.awt.Font("Lucida Grande", 0, 12)); // NOI18N
+        patientSexLabel.setForeground(new java.awt.Color(255, 255, 255));
+        patientSexLabel.setText("Sex");
+
+        patientIDLabel.setBackground(new java.awt.Color(0, 0, 0));
+        patientIDLabel.setFont(new java.awt.Font("Lucida Grande", 0, 12));
+        patientIDLabel.setForeground(new java.awt.Color(255, 255, 255));
+        patientIDLabel.setText("ID");
+
+        studyTimeLabel.setBackground(new java.awt.Color(0, 0, 0));
+        studyTimeLabel.setFont(new java.awt.Font("Lucida Grande", 0, 12));
+        studyTimeLabel.setForeground(new java.awt.Color(255, 255, 255));
+        studyTimeLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
+        studyTimeLabel.setText("Study Time");
+
+        studyDateLabel.setBackground(new java.awt.Color(0, 0, 0));
+        studyDateLabel.setFont(new java.awt.Font("Lucida Grande", 0, 12));
+        studyDateLabel.setForeground(new java.awt.Color(255, 255, 255));
+        studyDateLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
+        studyDateLabel.setText("Study Date");
+
+        institutionLabel.setBackground(new java.awt.Color(0, 0, 0));
+        institutionLabel.setFont(new java.awt.Font("Lucida Grande", 0, 12));
+        institutionLabel.setForeground(new java.awt.Color(255, 255, 255));
+        institutionLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
+        institutionLabel.setText("Institution");
+
+        jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
+
+        patientPositionLabel.setBackground(new java.awt.Color(0, 0, 0));
+        patientPositionLabel.setFont(new java.awt.Font("Lucida Grande", 0, 12)); // NOI18N
+        patientPositionLabel.setForeground(new java.awt.Color(255, 255, 255));
+        patientPositionLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
+        patientPositionLabel.setText("Patient Position");
+
+        instanceNoLabel.setBackground(new java.awt.Color(0, 0, 0));
+        instanceNoLabel.setFont(new java.awt.Font("Lucida Grande", 0, 12));
+        instanceNoLabel.setForeground(new java.awt.Color(255, 255, 255));
+        instanceNoLabel.setText("Im");
+
+        windowingLabel.setBackground(new java.awt.Color(0, 0, 0));
+        windowingLabel.setFont(new java.awt.Font("Lucida Grande", 0, 12));
+        windowingLabel.setForeground(new java.awt.Color(255, 255, 255));
+        windowingLabel.setText("Windowing");
+
+        slicePositionLabel.setBackground(new java.awt.Color(0, 0, 0));
+        slicePositionLabel.setFont(new java.awt.Font("Lucida Grande", 0, 12));
+        slicePositionLabel.setForeground(new java.awt.Color(255, 255, 255));
+        slicePositionLabel.setText("Slice Position");
+
+        frameNumberText.setForeground(java.awt.Color.white);
+        frameNumberText.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
+        frameNumberText.setText("Frame");
+
+        multiframeStatusText.setBackground(new java.awt.Color(255, 255, 153));
+        multiframeStatusText.setFont(new java.awt.Font("Lucida Grande", 0, 14)); // NOI18N
+        multiframeStatusText.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
+        multiframeStatusText.setText("Multiframe");
+        multiframeStatusText.setOpaque(true);
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
+        this.setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(layout.createSequentialGroup()
+                .addContainerGap()
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                    .add(patientNameLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 185, Short.MAX_VALUE)
+                    .add(layout.createSequentialGroup()
+                        .add(patientIDLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 150, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 35, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+                    .add(windowingLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 185, Short.MAX_VALUE)
+                    .add(slicePositionLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 185, Short.MAX_VALUE)
+                    .add(instanceNoLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 185, Short.MAX_VALUE))
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                    .add(org.jdesktop.layout.GroupLayout.TRAILING, frameNumberText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 147, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                    .add(org.jdesktop.layout.GroupLayout.TRAILING, patientPositionLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE)
+                    .add(org.jdesktop.layout.GroupLayout.TRAILING, multiframeStatusText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 77, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+                .add(12, 12, 12))
+            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+                .addContainerGap(151, Short.MAX_VALUE)
+                .add(studyTimeLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 204, Short.MAX_VALUE)
+                .addContainerGap())
+            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+                .addContainerGap(152, Short.MAX_VALUE)
+                .add(studyDateLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 203, Short.MAX_VALUE)
+                .addContainerGap())
+            .add(layout.createSequentialGroup()
+                .add(300, 300, 300)
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+                    .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel8)
+                    .add(layout.createSequentialGroup()
+                        .add(institutionLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                        .addContainerGap())))
+            .add(layout.createSequentialGroup()
+                .addContainerGap()
+                .add(patientSexLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 71, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addContainerGap(286, Short.MAX_VALUE))
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(layout.createSequentialGroup()
+                .addContainerGap()
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                    .add(layout.createSequentialGroup()
+                        .add(institutionLabel)
+                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                        .add(studyDateLabel)
+                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                        .add(studyTimeLabel))
+                    .add(layout.createSequentialGroup()
+                        .add(patientNameLabel)
+                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                        .add(patientIDLabel)
+                        .add(5, 5, 5)
+                        .add(patientSexLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(jLabel8)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 40, Short.MAX_VALUE)
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+                    .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
+                        .add(instanceNoLabel)
+                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                        .add(windowingLabel)
+                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                        .add(slicePositionLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 16, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+                    .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
+                        .add(multiframeStatusText)
+                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                        .add(frameNumberText)
+                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                        .add(patientPositionLabel)))
+                .addContainerGap())
+        );
+
+        layout.linkSize(new java.awt.Component[] {patientSexLabel, studyTimeLabel}, org.jdesktop.layout.GroupLayout.VERTICAL);
+
+        layout.linkSize(new java.awt.Component[] {instanceNoLabel, slicePositionLabel, windowingLabel}, org.jdesktop.layout.GroupLayout.VERTICAL);
+
+    }// </editor-fold>//GEN-END:initComponents
+
+    private void setTextOverlay() {
+        patientNameLabel.setText(" " + textOverlayParam.getPatientName());
+        patientIDLabel.setText(" " + "ID: " + textOverlayParam.getPatientID());
+        if (textOverlayParam.getSex() != null && !textOverlayParam.getSex().equalsIgnoreCase("")) {
+            patientSexLabel.setText(" Sex: " + textOverlayParam.getSex());
+        } else {
+            patientSexLabel.setText("");
+        }
+        patientPositionLabel.setText("Position:" + textOverlayParam.getPatientPosition() + "");
+        studyDateLabel.setText("Study Date: " + textOverlayParam.getStudyDate() + " ");
+        //studyTimeLabel.setText("Study Time: " + textOverlayParam.getStudyTime() + " ");
+        slicePositionLabel.setText(" " + "Slice pos: " + textOverlayParam.getSlicePosition());
+        int currentInstanceNo;
+        if (!ApplicationContext.databaseRef.getMultiframeStatus()) {
+            currentInstanceNo = (textOverlayParam.getCurrentInstance() != 0) ? textOverlayParam.getCurrentInstance() : 1;
+        } else {
+            currentInstanceNo = textOverlayParam.getCurrentInstance() + 1;
+        }
+        int totalNo = Integer.parseInt(textOverlayParam.getTotalInstance());
+        instanceNoLabel.setText(" " + "Im :" + currentInstanceNo + "/" + totalNo);
+        institutionLabel.setText(textOverlayParam.getInstitutionName() + " ");
+        windowingLabel.setText(" " + "W " + textOverlayParam.getWindowWidth() + "/ C " + textOverlayParam.getWindowLevel());
+        if (!textOverlayParam.getFramePosition().equalsIgnoreCase("")) {
+            frameNumberText.setText("Frame: " + textOverlayParam.getFramePosition());
+        } else {
+            frameNumberText.setText("");
+        }
+    }
+
+    private void setTextOverlayToNull() {
+        patientNameLabel.setText("");
+        patientIDLabel.setText("");
+        patientSexLabel.setText("");
+        patientPositionLabel.setText("");
+        studyDateLabel.setText("");
+        studyTimeLabel.setText("");
+        slicePositionLabel.setText("");
+        instanceNoLabel.setText("");
+        institutionLabel.setText("");
+        windowingLabel.setText("");
+
+    }
+
+    public void resizeHandler() {
+        this.firstTime = true;
+        this.repaint();
+    }
+
+    public void multiframeStatusDisplay(boolean status) {
+        multiframeStatusText.setVisible(status);
+    }
+
+    @Override
+    public void paint(Graphics g) {
+        super.paint(g);
+        if (textOverlay) {
+            setTextOverlay();
+        } else {
+            setTextOverlayToNull();
+        }
+        if (firstTime) {
+            this.setSize(layeredCanvas.getSize().width, layeredCanvas.getSize().height);
+            firstTime = false;
+            setTextOverlayToNull();
+            repaint();
+        }
+        showProbeFlag = false;
+    }
+
+    public void setFirstTime(boolean firstTime) {
+        this.firstTime = firstTime;
+    }
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JLabel frameNumberText;
+    private javax.swing.JLabel instanceNoLabel;
+    private javax.swing.JLabel institutionLabel;
+    private javax.swing.JLabel jLabel8;
+    private javax.swing.JLabel multiframeStatusText;
+    private javax.swing.JLabel patientIDLabel;
+    private javax.swing.JLabel patientNameLabel;
+    private javax.swing.JLabel patientPositionLabel;
+    private javax.swing.JLabel patientSexLabel;
+    private javax.swing.JLabel slicePositionLabel;
+    private javax.swing.JLabel studyDateLabel;
+    private javax.swing.JLabel studyTimeLabel;
+    private javax.swing.JLabel windowingLabel;
+    // End of variables declaration//GEN-END:variables
+}
diff --git a/src/in/raster/mayam/form/dcm3d/DicomMIP.form b/src/in/raster/mayam/form/dcm3d/DicomMIP.form
new file mode 100644
index 0000000..d1bd446
--- /dev/null
+++ b/src/in/raster/mayam/form/dcm3d/DicomMIP.form
@@ -0,0 +1,228 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
+  <Properties>
+    <Property name="defaultCloseOperation" type="int" value="2"/>
+    <Property name="title" type="java.lang.String" value="3D Maximum Intensity Projection (MIP)"/>
+    <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
+      <Color id="Default Cursor"/>
+    </Property>
+    <Property name="resizable" type="boolean" value="false"/>
+  </Properties>
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <Events>
+    <EventHandler event="windowClosed" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="formWindowClosed"/>
+  </Events>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="1" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="1" attributes="0">
+                  <Component id="pnlMIPViewer" alignment="0" max="32767" attributes="1"/>
+                  <Group type="102" alignment="1" attributes="0">
+                      <Component id="lblZoomInOutMIP" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="lblRotateMIP" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace min="-2" pref="9" max="-2" attributes="0"/>
+                      <Component id="lblMoveMIP" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="lblCubeBoxMIP" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="lblResetMIP" min="-2" pref="22" max="-2" attributes="0"/>
+                      <EmptySpace min="-2" pref="57" max="-2" attributes="0"/>
+                      <Component id="lblCaptureScreenShot" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace type="separate" max="-2" attributes="0"/>
+                      <Component id="pnlselectedBackgroundColor" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace min="-2" pref="231" max="-2" attributes="0"/>
+                      <Component id="lblDisplayPurpose" pref="501" max="32767" attributes="1"/>
+                  </Group>
+              </Group>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="0" max="-2" attributes="0">
+                  <Component id="lblMoveMIP" alignment="0" max="32767" attributes="1"/>
+                  <Component id="lblResetMIP" alignment="0" max="32767" attributes="1"/>
+                  <Component id="lblCubeBoxMIP" alignment="0" max="32767" attributes="1"/>
+                  <Component id="lblZoomInOutMIP" alignment="0" max="32767" attributes="1"/>
+                  <Component id="lblDisplayPurpose" alignment="1" max="32767" attributes="1"/>
+                  <Component id="lblRotateMIP" alignment="0" max="32767" attributes="1"/>
+                  <Component id="lblCaptureScreenShot" alignment="0" max="32767" attributes="1"/>
+                  <Component id="pnlselectedBackgroundColor" alignment="0" max="32767" attributes="1"/>
+              </Group>
+              <EmptySpace min="-2" pref="30" max="-2" attributes="0"/>
+              <Component id="pnlMIPViewer" min="-2" max="-2" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Container class="javax.swing.JPanel" name="pnlMIPViewer">
+      <Properties>
+        <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+          <Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
+            <LineBorder/>
+          </Border>
+        </Property>
+      </Properties>
+
+      <Layout>
+        <DimensionLayout dim="0">
+          <Group type="103" groupAlignment="0" attributes="0">
+              <EmptySpace min="0" pref="1004" max="32767" attributes="0"/>
+          </Group>
+        </DimensionLayout>
+        <DimensionLayout dim="1">
+          <Group type="103" groupAlignment="0" attributes="0">
+              <EmptySpace min="0" pref="686" max="32767" attributes="0"/>
+          </Group>
+        </DimensionLayout>
+      </Layout>
+    </Container>
+    <Component class="javax.swing.JLabel" name="lblRotateMIP">
+      <Properties>
+        <Property name="horizontalAlignment" type="int" value="0"/>
+        <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+          <Image iconType="3" name="/in/raster/mayam/form/images/RotateSurface.png"/>
+        </Property>
+        <Property name="toolTipText" type="java.lang.String" value="Rotate the Volume"/>
+        <Property name="verticalAlignment" type="int" value="3"/>
+        <Property name="horizontalTextPosition" type="int" value="0"/>
+        <Property name="iconTextGap" type="int" value="0"/>
+        <Property name="verticalTextPosition" type="int" value="3"/>
+      </Properties>
+      <Events>
+        <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblRotateMIPMouseClicked"/>
+        <EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblRotateMIPMouseEntered"/>
+        <EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblRotateMIPMouseExited"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JLabel" name="lblMoveMIP">
+      <Properties>
+        <Property name="horizontalAlignment" type="int" value="0"/>
+        <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+          <Image iconType="3" name="/in/raster/mayam/form/images/Move.png"/>
+        </Property>
+        <Property name="toolTipText" type="java.lang.String" value="Move the Volume"/>
+        <Property name="verticalAlignment" type="int" value="3"/>
+      </Properties>
+      <Events>
+        <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblMoveMIPMouseClicked"/>
+        <EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblMoveMIPMouseEntered"/>
+        <EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblMoveMIPMouseExited"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JLabel" name="lblCubeBoxMIP">
+      <Properties>
+        <Property name="horizontalAlignment" type="int" value="0"/>
+        <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+          <Image iconType="3" name="/in/raster/mayam/form/images/ResetInteractor.png"/>
+        </Property>
+        <Property name="toolTipText" type="java.lang.String" value="Reset the Mouse Interaction"/>
+        <Property name="verticalAlignment" type="int" value="3"/>
+      </Properties>
+      <Events>
+        <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblCubeBoxMIPMouseClicked"/>
+        <EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblCubeBoxMIPMouseEntered"/>
+        <EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblCubeBoxMIPMouseExited"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JLabel" name="lblDisplayPurpose">
+      <Properties>
+        <Property name="horizontalAlignment" type="int" value="0"/>
+        <Property name="text" type="java.lang.String" value="3D Maximum Intensity Projection (MIP)"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="lblCaptureScreenShot">
+      <Properties>
+        <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+          <Image iconType="3" name="/in/raster/mayam/form/images/ScreenShot.png"/>
+        </Property>
+        <Property name="toolTipText" type="java.lang.String" value="Capture Screenshot"/>
+      </Properties>
+      <Events>
+        <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblCaptureScreenShotMouseClicked"/>
+        <EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblCaptureScreenShotMouseEntered"/>
+        <EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblCaptureScreenShotMouseExited"/>
+      </Events>
+    </Component>
+    <Container class="javax.swing.JPanel" name="pnlselectedBackgroundColor">
+      <Properties>
+        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="4" green="2" red="3" type="rgb"/>
+        </Property>
+        <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+          <Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
+            <LineBorder/>
+          </Border>
+        </Property>
+        <Property name="toolTipText" type="java.lang.String" value="Change Background Color"/>
+      </Properties>
+      <Events>
+        <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="pnlselectedBackgroundColorMouseClicked"/>
+        <EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="pnlselectedBackgroundColorMouseEntered"/>
+        <EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="pnlselectedBackgroundColorMouseExited"/>
+      </Events>
+
+      <Layout>
+        <DimensionLayout dim="0">
+          <Group type="103" groupAlignment="0" attributes="0">
+              <EmptySpace min="0" pref="22" max="32767" attributes="0"/>
+          </Group>
+        </DimensionLayout>
+        <DimensionLayout dim="1">
+          <Group type="103" groupAlignment="0" attributes="0">
+              <EmptySpace min="0" pref="22" max="32767" attributes="0"/>
+          </Group>
+        </DimensionLayout>
+      </Layout>
+    </Container>
+    <Component class="javax.swing.JLabel" name="lblZoomInOutMIP">
+      <Properties>
+        <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+          <Image iconType="3" name="/in/raster/mayam/form/images/ZoomInOut.png"/>
+        </Property>
+        <Property name="toolTipText" type="java.lang.String" value="Zoom In or Zoom Out the Volume"/>
+      </Properties>
+      <Events>
+        <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblZoomInOutMIPMouseClicked"/>
+        <EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblZoomInOutMIPMouseEntered"/>
+        <EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblZoomInOutMIPMouseExited"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JLabel" name="lblResetMIP">
+      <Properties>
+        <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+          <Image iconType="3" name="/in/raster/mayam/form/images/DrawCircle.png"/>
+        </Property>
+        <Property name="toolTipText" type="java.lang.String" value="Reset the Volume"/>
+      </Properties>
+      <Events>
+        <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblResetMIPMouseClicked"/>
+        <EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblResetMIPMouseEntered"/>
+        <EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblResetMIPMouseExited"/>
+      </Events>
+    </Component>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/dcm3d/DicomMIP.java b/src/in/raster/mayam/form/dcm3d/DicomMIP.java
new file mode 100644
index 0000000..01ebb60
--- /dev/null
+++ b/src/in/raster/mayam/form/dcm3d/DicomMIP.java
@@ -0,0 +1,794 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Guru Rajan R
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Sathish Kumar V
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form.dcm3d;
+
+import java.awt.Color;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionListener;
+import java.io.File;
+import javax.swing.JColorChooser;
+import javax.swing.JFileChooser;
+import javax.swing.filechooser.FileFilter;
+import vtk.vtkCamera;
+import vtk.vtkCanvas;
+import vtk.vtkColorTransferFunction;
+import vtk.vtkDICOMImageReader;
+import vtk.vtkImageShiftScale;
+import vtk.vtkLight;
+import vtk.vtkLightCollection;
+import vtk.vtkPiecewiseFunction;
+import vtk.vtkVolume;
+import vtk.vtkVolumeProperty;
+import vtk.vtkVolumeRayCastMIPFunction;
+import vtk.vtkVolumeRayCastMapper;
+
+/**
+ * DicomMIP.java
+ *
+ * Created on 1 Jul, 2010, 1:06:56 PM
+ *
+ *  This File Load the Series of Dicom images and
+ *  Construct them as a Volume...
+ *
+ */
+
+/*
+ * @author Sathish Kumar V              (sathishkumar.v at raster.in)
+ */
+public class DicomMIP extends javax.swing.JFrame {
+
+    private vtkDICOMImageReader reader;
+    private vtkCanvas vpanMIP = new vtkCanvas();
+    private int mode = 0, lastX, lastY, doDragFlag;
+    private String directoryName = "", DisplayString = "3D Maximum Intensity Projection (MIP)";
+    private vtkImageShiftScale vtkmyImageCast = new vtkImageShiftScale();
+    private vtkPiecewiseFunction opacityTransferFunction = new vtkPiecewiseFunction();
+    private vtkPiecewiseFunction grayTransferFunction = new vtkPiecewiseFunction();
+    private vtkVolumeProperty volumeProperty = new vtkVolumeProperty();
+    private vtkVolumeRayCastMIPFunction mip = new vtkVolumeRayCastMIPFunction();
+    private vtkVolumeRayCastMapper mapper = new vtkVolumeRayCastMapper();
+    private vtkVolume volume = new vtkVolume();
+    long startTime;
+    private int xMin, xMax, yMin, yMax, zMin, zMax;
+    private double sx, sy, sz, ox, oy, oz;
+
+    static {
+        System.loadLibrary("vtkCommonJava");
+        System.loadLibrary("vtkFilteringJava");
+        System.loadLibrary("vtkIOJava");
+        System.loadLibrary("vtkImagingJava");
+        System.loadLibrary("vtkGraphicsJava");
+        System.loadLibrary("vtkRenderingJava");
+        System.loadLibrary("vtkVolumeRenderingJava");
+    }
+
+    /* Creates new form DicomMIP */
+    public DicomMIP() {
+        initComponents();
+        vpanMIP.setSize(pnlMIPViewer.getSize());
+        vpanMIP.setBackground(Color.white);
+    }
+
+    @SuppressWarnings("unchecked")
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        pnlMIPViewer = new javax.swing.JPanel();
+        lblRotateMIP = new javax.swing.JLabel();
+        lblMoveMIP = new javax.swing.JLabel();
+        lblCubeBoxMIP = new javax.swing.JLabel();
+        lblDisplayPurpose = new javax.swing.JLabel();
+        lblCaptureScreenShot = new javax.swing.JLabel();
+        pnlselectedBackgroundColor = new javax.swing.JPanel();
+        lblZoomInOutMIP = new javax.swing.JLabel();
+        lblResetMIP = new javax.swing.JLabel();
+
+        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+        setTitle("3D Maximum Intensity Projection (MIP)");
+        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
+        setResizable(false);
+        addWindowListener(new java.awt.event.WindowAdapter() {
+            public void windowClosed(java.awt.event.WindowEvent evt) {
+                formWindowClosed(evt);
+            }
+        });
+
+        pnlMIPViewer.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
+
+        javax.swing.GroupLayout pnlMIPViewerLayout = new javax.swing.GroupLayout(pnlMIPViewer);
+        pnlMIPViewer.setLayout(pnlMIPViewerLayout);
+        pnlMIPViewerLayout.setHorizontalGroup(
+            pnlMIPViewerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGap(0, 1004, Short.MAX_VALUE)
+        );
+        pnlMIPViewerLayout.setVerticalGroup(
+            pnlMIPViewerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGap(0, 686, Short.MAX_VALUE)
+        );
+
+        lblRotateMIP.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+        lblRotateMIP.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/RotateSurface.png"))); // NOI18N
+        lblRotateMIP.setToolTipText("Rotate the Volume");
+        lblRotateMIP.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
+        lblRotateMIP.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+        lblRotateMIP.setIconTextGap(0);
+        lblRotateMIP.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        lblRotateMIP.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                lblRotateMIPMouseClicked(evt);
+            }
+            public void mouseEntered(java.awt.event.MouseEvent evt) {
+                lblRotateMIPMouseEntered(evt);
+            }
+            public void mouseExited(java.awt.event.MouseEvent evt) {
+                lblRotateMIPMouseExited(evt);
+            }
+        });
+
+        lblMoveMIP.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+        lblMoveMIP.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/Move.png"))); // NOI18N
+        lblMoveMIP.setToolTipText("Move the Volume");
+        lblMoveMIP.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
+        lblMoveMIP.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                lblMoveMIPMouseClicked(evt);
+            }
+            public void mouseEntered(java.awt.event.MouseEvent evt) {
+                lblMoveMIPMouseEntered(evt);
+            }
+            public void mouseExited(java.awt.event.MouseEvent evt) {
+                lblMoveMIPMouseExited(evt);
+            }
+        });
+
+        lblCubeBoxMIP.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+        lblCubeBoxMIP.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/ResetInteractor.png"))); // NOI18N
+        lblCubeBoxMIP.setToolTipText("Reset the Mouse Interaction");
+        lblCubeBoxMIP.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
+        lblCubeBoxMIP.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                lblCubeBoxMIPMouseClicked(evt);
+            }
+            public void mouseEntered(java.awt.event.MouseEvent evt) {
+                lblCubeBoxMIPMouseEntered(evt);
+            }
+            public void mouseExited(java.awt.event.MouseEvent evt) {
+                lblCubeBoxMIPMouseExited(evt);
+            }
+        });
+
+        lblDisplayPurpose.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+        lblDisplayPurpose.setText("3D Maximum Intensity Projection (MIP)");
+
+        lblCaptureScreenShot.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/ScreenShot.png"))); // NOI18N
+        lblCaptureScreenShot.setToolTipText("Capture Screenshot");
+        lblCaptureScreenShot.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                lblCaptureScreenShotMouseClicked(evt);
+            }
+            public void mouseEntered(java.awt.event.MouseEvent evt) {
+                lblCaptureScreenShotMouseEntered(evt);
+            }
+            public void mouseExited(java.awt.event.MouseEvent evt) {
+                lblCaptureScreenShotMouseExited(evt);
+            }
+        });
+
+        pnlselectedBackgroundColor.setBackground(new java.awt.Color(3, 2, 4));
+        pnlselectedBackgroundColor.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
+        pnlselectedBackgroundColor.setToolTipText("Change Background Color");
+        pnlselectedBackgroundColor.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                pnlselectedBackgroundColorMouseClicked(evt);
+            }
+            public void mouseEntered(java.awt.event.MouseEvent evt) {
+                pnlselectedBackgroundColorMouseEntered(evt);
+            }
+            public void mouseExited(java.awt.event.MouseEvent evt) {
+                pnlselectedBackgroundColorMouseExited(evt);
+            }
+        });
+
+        javax.swing.GroupLayout pnlselectedBackgroundColorLayout = new javax.swing.GroupLayout(pnlselectedBackgroundColor);
+        pnlselectedBackgroundColor.setLayout(pnlselectedBackgroundColorLayout);
+        pnlselectedBackgroundColorLayout.setHorizontalGroup(
+            pnlselectedBackgroundColorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGap(0, 22, Short.MAX_VALUE)
+        );
+        pnlselectedBackgroundColorLayout.setVerticalGroup(
+            pnlselectedBackgroundColorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGap(0, 22, Short.MAX_VALUE)
+        );
+
+        lblZoomInOutMIP.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/ZoomInOut.png"))); // NOI18N
+        lblZoomInOutMIP.setToolTipText("Zoom In or Zoom Out the Volume");
+        lblZoomInOutMIP.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                lblZoomInOutMIPMouseClicked(evt);
+            }
+            public void mouseEntered(java.awt.event.MouseEvent evt) {
+                lblZoomInOutMIPMouseEntered(evt);
+            }
+            public void mouseExited(java.awt.event.MouseEvent evt) {
+                lblZoomInOutMIPMouseExited(evt);
+            }
+        });
+
+        lblResetMIP.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/DrawCircle.png"))); // NOI18N
+        lblResetMIP.setToolTipText("Reset the Volume");
+        lblResetMIP.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                lblResetMIPMouseClicked(evt);
+            }
+            public void mouseEntered(java.awt.event.MouseEvent evt) {
+                lblResetMIPMouseEntered(evt);
+            }
+            public void mouseExited(java.awt.event.MouseEvent evt) {
+                lblResetMIPMouseExited(evt);
+            }
+        });
+
+        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
+        getContentPane().setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
+                .addContainerGap()
+                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+                    .addComponent(pnlMIPViewer, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                    .addGroup(layout.createSequentialGroup()
+                        .addComponent(lblZoomInOutMIP)
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                        .addComponent(lblRotateMIP)
+                        .addGap(9, 9, 9)
+                        .addComponent(lblMoveMIP)
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                        .addComponent(lblCubeBoxMIP)
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                        .addComponent(lblResetMIP, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
+                        .addGap(57, 57, 57)
+                        .addComponent(lblCaptureScreenShot)
+                        .addGap(18, 18, 18)
+                        .addComponent(pnlselectedBackgroundColor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+                        .addGap(231, 231, 231)
+                        .addComponent(lblDisplayPurpose, javax.swing.GroupLayout.DEFAULT_SIZE, 501, Short.MAX_VALUE)))
+                .addContainerGap())
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGroup(layout.createSequentialGroup()
+                .addContainerGap()
+                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
+                    .addComponent(lblMoveMIP, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                    .addComponent(lblResetMIP, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                    .addComponent(lblCubeBoxMIP, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                    .addComponent(lblZoomInOutMIP, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                    .addComponent(lblDisplayPurpose, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                    .addComponent(lblRotateMIP, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                    .addComponent(lblCaptureScreenShot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                    .addComponent(pnlselectedBackgroundColor, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+                .addGap(30, 30, 30)
+                .addComponent(pnlMIPViewer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+                .addContainerGap())
+        );
+
+        pack();
+    }// </editor-fold>//GEN-END:initComponents
+
+    private void lblRotateMIPMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblRotateMIPMouseEntered
+        // Code for Display the Purpose of Rotate Icon
+        lblDisplayPurpose.setText("Rotate the Volume");
+    }//GEN-LAST:event_lblRotateMIPMouseEntered
+
+    private void lblRotateMIPMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblRotateMIPMouseExited
+        // Code for Remove the Purpose from label
+        lblDisplayPurpose.setText(DisplayString);
+    }//GEN-LAST:event_lblRotateMIPMouseExited
+
+    private void lblMoveMIPMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblMoveMIPMouseEntered
+        // Code for Display the Purpose of Move Icon
+        lblDisplayPurpose.setText("Move the Volume");
+    }//GEN-LAST:event_lblMoveMIPMouseEntered
+
+    private void lblMoveMIPMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblMoveMIPMouseExited
+        // Code for Remove the Purpose from label
+        lblDisplayPurpose.setText(DisplayString);
+    }//GEN-LAST:event_lblMoveMIPMouseExited
+
+    private void lblCubeBoxMIPMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblCubeBoxMIPMouseEntered
+        // Code for Display the Purpose of add Cube Box Icon
+        lblDisplayPurpose.setText("Reset the Mouse Interaction");
+    }//GEN-LAST:event_lblCubeBoxMIPMouseEntered
+
+    private void lblCubeBoxMIPMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblCubeBoxMIPMouseExited
+        // Code for Remove the Purpose from label
+        lblDisplayPurpose.setText(DisplayString);
+    }//GEN-LAST:event_lblCubeBoxMIPMouseExited
+
+    private void lblCubeBoxMIPMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblCubeBoxMIPMouseClicked
+        // Set the Default Interactor..
+
+        vpanMIP.removeMouseListener(myMouseListener);
+        vpanMIP.removeMouseMotionListener(myMouseMotionListener);
+
+        mode = 0;
+        vpanMIP.addMouseListener(vpanMIP);
+        vpanMIP.addMouseMotionListener(vpanMIP);
+    }//GEN-LAST:event_lblCubeBoxMIPMouseClicked
+
+    private void lblRotateMIPMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblRotateMIPMouseClicked
+        //  Set the interaction for Rotate...
+        vpanMIP.removeMouseListener(vpanMIP);
+        vpanMIP.removeMouseMotionListener(vpanMIP);
+
+        mode = 2;
+        vpanMIP.addMouseListener(myMouseListener);
+        vpanMIP.addMouseMotionListener(myMouseMotionListener);
+    }//GEN-LAST:event_lblRotateMIPMouseClicked
+
+    private void lblMoveMIPMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblMoveMIPMouseClicked
+        // Set the interaction for Move...
+
+        vpanMIP.removeMouseListener(vpanMIP);
+        vpanMIP.removeMouseMotionListener(vpanMIP);
+
+        mode = 3;
+        vpanMIP.addMouseListener(myMouseListener);
+        vpanMIP.addMouseMotionListener(myMouseMotionListener);
+    }//GEN-LAST:event_lblMoveMIPMouseClicked
+
+    private void lblCaptureScreenShotMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblCaptureScreenShotMouseClicked
+        // Code for capture the view as an Image...
+
+        // ask for the filename...
+        JFileChooser fc = new JFileChooser();
+        FileFilter filter = new FileFilter() {
+
+            @Override
+            public boolean accept(File file) {
+                if (file.isDirectory()) {
+                    return true;
+                }
+                String extension = null;
+                String s = file.getName();
+                int i = s.lastIndexOf('.');
+                if (i > 0 && i < s.length() - 1) {
+                    extension = s.substring(i + 1).toLowerCase();
+                }
+                if (extension != null) {
+                    if (extension.equals("tiff") || extension.equals("tif")) {
+                        return true;
+                    } else {
+                        return false;
+                    }
+                } else {
+                    return false;
+                }
+            }
+
+            @Override
+            public String getDescription() {
+                return "tiff/tif Images";
+            }
+        };
+
+        fc.setFileFilter(filter);
+
+        fc.setAcceptAllFileFilterUsed(false);
+        int returnVal = fc.showSaveDialog(this);
+        if (returnVal == JFileChooser.APPROVE_OPTION) {
+            File file = fc.getSelectedFile();
+            // Capture and Save the image...
+
+            String extension = null;
+            String s = file.getName();
+            int i = s.lastIndexOf('.');
+            if (i > 0 && i < s.length() - 1) {
+                extension = s.substring(i + 1).toLowerCase();
+                if (extension.equals("tif") || extension.equals("tiff")) {
+                    vpanMIP.HardCopy(file.getAbsolutePath(), 1);
+                } else {
+                    vpanMIP.HardCopy(file.getAbsolutePath().concat(".tif"), 1);
+                }
+            } else {
+                vpanMIP.HardCopy(file.getAbsolutePath().concat(".tif"), 1);
+            }
+        }
+        //Reset the file chooser for the next time it's shown.
+
+        fc.setSelectedFile(null);
+    }//GEN-LAST:event_lblCaptureScreenShotMouseClicked
+
+    private void lblCaptureScreenShotMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblCaptureScreenShotMouseEntered
+        // Code for capture the view as an Image...
+        lblDisplayPurpose.setText("Capture Screenshot");
+    }//GEN-LAST:event_lblCaptureScreenShotMouseEntered
+
+    private void lblCaptureScreenShotMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblCaptureScreenShotMouseExited
+        // Code for Remove the Purpose from label
+        lblDisplayPurpose.setText(DisplayString);
+    }//GEN-LAST:event_lblCaptureScreenShotMouseExited
+
+    private void pnlselectedBackgroundColorMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pnlselectedBackgroundColorMouseClicked
+        // Code for display the Color Pallette
+        Color bgColor = JColorChooser.showDialog(this, "Select Color", pnlselectedBackgroundColor.getBackground());
+        if (bgColor != null) {
+            pnlselectedBackgroundColor.setBackground(bgColor);
+            vpanMIP.GetRenderer().SetBackground(Double.valueOf(pnlselectedBackgroundColor.getBackground().getRed()) / 255.0, Double.valueOf(pnlselectedBackgroundColor.getBackground().getGreen()) / 255.0, Double.valueOf(pnlselectedBackgroundColor.getBackground().getBlue()) / 255.0);
+            vpanMIP.repaint();
+        }
+    }//GEN-LAST:event_pnlselectedBackgroundColorMouseClicked
+
+    private void pnlselectedBackgroundColorMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pnlselectedBackgroundColorMouseEntered
+        // TODO add your handling code here:
+        lblDisplayPurpose.setText("Change Background Color");
+    }//GEN-LAST:event_pnlselectedBackgroundColorMouseEntered
+
+    private void pnlselectedBackgroundColorMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pnlselectedBackgroundColorMouseExited
+        // Code for Remove the Purpose from label
+        lblDisplayPurpose.setText(DisplayString);
+
+    }//GEN-LAST:event_pnlselectedBackgroundColorMouseExited
+
+    private void lblZoomInOutMIPMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblZoomInOutMIPMouseClicked
+        // Set the interaction for Zoom In and Zoom Out...
+
+        vpanMIP.removeMouseListener(vpanMIP);
+        vpanMIP.removeMouseMotionListener(vpanMIP);
+
+        mode = 1;
+        vpanMIP.addMouseListener(myMouseListener);
+        vpanMIP.addMouseMotionListener(myMouseMotionListener);
+    }//GEN-LAST:event_lblZoomInOutMIPMouseClicked
+
+    private void lblZoomInOutMIPMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblZoomInOutMIPMouseEntered
+        // Code for Display the Purpose of Zoom In/Out Icon
+        lblDisplayPurpose.setText("Zoom In or Zoom Out the Volume");
+    }//GEN-LAST:event_lblZoomInOutMIPMouseEntered
+
+    private void lblZoomInOutMIPMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblZoomInOutMIPMouseExited
+        // Code for Remove the Purpose from label
+        lblDisplayPurpose.setText(DisplayString);
+    }//GEN-LAST:event_lblZoomInOutMIPMouseExited
+
+    private void lblResetMIPMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblResetMIPMouseClicked
+        // TODO add your handling code here:
+        double cx = (ox + (0.5 * (xMax - xMin)) * sx);
+        double cy = (oy + (0.5 * (yMax - yMin)) * sy);
+        double cz = (oy + (0.5 * (zMax - zMin)) * sz);
+        double vx = 0;
+        double vy = 0;
+        double vz = 0;
+        double nx = 0;
+        double ny = 0;
+        double nz = 0;
+        int iaxis = 2;
+        if (iaxis == 0) {
+            vz = -1;
+            nx = (ox + xMax * sx);
+            cx = (ox + 1 * sx);
+        } else if (iaxis == 1) {
+            vz = -1;
+            ny = (oy + yMax * sy);
+            cy = (oy + 1 * sy);
+        } else {
+            vy = 1;
+            nz = (oz + zMax * sz);
+            cz = (oz + 1 * sz);
+        }
+        double px = (cx + nx * 2);
+        double py = (cy + ny * 2);
+        double pz = (cz + nz * 3);
+
+        vtkCamera camera = vpanMIP.GetRenderer().GetActiveCamera();
+        camera.SetViewUp(vx, vy, vz);
+        camera.SetFocalPoint(cx, cy, cz);
+        camera.SetPosition(px, py, pz);
+        camera.OrthogonalizeViewUp();
+
+        // Reset the light...
+        vtkLightCollection Lights = vpanMIP.GetRenderer().GetLights();
+        int nLights = Lights.GetNumberOfItems();
+        vtkLight light;
+        double[] pos = camera.GetPosition();
+        double[] fp = camera.GetFocalPoint();
+        Lights.InitTraversal();
+        for (int i = 0; i < nLights; i++) {
+            light = Lights.GetNextItem();
+            light.SetPosition(pos);
+            light.SetFocalPoint(fp);
+            light.Modified();
+        }
+
+        vpanMIP.GetRenderer().ResetCameraClippingRange();
+        vpanMIP.GetRenderer().ResetCamera();
+        vpanMIP.GetRenderer().WorldToView();
+        vpanMIP.repaint();
+    }//GEN-LAST:event_lblResetMIPMouseClicked
+
+    private void lblResetMIPMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblResetMIPMouseEntered
+        // TODO add your handling code here:
+        lblDisplayPurpose.setText("Reset the Volume");
+    }//GEN-LAST:event_lblResetMIPMouseEntered
+
+    private void lblResetMIPMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblResetMIPMouseExited
+        // TODO add your handling code here:
+        lblDisplayPurpose.setText(DisplayString);
+    }//GEN-LAST:event_lblResetMIPMouseExited
+
+    private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
+        // vtkGlobalJavaHash.DeleteAll();
+    }//GEN-LAST:event_formWindowClosed
+
+    public static void main(String args[]) {
+        java.awt.EventQueue.invokeLater(new Runnable() {
+
+            public void run() {
+                new DicomMIP().setVisible(true);
+            }
+        });
+    }
+
+    public void readDicomDir(String path) {
+        startTime = System.currentTimeMillis();
+        directoryName = path;
+        displayMIP();
+    }
+
+    private void displayMIP() {
+        // Display the MIP
+
+        reader = new vtkDICOMImageReader();
+        if (new File(directoryName).isDirectory()) {
+            reader.SetDirectoryName(directoryName);
+        } else {
+            System.out.println("Please select a directory");
+        }
+        reader.Update();
+
+
+        int[] xyminmax = reader.GetOutput().GetWholeExtent();
+        xMin = xyminmax[0];
+        xMax = xyminmax[1];
+        yMin = xyminmax[2];
+        yMax = xyminmax[3];
+        zMin = xyminmax[4];
+        zMax = xyminmax[5];
+
+        double[] spacing = reader.GetOutput().GetSpacing();
+        sx = spacing[0];
+        sy = spacing[1];
+        sz = spacing[2];
+
+        double[] origin = reader.GetOutput().GetOrigin();
+        ox = origin[0];
+        oy = origin[1];
+        oz = origin[2];
+
+
+        double[] range = reader.GetOutput().GetScalarRange();
+        double min = range[0];
+        double max = range[1];
+        double diff = max - min;
+        double slop = 512.0 / diff;
+        double inter = -slop * min;
+        double shift = inter / slop;
+
+        vtkmyImageCast.SetInput(reader.GetOutput());
+        vtkmyImageCast.SetShift(shift);
+        vtkmyImageCast.SetScale(slop);
+        vtkmyImageCast.SetOutputScalarTypeToUnsignedChar();
+        vtkmyImageCast.Update();
+        vtkmyImageCast.GetOutput().GetScalarRange(range);
+
+        DisplayString = reader.GetPatientName();
+        reader.Delete();
+
+        double level = 0.5 * (range[0] + range[1]);
+        double window = range[1] - range[0];
+
+        System.out.println("Level : " + level);
+        System.out.println("Window : " + window);
+
+        opacityTransferFunction.AddPoint(0, 0.0);
+        opacityTransferFunction.AddPoint(75, 0.0);
+        opacityTransferFunction.AddPoint(95, 0.0);
+        opacityTransferFunction.AddPoint(110, 0.4); //0.4
+        opacityTransferFunction.AddPoint(120, 0.6); //0.6
+        opacityTransferFunction.AddPoint(145, 1.0);
+        opacityTransferFunction.AddPoint(255, 1.0);
+
+        grayTransferFunction.AddSegment(level - window / 2, 0.0, level + window / 2, 1.0);
+        grayTransferFunction.AddSegment(0, 0.0, 255, 1.0);
+
+        vtkColorTransferFunction colorTransferFunction = new vtkColorTransferFunction();
+
+        colorTransferFunction.AddRGBPoint(120.0, 0.2, 0.2, 0.2); //0.6
+        colorTransferFunction.AddRGBPoint(145.0, 0.3, 0.3, 0.3); //0.4
+        colorTransferFunction.AddRGBPoint(255.0, 1.0, 1.0, 1.0); //0.2
+
+        volumeProperty.SetScalarOpacity(opacityTransferFunction);
+        volumeProperty.SetColor(colorTransferFunction);
+        volumeProperty.SetInterpolationTypeToLinear();
+        mapper.SetInput(vtkmyImageCast.GetOutput());
+        mapper.SetVolumeRayCastFunction(mip);
+        mapper.SetBlendModeToMaximumIntensity();
+        mapper.SetSampleDistance(1.0);
+        volume.SetMapper(mapper);
+        volume.SetProperty(volumeProperty);
+        vpanMIP.GetRenderer().AddVolume(volume);
+
+        vpanMIP.GetRenderer().SetBackground(Double.valueOf(pnlselectedBackgroundColor.getBackground().getRed()) / 255.0, Double.valueOf(pnlselectedBackgroundColor.getBackground().getGreen()) / 255.0, Double.valueOf(pnlselectedBackgroundColor.getBackground().getBlue()) / 255.0);
+        vpanMIP.GetRenderer().ResetCamera();
+        pnlMIPViewer.add(vpanMIP);
+        vpanMIP.repaint();
+        pnlMIPViewer.setVisible(true);
+
+        System.out.println("Time taken : " + (System.currentTimeMillis() - startTime));
+    }
+    MouseListener myMouseListener = new MouseListener() {
+
+        public void mouseClicked(MouseEvent me) {
+        }
+
+        public void mousePressed(MouseEvent me) {
+            lastX = me.getX();
+            lastY = me.getY();
+        }
+
+        public void mouseReleased(MouseEvent me) {
+        }
+
+        public void mouseEntered(MouseEvent me) {
+        }
+
+        public void mouseExited(MouseEvent me) {
+        }
+    };
+    MouseMotionListener myMouseMotionListener = new MouseMotionListener() {
+
+        public void mouseDragged(MouseEvent me) {
+
+            if (doDragFlag > 0) {
+                doDragFlag--;
+            } else {
+                int x = me.getX();
+                int y = me.getY();
+                vtkCamera cam = vpanMIP.GetRenderer().GetActiveCamera();
+
+                if (mode == 1) {            // Zoom In/Out MIP...
+                    if (vpanMIP.GetRenderer().VisibleActorCount() == 0) {
+                        return;
+                    }
+                    double zoomFactor;
+                    zoomFactor = Math.pow(1.02, (y - lastY));
+                    if (cam.GetParallelProjection() == 1) {
+                        cam.SetParallelScale(cam.GetParallelScale() / zoomFactor);
+                    } else {
+                        cam.Dolly(zoomFactor);
+                        vpanMIP.resetCameraClippingRange();
+                    }
+                } else if (mode == 2) {     // Rotate MIP...
+
+                    if (vpanMIP.GetRenderer().VisibleActorCount() == 0) {
+                        return;
+                    }
+                    if (x > vpanMIP.getWidth() / 2.0) {
+                        cam.Roll(-(y - lastY));
+                    } else {
+                        cam.Roll((y - lastY));
+                    }
+                    if (y < vpanMIP.getHeight() / 2.0) {
+                        cam.Roll(-(x - lastX));
+                    } else {
+                        cam.Roll((x - lastX));
+                    }
+                    vpanMIP.resetCameraClippingRange();
+                } else if (mode == 3) {     // Move MIP...
+                    if (vpanMIP.GetRenderer().VisibleActorCount() == 0) {
+                        return;
+                    }
+                    double FPoint[];
+                    double PPoint[];
+                    double APoint[] = new double[3];
+                    double RPoint[];
+                    double focalDepth;
+
+                    // get the current focal point and position
+                    FPoint = cam.GetFocalPoint();
+                    PPoint = cam.GetPosition();
+
+                    // calculate the focal depth since we'll be using it a lot
+                    vpanMIP.GetRenderer().SetWorldPoint(FPoint[0], FPoint[1], FPoint[2], 1.0);
+                    vpanMIP.GetRenderer().WorldToDisplay();
+                    focalDepth = vpanMIP.GetRenderer().GetDisplayPoint()[2];
+
+                    APoint[0] = vpanMIP.GetRenderWindow().GetSize()[0] / 2.0 + (x - lastX);
+                    APoint[1] = vpanMIP.GetRenderWindow().GetSize()[1] / 2.0 - (y - lastY);
+                    APoint[2] = focalDepth;
+                    vpanMIP.GetRenderer().SetDisplayPoint(APoint);
+                    vpanMIP.GetRenderer().DisplayToWorld();
+                    RPoint = vpanMIP.GetRenderer().GetWorldPoint();
+                    if (RPoint[3] != 0.0) {
+                        RPoint[0] = RPoint[0] / RPoint[3];
+                        RPoint[1] = RPoint[1] / RPoint[3];
+                        RPoint[2] = RPoint[2] / RPoint[3];
+                    }
+                    /*
+                     * Compute a translation vector, moving everything 1/2
+                     * the distance to the cursor. (Arbitrary scale factor)
+                     */
+                    cam.SetFocalPoint(
+                            (FPoint[0] - RPoint[0]) / 2.0 + FPoint[0],
+                            (FPoint[1] - RPoint[1]) / 2.0 + FPoint[1],
+                            (FPoint[2] - RPoint[2]) / 2.0 + FPoint[2]);
+                    cam.SetPosition(
+                            (FPoint[0] - RPoint[0]) / 2.0 + PPoint[0],
+                            (FPoint[1] - RPoint[1]) / 2.0 + PPoint[1],
+                            (FPoint[2] - RPoint[2]) / 2.0 + PPoint[2]);
+                    vpanMIP.resetCameraClippingRange();
+                }
+                lastX = x;
+                lastY = y;
+
+                vpanMIP.Render();
+                doDragFlag = 5;
+            }
+        }
+
+        public void mouseMoved(MouseEvent me) {
+            lastX = me.getX();
+            lastY = me.getY();
+        }
+    };
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JLabel lblCaptureScreenShot;
+    private javax.swing.JLabel lblCubeBoxMIP;
+    private javax.swing.JLabel lblDisplayPurpose;
+    private javax.swing.JLabel lblMoveMIP;
+    private javax.swing.JLabel lblResetMIP;
+    private javax.swing.JLabel lblRotateMIP;
+    private javax.swing.JLabel lblZoomInOutMIP;
+    private javax.swing.JPanel pnlMIPViewer;
+    private javax.swing.JPanel pnlselectedBackgroundColor;
+    // End of variables declaration//GEN-END:variables
+}
diff --git a/src/in/raster/mayam/form/dcm3d/DicomMPR2D.form b/src/in/raster/mayam/form/dcm3d/DicomMPR2D.form
new file mode 100644
index 0000000..9576842
--- /dev/null
+++ b/src/in/raster/mayam/form/dcm3d/DicomMPR2D.form
@@ -0,0 +1,174 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
+  <Properties>
+    <Property name="defaultCloseOperation" type="int" value="2"/>
+    <Property name="title" type="java.lang.String" value="2D Orthogonal MPR(Multi Planner Reconstruction)"/>
+    <Property name="resizable" type="boolean" value="false"/>
+  </Properties>
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <Events>
+    <EventHandler event="windowClosed" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="formWindowClosed"/>
+  </Events>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Group type="103" alignment="0" groupAlignment="0" max="-2" attributes="0">
+                      <Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
+                      <Component id="pnlSagittalView" alignment="0" pref="417" max="32767" attributes="1"/>
+                      <Component id="pnlCoronalView" alignment="0" min="-2" pref="417" max="-2" attributes="1"/>
+                  </Group>
+                  <Component id="lblCoronalDisplay" alignment="0" min="-2" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Component id="pnlAxialView" min="-2" pref="565" max="-2" attributes="1"/>
+                  <Component id="lblAxialDisplay" min="-2" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace min="-2" pref="96" max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="1" attributes="0">
+                  <Component id="lblCoronalDisplay" min="-2" max="-2" attributes="0"/>
+                  <Component id="lblAxialDisplay" alignment="1" min="-2" pref="18" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace type="unrelated" max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="1" max="-2" attributes="0">
+                  <Group type="102" alignment="0" attributes="0">
+                      <Component id="pnlCoronalView" min="-2" pref="287" max="-2" attributes="1"/>
+                      <EmptySpace type="unrelated" max="-2" attributes="0"/>
+                      <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="pnlSagittalView" min="-2" pref="312" max="-2" attributes="1"/>
+                  </Group>
+                  <Component id="pnlAxialView" alignment="0" pref="632" max="32767" attributes="1"/>
+              </Group>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Container class="javax.swing.JPanel" name="pnlAxialView">
+      <Properties>
+        <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+          <Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
+            <LineBorder/>
+          </Border>
+        </Property>
+        <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+          <Dimension value="[360, 350]"/>
+        </Property>
+      </Properties>
+
+      <Layout>
+        <DimensionLayout dim="0">
+          <Group type="103" groupAlignment="0" attributes="0">
+              <EmptySpace min="0" pref="563" max="32767" attributes="0"/>
+          </Group>
+        </DimensionLayout>
+        <DimensionLayout dim="1">
+          <Group type="103" groupAlignment="0" attributes="0">
+              <EmptySpace min="0" pref="630" max="32767" attributes="0"/>
+          </Group>
+        </DimensionLayout>
+      </Layout>
+    </Container>
+    <Container class="javax.swing.JPanel" name="pnlCoronalView">
+      <Properties>
+        <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+          <Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
+            <LineBorder/>
+          </Border>
+        </Property>
+        <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+          <Dimension value="[362, 350]"/>
+        </Property>
+      </Properties>
+
+      <Layout>
+        <DimensionLayout dim="0">
+          <Group type="103" groupAlignment="0" attributes="0">
+              <EmptySpace min="0" pref="415" max="32767" attributes="0"/>
+          </Group>
+        </DimensionLayout>
+        <DimensionLayout dim="1">
+          <Group type="103" groupAlignment="0" attributes="0">
+              <EmptySpace min="0" pref="285" max="32767" attributes="0"/>
+          </Group>
+        </DimensionLayout>
+      </Layout>
+    </Container>
+    <Container class="javax.swing.JPanel" name="pnlSagittalView">
+      <Properties>
+        <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+          <Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
+            <LineBorder/>
+          </Border>
+        </Property>
+        <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+          <Dimension value="[362, 350]"/>
+        </Property>
+      </Properties>
+
+      <Layout>
+        <DimensionLayout dim="0">
+          <Group type="103" groupAlignment="0" attributes="0">
+              <EmptySpace min="0" pref="415" max="32767" attributes="0"/>
+          </Group>
+        </DimensionLayout>
+        <DimensionLayout dim="1">
+          <Group type="103" groupAlignment="0" attributes="0">
+              <EmptySpace min="0" pref="310" max="32767" attributes="0"/>
+          </Group>
+        </DimensionLayout>
+      </Layout>
+    </Container>
+    <Component class="javax.swing.JLabel" name="lblAxialDisplay">
+      <Properties>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Tahoma" size="10" style="1"/>
+        </Property>
+        <Property name="text" type="java.lang.String" value="Axial View"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="lblCoronalDisplay">
+      <Properties>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Tahoma" size="10" style="1"/>
+        </Property>
+        <Property name="text" type="java.lang.String" value="Coronal View"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="jLabel1">
+      <Properties>
+        <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+          <Font name="Tahoma" size="10" style="1"/>
+        </Property>
+        <Property name="text" type="java.lang.String" value="Sagittal View"/>
+      </Properties>
+    </Component>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/dcm3d/DicomMPR2D.java b/src/in/raster/mayam/form/dcm3d/DicomMPR2D.java
new file mode 100644
index 0000000..f6b8dbe
--- /dev/null
+++ b/src/in/raster/mayam/form/dcm3d/DicomMPR2D.java
@@ -0,0 +1,532 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Guru Rajan R
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Sathish Kumar V
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form.dcm3d;
+
+import java.awt.Point;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionListener;
+import vtk.vtkDICOMImageReader;
+import vtk.vtkImageActor;
+import vtk.vtkImageMapToColors;
+import vtk.vtkImageReslice;
+import vtk.vtkInteractorStyleImage;
+import vtk.vtkLookupTable;
+import vtk.vtkMatrix4x4;
+import vtk.vtkPanel;
+import vtk.vtkPointPicker;
+
+/**
+ *
+ * @author Sathish Kumar V              (sathishkumar.v at raster.in)
+ */
+public class DicomMPR2D extends javax.swing.JFrame {
+
+    vtkPanel vpanAxial = new vtkPanel();
+    vtkPanel vpanCoronal = new vtkPanel();
+    vtkPanel vpanSagittal = new vtkPanel();
+    vtkImageReslice resliceAxial = new vtkImageReslice();
+    vtkImageReslice resliceCoronal = new vtkImageReslice();
+    vtkImageReslice resliceSagittal = new vtkImageReslice();
+    vtkInteractorStyleImage interactorStyle = new vtkInteractorStyleImage();
+    vtkImageActor actorAxial = new vtkImageActor();
+    vtkImageActor actorCoronal = new vtkImageActor();
+    vtkImageActor actorSagittal = new vtkImageActor();
+    Point mouseXYAxial, mouseXYCoronal, mouseXYSagittal;
+    private vtkDICOMImageReader reader;
+    double[] dataExtent;
+
+    static {
+        System.loadLibrary("vtkCommonJava");
+        System.loadLibrary("vtkFilteringJava");
+        System.loadLibrary("vtkIOJava");
+        System.loadLibrary("vtkImagingJava");
+        System.loadLibrary("vtkGraphicsJava");
+        System.loadLibrary("vtkRenderingJava");
+    }
+
+    /** Creates new form DicomMPR2D */
+    public DicomMPR2D() {
+        initComponents();
+        try {
+            vpanAxial.GetRenderer().SetBackground(0.0, 0.0, 0.0);
+            vpanAxial.setSize(pnlAxialView.getSize());
+            pnlAxialView.add(vpanAxial);
+
+            vpanCoronal.GetRenderer().SetBackground(0.0, 0.0, 0.0);
+            vpanCoronal.setSize(pnlCoronalView.getSize());
+            pnlCoronalView.add(vpanCoronal);
+
+            vpanSagittal.GetRenderer().SetBackground(0.0, 0.0, 0.0);
+            vpanSagittal.setSize(pnlSagittalView.getSize());
+            pnlSagittalView.add(vpanSagittal);
+
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        pnlAxialView = new javax.swing.JPanel();
+        pnlCoronalView = new javax.swing.JPanel();
+        pnlSagittalView = new javax.swing.JPanel();
+        lblAxialDisplay = new javax.swing.JLabel();
+        lblCoronalDisplay = new javax.swing.JLabel();
+        jLabel1 = new javax.swing.JLabel();
+
+        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+        setTitle("2D Orthogonal MPR(Multi Planner Reconstruction)");
+        setResizable(false);
+        addWindowListener(new java.awt.event.WindowAdapter() {
+            public void windowClosed(java.awt.event.WindowEvent evt) {
+                formWindowClosed(evt);
+            }
+        });
+
+        pnlAxialView.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
+        pnlAxialView.setPreferredSize(new java.awt.Dimension(360, 350));
+
+        javax.swing.GroupLayout pnlAxialViewLayout = new javax.swing.GroupLayout(pnlAxialView);
+        pnlAxialView.setLayout(pnlAxialViewLayout);
+        pnlAxialViewLayout.setHorizontalGroup(
+            pnlAxialViewLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGap(0, 563, Short.MAX_VALUE)
+        );
+        pnlAxialViewLayout.setVerticalGroup(
+            pnlAxialViewLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGap(0, 630, Short.MAX_VALUE)
+        );
+
+        pnlCoronalView.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
+        pnlCoronalView.setPreferredSize(new java.awt.Dimension(362, 350));
+
+        javax.swing.GroupLayout pnlCoronalViewLayout = new javax.swing.GroupLayout(pnlCoronalView);
+        pnlCoronalView.setLayout(pnlCoronalViewLayout);
+        pnlCoronalViewLayout.setHorizontalGroup(
+            pnlCoronalViewLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGap(0, 415, Short.MAX_VALUE)
+        );
+        pnlCoronalViewLayout.setVerticalGroup(
+            pnlCoronalViewLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGap(0, 285, Short.MAX_VALUE)
+        );
+
+        pnlSagittalView.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
+        pnlSagittalView.setPreferredSize(new java.awt.Dimension(362, 350));
+
+        javax.swing.GroupLayout pnlSagittalViewLayout = new javax.swing.GroupLayout(pnlSagittalView);
+        pnlSagittalView.setLayout(pnlSagittalViewLayout);
+        pnlSagittalViewLayout.setHorizontalGroup(
+            pnlSagittalViewLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGap(0, 415, Short.MAX_VALUE)
+        );
+        pnlSagittalViewLayout.setVerticalGroup(
+            pnlSagittalViewLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGap(0, 310, Short.MAX_VALUE)
+        );
+
+        lblAxialDisplay.setFont(new java.awt.Font("Tahoma", 1, 10));
+        lblAxialDisplay.setText("Axial View");
+
+        lblCoronalDisplay.setFont(new java.awt.Font("Tahoma", 1, 10));
+        lblCoronalDisplay.setText("Coronal View");
+
+        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 10));
+        jLabel1.setText("Sagittal View");
+
+        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
+        getContentPane().setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGroup(layout.createSequentialGroup()
+                .addContainerGap()
+                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
+                        .addComponent(jLabel1)
+                        .addComponent(pnlSagittalView, javax.swing.GroupLayout.DEFAULT_SIZE, 417, Short.MAX_VALUE)
+                        .addComponent(pnlCoronalView, javax.swing.GroupLayout.PREFERRED_SIZE, 417, javax.swing.GroupLayout.PREFERRED_SIZE))
+                    .addComponent(lblCoronalDisplay))
+                .addGap(18, 18, 18)
+                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                    .addComponent(pnlAxialView, javax.swing.GroupLayout.PREFERRED_SIZE, 565, javax.swing.GroupLayout.PREFERRED_SIZE)
+                    .addComponent(lblAxialDisplay))
+                .addContainerGap())
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGroup(layout.createSequentialGroup()
+                .addGap(96, 96, 96)
+                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+                    .addComponent(lblCoronalDisplay)
+                    .addComponent(lblAxialDisplay, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE))
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
+                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
+                        .addComponent(pnlCoronalView, javax.swing.GroupLayout.PREFERRED_SIZE, 287, javax.swing.GroupLayout.PREFERRED_SIZE)
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+                        .addComponent(jLabel1)
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                        .addComponent(pnlSagittalView, javax.swing.GroupLayout.PREFERRED_SIZE, 312, javax.swing.GroupLayout.PREFERRED_SIZE))
+                    .addComponent(pnlAxialView, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 632, Short.MAX_VALUE))
+                .addContainerGap())
+        );
+
+        pack();
+    }// </editor-fold>//GEN-END:initComponents
+
+    private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
+        //vtkGlobalJavaHash.DeleteAll();
+    }//GEN-LAST:event_formWindowClosed
+
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String args[]) {
+        java.awt.EventQueue.invokeLater(new Runnable() {
+
+            public void run() {
+                new DicomMPR2D().setVisible(true);
+            }
+        });
+    }
+
+    public void readDicomDir(String path) {
+        reader = new vtkDICOMImageReader();
+        reader.SetDirectoryName(path);
+        reader.SetDataScalarTypeToUnsignedShort();
+        reader.UpdateWholeExtent();
+        reader.Update();
+
+
+        int[] extent = reader.GetOutput().GetWholeExtent();
+        double[] spacing = reader.GetOutput().GetSpacing();
+        double[] origin = reader.GetOutput().GetOrigin();
+        dataExtent = reader.GetOutput().GetCenter();
+
+
+        int xMin = extent[0];
+        int xMax = extent[1];
+        int yMin = extent[2];
+        int yMax = extent[3];
+        int zMin = extent[4];
+        int zMax = extent[5];
+
+        double xSpacing = spacing[0];
+        double ySpacing = spacing[1];
+        double zSpacing = spacing[2];
+
+        double x0 = origin[0];
+        double y0 = origin[1];
+        double z0 = origin[2];
+
+        double[] center = {x0 + xSpacing * 0.5 * (xMin + xMax), y0 + ySpacing * 0.5 * (yMin + yMax), z0 + zSpacing * 0.5 * (zMin + zMax)};
+
+        double[] axialElements = {1.0, 0.0, 0.0, center[0], 0.0, 1.0, 0.0, center[1], 0.0, 0.0, 1.0, center[2], 0.0, 0.0, 0.0, 1.0};
+
+        double[] coronalElements = {1.0, 0.0, 0.0, center[0], 0.0, 0.0, 1.0, center[1], 0.0, -1.0, 0.0, center[2], 0.0, 0.0, 0.0, 1.0};
+
+        double[] sagittalElements = {0.0, 0.0, -1.0, center[0], 1.0, 0.0, 0.0, center[1], 0.0, -1.0, 0.0, center[2], 0.0, 0.0, 0.0, 1.0};
+
+        double[] obiliqueElements = {1.0, 0.0, 0.0, center[0], 0.0, 0.866025, -0.5, center[1], 0.0, 0.5, 0.866025, center[2], 0.0, 0.0, 0.0, 1.0};
+
+        vtkMatrix4x4 axial = new vtkMatrix4x4();
+        axial.DeepCopy(axialElements);
+        vtkMatrix4x4 coronal = new vtkMatrix4x4();
+        coronal.DeepCopy(coronalElements);
+        vtkMatrix4x4 sagittal = new vtkMatrix4x4();
+        sagittal.DeepCopy(sagittalElements);
+        vtkMatrix4x4 obilique = new vtkMatrix4x4();
+        obilique.DeepCopy(obiliqueElements);
+
+        resliceAxial.SetInputConnection(reader.GetOutputPort());
+        resliceAxial.SetOutputDimensionality(2);
+        resliceAxial.SetResliceAxes(axial);
+        resliceAxial.SetInterpolationModeToLinear();
+
+        resliceCoronal.SetInputConnection(reader.GetOutputPort());
+        resliceCoronal.SetOutputDimensionality(2);
+        resliceCoronal.SetResliceAxes(coronal);
+        resliceCoronal.SetInterpolationModeToLinear();
+
+        resliceSagittal.SetInputConnection(reader.GetOutputPort());
+        resliceSagittal.SetOutputDimensionality(2);
+        resliceSagittal.SetResliceAxes(sagittal);
+        resliceSagittal.SetInterpolationModeToLinear();
+
+        // Release the memory...
+        reader.Delete();
+
+        vtkLookupTable tableAxial = new vtkLookupTable();
+        tableAxial.SetRange(25.0, 100.0);
+        tableAxial.SetValueRange(0.0, 1.0);
+        tableAxial.SetSaturationRange(0.0, 0.0);
+        tableAxial.SetRampToLinear();
+        tableAxial.Build();
+
+        vtkLookupTable tableCoronal = new vtkLookupTable();
+        tableCoronal.SetRange(25.0, 100.0);
+        tableCoronal.SetValueRange(0.0, 1.0);
+        tableCoronal.SetSaturationRange(0.0, 0.0);
+        tableCoronal.SetRampToLinear();
+        tableCoronal.Build();
+
+        vtkLookupTable tableSagittal = new vtkLookupTable();
+        tableSagittal.SetRange(25.0, 100.0);
+        tableSagittal.SetValueRange(0.0, 1.0);
+        tableSagittal.SetSaturationRange(0.0, 0.0);
+        tableSagittal.SetRampToLinear();
+        tableSagittal.Build();
+
+        vtkImageMapToColors colorAxial = new vtkImageMapToColors();
+        colorAxial.SetLookupTable(tableAxial);
+        colorAxial.SetInputConnection(resliceAxial.GetOutputPort());
+
+        vtkImageMapToColors colorCoronal = new vtkImageMapToColors();
+        colorCoronal.SetLookupTable(tableCoronal);
+        colorCoronal.SetInputConnection(resliceCoronal.GetOutputPort());
+
+        vtkImageMapToColors colorSagittal = new vtkImageMapToColors();
+        colorSagittal.SetLookupTable(tableSagittal);
+        colorSagittal.SetInputConnection(resliceSagittal.GetOutputPort());
+
+        actorAxial.SetInput(colorAxial.GetOutput());
+        actorCoronal.SetInput(colorCoronal.GetOutput());
+        actorSagittal.SetInput(colorSagittal.GetOutput());
+
+        vpanAxial.GetRenderer().AddActor(actorAxial);
+        vpanAxial.GetRenderer().ResetCamera();
+
+        vpanCoronal.GetRenderer().AddActor(actorCoronal);
+        vpanCoronal.GetRenderer().ResetCamera();
+
+        vpanSagittal.GetRenderer().AddActor(actorSagittal);
+        vpanSagittal.GetRenderer().ResetCamera();
+
+        vpanAxial.removeMouseListener(vpanAxial);
+        vpanAxial.removeMouseMotionListener(vpanAxial);
+        vpanAxial.addMouseListener(new MouseListener() {
+
+            public void mouseClicked(MouseEvent e) {
+                double[] axialMapperPosition = new double[4];
+                mouseXYAxial = e.getPoint();
+                vtkPointPicker pickerAxial = new vtkPointPicker();
+                int pickTest = pickerAxial.Pick(mouseXYAxial.x, mouseXYAxial.y, 0.0, vpanAxial.GetRenderer());
+                if (pickTest != 0) {
+                    axialMapperPosition = pickerAxial.GetMapperPosition();
+                    vtkMatrix4x4 matrixCoronalChange = resliceCoronal.GetResliceAxes();
+                    matrixCoronalChange.SetElement(1, 3, dataExtent[1] - axialMapperPosition[1]);
+                    vpanCoronal.Render();
+                    vpanCoronal.resetCamera();
+
+                    vtkMatrix4x4 matrixSagittalChange = resliceSagittal.GetResliceAxes();
+                    matrixSagittalChange.SetElement(0, 3, dataExtent[0] + axialMapperPosition[0]);
+                    vpanSagittal.Render();
+                    vpanSagittal.resetCamera();
+                }
+            }
+
+            public void mousePressed(MouseEvent e) {
+            }
+
+            public void mouseReleased(MouseEvent e) {
+            }
+
+            public void mouseEntered(MouseEvent e) {
+            }
+
+            public void mouseExited(MouseEvent e) {
+            }
+        });
+        vpanAxial.addMouseMotionListener(new MouseMotionListener() {
+
+            public void mouseDragged(MouseEvent e) {
+                double[] axialMapperPosition = new double[4];
+                mouseXYAxial = e.getPoint();
+                vtkPointPicker pickerAxial = new vtkPointPicker();
+                int pickTest = pickerAxial.Pick(mouseXYAxial.x, mouseXYAxial.y, 0.0, vpanAxial.GetRenderer());
+                if (pickTest != 0) {
+                    axialMapperPosition = pickerAxial.GetMapperPosition();
+                    vtkMatrix4x4 matrixCoronalChange = resliceCoronal.GetResliceAxes();
+                    matrixCoronalChange.SetElement(1, 3, dataExtent[1] - axialMapperPosition[1]);
+                    vpanCoronal.Render();
+                    vpanCoronal.resetCamera();
+
+                    vtkMatrix4x4 matrixSagittalChange = resliceSagittal.GetResliceAxes();
+                    matrixSagittalChange.SetElement(0, 3, dataExtent[0] + axialMapperPosition[0]);
+                    vpanSagittal.Render();
+                    vpanSagittal.resetCamera();
+                }
+            }
+
+            public void mouseMoved(MouseEvent e) {
+            }
+        });
+        vpanCoronal.removeMouseListener(vpanCoronal);
+        vpanCoronal.removeMouseMotionListener(vpanCoronal);
+        vpanCoronal.addMouseListener(new MouseListener() {
+
+            public void mouseClicked(MouseEvent e) {
+                double[] CoronalMapperPosition = new double[4];
+                mouseXYCoronal = e.getPoint();
+                vtkPointPicker pickerCoronal = new vtkPointPicker();
+                int pickTest = pickerCoronal.Pick(mouseXYCoronal.x, mouseXYCoronal.y, 0.0, vpanCoronal.GetRenderer());
+                if (pickTest != 0) {
+                    CoronalMapperPosition = pickerCoronal.GetMapperPosition();
+                    //double[] dataExtent = reader.GetOutput().GetCenter();
+                    vtkMatrix4x4 matrixCoronalChange = resliceAxial.GetResliceAxes();
+                    matrixCoronalChange.SetElement(2, 3, dataExtent[2] + CoronalMapperPosition[1]);
+                    vpanAxial.Render();
+                    vpanAxial.resetCamera();
+
+                    vtkMatrix4x4 matrixSagittalChange = resliceSagittal.GetResliceAxes();
+                    matrixSagittalChange.SetElement(0, 3, dataExtent[0] + CoronalMapperPosition[0]);
+                    vpanSagittal.Render();
+                    vpanSagittal.resetCamera();
+                }
+            }
+
+            public void mousePressed(MouseEvent e) {
+            }
+
+            public void mouseReleased(MouseEvent e) {
+            }
+
+            public void mouseEntered(MouseEvent e) {
+            }
+
+            public void mouseExited(MouseEvent e) {
+            }
+        });
+        vpanCoronal.addMouseMotionListener(new MouseMotionListener() {
+
+            public void mouseDragged(MouseEvent e) {
+                double[] CoronalMapperPosition = new double[4];
+                mouseXYCoronal = e.getPoint();
+                vtkPointPicker pickerCoronal = new vtkPointPicker();
+                int pickTest = pickerCoronal.Pick(mouseXYCoronal.x, mouseXYCoronal.y, 0.0, vpanCoronal.GetRenderer());
+                if (pickTest != 0) {
+                    CoronalMapperPosition = pickerCoronal.GetMapperPosition();
+                    vtkMatrix4x4 matrixCoronalChange = resliceAxial.GetResliceAxes();
+                    matrixCoronalChange.SetElement(2, 3, dataExtent[2] + CoronalMapperPosition[1]);
+                    vpanAxial.Render();
+                    vpanAxial.resetCamera();
+
+                    vtkMatrix4x4 matrixSagittalChange = resliceSagittal.GetResliceAxes();
+                    matrixSagittalChange.SetElement(0, 3, dataExtent[0] + CoronalMapperPosition[0]);
+                    vpanSagittal.Render();
+                    vpanSagittal.resetCamera();
+                }
+            }
+
+            public void mouseMoved(MouseEvent e) {
+            }
+        });
+        vpanSagittal.removeMouseListener(vpanSagittal);
+        vpanSagittal.removeMouseMotionListener(vpanSagittal);
+        vpanSagittal.addMouseListener(new MouseListener() {
+
+            public void mouseClicked(MouseEvent e) {
+                double[] sagittalMapperPosition = new double[4];
+                mouseXYSagittal = e.getPoint();
+                vtkPointPicker pickerSagittal = new vtkPointPicker();
+                int pickTest = pickerSagittal.Pick(mouseXYSagittal.x, mouseXYSagittal.y, 0.0, vpanSagittal.GetRenderer());
+                if (pickTest != 0) {
+                    sagittalMapperPosition = pickerSagittal.GetMapperPosition();
+                    vtkMatrix4x4 matrixAxialChange = resliceAxial.GetResliceAxes();
+                    matrixAxialChange.SetElement(2, 3, dataExtent[2] + sagittalMapperPosition[1]);
+                    vpanAxial.Render();
+                    vpanAxial.resetCamera();
+                    vtkMatrix4x4 matrixCoronalChange = resliceCoronal.GetResliceAxes();
+                    matrixCoronalChange.SetElement(1, 3, dataExtent[1] + sagittalMapperPosition[0]);
+                    vpanCoronal.Render();
+                    vpanCoronal.resetCamera();
+                }
+            }
+
+            public void mousePressed(MouseEvent e) {
+            }
+
+            public void mouseReleased(MouseEvent e) {
+            }
+
+            public void mouseEntered(MouseEvent e) {
+            }
+
+            public void mouseExited(MouseEvent e) {
+            }
+        });
+        vpanSagittal.addMouseMotionListener(new MouseMotionListener() {
+
+            public void mouseDragged(MouseEvent e) {
+                double[] sagittalMapperPosition = new double[4];
+                mouseXYSagittal = e.getPoint();
+                vtkPointPicker pickerSagittal = new vtkPointPicker();
+                int pickTest = pickerSagittal.Pick(mouseXYSagittal.x, mouseXYSagittal.y, 0.0, vpanSagittal.GetRenderer());
+                if (pickTest != 0) {
+                    sagittalMapperPosition = pickerSagittal.GetMapperPosition();
+                    //double[] dataExtent = reader.GetOutput().GetCenter();
+                    vtkMatrix4x4 matrixAxialChange = resliceAxial.GetResliceAxes();
+                    matrixAxialChange.SetElement(2, 3, dataExtent[2] + sagittalMapperPosition[1]);
+                    vpanAxial.Render();
+                    vpanAxial.resetCamera();
+                    vtkMatrix4x4 matrixCoronalChange = resliceCoronal.GetResliceAxes();
+                    matrixCoronalChange.SetElement(1, 3, dataExtent[1] + sagittalMapperPosition[0]);
+                    vpanCoronal.Render();
+                    vpanCoronal.resetCamera();
+                }
+            }
+
+            public void mouseMoved(MouseEvent e) {
+            }
+        });
+    }
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JLabel jLabel1;
+    private javax.swing.JLabel lblAxialDisplay;
+    private javax.swing.JLabel lblCoronalDisplay;
+    private javax.swing.JPanel pnlAxialView;
+    private javax.swing.JPanel pnlCoronalView;
+    private javax.swing.JPanel pnlSagittalView;
+    // End of variables declaration//GEN-END:variables
+}
diff --git a/src/in/raster/mayam/form/dcm3d/DicomMPR3DSlider.form b/src/in/raster/mayam/form/dcm3d/DicomMPR3DSlider.form
new file mode 100644
index 0000000..d86d2db
--- /dev/null
+++ b/src/in/raster/mayam/form/dcm3d/DicomMPR3DSlider.form
@@ -0,0 +1,267 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
+  <Properties>
+    <Property name="defaultCloseOperation" type="int" value="2"/>
+    <Property name="title" type="java.lang.String" value="Dicom MPR ( Multi Planner Reconstruction ) 3D"/>
+    <Property name="resizable" type="boolean" value="false"/>
+  </Properties>
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <Events>
+    <EventHandler event="windowClosed" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="formWindowClosed"/>
+  </Events>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="1" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="1" attributes="0">
+                  <Component id="pnlView" alignment="0" max="32767" attributes="1"/>
+                  <Group type="102" alignment="0" attributes="1">
+                      <Component id="lblZoomInOut" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="lblRotate" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="lblMove" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="lblMouseReset" min="-2" pref="24" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="lblScreenshot" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace min="-2" pref="42" max="-2" attributes="0"/>
+                      <Component id="lblDisplayPurpose" min="-2" pref="442" max="-2" attributes="0"/>
+                      <EmptySpace pref="142" max="32767" attributes="0"/>
+                      <Component id="lblAxialView" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="lblCoronalView" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="lblSagittalView" min="-2" max="-2" attributes="0"/>
+                  </Group>
+                  <Group type="102" alignment="0" attributes="0">
+                      <Component id="cbxAxial" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="sdrAxial" min="-2" pref="178" max="-2" attributes="0"/>
+                      <EmptySpace type="unrelated" max="-2" attributes="0"/>
+                      <Component id="cbxCoronal" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="sdrCoronal" min="-2" pref="178" max="-2" attributes="0"/>
+                      <EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
+                      <Component id="cbxSagittal" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="sdrSagittal" min="-2" pref="178" max="-2" attributes="0"/>
+                  </Group>
+              </Group>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Component id="lblDisplayPurpose" pref="24" max="32767" attributes="0"/>
+                  <Component id="lblZoomInOut" alignment="0" max="32767" attributes="1"/>
+                  <Component id="lblRotate" alignment="0" pref="24" max="32767" attributes="1"/>
+                  <Group type="103" groupAlignment="3" attributes="0">
+                      <Component id="lblMove" alignment="3" min="-2" pref="21" max="-2" attributes="0"/>
+                      <Component id="lblMouseReset" alignment="3" min="-2" pref="21" max="-2" attributes="0"/>
+                      <Component id="lblScreenshot" alignment="3" min="-2" pref="21" max="-2" attributes="0"/>
+                  </Group>
+                  <Component id="lblSagittalView" pref="24" max="32767" attributes="0"/>
+                  <Component id="lblAxialView" alignment="1" pref="24" max="32767" attributes="1"/>
+                  <Component id="lblCoronalView" pref="24" max="32767" attributes="0"/>
+              </Group>
+              <EmptySpace max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Component id="sdrAxial" alignment="0" min="-2" pref="23" max="-2" attributes="0"/>
+                  <Component id="cbxAxial" alignment="0" min="-2" max="-2" attributes="0"/>
+                  <Component id="cbxCoronal" alignment="0" min="-2" max="-2" attributes="0"/>
+                  <Component id="sdrCoronal" min="-2" pref="23" max="-2" attributes="0"/>
+                  <Group type="103" alignment="0" groupAlignment="1" attributes="0">
+                      <Component id="sdrSagittal" alignment="1" min="-2" pref="23" max="-2" attributes="0"/>
+                      <Component id="cbxSagittal" alignment="1" min="-2" max="-2" attributes="0"/>
+                  </Group>
+              </Group>
+              <EmptySpace type="separate" max="-2" attributes="0"/>
+              <Component id="pnlView" min="-2" max="-2" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Container class="javax.swing.JPanel" name="pnlView">
+
+      <Layout>
+        <DimensionLayout dim="0">
+          <Group type="103" groupAlignment="0" attributes="0">
+              <EmptySpace min="0" pref="794" max="32767" attributes="0"/>
+          </Group>
+        </DimensionLayout>
+        <DimensionLayout dim="1">
+          <Group type="103" groupAlignment="0" attributes="0">
+              <EmptySpace min="0" pref="531" max="32767" attributes="0"/>
+          </Group>
+        </DimensionLayout>
+      </Layout>
+    </Container>
+    <Component class="javax.swing.JLabel" name="lblZoomInOut">
+      <Properties>
+        <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+          <Image iconType="3" name="/in/raster/mayam/form/images/ZoomInOut.png"/>
+        </Property>
+      </Properties>
+      <Events>
+        <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblZoomInOutMouseClicked"/>
+        <EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblZoomInOutMouseEntered"/>
+        <EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblZoomInOutMouseExited"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JLabel" name="lblRotate">
+      <Properties>
+        <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+          <Image iconType="3" name="/in/raster/mayam/form/images/RotateSurface.png"/>
+        </Property>
+      </Properties>
+      <Events>
+        <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblRotateMouseClicked"/>
+        <EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblRotateMouseEntered"/>
+        <EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblRotateMouseExited"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JLabel" name="lblMove">
+      <Properties>
+        <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+          <Image iconType="3" name="/in/raster/mayam/form/images/Move.png"/>
+        </Property>
+      </Properties>
+      <Events>
+        <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblMoveMouseClicked"/>
+        <EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblMoveMouseEntered"/>
+        <EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblMoveMouseExited"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JLabel" name="lblMouseReset">
+      <Properties>
+        <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+          <Image iconType="3" name="/in/raster/mayam/form/images/ResetInteractor.png"/>
+        </Property>
+      </Properties>
+      <Events>
+        <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblMouseResetMouseClicked"/>
+        <EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblMouseResetMouseEntered"/>
+        <EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblMouseResetMouseExited"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JLabel" name="lblScreenshot">
+      <Properties>
+        <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+          <Image iconType="3" name="/in/raster/mayam/form/images/ScreenShot.png"/>
+        </Property>
+      </Properties>
+      <Events>
+        <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblScreenshotMouseClicked"/>
+        <EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblScreenshotMouseEntered"/>
+        <EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblScreenshotMouseExited"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JCheckBox" name="cbxAxial">
+      <Properties>
+        <Property name="selected" type="boolean" value="true"/>
+        <Property name="text" type="java.lang.String" value="Axial"/>
+      </Properties>
+      <Events>
+        <EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="cbxAxialStateChanged"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JCheckBox" name="cbxCoronal">
+      <Properties>
+        <Property name="selected" type="boolean" value="true"/>
+        <Property name="text" type="java.lang.String" value="Coronal"/>
+      </Properties>
+      <Events>
+        <EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="cbxCoronalStateChanged"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JCheckBox" name="cbxSagittal">
+      <Properties>
+        <Property name="selected" type="boolean" value="true"/>
+        <Property name="text" type="java.lang.String" value="Sagittal"/>
+      </Properties>
+      <Events>
+        <EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="cbxSagittalStateChanged"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JSlider" name="sdrAxial">
+      <Events>
+        <EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="sdrAxialStateChanged"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JSlider" name="sdrCoronal">
+      <Events>
+        <EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="sdrCoronalStateChanged"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JSlider" name="sdrSagittal">
+      <Events>
+        <EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="sdrSagittalStateChanged"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JLabel" name="lblAxialView">
+      <Properties>
+        <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+          <Image iconType="3" name="/in/raster/mayam/form/images/AxialView.png"/>
+        </Property>
+      </Properties>
+      <Events>
+        <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblAxialViewMouseClicked"/>
+        <EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblAxialViewMouseEntered"/>
+        <EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblAxialViewMouseExited"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JLabel" name="lblCoronalView">
+      <Properties>
+        <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+          <Image iconType="3" name="/in/raster/mayam/form/images/CoronalView.png"/>
+        </Property>
+      </Properties>
+      <Events>
+        <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblCoronalViewMouseClicked"/>
+        <EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblCoronalViewMouseEntered"/>
+        <EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblCoronalViewMouseExited"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JLabel" name="lblSagittalView">
+      <Properties>
+        <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+          <Image iconType="3" name="/in/raster/mayam/form/images/SagittalView.png"/>
+        </Property>
+      </Properties>
+      <Events>
+        <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblSagittalViewMouseClicked"/>
+        <EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblSagittalViewMouseEntered"/>
+        <EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblSagittalViewMouseExited"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JLabel" name="lblDisplayPurpose">
+      <Properties>
+        <Property name="horizontalAlignment" type="int" value="0"/>
+        <Property name="text" type="java.lang.String" value="Dicom MPR ( Multi Planner Reconstruction ) 3D"/>
+      </Properties>
+    </Component>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/dcm3d/DicomMPR3DSlider.java b/src/in/raster/mayam/form/dcm3d/DicomMPR3DSlider.java
new file mode 100644
index 0000000..b57c8b7
--- /dev/null
+++ b/src/in/raster/mayam/form/dcm3d/DicomMPR3DSlider.java
@@ -0,0 +1,967 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Guru Rajan R
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Sathish Kumar V
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form.dcm3d;
+
+import java.awt.Color;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionListener;
+import java.io.File;
+import javax.swing.filechooser.FileFilter;
+import javax.swing.JFileChooser;
+import vtk.vtkCamera;
+import vtk.vtkCanvas;
+import vtk.vtkDICOMImageReader;
+import vtk.vtkImageActor;
+import vtk.vtkImageMapToColors;
+import vtk.vtkImageReslice;
+import vtk.vtkLight;
+import vtk.vtkLightCollection;
+import vtk.vtkLookupTable;
+import vtk.vtkMatrix4x4;
+import vtk.vtkPanel;
+
+/**
+ * @author Sathish Kumar V      (sathishkumar.v at raster.in)
+ */
+public class DicomMPR3DSlider extends javax.swing.JFrame {
+    // Global Variable declarations...
+
+    private vtkPanel vpan3DMPRView = new vtkPanel();
+    public vtkDICOMImageReader reader = new vtkDICOMImageReader();
+    private vtkImageActor axialActor = new vtkImageActor();
+    private vtkImageActor coronalActor = new vtkImageActor();
+    private vtkImageActor sagittalActor = new vtkImageActor();
+    private vtkImageReslice axialReslice = new vtkImageReslice();
+    private vtkImageReslice coronalReslice = new vtkImageReslice();
+    private vtkImageReslice sagittalReslice = new vtkImageReslice();
+    private int xMin, xMax, yMin, yMax, zMin, zMax, mode, lastX, lastY, doDragFlag = 0;
+    private double sx, sy, sz, ox, oy, oz;
+    private vtkCamera camera;
+
+    static {
+        System.loadLibrary("vtkCommonJava");
+        System.loadLibrary("vtkFilteringJava");
+        System.loadLibrary("vtkIOJava");
+        System.loadLibrary("vtkImagingJava");
+        System.loadLibrary("vtkGraphicsJava");
+        System.loadLibrary("vtkRenderingJava");
+    }
+
+    /** Creates new form DicomMPR3DSlider */
+    public DicomMPR3DSlider() {
+        initComponents();
+        vpan3DMPRView.setSize(pnlView.getSize());
+        vpan3DMPRView.setBackground(Color.white);
+
+    }
+
+    @SuppressWarnings("unchecked")
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        pnlView = new javax.swing.JPanel();
+        lblZoomInOut = new javax.swing.JLabel();
+        lblRotate = new javax.swing.JLabel();
+        lblMove = new javax.swing.JLabel();
+        lblMouseReset = new javax.swing.JLabel();
+        lblScreenshot = new javax.swing.JLabel();
+        cbxAxial = new javax.swing.JCheckBox();
+        cbxCoronal = new javax.swing.JCheckBox();
+        cbxSagittal = new javax.swing.JCheckBox();
+        sdrAxial = new javax.swing.JSlider();
+        sdrCoronal = new javax.swing.JSlider();
+        sdrSagittal = new javax.swing.JSlider();
+        lblAxialView = new javax.swing.JLabel();
+        lblCoronalView = new javax.swing.JLabel();
+        lblSagittalView = new javax.swing.JLabel();
+        lblDisplayPurpose = new javax.swing.JLabel();
+
+        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+        setTitle("Dicom MPR ( Multi Planner Reconstruction ) 3D");
+        setResizable(false);
+        addWindowListener(new java.awt.event.WindowAdapter() {
+            public void windowClosed(java.awt.event.WindowEvent evt) {
+                formWindowClosed(evt);
+            }
+        });
+
+        javax.swing.GroupLayout pnlViewLayout = new javax.swing.GroupLayout(pnlView);
+        pnlView.setLayout(pnlViewLayout);
+        pnlViewLayout.setHorizontalGroup(
+            pnlViewLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGap(0, 794, Short.MAX_VALUE)
+        );
+        pnlViewLayout.setVerticalGroup(
+            pnlViewLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGap(0, 531, Short.MAX_VALUE)
+        );
+
+        lblZoomInOut.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/ZoomInOut.png"))); // NOI18N
+        lblZoomInOut.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                lblZoomInOutMouseClicked(evt);
+            }
+            public void mouseEntered(java.awt.event.MouseEvent evt) {
+                lblZoomInOutMouseEntered(evt);
+            }
+            public void mouseExited(java.awt.event.MouseEvent evt) {
+                lblZoomInOutMouseExited(evt);
+            }
+        });
+
+        lblRotate.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/RotateSurface.png"))); // NOI18N
+        lblRotate.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                lblRotateMouseClicked(evt);
+            }
+            public void mouseEntered(java.awt.event.MouseEvent evt) {
+                lblRotateMouseEntered(evt);
+            }
+            public void mouseExited(java.awt.event.MouseEvent evt) {
+                lblRotateMouseExited(evt);
+            }
+        });
+
+        lblMove.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/Move.png"))); // NOI18N
+        lblMove.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                lblMoveMouseClicked(evt);
+            }
+            public void mouseEntered(java.awt.event.MouseEvent evt) {
+                lblMoveMouseEntered(evt);
+            }
+            public void mouseExited(java.awt.event.MouseEvent evt) {
+                lblMoveMouseExited(evt);
+            }
+        });
+
+        lblMouseReset.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/ResetInteractor.png"))); // NOI18N
+        lblMouseReset.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                lblMouseResetMouseClicked(evt);
+            }
+            public void mouseEntered(java.awt.event.MouseEvent evt) {
+                lblMouseResetMouseEntered(evt);
+            }
+            public void mouseExited(java.awt.event.MouseEvent evt) {
+                lblMouseResetMouseExited(evt);
+            }
+        });
+
+        lblScreenshot.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/ScreenShot.png"))); // NOI18N
+        lblScreenshot.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                lblScreenshotMouseClicked(evt);
+            }
+            public void mouseEntered(java.awt.event.MouseEvent evt) {
+                lblScreenshotMouseEntered(evt);
+            }
+            public void mouseExited(java.awt.event.MouseEvent evt) {
+                lblScreenshotMouseExited(evt);
+            }
+        });
+
+        cbxAxial.setSelected(true);
+        cbxAxial.setText("Axial");
+        cbxAxial.addChangeListener(new javax.swing.event.ChangeListener() {
+            public void stateChanged(javax.swing.event.ChangeEvent evt) {
+                cbxAxialStateChanged(evt);
+            }
+        });
+
+        cbxCoronal.setSelected(true);
+        cbxCoronal.setText("Coronal");
+        cbxCoronal.addChangeListener(new javax.swing.event.ChangeListener() {
+            public void stateChanged(javax.swing.event.ChangeEvent evt) {
+                cbxCoronalStateChanged(evt);
+            }
+        });
+
+        cbxSagittal.setSelected(true);
+        cbxSagittal.setText("Sagittal");
+        cbxSagittal.addChangeListener(new javax.swing.event.ChangeListener() {
+            public void stateChanged(javax.swing.event.ChangeEvent evt) {
+                cbxSagittalStateChanged(evt);
+            }
+        });
+
+        sdrAxial.addChangeListener(new javax.swing.event.ChangeListener() {
+            public void stateChanged(javax.swing.event.ChangeEvent evt) {
+                sdrAxialStateChanged(evt);
+            }
+        });
+
+        sdrCoronal.addChangeListener(new javax.swing.event.ChangeListener() {
+            public void stateChanged(javax.swing.event.ChangeEvent evt) {
+                sdrCoronalStateChanged(evt);
+            }
+        });
+
+        sdrSagittal.addChangeListener(new javax.swing.event.ChangeListener() {
+            public void stateChanged(javax.swing.event.ChangeEvent evt) {
+                sdrSagittalStateChanged(evt);
+            }
+        });
+
+        lblAxialView.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/AxialView.png"))); // NOI18N
+        lblAxialView.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                lblAxialViewMouseClicked(evt);
+            }
+            public void mouseEntered(java.awt.event.MouseEvent evt) {
+                lblAxialViewMouseEntered(evt);
+            }
+            public void mouseExited(java.awt.event.MouseEvent evt) {
+                lblAxialViewMouseExited(evt);
+            }
+        });
+
+        lblCoronalView.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/CoronalView.png"))); // NOI18N
+        lblCoronalView.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                lblCoronalViewMouseClicked(evt);
+            }
+            public void mouseEntered(java.awt.event.MouseEvent evt) {
+                lblCoronalViewMouseEntered(evt);
+            }
+            public void mouseExited(java.awt.event.MouseEvent evt) {
+                lblCoronalViewMouseExited(evt);
+            }
+        });
+
+        lblSagittalView.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/SagittalView.png"))); // NOI18N
+        lblSagittalView.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                lblSagittalViewMouseClicked(evt);
+            }
+            public void mouseEntered(java.awt.event.MouseEvent evt) {
+                lblSagittalViewMouseEntered(evt);
+            }
+            public void mouseExited(java.awt.event.MouseEvent evt) {
+                lblSagittalViewMouseExited(evt);
+            }
+        });
+
+        lblDisplayPurpose.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+        lblDisplayPurpose.setText("Dicom MPR ( Multi Planner Reconstruction ) 3D");
+
+        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
+        getContentPane().setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
+                .addContainerGap()
+                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+                    .addComponent(pnlView, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
+                        .addComponent(lblZoomInOut)
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                        .addComponent(lblRotate)
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                        .addComponent(lblMove)
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                        .addComponent(lblMouseReset, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                        .addComponent(lblScreenshot)
+                        .addGap(42, 42, 42)
+                        .addComponent(lblDisplayPurpose, javax.swing.GroupLayout.PREFERRED_SIZE, 442, javax.swing.GroupLayout.PREFERRED_SIZE)
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 70, Short.MAX_VALUE)
+                        .addComponent(lblAxialView)
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                        .addComponent(lblCoronalView)
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                        .addComponent(lblSagittalView))
+                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
+                        .addComponent(cbxAxial)
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                        .addComponent(sdrAxial, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE)
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+                        .addComponent(cbxCoronal)
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                        .addComponent(sdrCoronal, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE)
+                        .addGap(18, 18, 18)
+                        .addComponent(cbxSagittal)
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                        .addComponent(sdrSagittal, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE)))
+                .addContainerGap())
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGroup(layout.createSequentialGroup()
+                .addContainerGap()
+                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                    .addComponent(lblDisplayPurpose, javax.swing.GroupLayout.DEFAULT_SIZE, 24, Short.MAX_VALUE)
+                    .addComponent(lblZoomInOut, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                    .addComponent(lblRotate, javax.swing.GroupLayout.DEFAULT_SIZE, 24, Short.MAX_VALUE)
+                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+                        .addComponent(lblMove, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
+                        .addComponent(lblMouseReset, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
+                        .addComponent(lblScreenshot, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE))
+                    .addComponent(lblSagittalView, javax.swing.GroupLayout.DEFAULT_SIZE, 24, Short.MAX_VALUE)
+                    .addComponent(lblAxialView, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 24, Short.MAX_VALUE)
+                    .addComponent(lblCoronalView, javax.swing.GroupLayout.DEFAULT_SIZE, 24, Short.MAX_VALUE))
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                    .addComponent(sdrAxial, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
+                    .addComponent(cbxAxial)
+                    .addComponent(cbxCoronal)
+                    .addComponent(sdrCoronal, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
+                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+                        .addComponent(sdrSagittal, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
+                        .addComponent(cbxSagittal)))
+                .addGap(18, 18, 18)
+                .addComponent(pnlView, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+                .addContainerGap())
+        );
+
+        pack();
+    }// </editor-fold>//GEN-END:initComponents
+
+    private void cbxAxialStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_cbxAxialStateChanged
+        // show or hide the Axial slice...
+        if (cbxAxial.isSelected()) {
+            vpan3DMPRView.GetRenderer().AddActor(axialActor);
+            vpan3DMPRView.repaint();
+            sdrAxial.setEnabled(true);
+        } else {
+            if (cbxCoronal.isSelected() || cbxSagittal.isSelected()) {
+                vpan3DMPRView.GetRenderer().RemoveActor(axialActor);
+                vpan3DMPRView.repaint();
+                sdrAxial.setEnabled(false);
+            } else {
+                cbxAxial.setSelected(true);
+            }
+        }
+
+    }//GEN-LAST:event_cbxAxialStateChanged
+
+    private void cbxCoronalStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_cbxCoronalStateChanged
+        // show or hide the Coronal slice...
+        if (cbxCoronal.isSelected()) {
+            vpan3DMPRView.GetRenderer().AddActor(coronalActor);
+            vpan3DMPRView.repaint();
+            sdrCoronal.setEnabled(true);
+        } else {
+            if (cbxAxial.isSelected() || cbxSagittal.isSelected()) {
+                vpan3DMPRView.GetRenderer().RemoveActor(coronalActor);
+                vpan3DMPRView.repaint();
+                sdrCoronal.setEnabled(false);
+            } else {
+                cbxCoronal.setSelected(true);
+            }
+        }
+    }//GEN-LAST:event_cbxCoronalStateChanged
+
+    private void cbxSagittalStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_cbxSagittalStateChanged
+        // show or hide the Sagittal slice...
+        if (cbxSagittal.isSelected()) {
+            vpan3DMPRView.GetRenderer().AddActor(sagittalActor);
+            vpan3DMPRView.repaint();
+            sdrSagittal.setEnabled(true);
+        } else {
+            if (cbxAxial.isSelected() || cbxCoronal.isSelected()) {
+                vpan3DMPRView.GetRenderer().RemoveActor(sagittalActor);
+                vpan3DMPRView.repaint();
+                sdrSagittal.setEnabled(false);
+            } else {
+                cbxSagittal.setSelected(true);
+            }
+        }
+    }//GEN-LAST:event_cbxSagittalStateChanged
+
+    private void sdrAxialStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_sdrAxialStateChanged
+        // Change the Axial slice, according to the axilaSlider value...
+        vtkMatrix4x4 matrixAxialChange = axialReslice.GetResliceAxes();
+        matrixAxialChange.SetElement(2, 3, ((Double.valueOf(sdrAxial.getValue()) / 100) * (reader.GetOutput().GetCenter()[2] * 2)));
+        axialActor.SetPosition(0, ((Double.valueOf(50 - sdrAxial.getValue()) / 100) * (reader.GetOutput().GetCenter()[2] * 2)), 0);
+        vpan3DMPRView.GetRenderer().ResetCameraClippingRange();
+        vpan3DMPRView.repaint();
+    }//GEN-LAST:event_sdrAxialStateChanged
+
+    private void sdrCoronalStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_sdrCoronalStateChanged
+        // Change the Coronal slice, according to the axilaSlider value...
+        vtkMatrix4x4 matrixCoronalChange = coronalReslice.GetResliceAxes();
+        matrixCoronalChange.SetElement(1, 3, ((Double.valueOf(sdrCoronal.getValue()) / 100) * (reader.GetOutput().GetCenter()[1] * 2)));
+        coronalActor.SetPosition(0, 0, ((Double.valueOf(sdrCoronal.getValue() - 50) / 100) * (reader.GetOutput().GetCenter()[1] * 2)));
+        vpan3DMPRView.GetRenderer().ResetCameraClippingRange();
+        vpan3DMPRView.repaint();
+    }//GEN-LAST:event_sdrCoronalStateChanged
+
+    private void sdrSagittalStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_sdrSagittalStateChanged
+        // Change the Sagittal slice, according to the axilaSlider value...
+        vtkMatrix4x4 matrixSagittalChange = sagittalReslice.GetResliceAxes();
+        matrixSagittalChange.SetElement(0, 3, ((Double.valueOf(sdrSagittal.getValue()) / 100) * (reader.GetOutput().GetCenter()[0] * 2)));
+        sagittalActor.SetPosition(((Double.valueOf(sdrSagittal.getValue() - 50) / 100) * (reader.GetOutput().GetCenter()[0] * 2)), 0, 0);
+        vpan3DMPRView.GetRenderer().ResetCameraClippingRange();
+        vpan3DMPRView.repaint();
+    }//GEN-LAST:event_sdrSagittalStateChanged
+
+    private void lblZoomInOutMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblZoomInOutMouseClicked
+        vpan3DMPRView.removeMouseListener(vpan3DMPRView);
+        vpan3DMPRView.removeMouseMotionListener(vpan3DMPRView);
+        mode = 1;
+        vpan3DMPRView.addMouseListener(myMouseListener);
+        vpan3DMPRView.addMouseMotionListener(myMouseMotionListener);
+    }//GEN-LAST:event_lblZoomInOutMouseClicked
+
+    private void lblRotateMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblRotateMouseClicked
+        //  Set the interaction for Rotate...
+        vpan3DMPRView.removeMouseListener(vpan3DMPRView);
+        vpan3DMPRView.removeMouseMotionListener(vpan3DMPRView);
+        mode = 2;
+        vpan3DMPRView.addMouseListener(myMouseListener);
+        vpan3DMPRView.addMouseMotionListener(myMouseMotionListener);
+    }//GEN-LAST:event_lblRotateMouseClicked
+
+    private void lblMoveMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblMoveMouseClicked
+        // Set the interaction for Move...
+        vpan3DMPRView.removeMouseListener(vpan3DMPRView);
+        vpan3DMPRView.removeMouseMotionListener(vpan3DMPRView);
+        mode = 3;
+        vpan3DMPRView.addMouseListener(myMouseListener);
+        vpan3DMPRView.addMouseMotionListener(myMouseMotionListener);
+    }//GEN-LAST:event_lblMoveMouseClicked
+
+    private void lblMouseResetMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblMouseResetMouseClicked
+        // Set the Default Interactor..
+        vpan3DMPRView.removeMouseListener(myMouseListener);
+        vpan3DMPRView.removeMouseMotionListener(myMouseMotionListener);
+        mode = 0;
+        vpan3DMPRView.addMouseListener(vpan3DMPRView);
+        vpan3DMPRView.addMouseMotionListener(vpan3DMPRView);
+    }//GEN-LAST:event_lblMouseResetMouseClicked
+
+    private void lblScreenshotMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblScreenshotMouseClicked
+        // Code for capture the view as an Image...
+
+        // ask for the filename...
+        JFileChooser fc = new JFileChooser();
+        FileFilter filter = new FileFilter() {
+
+            @Override
+            public boolean accept(File file) {
+                if (file.isDirectory()) {
+                    return true;
+                }
+                String extension = null;
+                String s = file.getName();
+                int i = s.lastIndexOf('.');
+                if (i > 0 && i < s.length() - 1) {
+                    extension = s.substring(i + 1).toLowerCase();
+                }
+                if (extension != null) {
+                    if (extension.equals("tiff") || extension.equals("tif")) {
+                        return true;
+                    } else {
+                        return false;
+                    }
+                } else {
+                    return false;
+                }
+            }
+
+            public String getDescription() {
+                return "tiff/tif Images";
+            }
+        };
+
+        fc.setFileFilter(filter);
+        int returnVal = fc.showSaveDialog(this);
+        if (returnVal == JFileChooser.APPROVE_OPTION) {
+            File file = fc.getSelectedFile();
+            // Capture and Save the image...
+            String extension = null;
+            String s = file.getName();
+            int i = s.lastIndexOf('.');
+            if (i > 0 && i < s.length() - 1) {
+                extension = s.substring(i + 1).toLowerCase();
+                if (extension.equals("tif") || extension.equals("tiff")) {
+                    vpan3DMPRView.HardCopy(file.getAbsolutePath(), 1);
+                } else {
+                    vpan3DMPRView.HardCopy(file.getAbsolutePath().concat(".tif"), 1);
+                }
+            } else {
+                vpan3DMPRView.HardCopy(file.getAbsolutePath().concat(".tif"), 1);
+            }
+        }
+        //Reset the file chooser for the next time it's shown.
+
+        fc.setSelectedFile(null);
+    }//GEN-LAST:event_lblScreenshotMouseClicked
+
+    private void lblZoomInOutMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblZoomInOutMouseEntered
+        // Code For Display the purpose of lblZoomInOut Icon
+        lblDisplayPurpose.setText("Zoom in/out the 3D MPR");
+    }//GEN-LAST:event_lblZoomInOutMouseEntered
+
+    private void lblZoomInOutMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblZoomInOutMouseExited
+        // Code For Display the purpose of lblZoomInOut Icon
+        lblDisplayPurpose.setText("");
+    }//GEN-LAST:event_lblZoomInOutMouseExited
+
+    private void lblRotateMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblRotateMouseEntered
+        // Code For Display the purpose of lblRotate Icon
+        lblDisplayPurpose.setText("Rotate the 3D MPR");
+    }//GEN-LAST:event_lblRotateMouseEntered
+
+    private void lblRotateMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblRotateMouseExited
+        // Code For Display the purpose of lblRotate Icon
+        lblDisplayPurpose.setText("");
+    }//GEN-LAST:event_lblRotateMouseExited
+
+    private void lblMoveMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblMoveMouseEntered
+        // Code For Display the purpose of lblMove Icon
+        lblDisplayPurpose.setText("Move the 3D MPR");
+    }//GEN-LAST:event_lblMoveMouseEntered
+
+    private void lblMoveMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblMoveMouseExited
+        // Code For Display the purpose of lblMove Icon
+        lblDisplayPurpose.setText("");
+    }//GEN-LAST:event_lblMoveMouseExited
+
+    private void lblMouseResetMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblMouseResetMouseEntered
+        // Code For Display the purpose of lblMouseReset Icon
+        lblDisplayPurpose.setText("Reset the Mouse Operations");
+    }//GEN-LAST:event_lblMouseResetMouseEntered
+
+    private void lblMouseResetMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblMouseResetMouseExited
+        // Code For Display the purpose of lblMouseReset Icon
+        lblDisplayPurpose.setText("");
+    }//GEN-LAST:event_lblMouseResetMouseExited
+
+    private void lblScreenshotMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblScreenshotMouseEntered
+        // Code For Display the purpose of lblScreenshot Icon
+        lblDisplayPurpose.setText("Save the view as Screenshot");
+    }//GEN-LAST:event_lblScreenshotMouseEntered
+
+    private void lblScreenshotMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblScreenshotMouseExited
+        // Code For Display the purpose of lblScreenshot Icon
+        lblDisplayPurpose.setText("");
+    }//GEN-LAST:event_lblScreenshotMouseExited
+
+    private void lblAxialViewMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblAxialViewMouseClicked
+        // TODO add your handling code here:
+        AlignCamera(1);
+    }//GEN-LAST:event_lblAxialViewMouseClicked
+
+    private void lblAxialViewMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblAxialViewMouseEntered
+        // Code For Display the purpose of lblAxialView Icon
+        lblDisplayPurpose.setText("Display the 3D MPR in Axial View");
+    }//GEN-LAST:event_lblAxialViewMouseEntered
+
+    private void lblAxialViewMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblAxialViewMouseExited
+        // Code For Display the purpose of lblAxialView Icon
+        lblDisplayPurpose.setText("");
+    }//GEN-LAST:event_lblAxialViewMouseExited
+
+    private void lblCoronalViewMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblCoronalViewMouseClicked
+        // TODO add your handling code here:
+        AlignCamera(2);
+    }//GEN-LAST:event_lblCoronalViewMouseClicked
+
+    private void lblCoronalViewMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblCoronalViewMouseEntered
+        // Code For Display the purpose of lblCoronalView Icon
+        lblDisplayPurpose.setText("Display the 3D MPR in Coronal View");
+    }//GEN-LAST:event_lblCoronalViewMouseEntered
+
+    private void lblCoronalViewMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblCoronalViewMouseExited
+        // Code For Display the purpose of lblCoronalView Icon
+        lblDisplayPurpose.setText("");
+    }//GEN-LAST:event_lblCoronalViewMouseExited
+
+    private void lblSagittalViewMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblSagittalViewMouseClicked
+        // TODO add your handling code here:
+        AlignCamera(0);
+    }//GEN-LAST:event_lblSagittalViewMouseClicked
+
+    private void lblSagittalViewMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblSagittalViewMouseEntered
+        // Code For Display the purpose of lblSagittalView Icon
+        lblDisplayPurpose.setText("Display the 3D MPR in Sagittal View");
+    }//GEN-LAST:event_lblSagittalViewMouseEntered
+
+    private void lblSagittalViewMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblSagittalViewMouseExited
+        // Code For Display the purpose of lblSagittalView Icon
+        lblDisplayPurpose.setText("");
+    }//GEN-LAST:event_lblSagittalViewMouseExited
+
+    private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
+        //   vtkGlobalJavaHash.DeleteAll();
+    }//GEN-LAST:event_formWindowClosed
+
+    public static void main(String args[]) {
+        java.awt.EventQueue.invokeLater(new Runnable() {
+
+            public void run() {
+                new DicomMPR3DSlider().setVisible(true);
+            }
+        });
+    }
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JCheckBox cbxAxial;
+    private javax.swing.JCheckBox cbxCoronal;
+    private javax.swing.JCheckBox cbxSagittal;
+    private javax.swing.JLabel lblAxialView;
+    private javax.swing.JLabel lblCoronalView;
+    private javax.swing.JLabel lblDisplayPurpose;
+    private javax.swing.JLabel lblMouseReset;
+    private javax.swing.JLabel lblMove;
+    private javax.swing.JLabel lblRotate;
+    private javax.swing.JLabel lblSagittalView;
+    private javax.swing.JLabel lblScreenshot;
+    private javax.swing.JLabel lblZoomInOut;
+    private javax.swing.JPanel pnlView;
+    private javax.swing.JSlider sdrAxial;
+    private javax.swing.JSlider sdrCoronal;
+    private javax.swing.JSlider sdrSagittal;
+    // End of variables declaration//GEN-END:variables
+
+    public void readDicom(String dirName) {
+        reader.SetDirectoryName(dirName);
+        reader.Update();
+
+        int[] xyminmax = reader.GetOutput().GetWholeExtent();
+        xMin = xyminmax[0];
+        xMax = xyminmax[1];
+        yMin = xyminmax[2];
+        yMax = xyminmax[3];
+        zMin = xyminmax[4];
+        zMax = xyminmax[5];
+
+        double[] spacing = reader.GetOutput().GetSpacing();
+        sx = spacing[0];
+        sy = spacing[1];
+        sz = spacing[2];
+
+        double[] origin = reader.GetOutput().GetOrigin();
+        ox = origin[0];
+        oy = origin[1];
+        oz = origin[2];
+
+        // Call the Method to display the slices...
+        displayMPRView();
+    }
+
+    private void displayMPRView() {
+
+        double[] center = reader.GetOutput().GetCenter();
+
+
+        double[] axialElements = {1, 0, 0, center[0], 0, 1, 0, center[1], 0, 0, 1, center[2], 0, 0, 0, 1};
+        double[] coronalElements = {1, 0, 0, center[0], 0, 0, 1, center[1], 0, -1, 0, center[2], 0, 0, 0, 1};
+        double[] sagittalElements = {0, 0, -1, center[0], 1, 0, 0, center[1], 0, -1, 0, center[2], 0, 0, 0, 1};
+
+        // For display the Axial Slice...
+
+        // Set the slice orientation...
+        vtkMatrix4x4 axialResliceAxes = new vtkMatrix4x4();
+        axialResliceAxes.DeepCopy(axialElements);
+
+        // Extract a slice in the desired orientation...        
+        axialReslice.SetInputConnection(reader.GetOutputPort());
+        axialReslice.SetOutputDimensionality(2);
+        axialReslice.SetResliceAxes(axialResliceAxes);
+        axialReslice.SetInterpolationModeToNearestNeighbor();
+
+        // Create a greyscale lookup table...
+        vtkLookupTable axialTable = new vtkLookupTable();
+        axialTable.SetRange(0, 100); // image intensity range
+        axialTable.SetValueRange(0.0, 1.0); // from black to white
+        axialTable.SetSaturationRange(0.0, 0.0); // no color saturation
+        axialTable.SetRampToLinear();
+        axialTable.Build();
+
+        // Map the image through the lookup table...
+        vtkImageMapToColors axialColor = new vtkImageMapToColors();
+        axialColor.SetLookupTable(axialTable);
+        axialColor.SetInputConnection(axialReslice.GetOutputPort());
+
+        // Display the image...
+        axialActor.SetInput(axialColor.GetOutput());
+        axialActor.SetInput(axialColor.GetOutput());
+
+        // For display the Coronal Slice...
+
+        // Set the slice orientation...
+        vtkMatrix4x4 coronalResliceAxes = new vtkMatrix4x4();
+        coronalResliceAxes.DeepCopy(coronalElements);
+
+        // Extract a slice in the desired orientation...        
+        coronalReslice.SetInputConnection(reader.GetOutputPort());
+        coronalReslice.SetOutputDimensionality(2);
+        coronalReslice.SetResliceAxes(coronalResliceAxes);
+        coronalReslice.SetInterpolationModeToNearestNeighbor();
+
+        // Create a greyscale lookup table...
+        vtkLookupTable coronalTable = new vtkLookupTable();
+        coronalTable.SetRange(0, 100); // image intensity range
+        coronalTable.SetValueRange(0.0, 1.0); // from black to white
+        coronalTable.SetSaturationRange(0.0, 0.0); // no color saturation
+        coronalTable.SetRampToLinear();
+        coronalTable.Build();
+
+        // Map the image through the lookup table...
+        vtkImageMapToColors coronalColor = new vtkImageMapToColors();
+        coronalColor.SetLookupTable(coronalTable);
+        coronalColor.SetInputConnection(coronalReslice.GetOutputPort());
+
+        // Display the image...
+        coronalActor.SetInput(coronalColor.GetOutput());
+
+        // For display the Sagittal Slice...
+        // Set the slice orientation...
+        vtkMatrix4x4 sagittalResliceAxes = new vtkMatrix4x4();
+        sagittalResliceAxes.DeepCopy(sagittalElements);
+
+        // Extract a slice in the desired orientation        
+        sagittalReslice.SetInputConnection(reader.GetOutputPort());
+        sagittalReslice.SetOutputDimensionality(2);
+        sagittalReslice.SetResliceAxes(sagittalResliceAxes);
+        sagittalReslice.SetInterpolationModeToNearestNeighbor();
+
+        // Create a greyscale lookup table
+        vtkLookupTable sagittalTable = new vtkLookupTable();
+        sagittalTable.SetRange(0, 100); // image intensity range
+        sagittalTable.SetValueRange(0.0, 1.0); // from black to white
+        sagittalTable.SetSaturationRange(0.0, 0.0); // no color saturation
+        sagittalTable.SetRampToLinear();
+        sagittalTable.Build();
+
+
+        // Map the image through the lookup table
+        vtkImageMapToColors sagittalColor = new vtkImageMapToColors();
+        sagittalColor.SetLookupTable(sagittalTable);
+        sagittalColor.SetInputConnection(sagittalReslice.GetOutputPort());
+
+        // Display the image
+        sagittalActor.SetInput(sagittalColor.GetOutput());
+
+        //Consider for positioning
+        axialActor.RotateX(90);
+        sagittalActor.RotateY(270);
+
+        // Display Axial, Coronal and Sagittal views into vtkPanel
+        vpan3DMPRView.GetRenderer().AddActor(axialActor);
+        vpan3DMPRView.GetRenderer().AddActor(coronalActor);
+        vpan3DMPRView.GetRenderer().AddActor(sagittalActor);
+        vpan3DMPRView.GetRenderer().SetBackground(0, 0, 0);
+        vpan3DMPRView.GetRenderer().ResetCamera();
+        pnlView.add(vpan3DMPRView);
+        vpan3DMPRView.repaint();
+    }
+
+    void AlignCamera(int iaxis) {
+
+        double cx = (ox + (0.5 * (xMax - xMin)) * sx);
+        double cy = (oy + (0.5 * (yMax - yMin)) * sy);
+        double cz = (oy + (0.5 * (zMax - zMin)) * sz);
+        double vx = 0;
+        double vy = 0;
+        double vz = 0;
+        double nx = 0;
+        double ny = 0;
+        double nz = 0;
+        if (iaxis == 0) {
+            vz = -1;
+            nx = (ox + xMax * sx);
+            cx = (ox + sx);
+        } else if (iaxis == 1) {
+            vz = -1;
+            ny = (oy + yMax * sy);
+            cy = (oy + sy);
+
+        } else {
+            vy = 1;
+            nz = (oz + zMax * sz);
+            cz = (oz + sz);
+        }
+        double px = (cx + nx * 2);
+        double py = (cy + ny * 2);
+        double pz = (cz + nz * 3);
+
+        camera = vpan3DMPRView.GetRenderer().GetActiveCamera();
+        camera.SetViewUp(vx, vy, vz);
+        camera.SetFocalPoint(cx, cy, cz);
+        camera.SetPosition(px, py, pz);
+        camera.OrthogonalizeViewUp();
+        if (iaxis == 0) {
+            camera.Roll(-90);
+        } else if (iaxis == 1) {
+            camera.Roll(180);
+        }
+
+        // Reset the light...
+        vtkLightCollection Lights = vpan3DMPRView.GetRenderer().GetLights();
+        int nLights = Lights.GetNumberOfItems();
+        vtkLight light;
+        double[] pos = camera.GetPosition();
+        double[] fp = camera.GetFocalPoint();
+        Lights.InitTraversal();
+        for (int i = 0; i < nLights; i++) {
+            light = Lights.GetNextItem();
+            light.SetPosition(pos);
+            light.SetFocalPoint(fp);
+            light.Modified();
+        }
+
+        vpan3DMPRView.GetRenderer().ResetCameraClippingRange();
+        vpan3DMPRView.GetRenderer().ResetCamera();
+        vpan3DMPRView.GetRenderer().WorldToView();
+        vpan3DMPRView.repaint();
+    }
+    MouseListener myMouseListener = new MouseListener() {
+
+        public void mouseClicked(MouseEvent me) {
+        }
+
+        public void mousePressed(MouseEvent me) {
+            lastX = me.getX();
+            lastY = me.getY();
+        }
+
+        public void mouseReleased(MouseEvent me) {
+        }
+
+        public void mouseEntered(MouseEvent me) {
+        }
+
+        public void mouseExited(MouseEvent me) {
+        }
+    };
+    MouseMotionListener myMouseMotionListener = new MouseMotionListener() {
+
+        public void mouseDragged(MouseEvent me) {
+
+            vpan3DMPRView.lock();
+            if (doDragFlag > 0) {
+                doDragFlag--;
+            } else {
+                int x = me.getX();
+                int y = me.getY();
+                vtkCamera cam = vpan3DMPRView.GetRenderer().GetActiveCamera();
+
+                if (mode == 1) {            // Zoom In/Out Surface...
+                    if (vpan3DMPRView.GetRenderer().VisibleActorCount() == 0) {
+                        return;
+                    }
+                    double zoomFactor;
+                    zoomFactor = Math.pow(1.02, (y - lastY));
+                    if (cam.GetParallelProjection() == 1) {
+                        cam.SetParallelScale(cam.GetParallelScale() / zoomFactor);
+                    } else {
+                        cam.Dolly(zoomFactor);
+                        vpan3DMPRView.resetCameraClippingRange();
+                    }
+                } else if (mode == 2) {     // Rotate Surface...
+
+                    if (vpan3DMPRView.GetRenderer().VisibleActorCount() == 0) {
+                        return;
+                    }
+                    if (x > vpan3DMPRView.getWidth() / 2.0) {
+                        cam.Roll(-(y - lastY));
+                    } else {
+                        cam.Roll((y - lastY));
+                    }
+                    if (y < vpan3DMPRView.getHeight() / 2.0) {
+                        cam.Roll(-(x - lastX));
+                    } else {
+                        cam.Roll((x - lastX));
+                    }
+                    vpan3DMPRView.resetCameraClippingRange();
+                } else if (mode == 3) {     // Move Surface...
+                    if (vpan3DMPRView.GetRenderer().VisibleActorCount() == 0) {
+                        return;
+                    }
+                    double FPoint[];
+                    double PPoint[];
+                    double APoint[] = new double[3];
+                    double RPoint[];
+                    double focalDepth;
+
+                    // get the current focal point and position
+                    FPoint = cam.GetFocalPoint();
+                    PPoint = cam.GetPosition();
+
+                    // calculate the focal depth since we'll be using it a lot
+                    vpan3DMPRView.GetRenderer().SetWorldPoint(FPoint[0], FPoint[1], FPoint[2], 1.0);
+                    vpan3DMPRView.GetRenderer().WorldToDisplay();
+                    focalDepth = vpan3DMPRView.GetRenderer().GetDisplayPoint()[2];
+
+                    APoint[0] = vpan3DMPRView.GetRenderWindow().GetSize()[0] / 2.0 + (x - lastX);
+                    APoint[1] = vpan3DMPRView.GetRenderWindow().GetSize()[1] / 2.0 - (y - lastY);
+                    APoint[2] = focalDepth;
+                    vpan3DMPRView.GetRenderer().SetDisplayPoint(APoint);
+                    vpan3DMPRView.GetRenderer().DisplayToWorld();
+                    RPoint = vpan3DMPRView.GetRenderer().GetWorldPoint();
+                    if (RPoint[3] != 0.0) {
+                        RPoint[0] = RPoint[0] / RPoint[3];
+                        RPoint[1] = RPoint[1] / RPoint[3];
+                        RPoint[2] = RPoint[2] / RPoint[3];
+                    }
+                    /*
+                     * Compute a translation vector, moving everything 1/2
+                     * the distance to the cursor. (Arbitrary scale factor)
+                     */
+                    cam.SetFocalPoint(
+                            (FPoint[0] - RPoint[0]) / 2.0 + FPoint[0],
+                            (FPoint[1] - RPoint[1]) / 2.0 + FPoint[1],
+                            (FPoint[2] - RPoint[2]) / 2.0 + FPoint[2]);
+                    cam.SetPosition(
+                            (FPoint[0] - RPoint[0]) / 2.0 + PPoint[0],
+                            (FPoint[1] - RPoint[1]) / 2.0 + PPoint[1],
+                            (FPoint[2] - RPoint[2]) / 2.0 + PPoint[2]);
+                    vpan3DMPRView.resetCameraClippingRange();
+                }
+                lastX = x;
+                lastY = y;
+
+                vpan3DMPRView.Render();
+                doDragFlag = 1;
+            }
+            vpan3DMPRView.unlock();
+        }
+
+        public void mouseMoved(MouseEvent me) {
+            lastX = me.getX();
+            lastY = me.getY();
+        }
+    };
+}
diff --git a/src/in/raster/mayam/form/dcm3d/DicomVolumeRendering.form b/src/in/raster/mayam/form/dcm3d/DicomVolumeRendering.form
new file mode 100644
index 0000000..06d2104
--- /dev/null
+++ b/src/in/raster/mayam/form/dcm3d/DicomVolumeRendering.form
@@ -0,0 +1,223 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
+  <Properties>
+    <Property name="defaultCloseOperation" type="int" value="2"/>
+    <Property name="title" type="java.lang.String" value="3D Volume Rendering"/>
+    <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
+      <Color id="Default Cursor"/>
+    </Property>
+    <Property name="resizable" type="boolean" value="false"/>
+  </Properties>
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <Events>
+    <EventHandler event="windowClosed" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="formWindowClosed"/>
+  </Events>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Component id="pnlVolumeViewer" alignment="0" max="32767" attributes="1"/>
+                  <Group type="102" alignment="0" attributes="0">
+                      <Component id="lblZoomInOut" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="lblRotate" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace min="-2" pref="9" max="-2" attributes="0"/>
+                      <Component id="lblMove" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="lblCubeBox" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="lblReset" min="-2" pref="22" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="lblCaptureScreenShot" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace min="-2" pref="4" max="-2" attributes="0"/>
+                      <Component id="pnlselectedBackgroundColor" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace pref="342" max="32767" attributes="0"/>
+                      <Component id="lblDisplayPurpose" min="-2" pref="466" max="-2" attributes="1"/>
+                  </Group>
+              </Group>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Component id="lblDisplayPurpose" alignment="0" pref="24" max="32767" attributes="1"/>
+                  <Group type="103" alignment="0" groupAlignment="0" max="-2" attributes="0">
+                      <Component id="pnlselectedBackgroundColor" alignment="0" max="32767" attributes="1"/>
+                      <Component id="lblMove" alignment="0" max="32767" attributes="1"/>
+                      <Component id="lblZoomInOut" alignment="0" max="32767" attributes="1"/>
+                      <Component id="lblRotate" alignment="0" max="32767" attributes="1"/>
+                      <Component id="lblCaptureScreenShot" alignment="0" max="32767" attributes="1"/>
+                      <Component id="lblReset" alignment="0" max="32767" attributes="1"/>
+                      <Component id="lblCubeBox" alignment="0" max="32767" attributes="1"/>
+                  </Group>
+              </Group>
+              <EmptySpace type="separate" max="-2" attributes="0"/>
+              <Component id="pnlVolumeViewer" max="32767" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Container class="javax.swing.JPanel" name="pnlVolumeViewer">
+
+      <Layout>
+        <DimensionLayout dim="0">
+          <Group type="103" groupAlignment="0" attributes="0">
+              <EmptySpace min="0" pref="1019" max="32767" attributes="0"/>
+          </Group>
+        </DimensionLayout>
+        <DimensionLayout dim="1">
+          <Group type="103" groupAlignment="0" attributes="0">
+              <EmptySpace min="0" pref="702" max="32767" attributes="0"/>
+          </Group>
+        </DimensionLayout>
+      </Layout>
+    </Container>
+    <Component class="javax.swing.JLabel" name="lblRotate">
+      <Properties>
+        <Property name="horizontalAlignment" type="int" value="0"/>
+        <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+          <Image iconType="3" name="/in/raster/mayam/form/images/RotateSurface.png"/>
+        </Property>
+        <Property name="toolTipText" type="java.lang.String" value="Rotate the Volume"/>
+        <Property name="verticalAlignment" type="int" value="3"/>
+        <Property name="horizontalTextPosition" type="int" value="0"/>
+        <Property name="iconTextGap" type="int" value="0"/>
+        <Property name="verticalTextPosition" type="int" value="3"/>
+      </Properties>
+      <Events>
+        <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblRotateMouseClicked"/>
+        <EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblRotateMouseEntered"/>
+        <EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblRotateMouseExited"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JLabel" name="lblMove">
+      <Properties>
+        <Property name="horizontalAlignment" type="int" value="0"/>
+        <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+          <Image iconType="3" name="/in/raster/mayam/form/images/Move.png"/>
+        </Property>
+        <Property name="toolTipText" type="java.lang.String" value="Move the Volume"/>
+        <Property name="verticalAlignment" type="int" value="3"/>
+      </Properties>
+      <Events>
+        <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblMoveMouseClicked"/>
+        <EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblMoveMouseEntered"/>
+        <EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblMoveMouseExited"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JLabel" name="lblCubeBox">
+      <Properties>
+        <Property name="horizontalAlignment" type="int" value="0"/>
+        <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+          <Image iconType="3" name="/in/raster/mayam/form/images/ResetInteractor.png"/>
+        </Property>
+        <Property name="toolTipText" type="java.lang.String" value="Reset the Mouse Interaction"/>
+        <Property name="verticalAlignment" type="int" value="3"/>
+      </Properties>
+      <Events>
+        <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblCubeBoxMouseClicked"/>
+        <EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblCubeBoxMouseEntered"/>
+        <EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblCubeBoxMouseExited"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JLabel" name="lblDisplayPurpose">
+      <Properties>
+        <Property name="horizontalAlignment" type="int" value="0"/>
+        <Property name="text" type="java.lang.String" value="3D Volume Rendering"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="lblCaptureScreenShot">
+      <Properties>
+        <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+          <Image iconType="3" name="/in/raster/mayam/form/images/ScreenShot.png"/>
+        </Property>
+        <Property name="toolTipText" type="java.lang.String" value="Capture Screenshot"/>
+      </Properties>
+      <Events>
+        <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblCaptureScreenShotMouseClicked"/>
+        <EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblCaptureScreenShotMouseEntered"/>
+        <EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblCaptureScreenShotMouseExited"/>
+      </Events>
+    </Component>
+    <Container class="javax.swing.JPanel" name="pnlselectedBackgroundColor">
+      <Properties>
+        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="4" green="2" red="3" type="rgb"/>
+        </Property>
+        <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+          <Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
+            <LineBorder/>
+          </Border>
+        </Property>
+        <Property name="toolTipText" type="java.lang.String" value="Change Background Color"/>
+      </Properties>
+      <Events>
+        <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="pnlselectedBackgroundColorMouseClicked"/>
+        <EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="pnlselectedBackgroundColorMouseEntered"/>
+        <EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="pnlselectedBackgroundColorMouseExited"/>
+      </Events>
+
+      <Layout>
+        <DimensionLayout dim="0">
+          <Group type="103" groupAlignment="0" attributes="0">
+              <EmptySpace min="0" pref="22" max="32767" attributes="0"/>
+          </Group>
+        </DimensionLayout>
+        <DimensionLayout dim="1">
+          <Group type="103" groupAlignment="0" attributes="0">
+              <EmptySpace min="0" pref="22" max="32767" attributes="0"/>
+          </Group>
+        </DimensionLayout>
+      </Layout>
+    </Container>
+    <Component class="javax.swing.JLabel" name="lblZoomInOut">
+      <Properties>
+        <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+          <Image iconType="3" name="/in/raster/mayam/form/images/ZoomInOut.png"/>
+        </Property>
+        <Property name="toolTipText" type="java.lang.String" value="Zoom In or Zoom Out the Volume"/>
+      </Properties>
+      <Events>
+        <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblZoomInOutMouseClicked"/>
+        <EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblZoomInOutMouseEntered"/>
+        <EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblZoomInOutMouseExited"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JLabel" name="lblReset">
+      <Properties>
+        <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+          <Image iconType="3" name="/in/raster/mayam/form/images/DrawCircle.png"/>
+        </Property>
+        <Property name="toolTipText" type="java.lang.String" value="Reset the Volume"/>
+      </Properties>
+      <Events>
+        <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblResetMouseClicked"/>
+        <EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblResetMouseEntered"/>
+        <EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblResetMouseExited"/>
+      </Events>
+    </Component>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/dcm3d/DicomVolumeRendering.java b/src/in/raster/mayam/form/dcm3d/DicomVolumeRendering.java
new file mode 100644
index 0000000..466f933
--- /dev/null
+++ b/src/in/raster/mayam/form/dcm3d/DicomVolumeRendering.java
@@ -0,0 +1,798 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Guru Rajan R
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Sathish Kumar V
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form.dcm3d;
+
+import java.awt.Color;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionListener;
+import java.io.File;
+import javax.swing.JColorChooser;
+import javax.swing.JFileChooser;
+import javax.swing.filechooser.FileFilter;
+import vtk.vtkCamera;
+import vtk.vtkCanvas;
+import vtk.vtkColorTransferFunction;
+import vtk.vtkDICOMImageReader;
+import vtk.vtkImageShiftScale;
+import vtk.vtkLight;
+import vtk.vtkLightCollection;
+import vtk.vtkPiecewiseFunction;
+import vtk.vtkVolume;
+import vtk.vtkVolumeProperty;
+import vtk.vtkVolumeRayCastCompositeFunction;
+import vtk.vtkVolumeRayCastMapper;
+
+/**
+ * DicomVolumeRendering.java
+ *
+ * Created on 20 Aug, 2010, 1:03:15 PM
+ *
+ *  This File Load the Series of Dicom images and
+ *  Construct them as a Volume...
+ *
+ */
+
+/*
+ * @author Sathish Kumar V              (sathishkumar.v at raster.in)
+ */
+public class DicomVolumeRendering extends javax.swing.JFrame {
+
+    private vtkDICOMImageReader reader;
+    private vtkCanvas vpanVolume = new vtkCanvas();
+    private int mode = 0, lastX, lastY, doDragFlag;
+    private String directoryName = "", DisplayString = "3D Volume Rendering";
+    private vtkImageShiftScale vtkmyImageCast = new vtkImageShiftScale();
+    private vtkVolume volume = new vtkVolume();
+    long startTime;
+    private int xMin, xMax, yMin, yMax, zMin, zMax;
+    private double sx, sy, sz, ox, oy, oz;
+
+    static {
+        System.loadLibrary("vtkCommonJava");
+        System.loadLibrary("vtkFilteringJava");
+        System.loadLibrary("vtkIOJava");
+        System.loadLibrary("vtkImagingJava");
+        System.loadLibrary("vtkGraphicsJava");
+        System.loadLibrary("vtkRenderingJava");
+        System.loadLibrary("vtkVolumeRenderingJava");
+    }
+
+    /* Creates new form DicomVolumeRendering */
+    public DicomVolumeRendering() {
+        initComponents();
+        vpanVolume.setSize(pnlVolumeViewer.getSize());
+        vpanVolume.setBackground(Color.white);
+    }
+
+    @SuppressWarnings("unchecked")
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        pnlVolumeViewer = new javax.swing.JPanel();
+        lblRotate = new javax.swing.JLabel();
+        lblMove = new javax.swing.JLabel();
+        lblCubeBox = new javax.swing.JLabel();
+        lblDisplayPurpose = new javax.swing.JLabel();
+        lblCaptureScreenShot = new javax.swing.JLabel();
+        pnlselectedBackgroundColor = new javax.swing.JPanel();
+        lblZoomInOut = new javax.swing.JLabel();
+        lblReset = new javax.swing.JLabel();
+
+        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+        setTitle("3D Volume Rendering");
+        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
+        setResizable(false);
+        addWindowListener(new java.awt.event.WindowAdapter() {
+            public void windowClosed(java.awt.event.WindowEvent evt) {
+                formWindowClosed(evt);
+            }
+        });
+
+        javax.swing.GroupLayout pnlVolumeViewerLayout = new javax.swing.GroupLayout(pnlVolumeViewer);
+        pnlVolumeViewer.setLayout(pnlVolumeViewerLayout);
+        pnlVolumeViewerLayout.setHorizontalGroup(
+            pnlVolumeViewerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGap(0, 1019, Short.MAX_VALUE)
+        );
+        pnlVolumeViewerLayout.setVerticalGroup(
+            pnlVolumeViewerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGap(0, 702, Short.MAX_VALUE)
+        );
+
+        lblRotate.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+        lblRotate.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/RotateSurface.png"))); // NOI18N
+        lblRotate.setToolTipText("Rotate the Volume");
+        lblRotate.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
+        lblRotate.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+        lblRotate.setIconTextGap(0);
+        lblRotate.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        lblRotate.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                lblRotateMouseClicked(evt);
+            }
+            public void mouseEntered(java.awt.event.MouseEvent evt) {
+                lblRotateMouseEntered(evt);
+            }
+            public void mouseExited(java.awt.event.MouseEvent evt) {
+                lblRotateMouseExited(evt);
+            }
+        });
+
+        lblMove.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+        lblMove.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/Move.png"))); // NOI18N
+        lblMove.setToolTipText("Move the Volume");
+        lblMove.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
+        lblMove.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                lblMoveMouseClicked(evt);
+            }
+            public void mouseEntered(java.awt.event.MouseEvent evt) {
+                lblMoveMouseEntered(evt);
+            }
+            public void mouseExited(java.awt.event.MouseEvent evt) {
+                lblMoveMouseExited(evt);
+            }
+        });
+
+        lblCubeBox.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+        lblCubeBox.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/ResetInteractor.png"))); // NOI18N
+        lblCubeBox.setToolTipText("Reset the Mouse Interaction");
+        lblCubeBox.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
+        lblCubeBox.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                lblCubeBoxMouseClicked(evt);
+            }
+            public void mouseEntered(java.awt.event.MouseEvent evt) {
+                lblCubeBoxMouseEntered(evt);
+            }
+            public void mouseExited(java.awt.event.MouseEvent evt) {
+                lblCubeBoxMouseExited(evt);
+            }
+        });
+
+        lblDisplayPurpose.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+        lblDisplayPurpose.setText("3D Volume Rendering");
+
+        lblCaptureScreenShot.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/ScreenShot.png"))); // NOI18N
+        lblCaptureScreenShot.setToolTipText("Capture Screenshot");
+        lblCaptureScreenShot.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                lblCaptureScreenShotMouseClicked(evt);
+            }
+            public void mouseEntered(java.awt.event.MouseEvent evt) {
+                lblCaptureScreenShotMouseEntered(evt);
+            }
+            public void mouseExited(java.awt.event.MouseEvent evt) {
+                lblCaptureScreenShotMouseExited(evt);
+            }
+        });
+
+        pnlselectedBackgroundColor.setBackground(new java.awt.Color(3, 2, 4));
+        pnlselectedBackgroundColor.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
+        pnlselectedBackgroundColor.setToolTipText("Change Background Color");
+        pnlselectedBackgroundColor.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                pnlselectedBackgroundColorMouseClicked(evt);
+            }
+            public void mouseEntered(java.awt.event.MouseEvent evt) {
+                pnlselectedBackgroundColorMouseEntered(evt);
+            }
+            public void mouseExited(java.awt.event.MouseEvent evt) {
+                pnlselectedBackgroundColorMouseExited(evt);
+            }
+        });
+
+        javax.swing.GroupLayout pnlselectedBackgroundColorLayout = new javax.swing.GroupLayout(pnlselectedBackgroundColor);
+        pnlselectedBackgroundColor.setLayout(pnlselectedBackgroundColorLayout);
+        pnlselectedBackgroundColorLayout.setHorizontalGroup(
+            pnlselectedBackgroundColorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGap(0, 22, Short.MAX_VALUE)
+        );
+        pnlselectedBackgroundColorLayout.setVerticalGroup(
+            pnlselectedBackgroundColorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGap(0, 22, Short.MAX_VALUE)
+        );
+
+        lblZoomInOut.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/ZoomInOut.png"))); // NOI18N
+        lblZoomInOut.setToolTipText("Zoom In or Zoom Out the Volume");
+        lblZoomInOut.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                lblZoomInOutMouseClicked(evt);
+            }
+            public void mouseEntered(java.awt.event.MouseEvent evt) {
+                lblZoomInOutMouseEntered(evt);
+            }
+            public void mouseExited(java.awt.event.MouseEvent evt) {
+                lblZoomInOutMouseExited(evt);
+            }
+        });
+
+        lblReset.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/DrawCircle.png"))); // NOI18N
+        lblReset.setToolTipText("Reset the Volume");
+        lblReset.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                lblResetMouseClicked(evt);
+            }
+            public void mouseEntered(java.awt.event.MouseEvent evt) {
+                lblResetMouseEntered(evt);
+            }
+            public void mouseExited(java.awt.event.MouseEvent evt) {
+                lblResetMouseExited(evt);
+            }
+        });
+
+        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
+        getContentPane().setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGroup(layout.createSequentialGroup()
+                .addContainerGap()
+                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                    .addComponent(pnlVolumeViewer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                    .addGroup(layout.createSequentialGroup()
+                        .addComponent(lblZoomInOut)
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                        .addComponent(lblRotate)
+                        .addGap(9, 9, 9)
+                        .addComponent(lblMove)
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                        .addComponent(lblCubeBox)
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                        .addComponent(lblReset, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                        .addComponent(lblCaptureScreenShot)
+                        .addGap(4, 4, 4)
+                        .addComponent(pnlselectedBackgroundColor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 342, Short.MAX_VALUE)
+                        .addComponent(lblDisplayPurpose, javax.swing.GroupLayout.PREFERRED_SIZE, 466, javax.swing.GroupLayout.PREFERRED_SIZE)))
+                .addContainerGap())
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGroup(layout.createSequentialGroup()
+                .addContainerGap()
+                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                    .addComponent(lblDisplayPurpose, javax.swing.GroupLayout.DEFAULT_SIZE, 24, Short.MAX_VALUE)
+                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
+                        .addComponent(pnlselectedBackgroundColor, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                        .addComponent(lblMove, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                        .addComponent(lblZoomInOut, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                        .addComponent(lblRotate, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                        .addComponent(lblCaptureScreenShot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                        .addComponent(lblReset, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                        .addComponent(lblCubeBox, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
+                .addGap(18, 18, 18)
+                .addComponent(pnlVolumeViewer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                .addContainerGap())
+        );
+
+        pack();
+    }// </editor-fold>//GEN-END:initComponents
+
+    private void lblRotateMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblRotateMouseEntered
+        // Code for Display the Purpose of Rotate Icon
+        lblDisplayPurpose.setText("Rotate the Volume");
+    }//GEN-LAST:event_lblRotateMouseEntered
+
+    private void lblRotateMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblRotateMouseExited
+        // Code for Remove the Purpose from label
+        lblDisplayPurpose.setText(DisplayString);
+    }//GEN-LAST:event_lblRotateMouseExited
+
+    private void lblMoveMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblMoveMouseEntered
+        // Code for Display the Purpose of Move Icon
+        lblDisplayPurpose.setText("Move the Volume");
+    }//GEN-LAST:event_lblMoveMouseEntered
+
+    private void lblMoveMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblMoveMouseExited
+        // Code for Remove the Purpose from label
+        lblDisplayPurpose.setText(DisplayString);
+    }//GEN-LAST:event_lblMoveMouseExited
+
+    private void lblCubeBoxMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblCubeBoxMouseEntered
+        // Code for Display the Purpose of add Cube Box Icon
+        lblDisplayPurpose.setText("Reset the Mouse Interaction");
+    }//GEN-LAST:event_lblCubeBoxMouseEntered
+
+    private void lblCubeBoxMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblCubeBoxMouseExited
+        // Code for Remove the Purpose from label
+        lblDisplayPurpose.setText(DisplayString);
+    }//GEN-LAST:event_lblCubeBoxMouseExited
+
+    private void lblCubeBoxMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblCubeBoxMouseClicked
+        // Set the Default Interactor..
+
+        vpanVolume.removeMouseListener(myMouseListener);
+        vpanVolume.removeMouseMotionListener(myMouseMotionListener);
+
+        mode = 0;
+        vpanVolume.addMouseListener(vpanVolume);
+        vpanVolume.addMouseMotionListener(vpanVolume);
+    }//GEN-LAST:event_lblCubeBoxMouseClicked
+
+    private void lblRotateMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblRotateMouseClicked
+        //  Set the interaction for Rotate...
+        vpanVolume.removeMouseListener(vpanVolume);
+        vpanVolume.removeMouseMotionListener(vpanVolume);
+
+        mode = 2;
+        vpanVolume.addMouseListener(myMouseListener);
+        vpanVolume.addMouseMotionListener(myMouseMotionListener);
+    }//GEN-LAST:event_lblRotateMouseClicked
+
+    private void lblMoveMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblMoveMouseClicked
+        // Set the interaction for Move...
+
+        vpanVolume.removeMouseListener(vpanVolume);
+        vpanVolume.removeMouseMotionListener(vpanVolume);
+
+        mode = 3;
+        vpanVolume.addMouseListener(myMouseListener);
+        vpanVolume.addMouseMotionListener(myMouseMotionListener);
+    }//GEN-LAST:event_lblMoveMouseClicked
+
+    private void lblCaptureScreenShotMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblCaptureScreenShotMouseClicked
+        // Code for capture the view as an Image...
+
+        // ask for the filename...
+        JFileChooser fc = new JFileChooser();
+        FileFilter filter = new FileFilter() {
+
+            @Override
+            public boolean accept(File file) {
+                if (file.isDirectory()) {
+                    return true;
+                }
+                String extension = null;
+                String s = file.getName();
+                int i = s.lastIndexOf('.');
+                if (i > 0 && i < s.length() - 1) {
+                    extension = s.substring(i + 1).toLowerCase();
+                }
+                if (extension != null) {
+                    if (extension.equals("tiff") || extension.equals("tif")) {
+                        return true;
+                    } else {
+                        return false;
+                    }
+                } else {
+                    return false;
+                }
+            }
+
+            @Override
+            public String getDescription() {
+                return "tiff/tif Images";
+            }
+        };
+
+        fc.setFileFilter(filter);
+
+        fc.setAcceptAllFileFilterUsed(false);
+        int returnVal = fc.showSaveDialog(this);
+        if (returnVal == JFileChooser.APPROVE_OPTION) {
+            File file = fc.getSelectedFile();
+            // Capture and Save the image...
+
+            String extension = null;
+            String s = file.getName();
+            int i = s.lastIndexOf('.');
+            if (i > 0 && i < s.length() - 1) {
+                extension = s.substring(i + 1).toLowerCase();
+                if (extension.equals("tif") || extension.equals("tiff")) {
+                    vpanVolume.HardCopy(file.getAbsolutePath(), 1);
+                } else {
+                    vpanVolume.HardCopy(file.getAbsolutePath().concat(".tif"), 1);
+                }
+            } else {
+                vpanVolume.HardCopy(file.getAbsolutePath().concat(".tif"), 1);
+            }
+        }
+        //Reset the file chooser for the next time it's shown.
+
+        fc.setSelectedFile(null);
+    }//GEN-LAST:event_lblCaptureScreenShotMouseClicked
+
+    private void lblCaptureScreenShotMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblCaptureScreenShotMouseEntered
+        // Code for capture the view as an Image...
+        lblDisplayPurpose.setText("Capture Screenshot");
+    }//GEN-LAST:event_lblCaptureScreenShotMouseEntered
+
+    private void lblCaptureScreenShotMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblCaptureScreenShotMouseExited
+        // Code for Remove the Purpose from label
+        lblDisplayPurpose.setText(DisplayString);
+    }//GEN-LAST:event_lblCaptureScreenShotMouseExited
+
+    private void pnlselectedBackgroundColorMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pnlselectedBackgroundColorMouseClicked
+        // Code for display the Color Pallette
+        Color bgColor = JColorChooser.showDialog(this, "Select Color", pnlselectedBackgroundColor.getBackground());
+        if (bgColor != null) {
+            pnlselectedBackgroundColor.setBackground(bgColor);
+            vpanVolume.GetRenderer().SetBackground(Double.valueOf(pnlselectedBackgroundColor.getBackground().getRed()) / 255.0, Double.valueOf(pnlselectedBackgroundColor.getBackground().getGreen()) / 255.0, Double.valueOf(pnlselectedBackgroundColor.getBackground().getBlue()) / 255.0);
+            vpanVolume.repaint();
+        }
+    }//GEN-LAST:event_pnlselectedBackgroundColorMouseClicked
+
+    private void pnlselectedBackgroundColorMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pnlselectedBackgroundColorMouseEntered
+        // TODO add your handling code here:
+        lblDisplayPurpose.setText("Change Background Color");
+    }//GEN-LAST:event_pnlselectedBackgroundColorMouseEntered
+
+    private void pnlselectedBackgroundColorMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pnlselectedBackgroundColorMouseExited
+        // Code for Remove the Purpose from label
+        lblDisplayPurpose.setText(DisplayString);
+
+    }//GEN-LAST:event_pnlselectedBackgroundColorMouseExited
+
+    private void lblZoomInOutMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblZoomInOutMouseClicked
+        // Set the interaction for Zoom In and Zoom Out...
+
+        vpanVolume.removeMouseListener(vpanVolume);
+        vpanVolume.removeMouseMotionListener(vpanVolume);
+        mode = 1;
+        vpanVolume.addMouseListener(myMouseListener);
+        vpanVolume.addMouseMotionListener(myMouseMotionListener);
+    }//GEN-LAST:event_lblZoomInOutMouseClicked
+
+    private void lblZoomInOutMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblZoomInOutMouseEntered
+        // Code for Display the Purpose of Zoom In/Out Icon
+        lblDisplayPurpose.setText("Zoom In or Zoom Out the Volume");
+    }//GEN-LAST:event_lblZoomInOutMouseEntered
+
+    private void lblZoomInOutMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblZoomInOutMouseExited
+        // Code for Remove the Purpose from label
+        lblDisplayPurpose.setText(DisplayString);
+    }//GEN-LAST:event_lblZoomInOutMouseExited
+
+    private void lblResetMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblResetMouseClicked
+        // TODO add your handling code here:
+        double cx = (ox + (0.5 * (xMax - xMin)) * sx);
+        double cy = (oy + (0.5 * (yMax - yMin)) * sy);
+        double cz = (oy + (0.5 * (zMax - zMin)) * sz);
+        double vx = 0;
+        double vy = 0;
+        double vz = 0;
+        double nx = 0;
+        double ny = 0;
+        double nz = 0;
+        int iaxis = 2;
+        if (iaxis == 0) {
+            vz = -1;
+            nx = (ox + xMax * sx);
+            cx = (ox + 1 * sx);
+        } else if (iaxis == 1) {
+            vz = -1;
+            ny = (oy + yMax * sy);
+            cy = (oy + 1 * sy);
+        } else {
+            vy = 1;
+            nz = (oz + zMax * sz);
+            cz = (oz + 1 * sz);
+        }
+        double px = (cx + nx * 2);
+        double py = (cy + ny * 2);
+        double pz = (cz + nz * 3);
+
+        vtkCamera camera = vpanVolume.GetRenderer().GetActiveCamera();
+        camera.SetViewUp(vx, vy, vz);
+        camera.SetFocalPoint(cx, cy, cz);
+        camera.SetPosition(px, py, pz);
+        camera.OrthogonalizeViewUp();
+
+        // Reset the light...
+        vtkLightCollection Lights = vpanVolume.GetRenderer().GetLights();
+        int nLights = Lights.GetNumberOfItems();
+        vtkLight light;
+        double[] pos = camera.GetPosition();
+        double[] fp = camera.GetFocalPoint();
+        Lights.InitTraversal();
+        for (int i = 0; i < nLights; i++) {
+            light = Lights.GetNextItem();
+            light.SetPosition(pos);
+            light.SetFocalPoint(fp);
+            light.Modified();
+        }
+
+        vpanVolume.GetRenderer().ResetCameraClippingRange();
+        vpanVolume.GetRenderer().ResetCamera();
+        vpanVolume.GetRenderer().WorldToView();
+        vpanVolume.repaint();
+    }//GEN-LAST:event_lblResetMouseClicked
+
+    private void lblResetMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblResetMouseEntered
+        // TODO add your handling code here:
+        lblDisplayPurpose.setText("Reset the Volume");
+    }//GEN-LAST:event_lblResetMouseEntered
+
+    private void lblResetMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblResetMouseExited
+        // TODO add your handling code here:
+        lblDisplayPurpose.setText(DisplayString);
+    }//GEN-LAST:event_lblResetMouseExited
+
+    private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
+        //  vtkGlobalJavaHash.DeleteAll();
+    }//GEN-LAST:event_formWindowClosed
+
+    public static void main(String args[]) {
+        java.awt.EventQueue.invokeLater(new Runnable() {
+
+            public void run() {
+                new DicomVolumeRendering().setVisible(true);
+            }
+        });
+    }
+
+    public void readDicomDir(String path) {
+        directoryName = path;
+
+        // Display the Volume
+        reader = new vtkDICOMImageReader();
+        if (new File(directoryName).isDirectory()) {
+            reader.SetDirectoryName(directoryName);
+        }
+        reader.Update();
+        reader.ReleaseDataFlagOn();
+
+        int[] xyminmax = reader.GetOutput().GetWholeExtent();
+        xMin = xyminmax[0];
+        xMax = xyminmax[1];
+        yMin = xyminmax[2];
+        yMax = xyminmax[3];
+        zMin = xyminmax[4];
+        zMax = xyminmax[5];
+
+        double[] spacing = reader.GetOutput().GetSpacing();
+        sx = spacing[0];
+        sy = spacing[1];
+        sz = spacing[2];
+
+        double[] origin = reader.GetOutput().GetOrigin();
+        ox = origin[0];
+        oy = origin[1];
+        oz = origin[2];
+
+
+        double[] range = reader.GetOutput().GetScalarRange();
+        double min = range[0];
+        double max = range[1];
+        double diff = max - min;
+        double slop = 512.0 / diff;
+        double inter = -slop * min;
+        double shift = inter / slop;
+
+        vtkmyImageCast.SetInput(reader.GetOutput());
+        vtkmyImageCast.SetShift(shift);
+        vtkmyImageCast.SetScale(slop);
+        vtkmyImageCast.SetOutputScalarTypeToUnsignedChar();
+        vtkmyImageCast.Update();
+        vtkmyImageCast.GetOutput().GetScalarRange(range);
+
+        DisplayString = reader.GetPatientName();
+        reader.Delete();
+
+        displayVolume();
+
+
+    }
+
+    private void displayVolume() {
+
+        // Create transfer mapping scalar value to opacity        
+        vtkPiecewiseFunction opacityTransferFunction = new vtkPiecewiseFunction();
+
+        opacityTransferFunction.AddPoint(30, 0.0);
+        opacityTransferFunction.AddPoint(100, 0.3);
+        opacityTransferFunction.AddPoint(101, 0.3);
+        opacityTransferFunction.AddPoint(175, 0.1);
+        opacityTransferFunction.AddPoint(255, 0.1);
+
+        // Create transfer mapping scalar value to color
+        vtkColorTransferFunction colorTransferFunction = new vtkColorTransferFunction();
+
+        colorTransferFunction.AddRGBPoint(120.0, 1.0, 0.6, 0.0);
+        colorTransferFunction.AddRGBPoint(140.0, 1.0, 0.0, 0.0);
+        colorTransferFunction.AddRGBPoint(150.0, 1.0, 0.0, 0.0);
+        //colorTransferFunction.AddRGBPoint(175.0, 1.0, 1.0, 1.0);
+        colorTransferFunction.AddRGBPoint(175.0, 1.0, 0.0, 0.0);
+        colorTransferFunction.AddRGBPoint(255.0, 1.0, 1.0, 1.0);
+
+        // The property describes how the data will look
+        vtkVolumeProperty volumeProperty = new vtkVolumeProperty();
+        volumeProperty.SetColor(colorTransferFunction);
+        volumeProperty.SetScalarOpacity(opacityTransferFunction);
+        volumeProperty.ShadeOn();
+        volumeProperty.SetInterpolationTypeToLinear();
+        volumeProperty.SetAmbient(0.1);
+        volumeProperty.SetDiffuse(0.6);
+        volumeProperty.SetSpecular(0.7);
+        volumeProperty.SetSpecularPower(30);
+
+        // The mapper / ray cast function know how to render the data
+        vtkVolumeRayCastCompositeFunction compositeFunction = new vtkVolumeRayCastCompositeFunction();
+        vtkVolumeRayCastMapper volumeMapper = new vtkVolumeRayCastMapper();
+        volumeMapper.SetVolumeRayCastFunction(compositeFunction);
+        volumeMapper.SetInput(vtkmyImageCast.GetOutput());
+
+        // The volume holds the mapper and the property and can be used to position/orient the volume
+        volume.SetMapper(volumeMapper);
+        volume.SetProperty(volumeProperty);
+
+        vpanVolume.GetRenderer().AddVolume(volume);
+        vpanVolume.repaint();
+
+        vpanVolume.GetRenderer().SetBackground(Double.valueOf(pnlselectedBackgroundColor.getBackground().getRed()) / 255.0, Double.valueOf(pnlselectedBackgroundColor.getBackground().getGreen()) / 255.0, Double.valueOf(pnlselectedBackgroundColor.getBackground().getBlue()) / 255.0);
+        vpanVolume.GetRenderer().ResetCamera();
+        pnlVolumeViewer.add(vpanVolume);
+        vpanVolume.repaint();
+        pnlVolumeViewer.setVisible(true);
+
+
+
+    }
+    MouseListener myMouseListener = new MouseListener() {
+
+        public void mouseClicked(MouseEvent me) {
+        }
+
+        public void mousePressed(MouseEvent me) {
+            lastX = me.getX();
+            lastY = me.getY();
+        }
+
+        public void mouseReleased(MouseEvent me) {
+        }
+
+        public void mouseEntered(MouseEvent me) {
+        }
+
+        public void mouseExited(MouseEvent me) {
+        }
+    };
+    MouseMotionListener myMouseMotionListener = new MouseMotionListener() {
+
+        public void mouseDragged(MouseEvent me) {
+
+            if (doDragFlag > 0) {
+                doDragFlag--;
+            } else {
+                int x = me.getX();
+                int y = me.getY();
+                vtkCamera cam = vpanVolume.GetRenderer().GetActiveCamera();
+
+                if (mode == 1) {            // Zoom In/Out Volume...
+                    if (vpanVolume.GetRenderer().VisibleActorCount() == 0) {
+                        return;
+                    }
+                    double zoomFactor;
+                    zoomFactor = Math.pow(1.02, (y - lastY));
+                    if (cam.GetParallelProjection() == 1) {
+                        cam.SetParallelScale(cam.GetParallelScale() / zoomFactor);
+                    } else {
+                        cam.Dolly(zoomFactor);
+                        vpanVolume.resetCameraClippingRange();
+                    }
+                } else if (mode == 2) {     // Rotate Volume...
+
+                    if (vpanVolume.GetRenderer().VisibleActorCount() == 0) {
+                        return;
+                    }
+                    if (x > vpanVolume.getWidth() / 2.0) {
+                        cam.Roll(-(y - lastY));
+                    } else {
+                        cam.Roll((y - lastY));
+                    }
+                    if (y < vpanVolume.getHeight() / 2.0) {
+                        cam.Roll(-(x - lastX));
+                    } else {
+                        cam.Roll((x - lastX));
+                    }
+                    vpanVolume.resetCameraClippingRange();
+                } else if (mode == 3) {     // Move Volume...
+                    if (vpanVolume.GetRenderer().VisibleActorCount() == 0) {
+                        return;
+                    }
+                    double FPoint[];
+                    double PPoint[];
+                    double APoint[] = new double[3];
+                    double RPoint[];
+                    double focalDepth;
+
+                    // get the current focal point and position
+                    FPoint = cam.GetFocalPoint();
+                    PPoint = cam.GetPosition();
+
+                    // calculate the focal depth since we'll be using it a lot
+                    vpanVolume.GetRenderer().SetWorldPoint(FPoint[0], FPoint[1], FPoint[2], 1.0);
+                    vpanVolume.GetRenderer().WorldToDisplay();
+                    focalDepth = vpanVolume.GetRenderer().GetDisplayPoint()[2];
+
+                    APoint[0] = vpanVolume.GetRenderWindow().GetSize()[0] / 2.0 + (x - lastX);
+                    APoint[1] = vpanVolume.GetRenderWindow().GetSize()[1] / 2.0 - (y - lastY);
+                    APoint[2] = focalDepth;
+                    vpanVolume.GetRenderer().SetDisplayPoint(APoint);
+                    vpanVolume.GetRenderer().DisplayToWorld();
+                    RPoint = vpanVolume.GetRenderer().GetWorldPoint();
+                    if (RPoint[3] != 0.0) {
+                        RPoint[0] = RPoint[0] / RPoint[3];
+                        RPoint[1] = RPoint[1] / RPoint[3];
+                        RPoint[2] = RPoint[2] / RPoint[3];
+                    }
+                    /*
+                     * Compute a translation vector, moving everything 1/2
+                     * the distance to the cursor. (Arbitrary scale factor)
+                     */
+                    cam.SetFocalPoint(
+                            (FPoint[0] - RPoint[0]) / 2.0 + FPoint[0],
+                            (FPoint[1] - RPoint[1]) / 2.0 + FPoint[1],
+                            (FPoint[2] - RPoint[2]) / 2.0 + FPoint[2]);
+                    cam.SetPosition(
+                            (FPoint[0] - RPoint[0]) / 2.0 + PPoint[0],
+                            (FPoint[1] - RPoint[1]) / 2.0 + PPoint[1],
+                            (FPoint[2] - RPoint[2]) / 2.0 + PPoint[2]);
+                    cam.SetEyeAngle(100);
+                    vpanVolume.resetCameraClippingRange();
+                }
+                lastX = x;
+                lastY = y;
+
+                vpanVolume.Render();
+                doDragFlag = 5;
+            }
+        }
+
+        public void mouseMoved(MouseEvent me) {
+            lastX = me.getX();
+            lastY = me.getY();
+        }
+    };
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JLabel lblCaptureScreenShot;
+    private javax.swing.JLabel lblCubeBox;
+    private javax.swing.JLabel lblDisplayPurpose;
+    private javax.swing.JLabel lblMove;
+    private javax.swing.JLabel lblReset;
+    private javax.swing.JLabel lblRotate;
+    private javax.swing.JLabel lblZoomInOut;
+    private javax.swing.JPanel pnlVolumeViewer;
+    private javax.swing.JPanel pnlselectedBackgroundColor;
+    // End of variables declaration//GEN-END:variables
+}
diff --git a/src/in/raster/mayam/form/dcm3d/SurfaceRendering.form b/src/in/raster/mayam/form/dcm3d/SurfaceRendering.form
new file mode 100644
index 0000000..f95a37f
--- /dev/null
+++ b/src/in/raster/mayam/form/dcm3d/SurfaceRendering.form
@@ -0,0 +1,663 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
+  <NonVisualComponents>
+    <Container class="javax.swing.JDialog" name="dlgSurfaceSettings">
+      <Properties>
+        <Property name="defaultCloseOperation" type="int" value="0"/>
+        <Property name="alwaysOnTop" type="boolean" value="true"/>
+        <Property name="resizable" type="boolean" value="false"/>
+      </Properties>
+
+      <Layout>
+        <DimensionLayout dim="0">
+          <Group type="103" groupAlignment="0" attributes="0">
+              <Group type="102" attributes="0">
+                  <EmptySpace max="-2" attributes="0"/>
+                  <Group type="103" groupAlignment="0" attributes="0">
+                      <Group type="102" alignment="1" attributes="0">
+                          <Component id="btnSurfaceSettingsOk" min="-2" pref="58" max="-2" attributes="0"/>
+                          <EmptySpace type="unrelated" max="-2" attributes="0"/>
+                          <Component id="btnSurfaceSettingsCancel" min="-2" pref="86" max="-2" attributes="0"/>
+                      </Group>
+                      <Group type="103" alignment="0" groupAlignment="1" max="-2" attributes="0">
+                          <Component id="pnlSurface1" alignment="0" max="32767" attributes="1"/>
+                          <Component id="pnlSurface2" alignment="0" max="32767" attributes="1"/>
+                      </Group>
+                  </Group>
+                  <EmptySpace max="32767" attributes="0"/>
+              </Group>
+          </Group>
+        </DimensionLayout>
+        <DimensionLayout dim="1">
+          <Group type="103" groupAlignment="0" attributes="0">
+              <Group type="102" alignment="0" attributes="0">
+                  <EmptySpace max="-2" attributes="0"/>
+                  <Component id="pnlSurface1" min="-2" max="-2" attributes="0"/>
+                  <EmptySpace type="unrelated" max="-2" attributes="0"/>
+                  <Component id="pnlSurface2" min="-2" max="-2" attributes="0"/>
+                  <EmptySpace type="unrelated" max="-2" attributes="0"/>
+                  <Group type="103" groupAlignment="0" attributes="0">
+                      <Component id="btnSurfaceSettingsOk" min="-2" max="-2" attributes="0"/>
+                      <Component id="btnSurfaceSettingsCancel" alignment="0" min="-2" max="-2" attributes="0"/>
+                  </Group>
+                  <EmptySpace max="32767" attributes="0"/>
+              </Group>
+          </Group>
+        </DimensionLayout>
+      </Layout>
+      <SubComponents>
+        <Component class="javax.swing.JButton" name="btnSurfaceSettingsOk">
+          <Properties>
+            <Property name="text" type="java.lang.String" value="Ok"/>
+          </Properties>
+          <Events>
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSurfaceSettingsOkActionPerformed"/>
+          </Events>
+        </Component>
+        <Component class="javax.swing.JButton" name="btnSurfaceSettingsCancel">
+          <Properties>
+            <Property name="text" type="java.lang.String" value="Cancel"/>
+          </Properties>
+          <Events>
+            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSurfaceSettingsCancelActionPerformed"/>
+          </Events>
+        </Component>
+        <Container class="javax.swing.JPanel" name="pnlSurface2">
+          <Properties>
+            <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+              <Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
+                <LineBorder/>
+              </Border>
+            </Property>
+          </Properties>
+
+          <Layout>
+            <DimensionLayout dim="0">
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Group type="102" attributes="0">
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Group type="103" groupAlignment="0" attributes="0">
+                          <Component id="chbxSecondSurface" alignment="0" min="-2" max="-2" attributes="0"/>
+                          <Group type="102" alignment="0" attributes="0">
+                              <Group type="103" groupAlignment="0" attributes="0">
+                                  <Component id="lblPredefinedValues2" alignment="0" min="-2" max="-2" attributes="1"/>
+                                  <Component id="lblPixelValues2" alignment="0" min="-2" max="-2" attributes="1"/>
+                                  <Component id="lblTransparency2" alignment="0" min="-2" max="-2" attributes="1"/>
+                                  <Component id="lblColor2" alignment="0" min="-2" max="-2" attributes="0"/>
+                              </Group>
+                              <EmptySpace max="-2" attributes="0"/>
+                              <Group type="103" groupAlignment="0" attributes="0">
+                                  <Component id="tfPixelValues2" alignment="0" min="-2" pref="70" max="-2" attributes="1"/>
+                                  <Component id="pnlSelectedColor2" alignment="0" min="-2" max="-2" attributes="0"/>
+                                  <Component id="sdrTransparency2" alignment="0" min="0" pref="0" max="32767" attributes="1"/>
+                                  <Component id="cbxPredefinedValues2" alignment="0" pref="193" max="32767" attributes="1"/>
+                              </Group>
+                          </Group>
+                      </Group>
+                      <EmptySpace max="-2" attributes="0"/>
+                  </Group>
+              </Group>
+            </DimensionLayout>
+            <DimensionLayout dim="1">
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Group type="102" attributes="0">
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="chbxSecondSurface" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace min="-2" pref="8" max="-2" attributes="0"/>
+                      <Group type="103" groupAlignment="3" attributes="0">
+                          <Component id="cbxPredefinedValues2" alignment="3" min="-2" max="-2" attributes="0"/>
+                          <Component id="lblPredefinedValues2" alignment="3" min="-2" pref="24" max="-2" attributes="0"/>
+                      </Group>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Group type="103" groupAlignment="3" attributes="0">
+                          <Component id="tfPixelValues2" alignment="3" min="-2" max="-2" attributes="0"/>
+                          <Component id="lblPixelValues2" alignment="3" min="-2" pref="20" max="-2" attributes="0"/>
+                      </Group>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Group type="103" groupAlignment="0" attributes="0">
+                          <Group type="102" alignment="0" attributes="0">
+                              <Component id="sdrTransparency2" min="-2" pref="28" max="-2" attributes="1"/>
+                              <EmptySpace type="separate" max="-2" attributes="0"/>
+                              <Component id="pnlSelectedColor2" min="-2" max="-2" attributes="0"/>
+                          </Group>
+                          <Group type="102" alignment="0" attributes="0">
+                              <Component id="lblTransparency2" min="-2" pref="36" max="-2" attributes="1"/>
+                              <EmptySpace type="unrelated" max="-2" attributes="0"/>
+                              <Component id="lblColor2" min="-2" pref="28" max="-2" attributes="0"/>
+                          </Group>
+                      </Group>
+                      <EmptySpace max="-2" attributes="0"/>
+                  </Group>
+              </Group>
+            </DimensionLayout>
+          </Layout>
+          <SubComponents>
+            <Component class="javax.swing.JLabel" name="lblColor2">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="Color"/>
+              </Properties>
+            </Component>
+            <Component class="javax.swing.JSlider" name="sdrTransparency2">
+              <Properties>
+                <Property name="value" type="int" value="100"/>
+              </Properties>
+            </Component>
+            <Component class="javax.swing.JCheckBox" name="chbxSecondSurface">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="Second Surface"/>
+              </Properties>
+            </Component>
+            <Component class="javax.swing.JLabel" name="lblPixelValues2">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="Pixel Values"/>
+              </Properties>
+            </Component>
+            <Component class="javax.swing.JTextField" name="tfPixelValues2">
+            </Component>
+            <Component class="javax.swing.JLabel" name="lblTransparency2">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="Transparency"/>
+              </Properties>
+            </Component>
+            <Component class="javax.swing.JComboBox" name="cbxPredefinedValues2">
+              <Properties>
+                <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
+                  <StringArray count="4">
+                    <StringItem index="0" value="Custom"/>
+                    <StringItem index="1" value="Skin"/>
+                    <StringItem index="2" value="Bone"/>
+                    <StringItem index="3" value="Metal"/>
+                  </StringArray>
+                </Property>
+                <Property name="keySelectionManager" type="javax.swing.JComboBox$KeySelectionManager" editor="org.netbeans.modules.form.ComponentChooserEditor">
+                  <ComponentRef name="null"/>
+                </Property>
+              </Properties>
+              <Events>
+                <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="cbxPredefinedValues2ItemStateChanged"/>
+              </Events>
+            </Component>
+            <Component class="javax.swing.JLabel" name="lblPredefinedValues2">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="Predefined Values"/>
+              </Properties>
+            </Component>
+            <Container class="javax.swing.JPanel" name="pnlSelectedColor2">
+              <Properties>
+                <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+                  <Color blue="69" green="95" red="eb" type="rgb"/>
+                </Property>
+                <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+                  <Border info="org.netbeans.modules.form.compat2.border.CompoundBorderInfo">
+                    <CompoundBorder>
+                      <Border PropertyName="outside" info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
+                        <LineBorder thickness="2"/>
+                      </Border>
+                      <Border PropertyName="inside" info="org.netbeans.modules.form.compat2.border.BevelBorderInfo">
+                        <BevelBorder bevelType="1"/>
+                      </Border>
+                    </CompoundBorder>
+                  </Border>
+                </Property>
+              </Properties>
+              <Events>
+                <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="pnlSelectedColor2MouseClicked"/>
+              </Events>
+
+              <Layout>
+                <DimensionLayout dim="0">
+                  <Group type="103" groupAlignment="0" attributes="0">
+                      <EmptySpace min="0" pref="60" max="32767" attributes="0"/>
+                  </Group>
+                </DimensionLayout>
+                <DimensionLayout dim="1">
+                  <Group type="103" groupAlignment="0" attributes="0">
+                      <EmptySpace min="0" pref="28" max="32767" attributes="0"/>
+                  </Group>
+                </DimensionLayout>
+              </Layout>
+            </Container>
+          </SubComponents>
+        </Container>
+        <Container class="javax.swing.JPanel" name="pnlSurface1">
+          <Properties>
+            <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+              <Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
+                <LineBorder/>
+              </Border>
+            </Property>
+          </Properties>
+
+          <Layout>
+            <DimensionLayout dim="0">
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Group type="102" attributes="0">
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Group type="103" groupAlignment="0" attributes="0">
+                          <Group type="102" alignment="0" attributes="0">
+                              <Component id="chbxFirstSurface" min="-2" max="-2" attributes="0"/>
+                              <EmptySpace min="-2" pref="184" max="-2" attributes="0"/>
+                          </Group>
+                          <Group type="102" alignment="0" attributes="0">
+                              <Group type="103" groupAlignment="0" attributes="0">
+                                  <Component id="lblPixelValues1" min="-2" max="-2" attributes="1"/>
+                                  <Component id="lblTransparency1" min="-2" max="-2" attributes="1"/>
+                                  <Group type="102" alignment="0" attributes="0">
+                                      <EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
+                                      <Component id="lblColor1" min="-2" max="-2" attributes="1"/>
+                                  </Group>
+                              </Group>
+                              <EmptySpace min="-2" pref="45" max="-2" attributes="0"/>
+                              <Group type="103" groupAlignment="1" attributes="0">
+                                  <Component id="pnlSelectedColor1" alignment="0" min="-2" max="-2" attributes="0"/>
+                                  <Group type="103" alignment="1" groupAlignment="1" attributes="0">
+                                      <Component id="cbxPredefinedValues1" alignment="0" pref="189" max="32767" attributes="1"/>
+                                      <Component id="sdrTransparency1" alignment="1" pref="189" max="32767" attributes="1"/>
+                                  </Group>
+                                  <Component id="tfPixelValues1" alignment="0" min="-2" pref="65" max="-2" attributes="1"/>
+                              </Group>
+                          </Group>
+                          <Component id="lblPredefinedValues1" alignment="0" min="-2" max="-2" attributes="1"/>
+                      </Group>
+                      <EmptySpace max="-2" attributes="0"/>
+                  </Group>
+              </Group>
+            </DimensionLayout>
+            <DimensionLayout dim="1">
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Group type="102" attributes="0">
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="chbxFirstSurface" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace type="unrelated" max="-2" attributes="0"/>
+                      <Group type="103" groupAlignment="0" attributes="0">
+                          <Component id="cbxPredefinedValues1" min="-2" max="-2" attributes="0"/>
+                          <Component id="lblPredefinedValues1" min="-2" pref="24" max="-2" attributes="0"/>
+                      </Group>
+                      <EmptySpace min="-2" pref="8" max="-2" attributes="0"/>
+                      <Group type="103" groupAlignment="1" max="-2" attributes="0">
+                          <Component id="lblPixelValues1" max="32767" attributes="1"/>
+                          <Component id="tfPixelValues1" alignment="1" max="32767" attributes="1"/>
+                      </Group>
+                      <EmptySpace type="unrelated" max="-2" attributes="0"/>
+                      <Group type="103" groupAlignment="1" max="-2" attributes="0">
+                          <Component id="lblTransparency1" max="32767" attributes="1"/>
+                          <Component id="sdrTransparency1" alignment="1" pref="28" max="32767" attributes="1"/>
+                      </Group>
+                      <EmptySpace type="separate" max="-2" attributes="0"/>
+                      <Group type="103" groupAlignment="1" max="-2" attributes="0">
+                          <Component id="lblColor1" max="32767" attributes="1"/>
+                          <Component id="pnlSelectedColor1" alignment="1" max="32767" attributes="1"/>
+                      </Group>
+                      <EmptySpace max="32767" attributes="0"/>
+                  </Group>
+              </Group>
+            </DimensionLayout>
+          </Layout>
+          <SubComponents>
+            <Component class="javax.swing.JComboBox" name="cbxPredefinedValues1">
+              <Properties>
+                <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
+                  <StringArray count="4">
+                    <StringItem index="0" value="Custom"/>
+                    <StringItem index="1" value="Skin"/>
+                    <StringItem index="2" value="Bone"/>
+                    <StringItem index="3" value="Metal"/>
+                  </StringArray>
+                </Property>
+                <Property name="keySelectionManager" type="javax.swing.JComboBox$KeySelectionManager" editor="org.netbeans.modules.form.ComponentChooserEditor">
+                  <ComponentRef name="null"/>
+                </Property>
+              </Properties>
+              <Events>
+                <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="cbxPredefinedValues1ItemStateChanged"/>
+              </Events>
+            </Component>
+            <Component class="javax.swing.JSlider" name="sdrTransparency1">
+              <Properties>
+                <Property name="value" type="int" value="100"/>
+              </Properties>
+            </Component>
+            <Component class="javax.swing.JLabel" name="lblPredefinedValues1">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="Predefined Values"/>
+              </Properties>
+            </Component>
+            <Container class="javax.swing.JPanel" name="pnlSelectedColor1">
+              <Properties>
+                <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+                  <Color blue="fe" green="fe" red="fe" type="rgb"/>
+                </Property>
+                <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+                  <Border info="org.netbeans.modules.form.compat2.border.CompoundBorderInfo">
+                    <CompoundBorder>
+                      <Border PropertyName="outside" info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
+                        <LineBorder thickness="2"/>
+                      </Border>
+                      <Border PropertyName="inside" info="org.netbeans.modules.form.compat2.border.BevelBorderInfo">
+                        <BevelBorder bevelType="1"/>
+                      </Border>
+                    </CompoundBorder>
+                  </Border>
+                </Property>
+              </Properties>
+              <Events>
+                <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="pnlSelectedColor1MouseClicked"/>
+              </Events>
+
+              <Layout>
+                <DimensionLayout dim="0">
+                  <Group type="103" groupAlignment="0" attributes="0">
+                      <EmptySpace min="0" pref="61" max="32767" attributes="0"/>
+                  </Group>
+                </DimensionLayout>
+                <DimensionLayout dim="1">
+                  <Group type="103" groupAlignment="0" attributes="0">
+                      <EmptySpace min="0" pref="26" max="32767" attributes="0"/>
+                  </Group>
+                </DimensionLayout>
+              </Layout>
+            </Container>
+            <Component class="javax.swing.JTextField" name="tfPixelValues1">
+            </Component>
+            <Component class="javax.swing.JLabel" name="lblTransparency1">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="Transparency"/>
+              </Properties>
+            </Component>
+            <Component class="javax.swing.JLabel" name="lblPixelValues1">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="Pixel Values"/>
+              </Properties>
+            </Component>
+            <Component class="javax.swing.JLabel" name="lblColor1">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="Color"/>
+              </Properties>
+            </Component>
+            <Component class="javax.swing.JCheckBox" name="chbxFirstSurface">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="First Surface"/>
+              </Properties>
+            </Component>
+          </SubComponents>
+        </Container>
+      </SubComponents>
+    </Container>
+  </NonVisualComponents>
+  <Properties>
+    <Property name="defaultCloseOperation" type="int" value="2"/>
+    <Property name="title" type="java.lang.String" value="Surface Rendering"/>
+    <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
+      <Color id="Default Cursor"/>
+    </Property>
+    <Property name="resizable" type="boolean" value="false"/>
+  </Properties>
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <Events>
+    <EventHandler event="windowClosed" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="formWindowClosed"/>
+  </Events>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Component id="pnlSurfaceViewer" alignment="0" max="32767" attributes="1"/>
+                  <Group type="102" alignment="0" attributes="0">
+                      <Component id="lblSurfaceZoomInOut" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="lblRotateSurface" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="lblSurfaceMove" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="lblSurfaceCubeBox" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
+                      <Component id="lblSurfaceSettings" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace type="separate" max="-2" attributes="0"/>
+                      <Component id="lblCaptureScreenShot" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace min="-2" pref="37" max="-2" attributes="0"/>
+                      <Component id="lblDisplayPurpose" min="-2" pref="615" max="-2" attributes="1"/>
+                      <EmptySpace pref="88" max="32767" attributes="0"/>
+                      <Component id="lblAxial" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace min="-2" pref="5" max="-2" attributes="0"/>
+                      <Component id="lblCoronal" min="-2" pref="22" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="lblSagittal" min="-2" pref="22" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="pnlselectedBackgroundColor" min="-2" max="-2" attributes="0"/>
+                  </Group>
+              </Group>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Component id="lblDisplayPurpose" pref="24" max="32767" attributes="1"/>
+                  <Group type="103" alignment="0" groupAlignment="1" attributes="0">
+                      <Group type="103" groupAlignment="0" max="-2" attributes="0">
+                          <Component id="lblCaptureScreenShot" alignment="0" max="32767" attributes="1"/>
+                          <Component id="lblSurfaceSettings" alignment="0" max="32767" attributes="1"/>
+                          <Component id="lblSurfaceCubeBox" alignment="0" max="32767" attributes="1"/>
+                          <Component id="lblSurfaceMove" alignment="0" max="32767" attributes="1"/>
+                          <Component id="lblRotateSurface" alignment="0" max="32767" attributes="1"/>
+                          <Component id="lblSurfaceZoomInOut" alignment="0" max="32767" attributes="1"/>
+                      </Group>
+                      <Group type="103" groupAlignment="0" max="-2" attributes="0">
+                          <Component id="pnlselectedBackgroundColor" max="32767" attributes="1"/>
+                          <Component id="lblSagittal" alignment="0" max="32767" attributes="1"/>
+                          <Component id="lblCoronal" alignment="0" max="32767" attributes="1"/>
+                          <Component id="lblAxial" alignment="0" min="-2" max="-2" attributes="1"/>
+                      </Group>
+                  </Group>
+              </Group>
+              <EmptySpace type="unrelated" max="-2" attributes="0"/>
+              <Component id="pnlSurfaceViewer" max="32767" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Container class="javax.swing.JPanel" name="pnlSurfaceViewer">
+
+      <Layout>
+        <DimensionLayout dim="0">
+          <Group type="103" groupAlignment="0" attributes="0">
+              <EmptySpace min="0" pref="1012" max="32767" attributes="0"/>
+          </Group>
+        </DimensionLayout>
+        <DimensionLayout dim="1">
+          <Group type="103" groupAlignment="0" attributes="0">
+              <EmptySpace min="0" pref="708" max="32767" attributes="0"/>
+          </Group>
+        </DimensionLayout>
+      </Layout>
+    </Container>
+    <Component class="javax.swing.JLabel" name="lblRotateSurface">
+      <Properties>
+        <Property name="horizontalAlignment" type="int" value="0"/>
+        <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+          <Image iconType="3" name="/in/raster/mayam/form/images/RotateSurface.png"/>
+        </Property>
+        <Property name="toolTipText" type="java.lang.String" value="Rotate the Surface Volume"/>
+        <Property name="verticalAlignment" type="int" value="3"/>
+        <Property name="horizontalTextPosition" type="int" value="0"/>
+        <Property name="iconTextGap" type="int" value="0"/>
+        <Property name="verticalTextPosition" type="int" value="3"/>
+      </Properties>
+      <Events>
+        <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblRotateSurfaceMouseClicked"/>
+        <EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblRotateSurfaceMouseEntered"/>
+        <EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblRotateSurfaceMouseExited"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JLabel" name="lblSurfaceMove">
+      <Properties>
+        <Property name="horizontalAlignment" type="int" value="0"/>
+        <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+          <Image iconType="3" name="/in/raster/mayam/form/images/Move.png"/>
+        </Property>
+        <Property name="toolTipText" type="java.lang.String" value="Move the Surface Volume"/>
+        <Property name="verticalAlignment" type="int" value="3"/>
+      </Properties>
+      <Events>
+        <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblSurfaceMoveMouseClicked"/>
+        <EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblSurfaceMoveMouseEntered"/>
+        <EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblSurfaceMoveMouseExited"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JLabel" name="lblSurfaceCubeBox">
+      <Properties>
+        <Property name="horizontalAlignment" type="int" value="0"/>
+        <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+          <Image iconType="3" name="/in/raster/mayam/form/images/ResetInteractor.png"/>
+        </Property>
+        <Property name="toolTipText" type="java.lang.String" value="Reset the Mouse Operations"/>
+        <Property name="verticalAlignment" type="int" value="3"/>
+      </Properties>
+      <Events>
+        <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblSurfaceCubeBoxMouseClicked"/>
+        <EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblSurfaceCubeBoxMouseEntered"/>
+        <EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblSurfaceCubeBoxMouseExited"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JLabel" name="lblSurfaceSettings">
+      <Properties>
+        <Property name="horizontalAlignment" type="int" value="0"/>
+        <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+          <Image iconType="3" name="/in/raster/mayam/form/images/FusionSurfaceSettings.png"/>
+        </Property>
+        <Property name="toolTipText" type="java.lang.String" value="Settings for Surface Rendering"/>
+        <Property name="verticalAlignment" type="int" value="3"/>
+      </Properties>
+      <Events>
+        <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblSurfaceSettingsMouseClicked"/>
+        <EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblSurfaceSettingsMouseEntered"/>
+        <EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblSurfaceSettingsMouseExited"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JLabel" name="lblAxial">
+      <Properties>
+        <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+          <Image iconType="3" name="/in/raster/mayam/form/images/AxialView.png"/>
+        </Property>
+        <Property name="toolTipText" type="java.lang.String" value="Display the Surface Volume in Axial View"/>
+      </Properties>
+      <Events>
+        <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblAxialMouseClicked"/>
+        <EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblAxialMouseEntered"/>
+        <EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblAxialMouseExited"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JLabel" name="lblCoronal">
+      <Properties>
+        <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+          <Image iconType="3" name="/in/raster/mayam/form/images/CoronalView.png"/>
+        </Property>
+        <Property name="toolTipText" type="java.lang.String" value="Display the Surface Volume in Coronal View"/>
+      </Properties>
+      <Events>
+        <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblCoronalMouseClicked"/>
+        <EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblCoronalMouseEntered"/>
+        <EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblCoronalMouseExited"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JLabel" name="lblSagittal">
+      <Properties>
+        <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+          <Image iconType="3" name="/in/raster/mayam/form/images/SagittalView.png"/>
+        </Property>
+        <Property name="toolTipText" type="java.lang.String" value="Display the Surface Volume in Sagittal View"/>
+      </Properties>
+      <Events>
+        <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblSagittalMouseClicked"/>
+        <EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblSagittalMouseEntered"/>
+        <EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblSagittalMouseExited"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JLabel" name="lblDisplayPurpose">
+      <Properties>
+        <Property name="horizontalAlignment" type="int" value="0"/>
+        <Property name="text" type="java.lang.String" value="3D Surface Rendering"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="lblCaptureScreenShot">
+      <Properties>
+        <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+          <Image iconType="3" name="/in/raster/mayam/form/images/ScreenShot.png"/>
+        </Property>
+        <Property name="toolTipText" type="java.lang.String" value="Capture ScreenShot"/>
+      </Properties>
+      <Events>
+        <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblCaptureScreenShotMouseClicked"/>
+        <EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblCaptureScreenShotMouseEntered"/>
+        <EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblCaptureScreenShotMouseExited"/>
+      </Events>
+    </Component>
+    <Container class="javax.swing.JPanel" name="pnlselectedBackgroundColor">
+      <Properties>
+        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+          <Color blue="4" green="2" red="3" type="rgb"/>
+        </Property>
+        <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+          <Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
+            <LineBorder thickness="2">
+              <Color PropertyName="color" blue="ff" green="a0" red="0" type="rgb"/>
+            </LineBorder>
+          </Border>
+        </Property>
+        <Property name="toolTipText" type="java.lang.String" value="Change Background Color"/>
+      </Properties>
+      <Events>
+        <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="pnlselectedBackgroundColorMouseClicked"/>
+        <EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="pnlselectedBackgroundColorMouseEntered"/>
+        <EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="pnlselectedBackgroundColorMouseExited"/>
+      </Events>
+
+      <Layout>
+        <DimensionLayout dim="0">
+          <Group type="103" groupAlignment="0" attributes="0">
+              <EmptySpace min="0" pref="23" max="32767" attributes="0"/>
+          </Group>
+        </DimensionLayout>
+        <DimensionLayout dim="1">
+          <Group type="103" groupAlignment="0" attributes="0">
+              <EmptySpace min="0" pref="20" max="32767" attributes="0"/>
+          </Group>
+        </DimensionLayout>
+      </Layout>
+    </Container>
+    <Component class="javax.swing.JLabel" name="lblSurfaceZoomInOut">
+      <Properties>
+        <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+          <Image iconType="3" name="/in/raster/mayam/form/images/ZoomInOut.png"/>
+        </Property>
+        <Property name="toolTipText" type="java.lang.String" value="Zoom In or Zoom Out the Surface Volume"/>
+      </Properties>
+      <Events>
+        <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblSurfaceZoomInOutMouseClicked"/>
+        <EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblSurfaceZoomInOutMouseEntered"/>
+        <EventHandler event="mouseExited" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblSurfaceZoomInOutMouseExited"/>
+      </Events>
+    </Component>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/dcm3d/SurfaceRendering.java b/src/in/raster/mayam/form/dcm3d/SurfaceRendering.java
new file mode 100644
index 0000000..da8ef45
--- /dev/null
+++ b/src/in/raster/mayam/form/dcm3d/SurfaceRendering.java
@@ -0,0 +1,1373 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Guru Rajan R
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Sathish Kumar V
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form.dcm3d;
+
+import java.io.File;
+import java.awt.Color;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionListener;
+
+import javax.swing.JColorChooser;
+import javax.swing.JFileChooser;
+import javax.swing.JOptionPane;
+import javax.swing.filechooser.FileFilter;
+
+import vtk.vtkCamera;
+import vtk.vtkCellPicker;
+import vtk.vtkDICOMImageReader;
+import vtk.vtkActor;
+import vtk.vtkLight;
+import vtk.vtkLightCollection;
+import vtk.vtkMarchingCubes;
+import vtk.vtkOutlineFilter;
+import vtk.vtkPanel;
+import vtk.vtkPolyDataMapper;
+
+/**
+ * SurfaceRendering.java
+ *
+ * Created on 1 Jul, 2010, 1:06:56 PM
+ *
+ *  This File Load the Series of Dicom images and
+ *  Construct them as a Surfaces like Skin, Bone, and Metal according to the User Inputs...
+ *
+ */
+
+/*
+ * @author Sathish Kumar V              (sathishkumar.v at raster.in)
+ */
+public class SurfaceRendering extends javax.swing.JFrame {
+
+    private vtkDICOMImageReader reader;
+    private vtkPanel vpanSurface = new vtkPanel();
+    private String directoryName = "", DisplayString = "3D Surface Rendering";
+    private vtkMarchingCubes mCube;
+    private int xMin, xMax, yMin, yMax, zMin, zMax, mode, lastX, lastY, doDragFlag = 0;
+    private double sx, sy, sz, ox, oy, oz;
+    private vtkCamera camera;
+
+    static {
+        System.loadLibrary("vtkCommonJava");
+        System.loadLibrary("vtkFilteringJava");
+        System.loadLibrary("vtkIOJava");
+        System.loadLibrary("vtkImagingJava");
+        System.loadLibrary("vtkGraphicsJava");
+        System.loadLibrary("vtkRenderingJava");
+        System.loadLibrary("vtkWidgetsJava");
+        System.loadLibrary("vtkVolumeRenderingJava");
+    }
+
+
+    /* Creates new form SurfaceRendering */
+    public SurfaceRendering() {
+        initComponents();
+        vpanSurface.setSize(pnlSurfaceViewer.getSize());
+        vpanSurface.setBackground(Color.white);
+    }
+
+    @SuppressWarnings("unchecked")
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        dlgSurfaceSettings = new javax.swing.JDialog();
+        btnSurfaceSettingsOk = new javax.swing.JButton();
+        btnSurfaceSettingsCancel = new javax.swing.JButton();
+        pnlSurface2 = new javax.swing.JPanel();
+        lblColor2 = new javax.swing.JLabel();
+        sdrTransparency2 = new javax.swing.JSlider();
+        chbxSecondSurface = new javax.swing.JCheckBox();
+        lblPixelValues2 = new javax.swing.JLabel();
+        tfPixelValues2 = new javax.swing.JTextField();
+        lblTransparency2 = new javax.swing.JLabel();
+        cbxPredefinedValues2 = new javax.swing.JComboBox();
+        lblPredefinedValues2 = new javax.swing.JLabel();
+        pnlSelectedColor2 = new javax.swing.JPanel();
+        pnlSurface1 = new javax.swing.JPanel();
+        cbxPredefinedValues1 = new javax.swing.JComboBox();
+        sdrTransparency1 = new javax.swing.JSlider();
+        lblPredefinedValues1 = new javax.swing.JLabel();
+        pnlSelectedColor1 = new javax.swing.JPanel();
+        tfPixelValues1 = new javax.swing.JTextField();
+        lblTransparency1 = new javax.swing.JLabel();
+        lblPixelValues1 = new javax.swing.JLabel();
+        lblColor1 = new javax.swing.JLabel();
+        chbxFirstSurface = new javax.swing.JCheckBox();
+        pnlSurfaceViewer = new javax.swing.JPanel();
+        lblRotateSurface = new javax.swing.JLabel();
+        lblSurfaceMove = new javax.swing.JLabel();
+        lblSurfaceCubeBox = new javax.swing.JLabel();
+        lblSurfaceSettings = new javax.swing.JLabel();
+        lblAxial = new javax.swing.JLabel();
+        lblCoronal = new javax.swing.JLabel();
+        lblSagittal = new javax.swing.JLabel();
+        lblDisplayPurpose = new javax.swing.JLabel();
+        lblCaptureScreenShot = new javax.swing.JLabel();
+        pnlselectedBackgroundColor = new javax.swing.JPanel();
+        lblSurfaceZoomInOut = new javax.swing.JLabel();
+
+        dlgSurfaceSettings.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
+        dlgSurfaceSettings.setAlwaysOnTop(true);
+        dlgSurfaceSettings.setResizable(false);
+
+        btnSurfaceSettingsOk.setText("Ok");
+        btnSurfaceSettingsOk.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                btnSurfaceSettingsOkActionPerformed(evt);
+            }
+        });
+
+        btnSurfaceSettingsCancel.setText("Cancel");
+        btnSurfaceSettingsCancel.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                btnSurfaceSettingsCancelActionPerformed(evt);
+            }
+        });
+
+        pnlSurface2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
+
+        lblColor2.setText("Color");
+
+        sdrTransparency2.setValue(100);
+
+        chbxSecondSurface.setText("Second Surface");
+
+        lblPixelValues2.setText("Pixel Values");
+
+        lblTransparency2.setText("Transparency");
+
+        cbxPredefinedValues2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Custom", "Skin", "Bone", "Metal" }));
+        cbxPredefinedValues2.setKeySelectionManager(null);
+        cbxPredefinedValues2.addItemListener(new java.awt.event.ItemListener() {
+            public void itemStateChanged(java.awt.event.ItemEvent evt) {
+                cbxPredefinedValues2ItemStateChanged(evt);
+            }
+        });
+
+        lblPredefinedValues2.setText("Predefined Values");
+
+        pnlSelectedColor2.setBackground(new java.awt.Color(235, 149, 105));
+        pnlSelectedColor2.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0), 2), javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED)));
+        pnlSelectedColor2.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                pnlSelectedColor2MouseClicked(evt);
+            }
+        });
+
+        javax.swing.GroupLayout pnlSelectedColor2Layout = new javax.swing.GroupLayout(pnlSelectedColor2);
+        pnlSelectedColor2.setLayout(pnlSelectedColor2Layout);
+        pnlSelectedColor2Layout.setHorizontalGroup(
+            pnlSelectedColor2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGap(0, 60, Short.MAX_VALUE)
+        );
+        pnlSelectedColor2Layout.setVerticalGroup(
+            pnlSelectedColor2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGap(0, 28, Short.MAX_VALUE)
+        );
+
+        javax.swing.GroupLayout pnlSurface2Layout = new javax.swing.GroupLayout(pnlSurface2);
+        pnlSurface2.setLayout(pnlSurface2Layout);
+        pnlSurface2Layout.setHorizontalGroup(
+            pnlSurface2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGroup(pnlSurface2Layout.createSequentialGroup()
+                .addContainerGap()
+                .addGroup(pnlSurface2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                    .addComponent(chbxSecondSurface)
+                    .addGroup(pnlSurface2Layout.createSequentialGroup()
+                        .addGroup(pnlSurface2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                            .addComponent(lblPredefinedValues2)
+                            .addComponent(lblPixelValues2)
+                            .addComponent(lblTransparency2)
+                            .addComponent(lblColor2))
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                        .addGroup(pnlSurface2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                            .addComponent(tfPixelValues2, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
+                            .addComponent(pnlSelectedColor2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+                            .addComponent(sdrTransparency2, 0, 0, Short.MAX_VALUE)
+                            .addComponent(cbxPredefinedValues2, 0, 193, Short.MAX_VALUE))))
+                .addContainerGap())
+        );
+        pnlSurface2Layout.setVerticalGroup(
+            pnlSurface2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGroup(pnlSurface2Layout.createSequentialGroup()
+                .addContainerGap()
+                .addComponent(chbxSecondSurface)
+                .addGap(8, 8, 8)
+                .addGroup(pnlSurface2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+                    .addComponent(cbxPredefinedValues2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+                    .addComponent(lblPredefinedValues2, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                .addGroup(pnlSurface2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+                    .addComponent(tfPixelValues2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+                    .addComponent(lblPixelValues2, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                .addGroup(pnlSurface2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                    .addGroup(pnlSurface2Layout.createSequentialGroup()
+                        .addComponent(sdrTransparency2, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
+                        .addGap(18, 18, 18)
+                        .addComponent(pnlSelectedColor2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+                    .addGroup(pnlSurface2Layout.createSequentialGroup()
+                        .addComponent(lblTransparency2, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+                        .addComponent(lblColor2, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)))
+                .addContainerGap())
+        );
+
+        pnlSurface1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
+
+        cbxPredefinedValues1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Custom", "Skin", "Bone", "Metal" }));
+        cbxPredefinedValues1.setKeySelectionManager(null);
+        cbxPredefinedValues1.addItemListener(new java.awt.event.ItemListener() {
+            public void itemStateChanged(java.awt.event.ItemEvent evt) {
+                cbxPredefinedValues1ItemStateChanged(evt);
+            }
+        });
+
+        sdrTransparency1.setValue(100);
+
+        lblPredefinedValues1.setText("Predefined Values");
+
+        pnlSelectedColor1.setBackground(new java.awt.Color(254, 254, 254));
+        pnlSelectedColor1.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0), 2), javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED)));
+        pnlSelectedColor1.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                pnlSelectedColor1MouseClicked(evt);
+            }
+        });
+
+        javax.swing.GroupLayout pnlSelectedColor1Layout = new javax.swing.GroupLayout(pnlSelectedColor1);
+        pnlSelectedColor1.setLayout(pnlSelectedColor1Layout);
+        pnlSelectedColor1Layout.setHorizontalGroup(
+            pnlSelectedColor1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGap(0, 61, Short.MAX_VALUE)
+        );
+        pnlSelectedColor1Layout.setVerticalGroup(
+            pnlSelectedColor1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGap(0, 26, Short.MAX_VALUE)
+        );
+
+        lblTransparency1.setText("Transparency");
+
+        lblPixelValues1.setText("Pixel Values");
+
+        lblColor1.setText("Color");
+
+        chbxFirstSurface.setText("First Surface");
+
+        javax.swing.GroupLayout pnlSurface1Layout = new javax.swing.GroupLayout(pnlSurface1);
+        pnlSurface1.setLayout(pnlSurface1Layout);
+        pnlSurface1Layout.setHorizontalGroup(
+            pnlSurface1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGroup(pnlSurface1Layout.createSequentialGroup()
+                .addContainerGap()
+                .addGroup(pnlSurface1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                    .addGroup(pnlSurface1Layout.createSequentialGroup()
+                        .addComponent(chbxFirstSurface)
+                        .addGap(184, 184, 184))
+                    .addGroup(pnlSurface1Layout.createSequentialGroup()
+                        .addGroup(pnlSurface1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                            .addComponent(lblPixelValues1)
+                            .addComponent(lblTransparency1)
+                            .addGroup(pnlSurface1Layout.createSequentialGroup()
+                                .addGap(12, 12, 12)
+                                .addComponent(lblColor1)))
+                        .addGap(45, 45, 45)
+                        .addGroup(pnlSurface1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+                            .addComponent(pnlSelectedColor1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+                            .addGroup(pnlSurface1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+                                .addComponent(cbxPredefinedValues1, javax.swing.GroupLayout.Alignment.LEADING, 0, 189, Short.MAX_VALUE)
+                                .addComponent(sdrTransparency1, javax.swing.GroupLayout.DEFAULT_SIZE, 189, Short.MAX_VALUE))
+                            .addComponent(tfPixelValues1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)))
+                    .addComponent(lblPredefinedValues1))
+                .addContainerGap())
+        );
+        pnlSurface1Layout.setVerticalGroup(
+            pnlSurface1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGroup(pnlSurface1Layout.createSequentialGroup()
+                .addContainerGap()
+                .addComponent(chbxFirstSurface)
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+                .addGroup(pnlSurface1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                    .addComponent(cbxPredefinedValues1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+                    .addComponent(lblPredefinedValues1, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
+                .addGap(8, 8, 8)
+                .addGroup(pnlSurface1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
+                    .addComponent(lblPixelValues1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                    .addComponent(tfPixelValues1))
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+                .addGroup(pnlSurface1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
+                    .addComponent(lblTransparency1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                    .addComponent(sdrTransparency1, javax.swing.GroupLayout.PREFERRED_SIZE, 28, Short.MAX_VALUE))
+                .addGap(18, 18, 18)
+                .addGroup(pnlSurface1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
+                    .addComponent(lblColor1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                    .addComponent(pnlSelectedColor1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+        );
+
+        javax.swing.GroupLayout dlgSurfaceSettingsLayout = new javax.swing.GroupLayout(dlgSurfaceSettings.getContentPane());
+        dlgSurfaceSettings.getContentPane().setLayout(dlgSurfaceSettingsLayout);
+        dlgSurfaceSettingsLayout.setHorizontalGroup(
+            dlgSurfaceSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGroup(dlgSurfaceSettingsLayout.createSequentialGroup()
+                .addContainerGap()
+                .addGroup(dlgSurfaceSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, dlgSurfaceSettingsLayout.createSequentialGroup()
+                        .addComponent(btnSurfaceSettingsOk, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+                        .addComponent(btnSurfaceSettingsCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE))
+                    .addGroup(dlgSurfaceSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
+                        .addComponent(pnlSurface1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                        .addComponent(pnlSurface2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
+                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+        );
+        dlgSurfaceSettingsLayout.setVerticalGroup(
+            dlgSurfaceSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGroup(dlgSurfaceSettingsLayout.createSequentialGroup()
+                .addContainerGap()
+                .addComponent(pnlSurface1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+                .addComponent(pnlSurface2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+                .addGroup(dlgSurfaceSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                    .addComponent(btnSurfaceSettingsOk)
+                    .addComponent(btnSurfaceSettingsCancel))
+                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+        );
+
+        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+        setTitle("Surface Rendering");
+        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
+        setResizable(false);
+        addWindowListener(new java.awt.event.WindowAdapter() {
+            public void windowClosed(java.awt.event.WindowEvent evt) {
+                formWindowClosed(evt);
+            }
+        });
+
+        javax.swing.GroupLayout pnlSurfaceViewerLayout = new javax.swing.GroupLayout(pnlSurfaceViewer);
+        pnlSurfaceViewer.setLayout(pnlSurfaceViewerLayout);
+        pnlSurfaceViewerLayout.setHorizontalGroup(
+            pnlSurfaceViewerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGap(0, 1012, Short.MAX_VALUE)
+        );
+        pnlSurfaceViewerLayout.setVerticalGroup(
+            pnlSurfaceViewerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGap(0, 708, Short.MAX_VALUE)
+        );
+
+        lblRotateSurface.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+        lblRotateSurface.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/RotateSurface.png"))); // NOI18N
+        lblRotateSurface.setToolTipText("Rotate the Surface Volume");
+        lblRotateSurface.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
+        lblRotateSurface.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+        lblRotateSurface.setIconTextGap(0);
+        lblRotateSurface.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        lblRotateSurface.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                lblRotateSurfaceMouseClicked(evt);
+            }
+            public void mouseEntered(java.awt.event.MouseEvent evt) {
+                lblRotateSurfaceMouseEntered(evt);
+            }
+            public void mouseExited(java.awt.event.MouseEvent evt) {
+                lblRotateSurfaceMouseExited(evt);
+            }
+        });
+
+        lblSurfaceMove.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+        lblSurfaceMove.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/Move.png"))); // NOI18N
+        lblSurfaceMove.setToolTipText("Move the Surface Volume");
+        lblSurfaceMove.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
+        lblSurfaceMove.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                lblSurfaceMoveMouseClicked(evt);
+            }
+            public void mouseEntered(java.awt.event.MouseEvent evt) {
+                lblSurfaceMoveMouseEntered(evt);
+            }
+            public void mouseExited(java.awt.event.MouseEvent evt) {
+                lblSurfaceMoveMouseExited(evt);
+            }
+        });
+
+        lblSurfaceCubeBox.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+        lblSurfaceCubeBox.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/ResetInteractor.png"))); // NOI18N
+        lblSurfaceCubeBox.setToolTipText("Reset the Mouse Operations");
+        lblSurfaceCubeBox.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
+        lblSurfaceCubeBox.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                lblSurfaceCubeBoxMouseClicked(evt);
+            }
+            public void mouseEntered(java.awt.event.MouseEvent evt) {
+                lblSurfaceCubeBoxMouseEntered(evt);
+            }
+            public void mouseExited(java.awt.event.MouseEvent evt) {
+                lblSurfaceCubeBoxMouseExited(evt);
+            }
+        });
+
+        lblSurfaceSettings.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+        lblSurfaceSettings.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/FusionSurfaceSettings.png"))); // NOI18N
+        lblSurfaceSettings.setToolTipText("Settings for Surface Rendering");
+        lblSurfaceSettings.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
+        lblSurfaceSettings.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                lblSurfaceSettingsMouseClicked(evt);
+            }
+            public void mouseEntered(java.awt.event.MouseEvent evt) {
+                lblSurfaceSettingsMouseEntered(evt);
+            }
+            public void mouseExited(java.awt.event.MouseEvent evt) {
+                lblSurfaceSettingsMouseExited(evt);
+            }
+        });
+
+        lblAxial.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/AxialView.png"))); // NOI18N
+        lblAxial.setToolTipText("Display the Surface Volume in Axial View");
+        lblAxial.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                lblAxialMouseClicked(evt);
+            }
+            public void mouseEntered(java.awt.event.MouseEvent evt) {
+                lblAxialMouseEntered(evt);
+            }
+            public void mouseExited(java.awt.event.MouseEvent evt) {
+                lblAxialMouseExited(evt);
+            }
+        });
+
+        lblCoronal.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/CoronalView.png"))); // NOI18N
+        lblCoronal.setToolTipText("Display the Surface Volume in Coronal View");
+        lblCoronal.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                lblCoronalMouseClicked(evt);
+            }
+            public void mouseEntered(java.awt.event.MouseEvent evt) {
+                lblCoronalMouseEntered(evt);
+            }
+            public void mouseExited(java.awt.event.MouseEvent evt) {
+                lblCoronalMouseExited(evt);
+            }
+        });
+
+        lblSagittal.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/SagittalView.png"))); // NOI18N
+        lblSagittal.setToolTipText("Display the Surface Volume in Sagittal View");
+        lblSagittal.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                lblSagittalMouseClicked(evt);
+            }
+            public void mouseEntered(java.awt.event.MouseEvent evt) {
+                lblSagittalMouseEntered(evt);
+            }
+            public void mouseExited(java.awt.event.MouseEvent evt) {
+                lblSagittalMouseExited(evt);
+            }
+        });
+
+        lblDisplayPurpose.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+        lblDisplayPurpose.setText("3D Surface Rendering");
+
+        lblCaptureScreenShot.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/ScreenShot.png"))); // NOI18N
+        lblCaptureScreenShot.setToolTipText("Capture ScreenShot");
+        lblCaptureScreenShot.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                lblCaptureScreenShotMouseClicked(evt);
+            }
+            public void mouseEntered(java.awt.event.MouseEvent evt) {
+                lblCaptureScreenShotMouseEntered(evt);
+            }
+            public void mouseExited(java.awt.event.MouseEvent evt) {
+                lblCaptureScreenShotMouseExited(evt);
+            }
+        });
+
+        pnlselectedBackgroundColor.setBackground(new java.awt.Color(3, 2, 4));
+        pnlselectedBackgroundColor.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 160, 255), 2));
+        pnlselectedBackgroundColor.setToolTipText("Change Background Color");
+        pnlselectedBackgroundColor.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                pnlselectedBackgroundColorMouseClicked(evt);
+            }
+            public void mouseEntered(java.awt.event.MouseEvent evt) {
+                pnlselectedBackgroundColorMouseEntered(evt);
+            }
+            public void mouseExited(java.awt.event.MouseEvent evt) {
+                pnlselectedBackgroundColorMouseExited(evt);
+            }
+        });
+
+        javax.swing.GroupLayout pnlselectedBackgroundColorLayout = new javax.swing.GroupLayout(pnlselectedBackgroundColor);
+        pnlselectedBackgroundColor.setLayout(pnlselectedBackgroundColorLayout);
+        pnlselectedBackgroundColorLayout.setHorizontalGroup(
+            pnlselectedBackgroundColorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGap(0, 23, Short.MAX_VALUE)
+        );
+        pnlselectedBackgroundColorLayout.setVerticalGroup(
+            pnlselectedBackgroundColorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGap(0, 20, Short.MAX_VALUE)
+        );
+
+        lblSurfaceZoomInOut.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/ZoomInOut.png"))); // NOI18N
+        lblSurfaceZoomInOut.setToolTipText("Zoom In or Zoom Out the Surface Volume");
+        lblSurfaceZoomInOut.addMouseListener(new java.awt.event.MouseAdapter() {
+            public void mouseClicked(java.awt.event.MouseEvent evt) {
+                lblSurfaceZoomInOutMouseClicked(evt);
+            }
+            public void mouseEntered(java.awt.event.MouseEvent evt) {
+                lblSurfaceZoomInOutMouseEntered(evt);
+            }
+            public void mouseExited(java.awt.event.MouseEvent evt) {
+                lblSurfaceZoomInOutMouseExited(evt);
+            }
+        });
+
+        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
+        getContentPane().setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGroup(layout.createSequentialGroup()
+                .addContainerGap()
+                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                    .addComponent(pnlSurfaceViewer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                    .addGroup(layout.createSequentialGroup()
+                        .addComponent(lblSurfaceZoomInOut)
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                        .addComponent(lblRotateSurface)
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                        .addComponent(lblSurfaceMove)
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                        .addComponent(lblSurfaceCubeBox)
+                        .addGap(18, 18, 18)
+                        .addComponent(lblSurfaceSettings)
+                        .addGap(18, 18, 18)
+                        .addComponent(lblCaptureScreenShot)
+                        .addGap(37, 37, 37)
+                        .addComponent(lblDisplayPurpose, javax.swing.GroupLayout.PREFERRED_SIZE, 615, javax.swing.GroupLayout.PREFERRED_SIZE)
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 40, Short.MAX_VALUE)
+                        .addComponent(lblAxial)
+                        .addGap(5, 5, 5)
+                        .addComponent(lblCoronal, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                        .addComponent(lblSagittal, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                        .addComponent(pnlselectedBackgroundColor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
+                .addContainerGap())
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGroup(layout.createSequentialGroup()
+                .addContainerGap()
+                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                    .addComponent(lblDisplayPurpose, javax.swing.GroupLayout.DEFAULT_SIZE, 24, Short.MAX_VALUE)
+                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
+                            .addComponent(lblCaptureScreenShot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                            .addComponent(lblSurfaceSettings, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                            .addComponent(lblSurfaceCubeBox, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                            .addComponent(lblSurfaceMove, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                            .addComponent(lblRotateSurface, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                            .addComponent(lblSurfaceZoomInOut, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
+                            .addComponent(pnlselectedBackgroundColor, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                            .addComponent(lblSagittal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                            .addComponent(lblCoronal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                            .addComponent(lblAxial))))
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+                .addComponent(pnlSurfaceViewer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                .addContainerGap())
+        );
+
+        pack();
+    }// </editor-fold>//GEN-END:initComponents
+
+    private void lblRotateSurfaceMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblRotateSurfaceMouseEntered
+        // Code for Display the Purpose of Rotate Icon
+        lblDisplayPurpose.setText("Rotate the Surface Volume");
+    }//GEN-LAST:event_lblRotateSurfaceMouseEntered
+
+    private void lblRotateSurfaceMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblRotateSurfaceMouseExited
+        // Code for Remove the Purpose from label
+        lblDisplayPurpose.setText(DisplayString);
+    }//GEN-LAST:event_lblRotateSurfaceMouseExited
+
+    private void lblSurfaceMoveMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblSurfaceMoveMouseEntered
+        // Code for Display the Purpose of Move Icon
+        lblDisplayPurpose.setText("Move the Surface Volume");
+    }//GEN-LAST:event_lblSurfaceMoveMouseEntered
+
+    private void lblSurfaceMoveMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblSurfaceMoveMouseExited
+        // Code for Remove the Purpose from label
+        lblDisplayPurpose.setText(DisplayString);
+    }//GEN-LAST:event_lblSurfaceMoveMouseExited
+
+    private void lblSurfaceCubeBoxMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblSurfaceCubeBoxMouseEntered
+        // Code for Display the Purpose of add Cube Box Icon
+        lblDisplayPurpose.setText("Reset the Mouse Operations");
+    }//GEN-LAST:event_lblSurfaceCubeBoxMouseEntered
+
+    private void lblSurfaceCubeBoxMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblSurfaceCubeBoxMouseExited
+        // Code for Remove the Purpose from label
+        lblDisplayPurpose.setText(DisplayString);
+    }//GEN-LAST:event_lblSurfaceCubeBoxMouseExited
+
+    private void lblSurfaceSettingsMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblSurfaceSettingsMouseEntered
+        // Code for Display the Purpose of SurfaceRenderingSettings Icon
+        lblDisplayPurpose.setText("Settings for Surface Rendering");
+    }//GEN-LAST:event_lblSurfaceSettingsMouseEntered
+
+    private void lblSurfaceSettingsMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblSurfaceSettingsMouseExited
+        // Code for Remove the Purpose from label
+        lblDisplayPurpose.setText(DisplayString);
+    }//GEN-LAST:event_lblSurfaceSettingsMouseExited
+
+    private void lblAxialMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblAxialMouseEntered
+        // Code For Display the purpose of Axial View Icon
+        lblDisplayPurpose.setText("Display the Surface Volume in Axial View");
+    }//GEN-LAST:event_lblAxialMouseEntered
+
+    private void lblAxialMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblAxialMouseExited
+        // Code for Remove the Purpose from label
+        lblDisplayPurpose.setText(DisplayString);
+    }//GEN-LAST:event_lblAxialMouseExited
+
+    private void lblCoronalMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblCoronalMouseEntered
+        // Code For Display the purpose of Coronal View Icon
+        lblDisplayPurpose.setText("Display the Surface Volume in Coronal View");
+    }//GEN-LAST:event_lblCoronalMouseEntered
+
+    private void lblCoronalMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblCoronalMouseExited
+        // Code for Remove the Purpose from label
+        lblDisplayPurpose.setText(DisplayString);
+    }//GEN-LAST:event_lblCoronalMouseExited
+
+    private void lblSagittalMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblSagittalMouseEntered
+        // Code For Display the purpose of Sagittal View Icon
+        lblDisplayPurpose.setText("Display the Surface Volume in Sagittal View");
+    }//GEN-LAST:event_lblSagittalMouseEntered
+
+    private void lblSagittalMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblSagittalMouseExited
+        // Code for Remove the Purpose from label
+        lblDisplayPurpose.setText(DisplayString);
+    }//GEN-LAST:event_lblSagittalMouseExited
+
+    private void lblCoronalMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblCoronalMouseClicked
+        // Code for display the Surface Volume in Coronal View by rotate the original volume...
+        AlignCamera(1);
+    }//GEN-LAST:event_lblCoronalMouseClicked
+
+    private void lblSurfaceCubeBoxMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblSurfaceCubeBoxMouseClicked
+        // Set the Default Interactor..
+        vpanSurface.removeMouseListener(myMouseListener);
+        vpanSurface.removeMouseMotionListener(myMouseMotionListener);
+        mode = 0;
+        vpanSurface.addMouseListener(vpanSurface);
+        vpanSurface.addMouseMotionListener(vpanSurface);
+    }//GEN-LAST:event_lblSurfaceCubeBoxMouseClicked
+
+    private void lblSurfaceSettingsMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblSurfaceSettingsMouseClicked
+        // Code for Display the Surface Rendering settings...
+        dlgSurfaceSettings.setSize(390, 494);
+        dlgSurfaceSettings.setVisible(true);
+
+    }//GEN-LAST:event_lblSurfaceSettingsMouseClicked
+
+    private void cbxPredefinedValues1ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbxPredefinedValues1ItemStateChanged
+        // Code for Set the predefined values...
+        if (cbxPredefinedValues1.getSelectedItem().equals("Skin")) {
+            tfPixelValues1.setText("-500");
+            lblPixelValues1.setEnabled(false);
+            tfPixelValues1.setEnabled(false);
+        } else if (cbxPredefinedValues1.getSelectedItem().equals("Bone")) {
+            tfPixelValues1.setText("500");
+            lblPixelValues1.setEnabled(false);
+            tfPixelValues1.setEnabled(false);
+        } else if (cbxPredefinedValues1.getSelectedItem().equals("Metal")) {
+            tfPixelValues1.setText("2000");
+            lblPixelValues1.setEnabled(false);
+            tfPixelValues1.setEnabled(false);
+        } else if (cbxPredefinedValues1.getSelectedItem().equals("Custom")) {
+            tfPixelValues1.setText("300");
+            lblPixelValues1.setEnabled(true);
+            tfPixelValues1.setEnabled(true);
+        }
+    }//GEN-LAST:event_cbxPredefinedValues1ItemStateChanged
+
+    private void cbxPredefinedValues2ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbxPredefinedValues2ItemStateChanged
+
+        // Code for Set the predefined values...
+
+        if (cbxPredefinedValues2.getSelectedItem().equals("Skin")) {
+            tfPixelValues2.setText("-500");
+            lblPixelValues2.setEnabled(false);
+            tfPixelValues2.setEnabled(false);
+        } else if (cbxPredefinedValues2.getSelectedItem().equals("Bone")) {
+            tfPixelValues2.setText("500");
+            lblPixelValues2.setEnabled(false);
+            tfPixelValues2.setEnabled(false);
+        } else if (cbxPredefinedValues2.getSelectedItem().equals("Metal")) {
+            tfPixelValues2.setText("2000");
+            lblPixelValues2.setEnabled(false);
+            tfPixelValues2.setEnabled(false);
+        } else if (cbxPredefinedValues2.getSelectedItem().equals("Custom")) {
+            tfPixelValues2.setText("300");
+            lblPixelValues2.setEnabled(true);
+            tfPixelValues2.setEnabled(true);
+        }
+    }//GEN-LAST:event_cbxPredefinedValues2ItemStateChanged
+
+    private void pnlSelectedColor1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pnlSelectedColor1MouseClicked
+        // Code for display the Color Pallette
+        pnlSelectedColor1.setBackground(JColorChooser.showDialog(dlgSurfaceSettings, "Select Color", pnlSelectedColor1.getBackground()));
+    }//GEN-LAST:event_pnlSelectedColor1MouseClicked
+
+    private void pnlSelectedColor2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pnlSelectedColor2MouseClicked
+        // Code for display the Color Pallette
+        pnlSelectedColor2.setBackground(JColorChooser.showDialog(dlgSurfaceSettings, "Select Color", pnlSelectedColor2.getBackground()));
+    }//GEN-LAST:event_pnlSelectedColor2MouseClicked
+
+    private void btnSurfaceSettingsOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSurfaceSettingsOkActionPerformed
+        // Code for Display the Surface(s) with given parameters...
+
+        if (chbxFirstSurface.isSelected() && chbxSecondSurface.isSelected()) {
+            dlgSurfaceSettings.setVisible(false);
+            vpanSurface.GetRenderer().RemoveAllViewProps();
+            int pixelValue1 = Integer.parseInt(tfPixelValues1.getText());
+            double opacity1 = Double.valueOf(sdrTransparency1.getValue()) / 100.0;
+            double colorRed1 = Double.valueOf(pnlSelectedColor1.getBackground().getRed()) / 255.0;
+            double colorGreen1 = Double.valueOf(pnlSelectedColor1.getBackground().getGreen()) / 255.0;
+            double colorBlue1 = Double.valueOf(pnlSelectedColor1.getBackground().getBlue()) / 255.0;
+            int pixelValue2 = Integer.parseInt(tfPixelValues2.getText());
+            double opacity2 = Double.valueOf(sdrTransparency2.getValue()) / 100.0;
+            double colorRed2 = Double.valueOf(pnlSelectedColor2.getBackground().getRed()) / 255.0;
+            double colorGreen2 = Double.valueOf(pnlSelectedColor2.getBackground().getGreen()) / 255.0;
+            double colorBlue2 = Double.valueOf(pnlSelectedColor2.getBackground().getBlue()) / 255.0;
+            DisplaySurfaces(pixelValue1, opacity1, colorRed1, colorGreen1, colorBlue1, pixelValue2, opacity2, colorRed2, colorGreen2, colorBlue2);
+
+        } else if (chbxFirstSurface.isSelected()) {
+            dlgSurfaceSettings.setVisible(false);
+            vpanSurface.GetRenderer().RemoveAllViewProps();
+            int pixelValue1 = Integer.parseInt(tfPixelValues1.getText());
+            double opacity1 = Double.valueOf(sdrTransparency1.getValue()) / 100.0;
+            double colorRed1 = Double.valueOf(pnlSelectedColor1.getBackground().getRed()) / 255.0;
+            double colorGreen1 = Double.valueOf(pnlSelectedColor1.getBackground().getGreen()) / 255.0;
+            double colorBlue1 = Double.valueOf(pnlSelectedColor1.getBackground().getBlue()) / 255.0;
+            DisplaySurfaces(pixelValue1, opacity1, colorRed1, colorGreen1, colorBlue1);
+
+        } else if (chbxSecondSurface.isSelected()) {
+            dlgSurfaceSettings.setVisible(false);
+            vpanSurface.GetRenderer().RemoveAllViewProps();
+            int pixelValue2 = Integer.parseInt(tfPixelValues2.getText());
+            double opacity2 = Double.valueOf(sdrTransparency2.getValue()) / 100.0;
+            double colorRed2 = Double.valueOf(pnlSelectedColor2.getBackground().getRed()) / 255.0;
+            double colorGreen2 = Double.valueOf(pnlSelectedColor2.getBackground().getGreen()) / 255.0;
+            double colorBlue2 = Double.valueOf(pnlSelectedColor2.getBackground().getBlue()) / 255.0;
+            DisplaySurfaces(pixelValue2, opacity2, colorRed2, colorGreen2, colorBlue2);
+        }
+
+        vpanSurface.repaint();
+        reader.Delete();
+        this.setCursor(DEFAULT_CURSOR);
+    }//GEN-LAST:event_btnSurfaceSettingsOkActionPerformed
+
+    private void btnSurfaceSettingsCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSurfaceSettingsCancelActionPerformed
+        // Code for cancel the Surface Settings...
+        dlgSurfaceSettings.setVisible(false);
+        if (vpanSurface.GetRenderer().VisibleActorCount() == 0) {
+            if (JOptionPane.showConfirmDialog(this, "Do you want to close the application?", "Dicom Surface Viewer", 0) == 0) {
+                this.dispose();
+            } else {
+                dlgSurfaceSettings.setVisible(true);
+            }
+        }
+    }//GEN-LAST:event_btnSurfaceSettingsCancelActionPerformed
+
+    private void lblAxialMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblAxialMouseClicked
+        // TODO add your handling code here:
+        AlignCamera(2);
+    }//GEN-LAST:event_lblAxialMouseClicked
+
+    private void lblSagittalMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblSagittalMouseClicked
+        // TODO add your handling code here:        
+        AlignCamera(0);
+    }//GEN-LAST:event_lblSagittalMouseClicked
+
+    private void lblRotateSurfaceMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblRotateSurfaceMouseClicked
+        //  Set the interaction for Rotate...
+        vpanSurface.removeMouseListener(vpanSurface);
+        vpanSurface.removeMouseMotionListener(vpanSurface);
+
+        mode = 2;
+        vpanSurface.addMouseListener(myMouseListener);
+        vpanSurface.addMouseMotionListener(myMouseMotionListener);
+    }//GEN-LAST:event_lblRotateSurfaceMouseClicked
+
+    private void lblSurfaceMoveMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblSurfaceMoveMouseClicked
+        // Set the interaction for Move...
+        vpanSurface.removeMouseListener(vpanSurface);
+        vpanSurface.removeMouseMotionListener(vpanSurface);
+        mode = 3;
+        vpanSurface.addMouseListener(myMouseListener);
+        vpanSurface.addMouseMotionListener(myMouseMotionListener);
+    }//GEN-LAST:event_lblSurfaceMoveMouseClicked
+
+    private void lblCaptureScreenShotMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblCaptureScreenShotMouseClicked
+        // Code for capture the view as an Image...
+
+        // ask for the filename...
+        JFileChooser fc = new JFileChooser();
+        FileFilter filter = new FileFilter() {
+
+            @Override
+            public boolean accept(File file) {
+                if (file.isDirectory()) {
+                    return true;
+                }
+                String extension = null;
+                String s = file.getName();
+                int i = s.lastIndexOf('.');
+                if (i > 0 && i < s.length() - 1) {
+                    extension = s.substring(i + 1).toLowerCase();
+                }
+                if (extension != null) {
+                    if (extension.equals("tiff") || extension.equals("tif")) {
+                        return true;
+                    } else {
+                        return false;
+                    }
+                } else {
+                    return false;
+                }
+            }
+
+            @Override
+            public String getDescription() {
+                return "tiff/tif Images";
+            }
+        };
+
+        fc.setFileFilter(filter);
+        fc.setAcceptAllFileFilterUsed(false);
+        int returnVal = fc.showSaveDialog(this);
+        if (returnVal == JFileChooser.APPROVE_OPTION) {
+            File file = fc.getSelectedFile();
+            // Capture and Save the image...
+
+            String extension = null;
+            String s = file.getName();
+            int i = s.lastIndexOf('.');
+            if (i > 0 && i < s.length() - 1) {
+                extension = s.substring(i + 1).toLowerCase();
+                if (extension.equals("tif") || extension.equals("tiff")) {
+                    vpanSurface.HardCopy(file.getAbsolutePath(), 1);
+                } else {
+                    vpanSurface.HardCopy(file.getAbsolutePath().concat(".tif"), 1);
+                }
+            } else {
+                vpanSurface.HardCopy(file.getAbsolutePath().concat(".tif"), 1);
+            }
+        }
+        //Reset the file chooser for the next time it's shown.
+
+        fc.setSelectedFile(null);
+    }//GEN-LAST:event_lblCaptureScreenShotMouseClicked
+
+    private void lblCaptureScreenShotMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblCaptureScreenShotMouseEntered
+        // Code for capture the view as an Image...
+        lblDisplayPurpose.setText("Capture the view as an Image");
+    }//GEN-LAST:event_lblCaptureScreenShotMouseEntered
+
+    private void lblCaptureScreenShotMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblCaptureScreenShotMouseExited
+        // Code for Remove the Purpose from label
+        lblDisplayPurpose.setText(DisplayString);
+    }//GEN-LAST:event_lblCaptureScreenShotMouseExited
+
+    private void pnlselectedBackgroundColorMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pnlselectedBackgroundColorMouseClicked
+        // Code for display the Color Pallette
+        pnlselectedBackgroundColor.setBackground(JColorChooser.showDialog(dlgSurfaceSettings, "Select Color", pnlselectedBackgroundColor.getBackground()));
+        vpanSurface.GetRenderer().SetBackground(Double.valueOf(pnlselectedBackgroundColor.getBackground().getRed()) / 255.0, Double.valueOf(pnlselectedBackgroundColor.getBackground().getGreen()) / 255.0, Double.valueOf(pnlselectedBackgroundColor.getBackground().getBlue()) / 255.0);
+        vpanSurface.repaint();
+
+
+    }//GEN-LAST:event_pnlselectedBackgroundColorMouseClicked
+
+    private void pnlselectedBackgroundColorMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pnlselectedBackgroundColorMouseEntered
+        // TODO add your handling code here:
+        lblDisplayPurpose.setText("Change Background Color");
+    }//GEN-LAST:event_pnlselectedBackgroundColorMouseEntered
+
+    private void pnlselectedBackgroundColorMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pnlselectedBackgroundColorMouseExited
+        // Code for Remove the Purpose from label
+        lblDisplayPurpose.setText(DisplayString);
+
+    }//GEN-LAST:event_pnlselectedBackgroundColorMouseExited
+
+    private void lblSurfaceZoomInOutMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblSurfaceZoomInOutMouseClicked
+        // Set the interaction for Zoom In and Zoom Out...
+
+        vpanSurface.removeMouseListener(vpanSurface);
+        vpanSurface.removeMouseMotionListener(vpanSurface);
+        mode = 1;
+        vpanSurface.addMouseListener(myMouseListener);
+        vpanSurface.addMouseMotionListener(myMouseMotionListener);
+
+    }//GEN-LAST:event_lblSurfaceZoomInOutMouseClicked
+
+    private void lblSurfaceZoomInOutMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblSurfaceZoomInOutMouseEntered
+        // Code for Display the Purpose of Zoom In/Out Icon
+        lblDisplayPurpose.setText("Zoom In or Zoom Out the Surface Volume");
+    }//GEN-LAST:event_lblSurfaceZoomInOutMouseEntered
+
+    private void lblSurfaceZoomInOutMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblSurfaceZoomInOutMouseExited
+        // Code for Remove the Purpose from label
+        lblDisplayPurpose.setText(DisplayString);
+    }//GEN-LAST:event_lblSurfaceZoomInOutMouseExited
+
+    private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
+        // vtkGlobalJavaHash.DeleteAll();
+    }//GEN-LAST:event_formWindowClosed
+
+    private void setDefaultSettings() {
+        chbxFirstSurface.setSelected(true);
+        cbxPredefinedValues1.setSelectedItem("Bone");
+        tfPixelValues1.setText("500");
+        tfPixelValues1.setEnabled(false);
+        lblPixelValues1.setEnabled(true);
+
+        chbxSecondSurface.setSelected(false);
+        cbxPredefinedValues2.setSelectedItem("Skin");
+        tfPixelValues2.setText("-500");
+        tfPixelValues2.setEnabled(false);
+        lblPixelValues2.setEnabled(true);
+    }
+
+    public static void main(String args[]) {
+        java.awt.EventQueue.invokeLater(new Runnable() {
+
+            public void run() {
+                new SurfaceRendering().setVisible(true);
+            }
+        });
+    }
+
+    public void readDicomDir(String path) {
+        directoryName = path;
+        setDefaultSettings();
+        lblSurfaceSettingsMouseClicked(null);
+    }
+
+    private void DisplaySurfaces(int val, double opacityValue, double redValue, double greenValue, double blueValue) {
+        // For Single Surface...
+
+        reader = new vtkDICOMImageReader();
+        if (new File(directoryName).isDirectory()) {
+            reader.SetDirectoryName(directoryName);
+        }
+        reader.Update();
+        reader.GetOutput().ReleaseDataFlagOn();
+
+        int[] xyminmax = reader.GetOutput().GetWholeExtent();
+        xMin = xyminmax[0];
+        xMax = xyminmax[1];
+        yMin = xyminmax[2];
+        yMax = xyminmax[3];
+        zMin = xyminmax[4];
+        zMax = xyminmax[5];
+
+        double[] spacing = reader.GetOutput().GetSpacing();
+        sx = spacing[0];
+        sy = spacing[1];
+        sz = spacing[2];
+
+        double[] origin = reader.GetOutput().GetOrigin();
+        ox = origin[0];
+        oy = origin[1];
+        oz = origin[2];
+
+        vtkOutlineFilter outline = new vtkOutlineFilter();
+        outline.SetInput(reader.GetOutput());
+
+        vtkPolyDataMapper outlineMapper = new vtkPolyDataMapper();
+        outlineMapper.SetInput(outline.GetOutput());
+
+        vtkActor outlineActor = new vtkActor();
+        outlineActor.SetMapper(outlineMapper);
+
+
+        vtkCellPicker picker = new vtkCellPicker();
+        picker.SetTolerance(0.005);
+
+        mCube = new vtkMarchingCubes();
+        mCube.SetInput(reader.GetOutput());
+        mCube.SetValue(0, val);
+        mCube.ComputeNormalsOn();
+        mCube.ComputeGradientsOff();
+        mCube.UpdateWholeExtent();
+
+        vtkPolyDataMapper pdMapper = new vtkPolyDataMapper();
+        pdMapper.SetInput(mCube.GetOutput());
+        pdMapper.ImmediateModeRenderingOn();
+        pdMapper.ScalarVisibilityOff();
+
+        // Create and Add Surface Actor...
+
+        vtkActor actor = new vtkActor();
+        actor.GetProperty().SetOpacity(opacityValue);
+        actor.GetProperty().SetColor(redValue, greenValue, blueValue);
+        actor.SetMapper(pdMapper);
+
+
+        vpanSurface.GetRenderer().AddActor(actor);
+        vpanSurface.GetRenderWindow().AddRenderer(vpanSurface.GetRenderer());
+
+        // Add the outline actor to the renderer, set the background color and size
+        vpanSurface.GetRenderer().AddActor(outlineActor);
+
+        vpanSurface.GetRenderer().SetBackground(Double.valueOf(pnlselectedBackgroundColor.getBackground().getRed()) / 255.0, Double.valueOf(pnlselectedBackgroundColor.getBackground().getGreen()) / 255.0, Double.valueOf(pnlselectedBackgroundColor.getBackground().getBlue()) / 255.0);
+        vpanSurface.GetRenderer().ResetCamera();
+        pnlSurfaceViewer.add(vpanSurface);
+        pnlSurfaceViewer.setVisible(true);
+
+        DisplayString = reader.GetPatientName();
+    }
+
+    private void DisplaySurfaces(int val1, double opacityValue1, double redValue1, double greenValue1, double blueValue1, int val2, double opacityValue2, double redValue2, double greenValue2, double blueValue2) {
+        // for 2 surfaces...
+        reader = new vtkDICOMImageReader();
+        if (new File(directoryName).isDirectory()) {
+            reader.SetDirectoryName(directoryName);
+        }
+        reader.Update();
+        reader.GetOutput().ReleaseDataFlagOn();
+
+        int[] xyminmax = reader.GetOutput().GetWholeExtent();
+        xMin = xyminmax[0];
+        xMax = xyminmax[1];
+        yMin = xyminmax[2];
+        yMax = xyminmax[3];
+        zMin = xyminmax[4];
+        zMax = xyminmax[5];
+
+        double[] spacing = reader.GetOutput().GetSpacing();
+        sx = spacing[0];
+        sy = spacing[1];
+        sz = spacing[2];
+
+        double[] origin = reader.GetOutput().GetOrigin();
+        ox = origin[0];
+        oy = origin[1];
+        oz = origin[2];
+
+        vtkOutlineFilter outline = new vtkOutlineFilter();
+        outline.SetInput(reader.GetOutput());
+
+        vtkPolyDataMapper outlineMapper = new vtkPolyDataMapper();
+        outlineMapper.SetInput(outline.GetOutput());
+        outlineMapper.ImmediateModeRenderingOn();
+
+        vtkActor outlineActor = new vtkActor();
+        outlineActor.SetMapper(outlineMapper);
+
+        vtkCellPicker picker = new vtkCellPicker();
+        picker.SetTolerance(0.005);
+
+        vtkMarchingCubes mCube1 = new vtkMarchingCubes();
+        mCube1.SetInput(reader.GetOutput());
+        mCube1.SetValue(0, val1);
+        mCube1.ComputeNormalsOn();
+        mCube1.ComputeGradientsOff();
+        mCube1.UpdateWholeExtent();
+
+        vtkPolyDataMapper pdMapper1 = new vtkPolyDataMapper();
+        pdMapper1.SetInput(mCube1.GetOutput());
+        pdMapper1.ImmediateModeRenderingOn();
+        pdMapper1.ScalarVisibilityOff();
+
+        // Create and Add Surface Actor...
+        vtkActor actor1 = new vtkActor();
+        actor1.GetProperty().SetOpacity(opacityValue1);
+        actor1.GetProperty().SetColor(redValue1, greenValue1, blueValue1);
+        actor1.SetMapper(pdMapper1);
+//        actor1.SetNumberOfCloudPoints(10000);
+
+        vtkMarchingCubes mCube2 = new vtkMarchingCubes();
+        mCube2.SetInput(reader.GetOutput());
+        mCube2.SetValue(0, val2);
+        mCube2.ComputeNormalsOn();
+        mCube2.ComputeGradientsOff();
+        mCube2.UpdateWholeExtent();
+
+        vtkPolyDataMapper pdMapper2 = new vtkPolyDataMapper();
+        pdMapper2.SetInput(mCube2.GetOutput());
+        pdMapper2.ImmediateModeRenderingOn();
+        pdMapper2.ScalarVisibilityOff();
+
+        // Create and Add Surface Actor...
+        vtkActor actor2 = new vtkActor();
+        actor2.GetProperty().SetOpacity(opacityValue2);
+        actor2.GetProperty().SetColor(redValue2, greenValue2, blueValue2);
+        actor2.SetMapper(pdMapper2);
+        //      actor2.SetNumberOfCloudPoints(10000);
+
+        vpanSurface.GetRenderer().AddActor(actor1);
+        vpanSurface.GetRenderer().AddActor(actor2);
+        vpanSurface.GetRenderWindow().AddRenderer(vpanSurface.GetRenderer());
+
+        // Add the outline actor to the renderer, set the background color and size
+        vpanSurface.GetRenderer().AddActor(outlineActor);
+
+        vpanSurface.GetRenderer().SetBackground(Double.valueOf(pnlselectedBackgroundColor.getBackground().getRed()) / 255.0, Double.valueOf(pnlselectedBackgroundColor.getBackground().getGreen()) / 255.0, Double.valueOf(pnlselectedBackgroundColor.getBackground().getBlue()) / 255.0);
+        vpanSurface.GetRenderer().ResetCamera();
+        pnlSurfaceViewer.add(vpanSurface);
+        pnlSurfaceViewer.setVisible(true);
+
+        DisplayString = reader.GetPatientName();
+    }
+
+    void AlignCamera(int iaxis) {
+        //global ox oy oz sx sy sz xMax xMin yMax yMin zMax zMin slice_number
+        //global current_widget
+        double cx = (ox + (0.5 * (xMax - xMin)) * sx);
+        double cy = (oy + (0.5 * (yMax - yMin)) * sy);
+        double cz = (oy + (0.5 * (zMax - zMin)) * sz);
+        double vx = 0;
+        double vy = 0;
+        double vz = 0;
+        double nx = 0;
+        double ny = 0;
+        double nz = 0;
+        if (iaxis == 0) {
+            vz = -1;
+            nx = (ox + xMax * sx);
+            cx = (ox + sx);
+        } else if (iaxis == 1) {
+            vz = -1;
+            ny = (oy + yMax * sy);
+            cy = (oy + sy);
+        } else {
+            vy = 1;
+            nz = (oz + zMax * sz);
+            cz = (oz + sz);
+        }
+        double px = (cx + nx * 2);
+        double py = (cy + ny * 2);
+        double pz = (cz + nz * 3);
+
+        camera = vpanSurface.GetRenderer().GetActiveCamera();
+        camera.SetViewUp(vx, vy, vz);
+        camera.SetFocalPoint(cx, cy, cz);
+        camera.SetPosition(px, py, pz);
+        camera.OrthogonalizeViewUp();
+
+        // Reset the light...
+        vtkLightCollection Lights = vpanSurface.GetRenderer().GetLights();
+        int nLights = Lights.GetNumberOfItems();
+        vtkLight light;
+        double[] pos = camera.GetPosition();
+        double[] fp = camera.GetFocalPoint();
+        Lights.InitTraversal();
+        for (int i = 0; i < nLights; i++) {
+            light = Lights.GetNextItem();
+            light.SetPosition(pos);
+            light.SetFocalPoint(fp);
+            light.Modified();
+        }
+
+        vpanSurface.GetRenderer().ResetCameraClippingRange();
+        vpanSurface.GetRenderer().ResetCamera();
+        vpanSurface.GetRenderer().WorldToView();
+        vpanSurface.repaint();
+    }
+    MouseListener myMouseListener = new MouseListener() {
+
+        public void mouseClicked(MouseEvent me) {
+        }
+
+        public void mousePressed(MouseEvent me) {
+            lastX = me.getX();
+            lastY = me.getY();
+        }
+
+        public void mouseReleased(MouseEvent me) {
+        }
+
+        public void mouseEntered(MouseEvent me) {
+        }
+
+        public void mouseExited(MouseEvent me) {
+        }
+    };
+    MouseMotionListener myMouseMotionListener = new MouseMotionListener() {
+
+        public void mouseDragged(MouseEvent me) {
+
+            vpanSurface.lock();
+            if (doDragFlag > 0) {
+                doDragFlag--;
+            } else {
+                int x = me.getX();
+                int y = me.getY();
+                vtkCamera cam = vpanSurface.GetRenderer().GetActiveCamera();
+
+                if (mode == 1) {            // Zoom In/Out Surface...
+                    if (vpanSurface.GetRenderer().VisibleActorCount() == 0) {
+                        return;
+                    }
+                    double zoomFactor;
+                    zoomFactor = Math.pow(1.02, (y - lastY));
+                    if (cam.GetParallelProjection() == 1) {
+                        cam.SetParallelScale(cam.GetParallelScale() / zoomFactor);
+                    } else {
+                        cam.Dolly(zoomFactor);
+                        vpanSurface.resetCameraClippingRange();
+                    }
+                } else if (mode == 2) {     // Rotate Surface...
+
+                    if (vpanSurface.GetRenderer().VisibleActorCount() == 0) {
+                        return;
+                    }
+                    if (x > vpanSurface.getWidth() / 2.0) {
+                        cam.Roll(-(y - lastY));
+                    } else {
+                        cam.Roll((y - lastY));
+                    }
+                    if (y < vpanSurface.getHeight() / 2.0) {
+                        cam.Roll(-(x - lastX));
+                    } else {
+                        cam.Roll((x - lastX));
+                    }
+                    vpanSurface.resetCameraClippingRange();
+                } else if (mode == 3) {     // Move Surface...
+                    if (vpanSurface.GetRenderer().VisibleActorCount() == 0) {
+                        return;
+                    }
+                    double FPoint[];
+                    double PPoint[];
+                    double APoint[] = new double[3];
+                    double RPoint[];
+                    double focalDepth;
+
+                    // get the current focal point and position
+                    FPoint = cam.GetFocalPoint();
+                    PPoint = cam.GetPosition();
+
+                    // calculate the focal depth since we'll be using it a lot
+                    vpanSurface.GetRenderer().SetWorldPoint(FPoint[0], FPoint[1], FPoint[2], 1.0);
+                    vpanSurface.GetRenderer().WorldToDisplay();
+                    focalDepth = vpanSurface.GetRenderer().GetDisplayPoint()[2];
+
+                    APoint[0] = vpanSurface.GetRenderWindow().GetSize()[0] / 2.0 + (x - lastX);
+                    APoint[1] = vpanSurface.GetRenderWindow().GetSize()[1] / 2.0 - (y - lastY);
+                    APoint[2] = focalDepth;
+                    vpanSurface.GetRenderer().SetDisplayPoint(APoint);
+                    vpanSurface.GetRenderer().DisplayToWorld();
+                    RPoint = vpanSurface.GetRenderer().GetWorldPoint();
+                    if (RPoint[3] != 0.0) {
+                        RPoint[0] = RPoint[0] / RPoint[3];
+                        RPoint[1] = RPoint[1] / RPoint[3];
+                        RPoint[2] = RPoint[2] / RPoint[3];
+                    }
+                    /*
+                     * Compute a translation vector, moving everything 1/2
+                     * the distance to the cursor. (Arbitrary scale factor)
+                     */
+                    cam.SetFocalPoint(
+                            (FPoint[0] - RPoint[0]) / 2.0 + FPoint[0],
+                            (FPoint[1] - RPoint[1]) / 2.0 + FPoint[1],
+                            (FPoint[2] - RPoint[2]) / 2.0 + FPoint[2]);
+                    cam.SetPosition(
+                            (FPoint[0] - RPoint[0]) / 2.0 + PPoint[0],
+                            (FPoint[1] - RPoint[1]) / 2.0 + PPoint[1],
+                            (FPoint[2] - RPoint[2]) / 2.0 + PPoint[2]);
+                    vpanSurface.resetCameraClippingRange();
+                }
+                lastX = x;
+                lastY = y;
+
+                vpanSurface.Render();
+                doDragFlag = 1;
+            }
+            vpanSurface.unlock();
+        }
+
+        public void mouseMoved(MouseEvent me) {
+            lastX = me.getX();
+            lastY = me.getY();
+        }
+    };
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JButton btnSurfaceSettingsCancel;
+    private javax.swing.JButton btnSurfaceSettingsOk;
+    private javax.swing.JComboBox cbxPredefinedValues1;
+    private javax.swing.JComboBox cbxPredefinedValues2;
+    private javax.swing.JCheckBox chbxFirstSurface;
+    private javax.swing.JCheckBox chbxSecondSurface;
+    private javax.swing.JDialog dlgSurfaceSettings;
+    private javax.swing.JLabel lblAxial;
+    private javax.swing.JLabel lblCaptureScreenShot;
+    private javax.swing.JLabel lblColor1;
+    private javax.swing.JLabel lblColor2;
+    private javax.swing.JLabel lblCoronal;
+    private javax.swing.JLabel lblDisplayPurpose;
+    private javax.swing.JLabel lblPixelValues1;
+    private javax.swing.JLabel lblPixelValues2;
+    private javax.swing.JLabel lblPredefinedValues1;
+    private javax.swing.JLabel lblPredefinedValues2;
+    private javax.swing.JLabel lblRotateSurface;
+    private javax.swing.JLabel lblSagittal;
+    private javax.swing.JLabel lblSurfaceCubeBox;
+    private javax.swing.JLabel lblSurfaceMove;
+    private javax.swing.JLabel lblSurfaceSettings;
+    private javax.swing.JLabel lblSurfaceZoomInOut;
+    private javax.swing.JLabel lblTransparency1;
+    private javax.swing.JLabel lblTransparency2;
+    private javax.swing.JPanel pnlSelectedColor1;
+    private javax.swing.JPanel pnlSelectedColor2;
+    private javax.swing.JPanel pnlSurface1;
+    private javax.swing.JPanel pnlSurface2;
+    private javax.swing.JPanel pnlSurfaceViewer;
+    private javax.swing.JPanel pnlselectedBackgroundColor;
+    private javax.swing.JSlider sdrTransparency1;
+    private javax.swing.JSlider sdrTransparency2;
+    private javax.swing.JTextField tfPixelValues1;
+    private javax.swing.JTextField tfPixelValues2;
+    // End of variables declaration//GEN-END:variables
+}
diff --git a/src/in/raster/mayam/form/dialog/AEManagementDialog.form b/src/in/raster/mayam/form/dialog/AEManagementDialog.form
new file mode 100644
index 0000000..6b03892
--- /dev/null
+++ b/src/in/raster/mayam/form/dialog/AEManagementDialog.form
@@ -0,0 +1,188 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <Events>
+    <EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="closeDialog"/>
+  </Events>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" attributes="0">
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Group type="102" alignment="0" attributes="0">
+                      <EmptySpace min="-2" pref="104" max="-2" attributes="0"/>
+                      <Component id="verifyButton" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="okButton" linkSize="1" min="-2" pref="67" max="-2" attributes="0"/>
+                      <EmptySpace type="unrelated" max="-2" attributes="0"/>
+                      <Component id="cancelButton" linkSize="1" min="-2" max="-2" attributes="0"/>
+                  </Group>
+                  <Group type="102" alignment="0" attributes="0">
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="jPanel1" max="32767" attributes="0"/>
+                  </Group>
+              </Group>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="1" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="jPanel1" min="-2" max="-2" attributes="0"/>
+              <EmptySpace pref="28" max="32767" attributes="0"/>
+              <Group type="103" groupAlignment="3" attributes="0">
+                  <Component id="cancelButton" alignment="3" min="-2" max="-2" attributes="0"/>
+                  <Component id="okButton" alignment="3" min="-2" max="-2" attributes="0"/>
+                  <Component id="verifyButton" alignment="3" min="-2" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Component class="javax.swing.JButton" name="okButton">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="OK"/>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okButtonActionPerformed"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JButton" name="cancelButton">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Cancel"/>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelButtonActionPerformed"/>
+      </Events>
+    </Component>
+    <Container class="javax.swing.JPanel" name="jPanel1">
+      <Properties>
+        <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+          <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
+            <TitledBorder title="AE Management"/>
+          </Border>
+        </Property>
+      </Properties>
+
+      <Layout>
+        <DimensionLayout dim="0">
+          <Group type="103" groupAlignment="0" attributes="0">
+              <Group type="102" alignment="1" attributes="0">
+                  <Group type="103" groupAlignment="0" attributes="0">
+                      <Group type="102" alignment="0" attributes="0">
+                          <EmptySpace min="-2" pref="104" max="-2" attributes="0"/>
+                          <Group type="103" groupAlignment="1" attributes="0">
+                              <Component id="jLabel5" alignment="1" min="-2" max="-2" attributes="0"/>
+                              <Component id="jLabel2" min="-2" max="-2" attributes="0"/>
+                              <Component id="jLabel4" min="-2" max="-2" attributes="0"/>
+                          </Group>
+                      </Group>
+                      <Group type="102" alignment="0" attributes="0">
+                          <EmptySpace min="-2" pref="78" max="-2" attributes="0"/>
+                          <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
+                      </Group>
+                  </Group>
+                  <EmptySpace max="-2" attributes="0"/>
+                  <Group type="103" groupAlignment="1" attributes="0">
+                      <Component id="serverNameText" alignment="0" pref="202" max="32767" attributes="1"/>
+                      <Component id="portText" alignment="0" pref="202" max="32767" attributes="1"/>
+                      <Component id="aeTitleText" alignment="0" pref="202" max="32767" attributes="1"/>
+                      <Component id="hostText" alignment="0" pref="202" max="32767" attributes="1"/>
+                  </Group>
+                  <EmptySpace min="-2" pref="32" max="-2" attributes="0"/>
+              </Group>
+          </Group>
+        </DimensionLayout>
+        <DimensionLayout dim="1">
+          <Group type="103" groupAlignment="0" attributes="0">
+              <Group type="102" alignment="0" attributes="0">
+                  <EmptySpace max="-2" attributes="0"/>
+                  <Group type="103" groupAlignment="3" attributes="0">
+                      <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
+                      <Component id="serverNameText" alignment="3" min="-2" max="-2" attributes="0"/>
+                  </Group>
+                  <Group type="103" groupAlignment="0" attributes="0">
+                      <Group type="102" attributes="0">
+                          <EmptySpace min="-2" pref="26" max="-2" attributes="0"/>
+                          <Component id="jLabel2" min="-2" max="-2" attributes="0"/>
+                      </Group>
+                      <Group type="102" alignment="0" attributes="0">
+                          <EmptySpace type="separate" max="-2" attributes="0"/>
+                          <Component id="hostText" min="-2" max="-2" attributes="0"/>
+                      </Group>
+                  </Group>
+                  <EmptySpace min="-2" pref="28" max="-2" attributes="0"/>
+                  <Group type="103" groupAlignment="0" attributes="0">
+                      <Component id="jLabel4" min="-2" max="-2" attributes="0"/>
+                      <Component id="aeTitleText" min="-2" max="-2" attributes="0"/>
+                  </Group>
+                  <EmptySpace min="-2" pref="26" max="-2" attributes="0"/>
+                  <Group type="103" groupAlignment="3" attributes="0">
+                      <Component id="portText" alignment="3" min="-2" max="-2" attributes="0"/>
+                      <Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/>
+                  </Group>
+                  <EmptySpace max="-2" attributes="0"/>
+              </Group>
+          </Group>
+        </DimensionLayout>
+      </Layout>
+      <SubComponents>
+        <Component class="javax.swing.JLabel" name="jLabel1">
+          <Properties>
+            <Property name="text" type="java.lang.String" value="Server Name"/>
+          </Properties>
+        </Component>
+        <Component class="javax.swing.JLabel" name="jLabel2">
+          <Properties>
+            <Property name="text" type="java.lang.String" value="Host"/>
+          </Properties>
+        </Component>
+        <Component class="javax.swing.JTextField" name="serverNameText">
+        </Component>
+        <Component class="javax.swing.JTextField" name="hostText">
+        </Component>
+        <Component class="javax.swing.JLabel" name="jLabel4">
+          <Properties>
+            <Property name="text" type="java.lang.String" value="AE Title"/>
+          </Properties>
+        </Component>
+        <Component class="javax.swing.JLabel" name="jLabel5">
+          <Properties>
+            <Property name="text" type="java.lang.String" value="Port"/>
+          </Properties>
+        </Component>
+        <Component class="javax.swing.JTextField" name="aeTitleText">
+        </Component>
+        <Component class="javax.swing.JTextField" name="portText">
+        </Component>
+      </SubComponents>
+    </Container>
+    <Component class="javax.swing.JButton" name="verifyButton">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Verify"/>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="verifyButtonActionPerformed"/>
+      </Events>
+    </Component>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/dialog/AEManagementDialog.java b/src/in/raster/mayam/form/dialog/AEManagementDialog.java
new file mode 100644
index 0000000..70940f7
--- /dev/null
+++ b/src/in/raster/mayam/form/dialog/AEManagementDialog.java
@@ -0,0 +1,374 @@
+
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form.dialog;
+
+
+import in.raster.mayam.delegate.EchoService;
+import in.raster.mayam.form.display.Display;
+import org.dcm4che.util.DcmURL;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class AEManagementDialog extends javax.swing.JDialog {
+    /** A return status code - returned if Cancel button has been pressed */
+    public static final int RET_CANCEL = 0;
+    /** A return status code - returned if OK button has been pressed */
+    public static final int RET_OK = 1;
+    
+    public String keyName="";
+    
+    /** Creates new form AEManagementDialog */
+    public AEManagementDialog(java.awt.Frame parent, boolean modal) {
+        super(parent, modal);
+        initComponents();
+    }
+    
+    /** @return the return status of this dialog - one of RET_OK or RET_CANCEL */
+    public int getReturnStatus() {
+        return returnStatus;
+    }
+    /**
+     *
+     * @param serverName-server name of the dicom server
+     * @param host-host name of the dicom server
+     * @param location-location of the dicom server
+     * @param aeTitle-aeTitle of the dicom server
+     * @param port-port of the dicom server
+     * @param headerPort-header port of the dicom server
+     * @param imagePort-image port of the dicom server
+     */
+    public void setFormValues(String serverName,String host,String location,String aeTitle,int port,int headerPort,int imagePort)
+    {      
+        serverNameText.setText(serverName);
+        hostText.setText(host);      
+        aeTitleText.setText(aeTitle);
+        portText.setText(Integer.toString(port));
+    }
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        okButton = new javax.swing.JButton();
+        cancelButton = new javax.swing.JButton();
+        jPanel1 = new javax.swing.JPanel();
+        jLabel1 = new javax.swing.JLabel();
+        jLabel2 = new javax.swing.JLabel();
+        serverNameText = new javax.swing.JTextField();
+        hostText = new javax.swing.JTextField();
+        jLabel4 = new javax.swing.JLabel();
+        jLabel5 = new javax.swing.JLabel();
+        aeTitleText = new javax.swing.JTextField();
+        portText = new javax.swing.JTextField();
+        verifyButton = new javax.swing.JButton();
+
+        addWindowListener(new java.awt.event.WindowAdapter() {
+            public void windowClosing(java.awt.event.WindowEvent evt) {
+                closeDialog(evt);
+            }
+        });
+
+        okButton.setText("OK");
+        okButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                okButtonActionPerformed(evt);
+            }
+        });
+
+        cancelButton.setText("Cancel");
+        cancelButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                cancelButtonActionPerformed(evt);
+            }
+        });
+
+        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("AE Management"));
+
+        jLabel1.setText("Server Name");
+
+        jLabel2.setText("Host");
+
+        jLabel4.setText("AE Title");
+
+        jLabel5.setText("Port");
+
+        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
+        jPanel1.setLayout(jPanel1Layout);
+        jPanel1Layout.setHorizontalGroup(
+            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup()
+                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                    .add(jPanel1Layout.createSequentialGroup()
+                        .add(104, 104, 104)
+                        .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+                            .add(jLabel5)
+                            .add(jLabel2)
+                            .add(jLabel4)))
+                    .add(jPanel1Layout.createSequentialGroup()
+                        .add(78, 78, 78)
+                        .add(jLabel1)))
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+                    .add(org.jdesktop.layout.GroupLayout.LEADING, serverNameText, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 202, Short.MAX_VALUE)
+                    .add(org.jdesktop.layout.GroupLayout.LEADING, portText, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 202, Short.MAX_VALUE)
+                    .add(org.jdesktop.layout.GroupLayout.LEADING, aeTitleText, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 202, Short.MAX_VALUE)
+                    .add(org.jdesktop.layout.GroupLayout.LEADING, hostText, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 202, Short.MAX_VALUE))
+                .add(32, 32, 32))
+        );
+        jPanel1Layout.setVerticalGroup(
+            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(jPanel1Layout.createSequentialGroup()
+                .addContainerGap()
+                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+                    .add(jLabel1)
+                    .add(serverNameText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                    .add(jPanel1Layout.createSequentialGroup()
+                        .add(26, 26, 26)
+                        .add(jLabel2))
+                    .add(jPanel1Layout.createSequentialGroup()
+                        .add(18, 18, 18)
+                        .add(hostText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
+                .add(28, 28, 28)
+                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                    .add(jLabel4)
+                    .add(aeTitleText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+                .add(26, 26, 26)
+                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+                    .add(portText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                    .add(jLabel5))
+                .addContainerGap())
+        );
+
+        verifyButton.setText("Verify");
+        verifyButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                verifyButtonActionPerformed(evt);
+            }
+        });
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+        getContentPane().setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(layout.createSequentialGroup()
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                    .add(layout.createSequentialGroup()
+                        .add(104, 104, 104)
+                        .add(verifyButton)
+                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                        .add(okButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 67, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+                        .add(cancelButton))
+                    .add(layout.createSequentialGroup()
+                        .addContainerGap()
+                        .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
+                .addContainerGap())
+        );
+
+        layout.linkSize(new java.awt.Component[] {cancelButton, okButton}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
+
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+                .addContainerGap()
+                .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 28, Short.MAX_VALUE)
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+                    .add(cancelButton)
+                    .add(okButton)
+                    .add(verifyButton))
+                .addContainerGap())
+        );
+
+        pack();
+    }// </editor-fold>//GEN-END:initComponents
+    /**
+     *
+     * @param evt-action performed event
+     */
+    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
+       /* boolean NoException=true;
+        if(this.getTitle().equalsIgnoreCase("Edit Server"))
+        {
+            try{       
+           int port=(portText.getText().equalsIgnoreCase(""))?0:Integer.parseInt(portText.getText());
+           //temp.doEditServerRecords(serverNameText.getText(), hostText.getText(), aeTitleText.getText(),port,keyName);
+             ApplicationContext.databaseRef.doEditServerRecords(serverNameText.getText(), hostText.getText(), aeTitleText.getText(),port,keyName);
+            }
+            catch(NumberFormatException nm)
+            {
+                NumberFormatValidator valitatorInfoDialog=new NumberFormatValidator(temp, true);
+               Display.alignScreen(valitatorInfoDialog);
+                valitatorInfoDialog.setVisible(true);
+                NoException=false;
+            }
+            }
+        else
+        {
+           try{        
+           int port=(portText.getText().equalsIgnoreCase(""))?0:Integer.parseInt(portText.getText());
+           //temp.doCreateServerRecords(serverNameText.getText(), hostText.getText(), aeTitleText.getText(),port);
+           ApplicationContext.databaseRef.doCreateServerRecords(serverNameText.getText(), hostText.getText(), aeTitleText.getText(),port);
+           }
+            catch(NumberFormatException nm)
+            {
+                NumberFormatValidator valitatorInfoDialog=new NumberFormatValidator(temp, true);
+                Display.alignScreen(valitatorInfoDialog);
+                valitatorInfoDialog.setVisible(true);
+                NoException=false;
+            }
+        }
+         if(NoException)
+         doClose(RET_OK);*/
+    }//GEN-LAST:event_okButtonActionPerformed
+    /**
+     *
+     * @param evt-action performed event
+     */
+    private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
+        doClose(RET_CANCEL);
+    }//GEN-LAST:event_cancelButtonActionPerformed
+    
+    /** Closes the dialog */
+    private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
+        doClose(RET_CANCEL);
+    }//GEN-LAST:event_closeDialog
+    /**
+     * This routine used to check the status of the dicom aetitle
+     * @param evt
+     */
+    private void verifyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_verifyButtonActionPerformed
+        try {
+            String aeTitle = "";
+            String hostName = "";
+            String port = "";
+            if (aeTitleText.getText() != null) {
+                aeTitle = aeTitleText.getText();
+            }
+            if (hostText.getText() != null) {
+                hostName = hostText.getText();
+            }
+            if (portText.getText() != null) {
+                port = portText.getText();
+            }
+
+            if (!aeTitle.equalsIgnoreCase("") & !hostName.equalsIgnoreCase("") & !port.equalsIgnoreCase("")) {
+
+                DcmURL url = new DcmURL("dicom://" + aeTitle + "@" + hostName + ":" + port);
+
+                EchoService echo = new EchoService();
+                EchoStatus echoStatus = new EchoStatus(this, true);
+               Display.alignScreen(echoStatus);
+                echo.checkEcho(url);
+                echoStatus.setTitle("Echo Status");
+                try {
+                    if (echo.getStatus().trim().equalsIgnoreCase("EchoSuccess")) {
+                        echoStatus.status.setText("Echo dicom://" + aeTitle + "@" + hostName + ":" + port + " successfully!");
+                        echoStatus.setVisible(true);
+                    } else {
+                        echoStatus.status.setText("Echo dicom://" + aeTitle + "@" + hostName + ":" + port + " not successfully!");
+                        echoStatus.setVisible(true);
+                    }
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            } else {
+                FieldValidator sd=new FieldValidator(this, true);
+                Display.alignScreen(sd);
+                sd.setVisible(true);
+
+            }
+
+
+
+        } catch (Exception e) {
+            System.out.println("Choosed tree node is not valid for this process");
+        }
+
+}//GEN-LAST:event_verifyButtonActionPerformed
+
+    private void doClose(int retStatus) {
+        returnStatus = retStatus;
+        setVisible(false);
+        dispose();
+    }
+    
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String args[]) {
+        java.awt.EventQueue.invokeLater(new Runnable() {
+            public void run() {
+                AEManagementDialog dialog = new AEManagementDialog(new javax.swing.JFrame(), true);
+                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
+                    public void windowClosing(java.awt.event.WindowEvent e) {
+                        System.exit(0);
+                    }
+                });
+                dialog.setVisible(true);
+            }
+        });
+    }
+    
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JTextField aeTitleText;
+    private javax.swing.JButton cancelButton;
+    private javax.swing.JTextField hostText;
+    private javax.swing.JLabel jLabel1;
+    private javax.swing.JLabel jLabel2;
+    private javax.swing.JLabel jLabel4;
+    private javax.swing.JLabel jLabel5;
+    private javax.swing.JPanel jPanel1;
+    private javax.swing.JButton okButton;
+    private javax.swing.JTextField portText;
+    private javax.swing.JTextField serverNameText;
+    private javax.swing.JButton verifyButton;
+    // End of variables declaration//GEN-END:variables
+    
+    private int returnStatus = RET_CANCEL;
+}
diff --git a/src/in/raster/mayam/form/dialog/About.form b/src/in/raster/mayam/form/dialog/About.form
new file mode 100644
index 0000000..7204554
--- /dev/null
+++ b/src/in/raster/mayam/form/dialog/About.form
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
+  <Properties>
+    <Property name="title" type="java.lang.String" value="About"/>
+    <Property name="modal" type="boolean" value="true"/>
+    <Property name="resizable" type="boolean" value="false"/>
+  </Properties>
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <Events>
+    <EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="closeDialog"/>
+  </Events>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Component id="aboutPanel" alignment="0" max="32767" attributes="0"/>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Component id="aboutPanel" alignment="0" max="32767" attributes="0"/>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Container class="javax.swing.JPanel" name="aboutPanel">
+
+      <Layout>
+        <DimensionLayout dim="0">
+          <Group type="103" groupAlignment="0" attributes="0">
+              <Component id="aboutLabel" alignment="0" max="32767" attributes="0"/>
+          </Group>
+        </DimensionLayout>
+        <DimensionLayout dim="1">
+          <Group type="103" groupAlignment="0" attributes="0">
+              <Component id="aboutLabel" alignment="0" max="32767" attributes="0"/>
+          </Group>
+        </DimensionLayout>
+      </Layout>
+      <SubComponents>
+        <Component class="javax.swing.JLabel" name="aboutLabel">
+          <Properties>
+            <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
+              <Image iconType="3" name="/in/raster/mayam/form/images/mayam.png"/>
+            </Property>
+          </Properties>
+        </Component>
+      </SubComponents>
+    </Container>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/dialog/About.java b/src/in/raster/mayam/form/dialog/About.java
new file mode 100644
index 0000000..09834a5
--- /dev/null
+++ b/src/in/raster/mayam/form/dialog/About.java
@@ -0,0 +1,147 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form.dialog;
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class About extends javax.swing.JDialog {
+    /** A return status code - returned if Cancel button has been pressed */
+    public static final int RET_CANCEL = 0;
+    /** A return status code - returned if OK button has been pressed */
+    public static final int RET_OK = 1;
+
+    /** Creates new form About */
+    public About(java.awt.Frame parent, boolean modal) {
+        super(parent, modal);
+        initComponents();
+    }
+
+    /** @return the return status of this dialog - one of RET_OK or RET_CANCEL */
+    public int getReturnStatus() {
+        return returnStatus;
+    }
+
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    @SuppressWarnings("unchecked")
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        aboutPanel = new javax.swing.JPanel();
+        aboutLabel = new javax.swing.JLabel();
+
+        setTitle("About");
+        setModal(true);
+        setResizable(false);
+        addWindowListener(new java.awt.event.WindowAdapter() {
+            public void windowClosing(java.awt.event.WindowEvent evt) {
+                closeDialog(evt);
+            }
+        });
+
+        aboutLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/in/raster/mayam/form/images/mayam.png"))); // NOI18N
+
+        org.jdesktop.layout.GroupLayout aboutPanelLayout = new org.jdesktop.layout.GroupLayout(aboutPanel);
+        aboutPanel.setLayout(aboutPanelLayout);
+        aboutPanelLayout.setHorizontalGroup(
+            aboutPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(aboutLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+        );
+        aboutPanelLayout.setVerticalGroup(
+            aboutPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(aboutLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+        );
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+        getContentPane().setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(aboutPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(aboutPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+        );
+
+        pack();
+    }// </editor-fold>//GEN-END:initComponents
+
+    /** Closes the dialog */
+    private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
+        doClose(RET_CANCEL);
+    }//GEN-LAST:event_closeDialog
+
+    private void doClose(int retStatus) {
+        returnStatus = retStatus;
+        setVisible(false);
+        dispose();
+    }
+
+    /**
+    * @param args the command line arguments
+    */
+    public static void main(String args[]) {
+        java.awt.EventQueue.invokeLater(new Runnable() {
+            public void run() {
+                About dialog = new About(new javax.swing.JFrame(), true);
+                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
+                    public void windowClosing(java.awt.event.WindowEvent e) {
+                        System.exit(0);
+                    }
+                });
+                dialog.setVisible(true);
+            }
+        });
+    }
+
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JLabel aboutLabel;
+    private javax.swing.JPanel aboutPanel;
+    // End of variables declaration//GEN-END:variables
+
+    private int returnStatus = RET_CANCEL;
+}
+
+
diff --git a/src/in/raster/mayam/form/dialog/ConfirmDelete.form b/src/in/raster/mayam/form/dialog/ConfirmDelete.form
new file mode 100644
index 0000000..1b578a6
--- /dev/null
+++ b/src/in/raster/mayam/form/dialog/ConfirmDelete.form
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
+  <Properties>
+    <Property name="resizable" type="boolean" value="false"/>
+  </Properties>
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <Events>
+    <EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="closeDialog"/>
+  </Events>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Group type="102" alignment="0" attributes="0">
+                      <Component id="status" pref="397" max="32767" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                  </Group>
+                  <Group type="102" alignment="1" attributes="0">
+                      <Component id="okButton" linkSize="1" min="-2" pref="67" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="jButton1" linkSize="1" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace min="-2" pref="133" max="-2" attributes="0"/>
+                  </Group>
+              </Group>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="1" attributes="0">
+              <EmptySpace pref="23" max="32767" attributes="0"/>
+              <Component id="status" min="-2" max="-2" attributes="0"/>
+              <EmptySpace type="separate" max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="3" attributes="0">
+                  <Component id="okButton" alignment="3" min="-2" max="-2" attributes="0"/>
+                  <Component id="jButton1" alignment="3" min="-2" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Component class="javax.swing.JButton" name="okButton">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="OK"/>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okButtonActionPerformed"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JLabel" name="status">
+      <Properties>
+        <Property name="horizontalAlignment" type="int" value="0"/>
+        <Property name="text" type="java.lang.String" value="Are you sure you want to delete the selected study?"/>
+      </Properties>
+      <AuxValues>
+        <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="1"/>
+      </AuxValues>
+    </Component>
+    <Component class="javax.swing.JButton" name="jButton1">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Cancel"/>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
+      </Events>
+    </Component>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/dialog/ConfirmDelete.java b/src/in/raster/mayam/form/dialog/ConfirmDelete.java
new file mode 100644
index 0000000..3ff23d3
--- /dev/null
+++ b/src/in/raster/mayam/form/dialog/ConfirmDelete.java
@@ -0,0 +1,229 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form.dialog;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.form.MainScreen;
+import in.raster.mayam.model.Instance;
+import in.raster.mayam.model.Series;
+import in.raster.mayam.model.Study;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class ConfirmDelete extends javax.swing.JDialog {
+
+    /** A return status code - returned if Cancel button has been pressed */
+    public static final int RET_CANCEL = 0;
+    /** A return status code - returned if OK button has been pressed */
+    public static final int RET_OK = 1;
+
+    /** Creates new form EchoStatus */
+    public ConfirmDelete(java.awt.Frame parent, boolean modal) {
+        super(parent, modal);
+        initComponents();
+    }
+
+    public ConfirmDelete(java.awt.Dialog parent, boolean modal) {
+        super(parent, modal);
+        initComponents();
+    }
+
+    /** @return the return status of this dialog - one of RET_OK or RET_CANCEL */
+    public int getReturnStatus() {
+        return returnStatus;
+    }
+
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        okButton = new javax.swing.JButton();
+        status = new javax.swing.JLabel();
+        jButton1 = new javax.swing.JButton();
+
+        setResizable(false);
+        addWindowListener(new java.awt.event.WindowAdapter() {
+            public void windowClosing(java.awt.event.WindowEvent evt) {
+                closeDialog(evt);
+            }
+        });
+
+        okButton.setText("OK");
+        okButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                okButtonActionPerformed(evt);
+            }
+        });
+
+        status.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+        status.setText("Are you sure you want to delete the selected study?");
+
+        jButton1.setText("Cancel");
+        jButton1.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                jButton1ActionPerformed(evt);
+            }
+        });
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+        getContentPane().setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(layout.createSequentialGroup()
+                .addContainerGap()
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                    .add(layout.createSequentialGroup()
+                        .add(status, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 397, Short.MAX_VALUE)
+                        .addContainerGap())
+                    .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+                        .add(okButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 67, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                        .add(jButton1)
+                        .add(133, 133, 133))))
+        );
+
+        layout.linkSize(new java.awt.Component[] {jButton1, okButton}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
+
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+                .addContainerGap(23, Short.MAX_VALUE)
+                .add(status)
+                .add(18, 18, 18)
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+                    .add(okButton)
+                    .add(jButton1))
+                .addContainerGap())
+        );
+
+        pack();
+    }// </editor-fold>//GEN-END:initComponents
+
+    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
+        if (MainScreen.studyListTable.getSelectedRow() != -1) {
+
+            int index[] = MainScreen.studyListTable.getSelectedRows();
+            for (int j = 0; j < index.length; j++) {
+                index[j] = MainScreen.studyListTable.convertRowIndexToModel(index[j]);
+            }
+            for (int tempI = 0; tempI < index.length; tempI++) {
+                String studyIUID = (String) MainScreen.studyListTable.getModel().getValueAt(index[tempI], 8);
+                ArrayList<Series> seriesList = ApplicationContext.databaseRef.getSeriesList(studyIUID);
+                Iterator<Series> seriesItr = seriesList.iterator();
+                while (seriesItr.hasNext()) {
+                    Series series = seriesItr.next();
+                    Iterator<Instance> imgitr = series.getImageList().iterator();
+                    while (imgitr.hasNext()) {
+                        Instance img = imgitr.next();
+                        File temp = new File(img.getFilepath());
+                        temp.delete();
+                        ApplicationContext.databaseRef.instanceTableRowDelete(img.getSop_iuid());
+                    }
+                    ApplicationContext.databaseRef.seriesTableRowDelete(series.getSeriesInstanceUID());
+                }
+                ApplicationContext.databaseRef.studyTableRowDelete(studyIUID);
+                removeStudyFromList(studyIUID);
+            }
+        }
+        MainScreen.showLocalDBStorage();
+        doClose(RET_OK);
+    }//GEN-LAST:event_okButtonActionPerformed
+
+    /** Closes the dialog */
+    private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
+        doClose(RET_CANCEL);
+    }//GEN-LAST:event_closeDialog
+
+    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
+        doClose(RET_CANCEL);
+    }//GEN-LAST:event_jButton1ActionPerformed
+
+    private void doClose(int retStatus) {
+        returnStatus = retStatus;
+        setVisible(false);
+        dispose();
+    }
+
+    public void removeStudyFromList(String studyUID) {
+        synchronized (MainScreen.studyList) {
+            for (Study study : MainScreen.studyList) {
+                if (study.getStudyInstanceUID().equalsIgnoreCase(studyUID)) {
+                    MainScreen.studyList.remove(study);
+                    break;
+                }
+            }
+        }
+    }
+
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String args[]) {
+        java.awt.EventQueue.invokeLater(new Runnable() {
+
+            public void run() {
+                ConfirmDelete dialog = new ConfirmDelete(new javax.swing.JFrame(), true);
+                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
+
+                    public void windowClosing(java.awt.event.WindowEvent e) {
+                        System.exit(0);
+                    }
+                });
+                dialog.setVisible(true);
+            }
+        });
+    }
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JButton jButton1;
+    private javax.swing.JButton okButton;
+    public javax.swing.JLabel status;
+    // End of variables declaration//GEN-END:variables
+    private int returnStatus = RET_CANCEL;
+}
diff --git a/src/in/raster/mayam/form/dialog/EchoStatus.form b/src/in/raster/mayam/form/dialog/EchoStatus.form
new file mode 100644
index 0000000..df12a35
--- /dev/null
+++ b/src/in/raster/mayam/form/dialog/EchoStatus.form
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
+  <Properties>
+    <Property name="resizable" type="boolean" value="false"/>
+  </Properties>
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <Events>
+    <EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="closeDialog"/>
+  </Events>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" attributes="0">
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Group type="102" attributes="0">
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="status" pref="558" max="32767" attributes="0"/>
+                  </Group>
+                  <Group type="102" alignment="0" attributes="0">
+                      <EmptySpace min="-2" pref="249" max="-2" attributes="0"/>
+                      <Component id="okButton" min="-2" pref="67" max="-2" attributes="0"/>
+                  </Group>
+              </Group>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="1" attributes="0">
+              <EmptySpace pref="23" max="32767" attributes="0"/>
+              <Component id="status" min="-2" max="-2" attributes="0"/>
+              <EmptySpace type="separate" max="-2" attributes="0"/>
+              <Component id="okButton" min="-2" max="-2" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Component class="javax.swing.JButton" name="okButton">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="OK"/>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okButtonActionPerformed"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JLabel" name="status">
+      <Properties>
+        <Property name="horizontalAlignment" type="int" value="0"/>
+        <Property name="text" type="java.lang.String" value="status"/>
+      </Properties>
+      <AuxValues>
+        <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="1"/>
+      </AuxValues>
+    </Component>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/dialog/EchoStatus.java b/src/in/raster/mayam/form/dialog/EchoStatus.java
new file mode 100644
index 0000000..6eec9f6
--- /dev/null
+++ b/src/in/raster/mayam/form/dialog/EchoStatus.java
@@ -0,0 +1,161 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form.dialog;
+
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class EchoStatus extends javax.swing.JDialog {
+    /** A return status code - returned if Cancel button has been pressed */
+    public static final int RET_CANCEL = 0;
+    /** A return status code - returned if OK button has been pressed */
+    public static final int RET_OK = 1;
+    
+    /** Creates new form EchoStatus */
+    public EchoStatus(java.awt.Frame parent, boolean modal) {
+        super(parent, modal);  
+        initComponents();
+    }
+     public EchoStatus(java.awt.Dialog parent, boolean modal) {
+        super(parent, modal);
+        initComponents();
+    }   
+    /** @return the return status of this dialog - one of RET_OK or RET_CANCEL */
+    public int getReturnStatus() {
+        return returnStatus;
+    }
+    
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        okButton = new javax.swing.JButton();
+        status = new javax.swing.JLabel();
+
+        setResizable(false);
+        addWindowListener(new java.awt.event.WindowAdapter() {
+            public void windowClosing(java.awt.event.WindowEvent evt) {
+                closeDialog(evt);
+            }
+        });
+
+        okButton.setText("OK");
+        okButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                okButtonActionPerformed(evt);
+            }
+        });
+
+        status.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+        status.setText("status");
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+        getContentPane().setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(layout.createSequentialGroup()
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                    .add(layout.createSequentialGroup()
+                        .addContainerGap()
+                        .add(status, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 558, Short.MAX_VALUE))
+                    .add(layout.createSequentialGroup()
+                        .add(249, 249, 249)
+                        .add(okButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 67, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
+                .addContainerGap())
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+                .addContainerGap(23, Short.MAX_VALUE)
+                .add(status)
+                .add(18, 18, 18)
+                .add(okButton)
+                .addContainerGap())
+        );
+
+        pack();
+    }// </editor-fold>//GEN-END:initComponents
+    
+    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
+        doClose(RET_OK);
+    }//GEN-LAST:event_okButtonActionPerformed
+        
+    /** Closes the dialog */
+    private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
+        doClose(RET_CANCEL);
+    }//GEN-LAST:event_closeDialog
+    
+    private void doClose(int retStatus) {
+        returnStatus = retStatus;
+        setVisible(false);
+        dispose();
+    }
+    
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String args[]) {
+        java.awt.EventQueue.invokeLater(new Runnable() {
+            public void run() {
+                EchoStatus dialog = new EchoStatus(new javax.swing.JFrame(), true);
+                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
+                    public void windowClosing(java.awt.event.WindowEvent e) {
+                        System.exit(0);
+                    }
+                });
+                dialog.setVisible(true);
+            }
+        });
+    }
+    
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JButton okButton;
+    public javax.swing.JLabel status;
+    // End of variables declaration//GEN-END:variables
+    
+    private int returnStatus = RET_CANCEL;
+}
diff --git a/src/in/raster/mayam/form/dialog/ExportDialog.form b/src/in/raster/mayam/form/dialog/ExportDialog.form
new file mode 100644
index 0000000..2927f81
--- /dev/null
+++ b/src/in/raster/mayam/form/dialog/ExportDialog.form
@@ -0,0 +1,143 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
+  <NonVisualComponents>
+    <Component class="javax.swing.ButtonGroup" name="buttonGroup1">
+    </Component>
+    <Component class="javax.swing.ButtonGroup" name="formatGroup">
+    </Component>
+  </NonVisualComponents>
+  <Properties>
+    <Property name="title" type="java.lang.String" value="Export"/>
+    <Property name="resizable" type="boolean" value="false"/>
+  </Properties>
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <Events>
+    <EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="closeDialog"/>
+  </Events>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="1" attributes="0">
+              <EmptySpace pref="252" max="32767" attributes="0"/>
+              <Component id="cancelButton" linkSize="1" min="-2" max="-2" attributes="0"/>
+              <EmptySpace type="unrelated" max="-2" attributes="0"/>
+              <Component id="okButton" linkSize="1" min="-2" pref="67" max="-2" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="allImageRadio" min="-2" max="-2" attributes="0"/>
+              <EmptySpace pref="244" max="32767" attributes="0"/>
+          </Group>
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="singleImage" min="-2" max="-2" attributes="0"/>
+              <EmptySpace pref="272" max="32767" attributes="0"/>
+          </Group>
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace min="-2" pref="31" max="-2" attributes="0"/>
+              <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="dicomRadio" min="-2" max="-2" attributes="0"/>
+              <EmptySpace type="unrelated" max="-2" attributes="0"/>
+              <Component id="jpgRadio" min="-2" max="-2" attributes="0"/>
+              <EmptySpace pref="227" max="32767" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="1" attributes="0">
+              <EmptySpace min="-2" pref="40" max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="3" attributes="0">
+                  <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
+                  <Component id="dicomRadio" alignment="3" min="-2" max="-2" attributes="0"/>
+                  <Component id="jpgRadio" alignment="3" min="-2" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace min="-2" pref="26" max="-2" attributes="0"/>
+              <Component id="singleImage" min="-2" max="-2" attributes="0"/>
+              <EmptySpace type="unrelated" max="-2" attributes="0"/>
+              <Component id="allImageRadio" min="-2" max="-2" attributes="0"/>
+              <EmptySpace max="32767" attributes="0"/>
+              <Group type="103" groupAlignment="3" attributes="0">
+                  <Component id="okButton" alignment="3" min="-2" max="-2" attributes="0"/>
+                  <Component id="cancelButton" alignment="3" min="-2" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Component class="javax.swing.JButton" name="okButton">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="OK"/>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okButtonActionPerformed"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JButton" name="cancelButton">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Cancel"/>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelButtonActionPerformed"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JRadioButton" name="singleImage">
+      <Properties>
+        <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
+          <ComponentRef name="buttonGroup1"/>
+        </Property>
+        <Property name="selected" type="boolean" value="true"/>
+        <Property name="text" type="java.lang.String" value="Current image only"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JRadioButton" name="allImageRadio">
+      <Properties>
+        <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
+          <ComponentRef name="buttonGroup1"/>
+        </Property>
+        <Property name="text" type="java.lang.String" value="All images of the series"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="jLabel1">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Format"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JRadioButton" name="dicomRadio">
+      <Properties>
+        <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
+          <ComponentRef name="formatGroup"/>
+        </Property>
+        <Property name="selected" type="boolean" value="true"/>
+        <Property name="text" type="java.lang.String" value="DICOM"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JRadioButton" name="jpgRadio">
+      <Properties>
+        <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
+          <ComponentRef name="formatGroup"/>
+        </Property>
+        <Property name="text" type="java.lang.String" value="Jpg"/>
+      </Properties>
+    </Component>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/dialog/ExportDialog.java b/src/in/raster/mayam/form/dialog/ExportDialog.java
new file mode 100644
index 0000000..71cff9d
--- /dev/null
+++ b/src/in/raster/mayam/form/dialog/ExportDialog.java
@@ -0,0 +1,266 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form.dialog;
+
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.form.display.Display;
+//import in.raster.mayam.form.dialog.ExportLocationChooser;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class ExportDialog extends javax.swing.JDialog {
+
+    /** A return status code - returned if Cancel button has been pressed */
+    public static final int RET_CANCEL = 0;
+    /** A return status code - returned if OK button has been pressed */
+    public static final int RET_OK = 1;  
+    public static boolean seriesOfImage;
+    public static boolean conversionFormatDcm;
+
+    /** Creates new form AEManagementDialog */
+    public ExportDialog(java.awt.Frame parent, boolean modal) {
+        super(parent, modal);
+        initComponents();
+
+    }
+
+    /** @return the return status of this dialog - one of RET_OK or RET_CANCEL */
+    public int getReturnStatus() {
+        return returnStatus;
+    }
+    public void selectedRadio()
+    {
+        if(singleImage.isSelected())
+        {
+            seriesOfImage=false;
+        }
+        else
+            seriesOfImage=true;
+    }
+    public void selectedFormat()
+    {
+        if(dicomRadio.isSelected())
+            conversionFormatDcm=true;
+        else
+            conversionFormatDcm=false;
+    }
+
+
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        buttonGroup1 = new javax.swing.ButtonGroup();
+        formatGroup = new javax.swing.ButtonGroup();
+        okButton = new javax.swing.JButton();
+        cancelButton = new javax.swing.JButton();
+        singleImage = new javax.swing.JRadioButton();
+        allImageRadio = new javax.swing.JRadioButton();
+        jLabel1 = new javax.swing.JLabel();
+        dicomRadio = new javax.swing.JRadioButton();
+        jpgRadio = new javax.swing.JRadioButton();
+
+        setTitle("Export");
+        setResizable(false);
+        addWindowListener(new java.awt.event.WindowAdapter() {
+            public void windowClosing(java.awt.event.WindowEvent evt) {
+                closeDialog(evt);
+            }
+        });
+
+        okButton.setText("OK");
+        okButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                okButtonActionPerformed(evt);
+            }
+        });
+
+        cancelButton.setText("Cancel");
+        cancelButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                cancelButtonActionPerformed(evt);
+            }
+        });
+
+        buttonGroup1.add(singleImage);
+        singleImage.setSelected(true);
+        singleImage.setText("Current image only");
+
+        buttonGroup1.add(allImageRadio);
+        allImageRadio.setText("All images of the series");
+
+        jLabel1.setText("Format");
+
+        formatGroup.add(dicomRadio);
+        dicomRadio.setSelected(true);
+        dicomRadio.setText("DICOM");
+
+        formatGroup.add(jpgRadio);
+        jpgRadio.setText("Jpg");
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+        getContentPane().setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+                .addContainerGap(252, Short.MAX_VALUE)
+                .add(cancelButton)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+                .add(okButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 67, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addContainerGap())
+            .add(layout.createSequentialGroup()
+                .addContainerGap()
+                .add(allImageRadio)
+                .addContainerGap(244, Short.MAX_VALUE))
+            .add(layout.createSequentialGroup()
+                .addContainerGap()
+                .add(singleImage)
+                .addContainerGap(272, Short.MAX_VALUE))
+            .add(layout.createSequentialGroup()
+                .add(31, 31, 31)
+                .add(jLabel1)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(dicomRadio)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+                .add(jpgRadio)
+                .addContainerGap(227, Short.MAX_VALUE))
+        );
+
+        layout.linkSize(new java.awt.Component[] {cancelButton, okButton}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
+
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+                .add(40, 40, 40)
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+                    .add(jLabel1)
+                    .add(dicomRadio)
+                    .add(jpgRadio))
+                .add(26, 26, 26)
+                .add(singleImage)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+                .add(allImageRadio)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+                    .add(okButton)
+                    .add(cancelButton))
+                .add(12, 12, 12))
+        );
+
+        pack();
+    }// </editor-fold>//GEN-END:initComponents
+
+    /**
+     *
+     * @param evt-action performed event
+     */
+    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
+        selectedRadio();
+        selectedFormat();
+        ExportLocationChooser jpegChooser=new ExportLocationChooser(ApplicationContext.imgView, true);
+        this.setVisible(false);
+        Display.alignScreen(jpegChooser);
+        jpegChooser.setSeriesOrInstanceLevel(true);
+        jpegChooser.hideFormatComponents();
+        jpegChooser.setVisible(true);
+        doClose(RET_OK);
+    }//GEN-LAST:event_okButtonActionPerformed
+
+    /**
+     *
+     * @param evt-action performed event
+     */
+    private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
+        doClose(RET_CANCEL);
+    }//GEN-LAST:event_cancelButtonActionPerformed
+
+    /** Closes the dialog */
+    private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
+        doClose(RET_CANCEL);
+    }//GEN-LAST:event_closeDialog
+    /**
+     * This routine used to check the status of the dicom aetitle
+     * @param evt
+     */
+    private void doClose(int retStatus) {
+        returnStatus = retStatus;
+        setVisible(false);
+        dispose();
+    }
+
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String args[]) {
+        java.awt.EventQueue.invokeLater(new Runnable() {
+
+            public void run() {
+                ExportDialog dialog = new ExportDialog(new javax.swing.JFrame(), true);
+                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
+
+                    public void windowClosing(java.awt.event.WindowEvent e) {
+                        System.exit(0);
+                    }
+                });
+                dialog.setVisible(true);
+            }
+        });
+    }
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JRadioButton allImageRadio;
+    private javax.swing.ButtonGroup buttonGroup1;
+    private javax.swing.JButton cancelButton;
+    private javax.swing.JRadioButton dicomRadio;
+    private javax.swing.ButtonGroup formatGroup;
+    private javax.swing.JLabel jLabel1;
+    private javax.swing.JRadioButton jpgRadio;
+    private javax.swing.JButton okButton;
+    private javax.swing.JRadioButton singleImage;
+    // End of variables declaration//GEN-END:variables
+    private int returnStatus = RET_CANCEL;
+}
diff --git a/src/in/raster/mayam/form/dialog/ExportLocationChooser.form b/src/in/raster/mayam/form/dialog/ExportLocationChooser.form
new file mode 100644
index 0000000..d7528a4
--- /dev/null
+++ b/src/in/raster/mayam/form/dialog/ExportLocationChooser.form
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
+  <NonVisualComponents>
+    <Component class="javax.swing.ButtonGroup" name="formatGroup">
+    </Component>
+  </NonVisualComponents>
+  <Properties>
+    <Property name="resizable" type="boolean" value="false"/>
+  </Properties>
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <Events>
+    <EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="closeDialog"/>
+  </Events>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="1" attributes="0">
+              <EmptySpace max="32767" attributes="0"/>
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Group type="102" alignment="0" attributes="0">
+                      <EmptySpace min="-2" pref="16" max="-2" attributes="0"/>
+                      <Component id="formatLabel" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace type="unrelated" max="-2" attributes="0"/>
+                      <Component id="dicomRadio" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="jpgRadio" min="-2" max="-2" attributes="0"/>
+                  </Group>
+                  <Component id="jFileChooser1" alignment="0" min="-2" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="1" attributes="0">
+              <EmptySpace pref="20" max="32767" attributes="0"/>
+              <Group type="103" groupAlignment="3" attributes="0">
+                  <Component id="dicomRadio" alignment="3" min="-2" max="-2" attributes="0"/>
+                  <Component id="jpgRadio" alignment="3" min="-2" max="-2" attributes="0"/>
+                  <Component id="formatLabel" alignment="3" min="-2" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace type="unrelated" max="-2" attributes="0"/>
+              <Component id="jFileChooser1" min="-2" max="-2" attributes="0"/>
+              <EmptySpace min="-2" pref="40" max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Component class="javax.swing.JFileChooser" name="jFileChooser1">
+      <Properties>
+        <Property name="dialogType" type="int" value="1"/>
+        <Property name="fileSelectionMode" type="int" value="1"/>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jFileChooser1ActionPerformed"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JLabel" name="formatLabel">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Format"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JRadioButton" name="dicomRadio">
+      <Properties>
+        <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
+          <ComponentRef name="formatGroup"/>
+        </Property>
+        <Property name="selected" type="boolean" value="true"/>
+        <Property name="text" type="java.lang.String" value="DICOM"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JRadioButton" name="jpgRadio">
+      <Properties>
+        <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
+          <ComponentRef name="formatGroup"/>
+        </Property>
+        <Property name="text" type="java.lang.String" value="Jpg"/>
+      </Properties>
+    </Component>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/dialog/ExportLocationChooser.java b/src/in/raster/mayam/form/dialog/ExportLocationChooser.java
new file mode 100644
index 0000000..49a19c3
--- /dev/null
+++ b/src/in/raster/mayam/form/dialog/ExportLocationChooser.java
@@ -0,0 +1,242 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form.dialog;
+
+import in.raster.mayam.delegate.ExportingDelegate;
+import in.raster.mayam.form.MainScreen;
+import in.raster.mayam.model.table.StudyListModel;
+import java.io.File;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class ExportLocationChooser extends javax.swing.JDialog {
+
+    /** A return status code - returned if Cancel button has been pressed */
+    public static final int RET_CANCEL = 0;
+    /** A return status code - returned if OK button has been pressed */
+    public static final int RET_OK = 1;
+    private boolean seriesOrInstanceLevel = false;
+    private String studyUID = "";
+    public static boolean conversionFormatDcm;
+    private MainScreen parent;
+
+    /** Creates new form FileChooserDialog */
+    public ExportLocationChooser(java.awt.Frame parent, boolean modal) {
+        super(parent, modal);
+
+        initComponents();
+    }
+
+    /** @return the return status of this dialog - one of RET_OK or RET_CANCEL */
+    public int getReturnStatus() {
+        return returnStatus;
+    }
+
+    public String getStudyUID() {
+        return studyUID;
+    }
+
+    public void setStudyUID(String studyUID) {
+        this.studyUID = studyUID;
+    }
+
+    public boolean isSeriesOrInstanceLevel() {
+        return seriesOrInstanceLevel;
+    }
+
+    public void setSeriesOrInstanceLevel(boolean seriesOrInstanceLevel) {
+        this.seriesOrInstanceLevel = seriesOrInstanceLevel;
+    }
+
+    public void hideFormatComponents() {
+        formatLabel.setVisible(false);
+        dicomRadio.setVisible(false);
+        jpgRadio.setVisible(false);
+    }
+
+    public void showFormatComponents() {
+
+        formatLabel.setVisible(true);
+        dicomRadio.setVisible(true);
+        jpgRadio.setVisible(true);
+    }
+
+    public void selectedFormat() {
+        if (dicomRadio.isSelected()) {
+            conversionFormatDcm = true;
+        } else {
+            conversionFormatDcm = false;
+        }
+    }
+
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        formatGroup = new javax.swing.ButtonGroup();
+        jFileChooser1 = new javax.swing.JFileChooser();
+        formatLabel = new javax.swing.JLabel();
+        dicomRadio = new javax.swing.JRadioButton();
+        jpgRadio = new javax.swing.JRadioButton();
+
+        setResizable(false);
+        addWindowListener(new java.awt.event.WindowAdapter() {
+            public void windowClosing(java.awt.event.WindowEvent evt) {
+                closeDialog(evt);
+            }
+        });
+
+        jFileChooser1.setDialogType(1);
+        jFileChooser1.setFileSelectionMode(javax.swing.JFileChooser.DIRECTORIES_ONLY);
+        jFileChooser1.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                jFileChooser1ActionPerformed(evt);
+            }
+        });
+
+        formatLabel.setText("Format");
+
+        formatGroup.add(dicomRadio);
+        dicomRadio.setSelected(true);
+        dicomRadio.setText("DICOM");
+
+        formatGroup.add(jpgRadio);
+        jpgRadio.setText("Jpg");
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+        getContentPane().setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                    .add(layout.createSequentialGroup()
+                        .add(16, 16, 16)
+                        .add(formatLabel)
+                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+                        .add(dicomRadio)
+                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                        .add(jpgRadio))
+                    .add(jFileChooser1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+                .addContainerGap())
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+                .addContainerGap(20, Short.MAX_VALUE)
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+                    .add(dicomRadio)
+                    .add(jpgRadio)
+                    .add(formatLabel))
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+                .add(jFileChooser1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .add(40, 40, 40))
+        );
+
+        pack();
+    }// </editor-fold>//GEN-END:initComponents
+
+    /** Closes the dialog */
+    private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
+        doClose(RET_CANCEL);
+    }//GEN-LAST:event_closeDialog
+
+    @SuppressWarnings("static-access")
+    private void jFileChooser1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jFileChooser1ActionPerformed
+        if (evt.getActionCommand().equalsIgnoreCase("CancelSelection")) {
+            doClose(RET_CANCEL);
+        } else if (evt.getActionCommand().equalsIgnoreCase("ApproveSelection")) {
+            File openedFile = jFileChooser1.getSelectedFile();
+            if (!seriesOrInstanceLevel) {
+                selectedFormat();
+                int index[] = MainScreen.studyListTable.getSelectedRows();
+                for (int j = 0; j < index.length; j++) {
+                    index[j] = MainScreen.studyListTable.convertRowIndexToModel(index[j]);
+                }
+                for (int tempI = 0; tempI < index.length; tempI++) {
+                    this.studyUID = ((StudyListModel) MainScreen.studyListTable.getModel()).getValueAt(index[tempI], 8);
+                    ExportingDelegate exportingDelegate = new ExportingDelegate(openedFile, this.studyUID, seriesOrInstanceLevel);
+                }
+            } else {
+                ExportingDelegate exportingDelegate = new ExportingDelegate(openedFile, this.studyUID, seriesOrInstanceLevel);
+            }
+
+            doClose(RET_OK);
+        }
+    }//GEN-LAST:event_jFileChooser1ActionPerformed
+
+    private void doClose(int retStatus) {
+        returnStatus = retStatus;
+        setVisible(false);
+        dispose();
+    }
+
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String args[]) {
+        java.awt.EventQueue.invokeLater(new Runnable() {
+            public void run() {
+                ExportLocationChooser dialog = new ExportLocationChooser(new javax.swing.JFrame(), true);
+                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
+                    public void windowClosing(java.awt.event.WindowEvent e) {
+                        System.exit(0);
+                    }
+                });
+                dialog.setVisible(true);
+            }
+        });
+    }
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JRadioButton dicomRadio;
+    private javax.swing.ButtonGroup formatGroup;
+    private javax.swing.JLabel formatLabel;
+    private javax.swing.JFileChooser jFileChooser1;
+    private javax.swing.JRadioButton jpgRadio;
+    // End of variables declaration//GEN-END:variables
+    private int returnStatus = RET_CANCEL;
+}
diff --git a/src/in/raster/mayam/form/dialog/FieldValidator.form b/src/in/raster/mayam/form/dialog/FieldValidator.form
new file mode 100644
index 0000000..1d2c00d
--- /dev/null
+++ b/src/in/raster/mayam/form/dialog/FieldValidator.form
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
+  <Properties>
+    <Property name="resizable" type="boolean" value="false"/>
+  </Properties>
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <Events>
+    <EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="closeDialog"/>
+  </Events>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="1" attributes="0">
+              <EmptySpace pref="109" max="32767" attributes="0"/>
+              <Component id="jLabel1" min="-2" pref="198" max="-2" attributes="0"/>
+              <EmptySpace min="-2" pref="107" max="-2" attributes="0"/>
+          </Group>
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace min="-2" pref="155" max="-2" attributes="0"/>
+              <Component id="okButton" min="-2" max="-2" attributes="0"/>
+              <EmptySpace pref="184" max="32767" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" attributes="0">
+              <EmptySpace min="-2" pref="27" max="-2" attributes="0"/>
+              <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
+              <EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
+              <Component id="okButton" min="-2" max="-2" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Component class="javax.swing.JButton" name="okButton">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="OK"/>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okButtonActionPerformed"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JLabel" name="jLabel1">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Fields should not be blank"/>
+      </Properties>
+    </Component>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/dialog/FieldValidator.java b/src/in/raster/mayam/form/dialog/FieldValidator.java
new file mode 100644
index 0000000..69f0e3c
--- /dev/null
+++ b/src/in/raster/mayam/form/dialog/FieldValidator.java
@@ -0,0 +1,161 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form.dialog;
+
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class FieldValidator extends javax.swing.JDialog {
+    /** A return status code - returned if Cancel button has been pressed */
+    public static final int RET_CANCEL = 0;
+    /** A return status code - returned if OK button has been pressed */
+    public static final int RET_OK = 1;
+
+    /** Creates new form StudyStatus */
+    public FieldValidator(java.awt.Frame parent, boolean modal) {
+        super(parent, modal);
+        initComponents();
+    }
+    public FieldValidator(java.awt.Dialog parent, boolean modal) {
+        super(parent, modal);
+        initComponents();
+    }
+
+    /** @return the return status of this dialog - one of RET_OK or RET_CANCEL */
+    public int getReturnStatus() {
+        return returnStatus;
+    }
+
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    @SuppressWarnings("unchecked")
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        okButton = new javax.swing.JButton();
+        jLabel1 = new javax.swing.JLabel();
+
+        setResizable(false);
+        addWindowListener(new java.awt.event.WindowAdapter() {
+            public void windowClosing(java.awt.event.WindowEvent evt) {
+                closeDialog(evt);
+            }
+        });
+
+        okButton.setText("OK");
+        okButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                okButtonActionPerformed(evt);
+            }
+        });
+
+        jLabel1.setText("Fields should not be blank");
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+        getContentPane().setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+                .addContainerGap(109, Short.MAX_VALUE)
+                .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 198, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .add(107, 107, 107))
+            .add(layout.createSequentialGroup()
+                .add(155, 155, 155)
+                .add(okButton)
+                .addContainerGap(184, Short.MAX_VALUE))
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(layout.createSequentialGroup()
+                .add(27, 27, 27)
+                .add(jLabel1)
+                .add(18, 18, 18)
+                .add(okButton)
+                .addContainerGap())
+        );
+
+        pack();
+    }// </editor-fold>//GEN-END:initComponents
+
+    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
+        doClose(RET_OK);
+    }//GEN-LAST:event_okButtonActionPerformed
+
+    /** Closes the dialog */
+    private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
+        doClose(RET_CANCEL);
+    }//GEN-LAST:event_closeDialog
+
+    private void doClose(int retStatus) {
+        returnStatus = retStatus;
+        setVisible(false);
+        dispose();
+    }
+
+    /**
+    * @param args the command line arguments
+    */
+    public static void main(String args[]) {
+        java.awt.EventQueue.invokeLater(new Runnable() {
+            public void run() {
+                FieldValidator dialog = new FieldValidator(new javax.swing.JFrame(), true);
+                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
+                    public void windowClosing(java.awt.event.WindowEvent e) {
+                        System.exit(0);
+                    }
+                });
+                dialog.setVisible(true);
+            }
+        });
+    }
+
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JLabel jLabel1;
+    private javax.swing.JButton okButton;
+    // End of variables declaration//GEN-END:variables
+
+    private int returnStatus = RET_CANCEL;
+}
diff --git a/src/in/raster/mayam/form/dialog/FileChooserDialog.form b/src/in/raster/mayam/form/dialog/FileChooserDialog.form
new file mode 100644
index 0000000..0a4ee61
--- /dev/null
+++ b/src/in/raster/mayam/form/dialog/FileChooserDialog.form
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
+  <Properties>
+    <Property name="resizable" type="boolean" value="false"/>
+  </Properties>
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <Events>
+    <EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="closeDialog"/>
+  </Events>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" attributes="0">
+              <EmptySpace max="32767" attributes="0"/>
+              <Component id="jFileChooser1" min="-2" max="-2" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="1" attributes="0">
+              <EmptySpace pref="20" max="32767" attributes="0"/>
+              <Component id="jFileChooser1" min="-2" max="-2" attributes="0"/>
+              <EmptySpace min="-2" pref="40" max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Component class="javax.swing.JFileChooser" name="jFileChooser1">
+      <Properties>
+        <Property name="fileSelectionMode" type="int" value="2"/>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jFileChooser1ActionPerformed"/>
+      </Events>
+    </Component>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/dialog/FileChooserDialog.java b/src/in/raster/mayam/form/dialog/FileChooserDialog.java
new file mode 100644
index 0000000..4dc1d0d
--- /dev/null
+++ b/src/in/raster/mayam/form/dialog/FileChooserDialog.java
@@ -0,0 +1,183 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form.dialog;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.delegate.ImportDcmDirDelegate;
+import in.raster.mayam.form.*;
+import in.raster.mayam.delegate.ImportDelegate;
+import in.raster.mayam.exception.CompressedDcmOnMacException;
+import java.io.File;
+import javax.swing.JOptionPane;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class FileChooserDialog extends javax.swing.JDialog {
+
+    /** A return status code - returned if Cancel button has been pressed */
+    public static final int RET_CANCEL = 0;
+    /** A return status code - returned if OK button has been pressed */
+    public static final int RET_OK = 1;
+    public MainScreen ms;
+
+    /** Creates new form FileChooserDialog */
+    public FileChooserDialog(java.awt.Frame parent, boolean modal) {
+        super(parent, modal);
+        ms = (MainScreen) parent;
+        initComponents();
+    }
+
+    /** @return the return status of this dialog - one of RET_OK or RET_CANCEL */
+    public int getReturnStatus() {
+        return returnStatus;
+    }
+
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        jFileChooser1 = new javax.swing.JFileChooser();
+
+        setResizable(false);
+        addWindowListener(new java.awt.event.WindowAdapter() {
+            public void windowClosing(java.awt.event.WindowEvent evt) {
+                closeDialog(evt);
+            }
+        });
+
+        jFileChooser1.setFileSelectionMode(javax.swing.JFileChooser.FILES_AND_DIRECTORIES);
+        jFileChooser1.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                jFileChooser1ActionPerformed(evt);
+            }
+        });
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+        getContentPane().setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(layout.createSequentialGroup()
+                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                .add(jFileChooser1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addContainerGap())
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+                .addContainerGap(20, Short.MAX_VALUE)
+                .add(jFileChooser1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .add(40, 40, 40))
+        );
+
+        pack();
+    }// </editor-fold>//GEN-END:initComponents
+
+    /** Closes the dialog */
+    private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
+        doClose(RET_CANCEL);
+    }//GEN-LAST:event_closeDialog
+
+    @SuppressWarnings("static-access")
+    private void jFileChooser1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jFileChooser1ActionPerformed
+        if (evt.getActionCommand().equalsIgnoreCase("CancelSelection")) {
+            doClose(RET_CANCEL);
+        } else if (evt.getActionCommand().equalsIgnoreCase("ApproveSelection")) {
+            File openedFile = jFileChooser1.getSelectedFile();
+            if (openedFile.isDirectory()) {
+                ImportDelegate importDelegate = new ImportDelegate(openedFile, true, ms);
+                doClose(RET_OK);
+            } else {
+                if (openedFile.getName().toLowerCase().startsWith("dicomdir")) {
+                    // add less restrictive check on name DICOMDIR
+
+                    try {
+                        ImportDcmDirDelegate importDcmDirDelegate = new ImportDcmDirDelegate(openedFile);
+                        importDcmDirDelegate.run();
+                        doClose(RET_OK);
+                    } catch (CompressedDcmOnMacException e) {
+                        JOptionPane.showMessageDialog(ApplicationContext.mainScreen, e.getMessage());
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
+                } else {
+                    ImportDelegate importDelegate = new ImportDelegate(openedFile, false, ms);
+                    doClose(RET_OK);
+                }
+            }
+
+        }
+    }//GEN-LAST:event_jFileChooser1ActionPerformed
+
+    private void doClose(int retStatus) {
+        returnStatus = retStatus;
+        setVisible(false);
+        dispose();
+    }
+
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String args[]) {
+        java.awt.EventQueue.invokeLater(new Runnable() {
+
+            public void run() {
+                FileChooserDialog dialog = new FileChooserDialog(new javax.swing.JFrame(), true);
+                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
+
+                    public void windowClosing(java.awt.event.WindowEvent e) {
+                        System.exit(0);
+                    }
+                });
+                dialog.setVisible(true);
+            }
+        });
+    }
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JFileChooser jFileChooser1;
+    // End of variables declaration//GEN-END:variables
+    private int returnStatus = RET_CANCEL;
+}
diff --git a/src/in/raster/mayam/form/dialog/NumberFormatValidator.form b/src/in/raster/mayam/form/dialog/NumberFormatValidator.form
new file mode 100644
index 0000000..a91f02b
--- /dev/null
+++ b/src/in/raster/mayam/form/dialog/NumberFormatValidator.form
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
+  <Properties>
+    <Property name="resizable" type="boolean" value="false"/>
+  </Properties>
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <Events>
+    <EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="closeDialog"/>
+  </Events>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace min="157" pref="157" max="-2" attributes="0"/>
+              <Component id="okButton" linkSize="1" min="-2" pref="67" max="-2" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="cancelButton" linkSize="1" min="-2" max="-2" attributes="0"/>
+              <EmptySpace pref="113" max="32767" attributes="0"/>
+          </Group>
+          <Group type="102" alignment="1" attributes="0">
+              <EmptySpace pref="171" max="32767" attributes="0"/>
+              <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
+              <EmptySpace min="-2" pref="145" max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="1" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
+              <EmptySpace min="-2" pref="28" max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="3" attributes="0">
+                  <Component id="cancelButton" alignment="3" min="-2" max="-2" attributes="0"/>
+                  <Component id="okButton" alignment="3" min="-2" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace max="32767" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Component class="javax.swing.JButton" name="okButton">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="OK"/>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okButtonActionPerformed"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JButton" name="cancelButton">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Cancel"/>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelButtonActionPerformed"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JLabel" name="jLabel1">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Number Format Error"/>
+      </Properties>
+    </Component>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/dialog/NumberFormatValidator.java b/src/in/raster/mayam/form/dialog/NumberFormatValidator.java
new file mode 100644
index 0000000..63e3e0a
--- /dev/null
+++ b/src/in/raster/mayam/form/dialog/NumberFormatValidator.java
@@ -0,0 +1,179 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form.dialog;
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class NumberFormatValidator extends javax.swing.JDialog {
+    /** A return status code - returned if Cancel button has been pressed */
+    public static final int RET_CANCEL = 0;
+    /** A return status code - returned if OK button has been pressed */
+    public static final int RET_OK = 1;
+    
+    
+    
+    /** Creates new form AEManagementDialog */
+    public NumberFormatValidator(java.awt.Frame parent, boolean modal) {
+        super(parent, modal);
+        initComponents();
+    }    
+  
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        okButton = new javax.swing.JButton();
+        cancelButton = new javax.swing.JButton();
+        jLabel1 = new javax.swing.JLabel();
+
+        setResizable(false);
+        addWindowListener(new java.awt.event.WindowAdapter() {
+            public void windowClosing(java.awt.event.WindowEvent evt) {
+                closeDialog(evt);
+            }
+        });
+
+        okButton.setText("OK");
+        okButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                okButtonActionPerformed(evt);
+            }
+        });
+
+        cancelButton.setText("Cancel");
+        cancelButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                cancelButtonActionPerformed(evt);
+            }
+        });
+
+        jLabel1.setText("Number Format Error");
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+        getContentPane().setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(layout.createSequentialGroup()
+                .add(157, 157, 157)
+                .add(okButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 67, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(cancelButton)
+                .addContainerGap(113, Short.MAX_VALUE))
+            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+                .addContainerGap(171, Short.MAX_VALUE)
+                .add(jLabel1)
+                .add(145, 145, 145))
+        );
+
+        layout.linkSize(new java.awt.Component[] {cancelButton, okButton}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
+
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+                .addContainerGap()
+                .add(jLabel1)
+                .add(28, 28, 28)
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+                    .add(cancelButton)
+                    .add(okButton))
+                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+        );
+
+        pack();
+    }// </editor-fold>//GEN-END:initComponents
+    /**
+     *
+     * @param evt-action performed event
+     */
+    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
+        
+       
+         doClose(RET_OK);
+    }//GEN-LAST:event_okButtonActionPerformed
+    /**
+     *
+     * @param evt-action performed event
+     */
+    private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
+        doClose(RET_CANCEL);
+    }//GEN-LAST:event_cancelButtonActionPerformed
+    
+    /** Closes the dialog */
+    private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
+        doClose(RET_CANCEL);
+    }//GEN-LAST:event_closeDialog
+    
+    private void doClose(int retStatus) {
+        returnStatus = retStatus;
+        setVisible(false);
+        dispose();
+    }
+    
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String args[]) {
+        java.awt.EventQueue.invokeLater(new Runnable() {
+            public void run() {
+                NumberFormatValidator dialog = new NumberFormatValidator(new javax.swing.JFrame(), true);
+                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
+                    public void windowClosing(java.awt.event.WindowEvent e) {
+                        System.exit(0);
+                    }
+                });
+                dialog.setVisible(true);
+            }
+        });
+    }
+    
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JButton cancelButton;
+    private javax.swing.JLabel jLabel1;
+    private javax.swing.JButton okButton;
+    // End of variables declaration//GEN-END:variables
+    
+    private int returnStatus = RET_CANCEL;
+}
diff --git a/src/in/raster/mayam/form/dialog/SendingProgress.form b/src/in/raster/mayam/form/dialog/SendingProgress.form
new file mode 100644
index 0000000..ccc1f6e
--- /dev/null
+++ b/src/in/raster/mayam/form/dialog/SendingProgress.form
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
+  <Properties>
+    <Property name="resizable" type="boolean" value="false"/>
+  </Properties>
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <Events>
+    <EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="closeDialog"/>
+  </Events>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace min="-2" pref="122" max="-2" attributes="0"/>
+              <Component id="okButton" min="-2" pref="67" max="-2" attributes="0"/>
+              <EmptySpace pref="153" max="32767" attributes="0"/>
+          </Group>
+          <Group type="102" alignment="1" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="jLabel1" pref="330" max="32767" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+          <Group type="102" alignment="1" attributes="0">
+              <EmptySpace pref="55" max="32767" attributes="0"/>
+              <Component id="jProgressBar1" min="-2" pref="256" max="-2" attributes="0"/>
+              <EmptySpace min="-2" pref="31" max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace min="-2" pref="15" max="-2" attributes="0"/>
+              <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="jProgressBar1" min="-2" max="-2" attributes="0"/>
+              <EmptySpace type="unrelated" max="-2" attributes="0"/>
+              <Component id="okButton" min="-2" max="-2" attributes="0"/>
+              <EmptySpace max="32767" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Component class="javax.swing.JButton" name="okButton">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Abort"/>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okButtonActionPerformed"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JLabel" name="jLabel1">
+      <Properties>
+        <Property name="horizontalAlignment" type="int" value="0"/>
+        <Property name="text" type="java.lang.String" value="Sending files..."/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JProgressBar" name="jProgressBar1">
+    </Component>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/dialog/SendingProgress.java b/src/in/raster/mayam/form/dialog/SendingProgress.java
new file mode 100644
index 0000000..bc60adb
--- /dev/null
+++ b/src/in/raster/mayam/form/dialog/SendingProgress.java
@@ -0,0 +1,178 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form.dialog;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class SendingProgress extends javax.swing.JDialog {
+    /** A return status code - returned if Cancel button has been pressed */
+    public static final int RET_CANCEL = 0;
+    /** A return status code - returned if OK button has been pressed */
+    public static final int RET_OK = 1;
+    
+    /** Creates new form EchoStatus */
+    public SendingProgress(java.awt.Frame parent, boolean modal) {
+        super(parent, modal);  
+        initComponents();
+    }
+     public SendingProgress(java.awt.Dialog parent, boolean modal) {
+        super(parent, modal);
+        initComponents();
+    }
+    /** @return the return status of this dialog - one of RET_OK or RET_CANCEL */
+    public int getReturnStatus() {
+        return returnStatus;
+    }
+    
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        okButton = new javax.swing.JButton();
+        jLabel1 = new javax.swing.JLabel();
+        jProgressBar1 = new javax.swing.JProgressBar();
+
+        setResizable(false);
+        addWindowListener(new java.awt.event.WindowAdapter() {
+            public void windowClosing(java.awt.event.WindowEvent evt) {
+                closeDialog(evt);
+            }
+        });
+
+        okButton.setText("Abort");
+        okButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                okButtonActionPerformed(evt);
+            }
+        });
+
+        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+        jLabel1.setText("Sending files...");
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+        getContentPane().setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(layout.createSequentialGroup()
+                .add(122, 122, 122)
+                .add(okButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 67, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addContainerGap(153, Short.MAX_VALUE))
+            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+                .addContainerGap()
+                .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 330, Short.MAX_VALUE)
+                .addContainerGap())
+            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+                .addContainerGap(55, Short.MAX_VALUE)
+                .add(jProgressBar1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 256, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .add(31, 31, 31))
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(layout.createSequentialGroup()
+                .add(15, 15, 15)
+                .add(jLabel1)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(jProgressBar1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+                .add(okButton)
+                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+        );
+
+        pack();
+    }// </editor-fold>//GEN-END:initComponents
+    
+    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
+        doClose(RET_OK);
+    }//GEN-LAST:event_okButtonActionPerformed
+        
+    /** Closes the dialog */
+    private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
+        doClose(RET_CANCEL);
+    }//GEN-LAST:event_closeDialog
+    
+    private void doClose(int retStatus) {
+        returnStatus = retStatus;
+        setVisible(false);
+        dispose();
+    }
+    public void updateBar(int value)
+    {
+        jProgressBar1.setValue(value);
+        jProgressBar1.repaint();
+
+    }
+    public void setProgressMaximum(int max)
+    {
+        jProgressBar1.setMinimum(1);
+        jProgressBar1.setMaximum(max);
+        
+    }
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String args[]) {
+        java.awt.EventQueue.invokeLater(new Runnable() {
+            public void run() {
+                SendingProgress dialog = new SendingProgress(new javax.swing.JFrame(), true);
+                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
+                    public void windowClosing(java.awt.event.WindowEvent e) {
+                        System.exit(0);
+                    }
+                });
+                dialog.setVisible(true);
+            }
+        });
+    }
+    
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JLabel jLabel1;
+    private javax.swing.JProgressBar jProgressBar1;
+    private javax.swing.JButton okButton;
+    // End of variables declaration//GEN-END:variables
+    
+    private int returnStatus = RET_CANCEL;
+}
diff --git a/src/in/raster/mayam/form/dialog/ServerListDialog.form b/src/in/raster/mayam/form/dialog/ServerListDialog.form
new file mode 100644
index 0000000..aa80475
--- /dev/null
+++ b/src/in/raster/mayam/form/dialog/ServerListDialog.form
@@ -0,0 +1,88 @@
+<?xml version="1.1" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
+  <Properties>
+    <Property name="title" type="java.lang.String" value="Dicom Nodes"/>
+    <Property name="resizable" type="boolean" value="false"/>
+  </Properties>
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <Events>
+    <EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="closeDialog"/>
+  </Events>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Group type="102" alignment="0" attributes="0">
+                      <EmptySpace min="21" pref="21" max="21" attributes="0"/>
+                      <Component id="okButton" linkSize="1" min="-2" pref="67" max="-2" attributes="0"/>
+                      <EmptySpace type="unrelated" max="-2" attributes="0"/>
+                      <Component id="cancelButton" linkSize="1" min="-2" max="-2" attributes="0"/>
+                  </Group>
+                  <Component id="jScrollPane1" alignment="0" min="-2" pref="202" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="jScrollPane1" min="-2" pref="184" max="-2" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="3" attributes="0">
+                  <Component id="okButton" alignment="3" min="-2" max="-2" attributes="0"/>
+                  <Component id="cancelButton" alignment="3" min="-2" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace max="32767" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Component class="javax.swing.JButton" name="okButton">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="OK"/>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okButtonActionPerformed"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JButton" name="cancelButton">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Cancel"/>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelButtonActionPerformed"/>
+      </Events>
+    </Component>
+    <Container class="javax.swing.JScrollPane" name="jScrollPane1">
+      <AuxValues>
+        <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+      </AuxValues>
+
+      <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+      <SubComponents>
+        <Component class="javax.swing.JTree" name="serversInfoTree">
+        </Component>
+      </SubComponents>
+    </Container>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/dialog/ServerListDialog.java b/src/in/raster/mayam/form/dialog/ServerListDialog.java
new file mode 100644
index 0000000..7f5376e
--- /dev/null
+++ b/src/in/raster/mayam/form/dialog/ServerListDialog.java
@@ -0,0 +1,245 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form.dialog;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.model.AEModel;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.DefaultTreeModel;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class ServerListDialog extends javax.swing.JDialog {
+
+    /** A return status code - returned if Cancel button has been pressed */
+    public static final int RET_CANCEL = 0;
+    /** A return status code - returned if OK button has been pressed */
+    public static final int RET_OK = 1;
+    //public String keyName = "";
+    private AEModel ae = null;
+
+    /** Creates new form AEManagementDialog */
+    public ServerListDialog(java.awt.Frame parent, boolean modal) {
+        super(parent, modal);
+        initComponents();
+        updateTreeModel();
+    }
+
+    public AEModel getAe() {
+        return ae;
+    }
+
+    /** @return the return status of this dialog - one of RET_OK or RET_CANCEL */
+    public int getReturnStatus() {
+        return returnStatus;
+    }
+
+    public void updateTreeModel() {
+        Object Root[] = ApplicationContext.databaseRef.retrieveAEList();
+        DefaultMutableTreeNode root = addServerNameToTree(Root);
+        DefaultTreeModel tm = new DefaultTreeModel(root);
+        serversInfoTree.setModel(tm);
+        serversInfoTree.setRootVisible(false);
+        serversInfoTree.revalidate();
+        serversInfoTree.setSelectionRow(1);
+    }
+
+    public DefaultMutableTreeNode addServerNameToTree(Object[] obj) {
+        DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("root");
+        DefaultMutableTreeNode serverName;
+        Object temp[];
+        for (int i = 0; i < obj.length; i++) {
+            temp = (Object[]) obj[i];
+            serverName = new DefaultMutableTreeNode(temp[0]);
+            rootNode.add(serverName);
+        }
+        return rootNode;
+    }
+
+    public DefaultMutableTreeNode processHierarchy(Object[] hierarchy) {
+        DefaultMutableTreeNode tempNode = new DefaultMutableTreeNode("");
+        DefaultMutableTreeNode child;
+        for (int i = 0; i < hierarchy.length; i++) {
+            Object nodeSpecifier = hierarchy[i];
+            if (nodeSpecifier instanceof Object[]) // Ie node with children
+            {
+                child = processHierarchy((Object[]) nodeSpecifier);
+            } else {
+                child = new DefaultMutableTreeNode(nodeSpecifier); // Ie Leaf
+            }
+            tempNode.add(child);
+        }
+        return (tempNode);
+    }
+
+
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        okButton = new javax.swing.JButton();
+        cancelButton = new javax.swing.JButton();
+        jScrollPane1 = new javax.swing.JScrollPane();
+        serversInfoTree = new javax.swing.JTree();
+
+        setTitle("Dicom Nodes");
+        setResizable(false);
+        addWindowListener(new java.awt.event.WindowAdapter() {
+            public void windowClosing(java.awt.event.WindowEvent evt) {
+                closeDialog(evt);
+            }
+        });
+
+        okButton.setText("OK");
+        okButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                okButtonActionPerformed(evt);
+            }
+        });
+
+        cancelButton.setText("Cancel");
+        cancelButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                cancelButtonActionPerformed(evt);
+            }
+        });
+
+        jScrollPane1.setViewportView(serversInfoTree);
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+        getContentPane().setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(layout.createSequentialGroup()
+                .addContainerGap()
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                    .add(layout.createSequentialGroup()
+                        .add(21, 21, 21)
+                        .add(okButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 67, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+                        .add(cancelButton))
+                    .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 202, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+                .addContainerGap())
+        );
+
+        layout.linkSize(new java.awt.Component[] {cancelButton, okButton}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
+
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(layout.createSequentialGroup()
+                .addContainerGap()
+                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 184, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+                    .add(okButton)
+                    .add(cancelButton))
+                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+        );
+
+        pack();
+    }// </editor-fold>//GEN-END:initComponents
+
+    /**
+     *
+     * @param evt-action performed event
+     */
+    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
+        DefaultMutableTreeNode node = (DefaultMutableTreeNode) serversInfoTree.getLastSelectedPathComponent();
+        if (node != null) {
+            ae = ApplicationContext.databaseRef.getServerDetail(node.getUserObject().toString());
+            doClose(RET_OK);
+        }
+    }//GEN-LAST:event_okButtonActionPerformed
+
+    /**
+     *
+     * @param evt-action performed event
+     */
+    private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
+        doClose(RET_CANCEL);
+    }//GEN-LAST:event_cancelButtonActionPerformed
+
+    /** Closes the dialog */
+    private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
+        doClose(RET_CANCEL);
+    }//GEN-LAST:event_closeDialog
+    /**
+     * This routine used to check the status of the dicom aetitle
+     * @param evt
+     */
+    private void doClose(int retStatus) {
+        returnStatus = retStatus;
+        setVisible(false);
+
+    }
+
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String args[]) {
+        java.awt.EventQueue.invokeLater(new Runnable() {
+
+            public void run() {
+                ServerListDialog dialog = new ServerListDialog(new javax.swing.JFrame(), true);
+                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
+
+                    public void windowClosing(java.awt.event.WindowEvent e) {
+                        System.exit(0);
+                    }
+                });
+                dialog.setVisible(true);
+            }
+        });
+    }
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JButton cancelButton;
+    private javax.swing.JScrollPane jScrollPane1;
+    private javax.swing.JButton okButton;
+    private javax.swing.JTree serversInfoTree;
+    // End of variables declaration//GEN-END:variables
+    private int returnStatus = RET_CANCEL;
+}
diff --git a/src/in/raster/mayam/form/dialog/SettingsDialog.form b/src/in/raster/mayam/form/dialog/SettingsDialog.form
new file mode 100644
index 0000000..56eb2b7
--- /dev/null
+++ b/src/in/raster/mayam/form/dialog/SettingsDialog.form
@@ -0,0 +1,185 @@
+<?xml version="1.1" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
+  <Properties>
+    <Property name="title" type="java.lang.String" value="Mayam Preferences"/>
+    <Property name="resizable" type="boolean" value="false"/>
+  </Properties>
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <Events>
+    <EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="closeDialog"/>
+  </Events>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Component id="jSplitPane1" alignment="0" pref="635" max="32767" attributes="0"/>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Component id="jSplitPane1" alignment="0" pref="365" max="32767" attributes="0"/>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Container class="javax.swing.JSplitPane" name="jSplitPane1">
+      <Properties>
+        <Property name="dividerLocation" type="int" value="160"/>
+        <Property name="dividerSize" type="int" value="2"/>
+      </Properties>
+
+      <Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/>
+      <SubComponents>
+        <Container class="javax.swing.JPanel" name="jPanel1">
+          <Constraints>
+            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
+              <JSplitPaneConstraints position="left"/>
+            </Constraint>
+          </Constraints>
+
+          <Layout>
+            <DimensionLayout dim="0">
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Component id="jScrollPane1" alignment="0" pref="158" max="32767" attributes="0"/>
+              </Group>
+            </DimensionLayout>
+            <DimensionLayout dim="1">
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Component id="jScrollPane1" alignment="0" pref="361" max="32767" attributes="0"/>
+              </Group>
+            </DimensionLayout>
+          </Layout>
+          <SubComponents>
+            <Container class="javax.swing.JScrollPane" name="jScrollPane1">
+              <AuxValues>
+                <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+              </AuxValues>
+
+              <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+              <SubComponents>
+                <Component class="javax.swing.JTree" name="jTree1">
+                  <Events>
+                    <EventHandler event="valueChanged" listener="javax.swing.event.TreeSelectionListener" parameters="javax.swing.event.TreeSelectionEvent" handler="jTree1ValueChanged"/>
+                  </Events>
+                </Component>
+              </SubComponents>
+            </Container>
+          </SubComponents>
+        </Container>
+        <Container class="javax.swing.JPanel" name="jPanel2">
+          <Constraints>
+            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
+              <JSplitPaneConstraints position="right"/>
+            </Constraint>
+          </Constraints>
+
+          <Layout>
+            <DimensionLayout dim="0">
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Component id="jPanel4" alignment="0" pref="471" max="32767" attributes="1"/>
+                  <Component id="jPanel3" alignment="0" max="32767" attributes="1"/>
+              </Group>
+            </DimensionLayout>
+            <DimensionLayout dim="1">
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Group type="102" alignment="1" attributes="0">
+                      <Component id="jPanel4" pref="315" max="32767" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="jPanel3" min="-2" max="-2" attributes="0"/>
+                  </Group>
+              </Group>
+            </DimensionLayout>
+          </Layout>
+          <SubComponents>
+            <Container class="javax.swing.JPanel" name="jPanel3">
+
+              <Layout>
+                <DimensionLayout dim="0">
+                  <Group type="103" groupAlignment="0" attributes="0">
+                      <Group type="102" alignment="1" attributes="0">
+                          <EmptySpace pref="270" max="32767" attributes="0"/>
+                          <Component id="okButton" linkSize="1" min="-2" pref="67" max="-2" attributes="0"/>
+                          <EmptySpace max="-2" attributes="0"/>
+                          <Component id="cancelButton" linkSize="1" min="-2" max="-2" attributes="0"/>
+                          <EmptySpace min="-2" pref="23" max="-2" attributes="0"/>
+                      </Group>
+                  </Group>
+                </DimensionLayout>
+                <DimensionLayout dim="1">
+                  <Group type="103" groupAlignment="0" attributes="0">
+                      <Group type="102" alignment="0" attributes="0">
+                          <Group type="103" groupAlignment="3" attributes="0">
+                              <Component id="okButton" alignment="3" min="-2" max="-2" attributes="0"/>
+                              <Component id="cancelButton" alignment="3" min="-2" max="-2" attributes="0"/>
+                          </Group>
+                          <EmptySpace max="32767" attributes="0"/>
+                      </Group>
+                  </Group>
+                </DimensionLayout>
+              </Layout>
+              <SubComponents>
+                <Component class="javax.swing.JButton" name="okButton">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="OK"/>
+                  </Properties>
+                  <Events>
+                    <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okButtonActionPerformed"/>
+                  </Events>
+                </Component>
+                <Component class="javax.swing.JButton" name="cancelButton">
+                  <Properties>
+                    <Property name="text" type="java.lang.String" value="Cancel"/>
+                  </Properties>
+                  <Events>
+                    <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelButtonActionPerformed"/>
+                  </Events>
+                </Component>
+              </SubComponents>
+            </Container>
+            <Container class="javax.swing.JPanel" name="jPanel4">
+
+              <Layout class="org.netbeans.modules.form.compat2.layouts.DesignCardLayout"/>
+              <SubComponents>
+                <Component class="in.raster.mayam.form.DicomListenerPanel" name="dicomServerPanel1">
+                  <Constraints>
+                    <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignCardLayout" value="org.netbeans.modules.form.compat2.layouts.DesignCardLayout$CardConstraintsDescription">
+                      <CardConstraints cardName="card4"/>
+                    </Constraint>
+                  </Constraints>
+                </Component>
+                <Component class="in.raster.mayam.form.DateFormatPanel" name="dateFormatPanel1">
+                  <Constraints>
+                    <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignCardLayout" value="org.netbeans.modules.form.compat2.layouts.DesignCardLayout$CardConstraintsDescription">
+                      <CardConstraints cardName="card5"/>
+                    </Constraint>
+                  </Constraints>
+                </Component>
+                <Component class="in.raster.mayam.form.WindowConfigurationPanel" name="windowConfigurationPanel1">
+                  <Constraints>
+                    <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignCardLayout" value="org.netbeans.modules.form.compat2.layouts.DesignCardLayout$CardConstraintsDescription">
+                      <CardConstraints cardName="card6"/>
+                    </Constraint>
+                  </Constraints>
+                </Component>
+              </SubComponents>
+            </Container>
+          </SubComponents>
+        </Container>
+      </SubComponents>
+    </Container>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/dialog/SettingsDialog.java b/src/in/raster/mayam/form/dialog/SettingsDialog.java
new file mode 100644
index 0000000..88179af
--- /dev/null
+++ b/src/in/raster/mayam/form/dialog/SettingsDialog.java
@@ -0,0 +1,331 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form.dialog;
+
+
+import in.raster.mayam.form.*;
+import in.raster.mayam.context.ApplicationContext;
+import java.awt.CardLayout;
+import javax.swing.tree.DefaultMutableTreeNode;
+
+import javax.swing.tree.DefaultTreeModel;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class SettingsDialog extends javax.swing.JDialog {
+
+    /** A return status code - returned if Cancel button has been pressed */
+    public static final int RET_CANCEL = 0;
+    /** A return status code - returned if OK button has been pressed */
+    public static final int RET_OK = 1;
+    DefaultTreeModel tm;
+    MainScreen m;
+    LayoutManagerPanel layoutManagerPanel1;
+    WindowingManagerPanel windowingManagerPanel1;
+    ServerManager serverManager;
+
+    /** Creates new form SettingsDialog */
+    public SettingsDialog(java.awt.Frame parent, boolean modal) {
+        super(parent, modal);
+        m = (MainScreen) parent;
+        initComponents();
+        updateTreeModel();
+        settingListenerDetail();
+        initializePanel();
+    }
+
+    private void initializePanel() {
+        layoutManagerPanel1 = new LayoutManagerPanel();
+        jPanel4.add(layoutManagerPanel1, "card3");
+        windowingManagerPanel1 = new WindowingManagerPanel();
+        jPanel4.add(windowingManagerPanel1, "card2");
+        serverManager = new ServerManager();
+        serverManager.addServerChangeListener(m.getQueryScreen());
+        jPanel4.add(serverManager, "card7");
+
+
+    }
+
+    public void settingListenerDetail() {
+        String s[] = ApplicationContext.databaseRef.getListenerDetails();
+        dicomServerPanel1.setAeTitle(s[0]);
+        dicomServerPanel1.setPort(s[1]);
+
+    }
+
+    /** @return the return status of this dialog - one of RET_OK or RET_CANCEL */
+    public int getReturnStatus() {
+        return returnStatus;
+    }
+
+    private DefaultMutableTreeNode settingTree() {
+        DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("root");
+        DefaultMutableTreeNode node1 = new DefaultMutableTreeNode("Date Format");
+        DefaultMutableTreeNode node2 = new DefaultMutableTreeNode("DICOM Listener");
+        DefaultMutableTreeNode node3 = new DefaultMutableTreeNode("Layout");
+        DefaultMutableTreeNode node4 = new DefaultMutableTreeNode("Window Configuration");
+        DefaultMutableTreeNode node5 = new DefaultMutableTreeNode("Preset");
+        DefaultMutableTreeNode node6 = new DefaultMutableTreeNode("Servers");
+        rootNode.add(node2);
+        rootNode.add(node3);
+        rootNode.add(node6);
+        rootNode.add(node5);
+        return rootNode;
+
+    }
+
+    private void updateTreeModel() {
+        tm = new DefaultTreeModel(settingTree());
+        jTree1.setModel(tm);
+        jTree1.setRootVisible(false);
+        jTree1.revalidate();
+        jTree1.setSelectionRow(0);
+
+    }
+
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        jSplitPane1 = new javax.swing.JSplitPane();
+        jPanel1 = new javax.swing.JPanel();
+        jScrollPane1 = new javax.swing.JScrollPane();
+        jTree1 = new javax.swing.JTree();
+        jPanel2 = new javax.swing.JPanel();
+        jPanel3 = new javax.swing.JPanel();
+        okButton = new javax.swing.JButton();
+        cancelButton = new javax.swing.JButton();
+        jPanel4 = new javax.swing.JPanel();
+        dicomServerPanel1 = new in.raster.mayam.form.DicomListenerPanel();
+        dateFormatPanel1 = new in.raster.mayam.form.DateFormatPanel();
+        windowConfigurationPanel1 = new in.raster.mayam.form.WindowConfigurationPanel();
+
+        setTitle("Mayam Preferences");
+        setResizable(false);
+        addWindowListener(new java.awt.event.WindowAdapter() {
+            public void windowClosing(java.awt.event.WindowEvent evt) {
+                closeDialog(evt);
+            }
+        });
+
+        jSplitPane1.setDividerLocation(160);
+        jSplitPane1.setDividerSize(2);
+
+        jTree1.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {
+            public void valueChanged(javax.swing.event.TreeSelectionEvent evt) {
+                jTree1ValueChanged(evt);
+            }
+        });
+        jScrollPane1.setViewportView(jTree1);
+
+        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
+        jPanel1.setLayout(jPanel1Layout);
+        jPanel1Layout.setHorizontalGroup(
+            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 158, Short.MAX_VALUE)
+        );
+        jPanel1Layout.setVerticalGroup(
+            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 361, Short.MAX_VALUE)
+        );
+
+        jSplitPane1.setLeftComponent(jPanel1);
+
+        okButton.setText("OK");
+        okButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                okButtonActionPerformed(evt);
+            }
+        });
+
+        cancelButton.setText("Cancel");
+        cancelButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                cancelButtonActionPerformed(evt);
+            }
+        });
+
+        org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3);
+        jPanel3.setLayout(jPanel3Layout);
+        jPanel3Layout.setHorizontalGroup(
+            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel3Layout.createSequentialGroup()
+                .addContainerGap(270, Short.MAX_VALUE)
+                .add(okButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 67, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(cancelButton)
+                .add(23, 23, 23))
+        );
+
+        jPanel3Layout.linkSize(new java.awt.Component[] {cancelButton, okButton}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
+
+        jPanel3Layout.setVerticalGroup(
+            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(jPanel3Layout.createSequentialGroup()
+                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+                    .add(okButton)
+                    .add(cancelButton))
+                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+        );
+
+        jPanel4.setLayout(new java.awt.CardLayout());
+        jPanel4.add(dicomServerPanel1, "card4");
+        jPanel4.add(dateFormatPanel1, "card5");
+        jPanel4.add(windowConfigurationPanel1, "card6");
+
+        org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
+        jPanel2.setLayout(jPanel2Layout);
+        jPanel2Layout.setHorizontalGroup(
+            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(jPanel4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 471, Short.MAX_VALUE)
+            .add(jPanel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+        );
+        jPanel2Layout.setVerticalGroup(
+            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel2Layout.createSequentialGroup()
+                .add(jPanel4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 315, Short.MAX_VALUE)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(jPanel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+        );
+
+        jSplitPane1.setRightComponent(jPanel2);
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+        getContentPane().setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(jSplitPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 635, Short.MAX_VALUE)
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(jSplitPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 365, Short.MAX_VALUE)
+        );
+
+        pack();
+    }// </editor-fold>//GEN-END:initComponents
+
+    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
+        int port = ((!dicomServerPanel1.getPortText().getText().equalsIgnoreCase("")) ? Integer.parseInt(dicomServerPanel1.getPortText().getText()) : 1025);
+        ApplicationContext.databaseRef.insertListenerDetail(dicomServerPanel1.getAetitleText().getText(), port, "");
+        String s[] = layoutManagerPanel1.getModalityLayoutDetail();
+        ApplicationContext.databaseRef.insertLayoutDetail(Integer.parseInt(s[1]), Integer.parseInt(s[2]), s[0]);
+        m.restartReceiver();
+        layoutManagerPanel1.updateSeriesDisplayModification();
+        doClose(RET_OK);
+    }//GEN-LAST:event_okButtonActionPerformed
+
+    private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
+        doClose(RET_CANCEL);
+    }//GEN-LAST:event_cancelButtonActionPerformed
+
+    /** Closes the dialog */
+    private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
+        doClose(RET_CANCEL);
+    }//GEN-LAST:event_closeDialog
+
+    private void jTree1ValueChanged(javax.swing.event.TreeSelectionEvent evt) {//GEN-FIRST:event_jTree1ValueChanged
+        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
+        if (node.getUserObject().toString().equalsIgnoreCase("Date Format")) {
+            ((CardLayout) jPanel4.getLayout()).show(jPanel4, "card5");
+
+        } else if (node.getUserObject().toString().equalsIgnoreCase("DICOM Listener")) {
+            ((CardLayout) jPanel4.getLayout()).show(jPanel4, "card4");
+
+        } else if (node.getUserObject().toString().equalsIgnoreCase("Layout")) {
+            ((CardLayout) jPanel4.getLayout()).show(jPanel4, "card3");
+        } else if (node.getUserObject().toString().equalsIgnoreCase("Window Configuration")) {
+            ((CardLayout) jPanel4.getLayout()).show(jPanel4, "card6");
+
+        } else if (node.getUserObject().toString().equalsIgnoreCase("Preset")) {
+            ((CardLayout) jPanel4.getLayout()).show(jPanel4, "card2");
+
+        } else if (node.getUserObject().toString().equalsIgnoreCase("Servers")) {
+            ((CardLayout) jPanel4.getLayout()).show(jPanel4, "card7");
+
+        }
+    }//GEN-LAST:event_jTree1ValueChanged
+
+    private void doClose(int retStatus) {
+        returnStatus = retStatus;
+        setVisible(false);
+        dispose();
+    }
+
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String args[]) {
+        java.awt.EventQueue.invokeLater(new Runnable() {
+
+            public void run() {
+                SettingsDialog dialog = new SettingsDialog(new javax.swing.JFrame(), true);
+                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
+
+                    public void windowClosing(java.awt.event.WindowEvent e) {
+                        System.exit(0);
+                    }
+                });
+                dialog.setVisible(true);
+            }
+        });
+    }
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JButton cancelButton;
+    private in.raster.mayam.form.DateFormatPanel dateFormatPanel1;
+    private in.raster.mayam.form.DicomListenerPanel dicomServerPanel1;
+    private javax.swing.JPanel jPanel1;
+    private javax.swing.JPanel jPanel2;
+    private javax.swing.JPanel jPanel3;
+    private javax.swing.JPanel jPanel4;
+    private javax.swing.JScrollPane jScrollPane1;
+    private javax.swing.JSplitPane jSplitPane1;
+    private javax.swing.JTree jTree1;
+    private javax.swing.JButton okButton;
+    private in.raster.mayam.form.WindowConfigurationPanel windowConfigurationPanel1;
+    // End of variables declaration//GEN-END:variables
+    private int returnStatus = RET_CANCEL;
+}
diff --git a/src/in/raster/mayam/form/dialog/StudyAvailabilityStatus.form b/src/in/raster/mayam/form/dialog/StudyAvailabilityStatus.form
new file mode 100644
index 0000000..ed1f2c4
--- /dev/null
+++ b/src/in/raster/mayam/form/dialog/StudyAvailabilityStatus.form
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
+  <Properties>
+    <Property name="resizable" type="boolean" value="false"/>
+  </Properties>
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <Events>
+    <EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="closeDialog"/>
+  </Events>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" attributes="0">
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Group type="102" attributes="0">
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="jLabel1" pref="383" max="32767" attributes="0"/>
+                  </Group>
+                  <Group type="102" alignment="0" attributes="0">
+                      <EmptySpace min="-2" pref="166" max="-2" attributes="0"/>
+                      <Component id="okButton" min="-2" pref="67" max="-2" attributes="0"/>
+                  </Group>
+              </Group>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="1" attributes="0">
+              <EmptySpace pref="22" max="32767" attributes="0"/>
+              <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
+              <EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
+              <Component id="okButton" min="-2" max="-2" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Component class="javax.swing.JButton" name="okButton">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="OK"/>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okButtonActionPerformed"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JLabel" name="jLabel1">
+      <Properties>
+        <Property name="horizontalAlignment" type="int" value="0"/>
+        <Property name="text" type="java.lang.String" value="Requested Study Already Present in local DB"/>
+      </Properties>
+    </Component>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/dialog/StudyAvailabilityStatus.java b/src/in/raster/mayam/form/dialog/StudyAvailabilityStatus.java
new file mode 100644
index 0000000..4c78c03
--- /dev/null
+++ b/src/in/raster/mayam/form/dialog/StudyAvailabilityStatus.java
@@ -0,0 +1,158 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form.dialog;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class StudyAvailabilityStatus extends javax.swing.JDialog {
+    /** A return status code - returned if Cancel button has been pressed */
+    public static final int RET_CANCEL = 0;
+    /** A return status code - returned if OK button has been pressed */
+    public static final int RET_OK = 1;
+
+    /** Creates new form StudyAvailabilityStatus */
+    public StudyAvailabilityStatus(java.awt.Frame parent, boolean modal) {
+        super(parent, modal);
+        initComponents();
+    }
+
+    /** @return the return status of this dialog - one of RET_OK or RET_CANCEL */
+    public int getReturnStatus() {
+        return returnStatus;
+    }
+
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    @SuppressWarnings("unchecked")
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        okButton = new javax.swing.JButton();
+        jLabel1 = new javax.swing.JLabel();
+
+        setResizable(false);
+        addWindowListener(new java.awt.event.WindowAdapter() {
+            public void windowClosing(java.awt.event.WindowEvent evt) {
+                closeDialog(evt);
+            }
+        });
+
+        okButton.setText("OK");
+        okButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                okButtonActionPerformed(evt);
+            }
+        });
+
+        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+        jLabel1.setText("Requested Study Already Present in local DB");
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+        getContentPane().setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(layout.createSequentialGroup()
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                    .add(layout.createSequentialGroup()
+                        .addContainerGap()
+                        .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 383, Short.MAX_VALUE))
+                    .add(layout.createSequentialGroup()
+                        .add(166, 166, 166)
+                        .add(okButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 67, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
+                .addContainerGap())
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+                .addContainerGap(22, Short.MAX_VALUE)
+                .add(jLabel1)
+                .add(18, 18, 18)
+                .add(okButton)
+                .addContainerGap())
+        );
+
+        pack();
+    }// </editor-fold>//GEN-END:initComponents
+
+    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
+        doClose(RET_OK);
+    }//GEN-LAST:event_okButtonActionPerformed
+
+    /** Closes the dialog */
+    private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
+        doClose(RET_CANCEL);
+    }//GEN-LAST:event_closeDialog
+
+    private void doClose(int retStatus) {
+        returnStatus = retStatus;
+        setVisible(false);
+        dispose();
+    }
+
+    /**
+    * @param args the command line arguments
+    */
+    public static void main(String args[]) {
+        java.awt.EventQueue.invokeLater(new Runnable() {
+            public void run() {
+                StudyAvailabilityStatus dialog = new StudyAvailabilityStatus(new javax.swing.JFrame(), true);
+                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
+                    public void windowClosing(java.awt.event.WindowEvent e) {
+                        System.exit(0);
+                    }
+                });
+                dialog.setVisible(true);
+            }
+        });
+    }
+
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JLabel jLabel1;
+    private javax.swing.JButton okButton;
+    // End of variables declaration//GEN-END:variables
+
+    private int returnStatus = RET_CANCEL;
+}
diff --git a/src/in/raster/mayam/form/dialog/WadoInformation.form b/src/in/raster/mayam/form/dialog/WadoInformation.form
new file mode 100644
index 0000000..decebd2
--- /dev/null
+++ b/src/in/raster/mayam/form/dialog/WadoInformation.form
@@ -0,0 +1,141 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <Events>
+    <EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="closeDialog"/>
+  </Events>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Group type="102" alignment="1" attributes="0">
+                      <Component id="okButton" linkSize="1" min="-2" pref="67" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="cancelButton" linkSize="1" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                  </Group>
+                  <Group type="102" alignment="0" attributes="0">
+                      <Group type="103" groupAlignment="0" attributes="0">
+                          <Component id="jLabel4" alignment="0" min="-2" max="-2" attributes="0"/>
+                          <Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
+                          <Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/>
+                          <Component id="jLabel3" alignment="0" min="-2" max="-2" attributes="0"/>
+                      </Group>
+                      <EmptySpace type="separate" max="-2" attributes="0"/>
+                      <Group type="103" groupAlignment="0" attributes="0">
+                          <Component id="wadoPortText" alignment="0" min="-2" pref="102" max="-2" attributes="0"/>
+                          <Component id="wadoURLText" alignment="0" min="-2" pref="237" max="-2" attributes="0"/>
+                          <Component id="retrieveSyntaxCombo" alignment="0" pref="239" max="32767" attributes="0"/>
+                          <Component id="wadoProtocolCheckBox" alignment="0" min="-2" max="-2" attributes="0"/>
+                      </Group>
+                      <EmptySpace pref="22" max="32767" attributes="0"/>
+                  </Group>
+              </Group>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="1" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="3" attributes="0">
+                  <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
+                  <Component id="wadoURLText" alignment="3" min="-2" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace type="separate" max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="3" attributes="0">
+                  <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
+                  <Component id="wadoPortText" alignment="3" min="-2" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace type="separate" max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="3" attributes="0">
+                  <Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
+                  <Component id="wadoProtocolCheckBox" alignment="3" min="-2" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace type="separate" max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="3" attributes="0">
+                  <Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
+                  <Component id="retrieveSyntaxCombo" alignment="3" min="-2" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace pref="13" max="32767" attributes="0"/>
+              <Group type="103" groupAlignment="3" attributes="0">
+                  <Component id="cancelButton" alignment="3" min="-2" max="-2" attributes="0"/>
+                  <Component id="okButton" alignment="3" min="-2" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Component class="javax.swing.JButton" name="okButton">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="OK"/>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okButtonActionPerformed"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JButton" name="cancelButton">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Cancel"/>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelButtonActionPerformed"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JLabel" name="jLabel1">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="WADO url"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="jLabel2">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="WADO Port"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="jLabel3">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Encryption"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="jLabel4">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Retrieve Syntax"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JTextField" name="wadoURLText">
+    </Component>
+    <Component class="javax.swing.JTextField" name="wadoPortText">
+    </Component>
+    <Component class="javax.swing.JCheckBox" name="wadoProtocolCheckBox">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="https"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JComboBox" name="retrieveSyntaxCombo">
+      <Properties>
+        <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+          <Connection code="new TransferSyntaxModel(getRetrieveTransferSyntaxArray())" type="code"/>
+        </Property>
+      </Properties>
+    </Component>
+  </SubComponents>
+</Form>
diff --git a/src/in/raster/mayam/form/dialog/WadoInformation.java b/src/in/raster/mayam/form/dialog/WadoInformation.java
new file mode 100644
index 0000000..5ee2edb
--- /dev/null
+++ b/src/in/raster/mayam/form/dialog/WadoInformation.java
@@ -0,0 +1,242 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form.dialog;
+
+import in.raster.mayam.model.ServerModel;
+import in.raster.mayam.model.combo.TransferSyntaxModel;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.7
+ *
+ */
+public class WadoInformation extends javax.swing.JDialog {
+    /** A return status code - returned if Cancel button has been pressed */
+    public static final int RET_CANCEL = 0;
+    /** A return status code - returned if OK button has been pressed */
+    public static final int RET_OK = 1;
+
+    private ServerModel serverModel;
+
+    /** Creates new form WadoInformation */
+    public WadoInformation(java.awt.Frame parent, boolean modal,ServerModel serverModel) {
+        super(parent, modal);
+        initComponents();
+        this.serverModel=serverModel;
+        updateWadoInformation();
+
+       
+    }
+    private String[] getRetrieveTransferSyntaxArray()
+    {
+        String[] retrieveSyntaxArray=new String[3];
+        retrieveSyntaxArray[0]="Explicit VR Little Endian";
+        retrieveSyntaxArray[1]="Implicit VR Little Endian";
+        retrieveSyntaxArray[2]="Original Syntax";
+        return retrieveSyntaxArray;
+    }
+
+    /** @return the return status of this dialog - one of RET_OK or RET_CANCEL */
+    public int getReturnStatus() {
+        return returnStatus;
+    }
+
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    @SuppressWarnings("unchecked")
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        okButton = new javax.swing.JButton();
+        cancelButton = new javax.swing.JButton();
+        jLabel1 = new javax.swing.JLabel();
+        jLabel2 = new javax.swing.JLabel();
+        jLabel3 = new javax.swing.JLabel();
+        jLabel4 = new javax.swing.JLabel();
+        wadoURLText = new javax.swing.JTextField();
+        wadoPortText = new javax.swing.JTextField();
+        wadoProtocolCheckBox = new javax.swing.JCheckBox();
+        retrieveSyntaxCombo = new javax.swing.JComboBox();
+
+        addWindowListener(new java.awt.event.WindowAdapter() {
+            public void windowClosing(java.awt.event.WindowEvent evt) {
+                closeDialog(evt);
+            }
+        });
+
+        okButton.setText("OK");
+        okButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                okButtonActionPerformed(evt);
+            }
+        });
+
+        cancelButton.setText("Cancel");
+        cancelButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                cancelButtonActionPerformed(evt);
+            }
+        });
+
+        jLabel1.setText("WADO url");
+
+        jLabel2.setText("WADO Port");
+
+        jLabel3.setText("Encryption");
+
+        jLabel4.setText("Retrieve Syntax");
+
+        wadoProtocolCheckBox.setText("https");
+
+        retrieveSyntaxCombo.setModel(new TransferSyntaxModel(getRetrieveTransferSyntaxArray()));
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+        getContentPane().setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(layout.createSequentialGroup()
+                .addContainerGap()
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                    .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+                        .add(okButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 67, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                        .add(cancelButton)
+                        .addContainerGap())
+                    .add(layout.createSequentialGroup()
+                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                            .add(jLabel4)
+                            .add(jLabel1)
+                            .add(jLabel2)
+                            .add(jLabel3))
+                        .add(18, 18, 18)
+                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                            .add(wadoPortText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 102, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                            .add(wadoURLText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 237, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                            .add(retrieveSyntaxCombo, 0, 239, Short.MAX_VALUE)
+                            .add(wadoProtocolCheckBox))
+                        .addContainerGap(22, Short.MAX_VALUE))))
+        );
+
+        layout.linkSize(new java.awt.Component[] {cancelButton, okButton}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
+
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+                .addContainerGap()
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+                    .add(jLabel1)
+                    .add(wadoURLText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+                .add(18, 18, 18)
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+                    .add(jLabel2)
+                    .add(wadoPortText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+                .add(18, 18, 18)
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+                    .add(jLabel3)
+                    .add(wadoProtocolCheckBox))
+                .add(18, 18, 18)
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+                    .add(jLabel4)
+                    .add(retrieveSyntaxCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 13, Short.MAX_VALUE)
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+                    .add(cancelButton)
+                    .add(okButton))
+                .addContainerGap())
+        );
+
+        pack();
+    }// </editor-fold>//GEN-END:initComponents
+
+    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
+        storeWadoInformation();
+        doClose(RET_OK);
+    }//GEN-LAST:event_okButtonActionPerformed
+
+    private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
+        doClose(RET_CANCEL);
+    }//GEN-LAST:event_cancelButtonActionPerformed
+
+    /** Closes the dialog */
+    private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
+        doClose(RET_CANCEL);
+    }//GEN-LAST:event_closeDialog
+
+    private void doClose(int retStatus) {
+        returnStatus = retStatus;
+        setVisible(false);
+        dispose();
+    }
+    public void updateWadoInformation()
+    {
+        wadoURLText.setText(serverModel.getWadoContextPath());
+        wadoPortText.setText(String.valueOf(serverModel.getWadoPort()));
+        if(serverModel.getWadoProtocol().equalsIgnoreCase("https"))
+        wadoProtocolCheckBox.setSelected(true);
+        if(!serverModel.getRetrieveTransferSyntax().equalsIgnoreCase(""))
+        retrieveSyntaxCombo.getModel().setSelectedItem(serverModel.getRetrieveTransferSyntax());
+    }
+    private void storeWadoInformation()
+    {      
+        String wadoProtocol=this.wadoProtocolCheckBox.isSelected()?"https":"http";  
+        serverModel.setWadoContextPath(this.wadoURLText.getText());
+        serverModel.setWadoPort(Integer.parseInt(this.wadoPortText.getText()));
+        serverModel.setWadoProtocol(wadoProtocol);
+        serverModel.setRetrieveTransferSyntax((String)this.retrieveSyntaxCombo.getSelectedItem());
+    }    
+
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JButton cancelButton;
+    private javax.swing.JLabel jLabel1;
+    private javax.swing.JLabel jLabel2;
+    private javax.swing.JLabel jLabel3;
+    private javax.swing.JLabel jLabel4;
+    private javax.swing.JButton okButton;
+    private javax.swing.JComboBox retrieveSyntaxCombo;
+    private javax.swing.JTextField wadoPortText;
+    private javax.swing.JCheckBox wadoProtocolCheckBox;
+    private javax.swing.JTextField wadoURLText;
+    // End of variables declaration//GEN-END:variables
+
+    private int returnStatus = RET_CANCEL;
+}
diff --git a/src/in/raster/mayam/form/display/Display.java b/src/in/raster/mayam/form/display/Display.java
new file mode 100644
index 0000000..80ee8a6
--- /dev/null
+++ b/src/in/raster/mayam/form/display/Display.java
@@ -0,0 +1,81 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form.display;
+
+import java.awt.Toolkit;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class Display {
+
+    public Display() {
+    }
+    /**
+     * This routine used to align the specified frame to the center position of the screen.
+     * @param toBeAligned
+     */
+    public static void alignScreen(JFrame toBeAligned) {
+        int frameWidh = toBeAligned.getWidth();
+        int frameHeight = toBeAligned.getHeight();
+        int scrWidth = Toolkit.getDefaultToolkit().getScreenSize().width;
+        int scrHeight = Toolkit.getDefaultToolkit().getScreenSize().height;
+        int centerX = scrWidth / 2;
+        int cenetrY = scrHeight / 2;
+        toBeAligned.setLocation(centerX - (frameWidh / 2), cenetrY - (frameHeight / 2));
+    }
+    /**
+     * This routine used to align the specified dialog to the center position of the screen.
+     * @param toBeAligned
+     */
+    public static void alignScreen(JDialog toBeAligned) {
+        int frameWidh = toBeAligned.getWidth();
+        int frameHeight = toBeAligned.getHeight();
+        int scrWidth = Toolkit.getDefaultToolkit().getScreenSize().width;
+        int scrHeight = Toolkit.getDefaultToolkit().getScreenSize().height;
+        int centerX = scrWidth / 2;
+        int cenetrY = scrHeight / 2;
+        toBeAligned.setLocation(centerX - (frameWidh / 2), cenetrY - (frameHeight / 2));
+    }
+}
diff --git a/src/in/raster/mayam/form/images/AxialView.png b/src/in/raster/mayam/form/images/AxialView.png
new file mode 100644
index 0000000..9795a10
Binary files /dev/null and b/src/in/raster/mayam/form/images/AxialView.png differ
diff --git a/src/in/raster/mayam/form/images/CoronalView.png b/src/in/raster/mayam/form/images/CoronalView.png
new file mode 100644
index 0000000..6dc76ad
Binary files /dev/null and b/src/in/raster/mayam/form/images/CoronalView.png differ
diff --git a/src/in/raster/mayam/form/images/Cube3D.png b/src/in/raster/mayam/form/images/Cube3D.png
new file mode 100755
index 0000000..dc15a4b
Binary files /dev/null and b/src/in/raster/mayam/form/images/Cube3D.png differ
diff --git a/src/in/raster/mayam/form/images/Cut.png b/src/in/raster/mayam/form/images/Cut.png
new file mode 100755
index 0000000..0dd39eb
Binary files /dev/null and b/src/in/raster/mayam/form/images/Cut.png differ
diff --git a/src/in/raster/mayam/form/images/DrawCircle.png b/src/in/raster/mayam/form/images/DrawCircle.png
new file mode 100755
index 0000000..b486680
Binary files /dev/null and b/src/in/raster/mayam/form/images/DrawCircle.png differ
diff --git a/src/in/raster/mayam/form/images/DrawLine.png b/src/in/raster/mayam/form/images/DrawLine.png
new file mode 100755
index 0000000..f95ec23
Binary files /dev/null and b/src/in/raster/mayam/form/images/DrawLine.png differ
diff --git a/src/in/raster/mayam/form/images/FusionSurfaceSettings.png b/src/in/raster/mayam/form/images/FusionSurfaceSettings.png
new file mode 100644
index 0000000..97146c8
Binary files /dev/null and b/src/in/raster/mayam/form/images/FusionSurfaceSettings.png differ
diff --git a/src/in/raster/mayam/form/images/Grid.png b/src/in/raster/mayam/form/images/Grid.png
new file mode 100755
index 0000000..c82d4a3
Binary files /dev/null and b/src/in/raster/mayam/form/images/Grid.png differ
diff --git a/src/in/raster/mayam/form/images/Link.png b/src/in/raster/mayam/form/images/Link.png
new file mode 100755
index 0000000..92590a5
Binary files /dev/null and b/src/in/raster/mayam/form/images/Link.png differ
diff --git a/src/in/raster/mayam/form/images/Move.png b/src/in/raster/mayam/form/images/Move.png
new file mode 100755
index 0000000..2019a6f
Binary files /dev/null and b/src/in/raster/mayam/form/images/Move.png differ
diff --git a/src/in/raster/mayam/form/images/Movie.png b/src/in/raster/mayam/form/images/Movie.png
new file mode 100755
index 0000000..a68fee7
Binary files /dev/null and b/src/in/raster/mayam/form/images/Movie.png differ
diff --git a/src/in/raster/mayam/form/images/ResetInteractor.png b/src/in/raster/mayam/form/images/ResetInteractor.png
new file mode 100755
index 0000000..dc15a4b
Binary files /dev/null and b/src/in/raster/mayam/form/images/ResetInteractor.png differ
diff --git a/src/in/raster/mayam/form/images/RotateSurface.png b/src/in/raster/mayam/form/images/RotateSurface.png
new file mode 100755
index 0000000..fd682df
Binary files /dev/null and b/src/in/raster/mayam/form/images/RotateSurface.png differ
diff --git a/src/in/raster/mayam/form/images/SagittalView.png b/src/in/raster/mayam/form/images/SagittalView.png
new file mode 100644
index 0000000..25f06f0
Binary files /dev/null and b/src/in/raster/mayam/form/images/SagittalView.png differ
diff --git a/src/in/raster/mayam/form/images/ScreenShot.png b/src/in/raster/mayam/form/images/ScreenShot.png
new file mode 100755
index 0000000..3b8c02c
Binary files /dev/null and b/src/in/raster/mayam/form/images/ScreenShot.png differ
diff --git a/src/in/raster/mayam/form/images/Search.png b/src/in/raster/mayam/form/images/Search.png
new file mode 100644
index 0000000..7570b74
Binary files /dev/null and b/src/in/raster/mayam/form/images/Search.png differ
diff --git a/src/in/raster/mayam/form/images/Settings.png b/src/in/raster/mayam/form/images/Settings.png
new file mode 100755
index 0000000..c075035
Binary files /dev/null and b/src/in/raster/mayam/form/images/Settings.png differ
diff --git a/src/in/raster/mayam/form/images/ZoomInOut.png b/src/in/raster/mayam/form/images/ZoomInOut.png
new file mode 100755
index 0000000..5b7bac2
Binary files /dev/null and b/src/in/raster/mayam/form/images/ZoomInOut.png differ
diff --git a/src/in/raster/mayam/form/images/ZoomInOut_1.png b/src/in/raster/mayam/form/images/ZoomInOut_1.png
new file mode 100755
index 0000000..5b7bac2
Binary files /dev/null and b/src/in/raster/mayam/form/images/ZoomInOut_1.png differ
diff --git a/src/in/raster/mayam/form/images/angle.png b/src/in/raster/mayam/form/images/angle.png
new file mode 100644
index 0000000..1d42925
Binary files /dev/null and b/src/in/raster/mayam/form/images/angle.png differ
diff --git a/src/in/raster/mayam/form/images/annotation_overlay.png b/src/in/raster/mayam/form/images/annotation_overlay.png
new file mode 100644
index 0000000..7535d69
Binary files /dev/null and b/src/in/raster/mayam/form/images/annotation_overlay.png differ
diff --git a/src/in/raster/mayam/form/images/annotation_selection.png b/src/in/raster/mayam/form/images/annotation_selection.png
new file mode 100644
index 0000000..d970262
Binary files /dev/null and b/src/in/raster/mayam/form/images/annotation_selection.png differ
diff --git a/src/in/raster/mayam/form/images/cd_burn.png b/src/in/raster/mayam/form/images/cd_burn.png
new file mode 100644
index 0000000..2a54bbc
Binary files /dev/null and b/src/in/raster/mayam/form/images/cd_burn.png differ
diff --git a/src/in/raster/mayam/form/images/cd_burn1.png b/src/in/raster/mayam/form/images/cd_burn1.png
new file mode 100755
index 0000000..0e8c8e2
Binary files /dev/null and b/src/in/raster/mayam/form/images/cd_burn1.png differ
diff --git a/src/in/raster/mayam/form/images/cd_burn2.png b/src/in/raster/mayam/form/images/cd_burn2.png
new file mode 100755
index 0000000..171398d
Binary files /dev/null and b/src/in/raster/mayam/form/images/cd_burn2.png differ
diff --git a/src/in/raster/mayam/form/images/cd_import.png b/src/in/raster/mayam/form/images/cd_import.png
new file mode 100644
index 0000000..35955f5
Binary files /dev/null and b/src/in/raster/mayam/form/images/cd_import.png differ
diff --git a/src/in/raster/mayam/form/images/cd_import1.png b/src/in/raster/mayam/form/images/cd_import1.png
new file mode 100755
index 0000000..e9c7ffd
Binary files /dev/null and b/src/in/raster/mayam/form/images/cd_import1.png differ
diff --git a/src/in/raster/mayam/form/images/cd_import2.png b/src/in/raster/mayam/form/images/cd_import2.png
new file mode 100755
index 0000000..75a092b
Binary files /dev/null and b/src/in/raster/mayam/form/images/cd_import2.png differ
diff --git a/src/in/raster/mayam/form/images/cineloop.png b/src/in/raster/mayam/form/images/cineloop.png
new file mode 100644
index 0000000..229fab2
Binary files /dev/null and b/src/in/raster/mayam/form/images/cineloop.png differ
diff --git a/src/in/raster/mayam/form/images/cineloop1.png b/src/in/raster/mayam/form/images/cineloop1.png
new file mode 100755
index 0000000..a006b1c
Binary files /dev/null and b/src/in/raster/mayam/form/images/cineloop1.png differ
diff --git a/src/in/raster/mayam/form/images/cineloop2.png b/src/in/raster/mayam/form/images/cineloop2.png
new file mode 100755
index 0000000..3505c08
Binary files /dev/null and b/src/in/raster/mayam/form/images/cineloop2.png differ
diff --git a/src/in/raster/mayam/form/images/clear_all_annotation.png b/src/in/raster/mayam/form/images/clear_all_annotation.png
new file mode 100644
index 0000000..6fb5554
Binary files /dev/null and b/src/in/raster/mayam/form/images/clear_all_annotation.png differ
diff --git a/src/in/raster/mayam/form/images/delete_annotation.png b/src/in/raster/mayam/form/images/delete_annotation.png
new file mode 100644
index 0000000..f3c7b3b
Binary files /dev/null and b/src/in/raster/mayam/form/images/delete_annotation.png differ
diff --git a/src/in/raster/mayam/form/images/delete_study.png b/src/in/raster/mayam/form/images/delete_study.png
new file mode 100644
index 0000000..d94eb71
Binary files /dev/null and b/src/in/raster/mayam/form/images/delete_study.png differ
diff --git a/src/in/raster/mayam/form/images/delete_study1.png b/src/in/raster/mayam/form/images/delete_study1.png
new file mode 100755
index 0000000..a1aade0
Binary files /dev/null and b/src/in/raster/mayam/form/images/delete_study1.png differ
diff --git a/src/in/raster/mayam/form/images/delete_study2.png b/src/in/raster/mayam/form/images/delete_study2.png
new file mode 100755
index 0000000..ff6b2aa
Binary files /dev/null and b/src/in/raster/mayam/form/images/delete_study2.png differ
diff --git a/src/in/raster/mayam/form/images/drop_down.png b/src/in/raster/mayam/form/images/drop_down.png
new file mode 100644
index 0000000..015a001
Binary files /dev/null and b/src/in/raster/mayam/form/images/drop_down.png differ
diff --git a/src/in/raster/mayam/form/images/ellipse.png b/src/in/raster/mayam/form/images/ellipse.png
new file mode 100644
index 0000000..94fd0ac
Binary files /dev/null and b/src/in/raster/mayam/form/images/ellipse.png differ
diff --git a/src/in/raster/mayam/form/images/export_series.png b/src/in/raster/mayam/form/images/export_series.png
new file mode 100644
index 0000000..fb6ad63
Binary files /dev/null and b/src/in/raster/mayam/form/images/export_series.png differ
diff --git a/src/in/raster/mayam/form/images/export_study.png b/src/in/raster/mayam/form/images/export_study.png
new file mode 100644
index 0000000..bba589c
Binary files /dev/null and b/src/in/raster/mayam/form/images/export_study.png differ
diff --git a/src/in/raster/mayam/form/images/export_study1.png b/src/in/raster/mayam/form/images/export_study1.png
new file mode 100755
index 0000000..b34daf0
Binary files /dev/null and b/src/in/raster/mayam/form/images/export_study1.png differ
diff --git a/src/in/raster/mayam/form/images/export_study2.png b/src/in/raster/mayam/form/images/export_study2.png
new file mode 100755
index 0000000..266fb2d
Binary files /dev/null and b/src/in/raster/mayam/form/images/export_study2.png differ
diff --git a/src/in/raster/mayam/form/images/fav_mayam.png b/src/in/raster/mayam/form/images/fav_mayam.png
new file mode 100755
index 0000000..be8313a
Binary files /dev/null and b/src/in/raster/mayam/form/images/fav_mayam.png differ
diff --git a/src/in/raster/mayam/form/images/flip_horizontal.png b/src/in/raster/mayam/form/images/flip_horizontal.png
new file mode 100644
index 0000000..b05e803
Binary files /dev/null and b/src/in/raster/mayam/form/images/flip_horizontal.png differ
diff --git a/src/in/raster/mayam/form/images/flip_vertical.png b/src/in/raster/mayam/form/images/flip_vertical.png
new file mode 100644
index 0000000..fb51788
Binary files /dev/null and b/src/in/raster/mayam/form/images/flip_vertical.png differ
diff --git a/src/in/raster/mayam/form/images/import.png b/src/in/raster/mayam/form/images/import.png
new file mode 100644
index 0000000..01b83fc
Binary files /dev/null and b/src/in/raster/mayam/form/images/import.png differ
diff --git a/src/in/raster/mayam/form/images/import1.png b/src/in/raster/mayam/form/images/import1.png
new file mode 100755
index 0000000..631e250
Binary files /dev/null and b/src/in/raster/mayam/form/images/import1.png differ
diff --git a/src/in/raster/mayam/form/images/import2.png b/src/in/raster/mayam/form/images/import2.png
new file mode 100755
index 0000000..eadcf6a
Binary files /dev/null and b/src/in/raster/mayam/form/images/import2.png differ
diff --git a/src/in/raster/mayam/form/images/invert.png b/src/in/raster/mayam/form/images/invert.png
new file mode 100644
index 0000000..4c05c93
Binary files /dev/null and b/src/in/raster/mayam/form/images/invert.png differ
diff --git a/src/in/raster/mayam/form/images/layout.png b/src/in/raster/mayam/form/images/layout.png
new file mode 100644
index 0000000..63776f7
Binary files /dev/null and b/src/in/raster/mayam/form/images/layout.png differ
diff --git a/src/in/raster/mayam/form/images/mayam.png b/src/in/raster/mayam/form/images/mayam.png
new file mode 100644
index 0000000..3b39520
Binary files /dev/null and b/src/in/raster/mayam/form/images/mayam.png differ
diff --git a/src/in/raster/mayam/form/images/metadata_mainpage.png b/src/in/raster/mayam/form/images/metadata_mainpage.png
new file mode 100644
index 0000000..77a05b4
Binary files /dev/null and b/src/in/raster/mayam/form/images/metadata_mainpage.png differ
diff --git a/src/in/raster/mayam/form/images/metadata_mainpage1.png b/src/in/raster/mayam/form/images/metadata_mainpage1.png
new file mode 100755
index 0000000..fcda91b
Binary files /dev/null and b/src/in/raster/mayam/form/images/metadata_mainpage1.png differ
diff --git a/src/in/raster/mayam/form/images/metadata_mainpage2.png b/src/in/raster/mayam/form/images/metadata_mainpage2.png
new file mode 100755
index 0000000..3c3efed
Binary files /dev/null and b/src/in/raster/mayam/form/images/metadata_mainpage2.png differ
diff --git a/src/in/raster/mayam/form/images/metadata_viewerpage.png b/src/in/raster/mayam/form/images/metadata_viewerpage.png
new file mode 100644
index 0000000..a9a3584
Binary files /dev/null and b/src/in/raster/mayam/form/images/metadata_viewerpage.png differ
diff --git a/src/in/raster/mayam/form/images/pan.png b/src/in/raster/mayam/form/images/pan.png
new file mode 100644
index 0000000..2019a6f
Binary files /dev/null and b/src/in/raster/mayam/form/images/pan.png differ
diff --git a/src/in/raster/mayam/form/images/pdficon.png b/src/in/raster/mayam/form/images/pdficon.png
new file mode 100644
index 0000000..351e026
Binary files /dev/null and b/src/in/raster/mayam/form/images/pdficon.png differ
diff --git a/src/in/raster/mayam/form/images/probe.png b/src/in/raster/mayam/form/images/probe.png
new file mode 100644
index 0000000..f91608a
Binary files /dev/null and b/src/in/raster/mayam/form/images/probe.png differ
diff --git a/src/in/raster/mayam/form/images/query.png b/src/in/raster/mayam/form/images/query.png
new file mode 100644
index 0000000..ffb46a6
Binary files /dev/null and b/src/in/raster/mayam/form/images/query.png differ
diff --git a/src/in/raster/mayam/form/images/query1.png b/src/in/raster/mayam/form/images/query1.png
new file mode 100755
index 0000000..68773de
Binary files /dev/null and b/src/in/raster/mayam/form/images/query1.png differ
diff --git a/src/in/raster/mayam/form/images/query2.png b/src/in/raster/mayam/form/images/query2.png
new file mode 100755
index 0000000..50b2bcb
Binary files /dev/null and b/src/in/raster/mayam/form/images/query2.png differ
diff --git a/src/in/raster/mayam/form/images/queue.png b/src/in/raster/mayam/form/images/queue.png
new file mode 100644
index 0000000..ba6f889
Binary files /dev/null and b/src/in/raster/mayam/form/images/queue.png differ
diff --git a/src/in/raster/mayam/form/images/queue1.png b/src/in/raster/mayam/form/images/queue1.png
new file mode 100755
index 0000000..f3a551d
Binary files /dev/null and b/src/in/raster/mayam/form/images/queue1.png differ
diff --git a/src/in/raster/mayam/form/images/queue2.png b/src/in/raster/mayam/form/images/queue2.png
new file mode 100755
index 0000000..ed8f1c8
Binary files /dev/null and b/src/in/raster/mayam/form/images/queue2.png differ
diff --git a/src/in/raster/mayam/form/images/rectangle.png b/src/in/raster/mayam/form/images/rectangle.png
new file mode 100644
index 0000000..e7dfad2
Binary files /dev/null and b/src/in/raster/mayam/form/images/rectangle.png differ
diff --git a/src/in/raster/mayam/form/images/reset.png b/src/in/raster/mayam/form/images/reset.png
new file mode 100644
index 0000000..be27a37
Binary files /dev/null and b/src/in/raster/mayam/form/images/reset.png differ
diff --git a/src/in/raster/mayam/form/images/rotate_left.png b/src/in/raster/mayam/form/images/rotate_left.png
new file mode 100644
index 0000000..fd682df
Binary files /dev/null and b/src/in/raster/mayam/form/images/rotate_left.png differ
diff --git a/src/in/raster/mayam/form/images/rotate_right.png b/src/in/raster/mayam/form/images/rotate_right.png
new file mode 100644
index 0000000..081c06b
Binary files /dev/null and b/src/in/raster/mayam/form/images/rotate_right.png differ
diff --git a/src/in/raster/mayam/form/images/ruler.png b/src/in/raster/mayam/form/images/ruler.png
new file mode 100644
index 0000000..e1cd18c
Binary files /dev/null and b/src/in/raster/mayam/form/images/ruler.png differ
diff --git a/src/in/raster/mayam/form/images/scout.png b/src/in/raster/mayam/form/images/scout.png
new file mode 100644
index 0000000..9da85e7
Binary files /dev/null and b/src/in/raster/mayam/form/images/scout.png differ
diff --git a/src/in/raster/mayam/form/images/send.png b/src/in/raster/mayam/form/images/send.png
new file mode 100644
index 0000000..22bafc0
Binary files /dev/null and b/src/in/raster/mayam/form/images/send.png differ
diff --git a/src/in/raster/mayam/form/images/send1.png b/src/in/raster/mayam/form/images/send1.png
new file mode 100755
index 0000000..5b79699
Binary files /dev/null and b/src/in/raster/mayam/form/images/send1.png differ
diff --git a/src/in/raster/mayam/form/images/send2.png b/src/in/raster/mayam/form/images/send2.png
new file mode 100755
index 0000000..9d503f3
Binary files /dev/null and b/src/in/raster/mayam/form/images/send2.png differ
diff --git a/src/in/raster/mayam/form/images/stack.png b/src/in/raster/mayam/form/images/stack.png
new file mode 100644
index 0000000..1faa1be
Binary files /dev/null and b/src/in/raster/mayam/form/images/stack.png differ
diff --git a/src/in/raster/mayam/form/images/textoverlay.png b/src/in/raster/mayam/form/images/textoverlay.png
new file mode 100644
index 0000000..9d2b4db
Binary files /dev/null and b/src/in/raster/mayam/form/images/textoverlay.png differ
diff --git a/src/in/raster/mayam/form/images/viewer.png b/src/in/raster/mayam/form/images/viewer.png
new file mode 100644
index 0000000..0946297
Binary files /dev/null and b/src/in/raster/mayam/form/images/viewer.png differ
diff --git a/src/in/raster/mayam/form/images/viewer1.png b/src/in/raster/mayam/form/images/viewer1.png
new file mode 100755
index 0000000..879c20f
Binary files /dev/null and b/src/in/raster/mayam/form/images/viewer1.png differ
diff --git a/src/in/raster/mayam/form/images/viewer2.png b/src/in/raster/mayam/form/images/viewer2.png
new file mode 100755
index 0000000..254aa51
Binary files /dev/null and b/src/in/raster/mayam/form/images/viewer2.png differ
diff --git a/src/in/raster/mayam/form/images/windowing.png b/src/in/raster/mayam/form/images/windowing.png
new file mode 100644
index 0000000..48eba3d
Binary files /dev/null and b/src/in/raster/mayam/form/images/windowing.png differ
diff --git a/src/in/raster/mayam/form/images/zoomin.png b/src/in/raster/mayam/form/images/zoomin.png
new file mode 100644
index 0000000..5b7bac2
Binary files /dev/null and b/src/in/raster/mayam/form/images/zoomin.png differ
diff --git a/src/in/raster/mayam/form/images/zoomout.png b/src/in/raster/mayam/form/images/zoomout.png
new file mode 100644
index 0000000..c9fdc59
Binary files /dev/null and b/src/in/raster/mayam/form/images/zoomout.png differ
diff --git a/src/in/raster/mayam/form/shapes/SelectedShape.java b/src/in/raster/mayam/form/shapes/SelectedShape.java
new file mode 100644
index 0000000..3af2efd
--- /dev/null
+++ b/src/in/raster/mayam/form/shapes/SelectedShape.java
@@ -0,0 +1,101 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form.shapes;
+
+import java.awt.geom.Rectangle2D;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class SelectedShape extends Rectangle2D {
+
+   // private String type="";
+
+    public SelectedShape() {
+    }
+
+    @Override
+    public void setRect(double x, double y, double w, double h) {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public int outcode(double x, double y) {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public Rectangle2D createIntersection(Rectangle2D r) {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public Rectangle2D createUnion(Rectangle2D r) {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public double getX() {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public double getY() {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public double getWidth() {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public double getHeight() {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public boolean isEmpty() {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+}
diff --git a/src/in/raster/mayam/form/shapes/ShapeCoordinates.java b/src/in/raster/mayam/form/shapes/ShapeCoordinates.java
new file mode 100644
index 0000000..d144d7d
--- /dev/null
+++ b/src/in/raster/mayam/form/shapes/ShapeCoordinates.java
@@ -0,0 +1,94 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form.shapes;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class ShapeCoordinates {
+
+    private int x;
+    private int y;
+    private int width;
+    private int height;
+
+    public ShapeCoordinates(int X1, int Y1, int X2 , int Y2) {
+
+           if(X2-X1>0 )
+            {
+                x=X1;
+                width=X2-X1;
+            }
+            else
+            {
+                x=X2;
+                width=X1-X2;
+            }
+            if(Y2-Y1>0)
+            {
+                y=Y1;
+                height=Y2-Y1;
+            }
+            else
+            {
+                y=Y2;
+                height=Y1-Y2;
+            }
+
+    }
+
+    public int getHeight() {
+        return height;
+    }
+
+    public int getWidth() {
+        return width;
+    }
+
+    public int getX() {
+        return x;
+    }
+
+    public int getY() {
+        return y;
+    }
+}
diff --git a/src/in/raster/mayam/form/tab/component/ButtonTabComp.java b/src/in/raster/mayam/form/tab/component/ButtonTabComp.java
new file mode 100644
index 0000000..b528dd6
--- /dev/null
+++ b/src/in/raster/mayam/form/tab/component/ButtonTabComp.java
@@ -0,0 +1,164 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.form.tab.component;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.delegate.AnnotationDelegate;
+import javax.swing.*;
+import javax.swing.plaf.basic.BasicButtonUI;
+import java.awt.*;
+import java.awt.event.*;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class ButtonTabComp extends JPanel {
+
+    private final JTabbedPane pane;
+
+    public ButtonTabComp(final JTabbedPane pane) {
+        this.pane = pane;
+        setOpaque(false);
+        JLabel label = new JLabel() {
+
+            public String getText() {
+                int i = pane.indexOfTabComponent(ButtonTabComp.this);
+                if (i != -1) {
+                    return pane.getTitleAt(i);
+                }
+                return null;
+            }
+        };
+        label.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 14));
+        add(label);
+        //add more space between the label and the button
+        label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2));
+        label.setVerticalTextPosition(JLabel.TOP);
+
+        JButton button = new TabButton();
+        add(button);
+        //add more space to the top of the component now it is -1 for mac computer
+        setBorder(BorderFactory.createEmptyBorder(-1, 0, 0, 0));
+    }
+
+    private class TabButton extends JButton implements ActionListener {
+
+        public TabButton() {
+            int size = 17;
+            setPreferredSize(new Dimension(size, size));
+            setToolTipText("close this tab");
+            //Make the button looks the same for all Laf's
+            setUI(new BasicButtonUI());
+            //Make it transparent
+            setContentAreaFilled(false);
+            //No need to be focusable
+            setFocusable(false);
+            setBorder(BorderFactory.createEtchedBorder());
+            setBorderPainted(false);
+            //Making nice rollover effect
+            //we use the same listener for all buttons
+            addMouseListener(buttonMouseListener);
+            setRolloverEnabled(true);
+            //Close the proper tab by clicking the button
+            addActionListener(this);
+        }
+
+        public void actionPerformed(ActionEvent e) {
+            int i = pane.indexOfTabComponent(ButtonTabComp.this);
+            int x = i;
+            if (i != -1) {
+                if (i >= 1) {
+                    x++;
+                }
+                AnnotationDelegate annotationDelegate = new AnnotationDelegate();
+                annotationDelegate.storeAnnotationHook(x);
+                annotationDelegate.saveAnnotation(x);
+                pane.remove(i);
+                if (i == 0 && pane.getComponentCount() == 1) {
+                    ApplicationContext.imgView.annotationAlreadyStored = true;
+                    ApplicationContext.imgView.dispose();
+                }
+            }
+        }
+        //we don't want to update UI for this button
+
+        public void updateUI() {
+        }
+
+        //paint the cross
+        protected void paintComponent(Graphics g) {
+            super.paintComponent(g);
+            Graphics2D g2 = (Graphics2D) g.create();
+            //shift the image for pressed buttons
+            if (getModel().isPressed()) {
+                g2.translate(1, 1);
+            }
+            g2.setStroke(new BasicStroke(2));
+            g2.setColor(Color.BLACK);
+            if (getModel().isRollover()) {
+                g2.setColor(Color.MAGENTA);
+            }
+            int delta = 6;
+            g2.drawLine(delta, delta, getWidth() - delta - 1, getHeight() - delta - 1);
+            g2.drawLine(getWidth() - delta - 1, delta, delta, getHeight() - delta - 1);
+            g2.dispose();
+        }
+    }
+    private final static MouseListener buttonMouseListener = new MouseAdapter() {
+
+        public void mouseEntered(MouseEvent e) {
+            Component component = e.getComponent();
+            if (component instanceof AbstractButton) {
+                AbstractButton button = (AbstractButton) component;
+                button.setBorderPainted(true);
+            }
+        }
+
+        public void mouseExited(MouseEvent e) {
+            Component component = e.getComponent();
+            if (component instanceof AbstractButton) {
+                AbstractButton button = (AbstractButton) component;
+                button.setBorderPainted(false);
+            }
+        }
+    };
+}
diff --git a/src/in/raster/mayam/model/AEModel.java b/src/in/raster/mayam/model/AEModel.java
new file mode 100644
index 0000000..e4060b7
--- /dev/null
+++ b/src/in/raster/mayam/model/AEModel.java
@@ -0,0 +1,102 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.model;
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class AEModel {
+    private String serverName="";
+    private String hostName="";    
+    private String aeTitle="";
+    private int port=0;
+    private String retrieveType;
+   
+    public AEModel(String serverName,String host,String aeTitle,int port,String retrieveType)
+    {
+        this.serverName=serverName;
+        this.hostName=host;      
+        this.aeTitle=aeTitle;
+        this.port=port;
+        this.retrieveType=retrieveType;
+    }
+    public String getAeTitle() {
+        return aeTitle;
+    }
+
+    public void setAeTitle(String aeTitle) {
+        this.aeTitle = aeTitle;
+    }    
+
+    public String getHostName() {
+        return hostName;
+    }
+    public void setHostName(String hostName) {
+        this.hostName = hostName;
+         System.out.println("hostname"+hostName);
+    } 
+
+    public int getPort() {
+        return port;
+    }
+
+    public void setPort(int port) {
+        this.port = port;
+        System.out.println("port"+port);
+    }
+
+    public String getServerName() {
+        return serverName;
+    }
+
+    public void setServerName(String serverName) {
+        this.serverName = serverName;
+    }
+
+    public String getRetrieveType() {
+        return retrieveType;
+    }
+
+    public void setRetrieveType(String retrieveType) {
+        this.retrieveType = retrieveType;
+    }
+
+}
diff --git a/src/in/raster/mayam/model/InputArgumentValues.java b/src/in/raster/mayam/model/InputArgumentValues.java
new file mode 100644
index 0000000..379017d
--- /dev/null
+++ b/src/in/raster/mayam/model/InputArgumentValues.java
@@ -0,0 +1,242 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.model;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.9
+ *
+ */
+public class InputArgumentValues {
+    //Remote server related variables
+
+    private String aeTitle;
+    private int port;
+    private String hostName;
+    //Query filter parameter.
+    private String patientID;
+    private String patientName;
+    private String studyUID;
+    private String studyDate;
+    private String modality;
+    private String accessionNumber;
+    //Wado related variables
+    private int wadoPort;
+    private String wadoContext;
+    private String wadoProtocol;
+    private String from;
+    private String to;
+
+    public String getAccessionNumber() {
+        return accessionNumber;
+    }
+
+    public void setAccessionNumber(String accessionNumber) {
+        this.accessionNumber = accessionNumber;
+    }
+
+    public String getAeTitle() {
+        return aeTitle;
+    }
+
+    public void setAeTitle(String aeTitle) {
+        this.aeTitle = aeTitle;
+    }
+
+    public String getHostName() {
+        return hostName;
+    }
+
+    public void setHostName(String hostName) {
+        this.hostName = hostName;
+    }
+
+    public String getModality() {
+        return modality;
+    }
+
+    public void setModality(String modality) {
+        this.modality = modality;
+    }
+
+    public String getPatientID() {
+        return patientID;
+    }
+
+    public void setPatientID(String patientID) {
+        this.patientID = patientID;
+    }
+
+    public String getPatientName() {
+        return patientName;
+    }
+
+    public void setPatientName(String patientName) {
+        this.patientName = patientName;
+    }
+
+    public int getPort() {
+        return port;
+    }
+
+    public void setPort(int port) {
+        this.port = port;
+    }
+    public String getStudyDate() {
+        return studyDate;
+    }
+    public void setStudyDate(String studyDate) {
+        this.studyDate = studyDate;
+    }
+
+    public String getStudyUID() {
+        return studyUID;
+    }
+
+    public void setStudyUID(String studyUID) {
+        this.studyUID = studyUID;
+    }
+
+    public String getWadoContext() {
+        return wadoContext;
+    }
+
+    public void setWadoContext(String wadoContext) {
+        this.wadoContext = wadoContext;
+    }
+
+    public int getWadoPort() {
+        return wadoPort;
+    }
+
+    public void setWadoPort(int wadoPort) {
+        this.wadoPort = wadoPort;
+    }
+
+    public String getWadoProtocol() {
+        return wadoProtocol;
+    }
+
+    public void setWadoProtocol(String wadoProtocol) {
+        this.wadoProtocol = wadoProtocol;
+    }
+
+    public String getFrom() {
+        return from;
+    }
+
+    public void setFrom(String from) {
+        this.from = from;
+    }
+
+    public String getTo() {
+        return to;
+    }
+
+    public void setTo(String to) {
+        this.to = to;
+    }
+
+    public String getSearchDate() {
+        String searchDate = "";
+        Date date = new Date();
+        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        String todayDate = dateFormat.format(date);
+        if (studyDate.equalsIgnoreCase("lastweek")) {
+            String lastWeek = getLastWeek();
+            lastWeek = lastWeek.replace("-", "");
+            todayDate = todayDate.replace("-", "");
+            searchDate = lastWeek + "-" + todayDate;
+
+        } else if (studyDate.equalsIgnoreCase("today")) {
+
+            todayDate = todayDate.replace("-", "");
+            searchDate = todayDate + "-" + todayDate;
+
+        } else if (studyDate.equalsIgnoreCase("lastmonth")) {
+            String lastMonth = getLastMonth();
+            lastMonth = lastMonth.replace("-", "");
+            todayDate = todayDate.replace("-", "");
+            searchDate = lastMonth + "-" + todayDate;
+
+        } else if (studyDate.equalsIgnoreCase("yesterday")) {
+            String yesterDay = getYesterday();
+            yesterDay = yesterDay.replace("-", "");
+            searchDate = yesterDay + "-" + yesterDay;
+
+        } else if (studyDate.equalsIgnoreCase("between")) {
+            from = from.replace("/", "");
+            to = to.replace("/", "");
+            from = from.replace("-", "");
+            to = to.replace("-", "");
+            searchDate = from + "-" + to;
+        } else {
+            searchDate = studyDate;
+        }
+        return searchDate;
+
+    }
+
+    public String getLastWeek() {
+        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        Calendar currDate = Calendar.getInstance();
+        currDate.add(Calendar.DATE, -7);
+        return dateFormat.format(currDate.getTime());
+    }
+
+    public String getLastMonth() {
+        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        Calendar currDate = Calendar.getInstance();
+        currDate.add(Calendar.DATE, -31);
+        return dateFormat.format(currDate.getTime());
+    }
+
+    public String getYesterday() {
+        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        Calendar currDate = Calendar.getInstance();
+        currDate.add(Calendar.DATE, -1);
+        return dateFormat.format(currDate.getTime());
+    }
+}
diff --git a/src/in/raster/mayam/model/Instance.java b/src/in/raster/mayam/model/Instance.java
new file mode 100644
index 0000000..b6075d0
--- /dev/null
+++ b/src/in/raster/mayam/model/Instance.java
@@ -0,0 +1,305 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.model;
+
+import in.raster.mayam.util.measurement.Annotation;
+import java.awt.image.BufferedImage;
+import java.io.Serializable;
+import java.util.HashMap;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class Instance implements Serializable {
+   
+    private String sop_iuid;
+    private String instance_no;
+    private String filepath;
+    private BufferedImage pixelData;
+    private Annotation annotation;
+
+    private String imagePosition;
+    private String imageOrientation;
+    private String pixelSpacing;
+    private String []imageType;
+    private int row;
+    private int column;
+    private String frameOfReferenceUID;
+    private String referenceSOPInstanceUID;
+    private boolean multiframe=false;
+    private int currentFrameNum;
+    private int totalNumFrames;
+    private int seriesLevelIndex;
+    private int instanceNumber;
+
+    private String sliceLocation;
+
+    private boolean encapsulatedPDF=false;
+
+    private HashMap<Integer,Annotation> annotations=null;
+
+
+    public Instance() {
+        sop_iuid = "";
+        instance_no = "";
+        filepath = "";
+        currentFrameNum=0;
+    }
+
+    /**
+     * @return the sop_iuid
+     */
+    public String getSop_iuid() {
+        return sop_iuid;
+    }
+
+    /**
+     * @param sop_iuid the sop_iuid to set
+     */
+    public void setSop_iuid(String sop_iuid) {
+        this.sop_iuid = sop_iuid;
+    }
+
+    /**
+     * @return the instance_no
+     */
+    public String getInstance_no() {
+        return instance_no;
+    }
+
+    /**
+     * @param instance_no the instance_no to set
+     */
+    public void setInstance_no(String instance_no) {
+        this.instance_no = instance_no;
+    }
+
+    /**
+     * @return the filepath
+     */
+    public String getFilepath() {
+        return filepath;
+    }
+
+    /**
+     * @param filepath the filepath to set
+     */
+    public void setFilepath(String filepath) {
+        this.filepath = filepath;
+    }
+
+    public BufferedImage getPixelData() {
+        return pixelData;
+    }
+
+    public void setPixelData(BufferedImage pixelData) {
+        this.pixelData = pixelData;
+    }
+
+    public Annotation getAnnotation() {
+        return annotation;
+    }
+
+    public void setAnnotation(Annotation annotation) {        
+        this.annotation = annotation;
+    }
+
+    public int getColumn() {
+        return column;
+    }
+
+    public String getFrameOfReferenceUID() {
+        return frameOfReferenceUID;
+    }
+
+    public String getImageOrientation() {
+        return imageOrientation;
+    }
+
+    public String getImagePosition() {
+        return imagePosition;
+    }
+
+    public String[] getImageType() {
+        return imageType;
+    }
+
+    public String getPixelSpacing() {
+        return pixelSpacing;
+    }
+
+    public String getReferenceSOPInstanceUID() {
+        return referenceSOPInstanceUID;
+    }
+
+    public int getRow() {
+        return row;
+    }
+
+    public void setColumn(int column) {
+        this.column = column;
+    }
+
+    public void setFrameOfReferenceUID(String frameOfReferenceUID) {
+        this.frameOfReferenceUID = frameOfReferenceUID;
+    }
+
+    public void setImageOrientation(String imageOrientation) {
+        this.imageOrientation = imageOrientation;
+    }
+
+    public void setImagePosition(String imagePosition) {
+        this.imagePosition = imagePosition;
+    }
+
+    public void setImageType(String[] imageType) {
+        this.imageType = imageType;
+    }
+
+    public void setPixelSpacing(String pixelSpacing) {
+        this.pixelSpacing = pixelSpacing;
+    }
+
+    public void setReferenceSOPInstanceUID(String referenceSOPInstanceUID) {
+        this.referenceSOPInstanceUID = referenceSOPInstanceUID;
+    }
+
+    public void setRow(int row) {
+        this.row = row;
+    }
+    public boolean isMultiframe() {
+        return multiframe;
+    }
+
+    public void setMultiframe(boolean multiframe) {
+        this.multiframe = multiframe;
+    }
+
+    public HashMap<Integer, Annotation> getAnnotations() {
+        return annotations;
+    }
+
+    public void setAnnotations(HashMap<Integer, Annotation> annotations) {
+        this.annotations = annotations;
+    }
+    /**
+     * This method used to add the annotation objects of the selected frame
+     * with the index value to the instance.
+     * @param index
+     * @param annotation
+     */
+    public void addMultiframeAnnotation(Integer index,Annotation annotation)
+    {
+        if(annotations==null)
+        annotations=new HashMap<Integer, Annotation>();
+
+        if(annotations.containsKey(index))
+        annotations.remove(index);
+        annotations.put(index, annotation);
+    }
+    /**
+     * This method used to get the annotation objects of the specified frame
+     * of the instance.
+     * @param index
+     * @return
+     */
+    public Annotation getMultiframeAnnotation(Integer index)
+    {
+        Annotation annotation=null;
+        if(annotations!=null)
+        {
+            if(annotations.containsKey(index))
+            annotation=annotations.get(index);
+        }
+
+        return annotation;
+    }
+
+    public int getCurrentFrameNum() {
+        return currentFrameNum;
+    }
+
+    public void setCurrentFrameNum(int currentFrameNum) {
+        this.currentFrameNum = currentFrameNum;
+    }
+
+    public int getTotalNumFrames() {
+        return totalNumFrames;
+    }
+
+    public void setTotalNumFrames(int totalNumFrames) {
+        this.totalNumFrames = totalNumFrames;
+    }
+
+    public int getSeriesLevelIndex() {
+        return seriesLevelIndex;
+    }
+
+    public void setSeriesLevelIndex(int seriesLevelIndex)
+    {
+        this.seriesLevelIndex=seriesLevelIndex;
+    }
+
+    public int getInstanceNumber() {
+        return instanceNumber;
+    }
+
+    public void setInstanceNumber(int instanceNumber) {
+        this.instanceNumber = instanceNumber;
+    }
+
+    public String getSliceLocation() {
+        return sliceLocation;
+    }
+
+    public void setSliceLocation(String sliceLocation) {
+        this.sliceLocation = sliceLocation;
+    }
+
+    public boolean isEncapsulatedPDF() {
+        return encapsulatedPDF;
+    }
+
+    public void setEncapsulatedPDF(boolean encapsulatedPDF) {
+        this.encapsulatedPDF = encapsulatedPDF;
+    }
+}
\ No newline at end of file
diff --git a/src/in/raster/mayam/model/PresetModel.java b/src/in/raster/mayam/model/PresetModel.java
new file mode 100644
index 0000000..44fbb86
--- /dev/null
+++ b/src/in/raster/mayam/model/PresetModel.java
@@ -0,0 +1,104 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.model;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class PresetModel {
+
+    private int pk;
+    private String presetName;
+    private String windowWidth;
+    private String windowLevel;
+    private int modalityFk;
+    
+    
+    public PresetModel() {
+    }
+
+    public int getPk() {
+        return pk;
+    }
+
+    public void setPk(int pk) {
+        this.pk = pk;
+    }
+
+    public String getPresetName() {
+        return presetName;
+    }
+
+    public void setPresetName(String presetName) {
+        this.presetName = presetName;
+    }
+
+    public String getWindowLevel() {
+        return windowLevel;
+    }
+
+    public void setWindowLevel(String windowLevel) {
+        this.windowLevel = windowLevel;
+    }
+
+    public String getWindowWidth() {
+        return windowWidth;
+    }
+
+    public void setWindowWidth(String windowWidth) {
+        this.windowWidth = windowWidth;
+    }
+
+    public int getModalityFk() {
+        return modalityFk;
+    }
+
+    public void setModalityFk(int modalityFk) {
+        this.modalityFk = modalityFk;
+    }
+
+    @Override
+    public String toString() {       
+        return this.presetName;
+    }  
+   
+}
diff --git a/src/in/raster/mayam/model/ScoutLineInfoModel.java b/src/in/raster/mayam/model/ScoutLineInfoModel.java
new file mode 100644
index 0000000..e3f5bb8
--- /dev/null
+++ b/src/in/raster/mayam/model/ScoutLineInfoModel.java
@@ -0,0 +1,170 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.model;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.6
+ *
+ */
+public class ScoutLineInfoModel {
+
+    private String scoutPosition;
+    private String scoutOrientation;
+    private String scoutPixelSpacing;
+    private String scoutRow;
+    private String scoutColumn;
+    private String scoutFrameofReferenceUID;
+
+    private String imagePosition;
+    private String imageOrientation;
+    private String imagePixelSpacing;
+    private int imageRow;
+    private int imageColumn;
+    private String imageFrameofReferenceUID;
+    private String imageReferenceSOPInstanceUID;
+
+    public ScoutLineInfoModel() {
+    }
+
+    public String getImageFrameofReferenceUID() {
+        return imageFrameofReferenceUID;
+    }
+
+    public void setImageFrameofReferenceUID(String imageFrameofReferenceUID) {
+        this.imageFrameofReferenceUID = imageFrameofReferenceUID;
+    }
+
+    public String getImageOrientation() {
+        return imageOrientation;
+    }
+
+    public void setImageOrientation(String imageOrientation) {
+        this.imageOrientation = imageOrientation;
+    }
+
+    public String getImagePixelSpacing() {
+        return imagePixelSpacing;
+    }
+
+    public void setImagePixelSpacing(String imagePixelSpacing) {
+        this.imagePixelSpacing = imagePixelSpacing;
+    }
+
+    public String getImagePosition() {
+        return imagePosition;
+    }
+
+    public void setImagePosition(String imagePosition) {
+        this.imagePosition = imagePosition;
+    }
+
+    public String getImageReferenceSOPInstanceUID() {
+        return imageReferenceSOPInstanceUID;
+    }
+
+    public void setImageReferenceSOPInstanceUID(String imageReferenceSOPInstanceUID) {
+        this.imageReferenceSOPInstanceUID = imageReferenceSOPInstanceUID;
+    }    
+
+    public String getScoutColumn() {
+        return scoutColumn;
+    }
+
+    public void setScoutColumn(String scoutColumn) {
+        this.scoutColumn = scoutColumn;
+    }
+
+    public String getScoutFrameofReferenceUID() {
+        return scoutFrameofReferenceUID;
+    }
+
+    public void setScoutFrameofReferenceUID(String scoutFrameofReferenceUID) {
+        this.scoutFrameofReferenceUID = scoutFrameofReferenceUID;
+    }
+
+    public String getScoutOrientation() {
+        return scoutOrientation;
+    }
+
+    public void setScoutOrientation(String scoutOrientation) {
+        this.scoutOrientation = scoutOrientation;
+    }
+
+    public String getScoutPixelSpacing() {
+        return scoutPixelSpacing;
+    }
+
+    public void setScoutPixelSpacing(String scoutPixelSpacing) {
+        this.scoutPixelSpacing = scoutPixelSpacing;
+    }
+
+    public String getScoutPosition() {
+        return scoutPosition;
+    }
+
+    public void setScoutPosition(String scoutPosition) {
+        this.scoutPosition = scoutPosition;
+    }
+
+    public String getScoutRow() {
+        return scoutRow;
+    }
+
+    public void setScoutRow(String scoutRow) {
+        this.scoutRow = scoutRow;
+    }
+
+    public int getImageColumn() {
+        return imageColumn;
+    }
+
+    public void setImageColumn(int imageColumn) {
+        this.imageColumn = imageColumn;
+    }
+
+    public int getImageRow() {
+        return imageRow;
+    }
+
+    public void setImageRow(int imageRow) {
+        this.imageRow = imageRow;
+    }
+}
diff --git a/src/in/raster/mayam/model/Series.java b/src/in/raster/mayam/model/Series.java
new file mode 100644
index 0000000..81ba0de
--- /dev/null
+++ b/src/in/raster/mayam/model/Series.java
@@ -0,0 +1,206 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.model;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import org.dcm4che.data.Dataset;
+import org.dcm4che.dict.Tags;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class Series implements Serializable {
+
+    private String SeriesInstanceUID;
+    private String StudyInstanceUID;
+    private String SeriesNumber;
+    private String Modality;
+    private String institutionName;
+    private List<Instance> imageList;
+    private String seriesDesc;
+    private String bodyPartExamined;
+    private int seriesRelatedInstance;
+    private boolean multiframe;
+    private String instanceUID;
+
+    public Series() {
+        SeriesInstanceUID = "";
+        StudyInstanceUID="";
+        Modality = "";
+        SeriesNumber = "";
+        seriesDesc="";
+        multiframe=false;
+        instanceUID="";
+        imageList = new ArrayList<Instance>();
+    }
+    public Series(Dataset dataset)
+    {
+        this.SeriesInstanceUID=dataset.getString(Tags.SeriesInstanceUID);
+        this.StudyInstanceUID=dataset.getString(Tags.StudyInstanceUID);
+        this.SeriesNumber=dataset.getString(Tags.SeriesNumber)!=null ? dataset.getString(Tags.SeriesNumber):"";
+        this.Modality=dataset.getString(Tags.Modality);
+        this.bodyPartExamined=dataset.getString(Tags.BodyPartExamined);
+        this.seriesDesc=dataset.getString(Tags.SeriesDescription)!=null ?dataset.getString(Tags.SeriesDescription): "";
+        this.institutionName=dataset.getString(Tags.InstitutionName)!=null ?dataset.getString(Tags.InstitutionName):"";
+
+    }
+
+    /**
+     * @return the SeriesInstanceUID
+     */
+    public String getSeriesInstanceUID() {
+        return SeriesInstanceUID;
+    }
+
+    /**
+     * @param SeriesInstanceUID the SeriesInstanceUID to set
+     */
+    public void setSeriesInstanceUID(String SeriesInstanceUID) {
+        this.SeriesInstanceUID = SeriesInstanceUID;
+    }
+
+    /**
+     * @return the Modality
+     */
+    public String getModality() {
+        return Modality;
+    }
+
+    /**
+     * @param Modality the Modality to set
+     */
+    public void setModality(String Modality) {
+        this.Modality = Modality;
+    }
+
+   
+    /**
+     * 
+     * @param image
+     */
+    public void addImage(Instance image) {
+        this.imageList.add(image);
+    }    
+   
+
+    public String getSeriesNumber() {
+        return SeriesNumber;
+    }
+    /**
+     * 
+     * @param seriesNumber
+     */
+    public void setSeriesNumber(String seriesNumber) {
+        SeriesNumber = seriesNumber;
+    }   
+   
+    /**
+     * @return the imageList
+     */
+    public List<Instance> getImageList() {
+        return imageList;
+    }
+
+    /**
+     * @param imageList the imageList to set
+     */
+    public void setImageList(List<Instance> imageList) {
+        this.imageList = imageList;
+    }
+
+    public String getStudyInstanceUID() {
+        return StudyInstanceUID;
+    }
+
+    public void setStudyInstanceUID(String StudyInstanceUID) {
+        this.StudyInstanceUID = StudyInstanceUID;
+    }
+
+    public String getSeriesDesc() {
+        return seriesDesc;
+    }
+
+    public void setSeriesDesc(String seriesDesc) {
+        this.seriesDesc = seriesDesc;
+    }
+
+    public String getInstitutionName() {
+        return institutionName;
+    }
+
+    public void setInstitutionName(String institutionName) {
+        this.institutionName = institutionName;
+    }
+
+    public int getSeriesRelatedInstance() {
+        return seriesRelatedInstance;
+    }
+
+    public void setSeriesRelatedInstance(int seriesRelatedInstance) {
+        this.seriesRelatedInstance = seriesRelatedInstance;
+    }
+
+    public String getBodyPartExamined() {
+        return bodyPartExamined;
+    }
+
+    public void setBodyPartExamined(String bodyPartExamined) {
+        this.bodyPartExamined = bodyPartExamined;
+    }
+    public String getInstanceUID() {
+        return instanceUID;
+    }
+
+    public void setInstanceUID(String instanceUID) {
+        this.instanceUID = instanceUID;
+    }
+
+    public boolean isMultiframe() {
+        return multiframe;
+    }
+
+    public void setMultiframe(boolean multiframe) {
+        this.multiframe = multiframe;
+    }
+}
\ No newline at end of file
diff --git a/src/in/raster/mayam/model/ServerModel.java b/src/in/raster/mayam/model/ServerModel.java
new file mode 100644
index 0000000..07a01bb
--- /dev/null
+++ b/src/in/raster/mayam/model/ServerModel.java
@@ -0,0 +1,156 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.model;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class ServerModel {
+
+    private int pk;
+    private String serverName;
+    private String hostName;
+    private int port;
+    private String aeTitle;
+    private String retrieveType;
+    private int wadoPort;
+    private String wadoContextPath;
+    private String wadoProtocol;
+    private String retrieveTransferSyntax;
+    
+    public ServerModel() {
+    }
+
+    public ServerModel(String serverName,String host,String aeTitle,int port,String retrieveType,String wadoContext,int wadoPort,String wadoProtocol,String retrieveTS)
+    {
+        this.serverName=serverName;
+        this.hostName=host;
+        this.aeTitle=aeTitle;
+        this.port=port;
+        this.retrieveType=retrieveType;
+        this.wadoContextPath=wadoContext;
+        this.wadoPort=wadoPort;
+        this.wadoProtocol=wadoProtocol;
+        this.retrieveTransferSyntax=retrieveTS;
+    }
+    public int getPk() {
+        return pk;
+    }
+
+    public void setPk(int pk) {
+        this.pk = pk;
+    }
+
+    public String getAeTitle() {
+        return aeTitle;
+    }
+
+    public void setAeTitle(String aeTitle) {
+        this.aeTitle = aeTitle;
+    }
+
+    public String getHostName() {
+        return hostName;
+    }
+
+    public void setHostName(String hostName) {
+        this.hostName = hostName;
+    }
+
+    public int getPort() {
+        return port;
+    }
+
+    public void setPort(int port) {
+        this.port = port;
+    }
+
+    public String getServerName() {
+        return serverName;
+    }
+
+    public void setServerName(String serverName) {
+        this.serverName = serverName;
+    }
+
+    public String getRetrieveType() {
+        return retrieveType;
+    }
+
+    public void setRetrieveType(String retrieveType) {
+        this.retrieveType = retrieveType;
+    }
+
+    public int getWadoPort() {
+        return wadoPort;
+    }
+
+    public void setWadoPort(int wadoPort) {
+        this.wadoPort = wadoPort;
+    }
+
+    public String getWadoContextPath() {
+        return wadoContextPath;
+    }
+
+    public void setWadoContextPath(String wadoContextPath) {
+        this.wadoContextPath = wadoContextPath;
+    }
+
+    public String getRetrieveTransferSyntax() {
+        return retrieveTransferSyntax;
+    }
+
+    public void setRetrieveTransferSyntax(String retrieveTransferSyntax) {
+        this.retrieveTransferSyntax = retrieveTransferSyntax;
+    }
+
+    public String getWadoProtocol() {
+        return wadoProtocol;
+    }
+
+    public void setWadoProtocol(String wadoProtocol) {
+        this.wadoProtocol = wadoProtocol;
+    }
+
+
+}
diff --git a/src/in/raster/mayam/model/Study.java b/src/in/raster/mayam/model/Study.java
new file mode 100644
index 0000000..f1e6f69
--- /dev/null
+++ b/src/in/raster/mayam/model/Study.java
@@ -0,0 +1,133 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.model;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class Study implements Serializable {
+
+    private String studyInstanceUID;
+    private String studyDate;
+    private String studyDesc;
+    private String modalityInStudy;
+    private String studyID;
+    private List<Series> seriesList;
+
+    public Study() {
+        studyInstanceUID = "";
+        studyDate = "";
+        studyDesc = "";
+        studyID = "";
+        seriesList = new ArrayList<Series>();
+    }
+
+    public Study(String siuid) {
+        studyInstanceUID = siuid;
+        studyDate = "";
+        studyDesc = "";
+        studyID = "";
+        seriesList = new ArrayList<Series>();
+    }
+
+    public String getModalityInStudy() {
+        return modalityInStudy;
+    }
+
+    public void setModalityInStudy(String modalityInStudy) {
+        this.modalityInStudy = modalityInStudy;
+    }
+
+    public List<Series> getSeriesList() {
+        return seriesList;
+    }
+
+    public void setSeriesList(List<Series> seriesList) {
+        this.seriesList = seriesList;
+    }
+
+    public String getStudyDate() {
+        return studyDate;
+    }
+
+    public void setStudyDate(String studyDate) {
+        this.studyDate = studyDate;
+    }
+
+    public String getStudyDesc() {
+        return studyDesc;
+    }
+
+    public void setStudyDesc(String studyDesc) {
+        this.studyDesc = studyDesc;
+    }
+
+    public String getStudyID() {
+        return studyID;
+    }
+
+    public void setStudyID(String studyID) {
+        this.studyID = studyID;
+    }
+
+    public String getStudyInstanceUID() {
+        return studyInstanceUID;
+    }
+
+    public void setStudyInstanceUID(String studyInstanceUID) {
+        this.studyInstanceUID = studyInstanceUID;
+    }
+
+    public void addSeries(Series series) {
+        if(this.seriesList==null)
+        this.seriesList= new ArrayList<Series>();
+        this.seriesList.add(series);
+    }
+    public void removeSeries(Series series)
+    {
+        this.seriesList.remove(series);
+    }
+}
diff --git a/src/in/raster/mayam/model/StudyModel.java b/src/in/raster/mayam/model/StudyModel.java
new file mode 100644
index 0000000..9868990
--- /dev/null
+++ b/src/in/raster/mayam/model/StudyModel.java
@@ -0,0 +1,160 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.model;
+
+import org.dcm4che.data.Dataset;
+import org.dcm4che.dict.Tags;
+import org.dcm4che2.data.Tag;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class StudyModel {
+
+    private String patientId;
+    private String patientName;
+    private String dob;
+    private String accessionNo;
+    private String studyDate;
+    private String studyDescription;
+    private String modalitiesInStudy;
+    private String studyUID;
+    private String[] modality;
+    private String studyLevelInstances;
+
+    public StudyModel() {
+    }
+
+    public StudyModel(Dataset dataSet) {
+        studyUID = dataSet.getString(Tags.StudyInstanceUID);
+        studyDescription = dataSet.getString(Tags.StudyDescription) != null ? dataSet.getString(Tags.StudyDescription) : "";
+        studyDate = dataSet.getString(Tags.StudyDate) != null ? dataSet.getString(Tags.StudyDate) : "unknown";
+        modality = dataSet.getStrings(Tags.ModalitiesInStudy) != null ? dataSet.getStrings(Tags.ModalitiesInStudy) : null;
+        if (modality != null) {
+            for (int i = 0; i < modality.length; i++) {
+                if (i == 0) {
+                    modalitiesInStudy = modality[i];
+                } else {
+                    modalitiesInStudy += "\\" + modality[i];
+                }
+            }
+        }
+        // modalitiesInStudy = dataSet.getString(Tags.ModalitiesInStudy) != null ? dataSet.getString(Tags.ModalitiesInStudy) : "";
+        patientName = dataSet.getString(Tags.PatientName) != null ? dataSet.getString(Tags.PatientName) : "";
+        patientId = dataSet.getString(Tags.PatientID) != null ? dataSet.getString(Tags.PatientID) : "";
+        dob = dataSet.getString(Tags.PatientBirthDate) != null ? dataSet.getString(Tags.PatientBirthDate) : "";
+        accessionNo = dataSet.getString(Tag.AccessionNumber) != null ? dataSet.getString(Tag.AccessionNumber) : "";
+        studyLevelInstances = dataSet.getString(Tag.NumberOfStudyRelatedInstances) != null ? dataSet.getString(Tag.NumberOfStudyRelatedInstances) : "";
+    }
+
+    public String getAccessionNo() {
+        return accessionNo;
+    }
+
+    public void setAccessionNo(String accessionNo) {
+        this.accessionNo = accessionNo;
+    }
+
+    public String getStudyUID() {
+        return studyUID;
+    }
+
+    public void setStudyUID(String studyUID) {
+        this.studyUID = studyUID;
+    }
+
+    public String getDob() {
+        return dob;
+    }
+
+    public String getModalitiesInStudy() {
+        return modalitiesInStudy;
+    }
+
+    public void setModalitiesInStudy(String modalitiesInStudy) {
+        this.modalitiesInStudy = modalitiesInStudy;
+    }
+
+    public void setDob(String dob) {
+        this.dob = dob;
+    }
+
+    public String getPatientId() {
+        return patientId;
+    }
+
+    public void setPatientId(String patientId) {
+        this.patientId = patientId;
+    }
+
+    public String getPatientName() {
+        return patientName;
+    }
+
+    public void setPatientName(String patientName) {
+        this.patientName = patientName;
+    }
+
+    public String getStudyDate() {
+        return studyDate;
+    }
+
+    public void setStudyDate(String studyDate) {
+        this.studyDate = studyDate;
+    }
+
+    public String getStudyDescription() {
+        return studyDescription;
+    }
+
+    public void setStudyDescription(String studyDescription) {
+        this.studyDescription = studyDescription;
+    }
+
+    public String getStudyLevelInstances() {
+        return studyLevelInstances;
+    }
+
+    public void setStudyLevelInstances(String studyLevelInstances) {
+        this.studyLevelInstances = studyLevelInstances;
+    }
+}
diff --git a/src/in/raster/mayam/model/combo/ModalityComboModel.java b/src/in/raster/mayam/model/combo/ModalityComboModel.java
new file mode 100644
index 0000000..d088da4
--- /dev/null
+++ b/src/in/raster/mayam/model/combo/ModalityComboModel.java
@@ -0,0 +1,83 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.model.combo;
+
+
+import javax.swing.AbstractListModel;
+import javax.swing.ComboBoxModel;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class ModalityComboModel extends AbstractListModel implements ComboBoxModel {
+
+    String modalities[];
+    String selection=null;
+    public ModalityComboModel(String mod[]) {
+        modalities=mod;
+    }
+
+    public ModalityComboModel()
+    {
+
+    }
+    public void setModalities(String mod[])
+    {
+        modalities=mod;
+    }
+    public int getSize() {
+       return modalities.length;
+    }
+
+    public Object getElementAt(int index) {
+        return modalities[index];
+    }
+
+    public void setSelectedItem(Object anItem) {
+        selection=(String)anItem;
+    }
+
+    public Object getSelectedItem() {
+        return selection;
+    }
+  
+}
diff --git a/src/in/raster/mayam/model/combo/TransferSyntaxModel.java b/src/in/raster/mayam/model/combo/TransferSyntaxModel.java
new file mode 100644
index 0000000..898e01c
--- /dev/null
+++ b/src/in/raster/mayam/model/combo/TransferSyntaxModel.java
@@ -0,0 +1,81 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.model.combo;
+
+import javax.swing.AbstractListModel;
+import javax.swing.ComboBoxModel;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.7
+ *
+ */
+public class TransferSyntaxModel extends AbstractListModel implements ComboBoxModel {
+
+    private String[] transferSyntaxArray;
+    private String selection = null;
+
+    public TransferSyntaxModel(String[] transferSyntaxArray) {
+        this.transferSyntaxArray = transferSyntaxArray;
+        selection = transferSyntaxArray[0];
+    }
+
+    public void setTrasferSyntaxArray(String[] transferSyntaxArray) {
+        this.transferSyntaxArray = transferSyntaxArray;
+    }
+
+    public int getSize() {
+        return this.transferSyntaxArray.length;
+    }
+
+    public Object getElementAt(int index) {
+        return transferSyntaxArray[index];
+    }
+
+    public void setSelectedItem(Object anItem) {
+        if (!anItem.toString().equalsIgnoreCase("")) {
+            selection = anItem.toString();
+        }
+    }
+
+    public String getSelectedItem() {
+        return selection;
+    }
+}
diff --git a/src/in/raster/mayam/model/combo/WindowingComboModel.java b/src/in/raster/mayam/model/combo/WindowingComboModel.java
new file mode 100644
index 0000000..04e271c
--- /dev/null
+++ b/src/in/raster/mayam/model/combo/WindowingComboModel.java
@@ -0,0 +1,83 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.model.combo;
+
+import java.util.ArrayList;
+import javax.swing.AbstractListModel;
+import javax.swing.ComboBoxModel;
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class WindowingComboModel extends AbstractListModel implements ComboBoxModel {
+
+    ArrayList presets=new ArrayList();
+    String selection="Default";
+    
+
+    public WindowingComboModel(ArrayList presets) {
+        this.presets=presets;
+    }
+
+    public WindowingComboModel()
+    {
+
+    }
+    public void setPresets(ArrayList presets)
+    {
+        this.presets=presets;
+    }
+    public int getSize() {
+       return presets.size();
+    }
+
+    public Object getElementAt(int index) {      
+        return presets.get(index).toString();
+    }
+
+    public void setSelectedItem(Object anItem) {
+        selection=anItem.toString();
+    }
+
+    public Object getSelectedItem() {
+        return selection;
+    }  
+}
diff --git a/src/in/raster/mayam/model/table/PresetTableModel.java b/src/in/raster/mayam/model/table/PresetTableModel.java
new file mode 100644
index 0000000..04a86ee
--- /dev/null
+++ b/src/in/raster/mayam/model/table/PresetTableModel.java
@@ -0,0 +1,140 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.model.table;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.model.PresetModel;
+import java.util.ArrayList;
+import javax.swing.table.AbstractTableModel;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class PresetTableModel extends AbstractTableModel {
+
+    String columnName[] = {"Preset Name", "Window Level", "Window Width"};
+    Class columnType[] = {String.class, String.class, String.class};
+    ArrayList presetList;
+
+    public PresetTableModel() {
+    }
+
+    public void setData(ArrayList v) {
+        presetList = v;
+    }
+
+    public int getColumnCount() {
+        return columnName.length;
+    }
+
+    public int getRowCount() {
+        if (presetList != null) {
+            return presetList.size();
+        } else {
+            return 0;
+        }
+    }
+
+    public ArrayList getStudyList() {
+        return presetList;
+    }
+
+    public String getValueAt(int nRow, int nCol) {
+        if (nRow < 0 || nRow >= getRowCount()) {
+            return "";
+        }
+        PresetModel row = (PresetModel) presetList.get(nRow);
+        switch (nCol) {
+            case 0:
+                return row.getPresetName();
+            case 1:
+                return row.getWindowLevel();
+            case 2:
+                return row.getWindowWidth();
+
+        }
+        return "";
+    }
+
+    public String getColumnName(int column) {
+        return columnName[column];
+    }
+
+    public Class getColumnClass(int c) {
+        return columnType[c];
+    }
+
+    public boolean isCellEditable(int r, int c) {
+        return true;
+    }
+
+    public PresetModel getRow(int r) {
+        return (PresetModel) presetList.get(r);
+    }
+
+    public void setValueAt(Object aValue, int r, int c) {
+        PresetModel row = (PresetModel) presetList.get(r);
+        switch (c) {
+            case 0:
+                row.setPresetName(aValue.toString());
+                ApplicationContext.databaseRef.updatePresetValues(row);
+                break;
+            case 1:
+                try {
+                    int level = Integer.parseInt(aValue.toString());
+
+                    row.setWindowLevel(Integer.toString(level));
+                    ApplicationContext.databaseRef.updatePresetValues(row);
+                } catch (Exception e) {e.printStackTrace();
+                }
+                break;
+            case 2:
+                try {
+                    int width = Integer.parseInt(aValue.toString());
+                    row.setWindowWidth(Integer.toString(width));
+                    ApplicationContext.databaseRef.updatePresetValues(row);
+                } catch (Exception e) {e.printStackTrace();
+                }
+                break;
+        }
+    }
+}
diff --git a/src/in/raster/mayam/model/table/SeriesListModel.java b/src/in/raster/mayam/model/table/SeriesListModel.java
new file mode 100644
index 0000000..ee80f0a
--- /dev/null
+++ b/src/in/raster/mayam/model/table/SeriesListModel.java
@@ -0,0 +1,118 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.model.table;
+
+import in.raster.mayam.model.Series;
+import java.util.Vector;
+import javax.swing.table.AbstractTableModel;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class SeriesListModel extends AbstractTableModel {
+
+    String columnName[] = {"Series Description", "Series#", "Modality", "Instance Count", "Institution Name"};
+    Class columnType[] = {String.class, String.class, String.class, String.class, String.class};
+    Vector seriesList;
+
+    public SeriesListModel() {
+    }
+
+    public void setData(Vector v) {
+        seriesList = v;
+    }
+
+    public int getColumnCount() {
+        return columnName.length;
+    }
+
+    public int getRowCount() {
+        if (seriesList != null) {
+            return seriesList.size();
+        } else {
+            return 0;
+        }
+    }
+
+    public Vector getStudyList() {
+        return seriesList;
+    }
+
+    public String getValueAt(int nRow, int nCol) {
+        if (nRow < 0 || nRow >= getRowCount()) {
+            return "";
+        }
+        Series row = (Series) seriesList.elementAt(nRow);
+        switch (nCol) {
+            case 0:
+                return row.getSeriesDesc();
+            case 1:
+                return row.getSeriesNumber();
+            case 2:
+                return row.getModality();
+            case 3:
+                return Integer.toString(row.getSeriesRelatedInstance());
+            case 4:
+                return row.getInstitutionName();
+            case 5:
+                return row.getSeriesInstanceUID();
+            case 6:
+                return row.getStudyInstanceUID();
+        }
+        return "";
+    }
+
+    public String getColumnName(int column) {
+        return columnName[column];
+    }
+
+    public Class getColumnClass(int c) {
+        return columnType[c];
+    }
+
+    public boolean isCellEditable(int r, int c) {
+        return false;
+    }
+
+    public void setValueAt(Object aValue, int r, int c) {
+    }
+}
diff --git a/src/in/raster/mayam/model/table/ServerTableModel.java b/src/in/raster/mayam/model/table/ServerTableModel.java
new file mode 100644
index 0000000..558c9a2
--- /dev/null
+++ b/src/in/raster/mayam/model/table/ServerTableModel.java
@@ -0,0 +1,195 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.model.table;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.form.ServerChangeListener;
+import in.raster.mayam.form.dialog.WadoInformation;
+import in.raster.mayam.model.ServerModel;
+import java.util.ArrayList;
+import javax.swing.table.AbstractTableModel;
+import org.dcm4che2.data.TransferSyntax;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class ServerTableModel extends AbstractTableModel {
+
+    private boolean editable = true;
+    String columnName[] = {"Description", "AE Title", "Host Name", "Port", "Retrieve Type"};
+    Class columnType[] = {String.class, String.class, String.class, String.class, String.class};
+    ArrayList serverList;
+    ServerChangeListener listener = null;
+
+    public ServerTableModel() {
+    }
+
+    public void setData(ArrayList v) {
+        serverList = v;
+    }
+
+    public int getColumnCount() {
+        return columnName.length;
+    }
+
+    public int getRowCount() {
+        if (serverList != null) {
+            return serverList.size();
+        } else {
+            return 0;
+        }
+    }
+
+    public ArrayList getStudyList() {
+        return serverList;
+    }
+
+    public String getValueAt(int nRow, int nCol) {
+        if (nRow < 0 || nRow >= getRowCount()) {
+            return "";
+        }
+        ServerModel row = (ServerModel) serverList.get(nRow);
+        switch (nCol) {
+            case 0:
+                return row.getServerName();
+            case 1:
+                return row.getAeTitle();
+            case 2:
+                return row.getHostName();
+            case 3:
+                return Integer.toString(row.getPort());
+            case 4:
+                return row.getRetrieveType();
+        }
+        return "";
+    }
+
+    public String getColumnName(int column) {
+        return columnName[column];
+    }
+
+    public Class getColumnClass(int c) {
+        return columnType[c];
+    }
+
+    public boolean isCellEditable(int r, int c) {
+        return editable;
+    }
+
+    public ServerModel getRow(int r) {
+        return (ServerModel) serverList.get(r);
+    }
+
+    public void setValueAt(Object aValue, int r, int c) {
+        ServerModel row = (ServerModel) serverList.get(r);
+        switch (c) {
+            case 0:
+                row.setServerName(aValue.toString());
+                ApplicationContext.databaseRef.updateServerListValues(row);
+                break;
+            case 1:
+                try {
+                    row.setAeTitle(aValue.toString());
+                    ApplicationContext.databaseRef.updateServerListValues(row);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+                break;
+            case 2:
+                try {
+                    row.setHostName(aValue.toString());
+                    ApplicationContext.databaseRef.updateServerListValues(row);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+                break;
+            case 3:
+                try {
+                    int port = Integer.parseInt(aValue.toString());
+                    row.setPort(port);
+                    ApplicationContext.databaseRef.updateServerListValues(row);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+                break;
+            case 4:
+                try {
+                    row.setRetrieveType(aValue.toString());
+                    if (row.getRetrieveType().equalsIgnoreCase("WADO")) {
+                        WadoInformation wadoInformation = new WadoInformation(null, true, row);
+                        wadoInformation.setLocationRelativeTo(ApplicationContext.mainScreen);
+                        wadoInformation.setVisible(true);
+                    } else {
+                        row.setWadoContextPath("wado");
+                        row.setWadoPort(0);
+                        row.setWadoProtocol("http");
+                        row.setRetrieveTransferSyntax("Explicit VR Little Endian");
+                    }
+                    ApplicationContext.databaseRef.updateServerListValues(row);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+
+        }
+        if (listener != null) {
+            listener.onServerChange();
+        }
+
+
+    }
+
+    public boolean isEditable() {
+        return editable;
+    }
+
+    public void setEditable(boolean editable) {
+        this.editable = editable;
+    }
+
+    public void addChangeListener(ServerChangeListener listener) {
+        this.listener = listener;
+    }
+
+    public ServerChangeListener getListener() {
+        return this.listener;
+    }
+}
diff --git a/src/in/raster/mayam/model/table/StudyListModel.java b/src/in/raster/mayam/model/table/StudyListModel.java
new file mode 100644
index 0000000..a283232
--- /dev/null
+++ b/src/in/raster/mayam/model/table/StudyListModel.java
@@ -0,0 +1,123 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.model.table;
+
+import in.raster.mayam.model.StudyModel;
+import java.util.Vector;
+import javax.swing.table.AbstractTableModel;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class StudyListModel extends AbstractTableModel {
+
+    String columnName[] = {"Patient ID", "Patient Name", "Date of Birth", "Accession Number", "Study Date", "Study Description", "Modality", "Instance Count"};
+    Class columnType[] = {String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class};
+    Vector studyList;
+
+    public StudyListModel() {
+    }
+
+    public void setData(Vector v) {
+        studyList = v;
+        super.fireTableDataChanged();
+    }
+
+    public int getColumnCount() {
+        return columnName.length;
+    }
+
+    public int getRowCount() {
+        if (studyList != null) {
+            return studyList.size();
+        } else {
+            return 0;
+        }
+    }
+
+    public Vector getStudyList() {
+        return studyList;
+    }
+
+    public String getValueAt(int nRow, int nCol) {
+        if (nRow < 0 || nRow >= getRowCount()) {
+            return "";
+        }
+        StudyModel row = (StudyModel) studyList.elementAt(nRow);
+        switch (nCol) {
+            case 0:
+                return row.getPatientId();
+            case 1:
+                return row.getPatientName();
+            case 2:
+                return row.getDob();
+            case 3:
+                return row.getAccessionNo();
+            case 4:
+                return row.getStudyDate();
+            case 5:
+                return row.getStudyDescription();
+            case 6:
+                return row.getModalitiesInStudy();
+            case 7:
+                return row.getStudyLevelInstances();
+            case 8:
+                return row.getStudyUID();
+        }
+        return "";
+    }
+
+    public String getColumnName(int column) {
+        return columnName[column];
+    }
+
+    public Class getColumnClass(int c) {
+        return columnType[c];
+    }
+
+    public boolean isCellEditable(int r, int c) {
+        return false;
+    }
+
+    public void setValueAt(Object aValue, int r, int c) {
+    }
+}
diff --git a/src/in/raster/mayam/model/table/TagsTableDataModel.java b/src/in/raster/mayam/model/table/TagsTableDataModel.java
new file mode 100644
index 0000000..4b894eb
--- /dev/null
+++ b/src/in/raster/mayam/model/table/TagsTableDataModel.java
@@ -0,0 +1,116 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.model.table;
+
+import in.raster.mayam.util.DicomTags;
+import java.util.ArrayList;
+import javax.swing.table.AbstractTableModel;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class TagsTableDataModel extends AbstractTableModel {
+
+    String columnName[] = { "Tag","Name","VR","Length","VM","Value"};
+
+    Class columnType[]={String.class, String.class, String.class, String.class, String.class, String.class };
+
+    ArrayList tagsList;
+
+    public TagsTableDataModel() {
+    }
+
+    public void setData(ArrayList v){
+        tagsList=v;
+    }
+
+    public ArrayList getTagsList(){
+        return tagsList;
+    }
+
+    public int getRowCount() {
+        if (tagsList!=null)
+            return tagsList.size();
+        else
+            return 0;
+
+    }
+
+    public int getColumnCount() {
+        return columnName.length;
+    }
+
+    public String getValueAt(int rowIndex, int columnIndex) {
+
+        if (rowIndex < 0 || rowIndex >= getRowCount()) {
+            return "";
+        }
+        DicomTags row = (DicomTags) tagsList.get(rowIndex);
+
+        switch (columnIndex) {
+            case 0:
+                return row.getTag();
+
+            case 1:
+                return row.getTagName();
+
+            case 2:
+                return row.getVR();
+
+            case 3:
+                return row.getTagLength();
+
+            case 4:
+                return row.getVM();
+
+            case 5:
+                return row.getTagValue();
+
+        }
+
+        return "";
+    }
+    
+    public String getColumnName(int column){
+        return columnName[column];
+    }
+}
diff --git a/src/in/raster/mayam/model/table/renderer/CellRenderer.java b/src/in/raster/mayam/model/table/renderer/CellRenderer.java
new file mode 100644
index 0000000..7198be5
--- /dev/null
+++ b/src/in/raster/mayam/model/table/renderer/CellRenderer.java
@@ -0,0 +1,84 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.model.table.renderer;
+
+import java.awt.Color;
+import java.awt.Component;
+import javax.swing.JTable;
+import javax.swing.table.DefaultTableCellRenderer;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class CellRenderer extends DefaultTableCellRenderer {
+
+    private Color whiteColor = new Color(254, 254, 254);
+    private Color alternateColor = new Color(237, 243, 254);   
+    private Color selectedColor = new Color(142,104,104);
+   
+    public Component getTableCellRendererComponent(JTable table,
+            Object value, boolean selected, boolean focused,
+            int row, int column) {
+        super.getTableCellRendererComponent(table, value,
+                selected, false, row, column);
+
+        // Set the background color
+        Color bg;
+        if (!selected) {
+            bg = (row % 2 == 0 ? alternateColor : whiteColor);
+        } else {
+            bg = selectedColor;
+        }
+        setBackground(bg);
+
+        // Set the foreground to white when selected
+        Color fg;
+        if (selected) {
+            fg = Color.white;
+        } else {
+            fg = Color.black;
+        }
+        setForeground(fg);
+
+        return this;
+    }
+}
diff --git a/src/in/raster/mayam/model/table/renderer/HeaderRenderer.java b/src/in/raster/mayam/model/table/renderer/HeaderRenderer.java
new file mode 100644
index 0000000..4c18f43
--- /dev/null
+++ b/src/in/raster/mayam/model/table/renderer/HeaderRenderer.java
@@ -0,0 +1,62 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.model.table.renderer;
+
+import java.awt.Component;
+import javax.swing.JTable;
+import javax.swing.UIManager;
+import javax.swing.table.DefaultTableCellRenderer;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class HeaderRenderer extends DefaultTableCellRenderer {
+
+    public Component getTableCellRendererComponent(JTable table,
+            Object value, boolean selected, boolean focused,
+            int row, int column) {
+        super.getTableCellRendererComponent(table, value,
+                selected, focused, row, column);
+        setBorder(UIManager.getBorder("TableHeader.cellBorder"));           
+        return this;
+    }
+}
diff --git a/src/in/raster/mayam/param/QueryParam.java b/src/in/raster/mayam/param/QueryParam.java
new file mode 100644
index 0000000..80c98b4
--- /dev/null
+++ b/src/in/raster/mayam/param/QueryParam.java
@@ -0,0 +1,289 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.param;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class QueryParam {
+
+    private String patientId = "";
+    private String patientName = "";
+    private String birthDate = "";
+    private String searchDate = "";
+    private String modality = "";
+    private String from = "";
+    private String to = "";
+    private String searchDays="Anydate";
+    private String accessionNo="";
+    Date date = new Date();
+    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+    String s = dateFormat.format(date);
+
+    public QueryParam() {
+    }
+
+    /**
+     * Setter for property patientId.
+     * @param patientId The String object registers the patientId.
+     */
+    public void setPatientId(String patientId) {
+        if (patientId == null) {
+            this.patientId = "";
+        } else {
+            this.patientId = patientId;
+        }
+    }
+
+    /**
+     * Setter for property patientName.
+     * @param patientName The String object registers the patientName.
+     */
+    public void setPatientName(String patientName) {
+        if (patientName == null) {
+            this.patientName = "";
+        } else {
+            this.patientName = patientName;
+        }
+    }
+
+    /**
+     * Setter for property birthDate.
+     * @param birthDate The String object registers the birthDate. 
+     */
+    public void setBirthDate(String birthDate) {
+        if (birthDate == null) {
+            this.birthDate = "";
+        } else {
+            this.birthDate = birthDate;
+        }
+    }
+
+    /**
+     * Setter for property searchDate.
+     * @param searchDate The String object registers the searchDate.
+     */
+    public void setSearchDate(String searchDate) {
+        if (searchDate == null) {
+            this.searchDate = "";
+        } else {
+            this.searchDate = searchDate;
+        }
+    }
+
+    /**
+     * Setter for property modality.
+     * @param modality The String object registers the modality.
+     */
+    public void setModality(String modality) {
+        if (modality == null) {
+            this.modality = "";
+        } else {
+            this.modality = modality;
+        }
+    }
+
+    /**
+     * Setter for property to.
+     * @param to The String object registers the to.
+     */
+    public void setTo(String to) {
+        if (to == null) {
+            this.to = "";
+        } else {
+            this.to = to;
+        }
+    }
+
+    /**
+     * Setter for property from
+     * @param from The String object registers the from.
+     */
+    public void setFrom(String from) {
+        if (from == null) {
+            this.from = "";
+        } else {
+            this.from = from;
+        }
+    }
+
+    /**
+     * Setter for property searchDays.
+     * @param searchDays The String object registers the searchDays.
+     */
+    public void setSearchDays(String searchDays) {
+        if (searchDays == null) {
+            this.searchDays = "";
+        } else {
+            this.searchDays = searchDays;
+        }
+    }
+
+    public void setSearchDays(String searchDays, String from, String to) {
+        if (searchDays == null && from == null && to == null) {
+            this.searchDays = "";
+        } else {
+            this.searchDays = searchDays;
+            this.from = from;
+            this.to = to;
+        }
+    }
+
+    public String getSearchDays() {
+        return searchDays;
+    }
+
+    /**
+     * It calculates and returns the lastweek's date(7 days ago from current date). 
+     * @return String value of lastweek's date.
+     */
+    public String getLastWeek() {
+        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        Calendar currDate = Calendar.getInstance();
+        currDate.add(Calendar.DATE, -7); //go back 7 days
+        currDate.getTime();
+        return dateFormat.format(currDate.getTime());
+    }
+
+    /**
+     * It calculates and returns the lastmonth's date(31 days ago from current date).
+     * @return String value of lastmonth's date.
+     */
+    public String getLastMonth() {
+        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        Calendar currDate = Calendar.getInstance();
+        currDate.add(Calendar.DATE, -31); //go back 31 days
+        currDate.getTime();
+        return dateFormat.format(currDate.getTime());
+    }
+
+    /**
+     * Calculates and returns the string format of yesterday Date.
+     * @return String value of yesterday.
+     */
+    public String getYesterday() {
+        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        Calendar currDate = Calendar.getInstance();
+        currDate.add(Calendar.DATE, -1); //go back 1 days
+        currDate.getTime();
+        return dateFormat.format(currDate.getTime());
+    }
+
+    /**
+     * Calculates and returns the date based on the searchDays value.
+     * @return String value of searchDate.
+     */
+    public String getSearchDate() {
+        if (searchDays.equalsIgnoreCase("Last week")) {
+            String lastWeek = getLastWeek();
+            lastWeek = lastWeek.replace("-", "");
+            s = s.replace("-", "");
+            searchDate = lastWeek + "-" + s;
+        }
+        else if (searchDays.equalsIgnoreCase("Today")) {
+            s = s.replace("-", "");
+            searchDate = s + "-" + s;
+        }
+        else if (searchDays.equalsIgnoreCase("Last month")) {
+            String lastMonth = getLastMonth();
+            lastMonth = lastMonth.replace("-", "");
+            s = s.replace("-", "");
+            searchDate = lastMonth + "-" + s;
+        }
+        else if (searchDays.equalsIgnoreCase("Yesterday")) {
+            String yesterDay = getYesterday();
+            yesterDay = yesterDay.replace("-", "");
+            searchDate = yesterDay + "-" + yesterDay;
+        }
+        else if (searchDays.equalsIgnoreCase("Between")) {
+            from = from.replace("/", "");
+            to = to.replace("/", "");
+            from = from.replace("-", "");
+            to = to.replace("-", "");
+            searchDate = from + "-" + to;
+        }
+        else
+        {
+           searchDate="";
+        }
+        return this.searchDate;
+    }
+
+    public String getBirthDate() {
+        return birthDate;
+    }
+
+    public String getFrom() {
+        return from;
+    }
+
+    public String getModality() {
+        return modality;
+    }
+
+    public String getPatientId() {
+        return patientId;
+    }
+
+    public String getPatientName() {
+        return patientName;
+    }
+
+    public String getTo() {
+        return to;
+    }
+
+    public String getAccessionNo() {
+        return accessionNo;
+    }
+
+    public void setAccessionNo(String accessionNo) {
+        this.accessionNo = accessionNo;
+    }
+
+
+}
diff --git a/src/in/raster/mayam/param/TextOverlayParam.java b/src/in/raster/mayam/param/TextOverlayParam.java
new file mode 100644
index 0000000..8171463
--- /dev/null
+++ b/src/in/raster/mayam/param/TextOverlayParam.java
@@ -0,0 +1,267 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.param;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class TextOverlayParam {
+
+    private String patientName = "";
+    private String patientID = "";
+    private String sex = "";
+    private String institutionName = "";
+    private String studyDate = "";
+    private String studyTime = "";
+    private String windowLevel = "";
+    private String bodyPartExamined = "";
+    private String slicePosition = "";
+    private String patientPosition = "";
+    private String windowWidth = "";
+    private String xPosition = "";
+    private String yPosition = "";
+    private String pxValue = "";
+    private String totalInstance = "";
+    private int currentInstance = 1;
+    private String zoomLevel = "";
+
+    //added variables for MAYAM-61
+    private String instanceNumber="";
+    private String studyDescription="";
+    private String seriesDescription="";
+    SimpleDateFormat sourceDateFormat = new SimpleDateFormat("yyyyMMdd");
+    SimpleDateFormat destinationDateFormat = new SimpleDateFormat("yyyy/MM/dd");
+    private String framePosition = "";
+
+    public TextOverlayParam() {
+    }
+
+    public String getBodyPartExamined() {
+        return bodyPartExamined;
+    }
+
+    public void setBodyPartExamined(String bodyPartExamined) {
+        this.bodyPartExamined = bodyPartExamined;
+    }
+
+    public String getInstitutionName() {
+        return institutionName;
+    }
+
+    public void setInstitutionName(String institutionName) {
+        this.institutionName = institutionName;
+    }
+
+    public String getPatientID() {
+        return patientID;
+    }
+
+    public void setPatientID(String patientID) {
+        this.patientID = patientID;
+    }
+
+    public String getPatientName() {
+        return patientName;
+    }
+
+    public void setPatientName(String patientName) {
+        this.patientName = patientName;
+    }
+
+    public String getPatientPosition() {
+        return patientPosition;
+    }
+
+    public void setPatientPosition(String patientPosition) {
+        this.patientPosition = patientPosition;
+    }
+
+    public String getPxValue() {
+        return pxValue;
+    }
+
+    public void setPxValue(String pxValue) {
+        this.pxValue = pxValue;
+    }
+
+    public String getSex() {
+        return sex;
+    }
+
+    public void setSex(String sex) {
+        this.sex = sex;
+    }
+
+    public String getSlicePosition() {
+        return slicePosition;
+    }
+
+    public void setSlicePosition(String slicePosition) {
+        this.slicePosition = slicePosition;
+    }
+
+    public String getStudyDate() {
+        return studyDate;
+    }
+
+    public void setStudyDate(String studyDate) {
+        try {
+            Date d = sourceDateFormat.parse(studyDate);
+            this.studyDate = destinationDateFormat.format(d);
+        } catch (ParseException ex) {
+            this.studyDate = "";
+        }
+    }
+
+    public String getStudyTime() {
+        return studyTime;
+    }
+
+    public void setStudyTime(String studyTime) {
+        this.studyTime = studyTime;
+    }
+
+    public String getWindowLevel() {
+        return windowLevel;
+    }
+
+    public void setWindowLevel(String windowLevel) {
+        this.windowLevel = windowLevel;
+    }
+
+    public String getWindowWidth() {
+        return windowWidth;
+    }
+
+    public void setWindowWidth(String windowWidth) {
+        this.windowWidth = windowWidth;
+    }
+
+    public void setWindowingParameter(String WL, String WW) {
+        this.windowLevel = WL;
+        this.windowWidth = WW;
+    }
+
+    public void setProbeParameters(String[] probeParameters) {
+        this.xPosition = probeParameters[0];
+        this.yPosition = probeParameters[1];
+        this.pxValue = probeParameters[2];
+
+    }
+
+    public String getXPosition() {
+        return xPosition;
+    }
+
+    public void setXPosition(String xPosition) {
+        this.xPosition = xPosition;
+    }
+
+    public String getYPosition() {
+        return yPosition;
+    }
+
+    public void setYPosition(String yPosition) {
+        this.yPosition = yPosition;
+    }
+
+    public String getTotalInstance() {
+        return totalInstance;
+    }
+
+    public void setTotalInstance(String totalInstance) {
+        this.totalInstance = totalInstance;
+    }
+
+    public int getCurrentInstance() {
+        return currentInstance;
+    }
+
+    public void setCurrentInstance(int currentInstance) {
+        this.currentInstance = currentInstance;
+    }
+
+    public String getZoomLevel() {
+        return zoomLevel;
+    }
+
+    public void setZoomLevel(String zoomLevel) {
+        this.zoomLevel = zoomLevel;
+    }
+
+    public String getFramePosition() {
+        return framePosition;
+    }
+
+    public void setFramePosition(String framePosition) {
+        this.framePosition = framePosition;
+    }
+
+    public String getInstanceNumber() {
+        return instanceNumber;
+    }
+
+    public void setInstanceNumber(String instanceNumber) {
+        this.instanceNumber = instanceNumber;
+    }
+
+    public String getSeriesDescription() {
+        return seriesDescription;
+    }
+
+    public void setSeriesDescription(String seriesDescription) {
+        this.seriesDescription = seriesDescription;
+    }
+
+    public String getStudyDescription() {
+        return studyDescription;
+    }
+
+    public void setStudyDescription(String studyDescription) {
+        this.studyDescription = studyDescription;
+    }
+
+}
diff --git a/src/in/raster/mayam/param/WadoParam.java b/src/in/raster/mayam/param/WadoParam.java
new file mode 100644
index 0000000..0d24195
--- /dev/null
+++ b/src/in/raster/mayam/param/WadoParam.java
@@ -0,0 +1,187 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.param;
+
+import org.dcm4che2.data.TransferSyntax;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.7
+ *
+ */
+public class WadoParam {
+
+    private String study;
+    private String series;
+    private String object;
+    private String remoteHostName;
+    private int remotePort;
+    private boolean secureQuery;
+    private String aeTitle;
+    private String retrieveTrasferSyntax;
+
+    public WadoParam() {
+    }   
+    public String getWadoUrl() {
+        String queryString = "";
+        queryString = getProtocol()+appendHostName();
+        queryString += remotePort != 0 ? ":" + remotePort : "8080";
+        queryString += "/wado?requestType=WADO&studyUID="+appendStudy();
+        queryString += "&seriesUID="+appendSeries();
+        queryString += "&objectUID="+appendObject();
+        queryString += "&contentType=application/dicom"+appendTransferSyntax();
+        return queryString;
+    }
+
+    private String getProtocol() {
+        if (secureQuery) {
+            return "https://";
+        } else {
+            return "http://";
+        }
+    }
+
+    private String appendHostName() {
+        if (remoteHostName != null && !remoteHostName.equalsIgnoreCase("")) {
+            return remoteHostName;
+        } else {
+            return "localhost";
+        }
+    }
+
+    private String appendStudy() {
+        if (study != null && !study.equalsIgnoreCase("")) {
+            return study;
+        }
+        return "";
+    }
+
+    private String appendSeries() {
+        if (series != null && !series.equalsIgnoreCase("")) {
+            return series;
+        }
+        return "";
+    }
+
+    private String appendObject() {
+        if (object != null && !object.equalsIgnoreCase("")) {
+            return object;
+        }
+        return "";
+    }
+
+    private String appendTransferSyntax() {
+        String transferSyntax="&transferSyntax=";
+        if (retrieveTrasferSyntax != null && !retrieveTrasferSyntax.equalsIgnoreCase("")) {
+            if (retrieveTrasferSyntax.equalsIgnoreCase("Explicit VR Little Endian")) {
+                transferSyntax+= TransferSyntax.ExplicitVRLittleEndian.uid();
+                return  transferSyntax;
+            } else if (retrieveTrasferSyntax.equalsIgnoreCase("Implicit VR Little Endian")) {
+                transferSyntax+= TransferSyntax.ImplicitVRLittleEndian.uid();
+                return  transferSyntax;
+            }
+        }
+        return "";
+    }
+
+    public String getObject() {
+        return object;
+    }
+
+    public void setObject(String object) {
+        this.object = object;
+    }
+
+    public String getSeries() {
+        return series;
+    }
+
+    public void setSeries(String series) {
+        this.series = series;
+    }
+
+    public String getStudy() {
+        return study;
+    }
+
+    public void setStudy(String study) {
+        this.study = study;
+    }
+
+    public String getRemoteHostName() {
+        return remoteHostName;
+    }
+
+    public void setRemoteHostName(String remoteHostName) {
+        this.remoteHostName = remoteHostName;
+    }
+
+    public int getRemotePort() {
+        return remotePort;
+    }
+
+    public void setRemotePort(int remotePort) {
+        this.remotePort = remotePort;
+    }
+
+    public boolean isSecureQuery() {
+        return secureQuery;
+    }
+
+    public void setSecureQuery(boolean secureQuery) {
+        this.secureQuery = secureQuery;
+    }
+
+    public String getAeTitle() {
+        return aeTitle;
+    }
+
+    public void setAeTitle(String aeTitle) {
+        this.aeTitle = aeTitle;
+    }
+
+    public String getRetrieveTrasferSyntax() {
+        return retrieveTrasferSyntax;
+    }
+
+    public void setRetrieveTrasferSyntax(String retrieveTrasferSyntax) {
+        this.retrieveTrasferSyntax = retrieveTrasferSyntax;
+    }
+}
diff --git a/src/in/raster/mayam/util/DicomTags.java b/src/in/raster/mayam/util/DicomTags.java
new file mode 100644
index 0000000..df980b1
--- /dev/null
+++ b/src/in/raster/mayam/util/DicomTags.java
@@ -0,0 +1,102 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.util;
+
+/**
+ *
+ * @author prakash.j
+ * @version 0.5
+ */
+public class DicomTags {
+
+    private String tag;
+    private String tagName;
+    private String VR;
+    private String VM;
+    private String tagLength;
+
+    public String getTagLength() {
+        return tagLength;
+    }
+
+    public void setTagLength(String tagLength) {
+        this.tagLength = tagLength;
+    }
+    private String tagValue;
+
+    public String getVM() {
+        return VM;
+    }
+
+    public void setVM(String VM) {
+        this.VM = VM;
+    }
+
+    public String getVR() {
+        return VR;
+    }
+
+    public void setVR(String VR) {
+        this.VR = VR;
+    }
+
+    public String getTag() {
+        return tag;
+    }
+
+    public void setTag(String tag) {
+        this.tag = tag;
+    }
+
+    public String getTagName() {
+        return tagName;
+    }
+
+    public void setTagName(String tagName) {
+        this.tagName = tagName;
+    }
+
+    public String getTagValue() {
+        return tagValue;
+    }
+
+    public void setTagValue(String tagValue) {
+        this.tagValue = tagValue;
+    }
+}
diff --git a/src/in/raster/mayam/util/DicomTagsReader.java b/src/in/raster/mayam/util/DicomTagsReader.java
new file mode 100644
index 0000000..500011c
--- /dev/null
+++ b/src/in/raster/mayam/util/DicomTagsReader.java
@@ -0,0 +1,140 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.util;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import org.dcm4che2.data.DicomElement;
+import org.dcm4che2.data.DicomObject;
+import org.dcm4che2.io.DicomInputStream;
+import org.dcm4che2.util.TagUtils;
+
+/**
+ *
+ * @author prakash.j
+ * @version 0.5
+ */
+public class DicomTagsReader {
+
+    public static ArrayList<DicomTags> tagsArray = new ArrayList<DicomTags>();
+
+    public DicomTagsReader() {
+    }
+
+    // Method to Parse Tags from the DICOM File
+    public static void ReadTags(File dcmfile) {
+        tagsArray = new ArrayList<DicomTags>();
+        DicomObject dcmObject = null;
+
+        try {
+
+            DicomInputStream dcmInputStream = new DicomInputStream(dcmfile);
+            dcmObject = dcmInputStream.readDicomObject();
+            dcmInputStream.close();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        //Call to Parsing Tags in an Array List        
+        listTags(dcmObject);       
+    }
+
+    //Method to parse tags from a DICOM Object
+    public static void listTags(DicomObject dcmObject){
+        Iterator<DicomElement> tagsIterator=null;
+        if(dcmObject!=null){
+        tagsIterator= dcmObject.datasetIterator();   
+
+        while (tagsIterator.hasNext()) {
+            DicomElement dcmElement = tagsIterator.next();
+
+            DicomTags dcmTags = new DicomTags();
+
+            int tag = dcmElement.tag();
+            try {
+
+                String tagName = dcmObject.nameOf(tag);
+                String tagAddr = TagUtils.toString(tag);
+                String tagVR = dcmObject.vrOf(tag).toString();
+                String tagLength = String.valueOf(dcmElement.length());
+
+
+                //Recursive calling for "SQ" Tags
+
+                if (tagVR.equals("SQ")) {
+                    if (dcmElement.hasItems()) {
+
+                        dcmTags.setTag(tagAddr);
+                        dcmTags.setTagName(tagName);
+                        dcmTags.setVR(tagVR);
+
+                        //Recursive call
+                        listTags(dcmElement.getDicomObject());
+                        continue;
+                    }
+                }
+
+                //Adding parsed tags to DicomTags Object
+
+                dcmTags.setTag(tagAddr);
+                dcmTags.setTagName(tagName);
+                dcmTags.setVR(tagVR);
+                dcmTags.setTagLength(tagLength);
+                dcmTags.setTagValue(dcmObject.getString(tag));
+
+            }catch(UnsupportedOperationException e){}
+            catch (Exception e) {
+                e.printStackTrace();
+            }
+
+            //Adding DicomTags object to Tags ArrayList
+            tagsArray.add(dcmTags);
+
+        }
+        }
+
+    }
+
+    // A method which gets DICOM File as an input and returns tags in a ArrayList
+    public static ArrayList<DicomTags> getTags(File dcmfile) {
+        ReadTags(dcmfile);
+        return tagsArray;
+    }
+}
diff --git a/src/in/raster/mayam/util/core/Configuration.java b/src/in/raster/mayam/util/core/Configuration.java
new file mode 100644
index 0000000..b28fa6e
--- /dev/null
+++ b/src/in/raster/mayam/util/core/Configuration.java
@@ -0,0 +1,117 @@
+package in.raster.mayam.util.core;
+
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is part of dcm4che, an implementation of DICOM(TM) in
+ * Java(TM), hosted at http://sourceforge.net/projects/dcm4che.
+ *
+ * The Initial Developer of the Original Code is
+ * TIANI Medgraph AG.
+ * Portions created by the Initial Developer are Copyright (C) 2002-2005
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Gunter Zeilinger <gunter.zeilinger at tiani.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+import java.io.InputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Properties;
+import java.util.StringTokenizer;
+
+/**
+ * <description> 
+ *
+ * @see <related>
+ * @author  <a href="mailto:gunter at tiani.com">gunter zeilinger</a>
+ * @version $Revision: 1.2 $ $Date: 2005/10/05 16:26:14 $
+ *   
+ * <p><b>Revisions:</b>
+ *
+ * <p><b>yyyymmdd author:</b>
+ * <ul>
+ * <li> explicit fix description (no line numbers but methods) go 
+ *            beyond the cvs commit message
+ * </ul>
+ */
+class Configuration extends Properties
+{
+   // Constants -----------------------------------------------------
+   
+   // Attributes ----------------------------------------------------
+   
+   // Static --------------------------------------------------------  
+   private static String replace(String val, String from, String to) {
+      return from.equals(val) ? to : val;
+   }
+   
+   // Constructors --------------------------------------------------
+   public Configuration(URL url) {
+      InputStream in = null;
+      try {
+         load(in = url.openStream());
+      } catch (Exception e) {
+         throw new RuntimeException("Could not load configuration from "
+               + url, e);
+      } finally {
+         if (in != null) {
+            try { in.close(); } catch (IOException ignore) {ignore.printStackTrace();}
+         }
+      }
+   }
+   
+   // Public --------------------------------------------------------
+   public String getProperty(String key, String defaultValue,
+                             String replace, String to) {
+      return replace(getProperty(key, defaultValue), replace, to);
+   }
+   
+   public List tokenize(String s, List result) {
+      StringTokenizer stk = new StringTokenizer(s, ", ");
+      while (stk.hasMoreTokens()) {
+         String tk = stk.nextToken();
+         if (tk.startsWith("$")) {
+            tokenize(getProperty(tk.substring(1),""), result);
+         } else {
+            result.add(tk);
+         }
+      }
+      return result;
+   }
+   
+   public String[] tokenize(String s) {
+      if (s == null)
+         return null;
+      
+      List l = tokenize(s, new LinkedList());      
+      return (String[])l.toArray(new String[l.size()]);
+   }
+       
+}
diff --git a/src/in/raster/mayam/util/core/DcmQR.java b/src/in/raster/mayam/util/core/DcmQR.java
new file mode 100644
index 0000000..1833b03
--- /dev/null
+++ b/src/in/raster/mayam/util/core/DcmQR.java
@@ -0,0 +1,1804 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is part of dcm4che, an implementation of DICOM(TM) in
+ * Java(TM), hosted at http://sourceforge.net/projects/dcm4che.
+ *
+ * The Initial Developer of the Original Code is
+ * Gunter Zeilinger, Huetteldorferstr. 24/10, 1150 Vienna/Austria/Europe.
+ * Portions created by the Initial Developer are Copyright (C) 2002-2005
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Gunter Zeilinger <gunterze at gmail.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.util.core;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.delegate.NetworkQueueUpdateDelegate;
+import in.raster.mayam.form.MainScreen;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.security.GeneralSecurityException;
+import java.security.KeyStore;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.List;
+import java.util.concurrent.Executor;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.GnuParser;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.commons.cli.OptionGroup;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.dcm4che2.data.BasicDicomObject;
+import org.dcm4che2.data.DicomObject;
+import org.dcm4che2.data.Tag;
+import org.dcm4che2.data.UID;
+import org.dcm4che2.data.UIDDictionary;
+import org.dcm4che2.data.VR;
+import org.dcm4che2.io.DicomOutputStream;
+import org.dcm4che2.net.Association;
+import org.dcm4che2.net.CommandUtils;
+import org.dcm4che2.net.ConfigurationException;
+import org.dcm4che2.net.Device;
+import org.dcm4che2.net.DicomServiceException;
+import org.dcm4che2.net.DimseRSP;
+import org.dcm4che2.net.DimseRSPHandler;
+import org.dcm4che2.net.ExtQueryTransferCapability;
+import org.dcm4che2.net.ExtRetrieveTransferCapability;
+import org.dcm4che2.net.NetworkApplicationEntity;
+import org.dcm4che2.net.NetworkConnection;
+import org.dcm4che2.net.NewThreadExecutor;
+import org.dcm4che2.net.NoPresentationContextException;
+import org.dcm4che2.net.PDVInputStream;
+import org.dcm4che2.net.Status;
+import org.dcm4che2.net.TransferCapability;
+import org.dcm4che2.net.UserIdentity;
+import org.dcm4che2.net.service.DicomService;
+import org.dcm4che2.net.service.StorageService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author gunter zeilinger(gunterze at gmail.com)
+ * @version $Revision: 11856 $ $Date: 2009-06-23 13:52:07 +0200 (Tue, 23 Jun 2009) $
+ * @since Jan, 2006
+ */
+public class DcmQR {
+
+    private static final Logger LOG = LoggerFactory.getLogger(DcmQR.class);
+    private static final int KB = 1024;
+    private static final String USAGE = "dcmqr <aet>[@<host>[:<port>]] [Options]";
+    private static final String DESCRIPTION =
+            "Query specified remote Application Entity (=Query/Retrieve SCP) "
+            + "and optional (s. option -cget/-cmove) retrieve instances of "
+            + "matching entities. If <port> is not specified, DICOM default port "
+            + "104 is assumed. If also no <host> is specified localhost is assumed. "
+            + "Also Storage Services can be provided (s. option -cstore) to receive "
+            + "retrieved instances. For receiving objects retrieved by C-MOVE in a "
+            + "separate association, a local listening port must be specified "
+            + "(s.option -L).\n"
+            + "Options:";
+    private static final String EXAMPLE =
+            "\nExample: dcmqr -L QRSCU:11113 QRSCP at localhost:11112 -cmove QRSCU "
+            + "-qStudyDate=20060204 -qModalitiesInStudy=CT -cstore CT -cstore PR:LE "
+            + "-cstoredest /tmp\n"
+            + "=> Query Application Entity QRSCP listening on local port 11112 for "
+            + "CT studies from Feb 4, 2006 and retrieve matching studies by C-MOVE "
+            + "to own Application Entity QRSCU listing on local port 11113, "
+            + "storing received CT images and Grayscale Softcopy Presentation "
+            + "states to /tmp.";
+    private static String[] TLS1 = {"TLSv1"};
+    private static String[] SSL3 = {"SSLv3"};
+    private static String[] NO_TLS1 = {"SSLv3", "SSLv2Hello"};
+    private static String[] NO_SSL2 = {"TLSv1", "SSLv3"};
+    private static String[] NO_SSL3 = {"TLSv1", "SSLv2Hello"};
+    private static char[] SECRET = {'s', 'e', 'c', 'r', 'e', 't'};
+    private static int cgetServiceCount=0;
+
+    public static enum QueryRetrieveLevel {
+
+        PATIENT("PATIENT", PATIENT_RETURN_KEYS, PATIENT_LEVEL_FIND_CUID,
+        PATIENT_LEVEL_GET_CUID, PATIENT_LEVEL_MOVE_CUID),
+        STUDY("STUDY", STUDY_RETURN_KEYS, STUDY_LEVEL_FIND_CUID,
+        STUDY_LEVEL_GET_CUID, STUDY_LEVEL_MOVE_CUID),
+        SERIES("SERIES", SERIES_RETURN_KEYS, SERIES_LEVEL_FIND_CUID,
+        SERIES_LEVEL_GET_CUID, SERIES_LEVEL_MOVE_CUID),
+        IMAGE("IMAGE", INSTANCE_RETURN_KEYS, SERIES_LEVEL_FIND_CUID,
+        SERIES_LEVEL_GET_CUID, SERIES_LEVEL_MOVE_CUID);
+        private final String code;
+        private final int[] returnKeys;
+        private final String[] findClassUids;
+        private final String[] getClassUids;
+        private final String[] moveClassUids;
+
+        private QueryRetrieveLevel(String code, int[] returnKeys,
+                String[] findClassUids, String[] getClassUids,
+                String[] moveClassUids) {
+            this.code = code;
+            this.returnKeys = returnKeys;
+            this.findClassUids = findClassUids;
+            this.getClassUids = getClassUids;
+            this.moveClassUids = moveClassUids;
+        }
+
+        public String getCode() {
+            return code;
+        }
+
+        public int[] getReturnKeys() {
+            return returnKeys;
+        }
+
+        public String[] getFindClassUids() {
+            return findClassUids;
+        }
+
+        public String[] getGetClassUids() {
+            return getClassUids;
+        }
+
+        public String[] getMoveClassUids() {
+            return moveClassUids;
+        }
+    }
+    private static final String[] PATIENT_LEVEL_FIND_CUID = {
+        UID.PatientRootQueryRetrieveInformationModelFIND,
+        UID.PatientStudyOnlyQueryRetrieveInformationModelFINDRetired};
+    private static final String[] STUDY_LEVEL_FIND_CUID = {
+        UID.StudyRootQueryRetrieveInformationModelFIND,
+        UID.PatientRootQueryRetrieveInformationModelFIND,
+        UID.PatientStudyOnlyQueryRetrieveInformationModelFINDRetired};
+    private static final String[] SERIES_LEVEL_FIND_CUID = {
+        UID.StudyRootQueryRetrieveInformationModelFIND,
+        UID.PatientRootQueryRetrieveInformationModelFIND,};
+    private static final String[] PATIENT_LEVEL_GET_CUID = {
+        UID.PatientRootQueryRetrieveInformationModelGET,
+        UID.PatientStudyOnlyQueryRetrieveInformationModelGETRetired};
+    private static final String[] STUDY_LEVEL_GET_CUID = {
+        UID.StudyRootQueryRetrieveInformationModelGET,
+        UID.PatientRootQueryRetrieveInformationModelGET,
+        UID.PatientStudyOnlyQueryRetrieveInformationModelGETRetired};
+    private static final String[] SERIES_LEVEL_GET_CUID = {
+        UID.StudyRootQueryRetrieveInformationModelGET,
+        UID.PatientRootQueryRetrieveInformationModelGET};
+    private static final String[] PATIENT_LEVEL_MOVE_CUID = {
+        UID.PatientRootQueryRetrieveInformationModelMOVE,
+        UID.PatientStudyOnlyQueryRetrieveInformationModelMOVERetired};
+    private static final String[] STUDY_LEVEL_MOVE_CUID = {
+        UID.StudyRootQueryRetrieveInformationModelMOVE,
+        UID.PatientRootQueryRetrieveInformationModelMOVE,
+        UID.PatientStudyOnlyQueryRetrieveInformationModelMOVERetired};
+    private static final String[] SERIES_LEVEL_MOVE_CUID = {
+        UID.StudyRootQueryRetrieveInformationModelMOVE,
+        UID.PatientRootQueryRetrieveInformationModelMOVE};
+    private static final int[] PATIENT_RETURN_KEYS = {
+        Tag.PatientName,
+        Tag.PatientID,
+        Tag.PatientBirthDate,
+        Tag.PatientSex,
+        Tag.NumberOfPatientRelatedStudies,
+        Tag.NumberOfPatientRelatedSeries,
+        Tag.NumberOfPatientRelatedInstances};
+    private static final int[] PATIENT_MATCHING_KEYS = {
+        Tag.PatientName,
+        Tag.PatientID,
+        Tag.IssuerOfPatientID,
+        Tag.PatientBirthDate,
+        Tag.PatientSex};
+    private static final int[] STUDY_RETURN_KEYS = {
+        Tag.StudyDate,
+        Tag.StudyTime,
+        Tag.AccessionNumber,
+        Tag.StudyID,
+        Tag.StudyInstanceUID,
+        Tag.NumberOfStudyRelatedSeries,
+        Tag.NumberOfStudyRelatedInstances};
+    private static final int[] STUDY_MATCHING_KEYS = {
+        Tag.StudyDate,
+        Tag.StudyTime,
+        Tag.AccessionNumber,
+        Tag.ModalitiesInStudy,
+        Tag.ReferringPhysicianName,
+        Tag.StudyID,
+        Tag.StudyInstanceUID};
+    private static final int[] PATIENT_STUDY_MATCHING_KEYS = {
+        Tag.StudyDate,
+        Tag.StudyTime,
+        Tag.AccessionNumber,
+        Tag.ModalitiesInStudy,
+        Tag.ReferringPhysicianName,
+        Tag.PatientName,
+        Tag.PatientID,
+        Tag.IssuerOfPatientID,
+        Tag.PatientBirthDate,
+        Tag.PatientSex,
+        Tag.StudyID,
+        Tag.StudyInstanceUID};
+    private static final int[] SERIES_RETURN_KEYS = {
+        Tag.Modality,
+        Tag.SeriesNumber,
+        Tag.SeriesInstanceUID,
+        Tag.NumberOfSeriesRelatedInstances};
+    private static final int[] SERIES_MATCHING_KEYS = {
+        Tag.Modality,
+        Tag.SeriesNumber,
+        Tag.SeriesInstanceUID,
+        Tag.RequestAttributesSequence
+    };
+    private static final int[] INSTANCE_RETURN_KEYS = {
+        Tag.InstanceNumber,
+        Tag.SOPClassUID,
+        Tag.SOPInstanceUID,};
+    private static final int[] MOVE_KEYS = {
+        Tag.QueryRetrieveLevel,
+        Tag.PatientID,
+        Tag.StudyInstanceUID,
+        Tag.SeriesInstanceUID,
+        Tag.SOPInstanceUID,};
+    private static final String[] IVRLE_TS = {
+        UID.ImplicitVRLittleEndian};
+    private static final String[] NATIVE_LE_TS = {
+        UID.ExplicitVRLittleEndian,
+        UID.ImplicitVRLittleEndian};
+    private static final String[] NATIVE_BE_TS = {
+        UID.ExplicitVRBigEndian,
+        UID.ImplicitVRLittleEndian};
+    private static final String[] DEFLATED_TS = {
+        UID.DeflatedExplicitVRLittleEndian,
+        UID.ExplicitVRLittleEndian,
+        UID.ImplicitVRLittleEndian};
+    private static final String[] NOPX_TS = {
+        UID.NoPixelData,
+        UID.ExplicitVRLittleEndian,
+        UID.ImplicitVRLittleEndian};
+    private static final String[] NOPXDEFL_TS = {
+        UID.NoPixelDataDeflate,
+        UID.NoPixelData,
+        UID.ExplicitVRLittleEndian,
+        UID.ImplicitVRLittleEndian};
+    private static final String[] JPLL_TS = {
+        UID.JPEGLossless,
+        UID.JPEGLosslessNonHierarchical14,
+        UID.JPEGLSLossless,
+        UID.JPEG2000LosslessOnly,
+        UID.ExplicitVRLittleEndian,
+        UID.ImplicitVRLittleEndian};
+    private static final String[] JPLY_TS = {
+        UID.JPEGBaseline1,
+        UID.JPEGExtended24,
+        UID.JPEGLSLossyNearLossless,
+        UID.JPEG2000,
+        UID.ExplicitVRLittleEndian,
+        UID.ImplicitVRLittleEndian};
+    private static final String[] MPEG2_TS = {UID.MPEG2};
+    private static final String[] DEF_TS = {
+        UID.JPEGLossless,
+        UID.JPEGLosslessNonHierarchical14,
+        UID.JPEGLSLossless,
+        UID.JPEGLSLossyNearLossless,
+        UID.JPEG2000LosslessOnly,
+        UID.JPEG2000,
+        UID.JPEGBaseline1,
+        UID.JPEGExtended24,
+        UID.MPEG2,
+        UID.DeflatedExplicitVRLittleEndian,
+        UID.ExplicitVRBigEndian,
+        UID.ExplicitVRLittleEndian,
+        UID.ImplicitVRLittleEndian};
+
+    private static enum TS {
+
+        IVLE(IVRLE_TS),
+        LE(NATIVE_LE_TS),
+        BE(NATIVE_BE_TS),
+        DEFL(DEFLATED_TS),
+        JPLL(JPLL_TS),
+        JPLY(JPLY_TS),
+        MPEG2(MPEG2_TS),
+        NOPX(NOPX_TS),
+        NOPXD(NOPXDEFL_TS);
+        final String[] uids;
+
+        TS(String[] uids) {
+            this.uids = uids;
+        }
+    }
+
+    private static enum CUID {
+
+        CR(UID.ComputedRadiographyImageStorage),
+        CT(UID.CTImageStorage),
+        MR(UID.MRImageStorage),
+        US(UID.UltrasoundImageStorage),
+        NM(UID.NuclearMedicineImageStorage),
+        PET(UID.PositronEmissionTomographyImageStorage),
+        SC(UID.SecondaryCaptureImageStorage),
+        XA(UID.XRayAngiographicImageStorage),
+        XRF(UID.XRayRadiofluoroscopicImageStorage),
+        DX(UID.DigitalXRayImageStorageForPresentation),
+        MG(UID.DigitalMammographyXRayImageStorageForPresentation),
+        PR(UID.GrayscaleSoftcopyPresentationStateStorageSOPClass),
+        KO(UID.KeyObjectSelectionDocumentStorage),
+        SR(UID.BasicTextSRStorage);
+        final String uid;
+
+        CUID(String uid) {
+            this.uid = uid;
+        }
+    }
+    private static final String[] EMPTY_STRING = {};
+    private final Executor executor;
+    private final NetworkApplicationEntity remoteAE = new NetworkApplicationEntity();
+    private final NetworkConnection remoteConn = new NetworkConnection();
+    private final Device device;
+    private final NetworkApplicationEntity ae = new NetworkApplicationEntity();
+    private final NetworkConnection conn = new NetworkConnection();
+    private Association assoc;
+    private int priority = 0;
+    private boolean cget;
+    private String moveDest;
+    private File storeDest;
+    private File devnull;
+    private int fileBufferSize = 256;
+    private boolean evalRetrieveAET = false;
+    private QueryRetrieveLevel qrlevel = QueryRetrieveLevel.STUDY;
+    private List<String> privateFind = new ArrayList<String>();
+    private final List<TransferCapability> storeTransferCapability =
+            new ArrayList<TransferCapability>(8);
+    private DicomObject keys = new BasicDicomObject();
+    private int cancelAfter = Integer.MAX_VALUE;
+    private int completed;
+    private int warning;
+    private int failed;
+    private boolean relationQR;
+    private boolean dateTimeMatching;
+    private boolean fuzzySemanticPersonNameMatching;
+    private boolean noExtNegotiation;
+    private String keyStoreURL = "resource:tls/test_sys_1.p12";
+    private char[] keyStorePassword = SECRET;
+    private char[] keyPassword;
+    private String trustStoreURL = "resource:tls/mesa_certs.jks";
+    private char[] trustStorePassword = SECRET;
+    private File destination;
+
+    public DcmQR(String name) {
+        cgetServiceCount++;
+        device = new Device(name);
+        executor = new NewThreadExecutor(name);
+        remoteAE.setInstalled(true);
+        remoteAE.setAssociationAcceptor(true);
+        remoteAE.setNetworkConnection(new NetworkConnection[]{remoteConn});
+        String[] s = ApplicationContext.databaseRef.getListenerDetails();
+        this.setDestination(s[2]);
+        this.setStoreDestination(s[2]);
+
+        device.setNetworkApplicationEntity(ae);
+        device.setNetworkConnection(conn);
+        ae.setNetworkConnection(conn);
+        ae.setAssociationInitiator(true);
+        ae.setAssociationAcceptor(true);
+        ae.setAETitle(name);
+    }
+
+    public final void setLocalHost(String hostname) {
+        conn.setHostname(hostname);
+    }
+
+    public final void setLocalPort(int port) {
+        conn.setPort(port);
+    }
+
+    public final void setRemoteHost(String hostname) {
+        remoteConn.setHostname(hostname);
+    }
+
+    public final void setRemotePort(int port) {
+        remoteConn.setPort(port);
+    }
+
+    public final void setTlsProtocol(String[] tlsProtocol) {
+        conn.setTlsProtocol(tlsProtocol);
+    }
+
+    public final void setTlsWithoutEncyrption() {
+        conn.setTlsWithoutEncyrption();
+        remoteConn.setTlsWithoutEncyrption();
+    }
+
+    public final void setTls3DES_EDE_CBC() {
+        conn.setTls3DES_EDE_CBC();
+        remoteConn.setTls3DES_EDE_CBC();
+    }
+
+    public final void setTlsAES_128_CBC() {
+        conn.setTlsAES_128_CBC();
+        remoteConn.setTlsAES_128_CBC();
+    }
+
+    public final void setTlsNeedClientAuth(boolean needClientAuth) {
+        conn.setTlsNeedClientAuth(needClientAuth);
+    }
+
+    public final void setKeyStoreURL(String url) {
+        keyStoreURL = url;
+    }
+
+    public final void setKeyStorePassword(String pw) {
+        keyStorePassword = pw.toCharArray();
+    }
+
+    public final void setKeyPassword(String pw) {
+        keyPassword = pw.toCharArray();
+    }
+
+    public final void setTrustStorePassword(String pw) {
+        trustStorePassword = pw.toCharArray();
+    }
+
+    public final void setTrustStoreURL(String url) {
+        trustStoreURL = url;
+    }
+
+    public final void setCalledAET(String called, boolean reuse) {
+        remoteAE.setAETitle(called);
+        if (reuse) {
+            ae.setReuseAssocationToAETitle(new String[]{called});
+        }
+    }
+
+    public final void setCalling(String calling) {
+        ae.setAETitle(calling);
+    }
+
+    public final void setUserIdentity(UserIdentity userIdentity) {
+        ae.setUserIdentity(userIdentity);
+    }
+
+    public final void setPriority(int priority) {
+        this.priority = priority;
+    }
+
+    public final void setConnectTimeout(int connectTimeout) {
+        conn.setConnectTimeout(connectTimeout);
+    }
+
+    public final void setMaxPDULengthReceive(int maxPDULength) {
+        ae.setMaxPDULengthReceive(maxPDULength);
+    }
+
+    public final void setMaxOpsInvoked(int maxOpsInvoked) {
+        ae.setMaxOpsInvoked(maxOpsInvoked);
+    }
+
+    public final void setMaxOpsPerformed(int maxOps) {
+        ae.setMaxOpsPerformed(maxOps);
+    }
+
+    public final void setPackPDV(boolean packPDV) {
+        ae.setPackPDV(packPDV);
+    }
+
+    public final void setAssociationReaperPeriod(int period) {
+        device.setAssociationReaperPeriod(period);
+    }
+
+    public final void setDimseRspTimeout(int timeout) {
+        ae.setDimseRspTimeout(timeout);
+    }
+
+    public final void setRetrieveRspTimeout(int timeout) {
+        ae.setRetrieveRspTimeout(timeout);
+    }
+
+    public final void setTcpNoDelay(boolean tcpNoDelay) {
+        conn.setTcpNoDelay(tcpNoDelay);
+    }
+
+    public final void setAcceptTimeout(int timeout) {
+        conn.setAcceptTimeout(timeout);
+    }
+
+    public final void setReleaseTimeout(int timeout) {
+        conn.setReleaseTimeout(timeout);
+    }
+
+    public final void setSocketCloseDelay(int timeout) {
+        conn.setSocketCloseDelay(timeout);
+    }
+
+    public final void setMaxPDULengthSend(int maxPDULength) {
+        ae.setMaxPDULengthSend(maxPDULength);
+    }
+
+    public final void setReceiveBufferSize(int bufferSize) {
+        conn.setReceiveBufferSize(bufferSize);
+    }
+
+    public final void setSendBufferSize(int bufferSize) {
+        conn.setSendBufferSize(bufferSize);
+    }
+
+    public final void setFileBufferSize(int size) {
+        fileBufferSize = size;
+    }
+
+    private static CommandLine parse(String[] args) {
+        Options opts = new Options();
+
+        OptionBuilder.withArgName("name");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "set device name, use DCMQR by default");
+        opts.addOption(OptionBuilder.create("device"));
+
+        OptionBuilder.withArgName("aet[@host][:port]");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "set AET, local address and listening port of local"
+                + "Application Entity, use device name and pick up any valid "
+                + "local address to bind the socket by default");
+        opts.addOption(OptionBuilder.create("L"));
+
+        OptionBuilder.withArgName("username");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "enable User Identity Negotiation with specified username and "
+                + " optional passcode");
+        opts.addOption(OptionBuilder.create("username"));
+
+        OptionBuilder.withArgName("passcode");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "optional passcode for User Identity Negotiation, "
+                + "only effective with option -username");
+        opts.addOption(OptionBuilder.create("passcode"));
+
+        opts.addOption("uidnegrsp", false,
+                "request positive User Identity Negotation response, "
+                + "only effective with option -username");
+
+        OptionBuilder.withArgName("NULL|3DES|AES");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "enable TLS connection without, 3DES or AES encryption");
+        opts.addOption(OptionBuilder.create("tls"));
+
+        OptionGroup tlsProtocol = new OptionGroup();
+        tlsProtocol.addOption(new Option("tls1",
+                "disable the use of SSLv3 and SSLv2 for TLS connections"));
+        tlsProtocol.addOption(new Option("ssl3",
+                "disable the use of TLSv1 and SSLv2 for TLS connections"));
+        tlsProtocol.addOption(new Option("no_tls1",
+                "disable the use of TLSv1 for TLS connections"));
+        tlsProtocol.addOption(new Option("no_ssl3",
+                "disable the use of SSLv3 for TLS connections"));
+        tlsProtocol.addOption(new Option("no_ssl2",
+                "disable the use of SSLv2 for TLS connections"));
+        opts.addOptionGroup(tlsProtocol);
+
+        opts.addOption("noclientauth", false,
+                "disable client authentification for TLS");
+
+        OptionBuilder.withArgName("file|url");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "file path or URL of P12 or JKS keystore, resource:tls/test_sys_1.p12 by default");
+        opts.addOption(OptionBuilder.create("keystore"));
+
+        OptionBuilder.withArgName("password");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "password for keystore file, 'secret' by default");
+        opts.addOption(OptionBuilder.create("keystorepw"));
+
+        OptionBuilder.withArgName("password");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "password for accessing the key in the keystore, keystore password by default");
+        opts.addOption(OptionBuilder.create("keypw"));
+
+        OptionBuilder.withArgName("file|url");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "file path or URL of JKS truststore, resource:tls/mesa_certs.jks by default");
+        opts.addOption(OptionBuilder.create("truststore"));
+
+        OptionBuilder.withArgName("password");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "password for truststore file, 'secret' by default");
+        opts.addOption(OptionBuilder.create("truststorepw"));
+
+        OptionBuilder.withArgName("aet");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "retrieve instances of matching entities by C-MOVE to specified destination.");
+        opts.addOption(OptionBuilder.create("cmove"));
+
+        opts.addOption("cget", false, "retrieve instances of matching entities by C-GET.");
+
+        OptionBuilder.withArgName("cuid[:ts]");
+        OptionBuilder.hasArgs();
+        OptionBuilder.withDescription(
+                "negotiate support of specified Storage SOP Class and Transfer "
+                + "Syntaxes. The Storage SOP Class may be specified by its UID "
+                + "or by one of following key words:\n"
+                + "CR  - Computed Radiography Image Storage\n"
+                + "CT  - CT Image Storage\n"
+                + "MR  - MRImageStorage\n"
+                + "US  - Ultrasound Image Storage\n"
+                + "NM  - Nuclear Medicine Image Storage\n"
+                + "PET - PET Image Storage\n"
+                + "SC  - Secondary Capture Image Storage\n"
+                + "XA  - XRay Angiographic Image Storage\n"
+                + "XRF - XRay Radiofluoroscopic Image Storage\n"
+                + "DX  - Digital X-Ray Image Storage for Presentation\n"
+                + "MG  - Digital Mammography X-Ray Image Storage for Presentation\n"
+                + "PR  - Grayscale Softcopy Presentation State Storage\n"
+                + "KO  - Key Object Selection Document Storage\n"
+                + "SR  - Basic Text Structured Report Document Storage\n"
+                + "The Transfer Syntaxes may be specified by a comma "
+                + "separated list of UIDs or by one of following key "
+                + "words:\n"
+                + "IVRLE - offer only Implicit VR Little Endian "
+                + "Transfer Syntax\n"
+                + "LE - offer Explicit and Implicit VR Little Endian "
+                + "Transfer Syntax\n"
+                + "BE - offer Explicit VR Big Endian Transfer Syntax\n"
+                + "DEFL - offer Deflated Explicit VR Little "
+                + "Endian Transfer Syntax\n"
+                + "JPLL - offer JEPG Loss Less Transfer Syntaxes\n"
+                + "JPLY - offer JEPG Lossy Transfer Syntaxes\n"
+                + "MPEG2 - offer MPEG2 Transfer Syntax\n"
+                + "NOPX - offer No Pixel Data Transfer Syntax\n"
+                + "NOPXD - offer No Pixel Data Deflate Transfer Syntax\n"
+                + "If only the Storage SOP Class is specified, all "
+                + "Transfer Syntaxes listed above except No Pixel Data "
+                + "and No Pixel Data Delflate Transfer Syntax are "
+                + "offered.");
+        opts.addOption(OptionBuilder.create("cstore"));
+
+        OptionBuilder.withArgName("dir");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "store received objects into files in specified directory <dir>."
+                + " Do not store received objects by default.");
+        opts.addOption(OptionBuilder.create("cstoredest"));
+
+        opts.addOption("ivrle", false, "offer only Implicit VR Little Endian Transfer Syntax.");
+
+        OptionBuilder.withArgName("maxops");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription("maximum number of outstanding C-MOVE-RQ "
+                + "it may invoke asynchronously, 1 by default.");
+        opts.addOption(OptionBuilder.create("async"));
+
+        OptionBuilder.withArgName("maxops");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "maximum number of outstanding storage operations performed "
+                + "asynchronously, unlimited by default.");
+        opts.addOption(OptionBuilder.create("storeasync"));
+
+        opts.addOption("noextneg", false, "disable extended negotiation.");
+        opts.addOption("rel", false,
+                "negotiate support of relational queries and retrieval.");
+        opts.addOption("datetime", false,
+                "negotiate support of combined date and time attribute range matching.");
+        opts.addOption("fuzzy", false,
+                "negotiate support of fuzzy semantic person name attribute matching.");
+
+        opts.addOption("retall", false, "negotiate private FIND SOP Classes "
+                + "to fetch all available attributes of matching entities.");
+        opts.addOption("blocked", false, "negotiate private FIND SOP Classes "
+                + "to return attributes of several matching entities per FIND "
+                + "response.");
+        opts.addOption("vmf", false, "negotiate private FIND SOP Classes to "
+                + "return attributes of legacy CT/MR images of one series as "
+                + "virtual multiframe object.");
+        opts.addOption("pdv1", false,
+                "send only one PDV in one P-Data-TF PDU, pack command and data "
+                + "PDV in one P-DATA-TF PDU by default.");
+        opts.addOption("tcpdelay", false,
+                "set TCP_NODELAY socket option to false, true by default");
+
+        OptionBuilder.withArgName("ms");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "timeout in ms for TCP connect, no timeout by default");
+        opts.addOption(OptionBuilder.create("connectTO"));
+
+        OptionBuilder.withArgName("ms");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "delay in ms for Socket close after sending A-ABORT, 50ms by default");
+        opts.addOption(OptionBuilder.create("soclosedelay"));
+
+        OptionBuilder.withArgName("ms");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "period in ms to check for outstanding DIMSE-RSP, 10s by default");
+        opts.addOption(OptionBuilder.create("reaper"));
+
+        OptionBuilder.withArgName("ms");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "timeout in ms for receiving C-FIND-RSP, 60s by default");
+        opts.addOption(OptionBuilder.create("cfindrspTO"));
+
+        OptionBuilder.withArgName("ms");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "timeout in ms for receiving C-MOVE-RSP and C-GET RSP, 600s by default");
+        opts.addOption(OptionBuilder.create("cmoverspTO"));
+
+        OptionBuilder.withArgName("ms");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "timeout in ms for receiving C-GET-RSP and C-MOVE RSP, 600s by default");
+        opts.addOption(OptionBuilder.create("cgetrspTO"));
+
+        OptionBuilder.withArgName("ms");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "timeout in ms for receiving A-ASSOCIATE-AC, 5s by default");
+        opts.addOption(OptionBuilder.create("acceptTO"));
+
+        OptionBuilder.withArgName("ms");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "timeout in ms for receiving A-RELEASE-RP, 5s by default");
+        opts.addOption(OptionBuilder.create("releaseTO"));
+
+        OptionBuilder.withArgName("KB");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "maximal length in KB of received P-DATA-TF PDUs, 16KB by default");
+        opts.addOption(OptionBuilder.create("rcvpdulen"));
+
+        OptionBuilder.withArgName("KB");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "maximal length in KB of sent P-DATA-TF PDUs, 16KB by default");
+        opts.addOption(OptionBuilder.create("sndpdulen"));
+
+        OptionBuilder.withArgName("KB");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "set SO_RCVBUF socket option to specified value in KB");
+        opts.addOption(OptionBuilder.create("sorcvbuf"));
+
+        OptionBuilder.withArgName("KB");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "set SO_SNDBUF socket option to specified value in KB");
+        opts.addOption(OptionBuilder.create("sosndbuf"));
+
+        OptionBuilder.withArgName("KB");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "minimal buffer size to write received object to file, 1KB by default");
+        opts.addOption(OptionBuilder.create("filebuf"));
+
+        OptionGroup qrlevel = new OptionGroup();
+
+        OptionBuilder.withDescription("perform patient level query, multiple "
+                + "exclusive with -S and -I, perform study level query "
+                + "by default.");
+        OptionBuilder.withLongOpt("patient");
+        opts.addOption(OptionBuilder.create("P"));
+
+        OptionBuilder.withDescription("perform series level query, multiple "
+                + "exclusive with -P and -I, perform study level query "
+                + "by default.");
+        OptionBuilder.withLongOpt("series");
+        opts.addOption(OptionBuilder.create("S"));
+
+        OptionBuilder.withDescription("perform instance level query, multiple "
+                + "exclusive with -P and -S, perform study level query "
+                + "by default.");
+        OptionBuilder.withLongOpt("image");
+        opts.addOption(OptionBuilder.create("I"));
+
+        OptionBuilder.withArgName("cuid");
+        OptionBuilder.hasArgs();
+        OptionBuilder.withDescription("negotiate addition private C-FIND SOP "
+                + "class with specified UID");
+        opts.addOption(OptionBuilder.create("cfind"));
+
+        opts.addOptionGroup(qrlevel);
+
+        OptionBuilder.withArgName("[seq/]attr=value");
+        OptionBuilder.hasArgs();
+        OptionBuilder.withValueSeparator('=');
+        OptionBuilder.withDescription("specify matching key. attr can be "
+                + "specified by name or tag value (in hex), e.g. PatientName "
+                + "or 00100010. Attributes in nested Datasets can "
+                + "be specified by including the name/tag value of "
+                + "the sequence attribute, e.g. 00400275/00400009 "
+                + "for Scheduled Procedure Step ID in the Request "
+                + "Attributes Sequence");
+        opts.addOption(OptionBuilder.create("q"));
+
+        OptionBuilder.withArgName("attr");
+        OptionBuilder.hasArgs();
+        OptionBuilder.withDescription("specify additional return key. attr can "
+                + "be specified by name or tag value (in hex).");
+        opts.addOption(OptionBuilder.create("r"));
+
+        OptionBuilder.withArgName("num");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription("cancel query after receive of specified "
+                + "number of responses, no cancel by default");
+        opts.addOption(OptionBuilder.create("C"));
+
+        OptionBuilder.withArgName("aet");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription("retrieve matching objects to specified "
+                + "move destination.");
+        opts.addOption(OptionBuilder.create("cmove"));
+
+        opts.addOption("evalRetrieveAET", false,
+                "Only Move studies not allready stored on destination AET");
+        opts.addOption("lowprior", false,
+                "LOW priority of the C-FIND/C-MOVE operation, MEDIUM by default");
+        opts.addOption("highprior", false,
+                "HIGH priority of the C-FIND/C-MOVE operation, MEDIUM by default");
+
+        OptionBuilder.withArgName("num");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription("repeat query (and retrieve) several times");
+        opts.addOption(OptionBuilder.create("repeat"));
+
+        OptionBuilder.withArgName("ms");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "delay in ms between repeated query (and retrieve), no delay by default");
+        opts.addOption(OptionBuilder.create("repeatdelay"));
+
+        opts.addOption("reuseassoc", false,
+                "Reuse association for repeated query (and retrieve)");
+        opts.addOption("closeassoc", false,
+                "Close association between repeated query (and retrieve)");
+
+        opts.addOption("h", "help", false, "print this message");
+        opts.addOption("V", "version", false,
+                "print the version information and exit");
+        CommandLine cl = null;
+        try {
+            cl = new GnuParser().parse(opts, args);
+        } catch (ParseException e) {
+            throw new RuntimeException("unreachable");
+        }       
+        return cl;
+    }
+
+    @SuppressWarnings("unchecked")
+    public static void main(String[] args) {
+        CommandLine cl = parse(args);
+        DcmQR dcmqr = new DcmQR(cl.hasOption("device")
+                ? cl.getOptionValue("device") : "DCMQR");
+        final List<String> argList = cl.getArgList();
+        String remoteAE = argList.get(0);
+        String[] calledAETAddress = split(remoteAE, '@');
+        dcmqr.setCalledAET(calledAETAddress[0], cl.hasOption("reuseassoc"));
+        if (calledAETAddress[1] == null) {
+            dcmqr.setRemoteHost("127.0.0.1");
+            dcmqr.setRemotePort(104);
+        } else {
+            String[] hostPort = split(calledAETAddress[1], ':');
+            dcmqr.setRemoteHost(hostPort[0]);
+            dcmqr.setRemotePort(toPort(hostPort[1]));
+        }
+        if (cl.hasOption("L")) {
+            String localAE = cl.getOptionValue("L");
+            String[] localPort = split(localAE, ':');
+            if (localPort[1] != null) {
+                dcmqr.setLocalPort(toPort(localPort[1]));
+            }
+            String[] callingAETHost = split(localPort[0], '@');
+            dcmqr.setCalling(callingAETHost[0]);
+            if (callingAETHost[1] != null) {
+                dcmqr.setLocalHost(callingAETHost[1]);
+            }
+        }
+        if (cl.hasOption("username")) {
+            String username = cl.getOptionValue("username");
+            UserIdentity userId;
+            if (cl.hasOption("passcode")) {
+                String passcode = cl.getOptionValue("passcode");
+                userId = new UserIdentity.UsernamePasscode(username,
+                        passcode.toCharArray());
+            } else {
+                userId = new UserIdentity.Username(username);
+            }
+            userId.setPositiveResponseRequested(cl.hasOption("uidnegrsp"));
+            dcmqr.setUserIdentity(userId);
+        }
+        if (cl.hasOption("connectTO")) {
+            dcmqr.setConnectTimeout(parseInt(cl.getOptionValue("connectTO"),
+                    "illegal argument of option -connectTO", 1,
+                    Integer.MAX_VALUE));
+        }
+        if (cl.hasOption("reaper")) {
+            dcmqr.setAssociationReaperPeriod(parseInt(cl.getOptionValue("reaper"),
+                    "illegal argument of option -reaper", 1,
+                    Integer.MAX_VALUE));
+        }
+        if (cl.hasOption("cfindrspTO")) {
+            dcmqr.setDimseRspTimeout(parseInt(cl.getOptionValue("cfindrspTO"),
+                    "illegal argument of option -cfindrspTO", 1, Integer.MAX_VALUE));
+        }
+        if (cl.hasOption("cmoverspTO")) {
+            dcmqr.setRetrieveRspTimeout(parseInt(cl.getOptionValue("cmoverspTO"),
+                    "illegal argument of option -cmoverspTO", 1, Integer.MAX_VALUE));
+        }
+        if (cl.hasOption("cgetrspTO")) {
+            dcmqr.setRetrieveRspTimeout(parseInt(cl.getOptionValue("cgetrspTO"),
+                    "illegal argument of option -cgetrspTO", 1, Integer.MAX_VALUE));
+        }
+        if (cl.hasOption("acceptTO")) {
+            dcmqr.setAcceptTimeout(parseInt(cl.getOptionValue("acceptTO"),
+                    "illegal argument of option -acceptTO", 1,
+                    Integer.MAX_VALUE));
+        }
+        if (cl.hasOption("releaseTO")) {
+            dcmqr.setReleaseTimeout(parseInt(cl.getOptionValue("releaseTO"),
+                    "illegal argument of option -releaseTO", 1,
+                    Integer.MAX_VALUE));
+        }
+        if (cl.hasOption("soclosedelay")) {
+            dcmqr.setSocketCloseDelay(parseInt(cl.getOptionValue("soclosedelay"),
+                    "illegal argument of option -soclosedelay", 1, 10000));
+        }
+        if (cl.hasOption("rcvpdulen")) {
+            dcmqr.setMaxPDULengthReceive(parseInt(cl.getOptionValue("rcvpdulen"),
+                    "illegal argument of option -rcvpdulen", 1, 10000)
+                    * KB);
+        }
+        if (cl.hasOption("sndpdulen")) {
+            dcmqr.setMaxPDULengthSend(parseInt(cl.getOptionValue("sndpdulen"),
+                    "illegal argument of option -sndpdulen", 1, 10000)
+                    * KB);
+        }
+        if (cl.hasOption("sosndbuf")) {
+            dcmqr.setSendBufferSize(parseInt(cl.getOptionValue("sosndbuf"),
+                    "illegal argument of option -sosndbuf", 1, 10000)
+                    * KB);
+        }
+        if (cl.hasOption("sorcvbuf")) {
+            dcmqr.setReceiveBufferSize(parseInt(cl.getOptionValue("sorcvbuf"),
+                    "illegal argument of option -sorcvbuf", 1, 10000)
+                    * KB);
+        }
+        if (cl.hasOption("filebuf")) {
+            dcmqr.setFileBufferSize(parseInt(cl.getOptionValue("filebuf"),
+                    "illegal argument of option -filebuf", 1, 10000)
+                    * KB);
+        }
+        dcmqr.setPackPDV(!cl.hasOption("pdv1"));
+        dcmqr.setTcpNoDelay(!cl.hasOption("tcpdelay"));
+        dcmqr.setMaxOpsInvoked(cl.hasOption("async") ? parseInt(cl.getOptionValue("async"), "illegal argument of option -async",
+                0, 0xffff) : 1);
+        dcmqr.setMaxOpsPerformed(cl.hasOption("cstoreasync") ? parseInt(cl.getOptionValue("cstoreasync"), "illegal argument of option -cstoreasync",
+                0, 0xffff) : 0);
+        if (cl.hasOption("C")) {
+            dcmqr.setCancelAfter(parseInt(cl.getOptionValue("C"),
+                    "illegal argument of option -C", 1, Integer.MAX_VALUE));
+        }
+        if (cl.hasOption("lowprior")) {
+            dcmqr.setPriority(CommandUtils.LOW);
+        }
+        if (cl.hasOption("highprior")) {
+            dcmqr.setPriority(CommandUtils.HIGH);
+        }      
+        /*--------------------------Added by Babu Hussain----------------------------*/
+        CUID[] cuidValues = CUID.values();
+        String[] tsuids = DEF_TS;
+        for (int i = 0; i < cuidValues.length; i++) {
+            String cuid = cuidValues[i].uid;
+            dcmqr.addStoreTransferCapability(cuid, tsuids);
+        }
+        /*---------------------------------------------------------------------------*/
+        dcmqr.setCGet(cl.hasOption("cget"));
+        if (cl.hasOption("cmove")) {
+            dcmqr.setMoveDest(cl.getOptionValue("cmove"));
+        }
+        if (cl.hasOption("evalRetrieveAET")) {
+            dcmqr.setEvalRetrieveAET(true);
+        }
+        if (cl.hasOption("P")) {
+            dcmqr.setQueryLevel(QueryRetrieveLevel.PATIENT);
+        } else if (cl.hasOption("S")) {
+            dcmqr.setQueryLevel(QueryRetrieveLevel.SERIES);
+        } else if (cl.hasOption("I")) {
+            dcmqr.setQueryLevel(QueryRetrieveLevel.IMAGE);
+        } else {
+            dcmqr.setQueryLevel(QueryRetrieveLevel.STUDY);
+        }
+        if (cl.hasOption("noextneg")) {
+            dcmqr.setNoExtNegotiation(true);
+        }
+        if (cl.hasOption("rel")) {
+            dcmqr.setRelationQR(true);
+        }
+        if (cl.hasOption("datetime")) {
+            dcmqr.setDateTimeMatching(true);
+        }
+        if (cl.hasOption("fuzzy")) {
+            dcmqr.setFuzzySemanticPersonNameMatching(true);
+        }
+        if (!cl.hasOption("P")) {
+            if (cl.hasOption("retall")) {
+                dcmqr.addPrivate(
+                        UID.PrivateStudyRootQueryRetrieveInformationModelFIND);
+            }
+            if (cl.hasOption("blocked")) {
+                dcmqr.addPrivate(
+                        UID.PrivateBlockedStudyRootQueryRetrieveInformationModelFIND);
+            }
+            if (cl.hasOption("vmf")) {
+                dcmqr.addPrivate(
+                        UID.PrivateVirtualMultiframeStudyRootQueryRetrieveInformationModelFIND);
+            }
+        }
+        if (cl.hasOption("cfind")) {
+            String[] cuids = cl.getOptionValues("cfind");
+            for (int i = 0; i < cuids.length; i++) {
+                dcmqr.addPrivate(cuids[i]);
+            }
+        }
+        if (cl.hasOption("q")) {
+            String[] matchingKeys = cl.getOptionValues("q");
+            for (int i = 1; i < matchingKeys.length; i++, i++) {
+                dcmqr.addMatchingKey(Tag.toTagPath(matchingKeys[i - 1]), matchingKeys[i]);
+            }
+        }
+        if (cl.hasOption("r")) {
+            String[] returnKeys = cl.getOptionValues("r");
+            for (int i = 0; i < returnKeys.length; i++) {
+                dcmqr.addReturnKey(Tag.toTagPath(returnKeys[i]));
+            }
+        }
+
+        dcmqr.configureTransferCapability(cl.hasOption("ivrle"));
+
+
+        int repeat = cl.hasOption("repeat") ? parseInt(cl.getOptionValue("repeat"),
+                "illegal argument of option -repeat", 1, Integer.MAX_VALUE) : 0;
+        int interval = cl.hasOption("repeatdelay") ? parseInt(cl.getOptionValue("repeatdelay"),
+                "illegal argument of option -repeatdelay", 1, Integer.MAX_VALUE)
+                : 0;
+        boolean closeAssoc = cl.hasOption("closeassoc");
+
+        if (cl.hasOption("tls")) {
+            String cipher = cl.getOptionValue("tls");
+            if ("NULL".equalsIgnoreCase(cipher)) {
+                dcmqr.setTlsWithoutEncyrption();
+            } else if ("3DES".equalsIgnoreCase(cipher)) {
+                dcmqr.setTls3DES_EDE_CBC();
+            } else if ("AES".equalsIgnoreCase(cipher)) {
+                dcmqr.setTlsAES_128_CBC();
+            }
+            if (cl.hasOption("tls1")) {
+                dcmqr.setTlsProtocol(TLS1);
+            } else if (cl.hasOption("ssl3")) {
+                dcmqr.setTlsProtocol(SSL3);
+            } else if (cl.hasOption("no_tls1")) {
+                dcmqr.setTlsProtocol(NO_TLS1);
+            } else if (cl.hasOption("no_ssl3")) {
+                dcmqr.setTlsProtocol(NO_SSL3);
+            } else if (cl.hasOption("no_ssl2")) {
+                dcmqr.setTlsProtocol(NO_SSL2);
+            }
+            dcmqr.setTlsNeedClientAuth(!cl.hasOption("noclientauth"));
+            if (cl.hasOption("keystore")) {
+                dcmqr.setKeyStoreURL(cl.getOptionValue("keystore"));
+            }
+            if (cl.hasOption("keystorepw")) {
+                dcmqr.setKeyStorePassword(
+                        cl.getOptionValue("keystorepw"));
+            }
+            if (cl.hasOption("keypw")) {
+                dcmqr.setKeyPassword(cl.getOptionValue("keypw"));
+            }
+            if (cl.hasOption("truststore")) {
+                dcmqr.setTrustStoreURL(
+                        cl.getOptionValue("truststore"));
+            }
+            if (cl.hasOption("truststorepw")) {
+                dcmqr.setTrustStorePassword(
+                        cl.getOptionValue("truststorepw"));
+            }
+            long t1 = System.currentTimeMillis();
+            try {
+                dcmqr.initTLS();
+            } catch (Exception e) {
+                System.err.println("ERROR: Failed to initialize TLS context:"
+                        + e.getMessage());                
+            }
+            long t2 = System.currentTimeMillis();
+            LOG.info("Initialize TLS context in {} s", Float.valueOf((t2 - t1) / 1000f));
+        }
+        try {
+            dcmqr.start();
+        } catch (Exception e) {
+            System.err.println("ERROR: Failed to start server for receiving "
+                    + "requested objects:" + e.getMessage());           
+        }
+        try {
+            long t1 = System.currentTimeMillis();
+            try {
+                dcmqr.open();
+            } catch (Exception e) {
+                LOG.error("Failed to establish association:", e);               
+            }
+            long t2 = System.currentTimeMillis();
+            LOG.info("Connected to {} in {} s", remoteAE, Float.valueOf((t2 - t1) / 1000f));
+
+            for (;;) {
+                List<DicomObject> result = dcmqr.query();
+                long t3 = System.currentTimeMillis();
+                LOG.info("Received {} matching entries in {} s", Integer.valueOf(result.size()),
+                        Float.valueOf((t3 - t2) / 1000f));
+                if (dcmqr.isCMove() || dcmqr.isCGet()) {
+                    if (dcmqr.isCMove()) {
+                        dcmqr.move(result);
+                    } else {
+                        dcmqr.get(result);
+                    }
+                    long t4 = System.currentTimeMillis();
+                    LOG.info("Retrieved {} objects (warning: {}, failed: {}) in {}s",
+                            new Object[]{
+                                Integer.valueOf(dcmqr.getTotalRetrieved()),
+                                Integer.valueOf(dcmqr.getWarning()),
+                                Integer.valueOf(dcmqr.getFailed()),
+                                Float.valueOf((t4 - t3) / 1000f)});
+                }
+                if (repeat == 0 || closeAssoc) {
+                    try {
+                        dcmqr.close();
+                    } catch (InterruptedException e) {
+                        LOG.error(e.getMessage(), e);
+                    }
+                    LOG.info("Released connection to {}", remoteAE);
+                }
+                if (repeat-- == 0) {
+                    break;
+                }
+                Thread.sleep(interval);
+                long t4 = System.currentTimeMillis();
+                dcmqr.open();
+                t2 = System.currentTimeMillis();
+                LOG.info("Reconnect or reuse connection to {} in {} s",
+                        remoteAE, Float.valueOf((t2 - t4) / 1000f));
+            }
+        } catch (IOException e) {
+            LOG.error(e.getMessage(), e);
+        } catch (InterruptedException e) {
+            LOG.error(e.getMessage(), e);
+        } catch (ConfigurationException e) {
+            LOG.error(e.getMessage(), e);
+        } finally {
+            dcmqr.stop();
+        }
+    }
+
+    public void addStoreTransferCapability(String cuid, String[] tsuids) {
+        storeTransferCapability.add(new TransferCapability(
+                cuid, tsuids, TransferCapability.SCP));
+    }
+
+    public void setEvalRetrieveAET(boolean evalRetrieveAET) {
+        this.evalRetrieveAET = evalRetrieveAET;
+    }
+
+    public boolean isEvalRetrieveAET() {
+        return evalRetrieveAET;
+    }
+
+    public void setNoExtNegotiation(boolean b) {
+        this.noExtNegotiation = b;
+    }
+
+    public void setFuzzySemanticPersonNameMatching(boolean b) {
+        this.fuzzySemanticPersonNameMatching = b;
+    }
+
+    public void setDateTimeMatching(boolean b) {
+        this.dateTimeMatching = b;
+    }
+
+    public void setRelationQR(boolean b) {
+        this.relationQR = b;
+    }
+
+    public final int getFailed() {
+        return failed;
+    }
+
+    public final int getWarning() {
+        return warning;
+    }
+
+    public final int getTotalRetrieved() {
+        return completed + warning;
+    }
+
+    public void setCancelAfter(int limit) {
+        this.cancelAfter = limit;
+    }
+
+    public void addMatchingKey(int[] tagPath, String value) {
+        keys.putString(tagPath, null, value);
+    }
+
+    public void addReturnKey(int[] tagPath) {
+        keys.putNull(tagPath, null);
+    }
+
+    public void configureTransferCapability(boolean ivrle) {
+        String[] findcuids = qrlevel.getFindClassUids();
+        String[] movecuids = moveDest != null ? qrlevel.getMoveClassUids()
+                : EMPTY_STRING;
+        String[] getcuids = cget ? qrlevel.getGetClassUids()
+                : EMPTY_STRING;
+        TransferCapability[] tcs = new TransferCapability[findcuids.length
+                + privateFind.size() + movecuids.length + getcuids.length
+                + storeTransferCapability.size()];
+        int i = 0;
+        for (String cuid : findcuids) {
+            tcs[i++] = mkFindTC(cuid, ivrle ? IVRLE_TS : NATIVE_LE_TS);
+        }
+        for (String cuid : privateFind) {
+            tcs[i++] = mkFindTC(cuid, ivrle ? IVRLE_TS : DEFLATED_TS);
+        }
+        for (String cuid : movecuids) {
+            tcs[i++] = mkRetrieveTC(cuid, ivrle ? IVRLE_TS : NATIVE_LE_TS);
+        }
+        for (String cuid : getcuids) {
+            tcs[i++] = mkRetrieveTC(cuid, ivrle ? IVRLE_TS : NATIVE_LE_TS);
+        }
+        for (TransferCapability tc : storeTransferCapability) {
+            tcs[i++] = tc;
+        }
+        ae.setTransferCapability(tcs);
+        if (!storeTransferCapability.isEmpty()) {
+            ae.register(createStorageService());
+        }
+    }
+
+    private DicomService createStorageService() {
+        String[] cuids = new String[storeTransferCapability.size()];
+        int i = 0;
+        for (TransferCapability tc : storeTransferCapability) {
+            cuids[i++] = tc.getSopClass();
+        }
+        return new StorageService(cuids) {
+
+            @Override
+            protected void onCStoreRQ(Association as, int pcid, DicomObject rq,
+                    PDVInputStream dataStream, String tsuid, DicomObject rsp)
+                    throws IOException, DicomServiceException {                
+                if (storeDest == null) {
+                    super.onCStoreRQ(as, pcid, rq, dataStream, tsuid, rsp);
+                } else {
+                    File file = null;
+                    try {
+                        String cuid = rq.getString(Tag.AffectedSOPClassUID);
+                        String iuid = rq.getString(Tag.AffectedSOPInstanceUID);
+                        DicomObject data = dataStream.readDataset();
+                        String suid = data.getString(Tag.StudyInstanceUID);
+                        Calendar today = Calendar.getInstance();
+                        File struturedDestination = new File(destination.getAbsolutePath() + File.separator + today.get(Calendar.YEAR) + File.separator + today.get(Calendar.MONTH) + File.separator + today.get(Calendar.DATE) + File.separator + suid);
+                        String child[] = struturedDestination.list();
+                        if (child == null) {
+                            struturedDestination.mkdirs();
+                        }
+                        file = devnull != null ? struturedDestination : new File(struturedDestination, iuid);
+                        BasicDicomObject fmi = new BasicDicomObject();
+                        fmi.initFileMetaInformation(cuid, iuid, tsuid);
+//                        File file = devnull ? storeDest : new File(storeDest, iuid);
+                        FileOutputStream fos = new FileOutputStream(file);
+                        BufferedOutputStream bos = new BufferedOutputStream(fos,
+                                fileBufferSize);
+                        DicomOutputStream dos = new DicomOutputStream(bos);
+                        dos.writeFileMetaInformation(fmi);
+//                      dataStream.copyTo(dos);
+                        dos.writeDataset(data, tsuid);
+                        dos.close();
+                    } catch (IOException e) {
+                        throw new DicomServiceException(rq, Status.ProcessingFailure, e.getMessage());
+                    }
+                    NetworkQueueUpdateDelegate networkQueueUpdateDelegate = new NetworkQueueUpdateDelegate();
+                    networkQueueUpdateDelegate.updateReceiveTable(file, as.getCallingAET());
+                }
+            }
+        };
+    }
+
+    private TransferCapability mkRetrieveTC(String cuid, String[] ts) {
+        ExtRetrieveTransferCapability tc = new ExtRetrieveTransferCapability(
+                cuid, ts, TransferCapability.SCU);
+        tc.setExtInfoBoolean(
+                ExtRetrieveTransferCapability.RELATIONAL_RETRIEVAL, relationQR);
+        if (noExtNegotiation) {
+            tc.setExtInfo(null);
+        }
+        return tc;
+    }
+
+    private TransferCapability mkFindTC(String cuid, String[] ts) {
+        ExtQueryTransferCapability tc = new ExtQueryTransferCapability(cuid,
+                ts, TransferCapability.SCU);
+        tc.setExtInfoBoolean(ExtQueryTransferCapability.RELATIONAL_QUERIES,
+                relationQR);
+        tc.setExtInfoBoolean(ExtQueryTransferCapability.DATE_TIME_MATCHING,
+                dateTimeMatching);
+        tc.setExtInfoBoolean(ExtQueryTransferCapability.FUZZY_SEMANTIC_PN_MATCHING,
+                fuzzySemanticPersonNameMatching);
+        if (noExtNegotiation) {
+            tc.setExtInfo(null);
+        }
+        return tc;
+    }
+
+    public void setQueryLevel(QueryRetrieveLevel qrlevel) {
+        this.qrlevel = qrlevel;
+        keys.putString(Tag.QueryRetrieveLevel, VR.CS, qrlevel.getCode());
+        for (int tag : qrlevel.getReturnKeys()) {
+            keys.putNull(tag, null);
+        }
+    }
+
+    public final void addPrivate(String cuid) {
+        privateFind.add(cuid);
+    }
+
+    public void setCGet(boolean cget) {
+        this.cget = cget;
+    }
+
+    public boolean isCGet() {
+        return cget;
+    }
+
+    public void setMoveDest(String aet) {
+        moveDest = aet;
+    }
+
+    public boolean isCMove() {
+        return moveDest != null;
+    }
+
+    private static int toPort(String port) {
+        return port != null ? parseInt(port, "illegal port number", 1, 0xffff)
+                : 104;
+    }
+
+    private static int parseInt(String s, String errPrompt, int min, int max) {
+        try {
+            int i = Integer.parseInt(s);
+            if (i >= min && i <= max) {
+                return i;
+            }
+        } catch (NumberFormatException e) {
+            // parameter is not a valid integer; fall through to exit
+        }
+        throw new RuntimeException();
+    }
+
+    private static String[] split(String s, char delim) {
+        String[] s2 = {s, null};
+        int pos = s.indexOf(delim);
+        if (pos != -1) {
+            s2[0] = s.substring(0, pos);
+            s2[1] = s.substring(pos + 1);
+        }
+        return s2;
+    }
+
+    public void start() throws IOException {     
+        ApplicationContext.mainScreen.stopReceiver();        
+        if (cgetServiceCount==1 && conn.isListening()) {
+            conn.bind(executor);
+        }
+    }
+
+    public void stop() {    
+        if (conn.isListening()) {
+            conn.unbind();
+        }
+        try {
+            cgetServiceCount--;
+            if(cgetServiceCount==0)
+            ApplicationContext.mainScreen.startReceiver();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void open() throws IOException, ConfigurationException,
+            InterruptedException {
+        assoc = ae.connect(remoteAE, executor);
+    }
+
+    public List<DicomObject> query() throws IOException, InterruptedException {
+        List<DicomObject> result = new ArrayList<DicomObject>();
+        TransferCapability tc = selectFindTransferCapability();
+        String cuid = tc.getSopClass();
+        String tsuid = selectTransferSyntax(tc);
+        if (tc.getExtInfoBoolean(ExtQueryTransferCapability.RELATIONAL_QUERIES)
+                || containsUpperLevelUIDs(cuid)) {
+            LOG.info("Send Query Request using {}:\n{}",
+                    UIDDictionary.getDictionary().prompt(cuid), keys);
+            DimseRSP rsp = assoc.cfind(cuid, priority, keys, tsuid, cancelAfter);
+            while (rsp.next()) {
+                DicomObject cmd = rsp.getCommand();
+                if (CommandUtils.isPending(cmd)) {
+                    DicomObject data = rsp.getDataset();
+                    result.add(data);
+                    LOG.info("Query Response #{}:\n{}", Integer.valueOf(result.size()), data);
+                }
+            }
+        } else {
+            List<DicomObject> upperLevelUIDs = queryUpperLevelUIDs(cuid, tsuid);
+            List<DimseRSP> rspList = new ArrayList<DimseRSP>(upperLevelUIDs.size());
+            for (int i = 0, n = upperLevelUIDs.size(); i < n; i++) {
+                upperLevelUIDs.get(i).copyTo(keys);
+                LOG.info("Send Query Request #{}/{} using {}:\n{}",
+                        new Object[]{
+                            Integer.valueOf(i + 1),
+                            Integer.valueOf(n),
+                            UIDDictionary.getDictionary().prompt(cuid),
+                            keys
+                        });
+                rspList.add(assoc.cfind(cuid, priority, keys, tsuid, cancelAfter));
+            }
+            for (int i = 0, n = rspList.size(); i < n; i++) {
+                DimseRSP rsp = rspList.get(i);
+                for (int j = 0; rsp.next(); ++j) {
+                    DicomObject cmd = rsp.getCommand();
+                    if (CommandUtils.isPending(cmd)) {
+                        DicomObject data = rsp.getDataset();
+                        result.add(data);
+                        LOG.info("Query Response #{} for Query Request #{}/{}:\n{}",
+                                new Object[]{Integer.valueOf(j + 1), Integer.valueOf(i + 1), Integer.valueOf(n), data});
+                    }
+                }
+            }
+        }
+        return result;
+    }
+
+    @SuppressWarnings("fallthrough")
+    private boolean containsUpperLevelUIDs(String cuid) {
+        switch (qrlevel) {
+            case IMAGE:
+                if (!keys.containsValue(Tag.SeriesInstanceUID)) {
+                    return false;
+                }
+            // fall through
+            case SERIES:
+                if (!keys.containsValue(Tag.StudyInstanceUID)) {
+                    return false;
+                }
+            // fall through
+            case STUDY:
+                if (Arrays.asList(PATIENT_LEVEL_FIND_CUID).contains(cuid)
+                        && !keys.containsValue(Tag.PatientID)) {
+                    return false;
+                }
+            // fall through
+            case PATIENT:
+            // fall through
+        }
+        return true;
+    }
+
+    private List<DicomObject> queryUpperLevelUIDs(String cuid, String tsuid)
+            throws IOException, InterruptedException {
+        List<DicomObject> keylist = new ArrayList<DicomObject>();
+        if (Arrays.asList(PATIENT_LEVEL_FIND_CUID).contains(cuid)) {
+            queryPatientIDs(cuid, tsuid, keylist);
+            if (qrlevel == QueryRetrieveLevel.STUDY) {
+                return keylist;
+            }
+            keylist = queryStudyOrSeriesIUIDs(cuid, tsuid, keylist,
+                    Tag.StudyInstanceUID, STUDY_MATCHING_KEYS, QueryRetrieveLevel.STUDY);
+        } else {
+            keylist.add(new BasicDicomObject());
+            keylist = queryStudyOrSeriesIUIDs(cuid, tsuid, keylist,
+                    Tag.StudyInstanceUID, PATIENT_STUDY_MATCHING_KEYS, QueryRetrieveLevel.STUDY);
+        }
+        if (qrlevel == QueryRetrieveLevel.IMAGE) {
+            keylist = queryStudyOrSeriesIUIDs(cuid, tsuid, keylist,
+                    Tag.SeriesInstanceUID, SERIES_MATCHING_KEYS, QueryRetrieveLevel.SERIES);
+        }
+        return keylist;
+    }
+
+    private void queryPatientIDs(String cuid, String tsuid,
+            List<DicomObject> keylist) throws IOException, InterruptedException {
+        String patID = keys.getString(Tag.PatientID);
+        String issuer = keys.getString(Tag.IssuerOfPatientID);
+        if (patID != null) {
+            DicomObject patIdKeys = new BasicDicomObject();
+            patIdKeys.putString(Tag.PatientID, VR.LO, patID);
+            if (issuer != null) {
+                patIdKeys.putString(Tag.IssuerOfPatientID, VR.LO, issuer);
+            }
+            keylist.add(patIdKeys);
+        } else {
+            DicomObject patLevelQuery = new BasicDicomObject();
+            keys.subSet(PATIENT_MATCHING_KEYS).copyTo(patLevelQuery);
+            patLevelQuery.putNull(Tag.PatientID, VR.LO);
+            patLevelQuery.putNull(Tag.IssuerOfPatientID, VR.LO);
+            patLevelQuery.putString(Tag.QueryRetrieveLevel, VR.CS, "PATIENT");
+            LOG.info("Send Query Request using {}:\n{}",
+                    UIDDictionary.getDictionary().prompt(cuid), patLevelQuery);
+            DimseRSP rsp = assoc.cfind(cuid, priority, patLevelQuery, tsuid,
+                    Integer.MAX_VALUE);
+            for (int i = 0; rsp.next(); ++i) {
+                DicomObject cmd = rsp.getCommand();
+                if (CommandUtils.isPending(cmd)) {
+                    DicomObject data = rsp.getDataset();
+                    LOG.info("Query Response #{}:\n{}", Integer.valueOf(i + 1), data);
+                    DicomObject patIdKeys = new BasicDicomObject();
+                    patIdKeys.putString(Tag.PatientID, VR.LO,
+                            data.getString(Tag.PatientID));
+                    issuer = keys.getString(Tag.IssuerOfPatientID);
+                    if (issuer != null) {
+                        patIdKeys.putString(Tag.IssuerOfPatientID, VR.LO,
+                                issuer);
+                    }
+                    keylist.add(patIdKeys);
+                }
+            }
+        }
+    }
+
+    private List<DicomObject> queryStudyOrSeriesIUIDs(String cuid, String tsuid,
+            List<DicomObject> upperLevelIDs, int uidTag, int[] matchingKeys,
+            QueryRetrieveLevel qrLevel) throws IOException,
+            InterruptedException {
+        List<DicomObject> keylist = new ArrayList<DicomObject>();
+        String uid = keys.getString(uidTag);
+        for (DicomObject upperLevelID : upperLevelIDs) {
+            if (uid != null) {
+                DicomObject suidKey = new BasicDicomObject();
+                upperLevelID.copyTo(suidKey);
+                suidKey.putString(uidTag, VR.UI, uid);
+                keylist.add(suidKey);
+            } else {
+                DicomObject keys2 = new BasicDicomObject();
+                keys.subSet(matchingKeys).copyTo(keys2);
+                upperLevelID.copyTo(keys2);
+                keys2.putNull(uidTag, VR.UI);
+                keys2.putString(Tag.QueryRetrieveLevel, VR.CS, qrLevel.getCode());
+                LOG.info("Send Query Request using {}:\n{}",
+                        UIDDictionary.getDictionary().prompt(cuid), keys2);
+                DimseRSP rsp = assoc.cfind(cuid, priority, keys2,
+                        tsuid, Integer.MAX_VALUE);
+                for (int i = 0; rsp.next(); ++i) {
+                    DicomObject cmd = rsp.getCommand();
+                    if (CommandUtils.isPending(cmd)) {
+                        DicomObject data = rsp.getDataset();
+                        LOG.info("Query Response #{}:\n{}", Integer.valueOf(i + 1), data);
+                        DicomObject suidKey = new BasicDicomObject();
+                        upperLevelID.copyTo(suidKey);
+                        suidKey.putString(uidTag, VR.UI, data.getString(uidTag));
+                        keylist.add(suidKey);
+                    }
+                }
+            }
+        }
+        return keylist;
+    }
+
+    public TransferCapability selectFindTransferCapability()
+            throws NoPresentationContextException {
+        TransferCapability tc;
+        if ((tc = selectTransferCapability(privateFind)) != null) {
+            return tc;
+        }
+        if ((tc = selectTransferCapability(qrlevel.getFindClassUids())) != null) {
+            return tc;
+        }
+        throw new NoPresentationContextException(UIDDictionary.getDictionary().prompt(qrlevel.getFindClassUids()[0])
+                + " not supported by " + remoteAE.getAETitle());
+    }
+
+    public String selectTransferSyntax(TransferCapability tc) {
+        String[] tcuids = tc.getTransferSyntax();
+        if (Arrays.asList(tcuids).indexOf(UID.DeflatedExplicitVRLittleEndian) != -1) {
+            return UID.DeflatedExplicitVRLittleEndian;
+        }
+        return tcuids[0];
+    }
+
+    public void move(List<DicomObject> findResults)
+            throws IOException, InterruptedException {
+        if (moveDest == null) {
+            throw new IllegalStateException("moveDest == null");
+        }
+        TransferCapability tc = selectTransferCapability(qrlevel.getMoveClassUids());
+        if (tc == null) {
+            throw new NoPresentationContextException(UIDDictionary.getDictionary().prompt(qrlevel.getMoveClassUids()[0])
+                    + " not supported by " + remoteAE.getAETitle());
+        }
+        String cuid = tc.getSopClass();
+        String tsuid = selectTransferSyntax(tc);
+        for (int i = 0, n = Math.min(findResults.size(), cancelAfter); i < n; ++i) {
+            DicomObject keys = findResults.get(i).subSet(MOVE_KEYS);
+            if (isEvalRetrieveAET() && containsMoveDest(
+                    findResults.get(i).getStrings(Tag.RetrieveAETitle))) {
+                LOG.info("Skipping {}:\n{}",
+                        UIDDictionary.getDictionary().prompt(cuid), keys);
+            } else {
+                LOG.info("Send Retrieve Request using {}:\n{}",
+                        UIDDictionary.getDictionary().prompt(cuid), keys);
+                assoc.cmove(cuid, priority, keys, tsuid, moveDest, rspHandler);
+            }
+        }
+        assoc.waitForDimseRSP();
+    }
+
+    private boolean containsMoveDest(String[] retrieveAETs) {
+        if (retrieveAETs != null) {
+            for (String aet : retrieveAETs) {
+                if (moveDest.equals(aet)) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    public void get(List<DicomObject> findResults)
+            throws IOException, InterruptedException {
+        TransferCapability tc = selectTransferCapability(qrlevel.getGetClassUids());
+        if (tc == null) {
+            throw new NoPresentationContextException(UIDDictionary.getDictionary().prompt(qrlevel.getGetClassUids()[0])
+                    + " not supported by " + remoteAE.getAETitle());
+        }
+        String cuid = tc.getSopClass();
+        String tsuid = selectTransferSyntax(tc);
+        for (int i = 0, n = Math.min(findResults.size(), cancelAfter); i < n; ++i) {
+            DicomObject keys = findResults.get(i).subSet(MOVE_KEYS);
+            LOG.info("Send Retrieve Request using {}:\n{}",
+                    UIDDictionary.getDictionary().prompt(cuid), keys);
+            assoc.cget(cuid, priority, keys, tsuid, rspHandler);
+        }
+        assoc.waitForDimseRSP();
+    }
+    private final DimseRSPHandler rspHandler = new DimseRSPHandler() {
+
+        @Override
+        public void onDimseRSP(Association as, DicomObject cmd,
+                DicomObject data) {
+            DcmQR.this.onMoveRSP(as, cmd, data);
+        }
+    };
+
+    protected void onMoveRSP(Association as, DicomObject cmd, DicomObject data) {
+        if (!CommandUtils.isPending(cmd)) {
+            completed += cmd.getInt(Tag.NumberOfCompletedSuboperations);
+            warning += cmd.getInt(Tag.NumberOfWarningSuboperations);
+            failed += cmd.getInt(Tag.NumberOfFailedSuboperations);
+        }
+    }
+
+    public TransferCapability selectTransferCapability(String[] cuid) {
+        TransferCapability tc;
+        for (int i = 0; i < cuid.length; i++) {
+            tc = assoc.getTransferCapabilityAsSCU(cuid[i]);
+            if (tc != null) {
+                return tc;
+            }
+        }
+        return null;
+    }
+
+    public TransferCapability selectTransferCapability(List<String> cuid) {
+        TransferCapability tc;
+        for (int i = 0, n = cuid.size(); i < n; i++) {
+            tc = assoc.getTransferCapabilityAsSCU(cuid.get(i));
+            if (tc != null) {
+                return tc;
+            }
+        }
+        return null;
+    }
+
+    public void close() throws InterruptedException {
+        assoc.release(true);
+    }
+
+    public void setStoreDestination(String filePath) {
+        this.storeDest = new File(filePath);
+        if ("/dev/null".equals(filePath)) {
+            devnull = destination;
+        }
+    }
+
+    public void setDestination(String filePath) {
+        destination = new File(filePath);
+        if ("/dev/null".equals(filePath)) {
+            devnull = destination;
+        } else {
+            devnull = null;
+        }
+    }
+
+    public void initTLS() throws GeneralSecurityException, IOException {
+        KeyStore keyStore = loadKeyStore(keyStoreURL, keyStorePassword);
+        KeyStore trustStore = loadKeyStore(trustStoreURL, trustStorePassword);
+        device.initTLS(keyStore,
+                keyPassword != null ? keyPassword : keyStorePassword,
+                trustStore);
+    }
+
+    private static KeyStore loadKeyStore(String url, char[] password)
+            throws GeneralSecurityException, IOException {
+        KeyStore key = KeyStore.getInstance(toKeyStoreType(url));
+        InputStream in = openFileOrURL(url);
+        try {
+            key.load(in, password);
+        } finally {
+            in.close();
+        }
+        return key;
+    }
+
+    private static InputStream openFileOrURL(String url) throws IOException {
+        if (url.startsWith("resource:")) {
+            return DcmQR.class.getClassLoader().getResourceAsStream(
+                    url.substring(9));
+        }
+        try {
+            return new URL(url).openStream();
+        } catch (MalformedURLException e) {
+            return new FileInputStream(url);
+        }
+    }
+
+    private static String toKeyStoreType(String fname) {
+        return fname.endsWith(".p12") || fname.endsWith(".P12")
+                ? "PKCS12" : "JKS";
+    }
+}
diff --git a/src/in/raster/mayam/util/core/DcmRcv.java b/src/in/raster/mayam/util/core/DcmRcv.java
new file mode 100644
index 0000000..29c0f69
--- /dev/null
+++ b/src/in/raster/mayam/util/core/DcmRcv.java
@@ -0,0 +1,1272 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is part of dcm4che, an implementation of DICOM(TM) in
+ * Java(TM), hosted at http://sourceforge.net/projects/dcm4che.
+ *
+ * The Initial Developer of the Original Code is
+ * Gunter Zeilinger, Huetteldorferstr. 24/10, 1150 Vienna/Austria/Europe.
+ * Portions created by the Initial Developer are Copyright (C) 2002-2005
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Gunter Zeilinger <gunterze at gmail.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.util.core;
+
+import in.raster.mayam.delegate.NetworkQueueUpdateDelegate;
+import in.raster.mayam.form.MainScreen;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.security.GeneralSecurityException;
+import java.security.KeyStore;
+import java.util.Calendar;
+import java.util.List;
+import java.util.Properties;
+import java.util.Timer;
+import java.util.concurrent.Executor;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.GnuParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.commons.cli.OptionGroup;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.dcm4che2.data.BasicDicomObject;
+import org.dcm4che2.data.DicomElement;
+import org.dcm4che2.data.DicomObject;
+import org.dcm4che2.data.Tag;
+import org.dcm4che2.data.UID;
+import org.dcm4che2.data.VR;
+import org.dcm4che2.filecache.FileCache;
+import org.dcm4che2.io.DicomOutputStream;
+import org.dcm4che2.net.Association;
+import org.dcm4che2.net.Device;
+import org.dcm4che2.net.DicomServiceException;
+import org.dcm4che2.net.DimseRSPHandler;
+import org.dcm4che2.net.NetworkApplicationEntity;
+import org.dcm4che2.net.NetworkConnection;
+import org.dcm4che2.net.NewThreadExecutor;
+import org.dcm4che2.net.PDVInputStream;
+import org.dcm4che2.net.Status;
+import org.dcm4che2.net.TransferCapability;
+import org.dcm4che2.net.service.VerificationService;
+import org.dcm4che2.util.CloseUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author gunter zeilinger(gunterze at gmail.com)
+ * @version $Revision: 13013 $ $Date: 2010-03-31 12:57:21 +0200 (Wed, 31 Mar 2010) $
+ * @since Oct 13, 2005
+ */
+public class DcmRcv {
+
+    private static final int NO_SUCH_OBJECT_INSTANCE = 0x0112;
+    static Logger LOG = LoggerFactory.getLogger(DcmRcv.class);
+    private static final int KB = 1024;
+    private static final String USAGE = "dcmrcv [Options] [<aet>[@<ip>]:]<port>";
+    private static final String DESCRIPTION = "DICOM Server listening on specified <port> for incoming association "
+            + "requests. If no local IP address of the network interface is specified "
+            + "connections on any/all local addresses are accepted. If <aet> is "
+            + "specified, only requests with matching called AE title will be "
+            + "accepted. If <aet> and a storage directory is specified by option "
+            + "-dest <dir>, also Storage Commitment requests will be accepted and "
+            + "processed.\n Options:";
+    private static final String EXAMPLE = "\nExample: dcmrcv DCMRCV:11112 -dest /tmp \n"
+            + "=> Starts server listening on port 11112, accepting association "
+            + "requests with DCMRCV as called AE title. Received objects "
+            + "are stored to /tmp.";
+    private static String[] TLS1 = {"TLSv1"};
+    private static String[] SSL3 = {"SSLv3"};
+    private static String[] NO_TLS1 = {"SSLv3", "SSLv2Hello"};
+    private static String[] NO_SSL2 = {"TLSv1", "SSLv3"};
+    private static String[] NO_SSL3 = {"TLSv1", "SSLv2Hello"};
+    private static char[] SECRET = {'s', 'e', 'c', 'r', 'e', 't'};
+    private static final String[] ONLY_DEF_TS = {UID.ImplicitVRLittleEndian};
+    private static final String[] NATIVE_TS = {UID.ExplicitVRLittleEndian,
+        UID.ExplicitVRBigEndian, UID.ImplicitVRLittleEndian};
+    private static final String[] NATIVE_LE_TS = {UID.ExplicitVRLittleEndian,
+        UID.ImplicitVRLittleEndian};
+    private static final String[] NON_RETIRED_TS = {UID.JPEGLSLossless,
+        UID.JPEGLossless, UID.JPEGLosslessNonHierarchical14,
+        UID.JPEG2000LosslessOnly, UID.DeflatedExplicitVRLittleEndian,
+        UID.RLELossless, UID.ExplicitVRLittleEndian,
+        UID.ExplicitVRBigEndian, UID.ImplicitVRLittleEndian,
+        UID.JPEGBaseline1, UID.JPEGExtended24, UID.JPEGLSLossyNearLossless,
+        UID.JPEG2000, UID.MPEG2,};
+    private static final String[] NON_RETIRED_LE_TS = {UID.JPEGLSLossless,
+        UID.JPEGLossless, UID.JPEGLosslessNonHierarchical14,
+        UID.JPEG2000LosslessOnly, UID.DeflatedExplicitVRLittleEndian,
+        UID.RLELossless, UID.ExplicitVRLittleEndian,
+        UID.ImplicitVRLittleEndian, UID.JPEGBaseline1, UID.JPEGExtended24,
+        UID.JPEGLSLossyNearLossless, UID.JPEG2000, UID.MPEG2,};
+    private static final String[] CUIDS = {
+        UID.BasicStudyContentNotificationSOPClassRetired,
+        UID.StoredPrintStorageSOPClassRetired,
+        UID.HardcopyGrayscaleImageStorageSOPClassRetired,
+        UID.HardcopyColorImageStorageSOPClassRetired,
+        UID.ComputedRadiographyImageStorage,
+        UID.DigitalXRayImageStorageForPresentation,
+        UID.DigitalXRayImageStorageForProcessing,
+        UID.DigitalMammographyXRayImageStorageForPresentation,
+        UID.DigitalMammographyXRayImageStorageForProcessing,
+        UID.DigitalIntraoralXRayImageStorageForPresentation,
+        UID.DigitalIntraoralXRayImageStorageForProcessing,
+        UID.StandaloneModalityLUTStorageRetired,
+        UID.EncapsulatedPDFStorage, UID.StandaloneVOILUTStorageRetired,
+        UID.GrayscaleSoftcopyPresentationStateStorageSOPClass,
+        UID.ColorSoftcopyPresentationStateStorageSOPClass,
+        UID.PseudoColorSoftcopyPresentationStateStorageSOPClass,
+        UID.BlendingSoftcopyPresentationStateStorageSOPClass,
+        UID.XRayAngiographicImageStorage, UID.EnhancedXAImageStorage,
+        UID.XRayRadiofluoroscopicImageStorage, UID.EnhancedXRFImageStorage,
+        UID.XRayAngiographicBiPlaneImageStorageRetired,
+        UID.PositronEmissionTomographyImageStorage,
+        UID.StandalonePETCurveStorageRetired, UID.CTImageStorage,
+        UID.EnhancedCTImageStorage, UID.NuclearMedicineImageStorage,
+        UID.UltrasoundMultiframeImageStorageRetired,
+        UID.UltrasoundMultiframeImageStorage, UID.MRImageStorage,
+        UID.EnhancedMRImageStorage, UID.MRSpectroscopyStorage,
+        UID.RTImageStorage, UID.RTDoseStorage, UID.RTStructureSetStorage,
+        UID.RTBeamsTreatmentRecordStorage, UID.RTPlanStorage,
+        UID.RTBrachyTreatmentRecordStorage,
+        UID.RTTreatmentSummaryRecordStorage,
+        UID.NuclearMedicineImageStorageRetired,
+        UID.UltrasoundImageStorageRetired, UID.UltrasoundImageStorage,
+        UID.RawDataStorage, UID.SpatialRegistrationStorage,
+        UID.SpatialFiducialsStorage, UID.RealWorldValueMappingStorage,
+        UID.SecondaryCaptureImageStorage,
+        UID.MultiframeSingleBitSecondaryCaptureImageStorage,
+        UID.MultiframeGrayscaleByteSecondaryCaptureImageStorage,
+        UID.MultiframeGrayscaleWordSecondaryCaptureImageStorage,
+        UID.MultiframeTrueColorSecondaryCaptureImageStorage,
+        UID.VLImageStorageTrialRetired, UID.VLEndoscopicImageStorage,
+        UID.VideoEndoscopicImageStorage, UID.VLMicroscopicImageStorage,
+        UID.VideoMicroscopicImageStorage,
+        UID.VLSlideCoordinatesMicroscopicImageStorage,
+        UID.VLPhotographicImageStorage, UID.VideoPhotographicImageStorage,
+        UID.OphthalmicPhotography8BitImageStorage,
+        UID.OphthalmicPhotography16BitImageStorage,
+        UID.StereometricRelationshipStorage,
+        UID.VLMultiframeImageStorageTrialRetired,
+        UID.StandaloneOverlayStorageRetired, UID.BasicTextSRStorage,
+        UID.EnhancedSRStorage, UID.ComprehensiveSRStorage,
+        UID.ProcedureLogStorage, UID.MammographyCADSRStorage,
+        UID.KeyObjectSelectionDocumentStorage,
+        UID.ChestCADSRStorage, UID.XRayRadiationDoseSRStorage,
+        UID.EncapsulatedPDFStorage, UID.EncapsulatedCDAStorage,
+        UID.StandaloneCurveStorageRetired,
+        UID._12leadECGWaveformStorage, UID.GeneralECGWaveformStorage,
+        UID.AmbulatoryECGWaveformStorage, UID.HemodynamicWaveformStorage,
+        UID.CardiacElectrophysiologyWaveformStorage,
+        UID.BasicVoiceAudioWaveformStorage, UID.HangingProtocolStorage,
+        UID.SiemensCSANonImageStorage,
+        UID.Dcm4cheAttributesModificationNotificationSOPClass};
+    private final Executor executor;
+    private final Device device;
+    private final NetworkApplicationEntity ae = new NetworkApplicationEntity();
+    private final NetworkConnection nc = new NetworkConnection();
+    private final StorageSCP storageSCP = new StorageSCP(this, CUIDS);
+    private final StgCmtSCP stgcmtSCP =
+            new StgCmtSCP(this);
+    private String[] tsuids = NON_RETIRED_LE_TS;
+    private FileCache cache = new FileCache();
+    private File destination;
+    private File devnull;
+    private Properties calling2dir;
+    private Properties called2dir;
+    private String callingdefdir = "OTHER";
+    private String calleddefdir = "OTHER";
+    private int fileBufferSize = 1024;
+    private int rspdelay = 0;
+    private String keyStoreURL = "resource:tls/test_sys_2.p12";
+    private char[] keyStorePassword = SECRET;
+    private char[] keyPassword;
+    private String trustStoreURL = "resource:tls/mesa_certs.jks";
+    private char[] trustStorePassword = SECRET;
+    private Timer stgcmtTimer;
+    private boolean stgcmtReuseFrom = false;
+    private boolean stgcmtReuseTo = false;
+    private int stgcmtPort = 104;
+    private long stgcmtDelay = 1000;
+    private int stgcmtRetry = 0;
+    private long stgcmtRetryPeriod = 60000;
+    private String stgcmtRetrieveAET;
+    private String stgcmtRetrieveAETs;
+    private final DimseRSPHandler nEventReportRspHandler =
+            new DimseRSPHandler();
+
+    public DcmRcv() {
+        this("DCMRCV");
+    }
+
+    public DcmRcv(String name) {
+        device = new Device(name);
+        executor = new NewThreadExecutor(name);
+        device.setNetworkApplicationEntity(ae);
+        device.setNetworkConnection(nc);
+        ae.setNetworkConnection(nc);
+        ae.setAssociationAcceptor(true);
+        ae.register(new VerificationService());
+        ae.register(storageSCP);
+        ae.register(stgcmtSCP);
+    }
+
+    public final void setAEtitle(String aet) {
+        ae.setAETitle(aet);
+    }
+
+    public final void setHostname(String hostname) {
+        nc.setHostname(hostname);
+    }
+
+    public final void setPort(int port) {
+        nc.setPort(port);
+    }
+
+    public final void setTlsProtocol(String[] tlsProtocol) {
+        nc.setTlsProtocol(tlsProtocol);
+    }
+
+    public final void setTlsWithoutEncyrption() {
+        nc.setTlsWithoutEncyrption();
+    }
+
+    public final void setTls3DES_EDE_CBC() {
+        nc.setTls3DES_EDE_CBC();
+    }
+
+    public final void setTlsAES_128_CBC() {
+        nc.setTlsAES_128_CBC();
+    }
+
+    public final void setTlsNeedClientAuth(boolean needClientAuth) {
+        nc.setTlsNeedClientAuth(needClientAuth);
+    }
+
+    public final void setKeyStoreURL(String url) {
+        keyStoreURL = url;
+    }
+
+    public final void setKeyStorePassword(String pw) {
+        keyStorePassword = pw.toCharArray();
+    }
+
+    public final void setKeyPassword(String pw) {
+        keyPassword = pw.toCharArray();
+    }
+
+    public final void setTrustStorePassword(String pw) {
+        trustStorePassword = pw.toCharArray();
+    }
+
+    public final void setTrustStoreURL(String url) {
+        trustStoreURL = url;
+    }
+
+    public final void setConnectTimeout(int connectTimeout) {
+        nc.setConnectTimeout(connectTimeout);
+    }
+
+    public final void setPackPDV(boolean packPDV) {
+        ae.setPackPDV(packPDV);
+    }
+
+    public final void setAssociationReaperPeriod(int period) {
+        device.setAssociationReaperPeriod(period);
+    }
+
+    public final void setTcpNoDelay(boolean tcpNoDelay) {
+        nc.setTcpNoDelay(tcpNoDelay);
+    }
+
+    public final void setAcceptTimeout(int timeout) {
+        nc.setAcceptTimeout(timeout);
+    }
+
+    public final void setRequestTimeout(int timeout) {
+        nc.setRequestTimeout(timeout);
+    }
+
+    public final void setReleaseTimeout(int timeout) {
+        nc.setReleaseTimeout(timeout);
+    }
+
+    public final void setSocketCloseDelay(int delay) {
+        nc.setSocketCloseDelay(delay);
+    }
+
+    public final void setIdleTimeout(int timeout) {
+        ae.setIdleTimeout(timeout);
+    }
+
+    public final void setDimseRspTimeout(int timeout) {
+        ae.setDimseRspTimeout(timeout);
+    }
+
+    public final void setMaxPDULengthSend(int maxLength) {
+        ae.setMaxPDULengthSend(maxLength);
+    }
+
+    public void setMaxPDULengthReceive(int maxLength) {
+        ae.setMaxPDULengthReceive(maxLength);
+    }
+
+    public final void setReceiveBufferSize(int bufferSize) {
+        nc.setReceiveBufferSize(bufferSize);
+    }
+
+    public final void setSendBufferSize(int bufferSize) {
+        nc.setSendBufferSize(bufferSize);
+    }
+
+    public final void setDimseRspDelay(int delay) {
+        rspdelay = delay;
+    }
+
+    public final int getDimseRspDelay() {
+        return rspdelay;
+    }
+
+    public final void setStgCmtReuseFrom(boolean stgcmtReuseFrom) {
+        this.stgcmtReuseFrom = stgcmtReuseFrom;
+    }
+
+    public final boolean isStgCmtReuseFrom() {
+        return stgcmtReuseFrom;
+    }
+
+    public final void setStgCmtReuseTo(boolean stgcmtReuseTo) {
+        this.stgcmtReuseTo = stgcmtReuseTo;
+    }
+
+    public final boolean isStgCmtReuseTo() {
+        return stgcmtReuseTo;
+    }
+
+    public final int getStgCmtPort() {
+        return stgcmtPort;
+    }
+
+    public final void setStgCmtPort(int stgcmtPort) {
+        this.stgcmtPort = stgcmtPort;
+    }
+
+    public final void setStgCmtDelay(long delay) {
+        this.stgcmtDelay = delay;
+    }
+
+    public final long getStgCmtDelay() {
+        return stgcmtDelay;
+    }
+
+    public final int getStgCmtRetry() {
+        return stgcmtRetry;
+    }
+
+    public final void setStgCmtRetry(int stgcmtRetry) {
+        this.stgcmtRetry = stgcmtRetry;
+    }
+
+    public final long getStgCmtRetryPeriod() {
+        return stgcmtRetryPeriod;
+    }
+
+    public final void setStgCmtRetryPeriod(long stgcmtRetryPeriod) {
+        this.stgcmtRetryPeriod = stgcmtRetryPeriod;
+    }
+
+    public final String getStgCmtRetrieveAET() {
+        return stgcmtRetrieveAET;
+    }
+
+    public final void setStgCmtRetrieveAET(String aet) {
+        this.stgcmtRetrieveAET = aet;
+    }
+
+    public final String getStgCmtRetrieveAETs() {
+        return stgcmtRetrieveAETs;
+    }
+
+    public final void setStgCmtRetrieveAETs(String aet) {
+        this.stgcmtRetrieveAETs = aet;
+    }
+
+    final Executor executor() {
+        return executor;
+    }
+
+    private static CommandLine parse(String[] args) {
+        Options opts = new Options();
+
+        OptionBuilder.withArgName("name");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "set device name, use DCMRCV by default");
+        opts.addOption(OptionBuilder.create("device"));
+
+        OptionBuilder.withArgName("NULL|3DES|AES");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "enable TLS connection without, 3DES or AES encryption");
+        opts.addOption(OptionBuilder.create("tls"));
+
+        OptionGroup tlsProtocol = new OptionGroup();
+        tlsProtocol.addOption(new Option("tls1",
+                "disable the use of SSLv3 and SSLv2 for TLS connections"));
+        tlsProtocol.addOption(new Option("ssl3",
+                "disable the use of TLSv1 and SSLv2 for TLS connections"));
+        tlsProtocol.addOption(new Option("no_tls1",
+                "disable the use of TLSv1 for TLS connections"));
+        tlsProtocol.addOption(new Option("no_ssl3",
+                "disable the use of SSLv3 for TLS connections"));
+        tlsProtocol.addOption(new Option("no_ssl2",
+                "disable the use of SSLv2 for TLS connections"));
+        opts.addOptionGroup(tlsProtocol);
+
+        opts.addOption("noclientauth", false,
+                "disable client authentification for TLS");
+
+        OptionBuilder.withArgName("file|url");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "file path or URL of P12 or JKS keystore, resource:tls/test_sys_2.p12 by default");
+        opts.addOption(OptionBuilder.create("keystore"));
+
+        OptionBuilder.withArgName("password");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "password for keystore file, 'secret' by default");
+        opts.addOption(OptionBuilder.create("keystorepw"));
+
+        OptionBuilder.withArgName("password");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "password for accessing the key in the keystore, keystore password by default");
+        opts.addOption(OptionBuilder.create("keypw"));
+
+        OptionBuilder.withArgName("file|url");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "file path or URL of JKS truststore, resource:tls/mesa_certs.jks by default");
+        opts.addOption(OptionBuilder.create("truststore"));
+
+        OptionBuilder.withArgName("password");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "password for truststore file, 'secret' by default");
+        opts.addOption(OptionBuilder.create("truststorepw"));
+
+        OptionBuilder.withArgName("dir");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "store received objects into files in specified directory <dir>."
+                + " Do not store received objects by default.");
+        opts.addOption(OptionBuilder.create("dest"));
+
+        OptionBuilder.withArgName("file|url");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "file path or URL of properties for mapping Calling AETs to "
+                + "sub-directories of the storage directory specified by "
+                + "-dest, to separate the storage location dependend on "
+                + "Calling AETs.");
+        opts.addOption(OptionBuilder.create("calling2dir"));
+
+
+        OptionBuilder.withArgName("file|url");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "file path or URL of properties for mapping Called AETs to "
+                + "sub-directories of the storage directory specified by "
+                + "-dest, to separate the storage location dependend on "
+                + "Called AETs.");
+        opts.addOption(OptionBuilder.create("called2dir"));
+
+        OptionBuilder.withArgName("sub-dir");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "storage sub-directory used for Calling AETs for which no "
+                + " mapping is defined by properties specified by "
+                + "-calling2dir, 'OTHER' by default.");
+        opts.addOption(OptionBuilder.create("callingdefdir"));
+
+        OptionBuilder.withArgName("sub-dir");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "storage sub-directory used for Called AETs for which no "
+                + " mapping is defined by properties specified by "
+                + "-called2dir, 'OTHER' by default.");
+        opts.addOption(OptionBuilder.create("calleddefdir"));
+
+        OptionBuilder.withArgName("dir");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "register stored objects in cache journal files in specified directory <dir>."
+                + " Do not register stored objects by default.");
+        opts.addOption(OptionBuilder.create("journal"));
+
+        OptionBuilder.withArgName("pattern");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription("cache journal file path, with "
+                + "'yyyy' will be replaced by the current year, "
+                + "'MM' by the current month, 'dd' by the current date, "
+                + "'HH' by the current hour and 'mm' by the current minute. "
+                + "'yyyy/MM/dd/HH/mm' by default.");
+        opts.addOption(OptionBuilder.create("journalfilepath"));
+
+        opts.addOption("defts", false, "accept only default transfer syntax.");
+        opts.addOption("bigendian", false,
+                "accept also Explict VR Big Endian transfer syntax.");
+        opts.addOption("native", false,
+                "accept only transfer syntax with uncompressed pixel data.");
+
+        OptionGroup scRetrieveAET = new OptionGroup();
+        OptionBuilder.withArgName("aet");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "Retrieve AE Title included in Storage Commitment "
+                + "N-EVENT-REPORT in items of the Referenced SOP Sequence.");
+        scRetrieveAET.addOption(OptionBuilder.create("scretraets"));
+        OptionBuilder.withArgName("aet");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "Retrieve AE Title included in Storage Commitment "
+                + "N-EVENT-REPORT outside of the Referenced SOP Sequence.");
+        scRetrieveAET.addOption(OptionBuilder.create("scretraet"));
+        opts.addOptionGroup(scRetrieveAET);
+
+        opts.addOption("screusefrom", false,
+                "attempt to issue the Storage Commitment N-EVENT-REPORT on "
+                + "the same Association on which the N-ACTION operation was "
+                + "performed; use different Association for N-EVENT-REPORT by "
+                + "default.");
+
+        opts.addOption("screuseto", false,
+                "attempt to issue the Storage Commitment N-EVENT-REPORT on "
+                + "previous initiated Association to the Storage Commitment SCU; "
+                + "initiate new Association for N-EVENT-REPORT by default.");
+
+        OptionBuilder.withArgName("port");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "port of Storage Commitment SCU to connect to issue "
+                + "N-EVENT-REPORT on different Association; 104 by default.");
+        opts.addOption(OptionBuilder.create("scport"));
+
+        OptionBuilder.withArgName("ms");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "delay in ms for N-EVENT-REPORT-RQ to Storage Commitment SCU, "
+                + "1s by default");
+        opts.addOption(OptionBuilder.create("scdelay"));
+
+        OptionBuilder.withArgName("retry");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "number of retries to issue N-EVENT-REPORT-RQ to Storage "
+                + "Commitment SCU, 0 by default");
+        opts.addOption(OptionBuilder.create("scretry"));
+
+        OptionBuilder.withArgName("ms");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "interval im ms between retries to issue N-EVENT-REPORT-RQ to"
+                + "Storage Commitment SCU, 60s by default");
+        opts.addOption(OptionBuilder.create("scretryperiod"));
+
+        OptionBuilder.withArgName("maxops");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "maximum number of outstanding operations performed "
+                + "asynchronously, unlimited by default.");
+        opts.addOption(OptionBuilder.create("async"));
+
+        opts.addOption("pdv1", false, "send only one PDV in one P-Data-TF PDU, "
+                + "pack command and data PDV in one P-DATA-TF PDU by default.");
+        opts.addOption("tcpdelay", false,
+                "set TCP_NODELAY socket option to false, true by default");
+
+        OptionBuilder.withArgName("ms");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "timeout in ms for TCP connect, no timeout by default");
+        opts.addOption(OptionBuilder.create("connectTO"));
+
+        OptionBuilder.withArgName("ms");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "timeout in ms for receiving DIMSE-RSP, 10s by default");
+        opts.addOption(OptionBuilder.create("rspTO"));
+
+        OptionBuilder.withArgName("ms");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "timeout in ms for receiving A-ASSOCIATE-AC, 5s by default");
+        opts.addOption(OptionBuilder.create("acceptTO"));
+
+        OptionBuilder.withArgName("ms");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "delay in ms for Socket close after sending A-ABORT, 50ms by default");
+        opts.addOption(OptionBuilder.create("soclosedelay"));
+
+        OptionBuilder.withArgName("ms");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "delay in ms for DIMSE-RSP; useful for testing asynchronous mode");
+        opts.addOption(OptionBuilder.create("rspdelay"));
+
+        OptionBuilder.withArgName("ms");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "timeout in ms for receiving -ASSOCIATE-RQ, 5s by default");
+        opts.addOption(OptionBuilder.create("requestTO"));
+
+        OptionBuilder.withArgName("ms");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "timeout in ms for receiving A-RELEASE-RP, 5s by default");
+        opts.addOption(OptionBuilder.create("releaseTO"));
+
+
+        OptionBuilder.withArgName("ms");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "period in ms to check for outstanding DIMSE-RSP, 10s by default");
+        opts.addOption(OptionBuilder.create("reaper"));
+
+        OptionBuilder.withArgName("ms");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "timeout in ms for receiving DIMSE-RQ, 60s by default");
+        opts.addOption(OptionBuilder.create("idleTO"));
+
+        OptionBuilder.withArgName("KB");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "maximal length in KB of received P-DATA-TF PDUs, 16KB by default");
+        opts.addOption(OptionBuilder.create("rcvpdulen"));
+
+        OptionBuilder.withArgName("KB");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "maximal length in KB of sent P-DATA-TF PDUs, 16KB by default");
+        opts.addOption(OptionBuilder.create("sndpdulen"));
+
+        OptionBuilder.withArgName("KB");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "set SO_RCVBUF socket option to specified value in KB");
+        opts.addOption(OptionBuilder.create("sorcvbuf"));
+
+        OptionBuilder.withArgName("KB");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "set SO_SNDBUF socket option to specified value in KB");
+        opts.addOption(OptionBuilder.create("sosndbuf"));
+
+        OptionBuilder.withArgName("KB");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "minimal buffer size to write received object to file, 1KB by default");
+        opts.addOption(OptionBuilder.create("bufsize"));
+
+        opts.addOption("h", "help", false, "print this message");
+        opts.addOption("V", "version", false,
+                "print the version information and exit");
+        CommandLine cl = null;
+        try {
+            cl = new GnuParser().parse(opts, args);
+        } catch (ParseException e) {
+            exit("dcmrcv: " + e.getMessage());
+            throw new RuntimeException("unreachable");
+        }
+        if (cl.hasOption("V")) {
+            Package p = DcmRcv.class.getPackage();
+            System.out.println("dcmrcv v" + p.getImplementationVersion());
+            System.exit(0);
+        }
+        if (cl.hasOption("h") || cl.getArgList().size() == 0) {
+            HelpFormatter formatter = new HelpFormatter();
+            formatter.printHelp(USAGE, DESCRIPTION, opts, EXAMPLE);
+            System.exit(0);
+        }
+        return cl;
+    }
+
+    @SuppressWarnings("unchecked")
+    public static void main(String[] args) {
+        CommandLine cl = parse(args);
+        DcmRcv dcmrcv = new DcmRcv(cl.hasOption("device")
+                ? cl.getOptionValue("device") : "DCMRCV");
+        final List<String> argList = cl.getArgList();
+        String port = argList.get(0);
+        String[] aetPort = split(port, ':', 1);
+        dcmrcv.setPort(parseInt(aetPort[1], "illegal port number", 1, 0xffff));
+        if (aetPort[0] != null) {
+            String[] aetHost = split(aetPort[0], '@', 0);
+            dcmrcv.setAEtitle(aetHost[0]);
+            if (aetHost[1] != null) {
+                dcmrcv.setHostname(aetHost[1]);
+            }
+        }
+
+        if (cl.hasOption("dest")) {
+            dcmrcv.setDestination(cl.getOptionValue("dest"));
+        }
+        if (cl.hasOption("calling2dir")) {
+            dcmrcv.setCalling2Dir(
+                    loadProperties(cl.getOptionValue("calling2dir")));
+        }
+        if (cl.hasOption("called2dir")) {
+            dcmrcv.setCalled2Dir(
+                    loadProperties(cl.getOptionValue("called2dir")));
+        }
+        if (cl.hasOption("callingdefdir")) {
+            dcmrcv.setCallingDefDir(cl.getOptionValue("callingdefdir"));
+        }
+        if (cl.hasOption("calleddefdir")) {
+            dcmrcv.setCalledDefDir(cl.getOptionValue("calleddefdir"));
+        }
+        if (cl.hasOption("journal")) {
+            dcmrcv.setJournal(cl.getOptionValue("journal"));
+        }
+        if (cl.hasOption("journalfilepath")) {
+            dcmrcv.setJournalFilePathFormat(
+                    cl.getOptionValue("journalfilepath"));
+        }
+
+        if (cl.hasOption("defts")) {
+            dcmrcv.setTransferSyntax(ONLY_DEF_TS);
+        } else if (cl.hasOption("native")) {
+            dcmrcv.setTransferSyntax(cl.hasOption("bigendian") ? NATIVE_TS
+                    : NATIVE_LE_TS);
+        } else if (cl.hasOption("bigendian")) {
+            dcmrcv.setTransferSyntax(NON_RETIRED_TS);
+        }
+        if (cl.hasOption("scretraets")) {
+            dcmrcv.setStgCmtRetrieveAETs(cl.getOptionValue("scretraets"));
+        }
+        if (cl.hasOption("scretraet")) {
+            dcmrcv.setStgCmtRetrieveAET(cl.getOptionValue("scretraet"));
+        }
+        dcmrcv.setStgCmtReuseFrom(cl.hasOption("screusefrom"));
+        dcmrcv.setStgCmtReuseTo(cl.hasOption("screuseto"));
+        if (cl.hasOption("scport")) {
+            dcmrcv.setStgCmtPort(parseInt(cl.getOptionValue("scport"),
+                    "illegal port number", 1, 0xffff));
+        }
+        if (cl.hasOption("scdelay")) {
+            dcmrcv.setStgCmtDelay(parseInt(cl.getOptionValue("scdelay"),
+                    "illegal argument of option -scdelay", 0,
+                    Integer.MAX_VALUE));
+        }
+        if (cl.hasOption("scretry")) {
+            dcmrcv.setStgCmtRetry(parseInt(cl.getOptionValue("scretry"),
+                    "illegal argument of option -scretry", 0,
+                    Integer.MAX_VALUE));
+        }
+        if (cl.hasOption("scretryperiod")) {
+            dcmrcv.setStgCmtRetryPeriod(parseInt(cl.getOptionValue("scretryperiod"),
+                    "illegal argument of option -scretryperiod", 1000,
+                    Integer.MAX_VALUE));
+        }
+        if (cl.hasOption("connectTO")) {
+            dcmrcv.setConnectTimeout(parseInt(cl.getOptionValue("connectTO"),
+                    "illegal argument of option -connectTO", 1,
+                    Integer.MAX_VALUE));
+        }
+        if (cl.hasOption("reaper")) {
+            dcmrcv.setAssociationReaperPeriod(parseInt(cl.getOptionValue("reaper"),
+                    "illegal argument of option -reaper", 1,
+                    Integer.MAX_VALUE));
+        }
+        if (cl.hasOption("rspTO")) {
+            dcmrcv.setDimseRspTimeout(parseInt(cl.getOptionValue("rspTO"),
+                    "illegal argument of option -rspTO",
+                    1, Integer.MAX_VALUE));
+        }
+        if (cl.hasOption("acceptTO")) {
+            dcmrcv.setAcceptTimeout(parseInt(cl.getOptionValue("acceptTO"),
+                    "illegal argument of option -acceptTO",
+                    1, Integer.MAX_VALUE));
+        }
+        if (cl.hasOption("idleTO")) {
+            dcmrcv.setIdleTimeout(parseInt(cl.getOptionValue("idleTO"),
+                    "illegal argument of option -idleTO", 1,
+                    Integer.MAX_VALUE));
+        }
+        if (cl.hasOption("requestTO")) {
+            dcmrcv.setRequestTimeout(parseInt(cl.getOptionValue("requestTO"),
+                    "illegal argument of option -requestTO", 1,
+                    Integer.MAX_VALUE));
+        }
+        if (cl.hasOption("releaseTO")) {
+            dcmrcv.setReleaseTimeout(parseInt(cl.getOptionValue("releaseTO"),
+                    "illegal argument of option -releaseTO", 1,
+                    Integer.MAX_VALUE));
+        }
+        if (cl.hasOption("soclosedelay")) {
+            dcmrcv.setSocketCloseDelay(parseInt(cl.getOptionValue("soclosedelay"),
+                    "illegal argument of option -soclosedelay", 1, 10000));
+        }
+        if (cl.hasOption("rspdelay")) {
+            dcmrcv.setDimseRspDelay(parseInt(cl.getOptionValue("rspdelay"),
+                    "illegal argument of option -rspdelay", 0, 10000));
+        }
+        if (cl.hasOption("rcvpdulen")) {
+            dcmrcv.setMaxPDULengthReceive(parseInt(cl.getOptionValue("rcvpdulen"),
+                    "illegal argument of option -rcvpdulen", 1, 10000)
+                    * KB);
+        }
+        if (cl.hasOption("sndpdulen")) {
+            dcmrcv.setMaxPDULengthSend(parseInt(cl.getOptionValue("sndpdulen"),
+                    "illegal argument of option -sndpdulen", 1, 10000)
+                    * KB);
+        }
+        if (cl.hasOption("sosndbuf")) {
+            dcmrcv.setSendBufferSize(parseInt(cl.getOptionValue("sosndbuf"),
+                    "illegal argument of option -sosndbuf", 1, 10000)
+                    * KB);
+        }
+        if (cl.hasOption("sorcvbuf")) {
+            dcmrcv.setReceiveBufferSize(parseInt(cl.getOptionValue("sorcvbuf"),
+                    "illegal argument of option -sorcvbuf", 1, 10000)
+                    * KB);
+        }
+        if (cl.hasOption("bufsize")) {
+            dcmrcv.setFileBufferSize(parseInt(cl.getOptionValue("bufsize"),
+                    "illegal argument of option -bufsize", 1, 10000)
+                    * KB);
+        }
+
+        dcmrcv.setPackPDV(!cl.hasOption("pdv1"));
+        dcmrcv.setTcpNoDelay(!cl.hasOption("tcpdelay"));
+        if (cl.hasOption("async")) {
+            dcmrcv.setMaxOpsPerformed(parseInt(cl.getOptionValue("async"),
+                    "illegal argument of option -async", 0, 0xffff));
+        }
+        dcmrcv.initTransferCapability();
+        if (cl.hasOption("tls")) {
+            String cipher = cl.getOptionValue("tls");
+            if ("NULL".equalsIgnoreCase(cipher)) {
+                dcmrcv.setTlsWithoutEncyrption();
+            } else if ("3DES".equalsIgnoreCase(cipher)) {
+                dcmrcv.setTls3DES_EDE_CBC();
+            } else if ("AES".equalsIgnoreCase(cipher)) {
+                dcmrcv.setTlsAES_128_CBC();
+            } else {
+                exit("Invalid parameter for option -tls: " + cipher);
+            }
+            if (cl.hasOption("tls1")) {
+                dcmrcv.setTlsProtocol(TLS1);
+            } else if (cl.hasOption("ssl3")) {
+                dcmrcv.setTlsProtocol(SSL3);
+            } else if (cl.hasOption("no_tls1")) {
+                dcmrcv.setTlsProtocol(NO_TLS1);
+            } else if (cl.hasOption("no_ssl3")) {
+                dcmrcv.setTlsProtocol(NO_SSL3);
+            } else if (cl.hasOption("no_ssl2")) {
+                dcmrcv.setTlsProtocol(NO_SSL2);
+            }
+            dcmrcv.setTlsNeedClientAuth(!cl.hasOption("noclientauth"));
+
+            if (cl.hasOption("keystore")) {
+                dcmrcv.setKeyStoreURL(cl.getOptionValue("keystore"));
+            }
+            if (cl.hasOption("keystorepw")) {
+                dcmrcv.setKeyStorePassword(
+                        cl.getOptionValue("keystorepw"));
+            }
+            if (cl.hasOption("keypw")) {
+                dcmrcv.setKeyPassword(cl.getOptionValue("keypw"));
+            }
+            if (cl.hasOption("truststore")) {
+                dcmrcv.setTrustStoreURL(
+                        cl.getOptionValue("truststore"));
+            }
+            if (cl.hasOption("truststorepw")) {
+                dcmrcv.setTrustStorePassword(
+                        cl.getOptionValue("truststorepw"));
+            }
+            try {
+                dcmrcv.initTLS();
+            } catch (Exception e) {
+                System.err.println("ERROR: Failed to initialize TLS context:"
+                        + e.getMessage());
+                System.exit(2);
+            }
+        }
+        try {
+            dcmrcv.start();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void setTransferSyntax(String[] tsuids) {
+        this.tsuids = tsuids;
+    }
+
+    public void initTransferCapability() {
+        TransferCapability[] tc;
+        if (isStgcmtEnabled()) {
+            tc = new TransferCapability[CUIDS.length + 2];
+            tc[tc.length - 1] = new TransferCapability(
+                    UID.StorageCommitmentPushModelSOPClass, ONLY_DEF_TS,
+                    TransferCapability.SCP);
+        } else {
+            tc = new TransferCapability[CUIDS.length + 1];
+        }
+        tc[0] = new TransferCapability(UID.VerificationSOPClass, ONLY_DEF_TS,
+                TransferCapability.SCP);
+        for (int i = 0; i < CUIDS.length; i++) {
+            tc[i + 1] = new TransferCapability(CUIDS[i], tsuids,
+                    TransferCapability.SCP);
+        }
+        ae.setTransferCapability(tc);
+    }
+
+    public void setFileBufferSize(int size) {
+        fileBufferSize = size;
+    }
+
+    public void setMaxOpsPerformed(int maxOps) {
+        ae.setMaxOpsPerformed(maxOps);
+    }
+
+    public void setDestination(String filePath) {
+        destination = new File(filePath);
+        if ("/dev/null".equals(filePath)) {
+            devnull = destination;
+            cache.setCacheRootDir(null);
+        } else {
+            devnull = null;
+            cache.setCacheRootDir(destination);
+        }
+    }
+
+    public void setCalling2Dir(Properties calling2dir) {
+        this.calling2dir = calling2dir;
+    }
+
+    public void setCalled2Dir(Properties called2dir) {
+        this.called2dir = called2dir;
+    }
+
+    private static Properties loadProperties(String url) {
+        Properties props = new Properties();
+        try {
+            InputStream inStream = openFileOrURL(url);
+            try {
+                props.load(inStream);
+            } finally {
+                inStream.close();
+            }
+        } catch (Exception e) {
+            exit("Failed to load properties from " + url);
+        }
+        return props;
+    }
+
+    public void setCallingDefDir(String callingdefdir) {
+        this.callingdefdir = callingdefdir;
+    }
+
+    public void setCalledDefDir(String calleddefdir) {
+        this.calleddefdir = calleddefdir;
+    }
+
+    public void setJournal(String journalRootDir) {
+        cache.setJournalRootDir(new File(journalRootDir));
+        // Prefix JournalFileName to distinguish from journal files created
+        // by other applications than DcmRcv
+        cache.setJournalFileName("DcmRcv." + cache.getJournalFileName());
+    }
+
+    public void setJournalFilePathFormat(String format) {
+        cache.setJournalFilePathFormat(format);
+    }
+
+    public void initTLS() throws GeneralSecurityException, IOException {
+        KeyStore keyStore = loadKeyStore(keyStoreURL, keyStorePassword);
+        KeyStore trustStore = loadKeyStore(trustStoreURL, trustStorePassword);
+        device.initTLS(keyStore,
+                keyPassword != null ? keyPassword : keyStorePassword,
+                trustStore);
+    }
+
+    private static KeyStore loadKeyStore(String url, char[] password)
+            throws GeneralSecurityException, IOException {
+        KeyStore key = KeyStore.getInstance(toKeyStoreType(url));
+        InputStream in = openFileOrURL(url);
+        try {
+            key.load(in, password);
+        } finally {
+            in.close();
+        }
+        return key;
+    }
+
+    private static InputStream openFileOrURL(String url) throws IOException {
+        if (url.startsWith("resource:")) {
+            return DcmRcv.class.getClassLoader().getResourceAsStream(
+                    url.substring(9));
+        }
+        try {
+            return new URL(url).openStream();
+        } catch (MalformedURLException e) {
+            return new FileInputStream(url);
+        }
+    }
+
+    private static String toKeyStoreType(String fname) {
+        return fname.endsWith(".p12") || fname.endsWith(".P12")
+                ? "PKCS12" : "JKS";
+    }
+
+    public void start() throws IOException {
+        device.startListening(executor);       
+    }
+
+    public void stop() {
+        if (device != null) {
+            device.stopListening();
+        }      
+    }
+
+    private static String[] split(String s, char delim, int defPos) {
+        String[] s2 = new String[2];
+        s2[defPos] = s;
+        int pos = s.indexOf(delim);
+        if (pos != -1) {
+            s2[0] = s.substring(0, pos);
+            s2[1] = s.substring(pos + 1);
+        }
+        return s2;
+    }
+
+    private static void exit(String msg) {
+        System.err.println(msg);
+        System.err.println("Try 'dcmrcv -h' for more information.");
+        System.exit(1);
+    }
+
+    private static int parseInt(String s, String errPrompt, int min, int max) {
+        try {
+            int i = Integer.parseInt(s);
+            if (i >= min && i <= max) {
+                return i;
+            }
+        } catch (NumberFormatException e) {
+            e.printStackTrace();
+            // parameter is not a valid integer; fall through to exit
+        }
+        exit(errPrompt);
+        throw new RuntimeException();
+    }
+
+    boolean isStoreFile() {
+        return devnull != null || cache.getCacheRootDir() != null;
+    }
+
+    private boolean isStgcmtEnabled() {
+        return ae.getAETitle() != null && cache.getCacheRootDir() != null;
+    }
+
+    void onCStoreRQ(Association as, int pcid, DicomObject rq,
+            PDVInputStream dataStream, String tsuid, DicomObject rsp)
+            throws IOException {
+        String cuid = rq.getString(Tag.AffectedSOPClassUID);
+        String iuid = rq.getString(Tag.AffectedSOPInstanceUID);
+
+        DicomObject data = dataStream.readDataset(); //You have one shot to get the data. You can't read twice with readDataset method.
+        String suid = data.getString(Tag.StudyInstanceUID);
+
+        Calendar today = Calendar.getInstance();
+        File struturedDestination = new File(destination.getAbsolutePath() + File.separator + today.get(Calendar.YEAR) + File.separator + today.get(Calendar.MONTH) + File.separator + today.get(Calendar.DATE) + File.separator + suid);
+        String child[] = struturedDestination.list();
+        if (child == null) {
+            struturedDestination.mkdirs();
+        }
+
+
+        File file = devnull != null ? struturedDestination : new File(struturedDestination, iuid);
+        // LOG.info("M-WRITE {}", file);
+        try {
+            DicomOutputStream dos = new DicomOutputStream(
+                    new BufferedOutputStream(
+                    new FileOutputStream(file),
+                    fileBufferSize));
+            try {
+                BasicDicomObject fmi = new BasicDicomObject();
+                fmi.initFileMetaInformation(cuid, iuid, tsuid);
+                dos.writeFileMetaInformation(fmi);
+                // dataStream.copyTo(dos);
+                dos.writeDataset(data, tsuid);
+            } finally {
+                CloseUtils.safeClose(dos);
+            }
+        } catch (IOException e) {
+            if (devnull == null && file != null) {
+                if (file.delete()) {
+                    LOG.info("M-DELETE {}", file);
+                }
+            }
+            throw new DicomServiceException(rq, Status.ProcessingFailure,
+                    e.getMessage());
+        }
+
+        // Rename the file after it has been written. See DCM-279
+        /*if (devnull == null && file != null) {
+        File rename = new File(file.getParent(), iuid);
+        LOG.info("M-RENAME {} to {}", file, rename);
+        file.renameTo(rename);
+        if (cache.getJournalRootDir() != null) {
+        cache.record(rename);
+        }
+        }*/
+        NetworkQueueUpdateDelegate networkQueueUpdateDelegate = new NetworkQueueUpdateDelegate();
+        networkQueueUpdateDelegate.updateReceiveTable(file, as.getCallingAET());
+    }
+
+    private File getDir(Association as) {
+        File dir = cache.getCacheRootDir();
+        if (called2dir != null) {
+            dir = new File(dir,
+                    called2dir.getProperty(as.getCalledAET(), calleddefdir));
+        }
+        if (calling2dir != null) {
+            dir = new File(dir,
+                    calling2dir.getProperty(as.getCallingAET(), callingdefdir));
+        }
+        return dir;
+    }
+
+    private File mkDir(Association as) {
+        File dir = getDir(as);
+        if (dir.mkdirs()) {
+            LOG.info("M-WRITE {}", dir);
+        }
+        return dir;
+    }
+
+    public void onNActionRQ(Association as, DicomObject rq, DicomObject info) {
+        stgcmtTimer().schedule(new SendStgCmtResult(this, mkStgCmtAE(as),
+                mkStgCmtResult(as, info)), stgcmtDelay, stgcmtRetryPeriod);
+    }
+
+    private NetworkApplicationEntity mkStgCmtAE(Association as) {
+        NetworkApplicationEntity stgcmtAE = new NetworkApplicationEntity();
+        NetworkConnection stgcmtNC = new NetworkConnection();
+        stgcmtNC.setHostname(as.getSocket().getInetAddress().getHostAddress());
+        stgcmtNC.setPort(stgcmtPort);
+        stgcmtNC.setTlsCipherSuite(nc.getTlsCipherSuite());
+        stgcmtAE.setNetworkConnection(stgcmtNC);
+        stgcmtAE.setAETitle(as.getRemoteAET());
+        stgcmtAE.setTransferCapability(new TransferCapability[]{
+                    new TransferCapability(
+                    UID.StorageCommitmentPushModelSOPClass, ONLY_DEF_TS,
+                    TransferCapability.SCU)});
+        return stgcmtAE;
+    }
+
+    private DicomObject mkStgCmtResult(Association as, DicomObject rqdata) {
+        DicomObject result = new BasicDicomObject();
+        result.putString(Tag.TransactionUID, VR.UI,
+                rqdata.getString(Tag.TransactionUID));
+        DicomElement rqsq = rqdata.get(Tag.ReferencedSOPSequence);
+        DicomElement resultsq = result.putSequence(Tag.ReferencedSOPSequence);
+        if (stgcmtRetrieveAET != null) {
+            result.putString(Tag.RetrieveAETitle, VR.AE, stgcmtRetrieveAET);
+        }
+        DicomElement failedsq = null;
+        File dir = getDir(as);
+        for (int i = 0, n = rqsq.countItems(); i < n; i++) {
+            DicomObject rqItem = rqsq.getDicomObject(i);
+            String uid = rqItem.getString(Tag.ReferencedSOPInstanceUID);
+            DicomObject resultItem = new BasicDicomObject();
+            rqItem.copyTo(resultItem);
+            if (stgcmtRetrieveAETs != null) {
+                resultItem.putString(Tag.RetrieveAETitle, VR.AE,
+                        stgcmtRetrieveAETs);
+            }
+            File f = new File(dir, uid);
+            if (f.isFile()) {
+                resultsq.addDicomObject(resultItem);
+            } else {
+                resultItem.putInt(Tag.FailureReason, VR.US,
+                        NO_SUCH_OBJECT_INSTANCE);
+                if (failedsq == null) {
+                    failedsq = result.putSequence(Tag.FailedSOPSequence);
+                }
+                failedsq.addDicomObject(resultItem);
+            }
+        }
+        return result;
+    }
+
+    private synchronized Timer stgcmtTimer() {
+        if (stgcmtTimer == null) {
+            stgcmtTimer = new Timer("SendStgCmtResult", true);
+        }
+        return stgcmtTimer;
+    }
+
+    void sendStgCmtResult(NetworkApplicationEntity stgcmtAE,
+            DicomObject result) throws Exception {
+        synchronized (ae) {
+            ae.setReuseAssocationFromAETitle(stgcmtReuseFrom
+                    ? new String[]{stgcmtAE.getAETitle()}
+                    : new String[]{});
+            ae.setReuseAssocationToAETitle(stgcmtReuseTo
+                    ? new String[]{stgcmtAE.getAETitle()}
+                    : new String[]{});
+            Association as = ae.connect(stgcmtAE, executor);
+            as.nevent(UID.StorageCommitmentPushModelSOPClass,
+                    UID.StorageCommitmentPushModelSOPInstance,
+                    eventTypeIdOf(result), result, UID.ImplicitVRLittleEndian,
+                    nEventReportRspHandler);
+            if (!stgcmtReuseFrom && !stgcmtReuseTo) {
+                as.release(true);
+            }
+        }
+    }
+
+    private static int eventTypeIdOf(DicomObject result) {
+        return result.contains(Tag.FailedSOPInstanceUIDList) ? 2 : 1;
+    }
+}
diff --git a/src/in/raster/mayam/util/core/DcmSnd.java b/src/in/raster/mayam/util/core/DcmSnd.java
new file mode 100644
index 0000000..81f6845
--- /dev/null
+++ b/src/in/raster/mayam/util/core/DcmSnd.java
@@ -0,0 +1,1472 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is part of dcm4che, an implementation of DICOM(TM) in
+ * Java(TM), hosted at http://sourceforge.net/projects/dcm4che.
+ *
+ * The Initial Developer of the Original Code is
+ * Gunter Zeilinger, Huetteldorferstr. 24/10, 1150 Vienna/Austria/Europe.
+ * Portions created by the Initial Developer are Copyright (C) 2002-2005
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Gunter Zeilinger <gunterze at gmail.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+package in.raster.mayam.util.core;
+
+import in.raster.mayam.context.ApplicationContext;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.security.GeneralSecurityException;
+import java.security.KeyStore;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Executor;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.GnuParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.commons.cli.OptionGroup;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.dcm4che2.data.BasicDicomObject;
+import org.dcm4che2.data.DicomElement;
+import org.dcm4che2.data.DicomObject;
+import org.dcm4che2.data.Tag;
+import org.dcm4che2.data.UID;
+import org.dcm4che2.data.UIDDictionary;
+import org.dcm4che2.data.VR;
+import org.dcm4che2.io.DicomInputStream;
+import org.dcm4che2.io.DicomOutputStream;
+import org.dcm4che2.io.StopTagInputHandler;
+import org.dcm4che2.io.TranscoderInputHandler;
+import org.dcm4che2.net.Association;
+import org.dcm4che2.net.CommandUtils;
+import org.dcm4che2.net.ConfigurationException;
+import org.dcm4che2.net.Device;
+import org.dcm4che2.net.DimseRSP;
+import org.dcm4che2.net.DimseRSPHandler;
+import org.dcm4che2.net.NetworkApplicationEntity;
+import org.dcm4che2.net.NetworkConnection;
+import org.dcm4che2.net.NewThreadExecutor;
+import org.dcm4che2.net.NoPresentationContextException;
+import org.dcm4che2.net.PDVOutputStream;
+import org.dcm4che2.net.TransferCapability;
+import org.dcm4che2.net.UserIdentity;
+import org.dcm4che2.net.service.StorageCommitmentService;
+import org.dcm4che2.util.CloseUtils;
+import org.dcm4che2.util.StringUtils;
+import org.dcm4che2.util.UIDUtils;
+
+/**
+ * @author gunter zeilinger(gunterze at gmail.com)
+ * @version $Revision: 12969 $ $Date:: 2010-03-19#$
+ * @since Oct 13, 2005
+ */
+public class DcmSnd extends StorageCommitmentService {
+
+    private static final int KB = 1024;
+
+    private static final int MB = KB * KB;
+
+    private static final int PEEK_LEN = 1024;
+
+    private static final String USAGE = 
+        "dcmsnd <aet>[@<host>[:<port>]] <file>|<directory>... [Options]";
+
+    private static final String DESCRIPTION = 
+        "\nLoad composite DICOM Object(s) from specified DICOM file(s) and send it "
+      + "to the specified remote Application Entity. If a directory is specified,"
+      + "DICOM Object in files under that directory and further sub-directories "
+      + "are sent. If <port> is not specified, DICOM default port 104 is assumed. "
+      + "If also no <host> is specified, localhost is assumed. Optionally, a "
+      + "Storage Commitment Request for successfully tranferred objects is sent "
+      + "to the remote Application Entity after the storage. The Storage Commitment "
+      + "result is accepted on the same association or - if a local port is "
+      + "specified by option -L - in a separate association initiated by the "
+      + "remote Application Entity\n"
+      + "OPTIONS:";
+
+    private static final String EXAMPLE = 
+        "\nExample: dcmsnd STORESCP at localhost:11112 image.dcm -stgcmt -L DCMSND:11113 \n"
+      + "=> Start listening on local port 11113 for receiving Storage Commitment "
+      + "results, send DICOM object image.dcm to Application Entity STORESCP, "
+      + "listening on local port 11112, and request Storage Commitment in same association.";
+
+    private static String[] TLS1 = { "TLSv1" };
+
+    private static String[] SSL3 = { "SSLv3" };
+
+    private static String[] NO_TLS1 = { "SSLv3", "SSLv2Hello" };
+
+    private static String[] NO_SSL2 = { "TLSv1", "SSLv3" };
+
+    private static String[] NO_SSL3 = { "TLSv1", "SSLv2Hello" };
+
+    private static char[] SECRET = { 's', 'e', 'c', 'r', 'e', 't' };
+    
+    private static final String[] ONLY_IVLE_TS = { 
+        UID.ImplicitVRLittleEndian
+    };
+
+    private static final String[] IVLE_TS = { 
+        UID.ImplicitVRLittleEndian,
+        UID.ExplicitVRLittleEndian, 
+        UID.ExplicitVRBigEndian,
+    };
+
+    private static final String[] EVLE_TS = {
+        UID.ExplicitVRLittleEndian,
+        UID.ImplicitVRLittleEndian,
+        UID.ExplicitVRBigEndian, 
+    };
+
+    private static final String[] EVBE_TS = { 
+        UID.ExplicitVRBigEndian,
+        UID.ExplicitVRLittleEndian, 
+        UID.ImplicitVRLittleEndian, 
+    };
+
+    private static final int STG_CMT_ACTION_TYPE = 1;
+
+    /** TransferSyntax: DCM4CHE URI Referenced */
+    private static final String DCM4CHEE_URI_REFERENCED_TS_UID =
+            "1.2.40.0.13.1.1.2.4.94";
+
+    private final Executor executor;
+
+    private final NetworkApplicationEntity remoteAE = new NetworkApplicationEntity();
+
+    private NetworkApplicationEntity remoteStgcmtAE;
+
+    private final NetworkConnection remoteConn = new NetworkConnection();
+
+    private final NetworkConnection remoteStgcmtConn = new NetworkConnection();
+
+    private final Device device;
+
+    private final NetworkApplicationEntity ae = new NetworkApplicationEntity();
+
+    private final NetworkConnection conn = new NetworkConnection();
+
+    private final Map<String, Set<String>> as2ts = new HashMap<String, Set<String>>();
+
+    private final ArrayList<FileInfo> files = new ArrayList<FileInfo>();
+
+    private Association assoc;
+
+    private int priority = 0;
+    
+    private int transcoderBufferSize = 1024;
+
+    private int filesSent = 0;
+
+    private long totalSize = 0L;
+
+    private boolean fileref = false;
+
+    private boolean stgcmt = false;
+    
+    private long shutdownDelay = 1000L;
+    
+    private DicomObject stgCmtResult;
+
+    private DicomObject coerceAttrs;
+
+    private String[] suffixUID;
+
+    private String keyStoreURL = "resource:tls/test_sys_1.p12";
+    
+    private char[] keyStorePassword = SECRET; 
+
+    private char[] keyPassword; 
+    
+    private String trustStoreURL = "resource:tls/mesa_certs.jks";
+    
+    private char[] trustStorePassword = SECRET;
+
+    public DcmSnd() {
+        this("DCMSND");
+    }
+
+    public DcmSnd(String name) {
+        device = new Device(name);
+        executor = new NewThreadExecutor(name);
+        remoteAE.setInstalled(true);
+        remoteAE.setAssociationAcceptor(true);
+        remoteAE.setNetworkConnection(new NetworkConnection[] { remoteConn });
+
+        device.setNetworkApplicationEntity(ae);
+        device.setNetworkConnection(conn);
+        ae.setNetworkConnection(conn);
+        ae.setAssociationInitiator(true);
+        ae.setAssociationAcceptor(true);
+        ae.register(this);
+        ae.setAETitle(name);
+    }
+
+    public final void setLocalHost(String hostname) {
+        conn.setHostname(hostname);
+    }
+
+    public final void setLocalPort(int port) {
+        conn.setPort(port);
+    }
+
+    public final void setRemoteHost(String hostname) {
+        remoteConn.setHostname(hostname);
+    }
+
+    public final void setRemotePort(int port) {
+        remoteConn.setPort(port);
+    }
+
+    public final void setRemoteStgcmtHost(String hostname) {
+        remoteStgcmtConn.setHostname(hostname);
+    }
+
+    public final void setRemoteStgcmtPort(int port) {
+        remoteStgcmtConn.setPort(port);
+    }
+
+    public final void setTlsProtocol(String[] tlsProtocol) {
+        conn.setTlsProtocol(tlsProtocol);
+    }
+
+    public final void setTlsWithoutEncyrption() {
+        conn.setTlsWithoutEncyrption();
+        remoteConn.setTlsWithoutEncyrption();
+        remoteStgcmtConn.setTlsWithoutEncyrption();
+    }
+
+    public final void setTls3DES_EDE_CBC() {
+        conn.setTls3DES_EDE_CBC();
+        remoteConn.setTls3DES_EDE_CBC();
+        remoteStgcmtConn.setTls3DES_EDE_CBC();
+    }
+
+    public final void setTlsAES_128_CBC() {
+        conn.setTlsAES_128_CBC();
+        remoteConn.setTlsAES_128_CBC();
+        remoteStgcmtConn.setTlsAES_128_CBC();
+    }
+    
+    public final void setTlsNeedClientAuth(boolean needClientAuth) {
+        conn.setTlsNeedClientAuth(needClientAuth);
+    }  
+    
+    public final void setKeyStoreURL(String url) {
+        keyStoreURL = url;
+    }
+    
+    public final void setKeyStorePassword(String pw) {
+        keyStorePassword = pw.toCharArray();
+    }
+    
+    public final void setKeyPassword(String pw) {
+        keyPassword = pw.toCharArray();
+    }
+    
+    public final void setTrustStorePassword(String pw) {
+        trustStorePassword = pw.toCharArray();
+    }
+    
+    public final void setTrustStoreURL(String url) {
+        trustStoreURL = url;
+    }
+
+    public final void setCalledAET(String called) {
+        remoteAE.setAETitle(called);
+    }
+
+    public final void setCalling(String calling) {
+        ae.setAETitle(calling);
+    }
+    
+    public final void setUserIdentity(UserIdentity userIdentity) {
+        ae.setUserIdentity(userIdentity);
+    }
+    
+    public final void setOfferDefaultTransferSyntaxInSeparatePresentationContext(
+            boolean enable) {
+        ae.setOfferDefaultTransferSyntaxInSeparatePresentationContext(enable);
+    }
+
+    public final void setSendFileRef(boolean fileref) {
+        this.fileref = fileref;
+    }
+
+    public final void setStorageCommitment(boolean stgcmt) {
+        this.stgcmt = stgcmt;
+    }
+
+    public final boolean isStorageCommitment() {
+        return stgcmt;
+    }
+
+    public final void setStgcmtCalledAET(String called) {
+        remoteStgcmtAE = new NetworkApplicationEntity();
+        remoteStgcmtAE.setInstalled(true);
+        remoteStgcmtAE.setAssociationAcceptor(true);
+        remoteStgcmtAE.setNetworkConnection(
+                new NetworkConnection[] { remoteStgcmtConn });
+        remoteStgcmtAE.setAETitle(called);
+    }
+
+    public final void setShutdownDelay(int shutdownDelay) {
+        this.shutdownDelay = shutdownDelay;
+    }
+    
+
+    public final void setConnectTimeout(int connectTimeout) {
+        conn.setConnectTimeout(connectTimeout);
+    }
+
+    public final void setMaxPDULengthReceive(int maxPDULength) {
+        ae.setMaxPDULengthReceive(maxPDULength);
+    }
+
+    public final void setMaxOpsInvoked(int maxOpsInvoked) {
+        ae.setMaxOpsInvoked(maxOpsInvoked);
+    }
+
+    public final void setPackPDV(boolean packPDV) {
+        ae.setPackPDV(packPDV);
+    }
+
+    public final void setAssociationReaperPeriod(int period) {
+        device.setAssociationReaperPeriod(period);
+    }
+
+    public final void setDimseRspTimeout(int timeout) {
+        ae.setDimseRspTimeout(timeout);
+    }
+
+    public final void setPriority(int priority) {
+        this.priority = priority;
+    }
+
+    public final void setTcpNoDelay(boolean tcpNoDelay) {
+        conn.setTcpNoDelay(tcpNoDelay);
+    }
+
+    public final void setAcceptTimeout(int timeout) {
+        conn.setAcceptTimeout(timeout);
+    }
+
+    public final void setReleaseTimeout(int timeout) {
+        conn.setReleaseTimeout(timeout);
+    }
+
+    public final void setSocketCloseDelay(int timeout) {
+        conn.setSocketCloseDelay(timeout);
+    }
+
+    public final void setMaxPDULengthSend(int maxPDULength) {
+        ae.setMaxPDULengthSend(maxPDULength);
+    }
+
+    public final void setReceiveBufferSize(int bufferSize) {
+        conn.setReceiveBufferSize(bufferSize);
+    }
+
+    public final void setSendBufferSize(int bufferSize) {
+        conn.setSendBufferSize(bufferSize);
+    }
+
+    public final void setTranscoderBufferSize(int transcoderBufferSize) {
+        this.transcoderBufferSize = transcoderBufferSize;
+    }
+
+    public final int getNumberOfFilesToSend() {
+        return files.size();
+    }
+
+    public final int getNumberOfFilesSent() {
+        return filesSent;
+    }
+
+    public final long getTotalSizeSent() {
+        return totalSize;
+    }
+    
+    public List<FileInfo> getFileInfos() {
+        return files;
+    }
+
+    private static CommandLine parse(String[] args) {
+        Options opts = new Options();
+
+        OptionBuilder.withArgName("name");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "set device name, use DCMSND by default");
+        opts.addOption(OptionBuilder.create("device"));
+
+        OptionBuilder.withArgName("aet[@host][:port]");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "set AET, local address and listening port of local "
+                + "Application Entity, use device name and pick up any valid "
+                + "local address to bind the socket by default");
+        opts.addOption(OptionBuilder.create("L"));
+
+        opts.addOption("ts1", false, "offer Default Transfer Syntax in " +
+                "separate Presentation Context. By default offered with " +
+                "Explicit VR Little Endian TS in one PC.");
+
+        opts.addOption("fileref", false,
+                "send objects without pixel data, but with a reference to " +
+                "the DICOM file using DCM4CHE URI Referenced Transfer Syntax " +
+                "to import DICOM objects on a given file system to a DCM4CHEE " +
+                "archive.");
+
+        OptionBuilder.withArgName("username");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "enable User Identity Negotiation with specified username and "
+                + " optional passcode");
+        opts.addOption(OptionBuilder.create("username"));
+
+        OptionBuilder.withArgName("passcode");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "optional passcode for User Identity Negotiation, "
+                + "only effective with option -username");
+        opts.addOption(OptionBuilder.create("passcode"));
+
+        opts.addOption("uidnegrsp", false,
+                "request positive User Identity Negotation response, "
+                + "only effective with option -username");
+                
+        OptionBuilder.withArgName("NULL|3DES|AES");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "enable TLS connection without, 3DES or AES encryption");
+        opts.addOption(OptionBuilder.create("tls"));
+
+        OptionGroup tlsProtocol = new OptionGroup();
+        tlsProtocol.addOption(new Option("tls1",
+                "disable the use of SSLv3 and SSLv2 for TLS connections"));
+        tlsProtocol.addOption(new Option("ssl3",
+                "disable the use of TLSv1 and SSLv2 for TLS connections"));
+        tlsProtocol.addOption(new Option("no_tls1",
+                "disable the use of TLSv1 for TLS connections"));
+        tlsProtocol.addOption(new Option("no_ssl3",
+                "disable the use of SSLv3 for TLS connections"));
+        tlsProtocol.addOption(new Option("no_ssl2",
+                "disable the use of SSLv2 for TLS connections"));
+        opts.addOptionGroup(tlsProtocol);
+
+        opts.addOption("noclientauth", false,
+                "disable client authentification for TLS");
+
+        OptionBuilder.withArgName("file|url");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "file path or URL of P12 or JKS keystore, resource:tls/test_sys_2.p12 by default");
+        opts.addOption(OptionBuilder.create("keystore"));
+
+        OptionBuilder.withArgName("password");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "password for keystore file, 'secret' by default");
+        opts.addOption(OptionBuilder.create("keystorepw"));
+
+        OptionBuilder.withArgName("password");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "password for accessing the key in the keystore, keystore password by default");
+        opts.addOption(OptionBuilder.create("keypw"));
+
+        OptionBuilder.withArgName("file|url");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "file path or URL of JKS truststore, resource:tls/mesa_certs.jks by default");
+        opts.addOption(OptionBuilder.create("truststore"));
+
+        OptionBuilder.withArgName("password");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "password for truststore file, 'secret' by default");
+        opts.addOption(OptionBuilder.create("truststorepw"));
+
+        OptionBuilder.withArgName("aet at host:port");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "request storage commitment of (successfully) sent objects " +
+                "afterwards in new association to specified remote " +
+                "Application Entity");
+        opts.addOption(OptionBuilder.create("stgcmtae"));
+
+        opts.addOption("stgcmt", false,
+                "request storage commitment of (successfully) sent objects " +
+                "afterwards in same association");
+        
+        OptionBuilder.withArgName("attr=value");
+        OptionBuilder.hasArgs();
+        OptionBuilder.withValueSeparator('=');
+        OptionBuilder.withDescription("Replace value of specified attribute " +
+                "with specified value in transmitted objects. attr can be " +
+                "specified by name or tag value (in hex), e.g. PatientName " +
+                "or 00100010.");
+        opts.addOption(OptionBuilder.create("set"));
+
+        OptionBuilder.withArgName("sx1[:sx2[:sx3]");
+        OptionBuilder.hasArgs();
+        OptionBuilder.withValueSeparator(':');
+        OptionBuilder.withDescription("Suffix SOP [,Series [,Study]] " +
+                "Instance UID with specified value[s] in transmitted objects.");
+        opts.addOption(OptionBuilder.create("setuid"));
+
+        OptionBuilder.withArgName("maxops");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "maximum number of outstanding operations it may invoke " + 
+                "asynchronously, unlimited by default.");
+        opts.addOption(OptionBuilder.create("async"));
+
+        opts.addOption("pdv1", false,
+                "send only one PDV in one P-Data-TF PDU, " + 
+                "pack command and data PDV in one P-DATA-TF PDU by default.");
+        opts.addOption("tcpdelay", false,
+                "set TCP_NODELAY socket option to false, true by default");
+
+        OptionBuilder.withArgName("ms");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "timeout in ms for TCP connect, no timeout by default");
+        opts.addOption(OptionBuilder.create("connectTO"));
+
+        OptionBuilder.withArgName("ms");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "delay in ms for Socket close after sending A-ABORT, " +
+                "50ms by default");
+        opts.addOption(OptionBuilder.create("soclosedelay"));
+
+        OptionBuilder.withArgName("ms");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "delay in ms for closing the listening socket, " +
+                "1000ms by default");
+        opts.addOption(OptionBuilder.create("shutdowndelay"));
+
+        OptionBuilder.withArgName("ms");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "period in ms to check for outstanding DIMSE-RSP, " +
+                "10s by default");
+        opts.addOption(OptionBuilder.create("reaper"));
+
+        OptionBuilder.withArgName("ms");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "timeout in ms for receiving DIMSE-RSP, 10s by default");
+        opts.addOption(OptionBuilder.create("rspTO"));
+
+        OptionBuilder.withArgName("ms");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "timeout in ms for receiving A-ASSOCIATE-AC, 5s by default");
+        opts.addOption(OptionBuilder.create("acceptTO"));
+
+        OptionBuilder.withArgName("ms");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "timeout in ms for receiving A-RELEASE-RP, 5s by default");
+        opts.addOption(OptionBuilder.create("releaseTO"));
+
+        OptionBuilder.withArgName("KB");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "maximal length in KB of received P-DATA-TF PDUs, 16KB by default");
+        opts.addOption(OptionBuilder.create("rcvpdulen"));
+
+        OptionBuilder.withArgName("KB");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "maximal length in KB of sent P-DATA-TF PDUs, 16KB by default");
+        opts.addOption(OptionBuilder.create("sndpdulen"));
+
+        OptionBuilder.withArgName("KB");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "set SO_RCVBUF socket option to specified value in KB");
+        opts.addOption(OptionBuilder.create("sorcvbuf"));
+
+        OptionBuilder.withArgName("KB");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "set SO_SNDBUF socket option to specified value in KB");
+        opts.addOption(OptionBuilder.create("sosndbuf"));
+
+        OptionBuilder.withArgName("KB");
+        OptionBuilder.hasArg();
+        OptionBuilder.withDescription(
+                "transcoder buffer size in KB, 1KB by default");
+        opts.addOption(OptionBuilder.create("bufsize"));
+
+        opts.addOption("lowprior", false,
+                "LOW priority of the C-STORE operation, MEDIUM by default");
+        opts.addOption("highprior", false,
+                "HIGH priority of the C-STORE operation, MEDIUM by default");
+        opts.addOption("h", "help", false, "print this message");
+        opts.addOption("V", "version", false,
+                "print the version information and exit");
+        CommandLine cl = null;
+        try {
+            cl = new GnuParser().parse(opts, args);
+        } catch (ParseException e) {
+            exit("dcmsnd: " + e.getMessage());
+            throw new RuntimeException("unreachable");
+        }
+        if (cl.hasOption('V')) {
+            Package p = DcmSnd.class.getPackage();
+            System.out.println("dcmsnd v" + p.getImplementationVersion());
+            System.exit(0);
+        }
+        if (cl.hasOption('h') || cl.getArgList().size() < 2) {
+            HelpFormatter formatter = new HelpFormatter();
+            formatter.printHelp(USAGE, DESCRIPTION, opts, EXAMPLE);
+            System.exit(0);
+        }
+        return cl;
+    }
+
+    @SuppressWarnings("unchecked")
+    public static void main(String[] args) {
+        CommandLine cl = parse(args);
+        String[] s = ApplicationContext.databaseRef.getListenerDetails();
+        DcmSnd dcmsnd = new DcmSnd(s[0]);
+        final List<String> argList = cl.getArgList();
+        String remoteAE = argList.get(0);
+        String[] calledAETAddress = split(remoteAE, '@');
+        dcmsnd.setCalledAET(calledAETAddress[0]);
+        if (calledAETAddress[1] == null) {
+            dcmsnd.setRemoteHost("127.0.0.1");
+            dcmsnd.setRemotePort(104);
+        } else {
+            String[] hostPort = split(calledAETAddress[1], ':');
+            dcmsnd.setRemoteHost(hostPort[0]);
+            dcmsnd.setRemotePort(toPort(hostPort[1]));
+        }
+        if (cl.hasOption("L")) {
+            String localAE = cl.getOptionValue("L");
+            String[] localPort = split(localAE, ':');
+            if (localPort[1] != null) {
+                dcmsnd.setLocalPort(toPort(localPort[1]));                
+            }
+            String[] callingAETHost = split(localPort[0], '@');
+            dcmsnd.setCalling(callingAETHost[0]);
+            if (callingAETHost[1] != null) {
+                dcmsnd.setLocalHost(callingAETHost[1]);
+            }
+        }
+        dcmsnd.setOfferDefaultTransferSyntaxInSeparatePresentationContext(
+                cl.hasOption("ts1"));
+        dcmsnd.setSendFileRef(cl.hasOption("fileref"));
+        if (cl.hasOption("username")) {
+            String username = cl.getOptionValue("username");
+            UserIdentity userId;
+            if (cl.hasOption("passcode")) {
+                String passcode = cl.getOptionValue("passcode");
+                userId = new UserIdentity.UsernamePasscode(username,
+                        passcode.toCharArray());
+            } else {
+                userId = new UserIdentity.Username(username);
+            }
+            userId.setPositiveResponseRequested(cl.hasOption("uidnegrsp"));
+            dcmsnd.setUserIdentity(userId);
+        }
+        dcmsnd.setStorageCommitment(cl.hasOption("stgcmt"));
+        String remoteStgCmtAE = null;
+        if (cl.hasOption("stgcmtae")) {
+            try {
+                remoteStgCmtAE = cl.getOptionValue("stgcmtae");
+                String[] aet_hostport = split(remoteStgCmtAE, '@');
+                String[] host_port = split(aet_hostport[1], ':');
+                dcmsnd.setStgcmtCalledAET(aet_hostport[0]);
+                dcmsnd.setRemoteStgcmtHost(host_port[0]);
+                dcmsnd.setRemoteStgcmtPort(toPort(host_port[1]));
+            } catch (Exception e) {
+                exit("illegal argument of option -stgcmtae");
+            }
+        }
+        if (cl.hasOption("set")) {
+            String[] vals = cl.getOptionValues("set");
+            for (int i = 0; i < vals.length; i++, i++) {
+                dcmsnd.addCoerceAttr(Tag.toTag(vals[i]), vals[i+1]);
+            }
+        }
+        if (cl.hasOption("setuid")) {
+            dcmsnd.setSuffixUID(cl.getOptionValues("setuid"));
+        }
+        if (cl.hasOption("connectTO"))
+            dcmsnd.setConnectTimeout(parseInt(cl.getOptionValue("connectTO"),
+                    "illegal argument of option -connectTO", 1,
+                    Integer.MAX_VALUE));
+        if (cl.hasOption("reaper"))
+            dcmsnd.setAssociationReaperPeriod(
+                    parseInt(cl.getOptionValue("reaper"),
+                    "illegal argument of option -reaper",
+                    1, Integer.MAX_VALUE));
+        if (cl.hasOption("rspTO"))
+            dcmsnd.setDimseRspTimeout(parseInt(cl.getOptionValue("rspTO"),
+                    "illegal argument of option -rspTO",
+                    1, Integer.MAX_VALUE));
+        if (cl.hasOption("acceptTO"))
+            dcmsnd.setAcceptTimeout(parseInt(cl.getOptionValue("acceptTO"),
+                    "illegal argument of option -acceptTO", 
+                    1, Integer.MAX_VALUE));
+        if (cl.hasOption("releaseTO"))
+            dcmsnd.setReleaseTimeout(parseInt(cl.getOptionValue("releaseTO"),
+                    "illegal argument of option -releaseTO",
+                    1, Integer.MAX_VALUE));
+        if (cl.hasOption("soclosedelay"))
+            dcmsnd.setSocketCloseDelay(
+                    parseInt(cl.getOptionValue("soclosedelay"),
+                    "illegal argument of option -soclosedelay", 1, 10000));
+        if (cl.hasOption("shutdowndelay"))
+            dcmsnd.setShutdownDelay(
+                    parseInt(cl.getOptionValue("shutdowndelay"),
+                    "illegal argument of option -shutdowndelay", 1, 10000));
+        if (cl.hasOption("rcvpdulen"))
+            dcmsnd.setMaxPDULengthReceive(
+                    parseInt(cl.getOptionValue("rcvpdulen"),
+                    "illegal argument of option -rcvpdulen", 1, 10000) * KB);
+        if (cl.hasOption("sndpdulen"))
+            dcmsnd.setMaxPDULengthSend(parseInt(cl.getOptionValue("sndpdulen"),
+                    "illegal argument of option -sndpdulen", 1, 10000) * KB);
+        if (cl.hasOption("sosndbuf"))
+            dcmsnd.setSendBufferSize(parseInt(cl.getOptionValue("sosndbuf"),
+                    "illegal argument of option -sosndbuf", 1, 10000) * KB);
+        if (cl.hasOption("sorcvbuf"))
+            dcmsnd.setReceiveBufferSize(parseInt(cl.getOptionValue("sorcvbuf"),
+                    "illegal argument of option -sorcvbuf", 1, 10000) * KB);
+        if (cl.hasOption("bufsize"))
+            dcmsnd.setTranscoderBufferSize(
+                    parseInt(cl.getOptionValue("bufsize"),
+                    "illegal argument of option -bufsize", 1, 10000) * KB);
+        dcmsnd.setPackPDV(!cl.hasOption("pdv1"));
+        dcmsnd.setTcpNoDelay(!cl.hasOption("tcpdelay"));
+        if (cl.hasOption("async"))
+            dcmsnd.setMaxOpsInvoked(parseInt(cl.getOptionValue("async"),
+                    "illegal argument of option -async", 0, 0xffff));
+        if (cl.hasOption("lowprior"))
+            dcmsnd.setPriority(CommandUtils.LOW);
+        if (cl.hasOption("highprior"))
+            dcmsnd.setPriority(CommandUtils.HIGH);
+    //    System.out.println("Scanning files to send");
+        long t1 = System.currentTimeMillis();
+        for (int i = 1, n = argList.size(); i < n; ++i)
+            dcmsnd.addFile(new File(argList.get(i)));
+        long t2 = System.currentTimeMillis();
+        if (dcmsnd.getNumberOfFilesToSend() == 0) {
+            //System.exit(2);
+        }
+    //    System.out.println("\nScanned " + dcmsnd.getNumberOfFilesToSend()
+            //    + " files in " + ((t2 - t1) / 1000F) + "s (="
+            //    + ((t2 - t1) / dcmsnd.getNumberOfFilesToSend()) + "ms/file)");
+        dcmsnd.configureTransferCapability();
+        if (cl.hasOption("tls")) {
+            String cipher = cl.getOptionValue("tls");
+            if ("NULL".equalsIgnoreCase(cipher)) {
+                dcmsnd.setTlsWithoutEncyrption();
+            } else if ("3DES".equalsIgnoreCase(cipher)) {
+                dcmsnd.setTls3DES_EDE_CBC();
+            } else if ("AES".equalsIgnoreCase(cipher)) {
+                dcmsnd.setTlsAES_128_CBC();
+            } else {
+                exit("Invalid parameter for option -tls: " + cipher);
+            }
+
+            if (cl.hasOption("tls1")) {
+                dcmsnd.setTlsProtocol(TLS1);
+            } else if (cl.hasOption("ssl3")) {
+                dcmsnd.setTlsProtocol(SSL3);
+            } else if (cl.hasOption("no_tls1")) {
+                dcmsnd.setTlsProtocol(NO_TLS1);
+            } else if (cl.hasOption("no_ssl3")) {
+                dcmsnd.setTlsProtocol(NO_SSL3);
+            } else if (cl.hasOption("no_ssl2")) {
+                dcmsnd.setTlsProtocol(NO_SSL2);
+            }
+            dcmsnd.setTlsNeedClientAuth(!cl.hasOption("noclientauth"));
+
+            if (cl.hasOption("keystore")) {
+                dcmsnd.setKeyStoreURL(cl.getOptionValue("keystore"));
+            }
+            if (cl.hasOption("keystorepw")) {
+                dcmsnd.setKeyStorePassword(
+                        cl.getOptionValue("keystorepw"));
+            }
+            if (cl.hasOption("keypw")) {
+                dcmsnd.setKeyPassword(cl.getOptionValue("keypw"));
+            }
+            if (cl.hasOption("truststore")) {
+                dcmsnd.setTrustStoreURL(
+                        cl.getOptionValue("truststore"));
+            }
+            if (cl.hasOption("truststorepw")) {
+                dcmsnd.setTrustStorePassword(
+                        cl.getOptionValue("truststorepw"));
+            }
+            try {
+                dcmsnd.initTLS();
+            } catch (Exception e) {e.printStackTrace();
+             //   System.err.println("ERROR: Failed to initialize TLS context:"
+               //         + e.getMessage());
+               // System.exit(2);
+            }
+        }        
+        try {
+            dcmsnd.start();
+        } catch (Exception e) {e.printStackTrace();
+           // System.err.println("ERROR: Failed to start server for receiving " +
+           //         "Storage Commitment results:" + e.getMessage());
+           // System.exit(2);
+        }
+        try {
+            t1 = System.currentTimeMillis();
+            try {
+                dcmsnd.open();
+            } catch (Exception e) {e.printStackTrace();
+              //  System.err.println("ERROR: Failed to establish association:"
+               //         + e.getMessage());
+              //  System.exit(2);
+            }
+            t2 = System.currentTimeMillis();
+           // System.out.println("Connected to " + remoteAE + " in "
+           //         + ((t2 - t1) / 1000F) + "s");
+    
+            t1 = System.currentTimeMillis();
+            dcmsnd.send();
+            t2 = System.currentTimeMillis();
+            prompt(dcmsnd, (t2 - t1) / 1000F);
+            if (dcmsnd.isStorageCommitment()) {
+                t1 = System.currentTimeMillis();
+                if (dcmsnd.commit()) {
+                    t2 = System.currentTimeMillis();
+                    System.out.println("Request Storage Commitment from " 
+                            + remoteAE + " in " + ((t2 - t1) / 1000F) + "s");
+                    System.out.println("Waiting for Storage Commitment Result..");
+                    try {
+                        DicomObject cmtrslt = dcmsnd.waitForStgCmtResult();
+                        t1 = System.currentTimeMillis();
+                        promptStgCmt(cmtrslt, ((t1 - t2) / 1000F));
+                    } catch (InterruptedException e) {
+                        System.err.println("ERROR:" + e.getMessage());
+                    }
+                }
+             }
+            dcmsnd.close();
+         //   System.out.println("Released connection to " + remoteAE);
+            if (remoteStgCmtAE != null) {
+                t1 = System.currentTimeMillis();
+                try {
+                    dcmsnd.openToStgcmtAE();
+                } catch (Exception e) {e.printStackTrace();
+                  //  System.err.println("ERROR: Failed to establish association:"
+                   //         + e.getMessage());
+                   // System.exit(2);
+                }
+                t2 = System.currentTimeMillis();
+             //   System.out.println("Connected to " + remoteStgCmtAE + " in "
+                 //       + ((t2 - t1) / 1000F) + "s");
+                t1 = System.currentTimeMillis();
+                if (dcmsnd.commit()) {
+                    t2 = System.currentTimeMillis();
+                  //  System.out.println("Request Storage Commitment from "
+                   //         + remoteStgCmtAE + " in " + ((t2 - t1) / 1000F) + "s");
+                  //  System.out.println("Waiting for Storage Commitment Result..");
+                    try {
+                        DicomObject cmtrslt = dcmsnd.waitForStgCmtResult();
+                        t1 = System.currentTimeMillis();
+                        promptStgCmt(cmtrslt, ((t1 - t2) / 1000F));
+                    } catch (InterruptedException e) {
+                        System.err.println("ERROR:" + e.getMessage());
+                    }
+                }
+                dcmsnd.close();
+              //  System.out.println("Released connection to " + remoteStgCmtAE);
+            }
+        } finally {
+            dcmsnd.stop();
+        }
+    }
+
+    public void addCoerceAttr(int tag, String val) {
+        if (coerceAttrs == null)
+            coerceAttrs = new BasicDicomObject();
+        if (val.length() == 0)
+            coerceAttrs.putNull(tag, null);
+        else
+            coerceAttrs.putString(tag, null, val);
+    }
+
+    public void setSuffixUID(String[] suffix) {
+        if (suffix.length > 3)
+            throw new IllegalArgumentException(
+                    "suffix.length: " + suffix.length);
+
+        this.suffixUID = suffix.length > 0 ? suffix.clone() : null;
+    }
+
+    private static void promptStgCmt(DicomObject cmtrslt, float seconds) {
+        System.out.println("Received Storage Commitment Result after "
+                + seconds + "s:");
+        DicomElement refSOPSq = cmtrslt.get(Tag.ReferencedSOPSequence);
+        System.out.print(refSOPSq.countItems());
+        System.out.println(" successful");
+        DicomElement failedSOPSq = cmtrslt.get(Tag.FailedSOPSequence);
+        if (failedSOPSq != null) {
+            System.out.print(failedSOPSq.countItems());
+            System.out.println(" FAILED!");                       
+        }
+    }
+
+    private synchronized DicomObject waitForStgCmtResult() throws InterruptedException {
+        while (stgCmtResult == null) {wait();}
+        return stgCmtResult;
+    }
+
+    private static void prompt(DcmSnd dcmsnd, float seconds) {
+       /* System.out.print("\nSent ");
+        System.out.print(dcmsnd.getNumberOfFilesSent());
+        System.out.print(" objects (=");
+        promptBytes(dcmsnd.getTotalSizeSent());
+        System.out.print(") in ");
+        System.out.print(seconds);
+        System.out.print("s (=");
+        promptBytes(dcmsnd.getTotalSizeSent() / seconds);
+        System.out.println("/s)");*/
+    }
+
+    private static void promptBytes(float totalSizeSent) {
+        if (totalSizeSent > MB) {
+            System.out.print(totalSizeSent / MB);
+            System.out.print("MB");
+        } else {
+            System.out.print(totalSizeSent / KB);
+            System.out.print("KB");
+        }
+    }
+
+    private static int toPort(String port) {
+        return port != null ? parseInt(port, "illegal port number", 1, 0xffff)
+                : 104;
+    }
+
+    private static String[] split(String s, char delim) {
+        String[] s2 = { s, null };
+        int pos = s.indexOf(delim);
+        if (pos != -1) {
+            s2[0] = s.substring(0, pos);
+            s2[1] = s.substring(pos + 1);
+        }
+        return s2;
+    }
+
+    private static void exit(String msg) {
+        System.err.println(msg);
+      //  System.err.println("Try 'dcmsnd -h' for more information.");
+      //  System.exit(1);
+    }
+
+    private static int parseInt(String s, String errPrompt, int min, int max) {
+        try {
+            int i = Integer.parseInt(s);
+            if (i >= min && i <= max)
+                return i;
+        } catch (NumberFormatException e) {e.printStackTrace();
+            // parameter is not a valid integer; fall through to exit
+        }
+        exit(errPrompt);
+        throw new RuntimeException();
+    }
+
+    public void addFile(File f) {
+        if (f.isDirectory()) {
+            File[] fs = f.listFiles();
+            for (int i = 0; i < fs.length; i++)
+                addFile(fs[i]);
+            return;
+        }
+        FileInfo info = new FileInfo(f);
+        DicomObject dcmObj = new BasicDicomObject();
+        DicomInputStream in = null;
+        try {
+            in = new DicomInputStream(f);
+            in.setHandler(new StopTagInputHandler(Tag.StudyDate));
+            in.readDicomObject(dcmObj, PEEK_LEN);
+            info.tsuid = in.getTransferSyntax().uid();
+            info.fmiEndPos = in.getEndOfFileMetaInfoPosition();
+        } catch (IOException e) {
+            e.printStackTrace();
+            System.err.println("WARNING: Failed to parse " + f + " - skipped.");
+            System.out.print('F');
+            return;
+        } finally {
+            CloseUtils.safeClose(in);
+        }
+        info.cuid = dcmObj.getString(Tag.MediaStorageSOPClassUID,
+                dcmObj.getString(Tag.SOPClassUID));
+        if (info.cuid == null) {
+            System.err.println("WARNING: Missing SOP Class UID in " + f
+                    + " - skipped.");
+            System.out.print('F');
+            return;
+        }
+        info.iuid = dcmObj.getString(Tag.MediaStorageSOPInstanceUID,
+                dcmObj.getString(Tag.SOPInstanceUID));
+        if (info.iuid == null) {
+            System.err.println("WARNING: Missing SOP Instance UID in " + f
+                    + " - skipped.");
+            System.out.print('F');
+            return;
+        }
+        if (suffixUID != null)
+            info.iuid = info.iuid + suffixUID[0];
+        addTransferCapability(info.cuid, info.tsuid);
+        files.add(info);
+        System.out.print('.');
+    }
+
+    public void addTransferCapability(String cuid, String tsuid) {
+        Set<String> ts = as2ts.get(cuid);
+        if (fileref) {
+            if (ts == null) {
+                as2ts.put(cuid,
+                        Collections.singleton(DCM4CHEE_URI_REFERENCED_TS_UID));
+            }
+        } else {
+            if (ts == null) {
+                ts = new HashSet<String>();
+                ts.add(UID.ImplicitVRLittleEndian);
+                as2ts.put(cuid, ts);
+            }
+            ts.add(tsuid);
+        }
+    }
+
+    public void configureTransferCapability() {
+        int off = stgcmt || remoteStgcmtAE != null ? 1 : 0;
+        TransferCapability[] tc = new TransferCapability[off + as2ts.size()];
+        if (off > 0) {
+            tc[0] = new TransferCapability(
+                    UID.StorageCommitmentPushModelSOPClass,
+                    ONLY_IVLE_TS, 
+                    TransferCapability.SCU);
+        }
+        Iterator<Map.Entry<String, Set<String>>> iter = as2ts.entrySet().iterator();
+        for (int i = off; i < tc.length; i++) {
+            Map.Entry<String, Set<String>> e = iter.next();
+            String cuid = e.getKey();
+            Set<String> ts = e.getValue();
+            tc[i] = new TransferCapability(cuid, 
+                    ts.toArray(new String[ts.size()]),
+                    TransferCapability.SCU);
+        }
+        ae.setTransferCapability(tc);
+    }
+
+    public void start() throws IOException { 
+        if (conn.isListening()) {
+            conn.bind(executor );
+            System.out.println("Start Server listening on port " + conn.getPort());
+        }
+    }
+
+    public void stop() {
+        if (conn.isListening()) {
+            try {
+                Thread.sleep(shutdownDelay);
+            } catch (InterruptedException e) {
+                // Should not happen
+                e.printStackTrace();                
+            }
+            conn.unbind();
+        }
+    }
+    
+    public void open() throws IOException, ConfigurationException,
+            InterruptedException {
+        assoc = ae.connect(remoteAE, executor);
+    }
+
+    public void openToStgcmtAE() throws IOException, ConfigurationException,
+            InterruptedException {
+        assoc = ae.connect(remoteStgcmtAE, executor);
+    }
+
+    public void send() {
+        for (int i = 0, n = files.size(); i < n; ++i) {
+            FileInfo info = files.get(i);
+            TransferCapability tc = assoc.getTransferCapabilityAsSCU(info.cuid);
+            if (tc == null) {
+                System.out.println();
+                System.out.println(UIDDictionary.getDictionary().prompt(
+                        info.cuid)
+                        + " not supported by " + remoteAE.getAETitle());
+                System.out.println("skip file " + info.f);
+                continue;
+            }
+            String tsuid = selectTransferSyntax(tc.getTransferSyntax(),
+                    fileref ? DCM4CHEE_URI_REFERENCED_TS_UID : info.tsuid);
+            if (tsuid == null) {
+                System.out.println();
+                System.out.println(UIDDictionary.getDictionary().prompt(
+                        info.cuid)
+                        + " with "
+                        + UIDDictionary.getDictionary().prompt(
+                                fileref ? DCM4CHEE_URI_REFERENCED_TS_UID 
+                                        : info.tsuid)
+                        + " not supported by " + remoteAE.getAETitle());
+                System.out.println("skip file " + info.f);
+                continue;
+            }
+            try {
+                DimseRSPHandler rspHandler = new DimseRSPHandler() {
+                    @Override
+                    public void onDimseRSP(Association as, DicomObject cmd,
+                            DicomObject data) {
+                        DcmSnd.this.onDimseRSP(cmd);
+                    }
+                };
+
+                assoc.cstore(info.cuid, info.iuid, priority,
+                        new DataWriter(info), tsuid, rspHandler);
+            } catch (NoPresentationContextException e) {
+                System.err.println("WARNING: " + e.getMessage()
+                        + " - cannot send " + info.f);
+                System.out.print('F');
+            } catch (IOException e) {
+                e.printStackTrace();
+                System.err.println("ERROR: Failed to send - " + info.f + ": "
+                        + e.getMessage());
+                System.out.print('F');
+            } catch (InterruptedException e) {
+                // should not happen
+                e.printStackTrace();
+            }
+        }
+        try {
+            assoc.waitForDimseRSP();
+        } catch (InterruptedException e) {
+            // should not happen
+            e.printStackTrace();
+        }
+    }
+
+    public boolean commit() {
+        DicomObject actionInfo = new BasicDicomObject();
+        actionInfo.putString(Tag.TransactionUID, VR.UI, UIDUtils.createUID());
+        DicomElement refSOPSq = actionInfo.putSequence(Tag.ReferencedSOPSequence);
+        for (int i = 0, n = files.size(); i < n; ++i) {
+            FileInfo info = files.get(i);
+            if (info.transferred) {
+                BasicDicomObject refSOP = new BasicDicomObject();
+                refSOP.putString(Tag.ReferencedSOPClassUID, VR.UI, info.cuid);
+                refSOP.putString(Tag.ReferencedSOPInstanceUID, VR.UI, info.iuid);
+                refSOPSq.addDicomObject(refSOP);
+            }
+        }
+        try {
+            stgCmtResult = null;
+            DimseRSP rsp = assoc.naction(UID.StorageCommitmentPushModelSOPClass,
+                UID.StorageCommitmentPushModelSOPInstance, STG_CMT_ACTION_TYPE,
+                actionInfo, UID.ImplicitVRLittleEndian);
+            rsp.next();
+            DicomObject cmd = rsp.getCommand();
+            int status = cmd.getInt(Tag.Status);
+            if (status == 0) {
+                return true;
+            }
+            System.err.println(
+                    "WARNING: Storage Commitment request failed with status: "
+                    + StringUtils.shortToHex(status) + "H");
+            System.err.println(cmd.toString());
+        } catch (NoPresentationContextException e) {
+            System.err.println("WARNING: " + e.getMessage()
+                    + " - cannot request Storage Commitment");
+        } catch (IOException e) {
+            e.printStackTrace();
+            System.err.println(
+                    "ERROR: Failed to send Storage Commitment request: "
+                    + e.getMessage());
+        } catch (InterruptedException e) {
+            // should not happen
+            e.printStackTrace();
+        }
+        return false;
+    }
+    
+    private String selectTransferSyntax(String[] available, String tsuid) {
+        if (tsuid.equals(UID.ImplicitVRLittleEndian))
+            return selectTransferSyntax(available, IVLE_TS);
+        if (tsuid.equals(UID.ExplicitVRLittleEndian))
+            return selectTransferSyntax(available, EVLE_TS);
+        if (tsuid.equals(UID.ExplicitVRBigEndian))
+            return selectTransferSyntax(available, EVBE_TS);
+        for (int j = 0; j < available.length; j++)
+            if (available[j].equals(tsuid))
+                return tsuid;
+        return null;
+    }
+
+    private String selectTransferSyntax(String[] available, String[] tsuids) {
+        for (int i = 0; i < tsuids.length; i++)
+            for (int j = 0; j < available.length; j++)
+                if (available[j].equals(tsuids[i]))
+                    return available[j];
+        return null;
+    }
+
+    public void close() {
+        try {
+            assoc.release(false);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public static final class FileInfo {
+        File f;
+
+        String cuid;
+
+        String iuid;
+
+        String tsuid;
+
+        long fmiEndPos;
+
+        long length;
+        
+        boolean transferred;
+        
+        int status;
+
+        public FileInfo(File f) {
+            this.f = f;
+            this.length = f.length();
+        }
+                
+    }
+
+    private class DataWriter implements org.dcm4che2.net.DataWriter {
+
+        private FileInfo info;
+
+        public DataWriter(FileInfo info) {
+            this.info = info;
+        }
+
+        public void writeTo(PDVOutputStream out, String tsuid)
+                throws IOException {
+            if (coerceAttrs != null || suffixUID != null) {
+                DicomObject attrs;
+                DicomInputStream dis = new DicomInputStream(info.f);
+                try {
+                    dis.setHandler(new StopTagInputHandler(Tag.PixelData));
+                    attrs = dis.readDicomObject();
+                    suffixUIDs(attrs);
+                    coerceAttrs(attrs);
+                    DicomOutputStream dos = new DicomOutputStream(out);
+                    dos.writeDataset(attrs, tsuid);
+                    if (dis.tag() >= Tag.PixelData) {
+                        copyPixelData(dis, dos, out);
+                        // copy attrs after PixelData
+                        attrs = dis.readDicomObject();
+                        dos.writeDataset(attrs, tsuid);
+                    }
+                } finally {
+                    dis.close();
+                }
+            } else if (tsuid.equals(info.tsuid)) {
+                FileInputStream fis = new FileInputStream(info.f);
+                try {
+                    long skip = info.fmiEndPos;
+                    while (skip > 0)
+                        skip -= fis.skip(skip);
+                    out.copyFrom(fis);
+                } finally {
+                    fis.close();
+                }
+            } else if (tsuid.equals(DCM4CHEE_URI_REFERENCED_TS_UID)) {
+                DicomObject attrs;
+                DicomInputStream dis = new DicomInputStream(info.f);
+                try {
+                    dis.setHandler(new StopTagInputHandler(Tag.PixelData));
+                    attrs = dis.readDicomObject();
+                } finally {
+                    dis.close();
+                }
+                DicomOutputStream dos = new DicomOutputStream(out);
+                attrs.putString(Tag.RetrieveURI, VR.UT, info.f.toURI().toString());
+                dos.writeDataset(attrs, tsuid);
+             } else {
+                DicomInputStream dis = new DicomInputStream(info.f);
+                try {
+                    DicomOutputStream dos = new DicomOutputStream(out);
+                    dos.setTransferSyntax(tsuid);
+                    TranscoderInputHandler h = new TranscoderInputHandler(dos,
+                            transcoderBufferSize);
+                    dis.setHandler(h);
+                    dis.readDicomObject();
+                } finally {
+                    dis.close();
+                }
+            }
+        }
+
+    }
+
+    private void suffixUIDs(DicomObject attrs) {
+        if (suffixUID != null) {
+            int[] uidTags = { Tag.SOPInstanceUID,
+                    Tag.SeriesInstanceUID, Tag.StudyInstanceUID };
+            for (int i = 0; i < suffixUID.length; i++)
+                attrs.putString(uidTags[i], VR.UI,
+                        attrs.getString(uidTags[i]) + suffixUID[i]);
+        }
+    }
+
+    private void coerceAttrs(DicomObject attrs) {
+        if (coerceAttrs != null)
+            coerceAttrs.copyTo(attrs);
+    }
+
+    private void copyPixelData(DicomInputStream dis, DicomOutputStream dos,
+            PDVOutputStream out) throws IOException {
+        int vallen = dis.valueLength();
+        dos.writeHeader(dis.tag(), dis.vr(), vallen);
+        if (vallen == -1) {
+            int tag;
+            do {
+                tag = dis.readHeader();
+                vallen = dis.valueLength();
+                dos.writeHeader(tag, null, vallen);
+                out.copyFrom(dis, vallen);
+            } while (tag == Tag.Item);
+        } else {
+            out.copyFrom(dis, vallen);
+        }
+    }
+
+    private void promptErrRSP(String prefix, int status, FileInfo info,
+            DicomObject cmd) {
+        System.err.println(prefix + StringUtils.shortToHex(status) + "H for "
+                + info.f + ", cuid=" + info.cuid + ", tsuid=" + info.tsuid);
+        System.err.println(cmd.toString());
+    }
+
+    private void onDimseRSP(DicomObject cmd) {
+        int status = cmd.getInt(Tag.Status);
+        int msgId = cmd.getInt(Tag.MessageIDBeingRespondedTo);
+        FileInfo info = files.get(msgId - 1);
+        info.status = status;
+        switch (status) {
+        case 0:
+            info.transferred = true;
+            totalSize += info.length;
+            ++filesSent;
+            System.out.print('.');
+            break;
+        case 0xB000:
+        case 0xB006:
+        case 0xB007:
+            info.transferred = true;
+            totalSize += info.length;
+            ++filesSent;
+            promptErrRSP("WARNING: Received RSP with Status ", status, info,
+                    cmd);
+            System.out.print('W');
+            break;
+        default:
+            promptErrRSP("ERROR: Received RSP with Status ", status, info, cmd);
+            System.out.print('F');
+        }
+    }
+    
+    @Override
+    protected synchronized void onNEventReportRSP(Association as, int pcid,
+            DicomObject rq, DicomObject info, DicomObject rsp) {
+        stgCmtResult = info;
+        notifyAll();
+    }
+
+    public void initTLS() throws GeneralSecurityException, IOException {
+        KeyStore keyStore = loadKeyStore(keyStoreURL, keyStorePassword);
+        KeyStore trustStore = loadKeyStore(trustStoreURL, trustStorePassword);
+        device.initTLS(keyStore,
+                keyPassword != null ? keyPassword : keyStorePassword,
+                trustStore);
+    }
+    
+    private static KeyStore loadKeyStore(String url, char[] password)
+            throws GeneralSecurityException, IOException {
+        KeyStore key = KeyStore.getInstance(toKeyStoreType(url));
+        InputStream in = openFileOrURL(url);
+        try {
+            key.load(in, password);
+        } finally {
+            in.close();
+        }
+        return key;
+    }
+
+    private static InputStream openFileOrURL(String url) throws IOException {
+        if (url.startsWith("resource:")) {
+            return DcmSnd.class.getClassLoader().getResourceAsStream(
+                    url.substring(9));
+        }
+        try {
+            return new URL(url).openStream();
+        } catch (MalformedURLException e) {
+            return new FileInputStream(url);
+        }
+    }
+
+    private static String toKeyStoreType(String fname) {
+        return fname.endsWith(".p12") || fname.endsWith(".P12")
+                 ? "PKCS12" : "JKS";
+    }
+}
diff --git a/src/in/raster/mayam/util/core/MoveScu.java b/src/in/raster/mayam/util/core/MoveScu.java
new file mode 100644
index 0000000..676b3fc
--- /dev/null
+++ b/src/in/raster/mayam/util/core/MoveScu.java
@@ -0,0 +1,537 @@
+package in.raster.mayam.util.core;
+
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is part of dcm4che, an implementation of DICOM(TM) in
+ * Java(TM), hosted at http://sourceforge.net/projects/dcm4che.
+ *
+ * The Initial Developer of the Original Code is
+ * TIANI Medgraph AG.
+ * Portions created by the Initial Developer are Copyright (C) 2002-2005
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Gunter Zeilinger <gunter.zeilinger at tiani.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+import gnu.getopt.Getopt;
+import gnu.getopt.LongOpt;
+
+import in.raster.mayam.context.ApplicationContext;
+import java.io.IOException;
+import java.net.Socket;
+import java.security.GeneralSecurityException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import org.apache.log4j.Logger;
+import org.dcm4che.data.Command;
+import org.dcm4che.data.Dataset;
+import org.dcm4che.data.DcmObjectFactory;
+import org.dcm4che.dict.DictionaryFactory;
+import org.dcm4che.dict.Tags;
+import org.dcm4che.dict.UIDDictionary;
+import org.dcm4che.dict.UIDs;
+import org.dcm4che.net.AAssociateAC;
+import org.dcm4che.net.AAssociateRQ;
+import org.dcm4che.net.ActiveAssociation;
+import org.dcm4che.net.Association;
+import org.dcm4che.net.AssociationFactory;
+import org.dcm4che.net.Dimse;
+import org.dcm4che.net.ExtNegotiation;
+import org.dcm4che.net.FutureRSP;
+import org.dcm4che.net.PDU;
+import org.dcm4che.util.DcmURL;
+import org.dcm4che.util.SSLContextAdapter;
+
+/**
+ *
+ * @author  gunter.zeilinger at tiani.com
+ * @since      7 Nov 2004
+ * @version    $Revision: 1.3 $ $Date: 2005/10/05 16:26:14 $
+ */
+public class MoveScu {
+
+    // Constants -----------------------------------------------------
+
+    private static final byte[] RELATIONAL = new byte[] { 1};
+
+    private static final String[] DEF_TS = { UIDs.ImplicitVRLittleEndian};
+
+    private static final int PCID_ECHO = 1;
+
+    private static final int PCID_PR_MOVE = 3;
+
+    private static final int PCID_SR_MOVE = 5;
+
+    private static final int PCID_PSO_MOVE = 7;
+
+    private abstract class InfoModel {
+
+        final int pcid;
+
+        final String cuid;
+
+        InfoModel(int pcid, String cuid) {
+            this.pcid = pcid;
+            this.cuid = cuid;
+        }
+
+        abstract boolean applicable(Association as);
+        
+        boolean ajustKeysIfApplicable(Association as) {
+            if (!applicable(as)) return false;
+            adjustKeys();
+            return true;
+        }
+        
+        void adjustKeys() {};
+    }
+
+    private final InfoModel patientRoot = new InfoModel(PCID_PR_MOVE,
+            UIDs.PatientRootQueryRetrieveInformationModelMOVE) {
+
+        boolean applicable(Association as) {
+            if (as.getAcceptedTransferSyntaxUID(pcid) == null) return false;
+            if ("PATIENT".equals(level)) return true;
+            if (keys.contains(Tags.PatientID)) {
+                if ("STUDY".equals(level)) return true;
+                if (keys.contains(Tags.StudyInstanceUID)) {
+                    if ("SERIES".equals(level)) return true;
+                    if (keys.contains(Tags.SeriesInstanceUID)) return true;
+                }
+            }
+            ExtNegotiation extNeg = as.getAAssociateAC()
+                    .getExtNegotiation(cuid);
+            return extNeg != null && extNeg.info()[0] == 1;
+        }
+
+    };
+    
+    private final InfoModel studyRoot = new InfoModel(PCID_SR_MOVE,
+            UIDs.StudyRootQueryRetrieveInformationModelMOVE) {
+
+        boolean applicable(Association as) {
+            if ("PATIENT".equals(level)) return false;
+            if (as.getAcceptedTransferSyntaxUID(pcid) == null) return false;
+            if ("STUDY".equals(level)) return true;
+            if (keys.contains(Tags.StudyInstanceUID)) {
+                if ("SERIES".equals(level)) return true;
+                if (keys.contains(Tags.SeriesInstanceUID)) return true;
+            }
+            ExtNegotiation extNeg = as.getAAssociateAC()
+                    .getExtNegotiation(cuid);
+            return extNeg != null && extNeg.info()[0] == 1;
+        }
+
+        void adjustKeys() {
+            keys.remove(Tags.PatientID);
+            keys.remove(Tags.IssuerOfPatientID);
+            };
+    };
+    
+    private final InfoModel patientStudyOnly = new InfoModel(PCID_PSO_MOVE,
+            UIDs.PatientStudyOnlyQueryRetrieveInformationModelMOVE) {
+
+        boolean applicable(Association as) {
+            if ("SERIES".equals(level)) return false;
+            if ("IMAGE".equals(level)) return false;
+            if (as.getAcceptedTransferSyntaxUID(pcid) == null) return false;
+            if ("PATIENT".equals(level)) return true;
+            if (keys.contains(Tags.PatientID)) return true;
+            ExtNegotiation extNeg = as.getAAssociateAC()
+                    .getExtNegotiation(cuid);
+            return extNeg != null && extNeg.info()[0] == 1;
+        }
+
+    };
+
+    // Attributes ----------------------------------------------------
+    static final Logger log = Logger.getLogger("MoveScu");
+
+    private static ResourceBundle messages = ResourceBundle
+            .getBundle("MoveScu", Locale.getDefault());
+
+    private static final UIDDictionary uidDict = DictionaryFactory
+            .getInstance().getDefaultUIDDictionary();
+
+    private static final AssociationFactory aFact = AssociationFactory
+            .getInstance();
+
+    private static final DcmObjectFactory oFact = DcmObjectFactory
+            .getInstance();
+
+    private DcmURL url = null;
+
+    private int priority = Command.MEDIUM;
+
+    private int acTimeout = 5000;
+
+    private int dimseTimeout = 0;
+
+    private int soCloseDelay = 500;
+
+    private AAssociateRQ assocRQ = aFact.newAAssociateRQ();
+
+    private Dataset keys = oFact.newDataset();
+
+    private String dest;
+
+    private String level;
+
+    private boolean move = false;
+
+    private boolean packPDVs = false;
+
+    private String infoModel = "SR";
+
+    private SSLContextAdapter tls = null;
+
+    private String[] cipherSuites = null;
+
+    private ActiveAssociation activeAssociation = null;
+
+    // Static --------------------------------------------------------
+    private static final LongOpt[] LONG_OPTS = new LongOpt[] {
+            new LongOpt("pid", LongOpt.REQUIRED_ARGUMENT, null, 'd'),
+            new LongOpt("issuer", LongOpt.REQUIRED_ARGUMENT, null, 'I'),
+            new LongOpt("suid", LongOpt.REQUIRED_ARGUMENT, null, 's'),
+            new LongOpt("Suid", LongOpt.REQUIRED_ARGUMENT, null, 'S'),
+            new LongOpt("iuid", LongOpt.REQUIRED_ARGUMENT, null, 'i'),
+            new LongOpt("dest", LongOpt.REQUIRED_ARGUMENT, null, 2),
+            new LongOpt("info-model", LongOpt.REQUIRED_ARGUMENT, null, 2),
+            new LongOpt("ac-timeout", LongOpt.REQUIRED_ARGUMENT, null, 2),
+            new LongOpt("dimse-timeout", LongOpt.REQUIRED_ARGUMENT, null, 2),
+            new LongOpt("so-close-delay", LongOpt.REQUIRED_ARGUMENT, null, 2),
+            new LongOpt("prior-high", LongOpt.NO_ARGUMENT, null, 'P'),
+            new LongOpt("prior-low", LongOpt.NO_ARGUMENT, null, 'p'),
+            new LongOpt("relational", LongOpt.NO_ARGUMENT, null, 'R'),
+            new LongOpt("hierachical", LongOpt.NO_ARGUMENT, null, 'H'),
+            new LongOpt("max-pdu-len", LongOpt.REQUIRED_ARGUMENT, null, 2),
+            new LongOpt("max-op-invoked", LongOpt.REQUIRED_ARGUMENT, null, 2),
+            new LongOpt("pack-pdvs", LongOpt.NO_ARGUMENT, null, 'k'),
+            new LongOpt("tls-key", LongOpt.REQUIRED_ARGUMENT, null, 2),
+            new LongOpt("tls-key-passwd", LongOpt.REQUIRED_ARGUMENT, null, 2),
+            new LongOpt("tls-cacerts", LongOpt.REQUIRED_ARGUMENT, null, 2),
+            new LongOpt("tls-cacerts-passwd", LongOpt.REQUIRED_ARGUMENT, null,
+                    2), new LongOpt("ts", LongOpt.REQUIRED_ARGUMENT, null, 2),
+            new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h'),
+            new LongOpt("version", LongOpt.NO_ARGUMENT, null, 'v'),};
+
+    public static void main(String args[]) throws Exception {
+        Getopt g = new Getopt("movescu", args, "", LONG_OPTS);
+
+        Configuration cfg = new Configuration(MoveScu.class
+                .getResource("/resources/movescu.cfg"));
+        String pid = null;
+        String issuer = null;
+        ArrayList suids = new ArrayList();
+        ArrayList serUids = new ArrayList();
+        ArrayList iuids = new ArrayList();
+        int c;
+        while ((c = g.getopt()) != -1) {
+            switch (c) {
+            case 2:
+                cfg.put(LONG_OPTS[g.getLongind()].getName(), g.getOptarg());
+                break;
+            case 'P':
+                cfg.put("prior", "1");
+                break;
+            case 'p':
+                cfg.put("prior", "2");
+                break;
+            case 'R':
+                cfg.put("ext-neg", "true");
+                break;
+            case 'H':
+                cfg.put("ext-neg", "false");
+                break;
+            case 'k':
+                cfg.put("pack-pdvs", "true");
+                break;
+            case 'd':
+                pid = g.getOptarg();
+                break;
+            case 'I':
+                issuer = g.getOptarg();
+                break;
+            case 's':
+                suids.add(g.getOptarg());
+                break;
+            case 'S':
+                serUids.add(g.getOptarg());
+                break;
+            case 'i':
+                iuids.add(g.getOptarg());
+                break;
+            case 'v':
+                exit(messages.getString("version"), false);
+            case 'h':
+                exit(messages.getString("usage"), false);
+            case '?':
+                exit(null, true);
+                break;
+            }
+        }
+        int optind = g.getOptind();
+        int argc = args.length - optind;
+        if (argc == 0) {
+            exit(messages.getString("missing"), true);
+        }
+        try {
+            MoveScu movescu = new MoveScu(cfg, new DcmURL(args[optind]), pid,
+                    issuer, (String[]) suids.toArray(new String[suids.size()]),
+                    (String[]) serUids.toArray(new String[serUids.size()]),
+                    (String[]) iuids.toArray(new String[iuids.size()]));
+            movescu.execute();
+        } catch (IllegalArgumentException e) {
+            exit(e.getMessage(), true);
+        }
+    }
+
+    MoveScu(Configuration cfg, DcmURL url, String pid, String issuer,
+            String[] suids, String[] serUids, String[] iuids) {
+        this.url = url;
+        ApplicationContext.moveScuUrl=url;
+        this.priority = Integer.parseInt(cfg.getProperty("prior", "0"));
+        this.infoModel = cfg.getProperty("info-model", "StudyRoot");
+        initAssocParam(cfg, url);
+        initTLS(cfg);
+        this.dest = cfg.getProperty("dest");
+        this.move = dest != null
+                && initKeys(pid, issuer, suids, serUids, iuids);
+    }
+
+    private boolean initKeys(String pid, String issuer, String[] suids,
+            String[] serUids, String[] iuids) {
+        if (pid != null && pid.length() > 0) {
+            level = "PATIENT";
+            keys.putLO(Tags.PatientID, pid);
+            if (issuer != null && issuer.length() > 0)
+                    keys.putLO(Tags.IssuerOfPatientID, issuer);
+        }
+        if (suids.length > 0) {
+            level = "STUDY";
+            keys.putUI(Tags.StudyInstanceUID, suids);
+        }
+        if (serUids.length > 0) {
+            if (suids.length > 1)
+                    throw new IllegalArgumentException(messages
+                            .getString("erruids"));
+            level = "SERIES";
+            keys.putUI(Tags.SeriesInstanceUID, serUids);
+        }
+        if (iuids.length > 0) {
+            if (serUids.length > 1)
+                    throw new IllegalArgumentException(messages
+                            .getString("erruids"));
+            level = "IMAGE";
+            keys.putUI(Tags.SOPInstanceUID, iuids);
+        }
+        if (level == null) return false;
+        keys.putCS(Tags.QueryRetrieveLevel, level);
+        return true;
+    }
+
+    private void execute() throws Exception {
+        ActiveAssociation a = openAssoc();
+        if (a != null) {
+            try {
+                if (move)
+                    move(a);
+                else
+                    echo(a);
+            } finally {
+                a.release(true);
+            }
+        }
+    }
+
+    private void echo(ActiveAssociation a) throws Exception {
+        if (a.getAssociation().getAcceptedTransferSyntaxUID(PCID_ECHO) == null) {
+            log.error(messages.getString("noPCEcho"));
+        } else {
+            Command cmd = oFact.newCommand();
+            cmd.initCEchoRQ(1);
+            Dimse echoRQ = aFact.newDimse(PCID_ECHO, cmd);
+            a.invoke(echoRQ, null);
+        }
+    }
+
+    private void move(ActiveAssociation a) throws Exception {
+        Association as = a.getAssociation();
+        int pcid = selectInfoModel(as);
+        if (pcid > 0) {
+            Command cmd = oFact.newCommand();
+            String cuid = as.getProposedPresContext(pcid)
+                    .getAbstractSyntaxUID();
+            cmd.initCMoveRQ(1, cuid, priority, dest);
+            Dimse moveRQ = aFact.newDimse(pcid, cmd, keys);
+            FutureRSP rsp = a.invoke(moveRQ);
+            rsp.get();
+        } else {
+            log.error(messages.getString("noPCMove"));
+        }
+    }
+
+    private int selectInfoModel(Association as) {
+        if (infoModel.equals("PatientStudyOnly")) {
+            if (patientStudyOnly.applicable(as))
+                return patientStudyOnly.pcid;
+            if (patientRoot.ajustKeysIfApplicable(as))
+                return patientRoot.pcid;
+            if (studyRoot.ajustKeysIfApplicable(as))
+                return studyRoot.pcid;
+        } else if (infoModel.equals("PatientRoot")) {
+            if (patientRoot.ajustKeysIfApplicable(as))
+                return patientRoot.pcid;
+            if (studyRoot.ajustKeysIfApplicable(as))
+                return studyRoot.pcid;
+            if (patientStudyOnly.ajustKeysIfApplicable(as))
+                return patientStudyOnly.pcid;
+        } else {
+            if (studyRoot.ajustKeysIfApplicable(as))
+                return studyRoot.pcid;
+            if (patientRoot.ajustKeysIfApplicable(as))
+                return patientRoot.pcid;
+            if (patientStudyOnly.ajustKeysIfApplicable(as))
+                return patientStudyOnly.pcid;
+        }
+        return 0;
+    }
+
+    private ActiveAssociation openAssoc() throws IOException,
+            GeneralSecurityException {
+        Association assoc = aFact.newRequestor(newSocket(url.getHost(), url
+                .getPort()));
+        assoc.setAcTimeout(acTimeout);
+        assoc.setDimseTimeout(dimseTimeout);
+        assoc.setSoCloseDelay(soCloseDelay);
+        assoc.setPackPDVs(packPDVs);
+        PDU assocAC = assoc.connect(assocRQ);
+        if (!(assocAC instanceof AAssociateAC)) { return null; }
+        ActiveAssociation retval = aFact.newActiveAssociation(assoc, null);
+        retval.start();
+        return retval;
+    }
+
+    private Socket newSocket(String host, int port) throws IOException,
+            GeneralSecurityException {
+        if (cipherSuites != null) {
+            return tls.getSocketFactory(cipherSuites).createSocket(host, port);
+        } else {
+            return new Socket(host, port);
+        }
+    }
+
+    private static void exit(String prompt, boolean error) {
+        if (prompt != null) System.err.println(prompt);
+        if (error) System.err.println(messages.getString("try"));
+        System.exit(1);
+    }
+
+    public static String maskNull(String aet) {
+        return aet != null ? aet : "MAYAM";
+    }
+
+    private final void initAssocParam(Configuration cfg, DcmURL url) {
+          String[] s = ApplicationContext.databaseRef.getListenerDetails();
+        acTimeout = Integer.parseInt(cfg.getProperty("ac-timeout", "5000"));
+        dimseTimeout = Integer.parseInt(cfg.getProperty("dimse-timeout", "0"));
+        soCloseDelay = Integer.parseInt(cfg
+                .getProperty("so-close-delay", "500"));
+        assocRQ.setCalledAET(url.getCalledAET());
+        assocRQ.setCallingAET(maskNull(s[0]));
+        assocRQ.setMaxPDULength(Integer.parseInt(cfg.getProperty("max-pdu-len",
+                "16352")));
+        assocRQ.setAsyncOpsWindow(aFact.newAsyncOpsWindow(Integer.parseInt(cfg
+                .getProperty("max-op-invoked", "0")), 1));
+        packPDVs = "true".equalsIgnoreCase(cfg
+                .getProperty("pack-pdvs", "false"));
+        assocRQ.addPresContext(aFact.newPresContext(PCID_ECHO,
+                UIDs.Verification,
+                DEF_TS));
+        List tsNames = cfg.tokenize(cfg.getProperty("ts"), new LinkedList());
+        String[] tsUIDs = new String[tsNames.size()];
+        Iterator it = tsNames.iterator();
+        for (int i = 0; i < tsUIDs.length; ++i) {
+            tsUIDs[i] = UIDs.forName((String) it.next());
+        }
+        assocRQ.addPresContext(aFact.newPresContext(PCID_PR_MOVE,
+                UIDs.PatientRootQueryRetrieveInformationModelMOVE,
+                tsUIDs));
+        assocRQ.addPresContext(aFact.newPresContext(PCID_SR_MOVE,
+                UIDs.StudyRootQueryRetrieveInformationModelMOVE,
+                tsUIDs));
+        assocRQ.addPresContext(aFact.newPresContext(PCID_PSO_MOVE,
+                UIDs.PatientStudyOnlyQueryRetrieveInformationModelMOVE,
+                tsUIDs));
+        final boolean extNeg = "true".equalsIgnoreCase(cfg
+                .getProperty("ext-neg", "true"));
+        if (extNeg) {
+            assocRQ
+                    .addExtNegotiation(aFact
+                            .newExtNegotiation(UIDs.PatientRootQueryRetrieveInformationModelMOVE,
+                                    RELATIONAL));
+            assocRQ
+                    .addExtNegotiation(aFact
+                            .newExtNegotiation(UIDs.StudyRootQueryRetrieveInformationModelMOVE,
+                                    RELATIONAL));
+            assocRQ
+                    .addExtNegotiation(aFact
+                            .newExtNegotiation(UIDs.PatientStudyOnlyQueryRetrieveInformationModelMOVE,
+                                    RELATIONAL));
+        }
+    }
+
+    private void initTLS(Configuration cfg) {
+        try {
+            cipherSuites = url.getCipherSuites();
+            if (cipherSuites == null) { return; }
+            tls = SSLContextAdapter.getInstance();
+            char[] keypasswd = cfg.getProperty("tls-key-passwd", "secret")
+                    .toCharArray();
+            tls.setKey(tls.loadKeyStore(MoveScu.class.getResource(cfg
+                    .getProperty("tls-key", "identity.p12")), keypasswd),
+                    keypasswd);
+            tls
+                    .setTrust(tls.loadKeyStore(MoveScu.class.getResource(cfg
+                            .getProperty("tls-cacerts", "cacerts.jks")), cfg
+                            .getProperty("tls-cacerts-passwd", "secret")
+                            .toCharArray()));
+            tls.init();
+        } catch (Exception ex) {
+            throw new RuntimeException(
+                    "Could not initalize TLS configuration: ", ex);
+        }
+    }
+
+}
diff --git a/src/in/raster/mayam/util/core/MoveScu.properties b/src/in/raster/mayam/util/core/MoveScu.properties
new file mode 100644
index 0000000..37db8ca
--- /dev/null
+++ b/src/in/raster/mayam/util/core/MoveScu.properties
@@ -0,0 +1,10 @@
+usage=Usage\: java -jar movescu.jar [OPTIONS]... URL [MOVEPARAMS]\nInvoke DICOM Move Request on remote DICOM node specified by URL. If no\nMOVEPARAMS are specified the connection to the remote node will only be\nverified by DICOM Echo.\n\nURL\: PROTOCOL\://CALLED[\:CALLING]@HOST[\:PORT]\n  PROTOCOL   Specifies protocol. Possible values:\n    dicom            DICOM default (without TLS)\n    dicom-tls        DICOM on TLS (offer AES and DES encryption)\n    dicom-tls.aes    DICOM on TLS (f [...]
+version=movescu version @VERSION@ compiled on @TODAY@
+missing=missing DICOM URL
+errnum={0} - not a number
+errurl={0} - invalid DICOM URL
+erruids=list of uids not allowed for keys above retrieve level
+noPCEcho=Verification Service not supported by remote DICOM node
+noPCMove=No appropriate Move Service negotiated with remote DICOM node
+try=Try 'java -jar movescu.jar --help' for more information.
+
diff --git a/src/in/raster/mayam/util/core/PixelDataParam.java b/src/in/raster/mayam/util/core/PixelDataParam.java
new file mode 100644
index 0000000..1179809
--- /dev/null
+++ b/src/in/raster/mayam/util/core/PixelDataParam.java
@@ -0,0 +1,213 @@
+package in.raster.mayam.util.core;
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is part of dcm4che, an implementation of DICOM(TM) in
+ * Java(TM), hosted at http://sourceforge.net/projects/dcm4che.
+ *
+ * The Initial Developer of the Original Code is
+ * Gunter Zeilinger, Huetteldorferstr. 24/10, 1150 Vienna/Austria/Europe.
+ * Portions created by the Initial Developer are Copyright (C) 2002-2005
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Gunter Zeilinger <gunterze at gmail.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+import java.awt.Dimension;
+import java.awt.color.ColorSpace;
+import java.awt.image.BandedSampleModel;
+import java.awt.image.BufferedImage;
+import java.awt.image.ColorModel;
+import java.awt.image.ComponentColorModel;
+import java.awt.image.DataBuffer;
+import java.awt.image.PixelInterleavedSampleModel;
+import java.awt.image.Raster;
+import java.awt.image.SampleModel;
+import java.awt.image.WritableRaster;
+import java.util.Arrays;
+
+import org.dcm4che.data.Dataset;
+import org.dcm4che.dict.Tags;
+
+/**
+ * @author Gunter.Zeilinger at tiani.com
+ * @version $Revision: 1.1 $
+ * @since 29.10.2003
+ */
+class PixelDataParam {
+
+    private static final int[] GRAY_BAND_OFFSETS = { 0};
+
+    private static final int[] RGB_BAND_OFFSETS = { 0, 1, 2};
+
+    private final String pmi;
+
+    private final int samplesPerPixel;
+
+    private final int columns;
+
+    private final int rows;
+
+    private final int bitsAllocated;
+
+    private final int bitsStored;
+
+    private final int pixelRepresentation;
+
+    private final int planarConfiguration;
+
+    private final int numberOfFrames;
+
+    private final int frameLength;
+
+    private final int dataType;
+
+    public PixelDataParam(Dataset ds, boolean typeShortSupported) {
+        pmi = ds.getString(Tags.PhotometricInterpretation, "MONOCHROME2");
+        samplesPerPixel = ds.getInt(Tags.SamplesPerPixel, 1);
+        columns = ds.getInt(Tags.Columns, -1);
+        rows = ds.getInt(Tags.Rows, -1);
+        numberOfFrames = ds.getInt(Tags.NumberOfFrames, 1);
+        pixelRepresentation = ds.getInt(Tags.PixelRepresentation, 0);
+        planarConfiguration = ds.getInt(Tags.PlanarConfiguration, 0);
+
+        switch (bitsAllocated = ds.getInt(Tags.BitsAllocated, 8)) {
+        case 8:
+            dataType = DataBuffer.TYPE_BYTE;
+            frameLength = rows * columns * samplesPerPixel;
+            break;
+        case 16:
+            dataType = pixelRepresentation != 0 && typeShortSupported ? DataBuffer.TYPE_SHORT
+                    : DataBuffer.TYPE_USHORT;
+            frameLength = rows * columns * samplesPerPixel * 2;
+            break;
+        default:
+            throw new IllegalArgumentException("bits allocated:"
+                    + bitsAllocated);
+        }
+        bitsStored = ds.getInt(Tags.BitsStored, bitsAllocated);
+    }
+
+    public final int getBitsAllocated() {
+        return bitsAllocated;
+    }
+
+    public final int getBitsStored() {
+        return bitsStored;
+    }
+
+    public final int getColumns() {
+        return columns;
+    }
+
+    public final int getPixelRepresentation() {
+        return pixelRepresentation;
+    }
+
+    public final int getPlanarConfiguration() {
+        return planarConfiguration;
+    }
+
+    public final String getPhotoMetricInterpretation() {
+        return pmi;
+    }
+
+    public final int getRows() {
+        return rows;
+    }
+
+    public final int getSamplesPerPixel() {
+        return samplesPerPixel;
+    }
+
+    public final int getNumberOfFrames() {
+        return numberOfFrames;
+    }
+
+    public final int getFrameLength() {
+        return frameLength;
+    }
+
+    public int getPixelDataLength() {
+        return frameLength * numberOfFrames;
+    }
+
+    public final Dimension[] createImageDimensionArray() {
+        Dimension[] a = new Dimension[numberOfFrames];
+        Arrays.fill(a, new Dimension(columns, rows));
+        return a;
+    }
+
+    private static int[] createOffsetArray(int numBands) {
+        int[] bandOffsets = new int[numBands];
+        for (int i = 0; i < numBands; i++) {
+            bandOffsets[i] = i;
+        }
+        return bandOffsets;
+    }
+
+    private SampleModel getSampleModel() {
+        if (planarConfiguration == 0) {
+            return new PixelInterleavedSampleModel(dataType, columns, rows,
+                    samplesPerPixel, columns * samplesPerPixel,
+                    samplesPerPixel == 1 ? GRAY_BAND_OFFSETS : RGB_BAND_OFFSETS);
+        } else {
+            return new BandedSampleModel(dataType, columns, rows,
+                    samplesPerPixel);
+        }
+    }
+
+    private ColorModel getColorModel(int bits) {
+        if (samplesPerPixel == 3) {
+            return new ComponentColorModel(ColorSpace
+                    .getInstance(ColorSpace.CS_sRGB), new int[] { bits, bits,
+                    bits}, false, false, ColorModel.OPAQUE, dataType);
+        } else {
+            return new ComponentColorModel(ColorSpace
+                    .getInstance(ColorSpace.CS_GRAY), new int[] { bitsStored},
+                    false, false, ColorModel.OPAQUE, dataType);
+        }
+    }
+
+    public WritableRaster createRaster() {
+        return Raster.createWritableRaster(getSampleModel(), null);
+    }
+
+    public BufferedImage createBufferedImage(int maxBits) {
+        return new BufferedImage(getColorModel(Math.min(maxBits, bitsStored)),
+                createRaster(), false, null);
+    }
+
+    public String toString() {
+        return "PixelData[pmi=" + pmi + ", samples=" + samplesPerPixel
+                + ", rows=" + rows + ", columns=" + columns + ", alloc="
+                + bitsAllocated + ", bits=" + bitsStored + ", signed="
+                + pixelRepresentation + ", planar=" + planarConfiguration
+                + ", frames=" + numberOfFrames;
+    }
+
+}
diff --git a/src/in/raster/mayam/util/core/SendStgCmtResult.java b/src/in/raster/mayam/util/core/SendStgCmtResult.java
new file mode 100644
index 0000000..8b470f2
--- /dev/null
+++ b/src/in/raster/mayam/util/core/SendStgCmtResult.java
@@ -0,0 +1,81 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is part of dcm4che, an implementation of DICOM(TM) in
+ * Java(TM), hosted at http://sourceforge.net/projects/dcm4che.
+ *
+ * The Initial Developer of the Original Code is
+ * Agfa HealthCare.
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * See listed authors below.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+package in.raster.mayam.util.core;
+
+import java.util.TimerTask;
+
+import org.dcm4che2.data.DicomObject;
+import org.dcm4che2.net.NetworkApplicationEntity;
+
+/**
+ * @author Gunter Zeilinger <gunterze at gmail.com>
+ * @version $Rev$ $Date:: 0000-00-00 $
+ * @since Mar 22, 2010
+ */
+class SendStgCmtResult extends TimerTask {
+
+    private final DcmRcv dcmrcv;
+    private final NetworkApplicationEntity stgcmtAE;
+    private final DicomObject result;
+    private int failureCount;
+
+    public SendStgCmtResult(DcmRcv dcmrcv, NetworkApplicationEntity stgcmtAE,
+            DicomObject result) {
+        this.dcmrcv = dcmrcv;
+        this.stgcmtAE = stgcmtAE;
+        this.result = result;
+    }
+
+    @Override
+    public void run() {
+        try {
+            dcmrcv.sendStgCmtResult(stgcmtAE, result);
+        } catch (Exception e) {
+            DcmRcv.LOG.warn("Send Storage Commitment Result to "
+                    + stgcmtAE.getAETitle() + " failed:", e);
+            if (failureCount++ < dcmrcv.getStgCmtRetry()) {
+                DcmRcv.LOG.info("Schedule retry in "
+                        + (dcmrcv.getStgCmtRetryPeriod()/1000) + "s.");
+               return;
+            }
+        }
+        this.cancel();
+    }
+
+}
diff --git a/src/in/raster/mayam/util/core/StgCmtSCP.java b/src/in/raster/mayam/util/core/StgCmtSCP.java
new file mode 100644
index 0000000..814431b
--- /dev/null
+++ b/src/in/raster/mayam/util/core/StgCmtSCP.java
@@ -0,0 +1,72 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is part of dcm4che, an implementation of DICOM(TM) in
+ * Java(TM), hosted at http://sourceforge.net/projects/dcm4che.
+ *
+ * The Initial Developer of the Original Code is
+ * Agfa HealthCare.
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * See listed authors below.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+package in.raster.mayam.util.core;
+
+import java.io.IOException;
+
+import org.dcm4che2.data.DicomObject;
+import org.dcm4che2.data.UID;
+import org.dcm4che2.net.Association;
+import org.dcm4che2.net.CommandUtils;
+import org.dcm4che2.net.service.DicomService;
+import org.dcm4che2.net.service.NActionSCP;
+
+/**
+ * @author Gunter Zeilinger <gunterze at gmail.com>
+ * @version $Rev$ $Date:: 0000-00-00 $
+ * @since Mar 22, 2010
+ */
+class StgCmtSCP extends DicomService implements NActionSCP {
+
+    private final DcmRcv dcmrcv;
+
+    public StgCmtSCP(DcmRcv dcmrcv) {
+        super(UID.StorageCommitmentPushModelSOPClass);
+        this.dcmrcv = dcmrcv;
+    }
+
+    @Override
+    public void naction(Association as, int pcid, DicomObject rq,
+            DicomObject info) throws IOException {
+        DicomObject rsp = CommandUtils.mkRSP(rq, CommandUtils.SUCCESS);
+        dcmrcv.onNActionRQ(as, rq, info);
+        as.writeDimseRSP(pcid, rsp);
+    }
+
+}
diff --git a/src/in/raster/mayam/util/core/StorageSCP.java b/src/in/raster/mayam/util/core/StorageSCP.java
new file mode 100644
index 0000000..f021e6a
--- /dev/null
+++ b/src/in/raster/mayam/util/core/StorageSCP.java
@@ -0,0 +1,101 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is part of dcm4che, an implementation of DICOM(TM) in
+ * Java(TM), hosted at http://sourceforge.net/projects/dcm4che.
+ *
+ * The Initial Developer of the Original Code is
+ * Agfa HealthCare.
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * See listed authors below.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+package in.raster.mayam.util.core;
+
+import java.io.IOException;
+
+import org.dcm4che2.data.DicomObject;
+import org.dcm4che2.net.Association;
+import org.dcm4che2.net.CommandUtils;
+import org.dcm4che2.net.DicomServiceException;
+import org.dcm4che2.net.PDVInputStream;
+import org.dcm4che2.net.service.StorageService;
+
+/**
+ * @author Gunter Zeilinger <gunterze at gmail.com>
+ * @version $Rev$ $Date:: 0000-00-00 $
+ * @since Mar 22, 2010
+ */
+class StorageSCP extends StorageService {
+
+    private final DcmRcv dcmrcv;
+
+    public StorageSCP(DcmRcv dcmrcv, String[] sopClasses) {
+        super(sopClasses);
+        this.dcmrcv = dcmrcv;
+    }
+
+    /** Overwrite {@link StorageService#cstore} to send delayed C-STORE RSP 
+     * by separate Thread, so reading of following received C-STORE RQs from
+     * the open association is not blocked.
+     */
+    @Override
+    public void cstore(final Association as, final int pcid, DicomObject rq,
+            PDVInputStream dataStream, String tsuid)
+            throws DicomServiceException, IOException {
+        final DicomObject rsp = CommandUtils.mkRSP(rq, CommandUtils.SUCCESS);
+        onCStoreRQ(as, pcid, rq, dataStream, tsuid, rsp);
+        if (dcmrcv.getDimseRspDelay() > 0) {
+            dcmrcv.executor().execute(new Runnable() {
+                public void run() {
+                    try {
+                        Thread.sleep(dcmrcv.getDimseRspDelay());
+                        as.writeDimseRSP(pcid, rsp);
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
+                }
+            });
+        } else {
+            as.writeDimseRSP(pcid, rsp);
+        }
+        onCStoreRSP(as, pcid, rq, dataStream, tsuid, rsp);
+    }
+
+    @Override
+    protected void onCStoreRQ(Association as, int pcid, DicomObject rq,
+            PDVInputStream dataStream, String tsuid, DicomObject rsp)
+            throws IOException, DicomServiceException {
+        if (dcmrcv.isStoreFile())
+            dcmrcv.onCStoreRQ(as, pcid, rq, dataStream, tsuid, rsp);
+        else
+            super.onCStoreRQ(as, pcid, rq, dataStream, tsuid, rsp);
+    }
+
+}
diff --git a/src/in/raster/mayam/util/core/Transcoder.java b/src/in/raster/mayam/util/core/Transcoder.java
new file mode 100644
index 0000000..784fb89
--- /dev/null
+++ b/src/in/raster/mayam/util/core/Transcoder.java
@@ -0,0 +1,730 @@
+package in.raster.mayam.util.core;
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is part of dcm4che, an implementation of DICOM(TM) in
+ * Java(TM), hosted at http://sourceforge.net/projects/dcm4che.
+ *
+ * The Initial Developer of the Original Code is
+ * Agfa HealthCare.
+ * Portions created by the Initial Developer are Copyright (C) 2002-2006
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * See listed authors below.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+import java.awt.Point;
+import java.awt.Transparency;
+import java.awt.color.ColorSpace;
+import java.awt.image.BufferedImage;
+import java.awt.image.ColorModel;
+import java.awt.image.ComponentColorModel;
+import java.awt.image.ComponentSampleModel;
+import java.awt.image.DataBuffer;
+import java.awt.image.DataBufferByte;
+import java.awt.image.DataBufferShort;
+import java.awt.image.DataBufferUShort;
+import java.awt.image.PixelInterleavedSampleModel;
+import java.awt.image.Raster;
+import java.awt.image.SampleModel;
+import java.awt.image.WritableRaster;
+import java.io.EOFException;
+import java.io.File;
+import java.io.IOException;
+import java.nio.ByteOrder;
+import java.util.Hashtable;
+
+import javax.imageio.IIOImage;
+import javax.imageio.ImageIO;
+import javax.imageio.ImageReadParam;
+import javax.imageio.ImageReader;
+import javax.imageio.ImageWriteParam;
+import javax.imageio.ImageWriter;
+import javax.imageio.stream.ImageInputStream;
+import javax.imageio.stream.ImageOutputStream;
+
+import org.apache.log4j.Logger;
+import org.dcm4che.data.Dataset;
+import org.dcm4che.data.DcmDecodeParam;
+import org.dcm4che.data.DcmElement;
+import org.dcm4che.data.DcmEncodeParam;
+import org.dcm4che.data.DcmObjectFactory;
+import org.dcm4che.data.DcmParser;
+import org.dcm4che.data.DcmParserFactory;
+import org.dcm4che.data.DcmValueException;
+import org.dcm4che.data.FileMetaInfo;
+import org.dcm4che.dict.Tags;
+import org.dcm4che.dict.UIDs;
+import org.dcm4che.dict.VRs;
+import org.dcm4che.util.UIDGenerator;
+import org.dcm4cheri.image.ImageReaderFactory;
+import org.dcm4cheri.image.ImageWriterFactory;
+import org.dcm4cheri.image.ItemParser;
+
+import com.sun.media.imageio.plugins.jpeg2000.J2KImageWriteParam;
+import com.sun.media.imageio.stream.SegmentedImageInputStream;
+/**
+ * @author Gunter.Zeilinger at tiani.com
+ * @version $Revision: 1.5 $ $Date: 2006/10/20 21:41:51 $
+ * @since 30.10.2003
+ */
+public class Transcoder {
+
+    private static final String RGB = "RGB";
+    private static final String YBR_FULL_422 = "YBR_FULL_422";
+    private static final String YBR_RCT = "YBR_RCT";
+    private static final String YBR_ICT = "YBR_ICT";
+
+    private static Logger log = Logger.getLogger(Transcoder.class.getName());
+   
+    private static DcmParserFactory parserFactory = 
+            DcmParserFactory.getInstance();
+    
+    private static DcmObjectFactory objectFactory =
+            DcmObjectFactory.getInstance();
+
+    protected static UIDGenerator uidGen = UIDGenerator.getInstance();
+
+    private float compressionQuality = 0.75f;
+    private double encodingRate = 1.;
+    private ImageInputStream iis;
+    private ImageOutputStream ios;
+    private String encodeTS = UIDs.ExplicitVRLittleEndian;
+    private DcmEncodeParam encodeParam = DcmDecodeParam.EVR_LE;
+    private DcmParser parser;
+    private DcmDecodeParam decodeParam;
+    private PixelDataParam pixelDataParam;
+    private ImageReader reader;
+    private ImageWriter writer;
+    private Dataset dsIn = objectFactory.newDataset();
+    private Dataset dsOut = objectFactory.newDataset();
+    private BufferedImage bi;
+    private int frameIndex = 0;
+    private boolean truncatePostPixelData = false;
+    private ItemParser itemParser;
+    private SegmentedImageInputStream siis;
+
+    /**
+     * if true, input stream is directly copied into output stream without pixel
+     * decoding. Makes sense if output ts == input ts. cleared by readHeader if
+     * no ts match.
+     */
+    private boolean directCopy = true;
+    private boolean ignoreMissingPixelData;
+
+    /**
+     * if true, input stream is directly copied into output stream without pixel
+     * decoding. Makes sense if output ts == input ts
+     */
+    public void setDirectCopy(boolean cp) {
+        directCopy = cp;
+    }
+
+    /**
+     * if true, input stream is directly copied into output stream without pixel
+     * decoding. Makes sense if output ts == input ts
+     */
+    public boolean doDirectCopy() {
+        return directCopy;
+    }
+
+    public void setInput(ImageInputStream iis) {
+        this.iis = iis;
+        this.bi = null;
+    }
+
+    public void setOutput(ImageOutputStream ios) {
+        this.ios = ios;
+    }
+
+    public void setTransferSyntax(String transferSyntax) {
+        this.encodeParam = DcmEncodeParam.valueOf(transferSyntax);
+        this.encodeTS = transferSyntax;
+    }
+
+    public final float getCompressionQuality() {
+        return compressionQuality;
+    }
+
+    public final void setCompressionQuality(float quality) {
+        this.compressionQuality = quality;
+    }
+
+    public final double getEncodingRate() {
+        return encodingRate;
+    }
+
+    public final void setEncodingRate(double rate) {
+        this.encodingRate = rate;
+    }
+
+    public void setTruncatePostPixelData(boolean truncate) {
+        this.truncatePostPixelData = truncate;
+
+    }
+
+    public boolean isTruncatePostPixelData() {
+        return this.truncatePostPixelData;
+    }
+
+    public Dataset getDataset() {
+        return dsIn;
+    }
+
+    public void transcode(File infile, File outfile) throws IOException {
+        outfile.delete();
+        ImageInputStream iis = null;
+        ImageOutputStream ios = null;
+        try {
+            setInput(iis = ImageIO.createImageInputStream(infile));
+            setOutput(ios = ImageIO.createImageOutputStream(outfile));
+            transcode();
+        } finally {
+            if (iis != null) {
+                try {
+                    iis.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            if (ios != null) {
+                try {
+                    ios.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+
+    public void transcode() throws IOException {
+        if (iis == null) {
+            throw new IllegalStateException("no input set");
+        }
+        if (ios == null) {
+            throw new IllegalStateException("no output set");
+        }
+        // direct copy only if no truncation
+        setDirectCopy(doDirectCopy() && !truncatePostPixelData);
+        // parse & copy header. may clear doDirectCopy if input ts != output ts
+        transcodeHeader();
+        if (doDirectCopy()) // just copy without recoding
+        {
+            copyPixelData();
+        } else {
+            transcodePixelHeader();// copy intro of PixelData
+            for (int i = 0, n = pixelDataParam.getNumberOfFrames(); i < n; i++) {
+                transcodeNextFrame(); // recode frames
+            }
+            transcodePixelFooter();// finish up PixelData tag
+        }
+        transcodeFooter();// copy all the stuff after pixel data
+    }
+
+    private void transcodePixelFooter() throws IOException {
+        if (itemParser != null) {
+            itemParser.seekFooter();
+        }
+        if (encodeParam.encapsulated) {
+            dsIn.writeHeader(ios, encodeParam, Tags.SeqDelimitationItem,
+                    VRs.NONE, 0);
+        }
+    }
+
+    private void transcodePixelHeader() throws IOException {
+        readPixelHeader();
+        writePixelHeader();
+    }
+
+    private void writePixelHeader() throws IOException {
+        if (encodeParam.encapsulated) {
+            dsIn.writeHeader(ios, encodeParam, Tags.PixelData, VRs.OB, -1);
+            dsIn.writeHeader(ios, encodeParam, Tags.Item, VRs.NONE, 0);
+            ImageWriterFactory f = ImageWriterFactory.getInstance();
+            writer = f.getWriterForTransferSyntax(encodeTS);
+        } else {
+            dsIn.writeHeader(ios, encodeParam, Tags.PixelData, VRs.OW,
+                    pixelDataParam.getPixelDataLength());
+        }
+        log.debug("wrote header");
+    }
+
+    private void readPixelHeader() throws IOException {
+        iis.setByteOrder(decodeParam.byteOrder);
+        if (decodeParam.encapsulated) {
+            itemParser = new ItemParser(parser);
+            siis = new SegmentedImageInputStream(iis, itemParser);
+            ImageReaderFactory f = ImageReaderFactory.getInstance();
+            reader = f.getReaderForTransferSyntax(dsIn.getFileMetaInfo()
+                    .getTransferSyntaxUID());
+            bi = (BufferedImage) createBufferedImage();
+        } else {
+            bi = pixelDataParam.createBufferedImage(getMaxBits());
+        }
+        if (log.isDebugEnabled()) {
+            log.debug("read header: " + pixelDataParam);
+        }
+    }
+
+    /**
+     * copy pixel tag without de/encoding
+     */
+    private void copyPixelData() throws IOException {
+        if (parser.hasSeenEOF())
+            return;
+        int len = parser.getReadLength();
+        dsIn.writeHeader(ios, encodeParam, parser.getReadTag(), parser
+                .getReadVR(), len);
+        if (len == -1) {
+            parser.parseHeader();
+            while (parser.getReadTag() == Tags.Item) {
+                len = parser.getReadLength();
+                dsIn.writeHeader(ios, encodeParam, Tags.Item, VRs.NONE, len);
+                copy(iis, ios, len);
+                parser.parseHeader();
+            }
+            dsIn.writeHeader(ios, encodeParam, Tags.SeqDelimitationItem,
+                    VRs.NONE, 0);
+        } else {
+            copy(iis, ios, len);
+        }
+    }
+
+    private void copy(ImageInputStream in, ImageOutputStream out, int totLen)
+            throws IOException {
+        int toRead = totLen == -1 ? Integer.MAX_VALUE : totLen;
+        int bufferSize = 8192;
+        byte[] buffer = new byte[bufferSize];
+        for (int len; toRead > 0; toRead -= len) {
+            len = in.read(buffer, 0, Math.min(toRead, buffer.length));
+            if (len == -1) {
+                if (totLen == -1) {
+                    return;
+                }
+                throw new EOFException();
+            }
+            out.write(buffer, 0, len);
+        }
+    }
+
+    public void transcodeHeader() throws IOException {
+        readHeader();
+        writeHeader();
+    }
+
+    public void readHeader() throws IOException {
+        log.debug("reading header");
+        parser = parserFactory.newDcmParser(iis);
+        frameIndex = 0;
+        dsIn.clear();
+        parser.setDcmHandler(dsIn.getDcmHandler());
+        parser.parseDcmFile(null, Tags.PixelData);
+        if (parser.getReadTag() != Tags.PixelData) {
+            if (ignoreMissingPixelData) {
+                setDirectCopy(true);
+            } else {
+                throw new IOException("no pixel data in source object");
+            }
+        }
+        decodeParam = parser.getDcmDecodeParam();
+
+        dsOut.clear();
+        dsOut.putAll(dsIn); // copy object, as some tags are modified by coerce
+
+        onHeaderParsed(dsOut);
+        if (doDirectCopy()) {
+            FileMetaInfo fmi = dsIn.getFileMetaInfo();
+            if (fmi != null) {
+                setDirectCopy(encodeTS.equals(fmi.getTransferSyntaxUID()));
+            } else {
+                setDirectCopy(decodeParam.byteOrder == ByteOrder.LITTLE_ENDIAN 
+                        && encodeTS.equals(UIDs.ExplicitVRLittleEndian));                
+            }
+        }
+        pixelDataParam = new PixelDataParam(dsIn, isTypeShortSupported());
+
+    }
+
+    private int getMaxBits() {
+        if (encodeTS.equals(UIDs.JPEGBaseline))
+            return 8;
+        if (encodeTS.equals(UIDs.JPEGExtended))
+            return 12;
+        return 16;
+    }
+
+    private boolean isTypeShortSupported() {
+        return !(encodeTS.equals(UIDs.JPEGBaseline)
+                || encodeTS.equals(UIDs.JPEGExtended)
+                || encodeTS.equals(UIDs.JPEGLossless)
+                || encodeTS.equals(UIDs.JPEGLossless14)
+                || encodeTS.equals(UIDs.JPEGLSLossless) || encodeTS
+                .equals(UIDs.JPEGLSLossy));
+    }
+
+    public void writeHeader() throws IOException {
+        log.debug("writing header");
+        coerceTS();
+        ios.setByteOrder(encodeParam.byteOrder);
+        if (!doDirectCopy())
+            coerceDataset(dsOut);
+        dsOut.writeFile(ios, encodeParam);
+    }
+
+    private void coerceTS() {
+        if (encodeTS.equals(UIDs.JPEGBaseline)) {
+            if (pixelDataParam.getBitsStored() > 8) {
+                encodeTS = UIDs.JPEGExtended;
+            }
+        } else if (encodeTS.equals(UIDs.JPEGExtended)) {
+            if (pixelDataParam.getBitsStored() <= 8) {
+                encodeTS = UIDs.JPEGBaseline;
+            }
+        }
+    }
+
+    public void coerceDataset(Dataset dsOut) throws DcmValueException {
+        final int samplesPerPixel = getSamplesPerPixel();
+        dsOut.putUS(Tags.SamplesPerPixel, samplesPerPixel);
+        dsOut.putCS(Tags.PhotometricInterpretation,
+                getPhotometricInterpretation());
+        if (samplesPerPixel > 1) {
+            dsOut.putUS(Tags.PlanarConfiguration, getPlanarConfiguration());
+        }
+        if (!isCompressionLossless()) {
+            dsOut.putCS(Tags.LossyImageCompression, "01");
+            String[] imageTypes = dsOut.getStrings(Tags.ImageType);
+            if (imageTypes == null || imageTypes.length == 0) {
+                imageTypes = new String[1];
+            }
+            if (!"DERIVED".equals(imageTypes)) {
+                imageTypes[0] = "DERIVED";
+                dsOut.putCS(Tags.ImageType, imageTypes);
+            }
+            dsOut.putCS(Tags.LossyImageCompression, "01");
+            if (encodeTS.equals(UIDs.JPEG2000Lossy)) {
+                float[] oldVal = dsOut
+                        .getFloats(Tags.LossyImageCompressionRatio);
+                if (oldVal == null) {
+                    oldVal = new float[0];
+                }
+                float[] newVal = new float[oldVal.length + 1];
+                System.arraycopy(oldVal, 0, newVal, 0, oldVal.length);
+                newVal[oldVal.length] = (float) (pixelDataParam
+                        .getBitsAllocated() / getEncodingRate());
+                dsOut.putDS(Tags.LossyImageCompressionRatio, newVal);
+                dsOut.putST(Tags.DerivationDescription,
+                                "JPKI lossy compressed "
+                                        + newVal[oldVal.length] + ":1");
+            } else {
+                dsOut.putST(Tags.DerivationDescription,
+                                "JPEG lossy compressed");
+            }
+            DcmElement sq = dsOut.putSQ(Tags.SourceImageSeq);
+            Dataset item = sq.addNewItem();
+            item.putUI(Tags.RefSOPInstanceUID, dsOut
+                    .getString(Tags.SOPInstanceUID));
+            item.putUI(Tags.RefSOPClassUID, dsOut.getString(Tags.SOPClassUID));
+            dsOut.putUI(Tags.SOPInstanceUID, uidGen.createUID());
+        }
+        dsOut.setFileMetaInfo(objectFactory.newFileMetaInfo(dsOut, encodeTS));
+    }
+
+    int getPlanarConfiguration() {
+        if (encodeParam.encapsulated) {
+            return 0;
+        }
+        return pixelDataParam.getPlanarConfiguration();
+    }
+
+    private String getPhotometricInterpretation() {
+        if (getSamplesPerPixel() == 1) {
+            return pixelDataParam.getPhotoMetricInterpretation();
+        }
+        if (encodeParam.encapsulated) {
+            if (encodeTS.equals(UIDs.JPEGBaseline)
+                    || encodeTS.equals(UIDs.JPEGExtended)) {
+                return YBR_FULL_422;
+            }
+            if (encodeTS.equals(UIDs.JPEG2000Lossless)) {
+                return YBR_RCT;
+            }
+            if (encodeTS.equals(UIDs.JPEG2000Lossy)) {
+                return YBR_ICT;
+            }
+        }
+        return RGB;
+    }
+
+    private int getSamplesPerPixel() {
+        return pixelDataParam.getSamplesPerPixel();
+    }
+
+    public boolean hasMoreFrames() {
+        if (pixelDataParam == null) {
+            throw new IllegalStateException();
+        }
+        return frameIndex < pixelDataParam.getNumberOfFrames();
+    }
+
+    public void transcodeNextFrame() throws IOException {
+        readNextFrame();
+        BufferedImage outBi = onFrameDecoded(bi);
+        writeNextFrame(outBi);
+    }
+
+    public void readNextFrame() throws IOException {
+        log.debug("reading frame #" + (frameIndex + 1));
+        if (decodeParam.encapsulated) {
+            reader.setInput(siis);
+            ImageReadParam param = reader.getDefaultReadParam();
+            if (bi != null)
+                param.setDestination(bi);
+            bi = reader.read(0, param);
+            itemParser.seekNextFrame(siis);
+        } else {
+            DataBuffer db = bi.getRaster().getDataBuffer();
+            switch (db.getDataType()) {
+            case DataBuffer.TYPE_BYTE:
+                read(((DataBufferByte) db).getBankData());
+                break;
+            case DataBuffer.TYPE_SHORT:
+                read(((DataBufferShort) db).getBankData());
+                break;
+            case DataBuffer.TYPE_USHORT:
+                read(((DataBufferUShort) db).getBankData());
+                break;
+            default:
+                throw new RuntimeException("dataType:" + db.getDataType());
+            }
+            iis.flushBefore(iis.getStreamPosition());
+        }
+        if (log.isDebugEnabled()) {
+            ColorModel cm = bi.getColorModel();
+            ColorSpace cs = cm.getColorSpace();
+            SampleModel sm = bi.getSampleModel();
+            Raster raster = bi.getData();
+            DataBuffer db = raster.getDataBuffer();
+            log.debug("read frame #" + (frameIndex + 1) + "[bitype="
+                    + bi.getType() + ", h=" + bi.getHeight() + ", w="
+                    + bi.getWidth() + ", sm=" + classNameOf(sm) + ", bands="
+                    + sm.getNumBands() + ", db=" + classNameOf(db) + ", banks="
+                    + db.getNumBanks() + ", bits=" + cm.getPixelSize()
+                    + ", cstype=" + cs.getType() + "]");
+        }
+        ++frameIndex;
+    }
+
+    private static String classNameOf(Object o) {
+        String s = o.getClass().getName();
+        return s.substring(s.lastIndexOf('.') + 1);
+    }
+
+    private void read(byte[][] data) throws IOException {
+        for (int i = 0; i < data.length; i++) {
+            iis.readFully(data[i], 0, data[i].length);
+        }
+    }
+
+    private void read(short[][] data) throws IOException {
+        for (int i = 0; i < data.length; i++) {
+            iis.readFully(data[i], 0, data[i].length);
+        }
+    }
+
+    public void writeNextFrame(BufferedImage bi) throws IOException {
+        log.debug("writing frame #" + frameIndex);
+        if (encodeParam.encapsulated) {
+            long itemPos = ios.getStreamPosition();
+            ios.flushBefore(itemPos);
+            dsIn.writeHeader(ios, encodeParam, Tags.Item, VRs.NONE, -1);
+            writer.setOutput(ios);
+            writer.write(null, new IIOImage(bi, null, null), getWriteParam());
+            long endPos = ios.length();
+            int itemLen = (int) (endPos - itemPos - 8);
+            if ((itemLen & 1) != 0) {
+                ios.write(0);
+                ++itemLen;
+                ++endPos;
+            }
+            ios.seek(itemPos);
+            dsIn.writeHeader(ios, encodeParam, Tags.Item, VRs.NONE, itemLen);
+            ios.seek(endPos);
+            ios.flushBefore(endPos);
+        } else {
+            ios.flushBefore(ios.getStreamPosition());
+            Raster raster = bi.getRaster();
+            DataBuffer buffer = raster.getDataBuffer();
+            final int stride = ((ComponentSampleModel) raster.getSampleModel())
+                    .getScanlineStride();
+            final int h = raster.getHeight();
+            final int w = raster.getWidth();
+            final int b = raster.getNumBands();
+            final int wb = w * b;
+            switch (buffer.getDataType()) {
+            case DataBuffer.TYPE_BYTE:
+                for (int i = 0; i < h; ++i)
+                    ios.write(((DataBufferByte) buffer).getData(), i * stride,
+                            wb);
+                break;
+            case DataBuffer.TYPE_USHORT:
+                for (int i = 0; i < h; ++i)
+                    ios.writeShorts(((DataBufferUShort) buffer).getData(), i
+                            * stride, wb);
+                break;
+            case DataBuffer.TYPE_SHORT:
+                for (int i = 0; i < h; ++i)
+                    ios.writeShorts(((DataBufferShort) buffer).getData(), i
+                            * stride, wb);
+                break;
+            default:
+                throw new RuntimeException("dataType:" + buffer.getDataType());
+            }
+            ios.flushBefore(ios.getStreamPosition());
+        }
+        log.debug("wrote frame #" + frameIndex);
+    }
+
+    public void transcodeFooter() throws IOException {
+        if (!truncatePostPixelData) {
+            readFooter();
+            writeFooter();
+        }
+        if (reader != null) {
+            reader.dispose();
+        }
+        if (writer != null) {
+            writer.dispose();
+        }
+        bi = null;
+    }
+
+    private void readFooter() throws IOException {
+        dsIn.clear();
+        parser.parseDataset(decodeParam, -1);
+    }
+
+    private void writeFooter() throws IOException {
+        dsIn.remove(Tags.DataSetTrailingPadding);
+        dsIn.writeDataset(ios, encodeParam);
+    }
+
+    private ImageWriteParam getWriteParam() {
+        ImageWriteParam wParam = writer.getDefaultWriteParam();
+        if (encodeTS.equals(UIDs.JPEGBaseline)
+                || encodeTS.equals(UIDs.JPEGExtended)) {
+            wParam.setCompressionType("JPEG");
+            wParam.setCompressionQuality(compressionQuality);
+        } else if (encodeTS.equals(UIDs.JPEGLossless)
+                || encodeTS.equals(UIDs.JPEGLossless14)) {
+            wParam.setCompressionType("JPEG-LOSSLESS");
+        } else if (encodeTS.equals(UIDs.JPEGLSLossless)) {
+            wParam.setCompressionType("JPEG-LS");
+        } else if (encodeTS.equals(UIDs.JPEG2000Lossless)) {
+            J2KImageWriteParam j2KwParam = (J2KImageWriteParam) wParam;
+            j2KwParam.setWriteCodeStreamOnly(true);
+        } else if (encodeTS.equals(UIDs.JPEG2000Lossy)) {
+            J2KImageWriteParam j2KwParam = (J2KImageWriteParam) wParam;
+            j2KwParam.setWriteCodeStreamOnly(true);
+            j2KwParam.setLossless(false);
+            j2KwParam.setEncodingRate(encodingRate);
+        }
+        return wParam;
+    }
+
+    protected boolean isCompressionLossless() {
+        return !encodeParam.encapsulated || encodeTS.equals(UIDs.JPEGLossless)
+                || encodeTS.equals(UIDs.JPEGLossless14)
+                || encodeTS.equals(UIDs.JPEGLSLossless)
+                || encodeTS.equals(UIDs.JPEG2000Lossless);
+    }
+
+    /**
+     * called after parsing object from input stream (until Tags.PixelData)
+     * 
+     * @param ds
+     *            parsed dataset containing header
+     */
+    public void onHeaderParsed(Dataset ds) {
+
+    }
+
+    /**
+     * overwrite to perform processing on decoded frames.
+     * 
+     * @param bi
+     *            decoded frame
+     * @return result image (default is image passed as bi)
+     */
+    public BufferedImage onFrameDecoded(BufferedImage bi) {
+        return bi;
+    }
+
+    /**
+     * @return Returns the ignoreMissingPixelData.
+     */
+    public boolean getIgnoreMissingPixelData() {
+        return ignoreMissingPixelData;
+    }
+
+    /**
+     * @param ignoreMissingPixelData
+     *            The ignoreMissingPixelData to set.
+     */
+    public void setIgnoreMissingPixelData(boolean ignoreMissingPixelData) {
+        this.ignoreMissingPixelData = ignoreMissingPixelData;
+    }
+
+    protected BufferedImage createBufferedImage() {
+        int pixelStride;
+        int[] bandOffset;
+        int dataType;
+        int colorSpace;
+        if (pixelDataParam.getSamplesPerPixel() == 3) {
+            pixelStride = 3;
+            bandOffset = new int[] { 0, 1, 2 };
+            dataType = DataBuffer.TYPE_BYTE;
+            colorSpace = ColorSpace.CS_sRGB;
+        } else {
+            pixelStride = 1;
+            bandOffset = new int[] { 0 };
+            dataType = pixelDataParam.getBitsAllocated() == 8 
+                    ? DataBuffer.TYPE_BYTE
+                    : DataBuffer.TYPE_USHORT;
+            colorSpace = ColorSpace.CS_GRAY;
+        }
+        SampleModel sm = new PixelInterleavedSampleModel(dataType,
+                pixelDataParam.getColumns(), pixelDataParam.getRows(),
+                pixelStride, pixelDataParam.getColumns() * pixelStride,
+                bandOffset);
+        ColorModel cm = new ComponentColorModel(
+                ColorSpace.getInstance(colorSpace), sm.getSampleSize(), false,
+                false, Transparency.OPAQUE, dataType);
+        WritableRaster r = Raster.createWritableRaster(sm, new Point(0, 0));
+        return new BufferedImage(cm, r, false, new Hashtable());
+    }
+
+}
diff --git a/src/in/raster/mayam/util/core/TranscoderMain.java b/src/in/raster/mayam/util/core/TranscoderMain.java
new file mode 100644
index 0000000..22a5313
--- /dev/null
+++ b/src/in/raster/mayam/util/core/TranscoderMain.java
@@ -0,0 +1,233 @@
+package in.raster.mayam.util.core;
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is part of dcm4che, an implementation of DICOM(TM) in
+ * Java(TM), hosted at http://sourceforge.net/projects/dcm4che.
+ *
+ * The Initial Developer of the Original Code is
+ * Gunter Zeilinger, Huetteldorferstr. 24/10, 1150 Vienna/Austria/Europe.
+ * Portions created by the Initial Developer are Copyright (C) 2002-2005
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Gunter Zeilinger <gunterze at gmail.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+import gnu.getopt.Getopt;
+import gnu.getopt.LongOpt;
+
+import java.io.File;
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+
+import org.dcm4che.dict.UIDs;
+/**
+ * @author Gunter.Zeilinger at tiani.com
+ * @version $Revision: 1.1 $
+ * @since 01.11.2003
+ */
+public final class TranscoderMain
+{
+
+    private static ResourceBundle rb =
+        ResourceBundle.getBundle(TranscoderMain.class.getName());
+
+    public static void main(String[] args)
+    {
+        int c;
+        String arg;
+        LongOpt[] longopts =
+            {
+                new LongOpt("trunc-post-pixeldata", LongOpt.NO_ARGUMENT, null, 't'),
+                new LongOpt("version", LongOpt.NO_ARGUMENT, null, 'v'),
+                new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h'),
+                new LongOpt("ivle", LongOpt.NO_ARGUMENT, null, 'd'),
+                new LongOpt("evle", LongOpt.NO_ARGUMENT, null, 'e'),
+                new LongOpt("evbe", LongOpt.NO_ARGUMENT, null, 'b'),
+                new LongOpt("jpll", LongOpt.NO_ARGUMENT, null, 'l'),
+                new LongOpt("jlsl", LongOpt.NO_ARGUMENT, null, 's'),
+                new LongOpt("j2kr", LongOpt.NO_ARGUMENT, null, 'r'),
+                new LongOpt("jply", LongOpt.OPTIONAL_ARGUMENT, null, 'y'),
+                new LongOpt("j2ki", LongOpt.OPTIONAL_ARGUMENT, null, 'i'),
+                };
+        // 
+        Getopt g = new Getopt("dcm4chex-codec", args, "jhv", longopts, true);
+        Transcoder t = new Transcoder();
+        while ((c = g.getopt()) != -1)
+            switch (c)
+            {
+                case 'd' :
+                    t.setTransferSyntax(UIDs.ImplicitVRLittleEndian);
+                    break;
+                case 'e' :
+                    t.setTransferSyntax(UIDs.ExplicitVRLittleEndian);
+                    break;
+                case 'b' :
+                    t.setTransferSyntax(UIDs.ExplicitVRBigEndian);
+                    break;
+                case 'l' :
+                    t.setTransferSyntax(UIDs.JPEGLossless);
+                    break;
+                case 's' :
+                    t.setTransferSyntax(UIDs.JPEGLSLossless);
+                    break;
+                case 'r' :
+                    t.setTransferSyntax(UIDs.JPEG2000Lossless);
+                    break;
+                case 'y' :
+                    t.setTransferSyntax(UIDs.JPEGBaseline);
+                    t.setCompressionQuality(
+                        toCompressionQuality(g.getOptarg()));
+                    break;
+                case 'i' :
+                    t.setTransferSyntax(UIDs.JPEG2000Lossy);
+                    t.setEncodingRate(toEncodingRate(g.getOptarg()));
+                    break;
+                case 't' :
+                    t.setTruncatePostPixelData(true);
+                    break;
+                case 'v' :
+                    System.out.println(
+                        MessageFormat.format(
+                            rb.getString("version"),
+                            new Object[] {
+                                Package
+                                    .getPackage("org.dcm4chex.codec")
+                                    .getImplementationVersion()}));
+                    return;
+                case '?' :
+                case 'h' :
+                    System.out.println(rb.getString("usage"));
+                    return;
+            }
+        if (!checkArgs(g.getOptind(), args))
+        {
+            System.out.println(rb.getString("usage"));
+            return;
+        }
+        File dest = new File(args[args.length - 1]);
+        for (int i = g.getOptind(); i + 1 < args.length; ++i)
+        {
+            transcode(t, new File(args[i]), dest);
+        }
+    }
+
+    private static void transcode(Transcoder t, File src, File dest)
+    {
+        if (src.isDirectory())
+        {
+            File[] file = src.listFiles();
+            for (int i = 0; i < file.length; i++)
+            {
+                transcode(t, file[i], dest);
+            }
+        } else
+        {
+            try
+            {
+                File outFile =
+                    dest.isDirectory() ? new File(dest, src.getName()) : dest;
+                long srcLength = src.length();            
+                long begin = System.currentTimeMillis();
+                t.transcode(src, outFile);
+                long end = System.currentTimeMillis();
+                long destLength = outFile.length();
+              
+            } catch (Exception e)
+            {
+                e.printStackTrace(System.out);
+            }
+        }
+    }
+
+    private static boolean checkArgs(int off, String[] args)
+    {
+        switch (args.length - off)
+        {
+            case 0 :
+                System.out.println(rb.getString("missingArgs"));
+                return false;
+            case 1 :
+                System.out.println(rb.getString("missingDest"));
+                return false;
+            case 2 :
+                if (!(new File(args[off])).isDirectory())
+                    break;
+            default :
+                if (!(new File(args[args.length - 1])).isDirectory())
+                {
+                    System.out.println(
+                        MessageFormat.format(
+                            rb.getString("needDir"),
+                            new Object[] { args[args.length - 1] }));
+                    return false;
+                }
+        }
+        return true;
+    }
+
+    private static float toCompressionQuality(String s)
+    {
+        if (s != null)
+        {
+            try
+            {
+                int quality = Integer.parseInt(s);
+                if (quality >= 0 && quality <= 100)
+                {
+                    return quality / 100.f;
+                }
+            } catch (IllegalArgumentException e)
+            {e.printStackTrace();}
+            System.out.println(
+                MessageFormat.format(
+                    rb.getString("ignoreQuality"),
+                    new Object[] { s }));
+        }
+        return .75f;
+    }
+
+    private static double toEncodingRate(String s)
+    {
+        if (s != null)
+        {
+            try
+            {
+                double rate = Double.parseDouble(s);
+                if (rate > 0)
+                {
+                    return rate;
+                }
+            } catch (IllegalArgumentException e)
+            {e.printStackTrace();}
+            System.out.println(
+                MessageFormat.format(
+                    rb.getString("ignoreRate"),
+                    new Object[] { s }));
+        }
+        return 1.;
+    }
+}
diff --git a/src/in/raster/mayam/util/core/TranscoderMain.properties b/src/in/raster/mayam/util/core/TranscoderMain.properties
new file mode 100644
index 0000000..6f511a2
--- /dev/null
+++ b/src/in/raster/mayam/util/core/TranscoderMain.properties
@@ -0,0 +1,21 @@
+usage=\r\nUsage: java -jar imgcodec.jar [OPTION] SOURCE DEST\
+\r\n  or:  java -jar imgcodec.jar [OPTION] SOURCE... DIRECTORY\
+\r\n\r\nTranscode SOURCE according OPTION to DEST,\
+\r\nor multiple SOURCE[s] to DIRECTORY\
+\r\n\r\nOPTION:\
+\r\n --jpll           use JPEG (ISO 10918-1) lossless\
+\r\n --jply[=quality] use JPEG baseline on 8-bit and JPEG extended mode on\
+\r\n                  up to 12-bit images with specified compression quality\
+\r\n                  [0..100], default: 75\
+\r\n --jlsl           use JPEG LS (ISO 14495-1)\
+\r\n --j2kr           use JPEG 2000 reversible mode\
+\r\n --j2ki[=rate]    use JPEG 2000 irreversible mode with specified\
+\r\n                  encoding rate (default: 1.0)\
+\r\n -v --version     display version and exit\
+\r\n -h --help        display this help and exit
+version=dcm2dcm v{0}
+ignoreQuality=warning: ignore invalid compression quality '{0}'
+ignoreRate=warning: ignore invalid encoding rate '{0}'
+missingArgs=missing file arguments
+missingDest=missing destination file
+needDir=transcoding multiple file, but last argument '{0}' is not a directory
\ No newline at end of file
diff --git a/src/in/raster/mayam/util/database/DatabaseHandler.java b/src/in/raster/mayam/util/database/DatabaseHandler.java
new file mode 100644
index 0000000..7e494bf
--- /dev/null
+++ b/src/in/raster/mayam/util/database/DatabaseHandler.java
@@ -0,0 +1,1741 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.util.database;
+
+import in.raster.mayam.context.ApplicationContext;
+import in.raster.mayam.facade.ApplicationFacade;
+import in.raster.mayam.form.MainScreen;
+import in.raster.mayam.model.AEModel;
+import in.raster.mayam.model.Instance;
+import in.raster.mayam.model.PresetModel;
+import in.raster.mayam.model.Series;
+import in.raster.mayam.model.ServerModel;
+import in.raster.mayam.model.Study;
+import in.raster.mayam.model.StudyModel;
+import java.io.File;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.apache.derby.jdbc.EmbeddedSimpleDataSource;
+import java.sql.*;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Vector;
+import javax.swing.SwingUtilities;
+import org.dcm4che.dict.Tags;
+import org.dcm4che2.data.DicomObject;
+import org.dcm4che2.data.Tag;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class DatabaseHandler {
+
+    //Named Constants for Database,driver,protocol
+    private static final String driver = "org.apache.derby.jdbc.EmbeddedDriver";
+    private static final String protocol = "jdbc:derby:";
+    private static final String databasename = "mayamdb";
+    // Named Constants for Table name
+    private static final String patientTable = "patient";
+    private static final String studyTable = "study";
+    private static final String seriesTable = "series";
+    private static final String instanceTable = "image";
+    private static final String aeTitleTable = "aetitles";
+    //Named Constants for username and password of Database 
+    private static final String username = "mayam";
+    private static final String password = "mayam";
+    //Database Connection creator and executor variables 
+    private Connection conn;
+    private Statement statement;
+    //Datasouce declaration
+    private EmbeddedSimpleDataSource ds;
+    //Boolean variables 
+    private boolean dbExists = false;
+    //Data formater
+    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+    private String DicomServersHeaderDisplayName = "Dicom Servers";
+
+    private DatabaseHandler() {
+    }
+
+    /**it checks whether database available in local folder or not.
+     */
+    public boolean checkDBexists(String tem) {
+
+        File temp = new File(tem);
+        boolean dbexists = false;
+        for (int l = 0; l < temp.listFiles().length; l++) {
+            if (temp.listFiles()[l].getName().equalsIgnoreCase(
+                    databasename)) {
+                dbexists = true;
+            }
+        }
+        return dbexists;
+    }
+
+    /** It initializes the Java Derby Databse.It creates the database if it is not available. */
+    public void openOrCreateDB() {
+        try {
+            System.setProperty("derby.system.home", ApplicationContext.getAppDirectory());
+            try {
+                Class.forName(driver).newInstance();
+            } catch (InstantiationException e) {
+                StringWriter str = new StringWriter();
+                e.printStackTrace(new PrintWriter(str));
+            } catch (IllegalAccessException e) {
+                StringWriter str = new StringWriter();
+                e.printStackTrace(new PrintWriter(str));
+            } catch (ClassNotFoundException e) {
+                StringWriter str = new StringWriter();
+                e.printStackTrace(new PrintWriter(str));
+            }
+            try {
+                ds = new org.apache.derby.jdbc.EmbeddedSimpleDataSource();
+                ds.setDatabaseName(databasename);
+            } catch (NoClassDefFoundError e) {
+                System.err.println("ERROR: ClassNotFoundException:" + e.getMessage());
+                ApplicationFacade.exitApp("ERROR: ClassNotFoundException:" + e.getMessage() + ": Exiting the program");
+            }
+            openConnection();
+            statement = conn.createStatement();
+            if (!dbExists) {
+                createTables();
+                insertModalities();
+                insertDefaultListenerDetail();
+                insertDefaultLayoutDetail();
+                insertDefaultPresets();
+                insertDefaultThemes();
+                insertDefaultPropertiesDetail();
+            }
+            conn.setAutoCommit(false);
+        } catch (SQLException e) {
+            StringWriter str = new StringWriter();
+            e.printStackTrace(new PrintWriter(str));
+        }
+    }
+
+    private void openConnection() {
+        this.dbExists = checkDBexists(ApplicationContext.getAppDirectory());
+        try {
+            if (!dbExists) {
+                conn = DriverManager.getConnection(protocol + databasename + ";create=true",
+                        username, password);
+            } else {
+                conn = DriverManager.getConnection(protocol + databasename + ";create=false", username, password);
+            }
+        } catch (Exception e) {
+            if (dbExists && conn == null) {
+                System.err.println("ERROR: Database connection cannot be created:" + e.getMessage());
+                System.err.println("An instance of application is already running");
+                ApplicationFacade.exitApp("An instance of Mayam is already running: Exiting the program");
+            }
+        }
+    }
+
+    /**
+     * It closes the local java derby database connection.
+     */
+    public void closeDrivers() {
+        try {
+            statement.close();
+            conn.commit();
+            conn.close();
+        } catch (SQLException e) {
+            StringWriter str = new StringWriter();
+            e.printStackTrace(new PrintWriter(str));
+        }
+
+    }
+
+    public void rebuild() {
+        deleteRows();
+        deleteDir(new File(getListenerDetails()[2]));
+        ApplicationContext.mainScreen.restartReceiver();
+    }
+
+    public void createAndInsertDefaults() {
+        createTables();
+        insertModalities();
+        insertDefaultListenerDetail();
+        insertDefaultLayoutDetail();
+        insertDefaultPresets();
+    }
+
+    /**
+     * Deletes all files and subdirectories under "dir".
+     * @param dir Directory to be deleted
+     * @return boolean Returns "true" if all deletions were successful.
+     *                 If a deletion fails, the method stops attempting to
+     *                 delete and returns "false".
+     */
+    private static boolean deleteDir(File dir) {
+        if (dir.isDirectory()) {
+            String[] children = dir.list();
+            for (int i = 0; i < children.length; i++) {
+                boolean success = deleteDir(new File(dir, children[i]));
+                if (!success) {
+                    return false;
+                }
+            }
+        }
+        // The directory is now empty so now it can be smoked
+        return dir.delete();
+    }
+
+    /**
+     * It commits the database.
+     */
+    public void doCommit() {
+        try {
+            conn.commit();
+        } catch (SQLException e) {
+            StringWriter str = new StringWriter();
+            e.printStackTrace(new PrintWriter(str));
+        }
+    }
+
+    public void insertAE(String serverName, String host, String location, String aeTitle, int port, int headerPort, int imagePort) {
+        try {
+            conn.createStatement().execute("insert into" + "ae values('" + serverName + "','" + host + "','" + location + "','" + aeTitle + "'," + port + "," + headerPort + "," + imagePort + ")");
+            conn.commit();
+        } catch (SQLException ex) {
+            Logger.getLogger(DatabaseHandler.class.getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+
+    public void insertListenerDetail(String aeTitle, int port, String storageLocation) {
+        try {
+            ResultSet rs = conn.createStatement().executeQuery("select pk from listener");
+            rs.next();
+            int pk = rs.getInt("pk");
+            int n = conn.createStatement().executeUpdate("update listener set aetitle='" + aeTitle + "',port=" + port + " where pk=" + pk);
+            conn.commit();
+        } catch (SQLException ex) {
+            Logger.getLogger(DatabaseHandler.class.getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+
+    public void updatePropertiesDetail(String value) {
+        try {
+            ResultSet rs = conn.createStatement().executeQuery("select pk,value from properties where property='multiframeassepseries'");
+            rs.next();
+            String status = rs.getString("value");
+            int n = conn.createStatement().executeUpdate("update properties set value='" + value + "' where property='multiframeassepseries'");
+            conn.commit();
+        } catch (SQLException ex) {
+            Logger.getLogger(DatabaseHandler.class.getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+
+    public void insertDefaultPropertiesDetail() {
+        try {
+            conn.createStatement().execute("insert into properties(property,value) values('multiframeassepseries','true')");
+            conn.commit();
+        } catch (SQLException ex) {
+            Logger.getLogger(DatabaseHandler.class.getName()).log(Level.SEVERE, null, ex);
+        }
+
+    }
+
+    public boolean getMultiframeStatus() {
+        boolean status = true;
+        try {
+            ResultSet rs = conn.createStatement().executeQuery("select pk,value from properties where property='multiframeassepseries'");
+            rs.next();
+            String value = rs.getString("value");
+            if (value.equalsIgnoreCase("true")) {
+                status = true;
+            } else {
+                status = false;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return status;
+    }
+
+    public String[] getListenerDetails() {
+        ResultSet rs = null;
+        String detail[] = new String[3];
+        try {
+            rs = conn.createStatement().executeQuery("select * from listener");
+            while (rs.next()) {
+                detail[0] = rs.getString("aetitle");
+                detail[1] = Integer.toString(rs.getInt("port"));
+                detail[2] = rs.getString("storagelocation");
+            }
+        } catch (SQLException ex) {
+            Logger.getLogger(DatabaseHandler.class.getName()).log(Level.SEVERE, null, ex);
+        }
+        return detail;
+    }
+
+    // checks the existence of the file
+    public boolean TableExists(String TableName) throws SQLException {
+        String[] types = {"TABLE"};
+        ResultSet rset = conn.getMetaData().getTables(null, null, "%", types);
+        while (rset.next()) {
+            if (rset.getString("TABLE_NAME").equalsIgnoreCase(TableName)) {
+                return true;
+            }
+        }
+        return false;
+
+    }
+
+    public void createTables() {
+        try {
+            String sql = "";
+            //creating patient table if it is not exist already
+            sql = "create table " + patientTable + " (PatientId varchar(255) NOT NULL CONSTRAINT PatientId_Pk PRIMARY KEY ," + "PatientName varchar(255)," + "PatientBirthDate varchar(30)," + "PatientSex varchar(10))";
+            statement.executeUpdate(sql);
+
+            //creating study table if it is not exist already
+            sql = "create table " + studyTable + "(StudyInstanceUID varchar(255)  NOT NULL CONSTRAINT StudyInstanceUID_pk PRIMARY KEY ," + "StudyDate varchar(30), " + "AccessionNo varchar(50), " + "ReferringPhysicianName varchar(255), " + "StudyDescription  varchar(80), " + "ModalityInStudy varchar(10), " + "NoOfSeries integer," + "NoOfInstances integer," + "RecdImgCnt Integer," + "SendImgCnt integer," + "RetrieveAET varchar(50)," + "StudyType varchar(75)," + "PatientId varchar(255), for [...]
+            statement.executeUpdate(sql);
+
+            //creating series table if it is not exist already
+            sql = "create table " + seriesTable + " (SeriesInstanceUID varchar(255) NOT NULL CONSTRAINT SeriesInstanceUID_pk PRIMARY KEY ," + "SeriesNo varchar(50)," + "Modality varchar(10)," + "SeriesDescription varchar(100)," + "BodyPartExamined varchar(100)," + "InstitutionName varchar(255)," + "NoOfSeriesRelatedInstances integer," + "PatientId varchar(255), foreign key(PatientId) references Patient(PatientId)," + "StudyInstanceUID varchar(255), foreign key (StudyInstanceUID) referenc [...]
+            statement.executeUpdate(sql);
+
+            //creating is instance table if it is not exist already
+            sql = "create table " + instanceTable + " (SopUID varchar(255) NOT NULL CONSTRAINT SopUID_pk PRIMARY KEY ," + "InstanceNo integer," + "multiframe varchar(50)," + "totalframe varchar(50)," + "SendStatus varchar(50)," + "ForwardDateTime varchar(30)," + "ReceivedDateTime varchar(30)," + "ReceiveStatus varchar(50)," + "FileStoreUrl varchar(750)," + "SliceLocation integer," + "EncapsulatedDocument varchar(50)," + "PatientId varchar(255), foreign key(PatientId) references Patient(P [...]
+            statement.executeUpdate(sql);
+
+            sql = "create table ae(pk integer primary key GENERATED ALWAYS AS IDENTITY,logicalname varchar(255),hostname varchar(255),aetitle varchar(255),port integer,retrievetype varchar(100),wadocontext varchar(100),wadoport integer,wadoprotocol varchar(100),retrievets varchar(255))";
+            statement.executeUpdate(sql);
+
+            sql = "create table modality(pk integer primary key GENERATED ALWAYS AS IDENTITY,logicalname varchar(255),shortname varchar(255))";
+            statement.executeUpdate(sql);
+
+            sql = "create table layout(pk integer primary key GENERATED ALWAYS AS IDENTITY,rowcount smallint,columncount smallint,modality_fk integer,foreign key(modality_fk) references modality(pk))";
+            statement.executeUpdate(sql);
+
+            sql = "create table preset(pk integer primary key GENERATED ALWAYS AS IDENTITY,presetname varchar(255),windowwidth numeric,windowlevel numeric,modality_fk integer,foreign key(modality_fk) references modality(pk))";
+            statement.executeUpdate(sql);
+
+            sql = "create table listener(pk integer primary key GENERATED ALWAYS AS IDENTITY,aetitle varchar(255),port integer,storagelocation varchar(255))";
+            statement.executeUpdate(sql);
+
+            sql = "create table theme(pk integer primary key GENERATED ALWAYS AS IDENTITY,name varchar(255),status varchar(255))";
+            statement.executeUpdate(sql);
+
+            sql = "create table properties (pk integer primary key GENERATED ALWAYS AS IDENTITY,property varchar(255),value varchar(255))";
+            statement.executeUpdate(sql);
+        } catch (SQLException ex) {
+            Logger.getLogger(DatabaseHandler.class.getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+
+    /**
+     * This routine is used to list studies of local db
+     * @return
+     */
+    public Vector listAllStudiesOfDB() {
+        ResultSet rs = null;
+        Vector studyList = new Vector();
+        try {
+            String sql = "Select * from study";
+            rs = conn.createStatement().executeQuery(sql);
+            while (rs.next()) {
+                StudyModel st = new StudyModel();
+                st.setStudyDate(rs.getString("StudyDate"));
+                st.setAccessionNo(rs.getString("AccessionNo").equalsIgnoreCase("null") ? "" : rs.getString("AccessionNo"));
+                st.setPatientId(rs.getString("PatientId"));
+                st.setStudyDescription(rs.getString("StudyDescription").equalsIgnoreCase("null") ? "" : rs.getString("StudyDescription"));
+                st.setStudyUID(rs.getString("StudyInstanceUID"));
+                st.setModalitiesInStudy(rs.getString("ModalityInStudy"));
+                st.setStudyLevelInstances("" + getStudyLevelInstance(st.getStudyUID()));
+
+                String sql2 = "select PatientName,PatientBirthDate from patient where PatientId='" + rs.getString("PatientId") + "'";
+                ResultSet rs1 = conn.createStatement().executeQuery(sql2);
+                rs1.next();
+
+                st.setPatientName(rs1.getString("PatientName"));
+                st.setDob(rs1.getString("PatientBirthDate"));
+                st.setModalitiesInStudy(getModalitiesOfStudy(st.getStudyUID()));
+                studyList.addElement(st);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return studyList;
+    }
+
+    public String getModalitiesOfStudy(String siuid) {
+        String modalities = "";
+        ResultSet rs = null;
+        try {
+            String sql = "Select * from series where StudyInstanceUID='" + siuid + "'";
+            rs = conn.createStatement().executeQuery(sql);
+            while (rs.next()) {
+                if (!modalities.contains(rs.getString("Modality"))) {
+                    if (modalities.equalsIgnoreCase("")) {
+                        modalities += rs.getString("Modality");
+                    } else {
+                        modalities += "/" + rs.getString("Modality");
+                    }
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return modalities;
+    }
+
+    public Vector listAllSeriesOfStudy(String siuid) {
+        ResultSet rs = null;
+        Vector seriesList = new Vector();
+        try {
+            String sql = "Select * from series where StudyInstanceUID='" + siuid + "'";
+            rs = conn.createStatement().executeQuery(sql);
+            while (rs.next()) {
+                Series series = new Series();
+                series.setSeriesDesc(rs.getString("SeriesDescription"));
+                series.setBodyPartExamined(rs.getString("BodyPartExamined"));
+                series.setSeriesInstanceUID(rs.getString("SeriesInstanceUID"));
+                series.setModality(rs.getString("Modality"));
+                series.setSeriesNumber(rs.getString("SeriesNo"));
+                series.setStudyInstanceUID(rs.getString("StudyInstanceUID"));
+                series.setInstitutionName(rs.getString("InstitutionName"));
+                series.setSeriesRelatedInstance(this.getSeriesLevelInstance(siuid, series.getSeriesInstanceUID()));
+                seriesList.addElement(series);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return seriesList;
+    }
+
+    public void insertModalities() {
+        String modality[] = {"CT", "MR", "XA", "CR", "SC", "NM", "RF", "DX", "US", "PX", "OT", "DR", "SR", "MG", "RG"};
+        for (int i = 0; i < modality.length; i++) {
+            try {
+                conn.createStatement().execute("insert into modality(logicalname,shortname) values('Dummy','" + modality[i] + "')");
+                conn.commit();
+            } catch (SQLException ex) {
+                Logger.getLogger(DatabaseHandler.class.getName()).log(Level.SEVERE, null, ex);
+            }
+        }
+    }
+
+    private void insertDefaultPresets() {
+        try {
+            String sql = "select pk from modality where shortname='CT'";
+            ResultSet rs = conn.createStatement().executeQuery(sql);
+            rs.next();
+            String sql1 = "insert into preset(presetname,windowwidth,windowlevel,modality_fk)values('CT Abdomen',40,350," + rs.getString("pk") + ")";
+            String sql2 = "insert into preset(presetname,windowwidth,windowlevel,modality_fk)values('CT Lung',1500,-600," + rs.getString("pk") + ")";
+            String sql3 = "insert into preset(presetname,windowwidth,windowlevel,modality_fk)values('CT Brain',80,40," + rs.getString("pk") + ")";
+            String sql4 = "insert into preset(presetname,windowwidth,windowlevel,modality_fk)values('CT Bone',2500,480," + rs.getString("pk") + ")";
+            String sql5 = "insert into preset(presetname,windowwidth,windowlevel,modality_fk)values('CT Head/Neck',350,90," + rs.getString("pk") + ")";
+
+            conn.createStatement().execute(sql1);
+            conn.createStatement().execute(sql2);
+            conn.createStatement().execute(sql3);
+            conn.createStatement().execute(sql4);
+            conn.createStatement().execute(sql5);
+
+            conn.commit();
+        } catch (Exception e) {
+            e.printStackTrace();
+
+        }
+    }
+
+    private void insertDefaultThemes() {
+        try {
+            String sql1 = "insert into theme(name,status)values('Nimrod','active')";
+            String sql2 = "insert into theme(name,status)values('Motif','idle')";
+            String sql3 = "insert into theme(name,status)values('System','idle')";
+
+            conn.createStatement().execute(sql1);
+            conn.createStatement().execute(sql2);
+            conn.createStatement().execute(sql3);
+
+            conn.commit();
+        } catch (Exception e) {
+            e.printStackTrace();
+
+        }
+    }
+
+    public void updateThemeStatus(String themeName) {
+        try {
+            String str = "select name from theme where status='active'";
+            ResultSet rs = conn.createStatement().executeQuery(str);
+            rs.next();
+            int n = conn.createStatement().executeUpdate("update theme set status='idle' where name='" + rs.getString("name") + "'");
+            int m = conn.createStatement().executeUpdate("update theme set status='active' where name='" + themeName + "'");
+            conn.commit();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public String getActiveTheme() {
+        String activeTheme = "";
+        try {
+            String str = "select name from theme where status='active'";
+            ResultSet rs = conn.createStatement().executeQuery(str);
+            rs.next();
+            activeTheme = rs.getString("name");
+        } catch (SQLException ex) {
+            Logger.getLogger(DatabaseHandler.class.getName()).log(Level.SEVERE, null, ex);
+        }
+        return activeTheme;
+    }
+
+    public String[] getModalities() {
+        String[] modalities = null;
+        try {
+            String sql2 = "Select shortname from modality";
+            String sql1 = "select count(*) from modality";
+            int count;
+            int index = 0;
+            ResultSet rs1 = conn.createStatement().executeQuery(sql1);
+            rs1.next();
+            count = rs1.getInt(1);
+            modalities = new String[count];
+            ResultSet rs2 = conn.createStatement().executeQuery(sql2);
+            while (rs2.next()) {
+                modalities[index] = rs2.getString("shortname");
+                index++;
+            }
+        } catch (SQLException ex) {
+            Logger.getLogger(DatabaseHandler.class.getName()).log(Level.SEVERE, null, ex);
+        }
+        return modalities;
+    }
+
+    public void insertDefaultListenerDetail() {
+        try {
+            boolean insertStatus = conn.createStatement().execute("insert into" + " listener(aetitle,port,storagelocation) values('MAYAM',1025,'" + ApplicationContext.getAppDirectory() + File.separator + "archive')");
+            conn.commit();
+        } catch (SQLException ex) {
+            Logger.getLogger(DatabaseHandler.class.getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+
+    public void insertDefaultLayoutDetail() {
+        try {
+            String sql1 = "select pk,shortname from modality";
+            ResultSet rs = conn.createStatement().executeQuery(sql1);
+            while (rs.next()) {
+                int pk = rs.getInt("pk");
+                boolean insertStatus = conn.createStatement().execute("insert into" + " layout(rowcount,columncount,modality_fk) values(1,2," + pk + ")");
+                conn.commit();
+            }
+        } catch (SQLException ex) {
+            Logger.getLogger(DatabaseHandler.class.getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+
+    public void insertLayoutDetail(int rowCount, int columnCount, String modality) {
+        try {
+            String sql1 = "select pk from modality where shortname='" + modality + "'";
+            ResultSet rs = conn.createStatement().executeQuery(sql1);
+            rs.next();
+            int pk = rs.getInt("pk");
+
+            String sql2 = "select pk from layout where modality_fk=" + pk;
+            ResultSet rs1 = conn.createStatement().executeQuery(sql2);
+            rs1.next();
+            int layoutPK = rs1.getInt("pk");
+            if (layoutPK != -1) {
+                int n = conn.createStatement().executeUpdate("update layout set rowcount=" + rowCount + ",columncount=" + columnCount + ",modality_fk=" + pk + " where pk=" + layoutPK);
+                conn.commit();
+            } else {
+                boolean insertStatus = conn.createStatement().execute("insert into" + " layout(rowcount,columncount,modality_fk) values(1,2," + pk + ")");
+                conn.commit();
+            }
+        } catch (SQLException ex) {
+            Logger.getLogger(DatabaseHandler.class.getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+
+    public void insertPreset(PresetModel presetModel, String modality) {
+        try {
+            String sql1 = "select pk from modality where shortname='" + modality + "'";
+            ResultSet rs = conn.createStatement().executeQuery(sql1);
+            rs.next();
+            int pk = rs.getInt("pk");
+            boolean insertStatus = conn.createStatement().execute("insert into" + " preset(presetname,windowwidth,windowlevel,modality_fk) values('" + presetModel.getPresetName() + "'," + presetModel.getWindowWidth() + "," + presetModel.getWindowLevel() + "," + pk + ")");
+            conn.commit();
+        } catch (SQLException ex) {
+            Logger.getLogger(DatabaseHandler.class.getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+
+    public ArrayList getPresetValueForModality(String modality) {
+        ArrayList presetList = new ArrayList();
+        try {
+            String sql1 = "select pk from modality where shortname='" + modality + "'";
+            ResultSet rs = conn.createStatement().executeQuery(sql1);
+            rs.next();
+            int pk = rs.getInt("pk");
+            String sql2 = "select pk,presetname,windowwidth,windowlevel from preset where modality_fk=" + pk;
+            ResultSet rs1 = conn.createStatement().executeQuery(sql2);
+            while (rs1.next()) {
+                PresetModel presetModel = new PresetModel();
+                presetModel.setPk(rs1.getInt("pk"));
+                presetModel.setPresetName(rs1.getString("presetname"));
+                presetModel.setWindowWidth(rs1.getString("windowwidth"));
+                presetModel.setWindowLevel(rs1.getString("windowlevel"));
+                presetList.add(presetModel);
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return presetList;
+
+    }
+
+    public void updatePresetValues(PresetModel presetModel) {
+        try {
+            int n = conn.createStatement().executeUpdate("update preset set presetname='" + presetModel.getPresetName() + "',windowwidth=" + presetModel.getWindowWidth() + ",windowlevel=" + presetModel.getWindowLevel() + " where pk=" + presetModel.getPk());
+            conn.commit();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void deletePreset(PresetModel presetModel) {
+        try {
+            String sql = "delete from preset where pk=" + presetModel.getPk();
+            conn.createStatement().execute(sql);
+            conn.commit();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void updateServerListValues(ServerModel serverModel) {
+        try {
+            int n = conn.createStatement().executeUpdate("update ae set logicalname='" + serverModel.getServerName() + "',hostname='" + serverModel.getHostName() + "',aetitle='" + serverModel.getAeTitle() + "',port=" + serverModel.getPort() + ",retrievetype='" + serverModel.getRetrieveType() + "',wadocontext='" + serverModel.getWadoContextPath() + "',wadoport=" + serverModel.getWadoPort() + ",wadoprotocol='" + serverModel.getWadoProtocol() + "',retrievets='" + serverModel.getRetrieveTran [...]
+            conn.commit();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void deleteServer(ServerModel serverModel) {
+        try {
+            String sql = "delete from ae where pk=" + serverModel.getPk();
+            conn.createStatement().execute(sql);
+            conn.commit();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void insertServer(ServerModel serverModel) {
+        try {
+            boolean insertStatus = conn.createStatement().execute("insert into" + " ae(logicalname,hostname,aetitle,port,retrievetype,wadocontext,wadoport,wadoprotocol,retrievets) values('" + serverModel.getServerName() + "','" + serverModel.getHostName() + "','" + serverModel.getAeTitle() + "'," + serverModel.getPort() + ",'" + serverModel.getRetrieveType() + "','" + serverModel.getWadoContextPath() + "'," + serverModel.getWadoPort() + ",'" + serverModel.getWadoProtocol() + "','" + serv [...]
+            conn.commit();
+        } catch (SQLException ex) {
+            Logger.getLogger(DatabaseHandler.class.getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+
+    public ArrayList getServerList() {
+        ArrayList serverList = new ArrayList();
+        try {
+            String sql2 = "select * from ae";
+            ResultSet rs1 = conn.createStatement().executeQuery(sql2);
+            while (rs1.next()) {
+                ServerModel serverModel = new ServerModel();
+                serverModel.setPk(rs1.getInt("pk"));
+                serverModel.setServerName(rs1.getString("logicalname"));
+                serverModel.setHostName(rs1.getString("hostname"));
+                serverModel.setAeTitle(rs1.getString("aetitle"));
+                serverModel.setPort(rs1.getInt("port"));
+                serverModel.setRetrieveType(rs1.getString("retrievetype"));
+                serverModel.setWadoContextPath(rs1.getString("wadocontext") != null ? rs1.getString("wadocontext") : "");
+                serverModel.setWadoPort(rs1.getInt("wadoport"));
+                serverModel.setWadoProtocol(rs1.getString("wadoprotocol"));
+                serverModel.setRetrieveTransferSyntax(rs1.getString("retrievets"));
+                serverList.add(serverModel);
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return serverList;
+    }
+
+    public int[] getRowColumnForModality(String modality) {
+        int rowColumn[] = new int[2];
+        try {
+
+            String sql = "select pk,shortname from modality where shortname='" + modality + "'";
+            ResultSet rs = conn.createStatement().executeQuery(sql);
+            rs.next();
+            int pk = rs.getInt("pk");
+            String sql1 = "select rowcount,columncount from layout where modality_fk=" + pk;
+            ResultSet rs1 = conn.createStatement().executeQuery(sql1);
+            rs1.next();
+            rowColumn[0] = rs1.getInt("rowcount");
+            rowColumn[1] = rs1.getInt("columncount");
+
+        } catch (SQLException ex) {
+            rowColumn[0] = 1;
+            rowColumn[1] = 1;
+        }
+        return rowColumn;
+    }
+
+    public int[] getRowColumnBasedStudyUID(String suid) {
+        return getRowColumnForModality(getModalityBasedonStudyUID(suid));
+    }
+
+    public String getModalityBasedonStudyUID(String suid) {
+        String modality = null;
+        try {
+            String sql = "select ModalityInStudy from study where StudyInstanceUID='" + suid + "'";
+            ResultSet rs = conn.createStatement().executeQuery(sql);
+            rs.next();
+            modality = rs.getString("ModalityInStudy");
+        } catch (SQLException ex) {
+            Logger.getLogger(DatabaseHandler.class.getName()).log(Level.SEVERE, null, ex);
+        }
+        return modality;
+    }
+
+    public String getPatientNameBasedonStudyUID(String suid) {
+        String patientName = null;
+        try {
+
+            String sql = "select PatientId from study where StudyInstanceUID='" + suid + "'";
+            ResultSet rs = conn.createStatement().executeQuery(sql);
+            rs.next();
+            String patientid = rs.getString("PatientId");
+            String sql1 = "select PatientName from patient where PatientId='" + patientid + "'";
+            ResultSet rs1 = conn.createStatement().executeQuery(sql1);
+            rs1.next();
+            patientName = rs1.getString("PatientName");
+
+        } catch (SQLException ex) {
+            Logger.getLogger(DatabaseHandler.class.getName()).log(Level.SEVERE, null, ex);
+        }
+        return patientName;
+    }
+
+    /** It checks the particular record exists or not. */
+    public boolean checkRecordExists(String tablename, String fieldname,
+            String compareWith) {
+        ResultSet rs = null;
+        boolean result = false;
+        try {
+            rs = conn.createStatement().executeQuery("select count(" + fieldname + ") from " + tablename + " where " + fieldname + " = '" + compareWith.trim() + "'");
+            rs.next();
+            if (rs.getInt(1) > 0) {
+                return true;
+            } else {
+                return false;
+            }
+        } catch (SQLException e) {
+            StringWriter str = new StringWriter();
+            e.printStackTrace(new PrintWriter(str));
+            return false;
+        }
+    }
+
+    public void writeDataToDatabase(DicomObject dataset) {
+        insertPatientData(dataset);
+        insertStudyData(dataset, false);
+        insertSeriesData(dataset);
+        insertImageData(dataset);
+    }
+
+    public void importDataToDatabase(DicomObject dataset, File dicomFile, boolean saveAsLink) {
+        insertPatientData(dataset);
+        insertStudyData(dataset, saveAsLink);
+        insertSeriesData(dataset);
+        insertImageData(dataset, dicomFile);
+    }
+
+    public void insertPatientData(DicomObject dataset) {
+        if (checkRecordExists(patientTable, "PatientId", dataset.getString(Tag.PatientID))) {
+        } else {
+            try {
+                String dat = null;
+                if ((dataset.getString(Tag.PatientBirthDate) != null) && dataset.getString(Tag.PatientBirthDate).length() > 0) {
+                    dat = (dataset.getDate(Tags.PatientBirthDate) != null) ? dateFormat.format(dataset.getDate(Tags.PatientBirthDate)) : "";
+                }
+                PreparedStatement prepareStatement = conn.prepareStatement("insert into " + patientTable + " values(?,?,?,?)");
+                prepareStatement.setString(1, dataset.getString(Tag.PatientID));
+                prepareStatement.setString(2, dataset.getString(Tag.PatientName));
+                prepareStatement.setString(3, dat);
+                prepareStatement.setString(4, dataset.getString(Tag.PatientSex));
+                prepareStatement.execute();
+                conn.commit();
+            } catch (SQLException ex) {
+                Logger.getLogger(DatabaseHandler.class.getName()).log(Level.SEVERE, null, ex);
+            }
+        }
+    }
+
+    public void insertStudyData(DicomObject dataset, boolean saveAslink) {
+        if (checkRecordExists(studyTable, "StudyInstanceUID", dataset.getString(Tag.StudyInstanceUID))) {
+        } else {
+            try {
+                String dat = "null";
+                String accessionno = "null";
+                String refName = "null";
+                int noSeries = 0;
+                int noInstance = 0;
+                String retAe = "null";
+                String studyDescription = "null";
+                if ((dataset.getString(Tag.StudyDate) != null) && dataset.getString(Tag.StudyDate).length() > 0) {
+                    dat = "date('" + dateFormat.format(dataset.getDate(Tag.StudyDate)) + "')";
+                }
+                if (dataset.getString(Tag.AccessionNumber) != null && dataset.getString(Tag.AccessionNumber).length() > 0) {
+                    accessionno = dataset.getString(Tag.AccessionNumber);
+                }
+                if (dataset.getString(Tag.ReferringPhysicianName) != null && dataset.getString(Tag.ReferringPhysicianName).length() > 0) {
+                    refName = dataset.getString(Tag.ReferringPhysicianName);
+                }
+                if (dataset.getString(Tag.NumberOfStudyRelatedSeries) != null && dataset.getString(Tag.NumberOfStudyRelatedSeries).length() > 0) {
+                    noSeries = Integer.parseInt(dataset.getString(Tag.NumberOfStudyRelatedSeries));
+                }
+                if (dataset.getString(Tag.NumberOfStudyRelatedInstances) != null && dataset.getString(Tag.NumberOfStudyRelatedInstances).length() > 0) {
+                    noInstance = Integer.parseInt(dataset.getString(Tag.NumberOfStudyRelatedInstances));
+                }
+                if (dataset.getString(Tag.StudyDescription) != null && dataset.getString(Tag.StudyDescription).length() > 0) {
+                    studyDescription = dataset.getString(Tag.StudyDescription);
+                }
+                String studyType = "local";
+                if (saveAslink) {
+                    studyType = "link";
+                }
+                conn.createStatement().execute("insert into " + studyTable + " values('" + dataset.getString(Tag.StudyInstanceUID) + "'," + dat + ",'" + accessionno + "','" + refName + "','" + studyDescription.replace('\'', ' ') + "','" + dataset.getString(Tag.Modality) + "'," + noSeries + "," + noInstance + "," + 0 + "," + 1 + ",'" + retAe + "','" + studyType + "','" + dataset.getString(Tag.PatientID) + "')");
+                conn.commit();
+            } catch (SQLException ex) {
+                Logger.getLogger(DatabaseHandler.class.getName()).log(Level.SEVERE, null, ex);
+            }
+        }
+    }
+
+    public void deleteCopyAsLinkStudies() {
+        try {
+            String sql = "Select StudyInstanceUID from " + studyTable + " where studytype='link'";
+            ResultSet rs = conn.createStatement().executeQuery(sql);
+            while (rs.next()) {
+                String studyUID = rs.getString("StudyInstanceUID");
+                String sql1 = "select SeriesInstanceUID from series where StudyInstanceUID='" + studyUID + "'";
+                ResultSet rs1 = conn.createStatement().executeQuery(sql1);
+                while (rs1.next()) {
+                    String sql2 = "select SopUID from image where StudyInstanceUID='" + studyUID + "' AND " + "SeriesInstanceUID='" + rs1.getString("SeriesInstanceUID") + "'";
+                    ResultSet rs2 = conn.createStatement().executeQuery(sql2);
+                    while (rs2.next()) {
+                        instanceTableRowDelete(rs2.getString("SopUID"));
+                    }
+                    seriesTableRowDelete(rs1.getString("SeriesInstanceUID"));
+                }
+                studyTableRowDelete(studyUID);
+            }
+            SwingUtilities.invokeLater(new Runnable() {
+
+                public void run() {
+                    MainScreen.refreshLocalDBStorage();
+                }
+            });
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void insertSeriesData(DicomObject dataset) {
+        if (checkRecordExists(seriesTable, "SeriesInstanceUID", dataset.getString(Tag.SeriesInstanceUID))) {
+        } else {
+            try {
+                String dat = "null";
+                int noSeries = 0;
+                String institution = "null";
+                String seriesNo = "null";
+                String modality = "null";
+                String studyDesc = "null";
+                String bodyPartExamined = "null";
+                if (dataset.getString(Tag.SeriesDate) != null && dataset.getString(Tag.SeriesDate).length() > 0) {
+                    dat = "date('" + dateFormat.format(dataset.getDate(Tag.SeriesDate)) + "')";
+                }
+                if (dataset.getString(Tag.NumberOfSeriesRelatedInstances) != null && dataset.getString(Tag.NumberOfSeriesRelatedInstances).length() > 0) {
+                    noSeries = Integer.parseInt(dataset.getString(Tag.NumberOfSeriesRelatedInstances));
+                }
+                if (dataset.getString(Tag.InstitutionName) != null && dataset.getString(Tag.InstitutionName).length() > 0) {
+                    institution = dataset.getString(Tag.InstitutionName).replace('\'', ' ');
+                }
+                if (dataset.getString(Tag.SeriesNumber) != null && dataset.getString(Tag.SeriesNumber).length() > 0) {
+                    seriesNo = dataset.getString(Tag.SeriesNumber);
+                }
+                if (dataset.getString(Tag.Modality) != null && dataset.getString(Tag.Modality).length() > 0) {
+                    modality = dataset.getString(Tag.Modality);
+                }
+                if (dataset.getString(Tag.SeriesDescription) != null && dataset.getString(Tag.SeriesDescription).length() > 0) {
+                    studyDesc = dataset.getString(Tag.SeriesDescription).replace('\'', ' ');
+                }
+                if (dataset.getString(Tag.BodyPartExamined) != null && dataset.getString(Tag.BodyPartExamined).length() > 0) {
+                    bodyPartExamined = dataset.getString(Tag.BodyPartExamined).replace('\'', ' ');
+                }
+                conn.createStatement().execute("insert into " + seriesTable + " values('" + dataset.getString(Tag.SeriesInstanceUID) + "','" + seriesNo + "','" + modality + "','" + studyDesc + "','" + bodyPartExamined + "','" + institution + "'," + noSeries + ",'" + dataset.getString(Tag.PatientID) + "','" + dataset.getString(Tag.StudyInstanceUID) + "')");
+                conn.commit();
+            } catch (SQLException ex) {
+                Logger.getLogger(DatabaseHandler.class.getName()).log(Level.SEVERE, null, ex);
+            }
+        }
+        SwingUtilities.invokeLater(new Runnable() {
+
+            public void run() {
+                MainScreen.refreshLocalDBStorage();
+            }
+        });
+    }
+
+    public void insertImageData(DicomObject dataset) {
+        if (checkRecordExists(instanceTable, "SopUID", dataset.getString(Tag.SOPInstanceUID))) {
+        } else {
+            try {
+                Calendar today = Calendar.getInstance();
+                String struturedDestination = ApplicationContext.getAppDirectory() + File.separator + "archive" + File.separator + today.get(Calendar.YEAR) + File.separator + today.get(Calendar.MONTH) + File.separator + today.get(Calendar.DATE) + File.separator + dataset.getString(Tag.StudyInstanceUID) + File.separator + dataset.getString(Tag.SOPInstanceUID);
+                String multiframe = "false";
+                int totalFrame = 0;
+                boolean encapsulatedPDF = false;
+                if (dataset.getString(Tags.SOPClassUID).equalsIgnoreCase("1.2.840.10008.5.1.4.1.1.104.1")) {
+                    encapsulatedPDF = true;
+                }
+                if (dataset.getString(Tags.NumberOfFrames) != null && Integer.parseInt(dataset.getString(Tags.NumberOfFrames)) > 1) {
+                    multiframe = "true";
+                    totalFrame = Integer.parseInt(dataset.getString(Tags.NumberOfFrames));
+                }
+                String sliceLocation = (dataset.getString(Tags.SliceLocation) != null) ? dataset.getString(Tags.SliceLocation) : "100000";
+                conn.createStatement().execute("insert into " + instanceTable + " values('" + dataset.getString(Tag.SOPInstanceUID) + "'," + dataset.getInt(Tag.InstanceNumber) + ",'" + multiframe + "','" + totalFrame + "','" + "partial" + "','" + " " + "','" + " " + "','" + "partial" + "','" + struturedDestination + "'," + sliceLocation + ",'" + encapsulatedPDF + "','" + dataset.getString(Tag.PatientID) + "','" + dataset.getString(Tag.StudyInstanceUID) + "','" + dataset.getString(Tag.Ser [...]
+                conn.commit();
+                int receivedCount = this.getReceiveCount(dataset.getString(Tag.StudyInstanceUID));
+                receivedCount = receivedCount + 1;
+                this.update("study", "RecdImgCnt", receivedCount, "StudyInstanceUID", dataset.getString(Tag.StudyInstanceUID));
+            } catch (Exception ex) {
+                ex.printStackTrace();
+            }
+        }
+    }
+
+    public void insertImageData(DicomObject dataset, File dicomFile) {
+        if (checkRecordExists(instanceTable, "SopUID", dataset.getString(Tag.SOPInstanceUID))) {
+        } else {
+            try {
+                Calendar today = Calendar.getInstance();
+                String struturedDestination = dicomFile.getAbsolutePath();
+                String multiframe = "false";
+                int totalFrame = 0;
+                boolean encapsulatedPDF = false;
+                if (dataset.getString(Tags.SOPClassUID).equalsIgnoreCase("1.2.840.10008.5.1.4.1.1.104.1")) {
+                    encapsulatedPDF = true;
+                }
+                if (dataset.getString(Tags.NumberOfFrames) != null && Integer.parseInt(dataset.getString(Tags.NumberOfFrames)) > 1) {
+                    multiframe = "true";
+                    totalFrame = Integer.parseInt(dataset.getString(Tags.NumberOfFrames));
+                }
+                String sliceLocation = (dataset.getString(Tags.SliceLocation) != null) ? dataset.getString(Tags.SliceLocation) : "100000";
+                conn.createStatement().execute("insert into " + instanceTable + " values('" + dataset.getString(Tag.SOPInstanceUID) + "'," + dataset.getInt(Tag.InstanceNumber) + ",'" + multiframe + "','" + totalFrame + "','" + "partial" + "','" + " " + "','" + " " + "','" + "partial" + "','" + struturedDestination + "'," + sliceLocation + ",'" + encapsulatedPDF + "','" + dataset.getString(Tag.PatientID) + "','" + dataset.getString(Tag.StudyInstanceUID) + "','" + dataset.getString(Tag.Ser [...]
+                conn.commit();
+                int receivedCount = this.getReceiveCount(dataset.getString(Tag.StudyInstanceUID));
+                receivedCount = receivedCount + 1;
+                this.update("study", "RecdImgCnt", receivedCount, "StudyInstanceUID", dataset.getString(Tag.StudyInstanceUID));
+            } catch (Exception ex) {
+                ex.printStackTrace();
+            }
+        }
+    }
+
+    public Object[] retrieveAEList() {
+        Object Root[];
+        ArrayList list = new ArrayList();
+        try {
+            String sql = "Select * from AE";
+            ResultSet rs = conn.createStatement().executeQuery(sql);
+            while (rs.next()) {
+                Object[] value = {rs.getString("logicalname")};
+                list.add(value);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        Root = list.toArray();
+        return Root;
+    }
+
+    public Object[] retrieveAEListWithHeader() {
+        Object Root[];
+        ArrayList list = new ArrayList();
+        list.add(DicomServersHeaderDisplayName);
+        try {
+            String sql = "Select * from AE";
+            ResultSet rs = conn.createStatement().executeQuery(sql);
+            while (rs.next()) {
+                Object[] value = {rs.getString("logicalname")};
+                list.add(value);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        Root = list.toArray();
+        return Root;
+    }
+
+    public AEModel getServerDetail(String serverName) {
+        AEModel ae = null;
+        try {
+            String sql = "Select * from AE where logicalname='" + serverName + "'";
+            ResultSet rs = conn.createStatement().executeQuery(sql);
+            while (rs.next()) {
+                ae = new AEModel(rs.getString("logicalname"), rs.getString("hostname"), rs.getString("aetitle"), rs.getInt("port"), rs.getString("retrievetype"));
+            }
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+        return ae;
+
+    }
+
+    public ArrayList getPresets() {
+        ArrayList presetList = new ArrayList();
+        presetList.add(getNonePreset());
+        try {
+            String sql = "select * from preset";
+            ResultSet rs = conn.createStatement().executeQuery(sql);
+            while (rs.next()) {
+                PresetModel presetModel = new PresetModel();
+                presetModel.setPresetName(rs.getString("presetname"));
+                presetModel.setWindowWidth(rs.getString("windowwidth"));
+                presetModel.setWindowLevel(rs.getString("windowlevel"));
+                presetList.add(presetModel);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return presetList;
+    }
+
+    private PresetModel getNonePreset() {
+        PresetModel presetModel = new PresetModel();
+        presetModel.setPresetName("Default");
+        return presetModel;
+    }
+
+    public ServerModel getServerModel(String serverName) {
+        ServerModel serverModel = null;
+        try {
+            String sql = "Select * from AE where logicalname='" + serverName + "'";
+            ResultSet rs = conn.createStatement().executeQuery(sql);
+            while (rs.next()) {
+                serverModel = new ServerModel(rs.getString("logicalname"), rs.getString("hostname"), rs.getString("aetitle"), rs.getInt("port"), rs.getString("retrievetype"), rs.getString("wadocontext"), rs.getInt("wadoport"), rs.getString("wadoprotocol"), rs.getString("retrievets"));
+            }
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+        return serverModel;
+
+    }
+
+    public PresetModel getPreset(String presetName) {
+        PresetModel presetModel = null;
+        try {
+            String sql = "select * from preset where presetname='" + presetName + "'";
+            ResultSet rs = conn.createStatement().executeQuery(sql);
+            rs.next();
+            presetModel = new PresetModel();
+            presetModel.setPk(rs.getInt("pk"));
+            presetModel.setPresetName(rs.getString("presetname"));
+            presetModel.setWindowLevel(rs.getString("windowlevel"));
+            presetModel.setWindowWidth(rs.getString("windowwidth"));
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return presetModel;
+    }
+
+    public ArrayList getFirstInstanceListFromMultipleStudies(String[] studies) {
+        ArrayList fileArray = new ArrayList();
+        for (int i = 0; i < studies.length; i++) {
+            fileArray.add(((ArrayList) this.getUrlBasedOnStudyIUID(studies[i])).get(0));
+        }
+        return fileArray;
+
+    }
+
+    public ArrayList getUrlBasedOnStudyIUID(String siuid) {
+        ArrayList fileArray = new ArrayList();
+        if (ApplicationContext.databaseRef.getMultiframeStatus()) {
+            fileArray = getUrlBasedOnStudyIUID_SepMulti(siuid);
+        } else {
+            fileArray = getUrlBasedOnStudyIUID_Normal(siuid);
+        }
+        return fileArray;
+    }
+
+    public ArrayList getUrlBasedOnStudyIUID_Normal(String siuid) {
+
+        ArrayList fileArray = new ArrayList();
+        try {
+            int i = 0;
+            String sql = "select SeriesInstanceUID from series where StudyInstanceUID='" + siuid + "'";
+            ResultSet rs = null;
+            rs = conn.createStatement().executeQuery(sql);
+            while (rs.next()) {
+                ResultSet rs1 = null;
+                String sql1 = "select FileStoreUrl from image where StudyInstanceUID='" + siuid + "' AND " + "SeriesInstanceUID='" + rs.getString("SeriesInstanceUID") + "'" + " order by InstanceNo asc";
+                rs1 = conn.createStatement().executeQuery(sql1);
+                File imageUrl = null;
+                if (rs1.next()) {
+                    imageUrl = new File(rs1.getString("FileStoreUrl"));
+                }
+                fileArray.add(imageUrl);
+            }
+        } catch (SQLException ex) {
+            Logger.getLogger(DatabaseHandler.class.getName()).log(Level.SEVERE, null, ex);
+        }
+        return fileArray;
+    }
+
+    public ArrayList getUrlBasedOnStudyIUID_SepMulti(String siuid) {
+
+        ArrayList fileArray = new ArrayList();
+        try {
+            int i = 0;
+            String sql = "select SeriesInstanceUID from series where StudyInstanceUID='" + siuid + "'";
+            ResultSet rs = null;
+            rs = conn.createStatement().executeQuery(sql);
+            while (rs.next()) {
+                ResultSet rs1 = null;
+                ResultSet rs2 = null;
+                String sql1 = "select FileStoreUrl from image where StudyInstanceUID='" + siuid + "' AND " + "SeriesInstanceUID='" + rs.getString("SeriesInstanceUID") + "'" + "AND " + "multiframe='false'" + " order by InstanceNo asc";
+                String sql2 = "select FileStoreUrl from image where StudyInstanceUID='" + siuid + "' AND " + "SeriesInstanceUID='" + rs.getString("SeriesInstanceUID") + "'" + "AND " + "multiframe='true'";
+                rs1 = conn.createStatement().executeQuery(sql1);
+                if (rs1.next()) {
+                    File imageUrl = new File(rs1.getString("FileStoreUrl"));
+                    fileArray.add(imageUrl);
+                }
+                rs2 = conn.createStatement().executeQuery(sql2);
+                while (rs2.next()) {
+                    File imageUrl = new File(rs2.getString("FileStoreUrl"));
+                    fileArray.add(imageUrl);
+                }
+            }
+        } catch (SQLException ex) {
+            Logger.getLogger(DatabaseHandler.class.getName()).log(Level.SEVERE, null, ex);
+        }
+        return fileArray;
+    }
+
+    public ArrayList getUrlBasedOnStudyAndSeriesUID(String studyUID, String seriesUID) {
+        ArrayList fileArray = new ArrayList();
+        try {
+            ResultSet rs1 = null;
+            String sql1 = "select FileStoreUrl from image where StudyInstanceUID='" + studyUID + "' AND " + "SeriesInstanceUID='" + seriesUID + "'";
+            rs1 = conn.createStatement().executeQuery(sql1);
+            while (rs1.next()) {
+                File imageUrl = new File(rs1.getString("FileStoreUrl"));
+                fileArray.add(imageUrl);
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return fileArray;
+    }
+
+    public ArrayList<Series> getSeriesList(String siuid) {
+        ArrayList<Series> arr = new ArrayList();
+        if (ApplicationContext.databaseRef.getMultiframeStatus()) {
+            arr = getSeriesList_SepMulti(siuid);
+        } else {
+            arr = getSeriesList_Normal(siuid);
+        }
+        return arr;
+    }
+
+    public ArrayList<Series> getSeriesList_Normal(String siuid) {
+        ArrayList<Series> arr = new ArrayList();
+        try {
+            String sql = "select SeriesInstanceUID,SeriesNo,SeriesDescription,BodyPartExamined from series where StudyInstanceUID='" + siuid + "'";
+            ResultSet rs = null;
+            rs = conn.createStatement().executeQuery(sql);
+            while (rs.next()) {
+                int seriesLevelIndex = 0;
+                Series series = new Series();
+                series.setStudyInstanceUID(siuid);
+                series.setSeriesInstanceUID(rs.getString("SeriesInstanceUID"));
+                series.setSeriesNumber(rs.getString("SeriesNo"));
+                series.setSeriesDesc(rs.getString("SeriesDescription"));
+                series.setBodyPartExamined(rs.getString("BodyPartExamined"));
+                ResultSet rs1 = null;
+                String sql1 = "select FileStoreUrl,SopUID,InstanceNo,multiframe,totalframe from image where StudyInstanceUID='" + siuid + "' AND " + "SeriesInstanceUID='" + rs.getString("SeriesInstanceUID") + "'" + " order by InstanceNo asc";
+                rs1 = conn.createStatement().executeQuery(sql1);
+                while (rs1.next()) {
+                    int totalFrames = Integer.parseInt(rs1.getString("totalFrame"));
+                    int tempi = 0;
+                    seriesLevelIndex++;
+                    do {
+                        Instance img = new Instance();
+                        img.setFilepath(rs1.getString("FileStoreUrl"));
+                        img.setSop_iuid(rs1.getString("SopUID"));
+                        img.setInstance_no(rs1.getString("InstanceNo"));
+                        img.setMultiframe(new Boolean(rs1.getString("multiframe")));
+                        img.setCurrentFrameNum(tempi);
+                        img.setTotalNumFrames(totalFrames);
+                        img.setSeriesLevelIndex(seriesLevelIndex);
+                        series.getImageList().add(img);
+                        tempi++;
+                    } while (tempi < totalFrames);
+                }
+                arr.add(series);
+            }
+        } catch (SQLException ex) {
+            Logger.getLogger(DatabaseHandler.class.getName()).log(Level.SEVERE, null, ex);
+        }
+        return arr;
+    }
+
+    public ArrayList<Series> getSeriesList_SepMulti(String siuid) {
+        ArrayList<Series> arr = new ArrayList();
+        try {
+            String sql = "select SeriesInstanceUID,SeriesNo,SeriesDescription,BodyPartExamined from series where StudyInstanceUID='" + siuid + "'";
+            ResultSet rs = null;
+            rs = conn.createStatement().executeQuery(sql);
+            while (rs.next()) {
+                Series series = new Series();
+                series.setStudyInstanceUID(siuid);
+                series.setSeriesInstanceUID(rs.getString("SeriesInstanceUID"));
+                series.setSeriesNumber(rs.getString("SeriesNo"));
+                series.setSeriesDesc(rs.getString("SeriesDescription"));
+                series.setBodyPartExamined(rs.getString("BodyPartExamined"));
+                ResultSet rs1 = null;
+                String sql1 = "select FileStoreUrl,totalframe,SopUID,InstanceNo,multiframe,EncapsulatedDocument from image where StudyInstanceUID='" + siuid + "' AND " + "SeriesInstanceUID='" + rs.getString("SeriesInstanceUID") + "'" + "AND multiframe='false'" + " order by InstanceNo asc";
+                rs1 = conn.createStatement().executeQuery(sql1);
+                boolean allInstanceAreMultiframe = true;
+                while (rs1.next()) {
+                    allInstanceAreMultiframe = false;
+                    Instance img = new Instance();
+                    img.setFilepath(rs1.getString("FileStoreUrl"));
+                    img.setSop_iuid(rs1.getString("SopUID"));
+                    img.setInstance_no(rs1.getString("InstanceNo"));
+                    img.setEncapsulatedPDF(rs1.getBoolean("EncapsulatedDocument"));
+                    img.setMultiframe(false);
+                    series.setMultiframe(false);
+                    series.getImageList().add(img);
+                }
+                if (!allInstanceAreMultiframe) {
+                    arr.add(series);
+                }
+                arr.addAll(getMultiframeSeriesList(siuid, series.getSeriesInstanceUID()));
+            }
+        } catch (SQLException ex) {
+            Logger.getLogger(DatabaseHandler.class.getName()).log(Level.SEVERE, null, ex);
+        }
+        return arr;
+    }
+
+    public ArrayList<Series> getMultiframeSeriesList(String studyUID, String seriesUID) {
+        ArrayList<Series> arr = new ArrayList();
+        try {
+            ResultSet rs1 = null;
+            String sql1 = "select FileStoreUrl,totalframe,SopUID,InstanceNo,multiframe,EncapsulatedDocument from image where StudyInstanceUID='" + studyUID + "' AND " + "SeriesInstanceUID='" + seriesUID + "'" + " AND multiframe='true'" + " order by InstanceNo asc";
+            rs1 = conn.createStatement().executeQuery(sql1);
+            while (rs1.next()) {
+                Series series = new Series();
+                series.setStudyInstanceUID(studyUID);
+                series.setSeriesInstanceUID(seriesUID);
+                series.setSeriesDesc("Multiframe: " + rs1.getString("InstanceNo"));
+                series.setMultiframe(true);
+                series.setInstanceUID(rs1.getString("SopUID"));
+                int totalFrames = Integer.parseInt(rs1.getString("totalFrame"));
+                Instance img = new Instance();
+                img.setFilepath(rs1.getString("FileStoreUrl"));
+                img.setTotalNumFrames(totalFrames);
+                img.setSop_iuid(rs1.getString("SopUID"));
+                img.setInstance_no(rs1.getString("InstanceNo"));
+                img.setEncapsulatedPDF(rs1.getBoolean("EncapsulatedDocument"));
+                img.setMultiframe(true);
+                series.getImageList().add(img);
+                arr.add(series);
+            }
+        } catch (SQLException e) {
+            e.printStackTrace();
+        }
+
+        return arr;
+    }
+
+    public Series getSeries(String studyUID, String seriesUID) {
+        Series series = null;
+        try {
+            String sql = "select SeriesInstanceUID,SeriesNo,SeriesDescription,BodyPartExamined from series where StudyInstanceUID='" + studyUID + "' AND " + "SeriesInstanceUID='" + seriesUID + "'";
+            ResultSet rs = null;
+            rs = conn.createStatement().executeQuery(sql);
+            while (rs.next()) {
+                int seriesLevelIndex = 0;
+                series = new Series();
+                series.setStudyInstanceUID(studyUID);
+                series.setSeriesInstanceUID(rs.getString("SeriesInstanceUID"));
+                series.setSeriesNumber(rs.getString("SeriesNo"));
+                series.setSeriesDesc(rs.getString("SeriesDescription"));
+                series.setBodyPartExamined(rs.getString("BodyPartExamined"));
+                ResultSet rs1 = null;
+                String sql1 = "select FileStoreUrl,SopUID,InstanceNo,multiframe,totalframe from image where StudyInstanceUID='" + studyUID + "' AND " + "SeriesInstanceUID='" + rs.getString("SeriesInstanceUID") + "'" + " order by InstanceNo asc";
+                rs1 = conn.createStatement().executeQuery(sql1);
+                while (rs1.next()) {
+                    int totalFrames = Integer.parseInt(rs1.getString("totalFrame"));
+                    int tempi = 0;
+                    seriesLevelIndex++;
+                    do {
+                        Instance img = new Instance();
+                        img.setFilepath(rs1.getString("FileStoreUrl"));
+                        img.setSop_iuid(rs1.getString("SopUID"));
+                        img.setInstance_no(rs1.getString("InstanceNo"));
+                        img.setMultiframe(new Boolean(rs1.getString("multiframe")));
+                        img.setCurrentFrameNum(tempi);
+                        img.setTotalNumFrames(totalFrames);
+                        img.setSeriesLevelIndex(seriesLevelIndex);
+                        series.getImageList().add(img);
+                        tempi++;
+                    } while (tempi < totalFrames);
+
+                }
+            }
+        } catch (SQLException ex) {
+            Logger.getLogger(DatabaseHandler.class.getName()).log(Level.SEVERE, null, ex);
+        }
+        return series;
+    }
+
+    public Series getSeries(String studyUID, String seriesUID, boolean multiframe, String instanceUID) {
+        Series series = null;
+        try {
+            String sql = "select SeriesInstanceUID,SeriesNo,SeriesDescription,BodyPartExamined from series where StudyInstanceUID='" + studyUID + "' AND " + "SeriesInstanceUID='" + seriesUID + "'";
+            ResultSet rs = null;
+            rs = conn.createStatement().executeQuery(sql);
+            while (rs.next()) {
+                series = new Series();
+                series.setStudyInstanceUID(studyUID);
+                series.setSeriesInstanceUID(rs.getString("SeriesInstanceUID"));
+                series.setSeriesDesc(rs.getString("SeriesDescription"));
+                series.setMultiframe(multiframe);
+                ResultSet rs1 = null;
+                String sopUID = "";
+                if (!multiframe) {
+                    sopUID = "SopUID,";
+                }
+
+                String sql1 = "select FileStoreUrl,totalframe," + sopUID + "InstanceNo from image where StudyInstanceUID='" + studyUID + "' AND " + "SeriesInstanceUID='" + rs.getString("SeriesInstanceUID") + "'";
+                if (multiframe) {
+                    sql1 += " AND SopUID='" + instanceUID + "'" + " AND multiframe='" + multiframe + "'" + " order by InstanceNo asc";
+                    series.setInstanceUID(instanceUID);
+                } else {
+                    sql1 += " AND multiframe='" + multiframe + "'" + " order by InstanceNo asc";
+                }
+
+                // sql1+=" order by InstanceNo asc";
+
+                rs1 = conn.createStatement().executeQuery(sql1);
+                while (rs1.next()) {
+                    int totalFrames = Integer.parseInt(rs1.getString("totalFrame"));
+                    Instance img = new Instance();
+                    img.setFilepath(rs1.getString("FileStoreUrl"));
+                    if (!multiframe) {
+                        img.setSop_iuid(rs1.getString("SopUID"));
+                    } else {
+                        img.setSop_iuid(instanceUID);
+                    }
+                    img.setMultiframe(multiframe);
+                    img.setTotalNumFrames(totalFrames);
+                    img.setInstance_no(rs1.getString("InstanceNo"));
+                    series.getImageList().add(img);
+
+                }
+
+            }
+        } catch (SQLException ex) {
+            Logger.getLogger(DatabaseHandler.class.getName()).log(Level.SEVERE, null, ex);
+        }
+        return series;
+    }
+
+    public int getStudyLevelInstance(String siuid) {
+        int size = 0;
+        try {
+            String sql = "select SeriesInstanceUID from series where StudyInstanceUID='" + siuid + "'";
+            ResultSet rs = null;
+            rs = conn.createStatement().executeQuery(sql);
+            while (rs.next()) {
+                ResultSet rs1 = null;
+                String sql1 = "select count(*) from image where StudyInstanceUID='" + siuid + "' AND " + "SeriesInstanceUID='" + rs.getString("SeriesInstanceUID") + "'";
+                rs1 = conn.createStatement().executeQuery(sql1);
+                rs1.next();
+                size = size + rs1.getInt(1);
+            }
+        } catch (Exception ex) {
+            Logger.getLogger(DatabaseHandler.class.getName()).log(Level.SEVERE, null, ex);
+        }
+        return size;
+    }
+
+    public String getStudyDescBasedOnStudyUID(String studyUID) {
+        String studyDesc = "";
+        try {
+            String sql = "select studyDesc from Study where StudyInstanceUID='" + studyUID + "'";
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return studyDesc;
+    }
+
+    public String getSeriesDesc(String studyUID, String seriesUID) {
+        String seriesDesc = "";
+        try {
+            String sql = "select SeriesDescription from Series where StudyInstanceUID='" + studyUID + "'" + "SeriesInstanceUID='" + seriesUID + "'";
+            ResultSet rs = conn.createStatement().executeQuery(sql);
+            rs.next();
+            seriesDesc = rs.getString("SeriesDescription");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return seriesDesc;
+    }
+
+    public int getSeriesLevelInstance(String studyuid, String seriesuid) {
+        int size = 0;
+        try {
+            String sql1 = "";
+            if (ApplicationContext.databaseRef.getMultiframeStatus()) {
+                sql1 = "select count(*) from image where StudyInstanceUID='" + studyuid + "' AND " + "SeriesInstanceUID='" + seriesuid + "'" + " AND multiframe='false'";
+            } else {
+                sql1 = "select count(*) from image where StudyInstanceUID='" + studyuid + "' AND " + "SeriesInstanceUID='" + seriesuid + "'";
+            }
+
+            ResultSet rs = conn.createStatement().executeQuery(sql1);
+            rs.next();
+            size = rs.getInt(1);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return size;
+    }
+
+    public boolean isSeriesHasInstance(String seriesuid) {
+        boolean hasInstance = true;
+        try {
+            String sql1 = "";
+            sql1 = "select count(*) from image where SeriesInstanceUID='" + seriesuid + "'";
+
+            ResultSet rs = conn.createStatement().executeQuery(sql1);
+            rs.next();
+            int size = rs.getInt(1);
+            if (size > 0) {
+                hasInstance = true;
+            } else {
+                hasInstance = false;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return hasInstance;
+
+    }
+
+    /**
+     * It updates the particular field on  table.
+     */
+    public void update(String tablename, String fieldname, String fieldvalue, String whereField, String whereValue) {
+        try {
+            int value = conn.createStatement().executeUpdate("update " + tablename + " set " + fieldname + "='" + fieldvalue + "' where " + whereField + "='" + whereValue + "'");
+        } catch (SQLException e) {
+            StringWriter str = new StringWriter();
+            e.printStackTrace(new PrintWriter(str));
+        }
+    }
+
+    public void update(String tablename, String fieldname, int fieldvalue, String whereField, String whereValue) {
+        try {
+            int value = conn.createStatement().executeUpdate("update " + tablename + " set " + fieldname + "=" + fieldvalue + " where " + whereField + "='" + whereValue + "'");
+        } catch (SQLException e) {
+            StringWriter str = new StringWriter();
+            e.printStackTrace(new PrintWriter(str));
+        }
+    }
+
+    /**
+     * It deletes all rows in patient,study,series and image.
+     */
+    public void deleteRows() {
+        try {
+            if (statement == null) {
+                statement = conn.createStatement();
+            }
+            statement.execute("delete from " + instanceTable);
+            statement.execute("delete from " + seriesTable);
+            statement.execute("delete from " + studyTable);
+            statement.execute("delete from " + patientTable);
+            conn.commit();
+        } catch (SQLException e) {
+            StringWriter str = new StringWriter();
+            e.printStackTrace(new PrintWriter(str));
+        }
+    }
+
+    public void instanceTableRowDelete(String instanceUID) {
+        try {
+            String sql = "delete from image where SopUID='" + instanceUID + "'";
+            conn.createStatement().execute(sql);
+            conn.commit();
+        } catch (SQLException ex) {
+            Logger.getLogger(DatabaseHandler.class.getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+
+    public void seriesTableRowDelete(String seriesUID) {
+        try {
+            if (!isSeriesHasInstance(seriesUID)) {
+                String sql = "delete from series where SeriesInstanceUID='" + seriesUID + "'";
+                conn.createStatement().execute(sql);
+                conn.commit();
+            }
+        } catch (SQLException ex) {
+            Logger.getLogger(DatabaseHandler.class.getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+
+    public void studyTableRowDelete(String studyUID) {
+        try {
+            String sql = "delete from study where StudyInstanceUID='" + studyUID + "'";
+            conn.createStatement().execute(sql);
+            conn.commit();
+        } catch (SQLException ex) {
+            Logger.getLogger(DatabaseHandler.class.getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+
+    public void dropTables() {
+        try {
+            statement.execute("drop table " + instanceTable);
+            statement.execute("drop table " + seriesTable);
+            statement.execute("drop table " + studyTable);
+            statement.execute("drop table " + patientTable);
+            statement.execute("drop table ae");
+            statement.execute("drop table listener");
+            statement.execute("drop table preset");
+            statement.execute("drop table layout");
+            statement.execute("drop table modality");
+            conn.commit();
+        } catch (SQLException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void resetStudyDB() {
+        try {
+            statement.execute("drop table " + instanceTable);
+            statement.execute("drop table " + seriesTable);
+            statement.execute("drop table " + studyTable);
+            statement.execute("drop table " + patientTable);
+            conn.commit();
+
+        } catch (SQLException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public String getSendStatus(String studyIUID) {
+        String status = null;
+        try {
+            String str = "select sendstatus "
+                    + "from study where studyinstanceuid='" + studyIUID + "'";
+            ResultSet rs = conn.createStatement().executeQuery(str);
+            while (rs.next()) {
+                status = rs.getString("sendstatus");
+            }
+        } catch (SQLException e) {
+            StringWriter str = new StringWriter();
+            e.printStackTrace(new PrintWriter(str));
+            str = null;
+        }
+        return status;
+    }
+
+    public int getSendCount(String studyIUID) {
+        int count = 0;
+        try {
+            String str = "select SendImgCnt "
+                    + "from study where StudyInstanceUID='" + studyIUID + "'";
+            ResultSet rs = conn.createStatement().executeQuery(str);
+            while (rs.next()) {
+                count = rs.getInt("SendImgCnt");
+            }
+        } catch (SQLException e) {
+            StringWriter str = new StringWriter();
+            e.printStackTrace(new PrintWriter(str));
+            str = null;
+        }
+        return count;
+    }
+
+    public String getReceiveStatus(String studyIUID) {
+        String status = null;
+        try {
+            String str = "select receivestatus "
+                    + "from study where studyinstanceuid='" + studyIUID + "'";
+            ResultSet rs = conn.createStatement().executeQuery(str);
+            while (rs.next()) {
+                status = rs.getString("receivestatus");
+            }
+        } catch (SQLException e) {
+            StringWriter str = new StringWriter();
+            e.printStackTrace(new PrintWriter(str));
+            str = null;
+        }
+        return status;
+    }
+
+    public int getReceiveCount(String studyIUID) {
+        int count = 0;
+        try {
+            String str = "select RecdImgCnt "
+                    + "from study where StudyInstanceUID='" + studyIUID + "'";
+            ResultSet rs = conn.createStatement().executeQuery(str);
+            while (rs.next()) {
+                count = rs.getInt("RecdImgCnt");
+            }
+        } catch (Exception e) {
+            StringWriter str = new StringWriter();
+            e.printStackTrace(new PrintWriter(str));
+            str = null;
+        }
+        return count;
+    }
+
+    public void doCreateServerRecords(String serverName, String host, String aeTitle, int port) {
+        try {
+            String sql = "insert into AE(logicalname,hostname,aetitle,port)values('" + serverName + "','" + host + "','" + aeTitle + "'," + port + ")";
+            boolean b = conn.createStatement().execute(sql);
+            conn.commit();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void doEditServerRecords(String serverName, String host, String aeTitle, int port, String keyName) {
+        try {
+            String getPKSql = "select pk from ae where logicalname='" + keyName + "'";
+
+            ResultSet rs = conn.createStatement().executeQuery(getPKSql);
+            while (rs.next()) {
+                String pk = rs.getString("pk");
+                String sql = "update AE SET logicalname='" + serverName + "',hostname='" + host + "',aetitle='" + aeTitle + "',port=" + port + "where pk=" + pk;
+                int n = conn.createStatement().executeUpdate(sql);
+            }
+            conn.commit();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void doDeleteRecords(String serverName) {
+        try {
+            String sql = "delete from ae where logicalname='" + serverName + "'";
+            boolean b = conn.createStatement().execute(sql);
+            conn.commit();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public int getInstaneNumberBasedOnSliceLocation(String studyUID, String seriesUID, String instanceUID, String sliceLocation) {
+        int instanceNumber = -1;
+        try {
+            double sliceLocTemp = 0;
+            if (sliceLocation != null && !sliceLocation.equalsIgnoreCase("")) {
+                sliceLocTemp = Double.parseDouble(sliceLocation);
+            }
+            String sql = "select instanceNo from image where StudyInstanceUID='" + studyUID + "' and SeriesInstanceUID='" + seriesUID + "' and SliceLocation between " + (sliceLocTemp - 0.5) + " and " + (sliceLocTemp + 0.5);
+            ResultSet rs = conn.createStatement().executeQuery(sql);
+            while (rs.next()) {
+                instanceNumber = rs.getInt("instanceNo");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return instanceNumber;
+    }
+
+    public ArrayList getStudyUIDBasedOnPatientName(String patientName) {
+        ArrayList<Study> studyList = new ArrayList<Study>();
+        try {
+            String getIDSql = "select PatientId from patient where patientName='" + patientName + "'";
+            ResultSet rs = conn.createStatement().executeQuery(getIDSql);
+            while (rs.next()) {
+                String id = rs.getString("PatientId");
+                String sql = "select StudyInstanceUID,StudyDescription from study where study.PatientId='" + id + "'";
+                ResultSet rs1 = conn.createStatement().executeQuery(sql);
+                while (rs1.next()) {
+                    Study study = new Study();
+                    study.setStudyInstanceUID(rs1.getString("StudyInstanceUID"));
+                    study.setStudyDesc(rs1.getString("StudyDescription"));
+                    studyList.add(study);
+                }
+            }
+            conn.commit();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return studyList;
+    }
+
+    public static DatabaseHandler getInstance() {
+        DatabaseHandler DatabaseUpdateRef = new DatabaseHandler();
+        return DatabaseUpdateRef;
+    }
+}
diff --git a/src/in/raster/mayam/util/localizer/SliceLocator.java b/src/in/raster/mayam/util/localizer/SliceLocator.java
new file mode 100644
index 0000000..1ff6468
--- /dev/null
+++ b/src/in/raster/mayam/util/localizer/SliceLocator.java
@@ -0,0 +1,584 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.util.localizer;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.6
+ *
+ */
+public class SliceLocator {
+
+    private float _scoutRowCosx = 0;
+    private float _scoutRowCosy = 0;
+    private float _scoutRowCosz = 0;
+    private float _scoutColCosx = 0;
+    private float _scoutColCosy = 0;
+    private float _scoutColCosz = 0;
+    private float _scoutx = 0;
+    private float _scouty = 0;
+    private float _scoutz = 0;
+    private float _imgRowCosx = 0;
+    private float _imgRowCosy = 0;
+    private float _imgRowCosz = 0;
+    private float _imgColCosx = 0;
+    private float _imgColCosy = 0;
+    private float _imgColCosz = 0;
+    private float _imgx = 0;
+    private float _imgy = 0;
+    private float _imgz = 0;
+    private float _nrmCosX = 0;
+    private float _nrmCosY = 0;
+    private float _nrmCosZ = 0;
+    private float _scoutxSpacing = 0;
+    private float _scoutySpacing = 0;
+    private float _imgxSpacing = 0;
+    private float _imgySpacing = 0;
+    private boolean _scoutValid = false;
+    private boolean _imgValid = false;
+    private float _scoutPosX = 0;
+    private float _scoutPosY = 0;
+    private float _scoutPosZ = 0;
+    private float _scoutRowLen = 0;
+    private float _scoutColLen = 0;
+    private float _scoutRows = 0;
+    private float _scoutCols = 0;
+    private float _imgRowLen = 0;
+    private float _imgColLen = 0;
+    private float _imgRows = 0;
+    private float _imgCols = 0;
+    private float _boxUlx;
+    private float _boxUly;
+    private float _boxUrx;
+    private float _boxUry;
+    private float _boxLrx;
+    private float _boxLry;
+    private float _boxLlx;
+    private float _boxLly;
+    private float _mAxisTopx;
+    private float _mAxisTopy;
+    private float _mAxisRightx;
+    private float _mAxisRighty;
+    private float _mAxisBottomx;
+    private float _mAxisBottomy;
+    private float _mAxisLeftx;
+    private float _mAxisLefty;
+
+    public SliceLocator() {
+    }
+
+    private boolean setScoutPosition(String scoutPosition) {
+        boolean retVal = true;
+        String _scoutPositionArray[];
+        // set the member variables
+        // _mScoutx, _mScouty, _mScoutz to the actual position information
+        // if the input pointer is null or the string is empty set all position to 0 and
+        // set the position valid flag (_mScoutvalid) to false
+        retVal = checkPosString(scoutPosition);
+        if (retVal) {
+            _scoutPositionArray = scoutPosition.split("\\\\");
+            _scoutx = Float.parseFloat(_scoutPositionArray[0]);
+            _scouty = Float.parseFloat(_scoutPositionArray[1]);
+            _scoutz = Float.parseFloat(_scoutPositionArray[2]);
+            _scoutValid = true;
+        } else {
+            // The Pos contains no valid information it is assumed that the sout position is to be clweared of all valid
+            // entries
+            clearScout();
+        }
+        return (retVal);
+    }
+
+    private boolean setScoutOrientation(String scoutOrientation) {
+        boolean retVal;
+        String scoutOrientationArray[];
+        // Scna the sout orientation vactor into the local variables and chack it for validity
+        retVal = checkVectorString(scoutOrientation);
+        if (retVal) {
+            scoutOrientationArray = scoutOrientation.split("\\\\");
+            _scoutRowCosx = Float.parseFloat(scoutOrientationArray[0]);
+            _scoutRowCosy = Float.parseFloat(scoutOrientationArray[1]);
+            _scoutRowCosz = Float.parseFloat(scoutOrientationArray[2]);
+            _scoutColCosx = Float.parseFloat(scoutOrientationArray[3]);
+            _scoutColCosy = Float.parseFloat(scoutOrientationArray[4]);
+            _scoutColCosz = Float.parseFloat(scoutOrientationArray[5]);
+            _scoutValid = checkScoutVector();
+            if (!_scoutValid) {
+                clearScout();
+            }
+        }
+        return (retVal);
+    }
+
+    private void clearScout() {
+        // clear all the scout parameters and set the scout valid flag to false.
+        _scoutRowCosx = 0;
+        _scoutRowCosy = 0;
+        _scoutRowCosz = 0;
+        _scoutColCosx = 0;
+        _scoutColCosy = 0;
+        _scoutColCosz = 0;
+        _scoutx = 0;
+        _scouty = 0;
+        _scoutz = 0;
+        _scoutValid = false;
+    }
+
+    private void clearImg() {
+        // clear all the image prameters and set the image valid flag to false.
+        _imgRowCosx = 0;
+        _imgRowCosy = 0;
+        _imgRowCosz = 0;
+        _imgColCosx = 0;
+        _imgColCosy = 0;
+        _imgColCosz = 0;
+        _imgx = 0;
+        _imgy = 0;
+        _imgz = 0;
+        _imgValid = false;
+    }
+
+    private boolean setImgPosition(String imagePosition) {
+        boolean retVal = true;
+        String _imgPositionArray[];
+        // set the member variables
+        // _mImgx, _mImgy, _mImgz to the actual position information
+        // if the input pointer is null or the string is empty set all position to 0 and
+        // set the position valid flag (_mImgvalid) to false
+        retVal = checkPosString(imagePosition);
+        if (retVal) {
+            // the position information contains valid data.  It has been checked prior to
+            // the activation of theis member function
+            _imgPositionArray = imagePosition.split("\\\\");
+            _imgx = Float.parseFloat(_imgPositionArray[0]);
+            _imgy = Float.parseFloat(_imgPositionArray[1]);
+            _imgz = Float.parseFloat(_imgPositionArray[2]);
+
+            _imgValid = true;
+        } else {
+            // The Pos contains no valid information it is assumed that the sout position is to be clweared of all valid
+            // entries
+            clearImg();
+        }
+        return (retVal);
+    }
+
+    private boolean setImgOrientation(String imageOrientation) {
+        boolean retVal;
+        String imageOrientationArray[];
+        // Scna the sout orientation vactor into the local variables and chack it for validity
+        retVal = checkVectorString(imageOrientation);
+        if (retVal) {
+            imageOrientationArray = imageOrientation.split("\\\\");
+            _imgRowCosx = Float.parseFloat(imageOrientationArray[0]);
+            _imgRowCosy = Float.parseFloat(imageOrientationArray[1]);
+            _imgRowCosz = Float.parseFloat(imageOrientationArray[2]);
+            _imgColCosx = Float.parseFloat(imageOrientationArray[3]);
+            _imgColCosy = Float.parseFloat(imageOrientationArray[4]);
+            _imgColCosz = Float.parseFloat(imageOrientationArray[5]);
+            _imgValid = checkImgVector();
+            if (!_imgValid) {
+                clearImg();
+            }
+        }
+        return (retVal);
+    }
+
+    private boolean checkScoutVector() {
+        boolean retVal;
+
+        // check the row vector and check the column vector
+        retVal = checkVector(_scoutRowCosx, _scoutRowCosy, _scoutRowCosz);
+        retVal = checkVector(_scoutColCosx, _scoutColCosy, _scoutColCosz);
+        return (retVal);
+    }
+
+    private boolean checkImgVector() {
+        boolean retVal;
+        // check the row vector and check the column vector
+        retVal = checkVector(_imgRowCosx, _imgRowCosy, _imgRowCosz);
+        retVal = checkVector(_imgColCosx, _imgColCosy, _imgColCosz);
+        return (retVal);
+
+    }
+
+    private boolean checkPosString(String position) {
+        boolean retVal = true;
+        String[] positionArray;
+        positionArray = position.split("\\\\");
+        for (int i = 0; i < positionArray.length; i++) {
+            if (positionArray[i].matches("((-|\\+)?[0-9]+(\\.[0-9]+)?)+")) {
+                retVal = true;
+            } else {
+                retVal = false;
+            }
+
+        }
+        //I just want to check the existance of the numeric values in the position.
+        return retVal;
+    }
+
+    private boolean checkVectorString(String vector) {
+        boolean retVal = true;
+        String[] vectorArray;
+        vectorArray = vector.split("\\\\");
+        for (int i = 0; i < vectorArray.length; i++) {
+            if (vectorArray[i].matches("((-|\\+)?[0-9]+(\\.[0-9]+)?)+")) {
+                retVal = true;
+            } else {
+                retVal = false;
+            }
+        }
+        //I just want to check the existance of the vector string.
+        return retVal;
+    }
+
+    private boolean checkVector(float CosX, float CosY, float CosZ) {
+        // Check if the vector passed is a unit vector
+        if (Math.abs(CosX * CosX + CosY * CosY + CosZ * CosZ - 1) < 0) {
+            return (false);
+        } else {
+            return (true);
+        }
+    }
+
+    private boolean normalizeScout() {
+        // first create the scout normal vector
+        _nrmCosX = _scoutRowCosy * _scoutColCosz - _scoutRowCosz * _scoutColCosy;
+        _nrmCosY = _scoutRowCosz * _scoutColCosx - _scoutRowCosx * _scoutColCosz;
+        _nrmCosZ = _scoutRowCosx * _scoutColCosy - _scoutRowCosy * _scoutColCosx;
+        return (checkVector(_nrmCosX, _nrmCosY, _nrmCosZ));
+    }
+
+    private boolean setScoutSpacing(String scoutPixelSpacing) {
+        //  Convert the pixelspacing for the scout image and return true if both values are > 0
+        // the pixel spacing is specified in adjacent row/adjacent column spacing
+        // in this code ..xSpacing refers to column spacing
+        String[] scoutPixelSpacingArray;
+        scoutPixelSpacingArray = scoutPixelSpacing.split("\\\\");
+        _scoutxSpacing = Float.parseFloat(scoutPixelSpacingArray[1]);
+        _scoutySpacing = Float.parseFloat(scoutPixelSpacingArray[0]);
+        if (_scoutxSpacing == 0 || _scoutySpacing == 0) {
+            return (false);
+        } else {
+            return (true);
+        }
+    }
+
+    private boolean setImgSpacing(String imgPixelSpacing) {
+        //  Convert the pixelspacing for the Img image and return true if both values are > 0
+        // the pixel spacing is specified in adjacent row/adjacent column spacing
+        // in this code ..xSpacing refers to column spacing
+        String[] imgPixelSpacingArray;
+        imgPixelSpacingArray = imgPixelSpacing.split("\\\\");
+
+        _imgxSpacing = Float.parseFloat(imgPixelSpacingArray[1]);
+        _imgySpacing = Float.parseFloat(imgPixelSpacingArray[0]);
+        if (_imgxSpacing == 0 || _imgySpacing == 0) {
+            return (false);
+        } else {
+            return (true);
+        }
+    }
+
+    private boolean rotateImage(float imgPosx, float imgPosy, float imgPosz) {
+        // projet the pioints passed into the space of the normalized scout image
+
+        _scoutPosX = _scoutRowCosx * imgPosx + _scoutRowCosy * imgPosy + _scoutRowCosz * imgPosz;
+        _scoutPosY = _scoutColCosx * imgPosx + _scoutColCosy * imgPosy + _scoutColCosz * imgPosz;
+        _scoutPosZ = _nrmCosX * imgPosx + _nrmCosY * imgPosy + _nrmCosZ * imgPosz;
+        return (true);
+    }
+
+    private boolean setScoutDimensions() {
+        _scoutRowLen = _scoutRows * _scoutxSpacing;
+        _scoutColLen = _scoutCols * _scoutySpacing;
+        return (true);
+    }
+
+    private boolean setImgDimensions() {
+        _imgRowLen = _imgRows * _imgxSpacing;
+        _imgColLen = _imgCols * _imgySpacing;
+        return (true);
+    }
+
+    private void calculateBoundingBox() {
+        // the four points in 3d space that defines the corners of the bounding box
+        float posX[] = new float[4];
+        float posY[] = new float[4];
+        float posZ[] = new float[4];
+        int rowPixel[] = new int[4];
+        int colPixel[] = new int[4];
+        int i;
+
+        // upper left hand Corner
+        posX[0] = _imgx;
+        posY[0] = _imgy;
+        posZ[0] = _imgz;
+
+        // upper right hand corner
+
+        posX[1] = posX[0] + _imgRowCosx * _imgRowLen;
+        posY[1] = posY[0] + _imgRowCosy * _imgRowLen;
+        posZ[1] = posZ[0] + _imgRowCosz * _imgRowLen;
+
+        // Buttom right hand corner
+
+        posX[2] = posX[1] + _imgColCosx * _imgColLen;
+        posY[2] = posY[1] + _imgColCosy * _imgColLen;
+        posZ[2] = posZ[1] + _imgColCosz * _imgColLen;
+
+        // bottom left hand corner
+
+        posX[3] = posX[0] + _imgColCosx * _imgColLen;
+        posY[3] = posY[0] + _imgColCosy * _imgColLen;
+        posZ[3] = posZ[0] + _imgColCosz * _imgColLen;
+
+        // Go through all four corners
+
+        for (i = 0; i < 4; i++) {
+            // we want to view the source slice from the "point of view" of
+            // the target localizer, i.e. a parallel projection of the source
+            // onto the target
+
+            // do this by imaging that the target localizer is a view port
+            // into a relocated and rotated co-ordinate space, where the
+            // viewport has a row vector of +X, col vector of +Y and normal +Z,
+            // then the X and Y values of the projected target correspond to
+            // row and col offsets in mm from the TLHC of the localizer image !
+
+            // move everything to origin of target
+            posX[i] -= _scoutx;
+            posY[i] -= _scouty;
+            posZ[i] -= _scoutz;
+
+            rotateImage(posX[i], posY[i], posZ[i]);
+            // at this point the position contains the location on the scout image. calculate the pixel position
+            // dicom coordinates are center of pixel 1\1
+            colPixel[i] = (int) (_scoutPosX / _scoutySpacing + 0.5);
+            rowPixel[i] = (int) (_scoutPosY / _scoutxSpacing + 0.5);
+        }
+        //  sort out the column and row pixel coordinates into the bounding box named coordinates
+        //  same order as the position ULC -> URC -> BRC -> BLC
+        _boxUlx = colPixel[0];
+        _boxUly = rowPixel[0];
+        _boxUrx = colPixel[1];
+        _boxUry = rowPixel[1];
+        _boxLrx = colPixel[2];
+        _boxLry = rowPixel[2];
+        _boxLlx = colPixel[3];
+        _boxLly = rowPixel[3];
+    }
+
+    public boolean projectSlice(String scoutPos, String scoutOrient, String scoutPixSpace,
+            int scoutRows,
+            int scoutCols,
+            String imgPos,
+            String imgOrient,
+            String imgPixSpace,
+            int imgRows,
+            int imgCols) {
+
+        boolean retVal = true;
+
+        // Fisrs step check if either the scout or the image has to be updated.
+
+        if (scoutPos != null && scoutOrient != null && scoutPixSpace != null && scoutRows != -1 && scoutCols != -1) {
+            // scout parameters appear to be semi-valid try to update the scout information
+            if (setScoutPosition(scoutPos) && setScoutOrientation(scoutOrient) && setScoutSpacing(scoutPixSpace)) {
+                _scoutRows = scoutRows;
+                _scoutCols = scoutCols;
+                setScoutDimensions();
+                retVal = normalizeScout();
+            }
+        }
+        //  Image and scout information is independent of one and other
+        if (imgPos != null && imgOrient != null && imgPixSpace != null && imgRows != -1 && imgCols != -1) {
+            // Img parameters appear to be semi-valid try to update the Img information
+            if (setImgPosition(imgPos) && setImgOrientation(imgOrient) && setImgSpacing(imgPixSpace)) {
+                _imgRows = imgRows;
+                _imgCols = imgCols;
+                setImgDimensions();
+            }
+        }
+        if (retVal) {
+            // start the calculation of the projected bounding box and the ends of the axes along the sides.
+            calculateBoundingBox();
+            calculateAxisPoints();
+        }
+        return (retVal);
+
+    }
+
+    private void calculateAxisPoints() {
+
+        // the four points in 3d space that defines the corners of the bounding box
+        float posX[] = new float[4];
+        float posY[] = new float[4];
+        float posZ[] = new float[4];
+        int rowPixel[] = new int[4];
+        int colPixel[] = new int[4];
+        int i;
+
+
+        // upper center
+        posX[0] = _imgx + _imgRowCosx * _imgRowLen / 2;
+        posY[0] = _imgy + _imgRowCosy * _imgRowLen / 2;
+        posZ[0] = _imgz + _imgRowCosz * _imgRowLen / 2;
+
+        // right hand center
+
+        posX[1] = _imgx + _imgRowCosx * _imgRowLen + _imgColCosx * _imgColLen / 2;
+        posY[1] = _imgy + _imgRowCosy * _imgRowLen + _imgColCosy * _imgColLen / 2;
+        posZ[1] = _imgz + _imgRowCosz * _imgRowLen + _imgColCosz * _imgColLen / 2;
+
+        // Buttom center
+
+        posX[2] = posX[0] + _imgColCosx * _imgColLen;
+        posY[2] = posY[0] + _imgColCosy * _imgColLen;
+        posZ[2] = posZ[0] + _imgColCosz * _imgColLen;
+
+        // left hand center
+
+        posX[3] = _imgx + _imgColCosx * _imgColLen / 2;
+        posY[3] = _imgy + _imgColCosy * _imgColLen / 2;
+        posZ[3] = _imgz + _imgColCosz * _imgColLen / 2;
+
+        // Go through all four corners
+
+        for (i = 0; i < 4; i++) {
+            // we want to view the source slice from the "point of view" of
+            // the target localizer, i.e. a parallel projection of the source
+            // onto the target
+
+            // do this by imaging that the target localizer is a view port
+            // into a relocated and rotated co-ordinate space, where the
+            // viewport has a row vector of +X, col vector of +Y and normal +Z,
+            // then the X and Y values of the projected target correspond to
+            // row and col offsets in mm from the TLHC of the localizer image !
+
+            // move everything to origin of target
+            posX[i] -= _scoutx;
+            posY[i] -= _scouty;
+            posZ[i] -= _scoutz;
+
+            rotateImage(posX[i], posY[i], posZ[i]);
+            // at this point the position contains the location on the scout image. calculate the pixel position
+            // dicom coordinates are center of pixel 1\1
+            colPixel[i] = (int) (_scoutPosX / _scoutySpacing + 0.5);
+            rowPixel[i] = (int) (_scoutPosY / _scoutxSpacing + 0.5);
+        }
+        // sort out the column and row pixel coordinates into the bounding box axis named coordinates
+        // same order as the position top -> right -> bottom -> left
+        _mAxisTopx = colPixel[0];
+        _mAxisTopy = rowPixel[0];
+        _mAxisRightx = colPixel[1];
+        _mAxisRighty = rowPixel[1];
+        _mAxisBottomx = colPixel[2];
+        _mAxisBottomy = rowPixel[2];
+        _mAxisLeftx = colPixel[3];
+        _mAxisLefty = rowPixel[3];
+
+    }
+
+    public float getBoxLlx() {
+        return _boxLlx;
+    }
+
+    public float getBoxLly() {
+        return _boxLly;
+    }
+
+    public float getBoxLrx() {
+        return _boxLrx;
+    }
+
+    public float getBoxLry() {
+        return _boxLry;
+    }
+
+    public float getBoxUlx() {
+        return _boxUlx;
+    }
+
+    public float getBoxUly() {
+        return _boxUly;
+    }
+
+    public float getBoxUrx() {
+        return _boxUrx;
+    }
+
+    public float getBoxUry() {
+        return _boxUry;
+    }
+
+    public float getmAxisBottomx() {
+        return _mAxisBottomx;
+    }
+
+    public float getmAxisBottomy() {
+        return _mAxisBottomy;
+    }
+
+    public float getmAxisLeftx() {
+        return _mAxisLeftx;
+    }
+
+    public float getmAxisLefty() {
+        return _mAxisLefty;
+    }
+
+    public float getmAxisRightx() {
+        return _mAxisRightx;
+    }
+
+    public float getmAxisRighty() {
+        return _mAxisRighty;
+    }
+
+    public float getmAxisTopx() {
+        return _mAxisTopx;
+    }
+
+    public float getmAxisTopy() {
+        return _mAxisTopy;
+    }
+}
diff --git a/src/in/raster/mayam/util/measurement/Annotation.java b/src/in/raster/mayam/util/measurement/Annotation.java
new file mode 100644
index 0000000..291176d
--- /dev/null
+++ b/src/in/raster/mayam/util/measurement/Annotation.java
@@ -0,0 +1,86 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.util.measurement;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class Annotation implements Serializable{
+
+    private ArrayList<AnnotationObj> line;
+    private ArrayList<AnnotationObj> rect;
+    private ArrayList<AnnotationObj> ellipse;
+
+    //Construct the Annotation object
+    public Annotation() {
+        line = new ArrayList<AnnotationObj>();
+        rect = new ArrayList<AnnotationObj>();
+        ellipse = new ArrayList<AnnotationObj>();
+    }
+
+    public ArrayList<AnnotationObj> getEllipse() {
+        return ellipse;
+    }
+
+    public void setEllipse(ArrayList<AnnotationObj> ellipse) {
+        this.ellipse = ellipse;
+    }
+
+    public ArrayList<AnnotationObj> getLine() {
+        return line;
+    }
+
+    public void setLine(ArrayList<AnnotationObj> line) {
+        this.line = line;
+    }
+
+    public ArrayList<AnnotationObj> getRect() {
+        return rect;
+    }
+
+    public void setRect(ArrayList<AnnotationObj> rect) {
+        this.rect = rect;
+    }
+}
\ No newline at end of file
diff --git a/src/in/raster/mayam/util/measurement/AnnotationObj.java b/src/in/raster/mayam/util/measurement/AnnotationObj.java
new file mode 100644
index 0000000..764c39e
--- /dev/null
+++ b/src/in/raster/mayam/util/measurement/AnnotationObj.java
@@ -0,0 +1,237 @@
+/* ***** BEGIN LICENSE BLOCK *****
+* Version: MPL 1.1/GPL 2.0/LGPL 2.1
+*
+* The contents of this file are subject to the Mozilla Public License Version
+* 1.1 (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+* http://www.mozilla.org/MPL/
+*
+* Software distributed under the License is distributed on an "AS IS" basis,
+* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+* for the specific language governing rights and limitations under the
+* License.
+*
+*
+* The Initial Developer of the Original Code is
+* Raster Images
+* Portions created by the Initial Developer are Copyright (C) 2009-2010
+* the Initial Developer. All Rights Reserved.
+*
+* Contributor(s):
+* Babu Hussain A
+* Meer Asgar Hussain B
+* Prakash J
+* Suresh V
+*
+* Alternatively, the contents of this file may be used under the terms of
+* either the GNU General Public License Version 2 or later (the "GPL"), or
+* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+* in which case the provisions of the GPL or the LGPL are applicable instead
+* of those above. If you wish to allow use of your version of this file only
+* under the terms of either the GPL or the LGPL, and not to allow others to
+* use your version of this file under the terms of the MPL, indicate your
+* decision by deleting the provisions above and replace them with the notice
+* and other provisions required by the GPL or the LGPL. If you do not delete
+* the provisions above, a recipient may use your version of this file under
+* the terms of any one of the MPL, the GPL or the LGPL.
+*
+* ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.util.measurement;
+
+import java.io.Serializable;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.5
+ *
+ */
+public class AnnotationObj implements Serializable{
+
+    //original X,Y coordinates
+    private int x1;
+    private int y1;
+    private int x2;
+    private int y2;
+    // Component center based X,Y coordinates
+    private int centerBasedX1;
+    private int centerBasedY1;
+    private int centerBasedX2;
+    private int centerBasedY2;
+    //Mid X point of the component
+    private int midX;
+    //Mid Y point of the component
+    private int midY;
+    // Calculated Measurement value for the current shape
+    private String length;
+    private String area;
+    private String mean;
+    private String stdDev;
+    // Type of the shape
+    private String type = "";
+
+    //Construct the Annotation object
+    public AnnotationObj() {
+    }
+
+    //Getter and Setter Methods
+    public int getX1() {
+        return x1;
+    }
+
+    public void setX1(int x1) {
+        this.x1 = x1;
+    }
+
+    public int getX2() {
+        return x2;
+    }
+
+    public void setX2(int x2) {
+        this.x2 = x2;
+    }
+
+    public int getY1() {
+        return y1;
+    }
+
+    public void setY1(int y1) {
+        this.y1 = y1;
+    }
+
+    public int getY2() {
+        return y2;
+    }
+
+    public void setY2(int y2) {
+        this.y2 = y2;
+    }
+
+    public int getCenterBasedX1() {
+        return centerBasedX1;
+    }
+
+    public void setCenterBasedX1(int centerBasedX1) {
+        this.centerBasedX1 = centerBasedX1;
+    }
+
+    public int getCenterBasedX2() {
+        return centerBasedX2;
+    }
+
+    public void setCenterBasedX2(int centerBasedX2) {
+        this.centerBasedX2 = centerBasedX2;
+    }
+
+    public int getCenterBasedY1() {
+        return centerBasedY1;
+    }
+
+    public void setCenterBasedY1(int centerBasedY1) {
+        this.centerBasedY1 = centerBasedY1;
+    }
+
+    public int getCenterBasedY2() {
+        return centerBasedY2;
+    }
+
+    public void setCenterBasedY2(int centerBasedY2) {
+        this.centerBasedY2 = centerBasedY2;
+    }
+
+    public int getMidX() {
+        return midX;
+    }
+
+    public void setMidX(int midX) {
+        this.midX = midX;
+    }
+
+    public int getMidY() {
+        return midY;
+    }
+
+    public void setMidY(int midY) {
+        this.midY = midY;
+    }
+
+    public String getArea() {
+        return area;
+    }
+
+    public void setArea(String area) {
+        this.area = area;
+    }
+
+    public String getLength() {
+        return length;
+    }
+
+    public void setLength(String length) {
+        this.length = length;
+    }
+
+    public String getMean() {
+        return mean;
+    }
+
+    public void setMean(String mean) {
+        this.mean = mean;
+    }
+
+    public String getStdDev() {
+        return stdDev;
+    }
+
+    public void setStdDev(String stdDev) {
+        this.stdDev = stdDev;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    // To set the location of the shape
+    public void setLocation(int x1, int y1, int x2, int y2) {
+        this.x1 = x1;
+        this.y1 = y1;
+        this.x2 = x2;
+        this.y2 = y2;
+        this.centerBasedX1 = centerBasedX(this.x1);
+        this.centerBasedX2 = centerBasedX(this.x2);
+        this.centerBasedY1 = centerBasedY(this.y1);
+        this.centerBasedY2 = centerBasedY(this.y2);
+    }
+    //This subroutine used to set the component center based coordinates
+
+    public void setCenterBasedLocation(int x1, int y1, int x2, int y2) {
+        this.centerBasedX1 = x1;
+        this.centerBasedX2 = x2;
+        this.centerBasedY1 = y1;
+        this.centerBasedY2 = y2;
+        this.x1 = originalX(this.centerBasedX1);
+        this.y1 = originalY(this.centerBasedY1);
+        this.x2 = originalX(this.centerBasedX2);
+        this.y2 = originalY(this.centerBasedY2);
+    }
+    //To find the center based x value for the given original X
+    private int centerBasedX(int x) {
+        return (x - midX);
+    }
+    //To find the center based y value for the given original Y
+    private int centerBasedY(int y) {
+        return (y - midY);
+    }
+    //To find the original x value for the given center based X
+    private int originalX(int x) {
+        return (x + midX);
+    }
+    //To find the original x value for the given center based Y
+    private int originalY(int y) {
+        return (y + midY);
+    }
+}
\ No newline at end of file
diff --git a/src/in/raster/mayam/util/measurement/InstanceAnnotation.java b/src/in/raster/mayam/util/measurement/InstanceAnnotation.java
new file mode 100755
index 0000000..3115f23
--- /dev/null
+++ b/src/in/raster/mayam/util/measurement/InstanceAnnotation.java
@@ -0,0 +1,102 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.util.measurement;
+
+import java.io.Serializable;
+import java.util.HashMap;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.6
+ *
+ */
+public class InstanceAnnotation implements Serializable {
+
+    private String instanceUID = "";
+    private Annotation annotation;
+    private boolean multiframe = false;
+    private HashMap<Integer, Annotation> annotations;
+
+    public InstanceAnnotation(Annotation annotation) {
+        this.annotation = annotation;
+    }
+
+    public InstanceAnnotation(HashMap<Integer, Annotation> annotations) {
+        this.annotations = annotations;
+    }
+
+    public InstanceAnnotation() {
+    }
+
+    public Annotation getAnnotation() {
+        return annotation;
+    }
+
+    public void setAnnotation(Annotation annotation) {
+        this.annotation = annotation;
+    }
+
+    public String getInstanceUID() {
+        return instanceUID;
+    }
+
+    public void setInstanceUID(String instanceUID) {
+        this.instanceUID = instanceUID;
+    }
+
+    public HashMap<Integer, Annotation> getAnnotations() {
+        if (annotations == null) {
+            annotations = new HashMap<Integer, Annotation>();
+        }
+        return annotations;
+    }
+
+    public void setAnnotations(HashMap<Integer, Annotation> annotations) {
+        this.annotations = annotations;
+    }
+
+    public boolean isMultiframe() {
+        return multiframe;
+    }
+
+    public void setMultiframe(boolean multiframe) {
+        this.multiframe = multiframe;
+    }
+}
diff --git a/src/in/raster/mayam/util/measurement/SeriesAnnotation.java b/src/in/raster/mayam/util/measurement/SeriesAnnotation.java
new file mode 100755
index 0000000..0c657a9
--- /dev/null
+++ b/src/in/raster/mayam/util/measurement/SeriesAnnotation.java
@@ -0,0 +1,95 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package in.raster.mayam.util.measurement;
+
+import java.io.Serializable;
+import java.util.HashMap;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.6
+ *
+ */
+public class SeriesAnnotation implements Serializable {
+
+    private String seriesUID = "";
+    private HashMap instanceArray;
+    private boolean multiframe = false;
+    private String instanceUID = "";
+
+    public SeriesAnnotation() {
+    }
+
+    public HashMap getInstanceArray() {
+        if (instanceArray == null) {
+            instanceArray = new HashMap();
+        }
+        return instanceArray;
+    }
+
+    public void setInstanceArray(HashMap instanceArray) {
+
+        this.instanceArray = instanceArray;
+    }
+
+    public String getSeriesUID() {
+        return seriesUID;
+    }
+
+    public void setSeriesUID(String seriesUID) {
+        this.seriesUID = seriesUID;
+    }
+
+    public String getInstanceUID() {
+        return instanceUID;
+    }
+
+    public void setInstanceUID(String instanceUID) {
+        this.instanceUID = instanceUID;
+    }
+
+    public boolean isMultiframe() {
+        return multiframe;
+    }
+
+    public void setMultiframe(boolean multiframe) {
+        this.multiframe = multiframe;
+    }
+}
diff --git a/src/in/raster/mayam/util/measurement/StudyAnnotation.java b/src/in/raster/mayam/util/measurement/StudyAnnotation.java
new file mode 100755
index 0000000..89a353c
--- /dev/null
+++ b/src/in/raster/mayam/util/measurement/StudyAnnotation.java
@@ -0,0 +1,79 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ *
+ * The Initial Developer of the Original Code is
+ * Raster Images
+ * Portions created by the Initial Developer are Copyright (C) 2009-2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Babu Hussain A
+ * Meer Asgar Hussain B
+ * Prakash J
+ * Suresh V
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+package in.raster.mayam.util.measurement;
+
+import java.io.Serializable;
+import java.util.HashMap;
+
+/**
+ *
+ * @author  BabuHussain
+ * @version 0.6
+ *
+ */
+public class StudyAnnotation implements Serializable{
+
+    private String studyUID="";
+    private HashMap seriesAnnotation;
+
+    public StudyAnnotation() {
+    }
+
+    public HashMap getSeriesAnnotation() {
+        if(seriesAnnotation==null)
+        {
+            seriesAnnotation=new HashMap();
+        }
+        return seriesAnnotation;
+    }
+
+    public void setSeriesAnnotation(HashMap seriesAnnotation) {
+        this.seriesAnnotation = seriesAnnotation;
+    }
+
+    public String getStudyUID() {
+        return studyUID;
+    }
+
+    public void setStudyUID(String studyUID) {
+        this.studyUID = studyUID;
+    }
+
+}
\ No newline at end of file
diff --git a/src/log4j.properties b/src/log4j.properties
new file mode 100644
index 0000000..b7136aa
--- /dev/null
+++ b/src/log4j.properties
@@ -0,0 +1,6 @@
+### direct log messages to stdout ###
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
+log4j.rootLogger=error
\ No newline at end of file
diff --git a/src/resources/CDimseService.cfg b/src/resources/CDimseService.cfg
new file mode 100644
index 0000000..df91769
--- /dev/null
+++ b/src/resources/CDimseService.cfg
@@ -0,0 +1,266 @@
+###############################################################################
+# Based on configuration file for dcm4che 1.4.0 sample: dcmsnd.cfg revision date 2005-08-25
+# Version: 2006-06-23
+###############################################################################
+
+# Time-out waiting [in msec] for A-ASSOCIATE-AC acknowlage, 0 is interpreted as an infinite timeout [default=5000].
+ac-timeout = 10000
+
+# Time-out waiting [in msec] for DIMSE on open association, 0 is interpreted as an infinite timeout [default=0]
+dimse-timeout = 0
+
+# Time delay [in msec] for socket close after sending A-ABORT [default=500]
+so-close-delay = 500
+
+# Activates packing of command PDV (Presentation Data Value) + (first) data PDV into one P-DATA-TF PDU (Protocol Data Unit)
+pack-pdvs = false
+
+# Message priority. Possible values low = 2, medium = 0, high = 1
+prior = 0
+
+# Maximal length of receiving PDUs (Protocol Data Unit) [default=16352]
+max-pdu-len = 16352
+
+# Maximal number of invoked operations with outstanding response.
+max-op-invoked = 0
+
+
+#>>>>> TLS: private key and certified-public key >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+# File reference of the container of the private key and certified-public key.
+# For details see the API documentation of the method CDimseService.initTLS
+# PKCS #12 or JKS (Java Keystore) containers may be use. Keys must be RSA encoded
+# Two forms are possible:
+# 1. Absolute reference (file:/C:/a/b/c.txt): The reference is taken as is.
+# 2. Relative reference (b/c.txt): The referece is relative to the package of the class CDimseService
+#tls-key = file:/c:/tmp/identity.p12
+#tls-key = resources/identity.p12
+
+# Password of the keystore containing the private key
+#tls-keystore-passwd = secret
+
+# Password of the private key in the keystore 
+#tls-key-passwd = secret
+
+#>>>>> TLS: root-certificates of Certifying Authorities >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+# File reference of the container of the root-certificates of the Certifying Authorities
+# For details see the API documentation of the method CDimseService.initTLS
+# PKCS #12 or JKS (Java Keystore) containers may be use. Keys must be RSA encoded
+# Two forms are possible:
+# 1. Absolute reference (file:/C:/a/b/c.txt): The reference is taken as is.
+# 2. Relative reference (b/c.txt): The referece is relative to the package of the class CDimseService
+#tls-cacerts = file:/c:/tmp/cacerts.jks
+#tls-cacerts = resources/cacerts.jks
+
+# Password of the keystore containing the root-certificates
+#tls-cacerts-passwd = secret
+
+
+#>>>>> Specific C-FIND >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+# Specifies Key Attributes used for matching in C-FIND
+# Special Key Attributes "QueryRetrieveLevel":
+# Defines the query/retrieve level. Possible values are "STUDY", "SERIES", "IMAGE"
+# See PS 3.4 - C.6.2 Study Root SOP Class Group
+key.QueryRetrieveLevel = STUDY
+
+key.PatientName = 
+key.PatientID =
+key.PatientSex =
+key.PatientBirthDate = 
+key.StudyID = 
+key.StudyInstanceUID =
+key.StudyDescription = 
+key.SeriesInstanceUID
+key.SeriesNumber = 
+key.InstanceNumber = 
+key.ModalitiesInStudy = 
+key.StudyDate = 
+key.NumberOfStudyRelatedSeries =
+key.StudyTime = 
+key.ReferringPhysicianName =
+key.AccessionNumber=
+key.NumberOfStudyRelatedInstances=
+
+
+<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
+>>>>> Specific C-MOVE >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+# Application Entity Title (AET) of the destination for the C-MOVE
+dest = MOVE_DESTINATION
+
+<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
+>>>>> Presesentation Context >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+# Macrodefinition of transfer syntaces
+
+ts-native=ExplicitVRLittleEndian,ImplicitVRLittleEndian
+
+
+# Available transfer syntaces for storage SOP classes
+# PS 3.4 - Annex B STORAGE SERVICE CLASS
+# PS 3.4 - B.5 STANDARD SOP CLASSES
+# Syntax: pc.n = sop_uid,transfer_syntax[,transfer_syntax]
+# with n = presentation context ID (a for the association unique odd number between 1 and 255)
+# with sop_uid = symbolic name of the UID of the SOP to transmit
+# with transfer_syntax = supportet transfer syntax for that SOP
+
+
+>>>>> Presesentation Context for C-STORE >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+ #pc.1=HardcopyGrayscaleImageStorage,$ts-native
+ #pc.3=HardcopyColorImageStorage,$ts-native
+ #pc.5=ComputedRadiographyImageStorage,$ts-native
+ #pc.7=DigitalXRayImageStorageForPresentation,$ts-native
+ #pc.9=DigitalXRayImageStorageForProcessing,$ts-native
+ #pc.11=DigitalMammographyXRayImageStorageForPresentation,$ts-native
+ #pc.13=DigitalMammographyXRayImageStorageForProcessing,$ts-native
+ #pc.15=DigitalIntraoralXRayImageStorageForPresentation,$ts-native
+ #pc.17=DigitalIntraoralXRayImageStorageForProcessing,$ts-native
+ #pc.19=CTImageStorage,$ts-native
+ #pc.21=UltrasoundMultiframeImageStorageRetired,$ts-native
+ #pc.23=UltrasoundMultiframeImageStorage,$ts-native
+ #pc.25=MRImageStorage,$ts-native
+ #pc.27=EnhancedMRImageStorage,$ts-native
+ #pc.29=NuclearMedicineImageStorageRetired,$ts-native
+ #pc.31=UltrasoundImageStorageRetired,$ts-native
+ #pc.33=UltrasoundImageStorage,$ts-native
+ #pc.35=SecondaryCaptureImageStorage,$ts-native
+ #pc.37=MultiframeSingleBitSecondaryCaptureImageStorage,$ts-native
+ #pc.39=MultiframeGrayscaleByteSecondaryCaptureImageStorage,$ts-native
+ #pc.41=MultiframeGrayscaleWordSecondaryCaptureImageStorage,$ts-native
+ #pc.43=MultiframeColorSecondaryCaptureImageStorage,$ts-native
+ #pc.45=XRayAngiographicImageStorage,$ts-native
+ #pc.47=XRayRadiofluoroscopicImageStorage,$ts-native
+ #pc.49=XRayAngiographicBiPlaneImageStorageRetired,$ts-native
+ #pc.51=NuclearMedicineImageStorage,$ts-native
+ #pc.53=VLImageStorageRetired,$ts-native
+ #pc.55=VLMultiframeImageStorageRetired,$ts-native
+ #pc.57=VLEndoscopicImageStorage,$ts-native
+ #pc.59=VLMicroscopicImageStorage,$ts-native
+ #pc.61=VLSlideCoordinatesMicroscopicImageStorage,$ts-native
+ #pc.63=VLPhotographicImageStorage,$ts-native
+ #pc.65=PositronEmissionTomographyImageStorage,$ts-native
+ #pc.67=RTImageStorage,$ts-native
+ #pc.69=BasicTextSR,$ts-native
+ #pc.71=EnhancedSR,$ts-native
+ #pc.73=ComprehensiveSR,$ts-native
+ #pc.75=MammographyCADSR,$ts-native
+ #pc.77=GrayscaleSoftcopyPresentationStateStorage,$ts-native
+ #pc.79=KeyObjectSelectionDocument,$ts-native
+ #pc.81=RTDoseStorage,$ts-native
+ #pc.83=RTStructureSetStorage,$ts-native
+ #pc.85=RTBeamsTreatmentRecordStorage,$ts-native
+ #pc.87=RTPlanStorage,$ts-native
+ #pc.89=RTBrachyTreatmentRecordStorage,$ts-native
+ #pc.91=RTTreatmentSummaryRecordStorage,$ts-native
+ #pc.93=RawDataStorage,$ts-native
+
+ #pc.95=ComputedRadiographyImageStorage,JPEGLossless
+ #pc.97=DigitalXRayImageStorageForPresentation,JPEGLossless
+ #pc.99=DigitalXRayImageStorageForProcessing,JPEGLossless
+ #pc.101=DigitalMammographyXRayImageStorageForPresentation,JPEGLossless
+ #pc.103=DigitalMammographyXRayImageStorageForProcessing,JPEGLossless
+ #pc.105=DigitalIntraoralXRayImageStorageForPresentation,JPEGLossless
+ #pc.107=DigitalIntraoralXRayImageStorageForProcessing,JPEGLossless
+ #pc.109=CTImageStorage,JPEGLossless
+ #pc.111=UltrasoundMultiframeImageStorage,JPEGLossless
+ #pc.113=MRImageStorage,JPEGLossless
+ #pc.115=EnhancedMRImageStorage,JPEGLossless
+ #pc.117=UltrasoundImageStorage,JPEGLossless
+ #pc.119=SecondaryCaptureImageStorage,JPEGLossless
+ #pc.121=MultiframeGrayscaleByteSecondaryCaptureImageStorage,JPEGLossless
+ #pc.123=MultiframeGrayscaleWordSecondaryCaptureImageStorage,JPEGLossless
+ #pc.125=MultiframeColorSecondaryCaptureImageStorage,JPEGLossless
+ #pc.127=XRayAngiographicImageStorage,JPEGLossless
+ #pc.129=XRayRadiofluoroscopicImageStorage,JPEGLossless
+ #pc.131=NuclearMedicineImageStorage,JPEGLossless
+ #pc.133=VLEndoscopicImageStorage,JPEGLossless
+ #pc.135=VLMicroscopicImageStorage,JPEGLossless
+ #pc.137=VLSlideCoordinatesMicroscopicImageStorage,JPEGLossless
+ #pc.139=VLPhotographicImageStorage,JPEGLossless
+ #pc.141=PositronEmissionTomographyImageStorage,JPEGLossless
+ #pc.143=RTImageStorage,JPEGLossless
+
+ #pc.145=UltrasoundMultiframeImageStorage,JPEGBaseline
+ #pc.147=UltrasoundImageStorage,JPEGBaseline
+ #pc.149=SecondaryCaptureImageStorage,JPEGBaseline
+ #pc.151=MultiframeGrayscaleByteSecondaryCaptureImageStorage,JPEGBaseline
+ #pc.153=MultiframeColorSecondaryCaptureImageStorage,JPEGBaseline
+ #pc.155=XRayAngiographicImageStorage,JPEGBaseline
+
+ #pc.157=ComputedRadiographyImageStorage,JPEGExtended
+ #pc.159=CTImageStorage,JPEGExtended
+ #pc.161=MRImageStorage,JPEGExtended
+ #pc.163=SecondaryCaptureImageStorage,JPEGExtended
+
+ #pc.165=ComputedRadiographyImageStorage,JPEGLSLossy
+ #pc.167=CTImageStorage,JPEGLSLossy
+ #pc.169=UltrasoundMultiframeImageStorage,JPEGLSLossy
+ #pc.171=MRImageStorage,JPEGLSLossy
+ #pc.173=UltrasoundImageStorage,JPEGLSLossy
+ #pc.175=SecondaryCaptureImageStorage,JPEGLSLossy
+
+ #pc.177=ComputedRadiographyImageStorage,JPEG2000Lossy
+ #pc.179=CTImageStorage,JPEG2000Lossy
+ #pc.181=UltrasoundMultiframeImageStorage,JPEG2000Lossy
+ #pc.183=MRImageStorage,JPEG2000Lossy
+ #pc.185=UltrasoundImageStorage,JPEG2000Lossy
+ #pc.187=SecondaryCaptureImageStorage,JPEG2000Lossy
+
+ #pc.189=ComputedRadiographyImageStorage,JPEGLSLossless
+ #pc.191=CTImageStorage,JPEGLSLossless
+ #pc.193=UltrasoundMultiframeImageStorage,JPEGLSLossless
+ #pc.195=MRImageStorage,JPEGLSLossless
+ #pc.197=UltrasoundImageStorage,JPEGLSLossless
+ #pc.199=SecondaryCaptureImageStorage,JPEGLSLossless
+
+ #pc.201=ComputedRadiographyImageStorage,JPEG2000Lossless
+ #pc.203=CTImageStorage,JPEG2000Lossless
+ #pc.205=UltrasoundMultiframeImageStorage,JPEG2000Lossless
+ #pc.207=MRImageStorage,JPEG2000Lossless
+ #pc.209=UltrasoundImageStorage,JPEG2000Lossless
+ #pc.211=SecondaryCaptureImageStorage,JPEG2000Lossless
+
+ #pc.213=ComputedRadiographyImageStorage,RLELossless
+ #pc.215=CTImageStorage,RLELossless
+ #pc.217=UltrasoundMultiframeImageStorage,RLELossless
+ #pc.219=MRImageStorage,RLELossless
+ #pc.221=UltrasoundImageStorage,RLELossless
+ #pc.223=SecondaryCaptureImageStorage,RLELossless
+
+ #pc.225=VideoEndoscopicImageStorage,MPEG2
+ #pc.227=VideoMicroscopicImageStorage,MPEG2
+ #pc.229=VideoPhotographicImageStorage,MPEG2
+
+ #pc.231=AmbulatoryECGWaveformStorage,$ts-native
+ #pc.233=BasicVoiceAudioWaveformStorage,$ts-native
+ #pc.235=CardiacElectrophysiologyWaveformStorage,$ts-native
+ #pc.237=GeneralECGWaveformStorage,$ts-native
+ #pc.239=HemodynamicWaveformStorage,$ts-native
+ #pc.241=TwelveLeadECGWaveformStorage,$ts-native
+
+ #pc.243=HangingProtocolStorage,$ts-native
+ #pc.245=EncapsulatedPDFStorage,$ts-native
+
+ #pc.247=BasicStudyContentNotification,$ts-native
+
+
+>>>>> Presesentation Context for C-FIND >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+pc.251=StudyRootQueryRetrieveInformationModelFIND,$ts-native
+
+
+>>>>> Presesentation Context for C-MOVE >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+#pc.253=StudyRootQueryRetrieveInformationModelMOVE,$ts-native
+
+
+>>>>> Presesentation Context for C-ECHO >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+pc.255=Verification,ImplicitVRLittleEndian
diff --git a/src/resources/EchoService.cfg b/src/resources/EchoService.cfg
new file mode 100644
index 0000000..5bcd6b4
--- /dev/null
+++ b/src/resources/EchoService.cfg
@@ -0,0 +1,247 @@
+###############################################################################
+# Based on configuration file for dcm4che 1.4.0 sample: dcmsnd.cfg revision date 2005-08-25
+# Version: 2006-06-23
+###############################################################################
+
+# Time-out waiting [in msec] for A-ASSOCIATE-AC acknowlage, 0 is interpreted as an infinite timeout [default=5000].
+ac-timeout = 10000
+
+# Time-out waiting [in msec] for DIMSE on open association, 0 is interpreted as an infinite timeout [default=0]
+dimse-timeout = 0
+
+# Time delay [in msec] for socket close after sending A-ABORT [default=500]
+so-close-delay = 500
+
+# Activates packing of command PDV (Presentation Data Value) + (first) data PDV into one P-DATA-TF PDU (Protocol Data Unit)
+pack-pdvs = false
+
+# Message priority. Possible values low = 2, medium = 0, high = 1
+prior = 0
+
+# Maximal length of receiving PDUs (Protocol Data Unit) [default=16352]
+max-pdu-len = 16352
+
+# Maximal number of invoked operations with outstanding response.
+max-op-invoked = 0
+
+
+#>>>>> TLS: private key and certified-public key >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+# File reference of the container of the private key and certified-public key.
+# For details see the API documentation of the method CDimseService.initTLS
+# PKCS #12 or JKS (Java Keystore) containers may be use. Keys must be RSA encoded
+# Two forms are possible:
+# 1. Absolute reference (file:/C:/a/b/c.txt): The reference is taken as is.
+# 2. Relative reference (b/c.txt): The referece is relative to the package of the class CDimseService
+#tls-key = file:/c:/tmp/identity.p12
+#tls-key = resources/identity.p12
+
+# Password of the keystore containing the private key
+#tls-keystore-passwd = secret
+
+# Password of the private key in the keystore 
+#tls-key-passwd = secret
+
+#>>>>> TLS: root-certificates of Certifying Authorities >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+# File reference of the container of the root-certificates of the Certifying Authorities
+# For details see the API documentation of the method CDimseService.initTLS
+# PKCS #12 or JKS (Java Keystore) containers may be use. Keys must be RSA encoded
+# Two forms are possible:
+# 1. Absolute reference (file:/C:/a/b/c.txt): The reference is taken as is.
+# 2. Relative reference (b/c.txt): The referece is relative to the package of the class CDimseService
+#tls-cacerts = file:/c:/tmp/cacerts.jks
+#tls-cacerts = resources/cacerts.jks
+
+# Password of the keystore containing the root-certificates
+#tls-cacerts-passwd = secret
+
+
+#>>>>> Specific C-FIND >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+# Specifies Key Attributes used for matching in C-FIND
+# Special Key Attributes "QueryRetrieveLevel":
+# Defines the query/retrieve level. Possible values are "STUDY", "SERIES", "IMAGE"
+# See PS 3.4 - C.6.2 Study Root SOP Class Group
+key.QueryRetrieveLevel = STUDY
+
+<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
+>>>>> Specific C-MOVE >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+# Application Entity Title (AET) of the destination for the C-MOVE
+dest = MOVE_DESTINATION
+
+<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
+>>>>> Presesentation Context >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+# Macrodefinition of transfer syntaces
+
+ts-native=ExplicitVRLittleEndian,ImplicitVRLittleEndian
+
+
+# Available transfer syntaces for storage SOP classes
+# PS 3.4 - Annex B STORAGE SERVICE CLASS
+# PS 3.4 - B.5 STANDARD SOP CLASSES
+# Syntax: pc.n = sop_uid,transfer_syntax[,transfer_syntax]
+# with n = presentation context ID (a for the association unique odd number between 1 and 255)
+# with sop_uid = symbolic name of the UID of the SOP to transmit
+# with transfer_syntax = supportet transfer syntax for that SOP
+
+
+>>>>> Presesentation Context for C-STORE >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+#pc.1=HardcopyGrayscaleImageStorage,$ts-native
+#pc.3=HardcopyColorImageStorage,$ts-native
+#pc.5=ComputedRadiographyImageStorage,$ts-native
+#pc.7=DigitalXRayImageStorageForPresentation,$ts-native
+#pc.9=DigitalXRayImageStorageForProcessing,$ts-native
+#pc.11=DigitalMammographyXRayImageStorageForPresentation,$ts-native
+#pc.13=DigitalMammographyXRayImageStorageForProcessing,$ts-native
+#pc.15=DigitalIntraoralXRayImageStorageForPresentation,$ts-native
+#pc.17=DigitalIntraoralXRayImageStorageForProcessing,$ts-native
+#pc.19=CTImageStorage,$ts-native
+#pc.21=UltrasoundMultiframeImageStorageRetired,$ts-native
+#pc.23=UltrasoundMultiframeImageStorage,$ts-native
+#pc.25=MRImageStorage,$ts-native
+#pc.27=EnhancedMRImageStorage,$ts-native
+#pc.29=NuclearMedicineImageStorageRetired,$ts-native
+#pc.31=UltrasoundImageStorageRetired,$ts-native
+#pc.33=UltrasoundImageStorage,$ts-native
+#pc.35=SecondaryCaptureImageStorage,$ts-native
+#pc.37=MultiframeSingleBitSecondaryCaptureImageStorage,$ts-native
+#pc.39=MultiframeGrayscaleByteSecondaryCaptureImageStorage,$ts-native
+#pc.41=MultiframeGrayscaleWordSecondaryCaptureImageStorage,$ts-native
+#pc.43=MultiframeColorSecondaryCaptureImageStorage,$ts-native
+#pc.45=XRayAngiographicImageStorage,$ts-native
+#pc.47=XRayRadiofluoroscopicImageStorage,$ts-native
+#pc.49=XRayAngiographicBiPlaneImageStorageRetired,$ts-native
+#pc.51=NuclearMedicineImageStorage,$ts-native
+#pc.53=VLImageStorageRetired,$ts-native
+#pc.55=VLMultiframeImageStorageRetired,$ts-native
+#pc.57=VLEndoscopicImageStorage,$ts-native
+#pc.59=VLMicroscopicImageStorage,$ts-native
+#pc.61=VLSlideCoordinatesMicroscopicImageStorage,$ts-native
+#pc.63=VLPhotographicImageStorage,$ts-native
+#pc.65=PositronEmissionTomographyImageStorage,$ts-native
+#pc.67=RTImageStorage,$ts-native
+#pc.69=BasicTextSR,$ts-native
+#pc.71=EnhancedSR,$ts-native
+#pc.73=ComprehensiveSR,$ts-native
+#pc.75=MammographyCADSR,$ts-native
+#pc.77=GrayscaleSoftcopyPresentationStateStorage,$ts-native
+#pc.79=KeyObjectSelectionDocument,$ts-native
+#pc.81=RTDoseStorage,$ts-native
+#pc.83=RTStructureSetStorage,$ts-native
+#pc.85=RTBeamsTreatmentRecordStorage,$ts-native
+#pc.87=RTPlanStorage,$ts-native
+#pc.89=RTBrachyTreatmentRecordStorage,$ts-native
+#pc.91=RTTreatmentSummaryRecordStorage,$ts-native
+#pc.93=RawDataStorage,$ts-native
+
+#pc.95=ComputedRadiographyImageStorage,JPEGLossless
+#pc.97=DigitalXRayImageStorageForPresentation,JPEGLossless
+#pc.99=DigitalXRayImageStorageForProcessing,JPEGLossless
+#pc.101=DigitalMammographyXRayImageStorageForPresentation,JPEGLossless
+#pc.103=DigitalMammographyXRayImageStorageForProcessing,JPEGLossless
+#pc.105=DigitalIntraoralXRayImageStorageForPresentation,JPEGLossless
+#pc.107=DigitalIntraoralXRayImageStorageForProcessing,JPEGLossless
+#pc.109=CTImageStorage,JPEGLossless
+#pc.111=UltrasoundMultiframeImageStorage,JPEGLossless
+#pc.113=MRImageStorage,JPEGLossless
+#pc.115=EnhancedMRImageStorage,JPEGLossless
+#pc.117=UltrasoundImageStorage,JPEGLossless
+#pc.119=SecondaryCaptureImageStorage,JPEGLossless
+#pc.121=MultiframeGrayscaleByteSecondaryCaptureImageStorage,JPEGLossless
+#pc.123=MultiframeGrayscaleWordSecondaryCaptureImageStorage,JPEGLossless
+#pc.125=MultiframeColorSecondaryCaptureImageStorage,JPEGLossless
+#pc.127=XRayAngiographicImageStorage,JPEGLossless
+#pc.129=XRayRadiofluoroscopicImageStorage,JPEGLossless
+#pc.131=NuclearMedicineImageStorage,JPEGLossless
+#pc.133=VLEndoscopicImageStorage,JPEGLossless
+#pc.135=VLMicroscopicImageStorage,JPEGLossless
+#pc.137=VLSlideCoordinatesMicroscopicImageStorage,JPEGLossless
+#pc.139=VLPhotographicImageStorage,JPEGLossless
+#pc.141=PositronEmissionTomographyImageStorage,JPEGLossless
+#pc.143=RTImageStorage,JPEGLossless
+
+#pc.145=UltrasoundMultiframeImageStorage,JPEGBaseline
+#pc.147=UltrasoundImageStorage,JPEGBaseline
+#pc.149=SecondaryCaptureImageStorage,JPEGBaseline
+#pc.151=MultiframeGrayscaleByteSecondaryCaptureImageStorage,JPEGBaseline
+#pc.153=MultiframeColorSecondaryCaptureImageStorage,JPEGBaseline
+#pc.155=XRayAngiographicImageStorage,JPEGBaseline
+
+#pc.157=ComputedRadiographyImageStorage,JPEGExtended
+#pc.159=CTImageStorage,JPEGExtended
+#pc.161=MRImageStorage,JPEGExtended
+#pc.163=SecondaryCaptureImageStorage,JPEGExtended
+
+#pc.165=ComputedRadiographyImageStorage,JPEGLSLossy
+#pc.167=CTImageStorage,JPEGLSLossy
+#pc.169=UltrasoundMultiframeImageStorage,JPEGLSLossy
+#pc.171=MRImageStorage,JPEGLSLossy
+#pc.173=UltrasoundImageStorage,JPEGLSLossy
+#pc.175=SecondaryCaptureImageStorage,JPEGLSLossy
+
+#pc.177=ComputedRadiographyImageStorage,JPEG2000Lossy
+#pc.179=CTImageStorage,JPEG2000Lossy
+#pc.181=UltrasoundMultiframeImageStorage,JPEG2000Lossy
+#pc.183=MRImageStorage,JPEG2000Lossy
+#pc.185=UltrasoundImageStorage,JPEG2000Lossy
+#pc.187=SecondaryCaptureImageStorage,JPEG2000Lossy
+
+#pc.189=ComputedRadiographyImageStorage,JPEGLSLossless
+#pc.191=CTImageStorage,JPEGLSLossless
+#pc.193=UltrasoundMultiframeImageStorage,JPEGLSLossless
+#pc.195=MRImageStorage,JPEGLSLossless
+#pc.197=UltrasoundImageStorage,JPEGLSLossless
+#pc.199=SecondaryCaptureImageStorage,JPEGLSLossless
+
+#pc.201=ComputedRadiographyImageStorage,JPEG2000Lossless
+#pc.203=CTImageStorage,JPEG2000Lossless
+#pc.205=UltrasoundMultiframeImageStorage,JPEG2000Lossless
+#pc.207=MRImageStorage,JPEG2000Lossless
+#pc.209=UltrasoundImageStorage,JPEG2000Lossless
+#pc.211=SecondaryCaptureImageStorage,JPEG2000Lossless
+
+#pc.213=ComputedRadiographyImageStorage,RLELossless
+#pc.215=CTImageStorage,RLELossless
+#pc.217=UltrasoundMultiframeImageStorage,RLELossless
+#pc.219=MRImageStorage,RLELossless
+#pc.221=UltrasoundImageStorage,RLELossless
+#pc.223=SecondaryCaptureImageStorage,RLELossless
+
+#pc.225=VideoEndoscopicImageStorage,MPEG2
+#pc.227=VideoMicroscopicImageStorage,MPEG2
+#pc.229=VideoPhotographicImageStorage,MPEG2
+
+#pc.231=AmbulatoryECGWaveformStorage,$ts-native
+#pc.233=BasicVoiceAudioWaveformStorage,$ts-native
+#pc.235=CardiacElectrophysiologyWaveformStorage,$ts-native
+#pc.237=GeneralECGWaveformStorage,$ts-native
+#pc.239=HemodynamicWaveformStorage,$ts-native
+#pc.241=TwelveLeadECGWaveformStorage,$ts-native
+
+#pc.243=HangingProtocolStorage,$ts-native
+#pc.245=EncapsulatedPDFStorage,$ts-native
+
+#pc.247=BasicStudyContentNotification,$ts-native
+
+
+>>>>> Presesentation Context for C-FIND >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+#pc.251=StudyRootQueryRetrieveInformationModelFIND,$ts-native
+
+
+>>>>> Presesentation Context for C-MOVE >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+#pc.253=StudyRootQueryRetrieveInformationModelMOVE,$ts-native
+
+
+>>>>> Presesentation Context for C-ECHO >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+pc.255=Verification,ImplicitVRLittleEndian
diff --git a/src/resources/Image.cfg b/src/resources/Image.cfg
new file mode 100644
index 0000000..1a7356b
--- /dev/null
+++ b/src/resources/Image.cfg
@@ -0,0 +1,256 @@
+###############################################################################
+# Based on configuration file for dcm4che 1.4.0 sample: dcmsnd.cfg revision date 2005-08-25
+# Version: 2006-06-23
+###############################################################################
+
+# Time-out waiting [in msec] for A-ASSOCIATE-AC acknowlage, 0 is interpreted as an infinite timeout [default=5000].
+ac-timeout = 10000
+
+# Time-out waiting [in msec] for DIMSE on open association, 0 is interpreted as an infinite timeout [default=0]
+dimse-timeout = 0
+
+# Time delay [in msec] for socket close after sending A-ABORT [default=500]
+so-close-delay = 500
+
+# Activates packing of command PDV (Presentation Data Value) + (first) data PDV into one P-DATA-TF PDU (Protocol Data Unit)
+pack-pdvs = false
+
+# Message priority. Possible values low = 2, medium = 0, high = 1
+prior = 0
+
+# Maximal length of receiving PDUs (Protocol Data Unit) [default=16352]
+max-pdu-len = 16352
+
+# Maximal number of invoked operations with outstanding response.
+max-op-invoked = 0
+
+
+#>>>>> TLS: private key and certified-public key >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+# File reference of the container of the private key and certified-public key.
+# For details see the API documentation of the method CDimseService.initTLS
+# PKCS #12 or JKS (Java Keystore) containers may be use. Keys must be RSA encoded
+# Two forms are possible:
+# 1. Absolute reference (file:/C:/a/b/c.txt): The reference is taken as is.
+# 2. Relative reference (b/c.txt): The referece is relative to the package of the class CDimseService
+#tls-key = file:/c:/tmp/identity.p12
+#tls-key = resources/identity.p12
+
+# Password of the keystore containing the private key
+#tls-keystore-passwd = secret
+
+# Password of the private key in the keystore 
+#tls-key-passwd = secret
+
+#>>>>> TLS: root-certificates of Certifying Authorities >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+# File reference of the container of the root-certificates of the Certifying Authorities
+# For details see the API documentation of the method CDimseService.initTLS
+# PKCS #12 or JKS (Java Keystore) containers may be use. Keys must be RSA encoded
+# Two forms are possible:
+# 1. Absolute reference (file:/C:/a/b/c.txt): The reference is taken as is.
+# 2. Relative reference (b/c.txt): The referece is relative to the package of the class CDimseService
+#tls-cacerts = file:/c:/tmp/cacerts.jks
+#tls-cacerts = resources/cacerts.jks
+
+# Password of the keystore containing the root-certificates
+#tls-cacerts-passwd = secret
+
+
+#>>>>> Specific C-FIND >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+# Specifies Key Attributes used for matching in C-FIND
+# Special Key Attributes "QueryRetrieveLevel":
+# Defines the query/retrieve level. Possible values are "STUDY", "SERIES", "IMAGE"
+# See PS 3.4 - C.6.2 Study Root SOP Class Group
+key.QueryRetrieveLevel = IMAGE
+
+key.PatientName = 
+key.InstanceNumber = 
+key.SOPInstanceUID =
+key.BodyPartExamined =
+key.ImageComments =
+key.SliceLocation = 
+key.NumberOfFrames = 
+
+
+#<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
+#>>>>> Specific C-MOVE >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+# Application Entity Title (AET) of the destination for the C-MOVE
+dest = MOVE_DESTINATION
+
+#<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
+#>>>>> Presesentation Context >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+# Macrodefinition of transfer syntaces
+
+ts-native=ExplicitVRLittleEndian,ImplicitVRLittleEndian
+
+
+# Available transfer syntaces for storage SOP classes
+# PS 3.4 - Annex B STORAGE SERVICE CLASS
+# PS 3.4 - B.5 STANDARD SOP CLASSES
+# Syntax: pc.n = sop_uid,transfer_syntax[,transfer_syntax]
+# with n = presentation context ID (a for the association unique odd number between 1 and 255)
+# with sop_uid = symbolic name of the UID of the SOP to transmit
+# with transfer_syntax = supportet transfer syntax for that SOP
+
+
+#>>>>> Presesentation Context for C-STORE >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+ #pc.1=HardcopyGrayscaleImageStorage,$ts-native
+ #pc.3=HardcopyColorImageStorage,$ts-native
+ #pc.5=ComputedRadiographyImageStorage,$ts-native
+ #pc.7=DigitalXRayImageStorageForPresentation,$ts-native
+ #pc.9=DigitalXRayImageStorageForProcessing,$ts-native
+ #pc.11=DigitalMammographyXRayImageStorageForPresentation,$ts-native
+ #pc.13=DigitalMammographyXRayImageStorageForProcessing,$ts-native
+ #pc.15=DigitalIntraoralXRayImageStorageForPresentation,$ts-native
+ #pc.17=DigitalIntraoralXRayImageStorageForProcessing,$ts-native
+ #pc.19=CTImageStorage,$ts-native
+ #pc.21=UltrasoundMultiframeImageStorageRetired,$ts-native
+ #pc.23=UltrasoundMultiframeImageStorage,$ts-native
+ #pc.25=MRImageStorage,$ts-native
+ #pc.27=EnhancedMRImageStorage,$ts-native
+ #pc.29=NuclearMedicineImageStorageRetired,$ts-native
+ #pc.31=UltrasoundImageStorageRetired,$ts-native
+ #pc.33=UltrasoundImageStorage,$ts-native
+ #pc.35=SecondaryCaptureImageStorage,$ts-native
+ #pc.37=MultiframeSingleBitSecondaryCaptureImageStorage,$ts-native
+ #pc.39=MultiframeGrayscaleByteSecondaryCaptureImageStorage,$ts-native
+ #pc.41=MultiframeGrayscaleWordSecondaryCaptureImageStorage,$ts-native
+ #pc.43=MultiframeColorSecondaryCaptureImageStorage,$ts-native
+ #pc.45=XRayAngiographicImageStorage,$ts-native
+ #pc.47=XRayRadiofluoroscopicImageStorage,$ts-native
+ #pc.49=XRayAngiographicBiPlaneImageStorageRetired,$ts-native
+ #pc.51=NuclearMedicineImageStorage,$ts-native
+ #pc.53=VLImageStorageRetired,$ts-native
+ #pc.55=VLMultiframeImageStorageRetired,$ts-native
+ #pc.57=VLEndoscopicImageStorage,$ts-native
+ #pc.59=VLMicroscopicImageStorage,$ts-native
+ #pc.61=VLSlideCoordinatesMicroscopicImageStorage,$ts-native
+ #pc.63=VLPhotographicImageStorage,$ts-native
+ #pc.65=PositronEmissionTomographyImageStorage,$ts-native
+ #pc.67=RTImageStorage,$ts-native
+ #pc.69=BasicTextSR,$ts-native
+ #pc.71=EnhancedSR,$ts-native
+ #pc.73=ComprehensiveSR,$ts-native
+ #pc.75=MammographyCADSR,$ts-native
+ #pc.77=GrayscaleSoftcopyPresentationStateStorage,$ts-native
+ #pc.79=KeyObjectSelectionDocument,$ts-native
+ #pc.81=RTDoseStorage,$ts-native
+ #pc.83=RTStructureSetStorage,$ts-native
+ #pc.85=RTBeamsTreatmentRecordStorage,$ts-native
+ #pc.87=RTPlanStorage,$ts-native
+ #pc.89=RTBrachyTreatmentRecordStorage,$ts-native
+ #pc.91=RTTreatmentSummaryRecordStorage,$ts-native
+ #pc.93=RawDataStorage,$ts-native
+
+ #pc.95=ComputedRadiographyImageStorage,JPEGLossless
+ #pc.97=DigitalXRayImageStorageForPresentation,JPEGLossless
+ #pc.99=DigitalXRayImageStorageForProcessing,JPEGLossless
+ #pc.101=DigitalMammographyXRayImageStorageForPresentation,JPEGLossless
+ #pc.103=DigitalMammographyXRayImageStorageForProcessing,JPEGLossless
+ #pc.105=DigitalIntraoralXRayImageStorageForPresentation,JPEGLossless
+ #pc.107=DigitalIntraoralXRayImageStorageForProcessing,JPEGLossless
+ #pc.109=CTImageStorage,JPEGLossless
+ #pc.111=UltrasoundMultiframeImageStorage,JPEGLossless
+ #pc.113=MRImageStorage,JPEGLossless
+ #pc.115=EnhancedMRImageStorage,JPEGLossless
+ #pc.117=UltrasoundImageStorage,JPEGLossless
+ #pc.119=SecondaryCaptureImageStorage,JPEGLossless
+ #pc.121=MultiframeGrayscaleByteSecondaryCaptureImageStorage,JPEGLossless
+ #pc.123=MultiframeGrayscaleWordSecondaryCaptureImageStorage,JPEGLossless
+ #pc.125=MultiframeColorSecondaryCaptureImageStorage,JPEGLossless
+ #pc.127=XRayAngiographicImageStorage,JPEGLossless
+ #pc.129=XRayRadiofluoroscopicImageStorage,JPEGLossless
+ #pc.131=NuclearMedicineImageStorage,JPEGLossless
+ #pc.133=VLEndoscopicImageStorage,JPEGLossless
+ #pc.135=VLMicroscopicImageStorage,JPEGLossless
+ #pc.137=VLSlideCoordinatesMicroscopicImageStorage,JPEGLossless
+ #pc.139=VLPhotographicImageStorage,JPEGLossless
+ #pc.141=PositronEmissionTomographyImageStorage,JPEGLossless
+ #pc.143=RTImageStorage,JPEGLossless
+
+ #pc.145=UltrasoundMultiframeImageStorage,JPEGBaseline
+ #pc.147=UltrasoundImageStorage,JPEGBaseline
+ #pc.149=SecondaryCaptureImageStorage,JPEGBaseline
+ #pc.151=MultiframeGrayscaleByteSecondaryCaptureImageStorage,JPEGBaseline
+ #pc.153=MultiframeColorSecondaryCaptureImageStorage,JPEGBaseline
+ #pc.155=XRayAngiographicImageStorage,JPEGBaseline
+
+ #pc.157=ComputedRadiographyImageStorage,JPEGExtended
+ #pc.159=CTImageStorage,JPEGExtended
+ #pc.161=MRImageStorage,JPEGExtended
+ #pc.163=SecondaryCaptureImageStorage,JPEGExtended
+
+ #pc.165=ComputedRadiographyImageStorage,JPEGLSLossy
+ #pc.167=CTImageStorage,JPEGLSLossy
+ #pc.169=UltrasoundMultiframeImageStorage,JPEGLSLossy
+ #pc.171=MRImageStorage,JPEGLSLossy
+ #pc.173=UltrasoundImageStorage,JPEGLSLossy
+ #pc.175=SecondaryCaptureImageStorage,JPEGLSLossy
+
+ #pc.177=ComputedRadiographyImageStorage,JPEG2000Lossy
+ #pc.179=CTImageStorage,JPEG2000Lossy
+ #pc.181=UltrasoundMultiframeImageStorage,JPEG2000Lossy
+ #pc.183=MRImageStorage,JPEG2000Lossy
+ #pc.185=UltrasoundImageStorage,JPEG2000Lossy
+ #pc.187=SecondaryCaptureImageStorage,JPEG2000Lossy
+
+ #pc.189=ComputedRadiographyImageStorage,JPEGLSLossless
+ #pc.191=CTImageStorage,JPEGLSLossless
+ #pc.193=UltrasoundMultiframeImageStorage,JPEGLSLossless
+ #pc.195=MRImageStorage,JPEGLSLossless
+ #pc.197=UltrasoundImageStorage,JPEGLSLossless
+ #pc.199=SecondaryCaptureImageStorage,JPEGLSLossless
+
+ #pc.201=ComputedRadiographyImageStorage,JPEG2000Lossless
+ #pc.203=CTImageStorage,JPEG2000Lossless
+ #pc.205=UltrasoundMultiframeImageStorage,JPEG2000Lossless
+ #pc.207=MRImageStorage,JPEG2000Lossless
+ #pc.209=UltrasoundImageStorage,JPEG2000Lossless
+ #pc.211=SecondaryCaptureImageStorage,JPEG2000Lossless
+
+ #pc.213=ComputedRadiographyImageStorage,RLELossless
+ #pc.215=CTImageStorage,RLELossless
+ #pc.217=UltrasoundMultiframeImageStorage,RLELossless
+ #pc.219=MRImageStorage,RLELossless
+ #pc.221=UltrasoundImageStorage,RLELossless
+ #pc.223=SecondaryCaptureImageStorage,RLELossless
+
+ #pc.225=VideoEndoscopicImageStorage,MPEG2
+ #pc.227=VideoMicroscopicImageStorage,MPEG2
+ #pc.229=VideoPhotographicImageStorage,MPEG2
+
+ #pc.231=AmbulatoryECGWaveformStorage,$ts-native
+ #pc.233=BasicVoiceAudioWaveformStorage,$ts-native
+ #pc.235=CardiacElectrophysiologyWaveformStorage,$ts-native
+ #pc.237=GeneralECGWaveformStorage,$ts-native
+ #pc.239=HemodynamicWaveformStorage,$ts-native
+ #pc.241=TwelveLeadECGWaveformStorage,$ts-native
+
+ #pc.243=HangingProtocolStorage,$ts-native
+ #pc.245=EncapsulatedPDFStorage,$ts-native
+
+ #pc.247=BasicStudyContentNotification,$ts-native
+
+
+#>>>>> Presesentation Context for C-FIND >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+pc.251=StudyRootQueryRetrieveInformationModelFIND,$ts-native
+
+
+#>>>>> Presesentation Context for C-MOVE >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+#pc.253=StudyRootQueryRetrieveInformationModelMOVE,$ts-native
+
+
+#>>>>> Presesentation Context for C-ECHO >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+#pc.255=Verification,ImplicitVRLittleEndian
diff --git a/src/resources/KeyTool_genkey_identityJava_20years.bat b/src/resources/KeyTool_genkey_identityJava_20years.bat
new file mode 100644
index 0000000..474c5c2
--- /dev/null
+++ b/src/resources/KeyTool_genkey_identityJava_20years.bat
@@ -0,0 +1,6 @@
+# Generates a keystore containing the private and root-public key for the alias "identityJava".
+# The keys are valid for 20 years (7300 days).
+
+keytool.exe -genkey -keyalg RSA -keystore identityJava.jks -alias identityJava -dname "cn=identityJava, o=dcm4che, c=de" -validity 7300 -keypass secret -storepass secret
+
+pause
\ No newline at end of file
diff --git a/src/resources/SaveFilesystem.cfg b/src/resources/SaveFilesystem.cfg
new file mode 100644
index 0000000..5c6792c
--- /dev/null
+++ b/src/resources/SaveFilesystem.cfg
@@ -0,0 +1,64 @@
+# URI:
+# For Windows-OS the absolute URI "file:/c:/user/tom/" describes the directory "C:\\user\\tom\\".
+# Relative URI's, e.g. without the "file:" schema-prefix, are relativ to the user-directory,
+# given by the system property user.dir. For example: If the user.dir is "C:\\user\\tom\\" 
+# and the relative URI is "/abc/" the referenced directory is "C:\\user\\tom\\abc\\".
+# The abbreviations "." for the current and ".." for the upper directory are valid to form 
+# a relative URI.
+# If the URI must contains special characters (see Character categories) use a escape sequence
+# to define them. Keep in mind that even the space character " " has to be written as "%20".
+
+
+# Tag-String:
+# Normally the strings for the keys and values of a property are used as written. In special
+# cases it is necessary to give them a special meaning. This meaning is described by lead-in
+# characters defined in the following table.
+#
+# $  The string is a named Tag. The substring following the lead-in character is interpreted 
+#    as the name of a tag as given in the class org.dcm4che.dict.Tags.
+#    Example: $SeriesInstanceUID The instance UID of the series. It is equivalent with the
+#             Tag with group number 0x0020 and element number 0x000E.
+# @  The string is a hexadecimal Tag. The substring following the lead-in character is 
+#    interpreted as a 4 character long hexadecimal group number followed by a 4 character
+#    long element number. With a hexadecimal tag it is possible to access private tags, 
+#    which are not defined in the list of tags in org.dcm4che.dict.Tags.
+#    Example: @0020000E The instance UID of the series. It is equivalent with the Tag 
+#             with th name "SeriesInstanceUID".
+
+
+# Describes the base directory as a URI. Default = ./
+#directory = ./
+
+# The name of the file to save. The string may be a Tag-String. Default = DICOM_object
+#file-name = DICOM_object
+
+# The extension (postfix without the character '.') of the file to save. Default = dcm
+#file-extension = dcm
+
+# If true, write files in the subdirectory "$PatientName_$PatientBirthDate/<directory>/". Default = false
+#Enumerated: true, True, false, False
+#separate-patients = false
+
+# Sets the transfer syntax of the file to save. Default = ImplicitVRLittleEndian.
+# The string may start with the escape-character '$', which is ignored.
+# Enumerated: ImplicitVRLittleEndian,ExplicitVRLittleEndian and ExplicitVRBigEndian.
+#transfersyntax = ImplicitVRLittleEndian
+
+# Write files in the subdirectory "[$PatientName_$PatientBirthDate/]<directory>/<use_subdirectory>/". Default =
+# If the value is empty no subdirectory "[$PatientName_$PatientBirthDate/]<directory>/" is used.
+#use-subdirectory = 
+
+# If true:
+# Construct the the filename of the file to save from the following components: 
+# 1.First letter of family name followed by first letter of given name followed by date of birth, 6 character. Example: HT570522 
+# 2.Study date, 6 character. Example: 043012 
+# 3.Modality, 2 character followed by study time, 4 character. Example: MR1531 
+# 4.Study ID. Example: 4711 
+# 5.Series number. Example: 3 
+# 6.Instance number. Example: 54 
+# If false:
+# Construct the the filename of the file to save from directory, name and extension. Default = true
+#write-dir-tree = true
+
+# Sets if a File Mete Information Block should be included in the saved file or not. Default = true
+#write-fmi = true
\ No newline at end of file
diff --git a/src/resources/Series.cfg b/src/resources/Series.cfg
new file mode 100644
index 0000000..c36b7e9
--- /dev/null
+++ b/src/resources/Series.cfg
@@ -0,0 +1,255 @@
+###############################################################################
+# Based on configuration file for dcm4che 1.4.0 sample: dcmsnd.cfg revision date 2005-08-25
+# Version: 2006-06-23
+###############################################################################
+
+# Time-out waiting [in msec] for A-ASSOCIATE-AC acknowlage, 0 is interpreted as an infinite timeout [default=5000].
+ac-timeout = 10000
+
+# Time-out waiting [in msec] for DIMSE on open association, 0 is interpreted as an infinite timeout [default=0]
+dimse-timeout = 0
+
+# Time delay [in msec] for socket close after sending A-ABORT [default=500]
+so-close-delay = 500
+
+# Activates packing of command PDV (Presentation Data Value) + (first) data PDV into one P-DATA-TF PDU (Protocol Data Unit)
+pack-pdvs = false
+
+# Message priority. Possible values low = 2, medium = 0, high = 1
+prior = 0
+
+# Maximal length of receiving PDUs (Protocol Data Unit) [default=16352]
+max-pdu-len = 16352
+
+# Maximal number of invoked operations with outstanding response.
+max-op-invoked = 0
+
+
+#>>>>> TLS: private key and certified-public key >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+# File reference of the container of the private key and certified-public key.
+# For details see the API documentation of the method CDimseService.initTLS
+# PKCS #12 or JKS (Java Keystore) containers may be use. Keys must be RSA encoded
+# Two forms are possible:
+# 1. Absolute reference (file:/C:/a/b/c.txt): The reference is taken as is.
+# 2. Relative reference (b/c.txt): The referece is relative to the package of the class CDimseService
+#tls-key = file:/c:/tmp/identity.p12
+#tls-key = resources/identity.p12
+
+# Password of the keystore containing the private key
+#tls-keystore-passwd = secret
+
+# Password of the private key in the keystore 
+#tls-key-passwd = secret
+
+#>>>>> TLS: root-certificates of Certifying Authorities >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+# File reference of the container of the root-certificates of the Certifying Authorities
+# For details see the API documentation of the method CDimseService.initTLS
+# PKCS #12 or JKS (Java Keystore) containers may be use. Keys must be RSA encoded
+# Two forms are possible:
+# 1. Absolute reference (file:/C:/a/b/c.txt): The reference is taken as is.
+# 2. Relative reference (b/c.txt): The referece is relative to the package of the class CDimseService
+#tls-cacerts = file:/c:/tmp/cacerts.jks
+#tls-cacerts = resources/cacerts.jks
+
+# Password of the keystore containing the root-certificates
+#tls-cacerts-passwd = secret
+
+
+#>>>>> Specific C-FIND >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+# Specifies Key Attributes used for matching in C-FIND
+# Special Key Attributes "QueryRetrieveLevel":
+# Defines the query/retrieve level. Possible values are "STUDY", "SERIES", "IMAGE"
+# See PS 3.4 - C.6.2 Study Root SOP Class Group
+key.QueryRetrieveLevel = SERIES
+
+key.PatientName = 
+key.SeriesNumber =
+key.SeriesInstanceUID =
+key.NumberOfSeriesRelatedInstances =
+key.SeriesDescription = 
+key.ModalitiesInStudy = 
+
+
+#<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
+#>>>>> Specific C-MOVE >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+# Application Entity Title (AET) of the destination for the C-MOVE
+#dest = MOVE_DESTINATION
+
+#<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
+#>>>>> Presesentation Context >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+# Macrodefinition of transfer syntaces
+
+ts-native=ExplicitVRLittleEndian,ImplicitVRLittleEndian
+
+
+# Available transfer syntaces for storage SOP classes
+# PS 3.4 - Annex B STORAGE SERVICE CLASS
+# PS 3.4 - B.5 STANDARD SOP CLASSES
+# Syntax: pc.n = sop_uid,transfer_syntax[,transfer_syntax]
+# with n = presentation context ID (a for the association unique odd number between 1 and 255)
+# with sop_uid = symbolic name of the UID of the SOP to transmit
+# with transfer_syntax = supportet transfer syntax for that SOP
+
+
+#>>>>> Presesentation Context for C-STORE >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+# pc.1=HardcopyGrayscaleImageStorage,$ts-native
+# pc.3=HardcopyColorImageStorage,$ts-native
+# pc.5=ComputedRadiographyImageStorage,$ts-native
+# pc.7=DigitalXRayImageStorageForPresentation,$ts-native
+# pc.9=DigitalXRayImageStorageForProcessing,$ts-native
+# pc.11=DigitalMammographyXRayImageStorageForPresentation,$ts-native
+# pc.13=DigitalMammographyXRayImageStorageForProcessing,$ts-native
+# pc.15=DigitalIntraoralXRayImageStorageForPresentation,$ts-native
+# pc.17=DigitalIntraoralXRayImageStorageForProcessing,$ts-native
+# pc.19=CTImageStorage,$ts-native
+# pc.21=UltrasoundMultiframeImageStorageRetired,$ts-native
+# pc.23=UltrasoundMultiframeImageStorage,$ts-native
+# pc.25=MRImageStorage,$ts-native
+# pc.27=EnhancedMRImageStorage,$ts-native
+# pc.29=NuclearMedicineImageStorageRetired,$ts-native
+# pc.31=UltrasoundImageStorageRetired,$ts-native
+# pc.33=UltrasoundImageStorage,$ts-native
+# pc.35=SecondaryCaptureImageStorage,$ts-native
+# pc.37=MultiframeSingleBitSecondaryCaptureImageStorage,$ts-native
+# pc.39=MultiframeGrayscaleByteSecondaryCaptureImageStorage,$ts-native
+# pc.41=MultiframeGrayscaleWordSecondaryCaptureImageStorage,$ts-native
+# pc.43=MultiframeColorSecondaryCaptureImageStorage,$ts-native
+# pc.45=XRayAngiographicImageStorage,$ts-native
+# pc.47=XRayRadiofluoroscopicImageStorage,$ts-native
+# pc.49=XRayAngiographicBiPlaneImageStorageRetired,$ts-native
+# pc.51=NuclearMedicineImageStorage,$ts-native
+# pc.53=VLImageStorageRetired,$ts-native
+# pc.55=VLMultiframeImageStorageRetired,$ts-native
+# pc.57=VLEndoscopicImageStorage,$ts-native
+# pc.59=VLMicroscopicImageStorage,$ts-native
+# pc.61=VLSlideCoordinatesMicroscopicImageStorage,$ts-native
+# pc.63=VLPhotographicImageStorage,$ts-native
+# pc.65=PositronEmissionTomographyImageStorage,$ts-native
+# pc.67=RTImageStorage,$ts-native
+# pc.69=BasicTextSR,$ts-native
+# pc.71=EnhancedSR,$ts-native
+# pc.73=ComprehensiveSR,$ts-native
+# pc.75=MammographyCADSR,$ts-native
+# pc.77=GrayscaleSoftcopyPresentationStateStorage,$ts-native
+# pc.79=KeyObjectSelectionDocument,$ts-native
+# pc.81=RTDoseStorage,$ts-native
+# pc.83=RTStructureSetStorage,$ts-native
+# pc.85=RTBeamsTreatmentRecordStorage,$ts-native
+# pc.87=RTPlanStorage,$ts-native
+# pc.89=RTBrachyTreatmentRecordStorage,$ts-native
+# pc.91=RTTreatmentSummaryRecordStorage,$ts-native
+# pc.93=RawDataStorage,$ts-native
+
+# pc.95=ComputedRadiographyImageStorage,JPEGLossless
+# pc.97=DigitalXRayImageStorageForPresentation,JPEGLossless
+# pc.99=DigitalXRayImageStorageForProcessing,JPEGLossless
+# pc.101=DigitalMammographyXRayImageStorageForPresentation,JPEGLossless
+# pc.103=DigitalMammographyXRayImageStorageForProcessing,JPEGLossless
+# pc.105=DigitalIntraoralXRayImageStorageForPresentation,JPEGLossless
+# pc.107=DigitalIntraoralXRayImageStorageForProcessing,JPEGLossless
+# pc.109=CTImageStorage,JPEGLossless
+# pc.111=UltrasoundMultiframeImageStorage,JPEGLossless
+# pc.113=MRImageStorage,JPEGLossless
+# pc.115=EnhancedMRImageStorage,JPEGLossless
+# pc.117=UltrasoundImageStorage,JPEGLossless
+# pc.119=SecondaryCaptureImageStorage,JPEGLossless
+# pc.121=MultiframeGrayscaleByteSecondaryCaptureImageStorage,JPEGLossless
+# pc.123=MultiframeGrayscaleWordSecondaryCaptureImageStorage,JPEGLossless
+# pc.125=MultiframeColorSecondaryCaptureImageStorage,JPEGLossless
+# pc.127=XRayAngiographicImageStorage,JPEGLossless
+# pc.129=XRayRadiofluoroscopicImageStorage,JPEGLossless
+# pc.131=NuclearMedicineImageStorage,JPEGLossless
+# pc.133=VLEndoscopicImageStorage,JPEGLossless
+# pc.135=VLMicroscopicImageStorage,JPEGLossless
+# pc.137=VLSlideCoordinatesMicroscopicImageStorage,JPEGLossless
+# pc.139=VLPhotographicImageStorage,JPEGLossless
+# pc.141=PositronEmissionTomographyImageStorage,JPEGLossless
+# pc.143=RTImageStorage,JPEGLossless
+
+# pc.145=UltrasoundMultiframeImageStorage,JPEGBaseline
+# pc.147=UltrasoundImageStorage,JPEGBaseline
+# pc.149=SecondaryCaptureImageStorage,JPEGBaseline
+# pc.151=MultiframeGrayscaleByteSecondaryCaptureImageStorage,JPEGBaseline
+# pc.153=MultiframeColorSecondaryCaptureImageStorage,JPEGBaseline
+# pc.155=XRayAngiographicImageStorage,JPEGBaseline
+
+# pc.157=ComputedRadiographyImageStorage,JPEGExtended
+# pc.159=CTImageStorage,JPEGExtended
+# pc.161=MRImageStorage,JPEGExtended
+# pc.163=SecondaryCaptureImageStorage,JPEGExtended
+
+# pc.165=ComputedRadiographyImageStorage,JPEGLSLossy
+# pc.167=CTImageStorage,JPEGLSLossy
+# pc.169=UltrasoundMultiframeImageStorage,JPEGLSLossy
+# pc.171=MRImageStorage,JPEGLSLossy
+# pc.173=UltrasoundImageStorage,JPEGLSLossy
+# pc.175=SecondaryCaptureImageStorage,JPEGLSLossy
+
+# pc.177=ComputedRadiographyImageStorage,JPEG2000Lossy
+# pc.179=CTImageStorage,JPEG2000Lossy
+# pc.181=UltrasoundMultiframeImageStorage,JPEG2000Lossy
+# pc.183=MRImageStorage,JPEG2000Lossy
+# pc.185=UltrasoundImageStorage,JPEG2000Lossy
+# pc.187=SecondaryCaptureImageStorage,JPEG2000Lossy
+
+# pc.189=ComputedRadiographyImageStorage,JPEGLSLossless
+# pc.191=CTImageStorage,JPEGLSLossless
+# pc.193=UltrasoundMultiframeImageStorage,JPEGLSLossless
+# pc.195=MRImageStorage,JPEGLSLossless
+# pc.197=UltrasoundImageStorage,JPEGLSLossless
+# pc.199=SecondaryCaptureImageStorage,JPEGLSLossless
+
+# pc.201=ComputedRadiographyImageStorage,JPEG2000Lossless
+# pc.203=CTImageStorage,JPEG2000Lossless
+# pc.205=UltrasoundMultiframeImageStorage,JPEG2000Lossless
+# pc.207=MRImageStorage,JPEG2000Lossless
+# pc.209=UltrasoundImageStorage,JPEG2000Lossless
+# pc.211=SecondaryCaptureImageStorage,JPEG2000Lossless
+
+# pc.213=ComputedRadiographyImageStorage,RLELossless
+# pc.215=CTImageStorage,RLELossless
+# pc.217=UltrasoundMultiframeImageStorage,RLELossless
+# pc.219=MRImageStorage,RLELossless
+# pc.221=UltrasoundImageStorage,RLELossless
+# pc.223=SecondaryCaptureImageStorage,RLELossless
+
+# pc.225=VideoEndoscopicImageStorage,MPEG2
+# pc.227=VideoMicroscopicImageStorage,MPEG2
+# pc.229=VideoPhotographicImageStorage,MPEG2
+
+# pc.231=AmbulatoryECGWaveformStorage,$ts-native
+# pc.233=BasicVoiceAudioWaveformStorage,$ts-native
+# pc.235=CardiacElectrophysiologyWaveformStorage,$ts-native
+# pc.237=GeneralECGWaveformStorage,$ts-native
+# pc.239=HemodynamicWaveformStorage,$ts-native
+# pc.241=TwelveLeadECGWaveformStorage,$ts-native
+
+# pc.243=HangingProtocolStorage,$ts-native
+# pc.245=EncapsulatedPDFStorage,$ts-native
+
+# pc.247=BasicStudyContentNotification,$ts-native
+
+
+#>>>>> Presesentation Context for C-FIND >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+pc.251=StudyRootQueryRetrieveInformationModelFIND,$ts-native
+
+
+#>>>>> Presesentation Context for C-MOVE >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+# pc.253=StudyRootQueryRetrieveInformationModelMOVE,$ts-native
+
+
+#>>>>> Presesentation Context for C-ECHO >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+# pc.255=Verification,ImplicitVRLittleEndian
diff --git a/src/resources/StorageService.cfg b/src/resources/StorageService.cfg
new file mode 100644
index 0000000..27ff3ea
--- /dev/null
+++ b/src/resources/StorageService.cfg
@@ -0,0 +1,195 @@
+###############################################################################
+# Based on configuration file for dcm4che 1.4.0 sample: dcmrcv.cfg revision date 2005-12-14
+# Version: 2006-06-23
+###############################################################################
+
+# Port number of the server [default=104]
+port = 104
+
+# Maximum number of simultaneous clients [default=10].
+max-clients = 10
+
+# Time-out waiting [in msec] for A-ASSOCIATE-RQ after TCP connect. 0 is interpreted as an infinite timeout [default=5000].
+rq-timeout = 5000
+
+# Time-out waiting [in msec] for DIMSE on open association. 0 is interpreted as an infinite timeout [default=0].
+dimse-timeout = 0
+
+# Time delay [in msec] for socket close after sending A-RELEASE-RP or A-ABORT [default=500].
+so-close-delay = 500
+
+# Activates packing of command PDV (Presentation Data Value) + (first) data PDV into one P-DATA-TF PDU (Protocol Data Unit)
+pack-pdvs = false
+
+# Own AET (Application Entity Title)
+# Default is "<any>", that means association of any AET is accepted.
+# The provided property value should be a comma or space separated list of individual AETs.
+# Providing no value is equivalent to to a value "<any>".
+called-aets = <any>
+
+# AETs  (Application Entity Titles) of the storage service users
+# Default is "<any>", that means association of any AET is accepted.
+# The provided property value should be a comma or space separated list of individual AETs.
+# Providing no value is equivalent to to a value "<any>".
+calling-aets = <any>
+
+# Maximal length of receiving PDUs (Protocol Data Unit) [default=16352]
+max-pdu-len = 16352
+
+# Maximal number of invoked operations with outstanding response.
+max-op-invoked = 0
+
+# Additional delay of response [in sec] (useful for testing async mode).
+rsp-delay = 0
+
+# Status code in C-STORE-RSP in decimal (#####) or hex (####H) [default=0]. Useful for testing modality behavior in case of status != 0.
+rsp-status = 0
+
+# Type of encryption used for connections [default=dicom]. Enumerated values: dicom, dicom-tls, dicom-tls.nodes and dicom-tls.3des
+protocol = dicom
+
+
+#>>>>> TLS: private key and certified-public key >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+# File reference of the container of the private key and certified-public key.
+# For details see the API documentation of the method StorageService.initTLS
+# PKCS #12 or JKS (Java Keystore) containers may be use. Keys must be RSA encoded
+# Two forms are possible:
+# 1. Absolute reference (file:/C:/a/b/c.txt): The reference is taken as is.
+# 2. Relative reference (b/c.txt): The referece is relative to the package of the class CDimseService
+#tls-key = file:/c:/tmp/identity.p12
+#tls-key = resources/identity.p12
+
+# Password of the keystore containing the private key
+#tls-keystore-passwd = secret
+
+# Password of the private key in the keystore 
+#tls-key-passwd = secret
+
+#>>>>> TLS: root-certificates of Certifying Authorities >>>>>>>>>>>>>>>>>>>>>>>>
+
+# File reference of the container of the root-certificates of the Certifying Authorities
+# For details see the API documentation of the method StorageService.initTLS
+# PKCS #12 or JKS (Java Keystore) containers may be use. Keys must be RSA encoded
+# Two forms are possible:
+# 1. Absolute reference (file:/C:/a/b/c.txt): The reference is taken as is.
+# 2. Relative reference (b/c.txt): The referece is relative to the package of the class CDimseService
+#tls-cacerts = file:/c:/tmp/cacerts.jks
+#tls-cacerts = resources/cacerts.jks
+
+# Password of the keystore containing the root-certificates
+#tls-cacerts-passwd = secret
+
+
+#>>>>> Available transfer syntaces for storage SOP classes >>>>>>>>>>>>>>>>>>>>>
+# PS 3.4 - Annex B STORAGE SERVICE CLASS
+# PS 3.4 - B.5 STANDARD SOP CLASSES
+
+ts-native=ExplicitVRLittleEndian,ExplicitVRBigEndian,ImplicitVRLittleEndian
+ts-retired=JPEGExtended35Retired,JPEG68Retired,JPEG79Retired,JPEG1012Retired,JPEG1113Retired,JPEGLossless15Retired,JPEG1618Retired,JPEG1719Retired,JPEG2022Retired,JPEG2123Retired,JPEG2426Retired,JPEG2527Retired,JPEGLoRetired,JPEG29Retired
+ts-lossless=JPEGLossless14,JPEGLossless,JPEGLSLossless,JPEG2000Lossless,RLELossless
+ts-lossy=JPEGBaseline,JPEGExtended,JPEGLSLossy,JPEG2000Lossy
+ts-image=$ts-lossless,$ts-lossy,$ts-native
+ts-sr=DeflatedExplicitVRLittleEndian,$ts-native
+
+# Syntax: pc.sop_uid = transfer_syntax[,transfer_syntax]
+# with sop_uid = symbolic name of the UID of the SOP to transmit
+# with transfer_syntax = supportet transfer syntax for that SOP
+
+pc.HardcopyGrayscaleImageStorage=$ts-image
+pc.HardcopyColorImageStorage=$ts-image
+pc.ComputedRadiographyImageStorage=$ts-image
+pc.DigitalXRayImageStorageForPresentation=$ts-image
+pc.DigitalXRayImageStorageForProcessing=$ts-image
+pc.DigitalMammographyXRayImageStorageForPresentation=$ts-image
+pc.DigitalMammographyXRayImageStorageForProcessing=$ts-image
+pc.DigitalIntraoralXRayImageStorageForPresentation=$ts-image
+pc.DigitalIntraoralXRayImageStorageForProcessing=$ts-image
+pc.CTImageStorage=$ts-image
+pc.UltrasoundMultiframeImageStorageRetired=$ts-image
+pc.UltrasoundMultiframeImageStorage=$ts-image
+pc.MRImageStorage=$ts-image
+pc.EnhancedMRImageStorage=$ts-image
+pc.MRSpectroscopyStorage=$ts-image
+pc.NuclearMedicineImageStorageRetired=$ts-image
+pc.UltrasoundImageStorageRetired=$ts-image
+pc.UltrasoundImageStorage=$ts-image
+pc.SecondaryCaptureImageStorage=$ts-image
+pc.MultiframeSingleBitSecondaryCaptureImageStorage=$ts-image
+pc.MultiframeGrayscaleByteSecondaryCaptureImageStorage=$ts-image
+pc.MultiframeGrayscaleWordSecondaryCaptureImageStorage=$ts-image
+pc.MultiframeColorSecondaryCaptureImageStorage=$ts-image
+pc.XRayAngiographicImageStorage=$ts-image
+pc.XRayRadiofluoroscopicImageStorage=$ts-image
+pc.XRayAngiographicBiPlaneImageStorageRetired=$ts-image
+pc.NuclearMedicineImageStorage=$ts-image
+pc.VLImageStorageRetired=$ts-image
+pc.VLMultiframeImageStorageRetired=$ts-image
+pc.VLEndoscopicImageStorage=$ts-image
+pc.VLMicroscopicImageStorage=$ts-image
+pc.VLSlideCoordinatesMicroscopicImageStorage=$ts-image
+pc.VLPhotographicImageStorage=$ts-image
+pc.PositronEmissionTomographyImageStorage=$ts-image
+pc.RTImageStorage=$ts-image
+
+pc.StoredPrintStorage=$ts-native
+pc.StandaloneOverlayStorage=$ts-native
+pc.StandaloneCurveStorage=$ts-native
+pc.TwelveLeadECGWaveformStorage=$ts-native
+pc.GeneralECGWaveformStorage=$ts-native
+pc.AmbulatoryECGWaveformStorage=$ts-native
+pc.HemodynamicWaveformStorage=$ts-native
+pc.CardiacElectrophysiologyWaveformStorage=$ts-native
+pc.BasicVoiceAudioWaveformStorage=$ts-native
+pc.StandaloneModalityLUTStorage=$ts-native
+pc.StandaloneVOILUTStorage=$ts-native
+pc.GrayscaleSoftcopyPresentationStateStorage=$ts-native
+pc.RawDataStorage=$ts-native
+pc.EncapsulatedPDFStorage=$ts-native
+
+pc.BasicTextSR=$ts-sr
+pc.EnhancedSR=$ts-sr
+pc.ComprehensiveSR=$ts-sr
+pc.MammographyCADSR=$ts-sr
+
+pc.KeyObjectSelectionDocument=$ts-native
+pc.StandalonePETCurveStorage=$ts-native
+pc.RTDoseStorage=$ts-native
+pc.RTStructureSetStorage=$ts-native
+pc.RTPlanStorage=$ts-native
+pc.RTIonPlanStorage=$ts-native
+pc.RTIonBeamsTreatmentRecordStorage=$ts-native
+pc.RTBeamsTreatmentRecordStorage=$ts-native
+pc.RTBrachyTreatmentRecordStorage=$ts-native
+pc.RTTreatmentSummaryRecordStorage=$ts-native
+
+pc.VideoEndoscopicImageStorage=MPEG2
+pc.VideoMicroscopicImageStorage=MPEG2
+pc.VideoPhotographicImageStorage=MPEG2
+
+pc.BasicStudyContentNotification=$ts-native
+pc.InstanceAvailabilityNotificationSOPClass=$ts-native
+
+pc.ModalityPerformedProcedureStep=$ts-native
+pc.GeneralPurposePerformedProcedureStepSOPClass=$ts-native
+pc.MediaCreationManagementSOPClass=$ts-native
+
+pc.HangingProtocolStorage=$ts-native
+
+pc.DetachedPatientManagement=$ts-native
+pc.DetachedResultsManagement=$ts-native
+pc.DetachedInterpretationManagement=$ts-native
+
+pc.TianiStudyManagement=$ts-native
+
+
+# User/provider role for Management Service Classes
+# PS3.4 - Annex E PATIENT MANAGEMENT SERVICE CLASS (retired since 2004)
+#                 -- Detached Patient Management SOP class
+# PS3.4 - Annex G RESULTS MANAGEMENT SERVICE CLASS (retired since 2004)
+#                 -- Detached Result Management SOP class
+#                 -- Detached Interpretation Management SOP class
+
+role.DetachedPatientManagement=scu,scp
+role.DetachedResultsManagement=scu,scp
+role.DetachedInterpretationManagement=scu,scp
diff --git a/src/resources/Study.cfg b/src/resources/Study.cfg
new file mode 100644
index 0000000..56653f3
--- /dev/null
+++ b/src/resources/Study.cfg
@@ -0,0 +1,264 @@
+###############################################################################
+# Based on configuration file for dcm4che 1.4.0 sample: dcmsnd.cfg revision date 2005-08-25
+# Version: 2006-06-23
+###############################################################################
+
+# Time-out waiting [in msec] for A-ASSOCIATE-AC acknowlage, 0 is interpreted as an infinite timeout [default=5000].
+ac-timeout = 10000
+
+# Time-out waiting [in msec] for DIMSE on open association, 0 is interpreted as an infinite timeout [default=0]
+dimse-timeout = 0
+
+# Time delay [in msec] for socket close after sending A-ABORT [default=500]
+so-close-delay = 500
+
+# Activates packing of command PDV (Presentation Data Value) + (first) data PDV into one P-DATA-TF PDU (Protocol Data Unit)
+pack-pdvs = false
+
+# Message priority. Possible values low = 2, medium = 0, high = 1
+prior = 0
+
+# Maximal length of receiving PDUs (Protocol Data Unit) [default=16352]
+max-pdu-len = 16352
+
+# Maximal number of invoked operations with outstanding response.
+max-op-invoked = 0
+
+
+#>>>>> TLS: private key and certified-public key >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+# File reference of the container of the private key and certified-public key.
+# For details see the API documentation of the method CDimseService.initTLS
+# PKCS #12 or JKS (Java Keystore) containers may be use. Keys must be RSA encoded
+# Two forms are possible:
+# 1. Absolute reference (file:/C:/a/b/c.txt): The reference is taken as is.
+# 2. Relative reference (b/c.txt): The referece is relative to the package of the class CDimseService
+#tls-key = file:/c:/tmp/identity.p12
+#tls-key = resources/identity.p12
+
+# Password of the keystore containing the private key
+#tls-keystore-passwd = secret
+
+# Password of the private key in the keystore 
+#tls-key-passwd = secret
+
+#>>>>> TLS: root-certificates of Certifying Authorities >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+# File reference of the container of the root-certificates of the Certifying Authorities
+# For details see the API documentation of the method CDimseService.initTLS
+# PKCS #12 or JKS (Java Keystore) containers may be use. Keys must be RSA encoded
+# Two forms are possible:
+# 1. Absolute reference (file:/C:/a/b/c.txt): The reference is taken as is.
+# 2. Relative reference (b/c.txt): The referece is relative to the package of the class CDimseService
+#tls-cacerts = file:/c:/tmp/cacerts.jks
+#tls-cacerts = resources/cacerts.jks
+
+# Password of the keystore containing the root-certificates
+#tls-cacerts-passwd = secret
+
+
+#>>>>> Specific C-FIND >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+# Specifies Key Attributes used for matching in C-FIND
+# Special Key Attributes "QueryRetrieveLevel":
+# Defines the query/retrieve level. Possible values are "STUDY", "SERIES", "IMAGE"
+# See PS 3.4 - C.6.2 Study Root SOP Class Group
+key.QueryRetrieveLevel = STUDY
+
+key.PatientName = 
+key.PatientID =
+key.PatientSex =
+key.PatientBirthDate = 
+key.StudyID = 
+key.StudyInstanceUID =
+key.StudyDescription = 
+key.SeriesInstanceUID
+key.SeriesNumber = 
+key.InstanceNumber = 
+key.ModalitiesInStudy = 
+key.StudyDate = 
+key.NumberOfStudyRelatedSeries =
+key.StudyTime = 
+key.ReferringPhysicianName =
+key.AccessionNumber=
+
+<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
+>>>>> Specific C-MOVE >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+# Application Entity Title (AET) of the destination for the C-MOVE
+dest = MOVE_DESTINATION
+
+<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+
+>>>>> Presesentation Context >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+# Macrodefinition of transfer syntaces
+
+ts-native=ExplicitVRLittleEndian,ImplicitVRLittleEndian
+
+
+# Available transfer syntaces for storage SOP classes
+# PS 3.4 - Annex B STORAGE SERVICE CLASS
+# PS 3.4 - B.5 STANDARD SOP CLASSES
+# Syntax: pc.n = sop_uid,transfer_syntax[,transfer_syntax]
+# with n = presentation context ID (a for the association unique odd number between 1 and 255)
+# with sop_uid = symbolic name of the UID of the SOP to transmit
+# with transfer_syntax = supportet transfer syntax for that SOP
+
+
+>>>>> Presesentation Context for C-STORE >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+ #pc.1=HardcopyGrayscaleImageStorage,$ts-native
+ #pc.3=HardcopyColorImageStorage,$ts-native
+ #pc.5=ComputedRadiographyImageStorage,$ts-native
+ #pc.7=DigitalXRayImageStorageForPresentation,$ts-native
+ #pc.9=DigitalXRayImageStorageForProcessing,$ts-native
+ #pc.11=DigitalMammographyXRayImageStorageForPresentation,$ts-native
+ #pc.13=DigitalMammographyXRayImageStorageForProcessing,$ts-native
+ #pc.15=DigitalIntraoralXRayImageStorageForPresentation,$ts-native
+ #pc.17=DigitalIntraoralXRayImageStorageForProcessing,$ts-native
+ #pc.19=CTImageStorage,$ts-native
+ #pc.21=UltrasoundMultiframeImageStorageRetired,$ts-native
+ #pc.23=UltrasoundMultiframeImageStorage,$ts-native
+ #pc.25=MRImageStorage,$ts-native
+ #pc.27=EnhancedMRImageStorage,$ts-native
+ #pc.29=NuclearMedicineImageStorageRetired,$ts-native
+ #pc.31=UltrasoundImageStorageRetired,$ts-native
+ #pc.33=UltrasoundImageStorage,$ts-native
+ #pc.35=SecondaryCaptureImageStorage,$ts-native
+ #pc.37=MultiframeSingleBitSecondaryCaptureImageStorage,$ts-native
+ #pc.39=MultiframeGrayscaleByteSecondaryCaptureImageStorage,$ts-native
+ #pc.41=MultiframeGrayscaleWordSecondaryCaptureImageStorage,$ts-native
+ #pc.43=MultiframeColorSecondaryCaptureImageStorage,$ts-native
+ #pc.45=XRayAngiographicImageStorage,$ts-native
+ #pc.47=XRayRadiofluoroscopicImageStorage,$ts-native
+ #pc.49=XRayAngiographicBiPlaneImageStorageRetired,$ts-native
+ #pc.51=NuclearMedicineImageStorage,$ts-native
+ #pc.53=VLImageStorageRetired,$ts-native
+ #pc.55=VLMultiframeImageStorageRetired,$ts-native
+ #pc.57=VLEndoscopicImageStorage,$ts-native
+ #pc.59=VLMicroscopicImageStorage,$ts-native
+ #pc.61=VLSlideCoordinatesMicroscopicImageStorage,$ts-native
+ #pc.63=VLPhotographicImageStorage,$ts-native
+ #pc.65=PositronEmissionTomographyImageStorage,$ts-native
+ #pc.67=RTImageStorage,$ts-native
+ #pc.69=BasicTextSR,$ts-native
+ #pc.71=EnhancedSR,$ts-native
+ #pc.73=ComprehensiveSR,$ts-native
+ #pc.75=MammographyCADSR,$ts-native
+ #pc.77=GrayscaleSoftcopyPresentationStateStorage,$ts-native
+ #pc.79=KeyObjectSelectionDocument,$ts-native
+ #pc.81=RTDoseStorage,$ts-native
+ #pc.83=RTStructureSetStorage,$ts-native
+ #pc.85=RTBeamsTreatmentRecordStorage,$ts-native
+ #pc.87=RTPlanStorage,$ts-native
+ #pc.89=RTBrachyTreatmentRecordStorage,$ts-native
+ #pc.91=RTTreatmentSummaryRecordStorage,$ts-native
+ #pc.93=RawDataStorage,$ts-native
+
+ #pc.95=ComputedRadiographyImageStorage,JPEGLossless
+ #pc.97=DigitalXRayImageStorageForPresentation,JPEGLossless
+ #pc.99=DigitalXRayImageStorageForProcessing,JPEGLossless
+ #pc.101=DigitalMammographyXRayImageStorageForPresentation,JPEGLossless
+ #pc.103=DigitalMammographyXRayImageStorageForProcessing,JPEGLossless
+ #pc.105=DigitalIntraoralXRayImageStorageForPresentation,JPEGLossless
+ #pc.107=DigitalIntraoralXRayImageStorageForProcessing,JPEGLossless
+ #pc.109=CTImageStorage,JPEGLossless
+ #pc.111=UltrasoundMultiframeImageStorage,JPEGLossless
+ #pc.113=MRImageStorage,JPEGLossless
+ #pc.115=EnhancedMRImageStorage,JPEGLossless
+ #pc.117=UltrasoundImageStorage,JPEGLossless
+ #pc.119=SecondaryCaptureImageStorage,JPEGLossless
+ #pc.121=MultiframeGrayscaleByteSecondaryCaptureImageStorage,JPEGLossless
+ #pc.123=MultiframeGrayscaleWordSecondaryCaptureImageStorage,JPEGLossless
+ #pc.125=MultiframeColorSecondaryCaptureImageStorage,JPEGLossless
+ #pc.127=XRayAngiographicImageStorage,JPEGLossless
+ #pc.129=XRayRadiofluoroscopicImageStorage,JPEGLossless
+ #pc.131=NuclearMedicineImageStorage,JPEGLossless
+ #pc.133=VLEndoscopicImageStorage,JPEGLossless
+ #pc.135=VLMicroscopicImageStorage,JPEGLossless
+ #pc.137=VLSlideCoordinatesMicroscopicImageStorage,JPEGLossless
+ #pc.139=VLPhotographicImageStorage,JPEGLossless
+ #pc.141=PositronEmissionTomographyImageStorage,JPEGLossless
+ #pc.143=RTImageStorage,JPEGLossless
+
+ #pc.145=UltrasoundMultiframeImageStorage,JPEGBaseline
+ #pc.147=UltrasoundImageStorage,JPEGBaseline
+ #pc.149=SecondaryCaptureImageStorage,JPEGBaseline
+ #pc.151=MultiframeGrayscaleByteSecondaryCaptureImageStorage,JPEGBaseline
+ #pc.153=MultiframeColorSecondaryCaptureImageStorage,JPEGBaseline
+ #pc.155=XRayAngiographicImageStorage,JPEGBaseline
+
+ #pc.157=ComputedRadiographyImageStorage,JPEGExtended
+ #pc.159=CTImageStorage,JPEGExtended
+ #pc.161=MRImageStorage,JPEGExtended
+ #pc.163=SecondaryCaptureImageStorage,JPEGExtended
+
+ #pc.165=ComputedRadiographyImageStorage,JPEGLSLossy
+ #pc.167=CTImageStorage,JPEGLSLossy
+ #pc.169=UltrasoundMultiframeImageStorage,JPEGLSLossy
+ #pc.171=MRImageStorage,JPEGLSLossy
+ #pc.173=UltrasoundImageStorage,JPEGLSLossy
+ #pc.175=SecondaryCaptureImageStorage,JPEGLSLossy
+
+ #pc.177=ComputedRadiographyImageStorage,JPEG2000Lossy
+ #pc.179=CTImageStorage,JPEG2000Lossy
+ #pc.181=UltrasoundMultiframeImageStorage,JPEG2000Lossy
+ #pc.183=MRImageStorage,JPEG2000Lossy
+ #pc.185=UltrasoundImageStorage,JPEG2000Lossy
+ #pc.187=SecondaryCaptureImageStorage,JPEG2000Lossy
+
+ #pc.189=ComputedRadiographyImageStorage,JPEGLSLossless
+ #pc.191=CTImageStorage,JPEGLSLossless
+ #pc.193=UltrasoundMultiframeImageStorage,JPEGLSLossless
+ #pc.195=MRImageStorage,JPEGLSLossless
+ #pc.197=UltrasoundImageStorage,JPEGLSLossless
+ #pc.199=SecondaryCaptureImageStorage,JPEGLSLossless
+
+ #pc.201=ComputedRadiographyImageStorage,JPEG2000Lossless
+ #pc.203=CTImageStorage,JPEG2000Lossless
+ #pc.205=UltrasoundMultiframeImageStorage,JPEG2000Lossless
+ #pc.207=MRImageStorage,JPEG2000Lossless
+ #pc.209=UltrasoundImageStorage,JPEG2000Lossless
+ #pc.211=SecondaryCaptureImageStorage,JPEG2000Lossless
+
+ #pc.213=ComputedRadiographyImageStorage,RLELossless
+ #pc.215=CTImageStorage,RLELossless
+ #pc.217=UltrasoundMultiframeImageStorage,RLELossless
+ #pc.219=MRImageStorage,RLELossless
+ #pc.221=UltrasoundImageStorage,RLELossless
+ #pc.223=SecondaryCaptureImageStorage,RLELossless
+
+ #pc.225=VideoEndoscopicImageStorage,MPEG2
+ #pc.227=VideoMicroscopicImageStorage,MPEG2
+ #pc.229=VideoPhotographicImageStorage,MPEG2
+
+ #pc.231=AmbulatoryECGWaveformStorage,$ts-native
+ #pc.233=BasicVoiceAudioWaveformStorage,$ts-native
+ #pc.235=CardiacElectrophysiologyWaveformStorage,$ts-native
+ #pc.237=GeneralECGWaveformStorage,$ts-native
+ #pc.239=HemodynamicWaveformStorage,$ts-native
+ #pc.241=TwelveLeadECGWaveformStorage,$ts-native
+
+ #pc.243=HangingProtocolStorage,$ts-native
+ #pc.245=EncapsulatedPDFStorage,$ts-native
+
+ #pc.247=BasicStudyContentNotification,$ts-native
+
+
+>>>>> Presesentation Context for C-FIND >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+pc.251=StudyRootQueryRetrieveInformationModelFIND,$ts-native
+
+
+>>>>> Presesentation Context for C-MOVE >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+#pc.253=StudyRootQueryRetrieveInformationModelMOVE,$ts-native
+
+
+>>>>> Presesentation Context for C-ECHO >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+#pc.255=Verification,ImplicitVRLittleEndian
diff --git a/src/resources/cacerts.jks b/src/resources/cacerts.jks
new file mode 100644
index 0000000..da35e5e
Binary files /dev/null and b/src/resources/cacerts.jks differ
diff --git a/src/resources/identity.p12 b/src/resources/identity.p12
new file mode 100644
index 0000000..3538a4a
Binary files /dev/null and b/src/resources/identity.p12 differ
diff --git a/src/resources/identityJava.jks b/src/resources/identityJava.jks
new file mode 100644
index 0000000..180b611
Binary files /dev/null and b/src/resources/identityJava.jks differ
diff --git a/src/resources/movescu.cfg b/src/resources/movescu.cfg
new file mode 100644
index 0000000..a8ef73c
--- /dev/null
+++ b/src/resources/movescu.cfg
@@ -0,0 +1,23 @@
+# Configuration file for movescu.jar
+
+#info-model=PatientRoot
+info-model=StudyRoot
+#info-model=PatientStudyOnly
+
+ext-neg=true
+
+ac-timeout=5000
+dimse-timeout=0
+so-close-delay=500
+
+prior=0
+max-pdu-len=16352
+max-op-invoked=0
+pack-pdvs=false
+
+tls-key=identity.p12
+tls-key-passwd=secret
+tls-cacerts=cacerts.jks
+tls-cacerts-passwd=secret
+
+ts=ExplicitVRLittleEndian,ImplicitVRLittleEndian

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/mayam.git



More information about the debian-med-commit mailing list