private void writeToLog(NodeModel node) {
   URI uri = Tools.getAbsoluteUri(node);
   if (uri == null) {
     return;
   }
   if ("file".equals(uri.getScheme())) {
     File f = WorkspaceUtils.resolveURI(uri);
     // if map file is opened, then there is a MapLifeCycleListener Event
     if (f != null && !f.getName().endsWith(".mm")) {
       DocearController.getController()
           .getDocearEventLogger()
           .appendToLog(this, DocearLogEvent.FILE_OPENED, f);
     }
   } else {
     try {
       DocearController.getController()
           .getDocearEventLogger()
           .appendToLog(this, DocearLogEvent.OPEN_URL, uri.toURL());
     } catch (MalformedURLException ex) {
       LogUtils.warn(ex);
     }
   }
 }
  private void pdfHeaderExtraction(MouseEvent e, StringBuilder sb) {
    NodeModel mmNode = ((MainView) e.getSource()).getNodeView().getModel();
    URI uri = Tools.getAbsoluteUri(mmNode);
    if (uri == null) {
      return;
    }
    try {
      File csvFile = new File("C:\\Header_Extraction\\result.csv");
      if (!csvFile.exists()) {
        csvFile.getParentFile().mkdirs();
        csvFile.createNewFile();
      }
      PrintStream printer = new PrintStream(new FileOutputStream(csvFile), true);

      try {
        File[] fileList =
            new File("C:\\Header_Extraction\\testpdfs")
                .listFiles(
                    new FileFilter() {
                      public boolean accept(File pathname) {
                        //						if(!"(164).pdf".equals(pathname.getName())) {
                        //							return false;
                        //						}
                        return pathname.getName().toLowerCase().endsWith(".pdf");
                      }
                    });
        Arrays.sort(
            fileList,
            new Comparator<File>() {
              public int compare(File self, File other) {
                int f1 = extractNumber(self.getName());
                int f2 = extractNumber(other.getName());
                if (f1 > f2) {
                  return 1;
                }
                if (f1 < f2) {
                  return -1;
                }
                return 0;
              }

              private int extractNumber(String name) {
                String token = name.toLowerCase().replace("(", "");
                token = token.replace(").pdf", "");
                try {
                  return Integer.parseInt(token);
                } catch (Exception e) {
                }
                return 100;
              }
            });
        int failCount = 0;
        int hashCount = 0;
        int pdfFails = 0;
        float avgSum = 0;
        for (File file : fileList) {
          String title = null;
          String hash = null;
          try {
            long time = System.currentTimeMillis();
            PdfDataExtractor pdfData = new PdfDataExtractor(file);
            title = pdfData.extractTitle();
            hash = pdfData.getUniqueHashCode();
            avgSum += (System.currentTimeMillis() - time);
          } catch (Exception ex) {
            pdfFails++;
            LogUtils.warn(file.getName() + ": " + ex.getMessage());
          }
          if (title == null) {
            failCount++;
          }
          if (hash == null) {
            hashCount++;
          }
          printer.println(file.getName() + ";" + (title == null ? "NULL" : title));
          System.out.println(
              file.getName()
                  + ";"
                  + (hash == null ? "NULL" : hash)
                  + ";"
                  + (title == null ? "NULL" : title));
        }

        System.out.println("avg. item: " + (avgSum / fileList.length));
        System.out.println("title fails: " + failCount + "/" + fileList.length);
        System.out.println("hash fails: " + hashCount + "/" + fileList.length);
        System.out.println("pdf read fails: " + pdfFails + "/" + fileList.length);
      } finally {
        printer.flush();
        printer.close();
      }
    } catch (IOException ex) {
      LogUtils.warn(ex);
    }
  }
  public void mouseClicked(MouseEvent e) {
    if (e.getButton() == MouseEvent.BUTTON1 && e.getSource() instanceof MainView) {
      MainView view = (MainView) e.getSource();
      Rectangle bounds = ((ZoomableLabelUI) view.getUI()).getIconR(view);
      Point p = e.getPoint();
      if (bounds.contains(p)) {
        if (view.getIcon() instanceof MultipleImage) {
          Rectangle iconR =
              ((MultipleImage) view.getIcon())
                  .getIconR(PdfUtilitiesController.REFRESH_MONITORING_ICON);
          if (iconR != null) {
            float zoom = Controller.getCurrentController().getViewController().getZoom();
            iconR.setLocation((int) (iconR.x * zoom), iconR.y);
            iconR.setSize((int) (iconR.width * zoom), (int) (iconR.height * zoom));
            iconR.translate(bounds.x, bounds.y);
            if (iconR.contains(p)) {
              UpdateMonitoringFolderAction.updateNodesAgainstMonitoringDir(
                  getMonitorNodes(
                      Controller.getCurrentController().getViewController().getMap().getRootNode()),
                  false);
              return;
            }
          }
        }
      }
      //			StringBuilder sb = new StringBuilder();
      //			pdfHeaderExtraction(e, sb);
    }
    boolean openOnPage =
        ResourceController.getResourceController()
            .getBooleanProperty(PdfUtilitiesController.OPEN_PDF_VIEWER_ON_PAGE_KEY);

    if (!openOnPage) {
      this.mouseListener.mouseClicked(e);
      return;
    }

    if (
    /*wasFocused() && */ (e.getModifiers() & ~(InputEvent.ALT_DOWN_MASK | InputEvent.ALT_MASK))
        == InputEvent.BUTTON1_MASK) {
      final MainView component = (MainView) e.getComponent();
      final ModeController modeController = Controller.getCurrentModeController();
      NodeModel node = null;
      try {
        node = ((MainView) e.getSource()).getNodeView().getModel();
      } catch (Exception ex) {
      }

      if (node == null) {
        node = modeController.getMapController().getSelectedNode();
      }

      if (component.isInFollowLinkRegion(e.getX())) {
        writeToLog(node);
      }
      if (!component.isInFollowLinkRegion(e.getX()) || !MonitoringUtils.isPdfLinkedNode(node)) {
        this.mouseListener.mouseClicked(e);
        return;
      }

      URI uri = Tools.getAbsoluteUri(node);
      if (uri == null) {
        this.mouseListener.mouseClicked(e);
        return;
      }

      IAnnotation annotation = null;
      try {
        annotation = node.getExtension(AnnotationModel.class);
      } catch (Exception ex) {
      }

      LinkController.getController().onDeselect(node);
      if (!PdfUtilitiesController.getController().openPdfOnPage(uri, annotation)) {
        this.mouseListener.mouseClicked(e);
        return;
      }
      LinkController.getController().onSelect(node);

    } else {
      this.mouseListener.mouseClicked(e);
    }
  }