Exemplo n.º 1
0
  @Override
  protected Boolean doInBackground() throws Exception {

    JFrame waitFrame = null;
    if (timeIntensive) {
      //		gui.getStatusPanel().setStatus("Initialising reasoner ... ");
      gui.disableTabbedPane();
      gui.setEnabled(false);
      waitFrame = new JFrame();
      waitFrame.setUndecorated(true);
      waitFrame.setSize(160, 100);
      waitFrame.getContentPane().setBackground(Color.WHITE);
      URL imgURL = Config.class.getResource("ajaxloader.gif");
      //    	ImageIcon waitIcon = new ImageIcon(imgURL, "wait");
      //    	waitFrame.add(new JLabel("Wait!"), waitIcon, SwingConstants.RIGHT);
      //    	waitFrame.add(new JLabel("Wait"));
      //    	JLabel iconLabel = new JLabel(waitIcon);
      //    	iconLabel.setOpaque(true);
      //    	iconLabel.setBackground(Color.RED);
      //    	iconLabel.setForeground(Color.RED);
      //    	waitFrame.add(iconLabel, BorderLayout.NORTH);
      waitFrame.add(
          new JLabel(
              "<html><br /><p align=\"center\"><img src=\""
                  + imgURL
                  + "\" /><br /> &nbsp;&nbsp;Initialising component.<br />Please wait.</p></html>"));
      waitFrame.setLocationRelativeTo(gui);
      waitFrame.setVisible(true);
    }

    try {
      for (AbstractComponent component : components) {
        component.init();

        // when the reasoner has been initialised, we need to update
        // the option panel (such that the user can see the existing
        // examples, classes etc.)
        if (component instanceof AbstractReasonerComponent) {
          gui.panels[2].updateOptionPanel();
          gui.panels[3].updateOptionPanel();
        }
      }
    } catch (ComponentInitException e) {
      gui.getStatusPanel().setExceptionMessage(e.getMessage());
      e.printStackTrace();
    }

    if (timeIntensive) {
      gui.enableTabbedPane();
      gui.setEnabled(true);
      //		gui.getStatusPanel().extendMessage("done.");
      waitFrame.dispose();
    }

    return true;
  }
  /**
   * Simple method for creating a reasoner component.
   *
   * @param ontologyFile URI or path to OWL ontology file.
   * @param type Reasoner type.
   * @return A reasoner component.
   */
  public static AbstractReasonerComponent getReasonerComponent(
      String ontologyFile, ReasonerType type) {
    ComponentManager cm = ComponentManager.getInstance();
    AbstractReasonerComponent rc = null;

    try {
      // knowledge source
      OWLFile ks = cm.knowledgeSource(OWLFile.class);
      URL fileURL = new File(ontologyFile).toURI().toURL();
      ks.setURL(fileURL);
      ks.init();

      // reasoner component
      switch (type) {
        case FAST_INSTANCE_CHECKER:
          rc = cm.reasoner(FastInstanceChecker.class, ks);
          break;
        case OWLAPI_FACT:
          rc = cm.reasoner(OWLAPIReasoner.class, ks);
          ((OWLAPIReasoner) rc).setReasonerTypeString("fact");
          break;
        case OWLAPI_PELLET:
          rc = cm.reasoner(OWLAPIReasoner.class, ks);
          ((OWLAPIReasoner) rc).setReasonerTypeString("pellet");
          break;
        default:
          rc = cm.reasoner(FastInstanceChecker.class, ks);
          break;
      }
      rc.init();
    } catch (MalformedURLException e) {
      e.printStackTrace();
    } catch (ComponentInitException e) {
      e.printStackTrace();
    }

    return rc;
  }