293. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 12/5/2017 12:06:45 PM Central Standard Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

293.1 Files compared

# Location File Last Modified
1 IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\ImagingExchangeImageConversion\main\src\java\gov\va\med\imaging\exchange\conversion\configuration ImageLossyCompressionConfiguration.java Mon Dec 4 21:35:18 2017 UTC
2 IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\ImagingExchangeImageConversion\main\src\java\gov\va\med\imaging\exchange\conversion\configuration ImageLossyCompressionConfiguration.java Mon Dec 4 22:03:23 2017 UTC

293.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 3 822
Changed 2 4
Inserted 0 0
Removed 0 0

293.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

293.4 Active regular expressions

No regular expressions were active.

293.5 Comparison detail

  1   /**
  2    * 
  3     Package:  MAG - Vis tA Imaging
  4     WARNING:  Per VHA D irective 2 004-038, t his routin e should n ot be modi fied.
  5     Date Cre ated: May  26, 2009
  6     Site Nam e:  Washin gton OI Fi eld Office , Silver S pring, MD
  7       Developer:          
TITTOC
  8     Descript ion: 
  9  
  10           ;;  +-------- ---------- ---------- ---------- ---------- ---------- ---------- +
  11           ;;  Property  of the US  Government .
  12           ;;  No permis sion to co py or redi stribute t his softwa re is give n.
  13           ;;  Use of un released v ersions of  this soft ware requi res the us er
  14           ;;   to execu te a writt en test ag reement wi th the Vis tA Imaging
  15           ;;   Developm ent Office  of the De partment o f Veterans  Affairs,
  16           ;;   telephon e (301) 73 4-0100.
  17           ;;
  18           ;;  The Food  and Drug A dministrat ion classi fies this  software a s
  19           ;;  a Class I I medical  device.  A s such, it  may not b e changed
  20           ;;  in any wa y.  Modifi cations to  this soft ware may r esult in a n
  21           ;;  adulterat ed medical  device un der 21CFR8 20, the us e of which
  22           ;;  is consid ered to be  a violati on of US F ederal Sta tutes.
  23           ;;  +-------- ---------- ---------- ---------- ---------- ---------- ---------- +
  24  
  25    */
  26   package go v.va.med.i maging.exc hange.conv ersion.con figuration ;
  27  
  28   import gov .va.med.im aging.core .interface s.IImageLo ssyCompres sionConfig uration;
  29   import gov .va.med.im aging.core .interface s.exceptio ns.Applica tionConfig urationExc eption;
  30   import gov .va.med.im aging.exch ange.busin ess.Modali tyLossyCom pressionPa rameters;
  31  
  32   import jav a.beans.XM LDecoder;
  33   import jav a.beans.XM LEncoder;
  34   import jav a.io.Buffe redInputSt ream;
  35   import jav a.io.Buffe redOutputS tream;
  36   import jav a.io.File;
  37   import jav a.io.FileI nputStream ;
  38   import jav a.io.FileN otFoundExc eption;
  39   import jav a.io.FileO utputStrea m;
  40   import jav a.util.Arr ayList;
  41   import jav a.util.Lis t;
  42  
  43   import org .apache.lo gging.log4 j.LogManag er;
  44   import org .apache.lo gging.log4 j.Logger;
  45  
  46   /**
  47    * Image c onversion  configurat ion. Conta ins option s for usin g in Image  conversio n.
  48    * 
  49    * @author         
WERFEJ
  50    *
  51    */
  52   public cla ss ImageLo ssyCompres sionConfig uration 
  53   implements  IImageLos syCompress ionConfigu ration
  54   {
  55           /* *
  56            *  TODO adju st big fil e border,  J2K compre ssion fact ors and JP G compress  qualities
  57            * /
  58           pr ivate stat ic int        average ImageSize  = 1048576;  // 1 MB
  59           pr ivate stat ic float s mallCompre ssRatio =  10.0f; //  lossy J2K  compressio n ratio fo r small im ages 
  60           pr ivate stat ic float b igCompress Ratio = 25 .0f;   //  lossy J2K  compressio n ratio fo r large im ages 
  61           pr ivate stat ic int        smallCo mpressQual ity = 75;   // lossy  JPG compre ssion qual ity for sm all images  (0..100;  75 - JPG d efault)
  62           pr ivate stat ic int        bigComp ressQualit y = 50;     // lossy  compressio n quality  for large  images 
  63  
  64           pr ivate stat ic final S tring MODA LITY_LOSSY _COMPRESSI ON_CONFIG_ FILENAME =  "ImageLos syCompress ionConfig. xml";
  65           pr ivate stat ic final   Logger log ger = LogM anager.get Logger(Ima geLossyCom pressionCo nfiguratio n.class);
  66  
  67           pr otected bo olean exch angeCompat ibilityMod eEnabled =  true;
  68           
  69           pr otected Li st<Modalit yLossyComp ressionPar ameters> i mageLossyC ompression ConfigList  = new Arr ayList<Mod alityLossy Compressio nParameter s>();
  70           
  71           pr ivate Stri ng vixConf igurationD irectory =  null;
  72           pr ivate Stri ng imageLo ssyCompres sionConfig urationFil espec = nu ll;
  73           
  74           pu blic Image LossyCompr essionConf iguration( )
  75           {
  76                    supe r();
  77           }
  78           
  79           pu blic void  init() 
  80           th rows Appli cationConf igurationE xception
  81           {
  82                    getI mageLossyC ompression Configurat ionFilespe c();
  83                    imag eLossyComp ressionCon figList.cl ear();
  84           }
  85           
  86           @O verride
  87           pu blic boole an loadIma geLossyCom pressionCo nfiguratio nFromFile(
  88           {
  89                    bool ean succes s = false;
  90                    try
  91                    {
  92                             succes s = this.l oadAppConf igurationF romFile(th is.getImag eLossyComp ressionCon figuration Filespec() ); // uses  read lock
  93                    }
  94                    catc h (Applica tionConfig urationExc eption ex)  
  95                    {
  96                             logger .error("Er ror in Ima geLossyCom pressionCo nfiguratio n.loadImag eLossyComp ressionCon figuration FromFile",  ex);
  97                    }
  98                    retu rn success ;
  99           }        
  100  
  101           /* *
  102            *  @param fi leSpec - t he file th at contain s the appl ication co nfiguratio n
  103            *  @return t rue if the  configura tion was s uccessfull y loaded f rom the fi le specifi ed by appC onfigurati onFilespec
  104            * /
  105           pr ivate bool ean loadAp pConfigura tionFromFi le(String  fileSpec) 
  106           {
  107                    logg er.info("L oading ima ge compres sion ratio  configura tion from  '" + fileS pec + "'." );
  108                    
  109                    bool ean succes s = false;
  110                    XMLD ecoder xml Decoder =  null;
  111                    Imag eLossyComp ressionCon figuration  imageLoss yCompressi onConfigur ation = nu ll;
  112  
  113                    if ( fileSpec ! = null)
  114                    {
  115                             File c onfigFile  = new File (fileSpec) ;
  116                             if (co nfigFile.e xists())
  117                             {
  118                                      try
  119                                      {
  120                                               xmlDecoder  = new XML Decoder(ne w Buffered InputStrea m(new File InputStrea m(fileSpec ))); // th rows FileN otFoundExc eption
  121                                               imageLossy Compressio nConfigura tion = (Im ageLossyCo mpressionC onfigurati on) xmlDec oder.readO bject();
  122                                               if (imageL ossyCompre ssionConfi guration ! = null)
  123                                               {
  124                                                       th is.assignS tate(image LossyCompr essionConf iguration) ; // this  method obt ains a wri te lock
  125                                                       lo gger.info( "ImageLoss yCompressi onConfigur ation: loa ded Lossy  Image Comp ression co nfiguratio n from: "  + fileSpec );
  126                                                       su ccess = tr ue;
  127                                               }
  128                                      }
  129                                      catch (F ileNotFoun dException  ex)
  130                                      {
  131                                               logger.err or(ex.getM essage());
  132                                      }
  133                                      catch (A rrayIndexO utOfBounds Exception  ex)
  134                                      {
  135                                               logger.err or("ImageL ossyCompre ssionConfi guration.l oadAppConf igurationF romFile: A rrayIndexO utOfBounds Exception  : " + ex.g etMessage( ));
  136                                      }
  137                                      finally
  138                                      {
  139                                               if (xmlDec oder != nu ll)
  140                                               {
  141                                                       xm lDecoder.c lose();
  142                                               }
  143                                      }
  144                             }
  145                    }
  146                    logg er.info("I mage lossy  compressi on configu ration fro m file '"  + fileSpec  + "' load ed.");
  147                    retu rn success ;
  148           }
  149           
  150           /* *
  151            *  @param im ageLossyCo mpressionC onfigurati on - the A ppConfigur ation obje ct that co ntains the  state to  use
  152            *  This publ ic method  takes the  state of t he passed  appConfigu ration par am and ove rlays it o nto the cu rrent inst ance
  153            * /
  154           pr ivate void  assignSta te(ImageLo ssyCompres sionConfig uration im ageLossyCo mpressionC onfigurati on)
  155           {
  156                    if ( imageLossy Compressio nConfigura tion != nu ll)
  157                    {
  158                             this.e xchangeCom patibility ModeEnable d = imageL ossyCompre ssionConfi guration.e xchangeCom patibility ModeEnable d;                      
  159                             this.i mageLossyC ompression ConfigList .addAll(im ageLossyCo mpressionC onfigurati on.imageLo ssyCompres sionConfig List);
  160                    }
  161           }
  162           
  163           pr ivate Stri ng getImag eLossyComp ressionCon figuration Filespec()  
  164           th rows Appli cationConf igurationE xception
  165           {
  166                    Stri ng fileSpe c = null;          
  167                    file Spec = thi s.imageLos syCompress ionConfigu rationFile spec;
  168                    
  169  
  170                    if ( fileSpec = = null)
  171                    {
  172                             fileSp ec = this. getVixConf igurationD irectory() ;
  173                             // add  the trail ing file s eparator c haracter i f necessar y
  174                             if (!f ileSpec.en dsWith("\\ ") || !fil eSpec.ends With("/"))
  175                             {
  176                                      fileSpec  += "/";
  177                             }
  178                             fileSp ec += MODA LITY_LOSSY _COMPRESSI ON_CONFIG_ FILENAME;
  179  
  180                             this.s etAppConfi gurationFi lespec(fil eSpec);
  181                    }
  182                    
  183                    retu rn fileSpe c;
  184           }
  185           
  186           pr ivate void  setAppCon figuration Filespec(S tring file Spec) 
  187           {
  188                    this .imageLoss yCompressi onConfigur ationFiles pec = file Spec;              
  189           }
  190           
  191           pr ivate Stri ng getVixC onfigurati onDirector y() 
  192           th rows Appli cationConf igurationE xception
  193           {
  194                    Stri ng configD ir = null;
  195                    conf igDir = th is.vixConf igurationD irectory;               
  196                    if ( configDir  == null)
  197                    {
  198                             config Dir = Syst em.getenv( "vixconfig ");
  199                             if (co nfigDir ==  null)
  200                             {
  201                                      throw ne w Applicat ionConfigu rationExce ption("The  vixconfig  has not b een set.") ;
  202                             }
  203  
  204                             this.s etVixConfi gurationDi rectory(co nfigDir);
  205                    }
  206                    retu rn configD ir;
  207           }
  208           
  209           pr ivate void  setVixCon figuration Directory( String vix Configurat ionDirecto ry) 
  210           {
  211                    this .vixConfig urationDir ectory = v ixConfigur ationDirec tory;
  212           }
  213           
  214           
  215           /*  (non-Java doc)
  216            *  @see gov. va.med.ima ging.core. interfaces .IImageLos syCompress ionConfigu ration#isD ecompressi onEnabled( )
  217            * /
  218           @O verride
  219           pu blic boole an isExcha ngeCompati bilityMode Enabled() 
  220           {
  221                    retu rn this.ex changeComp atibilityM odeEnabled ;
  222           }
  223           
  224           /*  (non-Java doc)
  225            *  @see gov. va.med.ima ging.core. interfaces .IImageLos syCompress ionConfigu ration#set Decompress ionEnabled (boolean)
  226            * /
  227           @O verride
  228           pu blic void  setExchang eCompatibi lityMode(b oolean ena bled) 
  229           {
  230                    this .exchangeC ompatibili tyModeEnab led = enab led;
  231           }
  232  
  233           @O verride
  234           pu blic List< ModalityLo ssyCompres sionParame ters> getI mageLossyC ompression ConfigList () 
  235           {
  236                    retu rn this.im ageLossyCo mpressionC onfigList;              
  237           }
  238  
  239           pu blic void  setImageLo ssyCompres sionConfig List(
  240                             List<M odalityLos syCompress ionParamet ers> image LossyCompr essionConf igList) 
  241           {
  242                    this .imageLoss yCompressi onConfigLi st = image LossyCompr essionConf igList;
  243           }
  244           
  245           @O verride
  246           pu blic float  getModali tyLossyJPE G2000Ratio (String mo dality, in t imageByt es, boolea n xChangeU se) 
  247           {                          
  248                    floa t xCompatR atio= (ima geBytes >  averageIma geSize) ?  bigCompres sRatio : s mallCompre ssRatio;             
  249  
  250                    if(x ChangeUse  && this.is ExchangeCo mpatibilit yModeEnabl ed())
  251                    {
  252                             logger .warn("JPE G2000 Comp ression Ra tio is set  to XChang e default  [" + xComp atRatio +  "]");
  253                             return  xCompatRa tio;
  254                    }
  255                    if(m odality ==  null)
  256                    {
  257                             logger .warn("JPE G2000 Comp ression Ra tio for nu ll modalit y is set t o XChange  default ["  + xCompat Ratio + "] ");
  258                             return  xCompatRa tio;
  259                    }
  260                    logg er.info("S earching f or JPEG200 0 Compress ion Ratio  for modali ty Type ["  + modalit y + "]");
  261                    for( ModalityLo ssyCompres sionParame ters mlcp  : imageLos syCompress ionConfigL ist)
  262                    {
  263                             if(mlc p.getModal ity().equa ls(modalit y)) {
  264                                      logger.i nfo("JPEG2 000 Compre ssion Rati o for moda lity Type  [" + modal ity + 
  265                                                   "] is  configured  to [" + x CompatRati o + "]");
  266                                      return m lcp.getJ2k LossyRatio ();
  267                             }
  268                    }
  269                    logg er.info("J PEG2000 Co mpression  Ratio conf ig setting  for modal ity Type [ " + modali ty + 
  270                                          "] i s not foun d; value s et to XCha nge defaul t [" + xCo mpatRatio  + "]");
  271                    retu rn xCompat Ratio;
  272           }
  273  
  274           @O verride
  275           pu blic int g etModality LossyJPEGQ uality(Str ing modali ty, int im ageBytes,  boolean xC hangeUse) 
  276           {                 
  277                    int  xCompatQua lity= (ima geBytes >  averageIma geSize) ?  bigCompres sQuality :  smallComp ressQualit y;                 
  278  
  279                    if(x ChangeUse  && this.is ExchangeCo mpatibilit yModeEnabl ed())
  280                    {
  281                             logger .warn("JPE G Compress ion Qualit y is set t o XChange  default ["  + xCompat Quality +  "]");
  282                             return  xCompatQu ality;
  283                    }
  284                    if(m odality ==  null)
  285                    {
  286                             logger .warn("JPE G Compress ion Qualit y for null  modality  is set to  XChange de fault [" +  xCompatQu ality + "] ");
  287                             return  xCompatQu ality;
  288                    }
  289                    logg er.info("S earching f or JPEG Co mpression  Quality va lue for mo dality Typ e [" + mod ality + "] ");
  290                    int  quality=0;                                      
  291                    for( ModalityLo ssyCompres sionParame ters mlcp  : imageLos syCompress ionConfigL ist)
  292                    {
  293                             if(mlc p.getModal ity().equa ls(modalit y)) {
  294                                      quality  = mlcp.get JpegQualit y();
  295                                      // TODO  if 0 recei ved -- com pute j2k e quivalent  quality se tting for  JPEG
  296                                      if (qual ity == 0)  {
  297                                               quality =  xCompatQua lity; // t emporarily  use defau lt setting  for excha nge
  298                                               logger.inf o("JPEG Co mpression  Quality fo r modality  Type [" +  modality 
  299                                                            "] is fo rced to XC hange sett ing [" + q uality + " ]");
  300                                      } else {
  301                                               logger.inf o("JPEG Co mpression  Quality fo r modality  Type [" +  modality 
  302                                                            "] is co nfigured t o [" + qua lity + "]" );
  303                             
  304                                      }
  305                             }
  306                             return  quality;
  307                    }
  308                    logg er.info("C ompression  Quality c onfig sett ing for mo dality Typ e [" + mod ality + 
  309                                 "]  is not fo und; value  set to XC hange defa ult [" + x CompatQual ity + "]") ;
  310                    retu rn xCompat Quality;
  311           }
  312  
  313           @O verride
  314           pu blic boole an saveIma geLossyCom pressionCo nfiguratio nToFile()  {
  315                    bool ean succes s = false;
  316                    XMLE ncoder xml Encoder =  null;
  317                    try
  318                    {
  319                             xmlEnc oder = new  XMLEncode r(new Buff eredOutput Stream(new  FileOutpu tStream(th is.getImag eLossyComp ressionCon figuration Filespec() )));
  320                             xmlEnc oder.write Object(thi s);
  321                             logger .info("Ima geLossyCom pressionCo nfiguratio n: configu ration sav ed to: " +  this.getI mageLossyC ompression Configurat ionFilespe c());
  322                             succes s = true;
  323                    }
  324                    catc h (Applica tionConfig urationExc eption ex)
  325                    {
  326                             logger .error(ex. getMessage ());
  327                    }
  328                    catc h (FileNot FoundExcep tion ex)
  329                    {
  330                             logger .error("Im ageLossyCo mpressionC onfigurati on.saveApp Configurat ionToFile:  " + ex.ge tMessage() );
  331                    }
  332                    fina lly
  333                    {
  334                             if (xm lEncoder ! = null)
  335                             {
  336                                      xmlEncod er.close() ;
  337                             }
  338                    }
  339                    retu rn success ;
  340           }
  341           
  342           pu blic stati c void mai n(String [ ] args)
  343           {
  344                    Imag eLossyComp ressionCon figuration  config =  new ImageL ossyCompre ssionConfi guration() ;
  345                    try
  346                    {
  347                             config .init();
  348                    }
  349                    catc h(Applicat ionConfigu rationExce ption acX)
  350                    {
  351                             acX.pr intStackTr ace();
  352                    }
  353                    setB asicConfig uration(co nfig);
  354                    conf ig.saveIma geLossyCom pressionCo nfiguratio nToFile();
  355           }
  356           
  357           pr ivate stat ic void ad dAnEntry ( ImageLossy Compressio nConfigura tion confi g, 
  358                                                                                  String m odality, f loat j2kRa tio, int j pegQuality )
  359           {
  360                    Moda lityLossyC ompression Parameters  mlcp = 
  361                             new Mo dalityLoss yCompressi onParamete rs(modalit y, j2kRati o, jpegQua lity);
  362                    conf ig.imageLo ssyCompres sionConfig List.add(m lcp);        
  363           }
  364           
  365           pr ivate stat ic void se tBasicConf iguration( ImageLossy Compressio nConfigura tion confi g)
  366           {
  367                    conf ig.setExch angeCompat ibilityMod e(true);
  368                    
  369                    // C reate the  default co mpression  options al lowed for  each forma t
  370                    // T he order o f items in  these lis ts is NOT  relevant, 
  371                    // N O MODALITY  code shou ld be repe ated!
  372                    addA nEntry(con fig, "CR",  25.0f, 0) ; // Compu ted Radiog raphy
  373                    addA nEntry(con fig, "DX",  25.0f, 0) ; // Digit al Radiogr aphy
  374                    addA nEntry(con fig, "DG",  25.0f, 0) ; // Diaph anoGraphy
  375                    addA nEntry(con fig, "RG",  25.0f, 0) ; // Radio Graphic im g (conv. f ilm/screen )
  376                    addA nEntry(con fig, "MG",  25.0f, 0) ; // Mammo graphy
  377                    addA nEntry(con fig, "RF",  25.0f, 0) ; // Radio  Fluorosco py 
  378                    addA nEntry(con fig, "XC",  25.0f, 0) ; // Exter nal-camera  Photograp hy
  379                    addA nEntry(con fig, "CT",  10.0f, 0) ; // Compu ted Tomogr aphy
  380                    addA nEntry(con fig, "XA",  10.0f, 0) ; // X-Ray  Angiograp hy
  381                    addA nEntry(con fig, "MR",  10.0f, 0) ; // Magne tic Resona nce
  382                    addA nEntry(con fig, "OT",  10.0f, 0) ; // other
  383                    addA nEntry(con fig, "PT",  10.0f, 0) ; // Posit ron emissi on Tomogra phy (PET)
  384                    addA nEntry(con fig, "US",  10.0f, 0) ; // Ultra Sound
  385                    addA nEntry(con fig, "DD",  10.0f, 0) ; // Duple x Doppler
  386                    addA nEntry(con fig, "NM",   8.0f, 0) ; // Nucle ar Medicin e
  387                    addA nEntry(con fig, "ES",  10.0f, 0) ; // EndoS copy
  388                    addA nEntry(con fig, "LS",  10.0f, 0) ; // Laser  surface S can
  389                    addA nEntry(con fig, "PX",  10.0f, 0) ; // Panor amic X-Ray
  390                    addA nEntry(con fig, "IO",  10.0f, 0) ; // Intra -oral Radi ography
  391                    addA nEntry(con fig, "CD",  10.0f, 0) ; // Color  flow Dopp ler
  392                    addA nEntry(con fig, "BI",  10.0f, 0) ; // Bioma gnetic Ima ging
  393                    addA nEntry(con fig, "ST",  10.0f, 0) ; // Singl e-photon e mission CT  (SPECT)
  394                    addA nEntry(con fig, "TG",  10.0f, 0) ; // Therm ography
  395                    addA nEntry(con fig, "GM",  10.0f, 0) ; // Gener al Microsc opy
  396                    addA nEntry(con fig, "SM",  10.0f, 0) ; // Slide  Microscop y
  397                    // r etired mod alities
  398                    addA nEntry(con fig, "DS",  10.0f, 0) ;     // D igital Sub traction A ngiography  --> XA
  399                    addA nEntry(con fig, "AS",  10.0f, 0) ;     // A ngioScopy  --> XA
  400                    addA nEntry(con fig, "CF",  10.0f, 0) ;     // C ine Fluoro graphy -->  RF
  401                    addA nEntry(con fig, "VF",  10.0f, 0) ;     // V ideo Fluor ography -- > RF
  402                    addA nEntry(con fig, "DF",  10.0f, 0) ;     // D igital Flu oroscopy - -> RF
  403                    addA nEntry(con fig, "LP",  10.0f, 0) ;     // L aParoscopy
  404                    addA nEntry(con fig, "EC",  10.0f, 0) ;     // E choCardiog raphy -->  XA
  405                    addA nEntry(con fig, "MA",  10.0f, 0) ;     // M agnetic Re sonance An giography  --> XA?
  406                    addA nEntry(con fig, "MS",  10.0f, 0) ;     // M agnetic Re sonance Sp ectroscopy
  407                    addA nEntry(con fig, "FS",  10.0f, 0) ;     // F undoscopy
  408                    addA nEntry(con fig, "DM",  10.0f, 0) ;     // D igital Mic roscopy -- > GM
  409                    addA nEntry(con fig, "FA",  10.0f, 0) ;     // F luorescein  Angiograp hy --> XA
  410                    addA nEntry(con fig, "EC",  10.0f, 0) ;     // E choCardiog raphy
  411                    addA nEntry(con fig, "CS",  10.0f, 0) ;     // C ystoScopy
  412           }
  413   }