/** * 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)); } } }
/** * 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)); }
// 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); }