Esempio n. 1
0
  private static void readTagDisplayByModality() {
    XMLStreamReader xmler = null;
    InputStream stream = null;
    try {
      File file = ResourceUtil.getResource("attributes-view.xml"); // $NON-NLS-1$
      if (!file.canRead()) {
        return;
      }
      XMLInputFactory xmlif = XMLInputFactory.newInstance();
      stream = new FileInputStream(file); // $NON-NLS-1$
      xmler = xmlif.createXMLStreamReader(stream);

      while (xmler.hasNext()) {
        switch (xmler.next()) {
          case XMLStreamConstants.START_ELEMENT:
            String key = xmler.getName().getLocalPart();
            if ("modalities".equals(key)) { // $NON-NLS-1$
              readModalities(xmler);
            }
            break;
          default:
            break;
        }
      }
    } catch (Exception e) {
      LOGGER.error("Cannot read attributes-view.xml! ", e); // $NON-NLS-1$
    } finally {
      FileUtil.safeClose(xmler);
      FileUtil.safeClose(stream);
    }
  }
 static {
   String tempDir = System.getProperty("java.io.tmpdir"); // $NON-NLS-1$
   File tdir;
   if (tempDir == null || tempDir.length() == 1) {
     String dir = System.getProperty("user.home", ""); // $NON-NLS-1$ //$NON-NLS-2$
     tdir = new File(dir);
   } else {
     tdir = new File(tempDir);
   }
   /*
    * Set the user name and the id (weasis source instance on web) to avoid mixing files by several users (Linux)
    * or by running multiple instances of Weasis from different sources.
    */
   APP_TEMP_DIR =
       new File(
           tdir,
           "weasis-"
               + System.getProperty("user.name", "tmp")
               + "."
               + System.getProperty(
                   "weasis.source.id",
                   "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
                         // //$NON-NLS-6$
   System.setProperty("weasis.tmp.dir", APP_TEMP_DIR.getAbsolutePath()); // $NON-NLS-1$
   try {
     // Clean temp folder, necessary when the application has crashed.
     FileUtil.deleteDirectoryContents(APP_TEMP_DIR, 3, 0);
   } catch (Exception e1) {
   }
 }
Esempio n. 3
0
 public static void loadDicomZip(File file, DicomModel dicomModel) {
   if (file != null) {
     ArrayList<LoadSeries> loadSeries = null;
     if (file.canRead()) {
       File dir = FileUtil.createTempDir("unzip");
       try {
         FileUtil.unzip(file, dir);
       } catch (IOException e) {
         e.printStackTrace();
       }
       DicomDirLoader dirImport = new DicomDirLoader(new File(dir, "DICOMDIR"), dicomModel, true);
       loadSeries = dirImport.readDicomDir();
     }
     if (loadSeries != null && loadSeries.size() > 0) {
       DicomModel.loadingExecutor.execute(new LoadDicomDir(loadSeries, dicomModel));
     } else {
       LOGGER.error("Cannot import DICOM from {}", file); // $NON-NLS-1$
     }
   }
 }