private boolean evaluateSetClause(String str) {

		if (str.toLowerCase().startsWith("dna")) {
			model.containerScriptCallback.setScript("set " + str);
			model.containerScriptCallback.execute();
			return true;
		}

		String[] s = null;

		// action
		Matcher matcher = ACTION.matcher(str);
		if (matcher.find()) {
			str = str.substring(matcher.end()).trim().toUpperCase();
			matcher = ACTION_ID.matcher(str);
			if (matcher.find()) {
				fillActionIDMap();
				if (!actionIDMap.containsKey(str)) {
					out(ScriptEvent.FAILED, "Unrecognized parameter: " + str);
					return false;
				}
				view.setAction(actionIDMap.get(str));
				return true;
			}
		}

		// particle field
		matcher = PARTICLE_FIELD.matcher(str);
		if (matcher.find()) {
			int end = matcher.end();
			String s2 = str.substring(end).trim();
			int i = s2.indexOf(" ");
			if (i < 0) {
				out(ScriptEvent.FAILED, "Argument error: " + str);
				return false;
			}
			s = new String[] { s2.substring(0, i).trim(), s2.substring(i + 1).trim() };
			s2 = str.substring(0, end - 1);
			if (s2.startsWith("%")) {
				s2 = s2.substring(1);
			}
			if ("on".equalsIgnoreCase(s[1]) || "off".equalsIgnoreCase(s[1])) {
				if ("visible".equalsIgnoreCase(s[0])) {
					setParticleField(s2, s[0], "on".equalsIgnoreCase(s[1]));
				} else if ("movable".equalsIgnoreCase(s[0])) {
					setParticleField(s2, s[0], "on".equalsIgnoreCase(s[1]));
				} else if ("draggable".equalsIgnoreCase(s[0])) {
					setParticleField(s2, s[0], "on".equalsIgnoreCase(s[1]));
				}
			} else {
				double x = parseMathExpression(s[1]);
				if (Double.isNaN(x))
					return false;
				setParticleField(s2, s[0], x);
			}
			return true;
		}

		// atom field
		matcher = ATOM_FIELD.matcher(str);
		if (matcher.find()) {
			int end = matcher.end();
			String s2 = str.substring(end).trim();
			int i = s2.indexOf(" ");
			if (i < 0) {
				out(ScriptEvent.FAILED, "Argument error: " + str);
				return false;
			}
			s = new String[] { s2.substring(0, i).trim(), s2.substring(i + 1).trim() };
			s2 = str.substring(0, end - 1);
			if (s2.startsWith("%")) {
				s2 = s2.substring(1);
			}
			if ("on".equalsIgnoreCase(s[1]) || "off".equalsIgnoreCase(s[1])) {
				if ("visible".equalsIgnoreCase(s[0])) {
					setParticleField(s2, s[0], "on".equalsIgnoreCase(s[1]));
				} else if ("movable".equalsIgnoreCase(s[0])) {
					setParticleField(s2, s[0], "on".equalsIgnoreCase(s[1]));
				} else if ("draggable".equalsIgnoreCase(s[0])) {
					setParticleField(s2, s[0], "on".equalsIgnoreCase(s[1]));
				}
			} else {
				double x = parseMathExpression(s[1]);
				if (Double.isNaN(x))
					return false;
				setAtomField(s2, s[0], x);
			}
			return true;
		}

		// rbond field
		matcher = RBOND_FIELD.matcher(str);
		if (matcher.find()) {
			int end = matcher.end();
			String s2 = str.substring(end).trim();
			int i = s2.indexOf(" ");
			if (i < 0) {
				out(ScriptEvent.FAILED, "Argument error: " + str);
				return false;
			}
			s = new String[] { s2.substring(0, i).trim(), s2.substring(i + 1).trim() };
			s2 = str.substring(0, end - 1);
			if (s2.startsWith("%")) {
				s2 = s2.substring(1);
			}
			if ("visible".equalsIgnoreCase(s[0]) || "style".equalsIgnoreCase(s[0]) || "torquetype".equalsIgnoreCase(s[0])) {
				setRbondField(s2, s[0], s[1]);
			} else {
				double x = parseMathExpression(s[1]);
				if (Double.isNaN(x))
					return false;
				setRbondField(s2, s[0], x);
			}
			return true;
		}

		// abond field
		matcher = ABOND_FIELD.matcher(str);
		if (matcher.find()) {
			int end = matcher.end();
			String s2 = str.substring(end).trim();
			int i = s2.indexOf(" ");
			if (i < 0) {
				out(ScriptEvent.FAILED, "Argument error: " + str);
				return false;
			}
			s = new String[] { s2.substring(0, i).trim(), s2.substring(i + 1).trim() };
			s2 = str.substring(0, end - 1);
			if (s2.startsWith("%")) {
				s2 = s2.substring(1);
			}
			double x = parseMathExpression(s[1]);
			if (Double.isNaN(x))
				return false;
			setAbondField(s2, s[0], x);
			return true;
		}

		// element field
		matcher = ELEMENT_FIELD.matcher(str);
		if (matcher.find()) {
			int end = matcher.end();
			s = str.substring(end).trim().split(REGEX_WHITESPACE + "+");
			if (s.length != 2) {
				out(ScriptEvent.FAILED, "Argument error: " + str);
				return false;
			}
			double x = parseMathExpression(s[1]);
			if (Double.isNaN(x))
				return false;
			setElementField(str.substring(0, end - 1), s[0], x);
			return true;
		}

		// obstacle field
		matcher = OBSTACLE_FIELD.matcher(str);
		if (matcher.find()) {
			int end = matcher.end();
			s = str.substring(end).trim().split(REGEX_WHITESPACE + "+");
			if (s.length < 2) {
				out(ScriptEvent.FAILED, "Argument error: " + str);
				return false;
			}
			if (s[0].startsWith("%")) {
				s[0] = s[0].substring(1);
			}
			if (s[0].equalsIgnoreCase("permeable")) { // special case to deal with setting permeability
				if (model.obstacles != null) {
					String str1 = str.substring(0, end - 1);
					int lb = str1.indexOf("[");
					int rb = str1.indexOf("]");
					double z = parseMathExpression(str1.substring(lb + 1, rb));
					if (Double.isNaN(z))
						return false;
					int i = (int) Math.round(z);
					if (i < 0 || i >= model.obstacles.size()) {
						out(ScriptEvent.FAILED, "Obstacle " + i + " doesn't exisit.");
						return false;
					}
					RectangularObstacle obs = model.obstacles.get(i);
					for (byte id = 0; id < 4; id++)
						obs.setPermeable(id, false);
					obs.setPhotonPermeable(false);
					obs.setElectronPermeable(false);
					for (int k = 1; k < s.length; k++) {
						s[k] = s[k].trim().toLowerCase().intern();
						if (s[k] == "nt") {
							obs.setPermeable((byte) 0, true);
						} else if (s[k] == "pl") {
							obs.setPermeable((byte) 1, true);
						} else if (s[k] == "ws") {
							obs.setPermeable((byte) 2, true);
						} else if (s[k] == "ck") {
							obs.setPermeable((byte) 3, true);
						} else if (s[k] == "photon") {
							obs.setPhotonPermeable(true);
						} else if (s[k] == "electron") {
							obs.setElectronPermeable(true);
						}
					}
				}
			} else {
				if (s.length == 2) {
					if ("on".equalsIgnoreCase(s[1]) || "off".equalsIgnoreCase(s[1])) {
						if ("visible".equalsIgnoreCase(s[0])) {
							setObstacleField(str.substring(0, end - 1), s[0], "on".equalsIgnoreCase(s[1]));
						} else if ("draggable".equalsIgnoreCase(s[0])) {
							setObstacleField(str.substring(0, end - 1), s[0], "on".equalsIgnoreCase(s[1]));
						}
					} else {
						double x = parseMathExpression(s[1]);
						if (Double.isNaN(x))
							return false;
						setObstacleField(str.substring(0, end - 1), s[0], x);
					}
				}
			}
			return true;
		}

		// light source field
		matcher = LIGHT_SOURCE.matcher(str);
		if (matcher.find()) {
			if (model instanceof MolecularModel) {
				MolecularModel mm = (MolecularModel) model;
				String t = str.substring(matcher.end()).toLowerCase();
				if (t.startsWith(".angle")) {
					t = t.substring(6).trim();
					double x = parseMathExpression(t);
					if (Double.isNaN(x))
						return false;
					mm.getLightSource().setAngleOfIncidence((float) Math.toRadians(x));
				} else if (t.startsWith(".wavelength")) {
					t = t.substring(11).trim();
					double x = parseMathExpression(t);
					if (Double.isNaN(x))
						return false;
					mm.getLightSource().setFrequency((float) (LightSource.WAVELENGTH_CONVERTER / x));
				}
				return true;
			}
			return false;
		}

		// image field
		matcher = IMAGE_FIELD.matcher(str);
		if (matcher.find()) {
			int end = matcher.end();
			s = str.substring(end).trim().split(REGEX_WHITESPACE + "+");
			if (s.length != 2) {
				out(ScriptEvent.FAILED, "Argument error: " + str);
				return false;
			}
			setImageField(str.substring(0, end - 1), s[0], s[1]);
			return true;
		}

		// line field
		matcher = LINE_FIELD.matcher(str);
		if (matcher.find()) {
			int end = matcher.end();
			s = str.substring(end).trim().split(REGEX_WHITESPACE + "+");
			if (s.length < 2) {
				out(ScriptEvent.FAILED, "Argument error: " + str);
				return false;
			} else if (s.length == 5) {
				s[1] += s[2] + s[3] + s[4];
			}
			setLineField(str.substring(0, end - 1), s[0], s[1]);
			return true;
		}

		// rectangle field
		matcher = RECTANGLE_FIELD.matcher(str);
		if (matcher.find()) {
			int end = matcher.end();
			s = str.substring(end).trim().split(REGEX_WHITESPACE + "+");
			if (s.length < 2) {
				out(ScriptEvent.FAILED, "Argument error: " + str);
				return false;
			} else if (s.length == 5) {
				s[1] += s[2] + s[3] + s[4];
			}
			setRectangleField(str.substring(0, end - 1), s[0], s[1]);
			return true;
		}

		// triangle field
		matcher = TRIANGLE_FIELD.matcher(str);
		if (matcher.find()) {
			int end = matcher.end();
			s = str.substring(end).trim().split(REGEX_WHITESPACE + "+");
			if (s.length < 2) {
				out(ScriptEvent.FAILED, "Argument error: " + str);
				return false;
			}
			setTriangleField(str.substring(0, end - 1), s[0], s[1]);
			return true;
		}

		// ellipse field
		matcher = ELLIPSE_FIELD.matcher(str);
		if (matcher.find()) {
			int end = matcher.end();
			s = str.substring(end).trim().split(REGEX_WHITESPACE + "+");
			if (s.length < 2) {
				out(ScriptEvent.FAILED, "Argument error: " + str);
				return false;
			} else if (s.length == 5) {
				s[1] += s[2] + s[3] + s[4];
			}
			setEllipseField(str.substring(0, end - 1), s[0], s[1]);
			return true;
		}

		// textbox field
		matcher = TEXTBOX_FIELD.matcher(str);
		if (matcher.find()) {
			int end = matcher.end();
			String s1 = str.substring(0, end - 1);
			String s2 = str.substring(end).trim();
			int i = s2.indexOf(" ");
			setTextBoxField(s1, s2.substring(0, i), s2.substring(i).trim());
			return true;
		}

		if (str.trim().startsWith("%")) { // change the value of a defined variable
			int whitespace = str.indexOf(" ");
			String var = str.substring(0, whitespace).trim().toLowerCase();
			String exp = str.substring(whitespace).trim().toLowerCase();
			boolean isStatic = false;
			if (!sharedDefinition.isEmpty()) {
				Map<String, String> map = sharedDefinition.get(model.getClass());
				if (map != null && !map.isEmpty()) {
					if (map.containsKey(var)) {
						isStatic = true;
					}
				}
			}
			if (exp.startsWith("temperature(")) {
				exp = evaluateTemperatureFunction(exp);
				if (exp != null)
					storeDefinition(isStatic, var, exp);
			} else if (exp.startsWith("kineticenergy(")) {
				exp = evaluateKineticEnergyFunction(exp);
				if (exp != null)
					storeDefinition(isStatic, var, exp);
			} else if (exp.startsWith("speed(")) {
				exp = evaluateSpeedFunction(exp);
				if (exp != null)
					storeDefinition(isStatic, var, exp);
			} else if (exp.startsWith("count(")) {
				exp = evaluateCountFunction(exp);
				storeDefinition(isStatic, var, exp != null ? exp : "0");
			} else if (exp.startsWith("within(")) {
				removeDefinition(var);
				String[] array = evaluateWithinFunction(exp);
				if (array != null) {
					createArray(var, array.length);
					for (int i = 0; i < array.length; i++) {
						storeDefinition(isStatic, var + "[" + i + "]", array[i] != null ? array[i] : "-1");
					}
				} else {
					storeDefinition(isStatic, var + ".length", "0");
				}
			} else if (exp.startsWith("nearest(")) {
				exp = evaluateNearestParticleFunction(exp);
				storeDefinition(isStatic, var, exp != null ? exp : "-1");
			} else if (exp.startsWith("nearestmolecule(")) {
				exp = evaluateNearestMoleculeFunction(exp);
				storeDefinition(isStatic, var, exp != null ? exp : "-1");
			} else if (exp.startsWith("nearesttoatom(")) {
				exp = evaluateNearestToAtomFunction(exp);
				storeDefinition(isStatic, var, exp != null ? exp : "-1");
			} else if (exp.startsWith("complementarytype(")) {
				exp = evaluateComplementaryTypeFunction(exp);
				storeDefinition(isStatic, var, exp != null ? exp : "-1");
			} else if (exp.startsWith("whichparticle(")) {
				exp = evaluateWhichParticleFunction(exp);
				storeDefinition(isStatic, var, exp != null ? exp : "-1");
			} else if (exp.startsWith("whichobstacle(")) {
				exp = evaluateWhichObstacleFunction(exp);
				storeDefinition(isStatic, var, exp != null ? exp : "-1");
			} else if (exp.startsWith("whichrbond(")) {
				exp = evaluateWhichRBondFunction(exp);
				storeDefinition(isStatic, var, exp != null ? exp : "-1");
			} else if (exp.startsWith("countrbond(")) {
				exp = evaluateCountRBondFunction(exp);
				storeDefinition(isStatic, var, exp != null ? exp : "0");
			} else if (exp.startsWith("whichabond(")) {
				exp = evaluateWhichABondFunction(exp);
				storeDefinition(isStatic, var, exp != null ? exp : "-1");
			} else if (exp.startsWith("whichmolecule(")) {
				exp = evaluateWhichMoleculeFunction(exp);
				storeDefinition(isStatic, var, exp != null ? exp : "-1");
			} else if (exp.startsWith("atomofmolecule(")) {
				exp = evaluateAtomOfMoleculeFunction(exp);
				storeDefinition(isStatic, var, exp != null ? exp : "-1");
			} else if (exp.startsWith("sequenceofmolecule(")) {
				exp = evaluateSequenceOfMoleculeFunction(exp);
				storeDefinition(isStatic, var, exp != null ? exp : "-1");
			} else if (exp.startsWith("whichimageisattached(")) {
				exp = evaluateWhichImageIsAttachedFunction(exp);
				storeDefinition(isStatic, var, exp != null ? exp : "-1");
			} else if (exp.startsWith("findindexbycustom(")) {
				exp = evaluateFindIndexByCustomFunction(exp);
				storeDefinition(isStatic, var, exp != null ? exp : "-1");
			} else if (exp.startsWith("ptsegdistsq(")) {
				exp = evaluatePtSegDistSqFunction(exp);
				storeDefinition(isStatic, var, exp != null ? exp : "-1");
			} else {
				evaluateDefineMathexClause(isStatic, var, exp);
			}
			return true;
		}

		s = str.trim().split(REGEX_WHITESPACE + "+");

		if (s.length == 2) {

			String s0 = s[0].trim().toLowerCase().intern();
			if ("on".equalsIgnoreCase(s[1].trim()) || "off".equalsIgnoreCase(s[1].trim())) {
				if (s0 == "visible") {
					boolean b = "on".equalsIgnoreCase(s[1].trim());
					int n = model.getNumberOfParticles();
					for (int i = 0; i < n; i++) {
						Particle p = model.getParticle(i);
						if (p.isSelected())
							p.visible = b;
					}
					LineComponent[] lc = view.getLines();
					if (lc != null && lc.length > 0) {
						for (LineComponent x : lc) {
							if (x.isSelected())
								x.setVisible(b);
						}
					}
					RectangleComponent[] rc = view.getRectangles();
					if (rc != null && rc.length > 0) {
						for (RectangleComponent x : rc) {
							if (x.isSelected())
								x.setVisible(b);
						}
					}
					EllipseComponent[] ec = view.getEllipses();
					if (ec != null && ec.length > 0) {
						for (EllipseComponent x : ec) {
							if (x.isSelected())
								x.setVisible(b);
						}
					}
					TextBoxComponent[] tc = view.getTextBoxes();
					if (tc != null && tc.length > 0) {
						for (TextBoxComponent x : tc) {
							if (x.isSelected())
								x.setVisible(b);
						}
					}
					ImageComponent[] ic = view.getImages();
					if (ic != null && ic.length > 0) {
						for (ImageComponent x : ic) {
							if (x.isSelected())
								x.setVisible(b);
						}
					}
					if (model instanceof MolecularModel) {
						MolecularModel mm = (MolecularModel) model;
						RadialBond rb;
						boolean rbChanged = false;
						synchronized (mm.bonds.getSynchronizationLock()) {
							for (Iterator it = mm.bonds.iterator(); it.hasNext();) {
								rb = (RadialBond) it.next();
								if (rb.isSelected()) {
									rb.setVisible(b);
									if (!rbChanged)
										rbChanged = true;
								}
							}
						}
						if (rbChanged) // notify the bond change listener so that JmolRender can set visibility
							mm.notifyBondChangeListeners();
						RectangularObstacle obs;
						synchronized (mm.obstacles.getSynchronizationLock()) {
							for (Iterator it = mm.obstacles.iterator(); it.hasNext();) {
								obs = (RectangularObstacle) it.next();
								if (obs.isSelected())
									obs.setVisible(b);
							}
						}
					}
					notifyChange();
					view.repaint();
					return true;
				}
				if (s0 == "draggable") {
					boolean b = "on".equalsIgnoreCase(s[1].trim());
					int n = model.getNumberOfParticles();
					for (int i = 0; i < n; i++) {
						Particle p = model.getParticle(i);
						if (p.isSelected())
							p.setDraggable(b);
					}
					LineComponent[] lc = view.getLines();
					if (lc != null && lc.length > 0) {
						for (LineComponent x : lc) {
							if (x.isSelected())
								x.setDraggable(b);
						}
					}
					RectangleComponent[] rc = view.getRectangles();
					if (rc != null && rc.length > 0) {
						for (RectangleComponent x : rc) {
							if (x.isSelected())
								x.setDraggable(b);
						}
					}
					EllipseComponent[] ec = view.getEllipses();
					if (ec != null && ec.length > 0) {
						for (EllipseComponent x : ec) {
							if (x.isSelected())
								x.setDraggable(b);
						}
					}
					TextBoxComponent[] tc = view.getTextBoxes();
					if (tc != null && tc.length > 0) {
						for (TextBoxComponent x : tc) {
							if (x.isSelected())
								x.setDraggable(b);
						}
					}
					ImageComponent[] ic = view.getImages();
					if (ic != null && ic.length > 0) {
						for (ImageComponent x : ic) {
							if (x.isSelected())
								x.setDraggable(b);
						}
					}
					if (model instanceof MolecularModel) {
						MolecularModel mm = (MolecularModel) model;
						RectangularObstacle obs;
						synchronized (mm.obstacles.getSynchronizationLock()) {
							for (Iterator it = mm.obstacles.iterator(); it.hasNext();) {
								obs = (RectangularObstacle) it.next();
								if (obs.isSelected())
									obs.setDraggable(b);
							}
						}
					}
					notifyChange();
					return true;
				}
				if (s0 == "movable") {
					boolean b = "on".equalsIgnoreCase(s[1].trim());
					int n = model.getNumberOfParticles();
					for (int i = 0; i < n; i++) {
						Particle p = model.getParticle(i);
						if (p.isSelected())
							p.setMovable(b);
					}
					notifyChange();
					return true;
				}
				if (s0 == "translucent") {
					if (model instanceof MolecularModel) {
						((AtomisticView) view).setTranslucent("on".equalsIgnoreCase(s[1].trim()));
						view.repaint();
						notifyChange();
						return true;
					}
				}
			}
			if (s0 == "bondstyle") {
				if (model instanceof MolecularModel) {
					MolecularModel mm = (MolecularModel) model;
					if (!mm.bonds.isEmpty()) {
						byte style = -1;
						for (Field f : RadialBond.class.getFields()) {
							if (f.getName().equalsIgnoreCase(s[1].trim())) {
								try {
									style = f.getByte(null);
								} catch (IllegalArgumentException e) {
									e.printStackTrace();
									out(ScriptEvent.FAILED, "Incorrect bond style input.");
									return false;
								} catch (IllegalAccessException e) {
									e.printStackTrace();
									out(ScriptEvent.FAILED, "Incorrect bond style input.");
									return false;
								}
							}
						}
						if (style == -1) {
							out(ScriptEvent.FAILED, "Incorrect bond style input.");
							return false;
						}
						RadialBond rb;
						synchronized (mm.bonds.getSynchronizationLock()) {
							for (Iterator it = mm.bonds.iterator(); it.hasNext();) {
								rb = (RadialBond) it.next();
								if (rb.isSelected())
									rb.setBondStyle(style);
							}
						}
						notifyChange();
					}
				}
				return true;
			} else if (s0 == "bondcolor") {
				if (model instanceof MolecularModel) {
					MolecularModel mm = (MolecularModel) model;
					if (!mm.bonds.isEmpty()) {
						Color c = parseRGBColor(s[1].trim());
						if (c == null) {
							out(ScriptEvent.FAILED, "Incorrect bond color input.");
							return false;
						}
						RadialBond rb;
						synchronized (mm.bonds.getSynchronizationLock()) {
							for (Iterator it = mm.bonds.iterator(); it.hasNext();) {
								rb = (RadialBond) it.next();
								if (rb.isSelected())
									rb.setBondColor(c);
							}
						}
						notifyChange();
					}
				}
				return true;
			} else if (s0 == "efielddirection") {
				ElectricField eField = (ElectricField) model.getNonLocalField(ElectricField.class.getName());
				if (eField != null) {
					try {
						Field fie = VectorField.class.getField(s[1]);
						eField.setOrientation(fie.getShort(null));
					} catch (Exception e) {
						e.printStackTrace();
						return false;
					}
					notifyChange();
				}
				return true;
			}
			double x = parseMathExpression(s[1]);
			if (Double.isNaN(x))
				return false;
			if (s0 == "vx") {
				int n = model.getNumberOfParticles();
				for (int i = 0; i < n; i++) {
					Particle p = model.getParticle(i);
					if (p.isSelected())
						p.vx = x * IV_CONVERTER;
				}
				notifyChange();
				return true;
			} else if (s0 == "vy") {
				int n = model.getNumberOfParticles();
				for (int i = 0; i < n; i++) {
					Particle p = model.getParticle(i);
					if (p.isSelected())
						p.vy = x * IV_CONVERTER;
				}
				notifyChange();
				return true;
			} else if (s0 == "hx") {
				int n = model.getNumberOfParticles();
				for (int i = 0; i < n; i++) {
					Particle p = model.getParticle(i);
					if (p.isSelected())
						p.hx = (float) x * R_CONVERTER;
				}
				notifyChange();
				return true;
			} else if (s0 == "hy") {
				int n = model.getNumberOfParticles();
				for (int i = 0; i < n; i++) {
					Particle p = model.getParticle(i);
					if (p.isSelected())
						p.hy = (float) x * R_CONVERTER;
				}
				notifyChange();
				return true;
			} else if (s0 == "kelvin") {
				int n = model.getNumberOfParticles();
				if (model instanceof AtomicModel) {
					AtomicModel am = (AtomicModel) model;
					List<Atom> list = new ArrayList<Atom>();
					for (int i = 0; i < n; i++) {
						Atom a = am.atom[i];
						if (a.isSelected())
							list.add(a);
					}
					if (!list.isEmpty()) {
						am.setTemperature(list, x);
						notifyChange();
					}
				}
				return true;
			} else if (s0 == "charge") {
				int n = model.getNumberOfParticles();
				for (int i = 0; i < n; i++) {
					Particle p = model.getParticle(i);
					if (p.isSelected())
						p.charge = x;
				}
				notifyChange();
				return true;
			} else if (s0 == "omega") {
				int n = model.getNumberOfParticles();
				for (int i = 0; i < n; i++) {
					Particle p = model.getParticle(i);
					if (p.isSelected() && p instanceof UnitedAtom) {
						((UnitedAtom) p).omega = x;
					}
				}
				notifyChange();
				return true;
			} else if (s0 == "dipole") {
				int n = model.getNumberOfParticles();
				for (int i = 0; i < n; i++) {
					Particle p = model.getParticle(i);
					if (p.isSelected() && p instanceof UnitedAtom) {
						((UnitedAtom) p).dipoleMoment = x;
					}
				}
				notifyChange();
				return true;
			} else if (s0 == "strength") {
				if (model instanceof MolecularModel) {
					MolecularModel mm = (MolecularModel) model;
					if (!mm.bonds.isEmpty()) {
						RadialBond rb;
						synchronized (mm.bonds.getSynchronizationLock()) {
							for (Iterator it = mm.bonds.iterator(); it.hasNext();) {
								rb = (RadialBond) it.next();
								if (rb.isSelected()) {
									if (x > ZERO) {
										rb.setBondStrength(x);
									} else {
										it.remove();
									}
								}
							}
						}
					}
					if (!mm.bends.isEmpty()) {
						AngularBond ab;
						synchronized (mm.bends.getSynchronizationLock()) {
							for (Iterator it = mm.bends.iterator(); it.hasNext();) {
								ab = (AngularBond) it.next();
								if (ab.isSelected()) {
									if (x > ZERO) {
										ab.setBondStrength(x);
									} else {
										it.remove();
									}
								}
							}
						}
					}
					mm.removeGhostAngularBonds();
					notifyChange();
				}
				return true;
			} else if (s0 == "bondlength") {
				if (model instanceof MolecularModel) {
					MolecularModel mm = (MolecularModel) model;
					if (!mm.bonds.isEmpty()) {
						RadialBond rb;
						synchronized (mm.bonds.getSynchronizationLock()) {
							for (Iterator it = mm.bonds.iterator(); it.hasNext();) {
								rb = (RadialBond) it.next();
								if (rb.isSelected())
									rb.setBondLength(x * IR_CONVERTER);
							}
						}
						notifyChange();
					}
				}
				return true;
			} else if (s0 == "bondangle") {
				if (model instanceof MolecularModel) {
					MolecularModel mm = (MolecularModel) model;
					if (!mm.bends.isEmpty()) {
						AngularBond ab;
						synchronized (mm.bends.getSynchronizationLock()) {
							for (Iterator it = mm.bends.iterator(); it.hasNext();) {
								ab = (AngularBond) it.next();
								if (ab.isSelected())
									ab.setBondAngle(Math.toRadians(x));
							}
						}
						notifyChange();
					}
				}
				return true;
			} else if (s0 == "torque") {
				if (model instanceof MolecularModel) {
					MolecularModel mm = (MolecularModel) model;
					if (!mm.molecules.isEmpty()) {
						Molecule mol;
						synchronized (mm.molecules.getSynchronizationLock()) {
							for (Iterator it = mm.molecules.iterator(); it.hasNext();) {
								mol = (Molecule) it.next();
								if (mol.isSelected()) {
									if (Math.abs(x) > Particle.ZERO) {
										MolecularTorque mt = mol.getTorque();
										if (mt == null) {
											mt = new MolecularTorque();
											mol.setTorque(mt);
										}
										mt.setForce((float) (x * IV_CONVERTER));
									} else {
										mol.setTorque(null);
									}
								}
							}
						}
						notifyChange();
					}
				}
				return true;
			} else if (s0 == "muscle_amplitude") {
				if (model instanceof MolecularModel) {
					MolecularModel mm = (MolecularModel) model;
					if (!mm.bonds.isEmpty()) {
						RadialBond rb;
						synchronized (mm.bonds.getSynchronizationLock()) {
							for (Iterator it = mm.bonds.iterator(); it.hasNext();) {
								rb = (RadialBond) it.next();
								if (rb.isSelected()) {
									rb.setAmplitude((float) (x * 0.001));
								}
							}
						}
						notifyChange();
					}
				}
				return true;
			} else if (s0 == "muscle_period") {
				if (model instanceof MolecularModel) {
					MolecularModel mm = (MolecularModel) model;
					if (!mm.bonds.isEmpty()) {
						RadialBond rb;
						synchronized (mm.bonds.getSynchronizationLock()) {
							for (Iterator it = mm.bonds.iterator(); it.hasNext();) {
								rb = (RadialBond) it.next();
								if (rb.isSelected()) {
									rb.setPeriod((int) x);
								}
							}
						}
						notifyChange();
					}
				}
				return true;
			} else if (s0 == "model_time") {
				model.setModelTime((float) x);
				notifyChange();
				return true;
			} else if (s0 == "temperature") {
				model.setTemperature(x);
				notifyChange();
				return true;
			} else if (s0 == "amino_acid_name_style") {
				if (model instanceof MolecularModel) {
					((MolecularModel) model).setAminoAcidNameStyle((byte) Math.round(x));
					notifyChange();
				}
				return true;
			} else if (s0 == "dielectric") {
				model.universe.setDielectricConstant((float) x);
				notifyChange();
				return true;
			} else if (s0 == "viscosity") {
				model.universe.setViscosity((float) x);
				notifyChange();
				return true;
			} else if (s0 == "timestep") {
				model.setTimeStepAndAdjustReminder(x);
				notifyChange();
				return true;
			} else if (s0 == "heatbath") {
				model.activateHeatBath(x > 0);
				if (model.heatBathActivated())
					model.getHeatBath().setExpectedTemperature(x);
				notifyChange();
				return true;
			} else if (s0 == "cell_x") {
				if (model.boundary.getType() == Boundary.DBC_ID) {
					out(ScriptEvent.HARMLESS, "No effect for default boundary.");
				} else {
					model.boundary.x = x * IR_CONVERTER;
					notifyChange();
				}
				return true;
			} else if (s0 == "cell_y") {
				if (model.boundary.getType() == Boundary.DBC_ID) {
					out(ScriptEvent.HARMLESS, "No effect for default boundary.");
				} else {
					model.boundary.y = x * IR_CONVERTER;
					notifyChange();
				}
				return true;
			} else if (s0 == "cell_width") {
				if (model.boundary.getType() == Boundary.DBC_ID) {
					out(ScriptEvent.HARMLESS, "No effect for default boundary.");
				} else {
					model.boundary.width = x * IR_CONVERTER;
					notifyChange();
				}
				return true;
			} else if (s0 == "cell_height") {
				if (model.boundary.getType() == Boundary.DBC_ID) {
					out(ScriptEvent.HARMLESS, "No effect for default boundary.");
				} else {
					model.boundary.height = x * IR_CONVERTER;
					notifyChange();
				}
				return true;
			} else if (s0 == "width") {
				final Dimension dim = new Dimension((int) (x * IR_CONVERTER), view.getHeight());
				EventQueue.invokeLater(new Runnable() {
					public void run() {
						view.setSize(dim);
					}
				});
				notifyChange();
				return true;
			} else if (s0 == "height") {
				final Dimension dim = new Dimension(view.getWidth(), (int) (x * IR_CONVERTER));
				EventQueue.invokeLater(new Runnable() {
					public void run() {
						view.setSize(dim);
					}
				});
				notifyChange();
				return true;
			} else if (s0 == "gfield") {
				if (x < 0) {
					out(ScriptEvent.FAILED, "Illegal parameter: gravitational acceleration cannot be negative: " + x);
					return false;
				}
				VectorField vf = model.getNonLocalField(GravitationalField.class.getName());
				if (x < ZERO) {
					if (vf != null)
						model.removeNonLocalField(vf);
				} else {
					if (vf == null) {
						vf = new GravitationalField(view.getBounds());
						model.addNonLocalField(vf);
					}
					vf.setIntensity(x);
				}
				notifyChange();
				return true;
			} else if (s0 == "efield") {
				VectorField vf = model.getNonLocalField(ElectricField.class.getName());
				if (Math.abs(x) < ZERO) {
					if (vf != null)
						model.removeNonLocalField(vf);
				} else {
					if (vf == null) {
						vf = new ElectricField(view.getBounds());
						model.addNonLocalField(vf);
					}
					vf.setIntensity(x);
				}
				notifyChange();
				return true;
			} else if (s0 == "bfield") {
				VectorField vf = model.getNonLocalField(MagneticField.class.getName());
				if (Math.abs(x) < ZERO) {
					if (vf != null)
						model.removeNonLocalField(vf);
				} else {
					if (vf == null) {
						vf = new MagneticField(view.getBounds());
						model.addNonLocalField(vf);
					}
					vf.setIntensity(x);
				}
				notifyChange();
				return true;
			} else if (s0 == "weight") {
				LineComponent[] lines = view.getLines();
				for (LineComponent lc : lines) {
					if (lc.isSelected())
						lc.setLineWeight((byte) x);
				}
				RectangleComponent[] rects = view.getRectangles();
				for (RectangleComponent rc : rects) {
					if (rc.isSelected())
						rc.setLineWeight((byte) x);
				}
				EllipseComponent[] ellipses = view.getEllipses();
				for (EllipseComponent ec : ellipses) {
					if (ec.isSelected())
						ec.setLineWeight((byte) x);
				}
				return true;
			}
		} else {

			if (s.length == 4) {

				if (model instanceof AtomicModel) {
					AtomicModel am = (AtomicModel) model;
					matcher = SET_EPSILON.matcher(str);
					if (matcher.find()) {
						double x = parseMathExpression(s[1]);
						if (Double.isNaN(x))
							return false;
						int i1 = (int) Math.round(x);
						if (i1 < 0 || i1 > Element.ID_CK) {
							out(ScriptEvent.FAILED, "Unsupported element: type " + i1);
							return false;
						}
						x = parseMathExpression(s[2]);
						if (Double.isNaN(x))
							return false;
						int i2 = (int) Math.round(x);
						if (i2 < 0 || i2 > Element.ID_CK) {
							out(ScriptEvent.FAILED, "Unsupported element: type " + i2);
							return false;
						}
						double eps = parseMathExpression(s[3]);
						if (Double.isNaN(eps))
							return false;
						if (i1 == i2) {
							am.getElement(i1).setEpsilon(eps);
						} else {
							Element e1 = am.getElement(i1);
							Element e2 = am.getElement(i2);
							am.getAffinity().setLBMixing(e1, e2, false);
							am.getAffinity().setEpsilon(e1, e2, eps);
						}
						notifyChange();
						return true;
					}
				}

			}

		}

		out(ScriptEvent.FAILED, "Unrecognized type of parameter to set: " + str);
		return false;

	}