@Override
 public void setLocation(int x, int y) {
   super.setLocation(x, y);
   this.x = x;
   this.y = y;
   if (patch != null) {
     patch.repaint();
   }
 }
  public AxoObjectInstanceAbstract(
      AxoObjectAbstract type, Patch patch1, String InstanceName1, Point location) {
    super();
    this.type = type;
    typeName = type.id;
    if (type.createdFromRelativePath && (patch1 != null)) {
      String pPath = patch1.getFileNamePath();
      String oPath = type.sPath;

      if (oPath.endsWith(".axp") || oPath.endsWith(".axo") || oPath.endsWith(".axs")) {
        oPath = oPath.substring(0, oPath.length() - 4);
      }
      pPath = pPath.replaceAll("\\\\", "/");
      oPath = oPath.replaceAll("\\\\", "/");
      String[] pPathA = pPath.split("/");
      String[] oPathA = oPath.split("/");
      int i = 0;
      while ((i < pPathA.length) && (i < oPathA.length) && (oPathA[i].equals(pPathA[i]))) {
        i++;
      }
      String rPath = "";
      for (int j = i; j < pPathA.length - 1; j++) {
        rPath += "../";
      }
      if (rPath.isEmpty()) {
        rPath = ".";
      } else {
        rPath = rPath.substring(0, rPath.length() - 1);
      }
      for (int j = i; j < oPathA.length; j++) {
        rPath += "/" + oPathA[j];
      }

      System.out.println(rPath);
      typeName = rPath;
      //            File f = new File();
      //            f.ge
      //            typeName =
    }

    typeSHA = type.getSHA();
    typeUUID = type.getUUID();
    this.InstanceName = InstanceName1;
    this.x = location.x;
    this.y = location.y;
    this.patch = patch1;
  }
 public AxoObjectAbstract resolveType() {
   if (type != null) {
     return type;
   }
   if (typeUUID != null) {
     type = MainFrame.axoObjects.GetAxoObjectFromUUID(typeUUID);
     if (type != null) {
       System.out.println("restored from UUID:" + type.id);
       typeName = type.id;
     }
   }
   if ((type == null) && (typeSHA != null)) {
     type = MainFrame.axoObjects.GetAxoObjectFromSHA(typeSHA);
     if (type != null) {
       System.out.println("restored from SHA:" + type.id);
       typeName = type.id;
     }
   }
   if (type == null) {
     ArrayList<AxoObjectAbstract> types =
         MainFrame.axoObjects.GetAxoObjectFromName(typeName, patch.GetCurrentWorkingDirectory());
     if (types == null) {
       Logger.getLogger(AxoObjectInstanceAbstract.class.getName())
           .log(Level.SEVERE, "Object name {0} not found", typeName);
     } else { // pick first
       if (types.size() > 1) {
         typeWasAmbiguous = true;
       }
       type = types.get(0);
       if (type instanceof AxoObjectUnloaded) {
         AxoObjectUnloaded aou = (AxoObjectUnloaded) type;
         type = aou.Load();
         return (AxoObject) type;
       }
       typeSHA = type.getSHA();
     }
   }
   return type;
 }
 public void setInstanceName(String InstanceName) {
   if (this.InstanceName.equals(InstanceName)) {
     return;
   }
   if (patch != null) {
     AxoObjectInstanceAbstract o1 = patch.GetObjectInstance(InstanceName);
     if ((o1 != null) && (o1 != this)) {
       Logger.getLogger(AxoObjectInstanceAbstract.class.getName())
           .log(Level.SEVERE, "Object name {0} already exists!", InstanceName);
       doLayout();
       repaint();
       return;
     }
   }
   this.InstanceName = InstanceName;
   if (InstanceLabel != null) {
     InstanceLabel.setText(InstanceName);
   }
   doLayout();
   if (getParent() != null) {
     getParent().repaint();
   }
 }