@SuppressWarnings({"unchecked", "rawtypes"})
 public void setInitialData() {
   ArrayList<OntoUMLElement> generallist = new ArrayList<OntoUMLElement>();
   ArrayList<OntoUMLElement> specificlist = new ArrayList<OntoUMLElement>();
   OntoUMLElement generalValue = null;
   OntoUMLElement specificValue = null;
   OntoUMLParser refparser =
       diagramManager.getFrame().getBrowserManager().getProjectBrowser().getParser();
   if (element.getGeneral() != null) generalValue = new OntoUMLElement(element.getGeneral(), "");
   else generalValue = new OntoUMLElement(null, "");
   if (element.getSpecific() != null)
     specificValue = new OntoUMLElement(element.getSpecific(), "");
   else specificValue = new OntoUMLElement(null, "");
   for (RefOntoUML.Type t : refparser.getAllInstances(RefOntoUML.Type.class)) {
     if (t instanceof RefOntoUML.Class
         || t instanceof RefOntoUML.DataType
         || t instanceof RefOntoUML.Association) {
       if (((OntoUMLElement) generalValue).getElement() != null
           && t.equals(((OntoUMLElement) generalValue).getElement()))
         generallist.add((OntoUMLElement) generalValue);
       else generallist.add(new OntoUMLElement(t, ""));
       if (((OntoUMLElement) specificValue).getElement() != null
           && t.equals(((OntoUMLElement) specificValue).getElement()))
         specificlist.add((OntoUMLElement) specificValue);
       else specificlist.add(new OntoUMLElement(t, ""));
     }
   }
   if (((OntoUMLElement) generalValue).getElement() == null)
     generallist.add((OntoUMLElement) generalValue);
   else if (!refparser.getAllInstances(RefOntoUML.Type.class).contains(element.getGeneral()))
     generallist.add((OntoUMLElement) generalValue);
   if (((OntoUMLElement) specificValue).getElement() == null)
     specificlist.add((OntoUMLElement) specificValue);
   else if (!refparser.getAllInstances(RefOntoUML.Type.class).contains(element.getSpecific()))
     specificlist.add((OntoUMLElement) specificValue);
   Collections.sort(generallist, new CustomComparator());
   Collections.sort(specificlist, new CustomComparator());
   generalCombo.setModel(new DefaultComboBoxModel(generallist.toArray()));
   generalCombo.setSelectedItem(generalValue);
   specificCombo.setModel(new DefaultComboBoxModel(specificlist.toArray()));
   specificCombo.setSelectedItem(specificValue);
 }
  public static int[][] buildGraph(
      OntoUMLParser parser, ArrayList<Class> classes, ArrayList<Relationship> relationships) {
    HashMap<Type, ArrayList<Type>> relatedHash = new HashMap<Type, ArrayList<Type>>();

    classes.add(null);
    relationships.add(null);

    for (EObject element : parser.getElements()) {
      if (element instanceof Class) classes.add((Class) element);

      if (element instanceof Association && !(element instanceof Derivation)) {
        Association a = (Association) element;
        if (a.getMemberEnd().size() != 2 || a.isIsDerived()) continue;

        Property sourceEnd = a.getMemberEnd().get(0);
        Property targetEnd = a.getMemberEnd().get(1);
        Type source = sourceEnd.getType();
        Type target = targetEnd.getType();

        if (sourceEnd.isIsDerived()
            || !(source instanceof Class)
            || targetEnd.isIsDerived()
            || !(target instanceof Class)
            || source.equals(target)) continue;

        if (relatedHash.containsKey(source) && relatedHash.get(source).contains(target)) continue;

        addToHash(relatedHash, source, target);
        addToHash(relatedHash, target, source);
        relationships.add((Relationship) element);
      }

      if (element instanceof Generalization) {
        Generalization g = (Generalization) element;
        Classifier parent = g.getGeneral();
        Classifier child = g.getSpecific();

        if (!(parent instanceof Class) || !(child instanceof Class) || child.equals(parent))
          continue;

        if (relatedHash.containsKey(child) && relatedHash.get(child).contains(parent)) continue;

        addToHash(relatedHash, child, parent);
        addToHash(relatedHash, parent, child);
        relationships.add((Relationship) element);
      }
    }

    int result[][] = new int[2][];
    int nodei[] = new int[relationships.size()];
    int nodej[] = new int[relationships.size()];
    nodei[0] = 0;
    nodej[0] = 0;

    for (Relationship r : relationships) {
      if (r == null) continue;

      if (r instanceof Association) {
        if (((Association) r).getMemberEnd().size() == 2) {
          nodei[relationships.indexOf(r)] =
              classes.indexOf(((Association) r).getMemberEnd().get(0).getType());
          nodej[relationships.indexOf(r)] =
              classes.indexOf(((Association) r).getMemberEnd().get(1).getType());
        }
      }
      if (r instanceof Generalization) {
        nodei[relationships.indexOf(r)] = classes.indexOf(((Generalization) r).getGeneral());
        nodej[relationships.indexOf(r)] = classes.indexOf(((Generalization) r).getSpecific());
      }
    }

    result[0] = nodei;
    result[1] = nodej;

    return result;
  }