Exemple #1
0
 /**
  * Method to add a Variable on this IconNodeInst. It may add a repaired copy of this Variable in
  * some cases.
  *
  * @param var Variable to add.
  */
 @Override
 public void addVar(Variable var) {
   if (isParam(var.getKey())) {
     throw new IllegalArgumentException(this + " already has a variable with name " + var);
   }
   super.addVar(var.withParam(false).withInherit(false));
 }
Exemple #2
0
 /**
  * Updates the TextDescriptor on this NodeInst selected by varKey. The varKey may be a key of
  * variable on this NodeInst or one of the special keys: NodeInst.NODE_NAME NodeInst.NODE_PROTO If
  * varKey doesn't select any text descriptor, no action is performed. The TextDescriptor gives
  * information for displaying the Variable.
  *
  * @param varKey key of variable or special key.
  * @param td new value TextDescriptor
  */
 @Override
 public void setTextDescriptor(Variable.Key varKey, TextDescriptor td) {
   Variable param = getParameter(varKey);
   if (param != null) {
     td = td.withParam(true).withInherit(false).withUnit(param.getUnit());
     addParameter(param.withTextDescriptor(td));
     return;
   }
   super.setTextDescriptor(varKey, td);
 }
Exemple #3
0
 /**
  * Method to get the transparent color information from a NodeInst.
  *
  * @param ni the NodeInst to examine.
  * @return an array of Color values. Returns null if no such data exists on the NodeInst.
  */
 public static Color[] getTransparentColors(NodeInst ni) {
   int opt = Manipulate.getOptionOnNode(ni);
   if (opt != TECHTRANSPCOLORS) return null;
   Variable var = ni.getVar(TRANSLAYER_KEY);
   String transparentColorsStr = (String) var.getObject();
   int colon = transparentColorsStr.indexOf(':');
   if (colon >= 0) transparentColorsStr = transparentColorsStr.substring(colon + 1);
   if (var == null) return null;
   Color[] colors = TextUtils.getTransparentColors(transparentColorsStr);
   return colors;
 }
Exemple #4
0
 //    public void addParam(Variable var) {
 //        assert var.getTextDescriptor().isParam() && var.isInherit();
 //        if (isIcon()) {
 //            // Remove variables with the same name as new parameter
 //            for (Iterator<NodeInst> it = getInstancesOf(); it.hasNext(); ) {
 //                NodeInst ni = it.next();
 //                ni.delVar(var.getKey());
 //            }
 //        }
 //        setD(getD().withoutVariable(var.getKey()).withParam(var));
 //    }
 //
 private static Variable composeInstParam(Variable iconParam, Variable instVar) {
   boolean display = !iconParam.isInterior();
   if (instVar != null) {
     return instVar
         .withParam(true)
         .withInherit(false)
         .withInterior(false)
         .withDisplay(display)
         .withUnit(iconParam.getUnit());
   }
   return iconParam.withInherit(false).withInterior(false).withDisplay(display);
 }
Exemple #5
0
 /**
  * Method to copy all variables from another ElectricObject to this ElectricObject.
  *
  * @param other the other ElectricObject from which to copy Variables.
  */
 @Override
 public void copyVarsFrom(ElectricObject other) {
   checkChanging();
   for (Iterator<Variable> it = other.getParametersAndVariables(); it.hasNext(); ) {
     Variable var = it.next();
     if (isParam(var.getKey())) {
       addParameter(var.withParam(true));
     } else {
       addVar(var.withParam(false));
     }
   }
 }
Exemple #6
0
 /**
  * Method to add a Parameter to this NodeInst. Overridden in IconNodeInst
  *
  * @param param the Variable to delete.
  */
 public void addParameter(Variable param) {
   if (!isParam(param.getKey())) {
     throw new IllegalArgumentException("Parameter " + param + " is not defined on " + getProto());
   }
   Cell icon = (Cell) getProto();
   Variable iconParam = icon.getParameter(param.getKey());
   param = composeInstParam(iconParam, param);
   if (setD(getD().withParam(param), true)) // check for side-effects of the change
   {
     checkPossibleVariableEffects(param.getKey());
   }
 }
Exemple #7
0
  /**
   * Method to return an Iterator over all Parameters on this IconNodeInst. This may also include
   * any parameters on the defaultVarOwner object that are not on this object.
   *
   * @return an Iterator over all Parameters on this IconNodeInst.
   */
  @Override
  public Iterator<Variable> getParameters() {
    Cell icon = (Cell) getProto();
    if (!icon.hasParameters()) {
      return ArrayIterator.emptyIterator();
    }

    ArrayList<Variable> params = new ArrayList<Variable>();
    // get all parameters on this object
    for (Iterator<Variable> it = icon.getParameters(); it.hasNext(); ) {
      Variable iconParam = it.next();
      Variable instVar = getD().getDefinedParameter((Variable.AttrKey) iconParam.getKey());
      params.add(composeInstParam(iconParam, instVar));
    }
    return params.iterator();
  }
Exemple #8
0
  /** Method to parse the arc cell in "np" and return an ArcInfo object that describes it. */
  static ArcInfo parseCell(Cell np) {
    // create and initialize the GRAPHICS structure
    ArcInfo aIn = new ArcInfo();
    aIn.name = np.getName().substring(4);

    // look at all nodes in the arc description cell
    for (Iterator<NodeInst> it = np.getNodes(); it.hasNext(); ) {
      NodeInst ni = it.next();
      Variable var = ni.getVar(OPTION_KEY);
      if (var == null) continue;
      String str = getValueOnNode(ni);

      switch (((Integer) var.getObject()).intValue()) {
        case ARCFUNCTION:
          aIn.func = ArcProto.Function.UNKNOWN;
          List<ArcProto.Function> allFuncs = ArcProto.Function.getFunctions();
          for (ArcProto.Function fun : allFuncs) {
            if (fun.toString().equalsIgnoreCase(str)) {
              aIn.func = fun;
              break;
            }
          }
          break;
        case ARCINC:
          aIn.angInc = TextUtils.atoi(str);
          break;
        case ARCFIXANG:
          aIn.fixAng = str.equalsIgnoreCase("yes");
          break;
        case ARCWIPESPINS:
          aIn.wipes = str.equalsIgnoreCase("yes");
          break;
        case ARCNOEXTEND:
          aIn.noExtend = str.equalsIgnoreCase("no");
          break;
        case ARCANTENNARATIO:
          aIn.antennaRatio = TextUtils.atof(str);
          break;
        case ARCWIDTHOFFSET:
          aIn.widthOffset = TextUtils.atof(str);
          break;
      }
    }
    return aIn;
  }