for (int j = 1; j < coords[0]; j++)
int j = 1; while (j < coords[0])
	private void execute(Statement st, ContextStack context)		throws MapyrusException, IOException	{		Expression []expr;		int nExpressions;		int type;		Argument []args = null;		double degrees;		double x1, y1, x2, y2;		int units;		expr = st.getExpressions();		nExpressions = expr.length;				/*		 * Evaluate each of the expressions for this statement.		 */		if (nExpressions > 0)		{			args = new Argument[nExpressions];			for (int i = 0; i < nExpressions; i++)			{				args[i] = expr[i].evaluate(context);			}		}				type = st.getType();		switch (type)		{			case Statement.COLOR:				if (nExpressions == 1 && args[0].getType() == Argument.STRING)				{					/*					 * Find named color in color name database.					 */					Color c = ColorDatabase.getColor(args[0].getStringValue());					if (c == null)					{						throw new MapyrusException("Color not found: " +							args[0].getStringValue());					}					context.setColor(c); 				}				else if (nExpressions == 4 &&					args[0].getType() == Argument.STRING &&					args[1].getType() == Argument.NUMERIC &&					args[2].getType() == Argument.NUMERIC &&					args[3].getType() == Argument.NUMERIC)				{					String colorType = args[0].getStringValue();					float c1 = (float)args[1].getNumericValue();					float c2 = (float)args[2].getNumericValue();					float c3 = (float)args[3].getNumericValue();										if (colorType.equalsIgnoreCase("hsb"))					{						/*						 * Set HSB color.						 */						int rgb = Color.HSBtoRGB(c1, c2, c3);						context.setColor(new Color(rgb));					}					else if (colorType.equalsIgnoreCase("rgb"))					{								/*						 * Set RGB color.						 */						context.setColor(new Color(c1, c2, c3));					}					else					{						throw new MapyrusException("Unknown color type: " +							colorType);					}				}				else				{					throw new MapyrusException("Invalid color at " +						st.getFilenameAndLineNumber());				}				break;			case Statement.LINEWIDTH:				if (nExpressions == 1 && args[0].getType() == Argument.NUMERIC)				{					/*					 * Set new line width.					 */					context.setLineWidth(args[0].getNumericValue());				}				else				{					throw new MapyrusException("Invalid line width at " +							st.getFilenameAndLineNumber());				}				break;						case Statement.MOVE:			case Statement.DRAW:				if (nExpressions > 0 && nExpressions % 2 == 0)				{					/*					 * Check that all coordindate values are numbers.					 */					for (int i = 0; i < nExpressions; i++)					{						if (args[0].getType() != Argument.NUMERIC)						{							throw new MapyrusException("Invalid coordinate value at " +								st.getFilenameAndLineNumber());						}					}										for (int i = 0; i < nExpressions; i += 2)					{						/*						 * Add point to path.						 */						if (type == Statement.MOVE)						{							context.moveTo(args[i].getNumericValue(),								args[i + 1].getNumericValue());						}						else						{							context.lineTo(args[i].getNumericValue(),								args[i + 1].getNumericValue());						}					}				}				else				{					throw new MapyrusException("Wrong number of coordinate values at " +						st.getFilenameAndLineNumber());				}				break;							case Statement.CLEARPATH:				if (nExpressions > 0)				{					throw new MapyrusException("Unexpected arguments at " +						st.getFilenameAndLineNumber());				}				context.clearPath();				break;			case Statement.SLICEPATH:				if (nExpressions == 2 && args[0].getType() == Argument.NUMERIC &&					args[1].getType() == Argument.NUMERIC)				{					context.slicePath(args[0].getNumericValue(), args[1].getNumericValue());				}				else				{					throw new MapyrusException("Invalid path slice values at " +						st.getFilenameAndLineNumber());				}				break;							case Statement.STRIPEPATH:				if (nExpressions == 2 && args[0].getType() == Argument.NUMERIC &&					args[1].getType() == Argument.NUMERIC)				{					degrees = args[1].getNumericValue();					context.stripePath(args[0].getNumericValue(), Math.toRadians(degrees));				}				else				{					throw new MapyrusException("Invalid path stripe values at " +						st.getFilenameAndLineNumber());				}				break;			case Statement.STROKE:				if (nExpressions > 0)				{					throw new MapyrusException("Unexpected arguments at " +						st.getFilenameAndLineNumber());				}				context.stroke();				break;							case Statement.FILL:				if (nExpressions > 0)				{					throw new MapyrusException("Unexpected arguments at " +						st.getFilenameAndLineNumber());				}				context.fill();				break;							case Statement.CLIP:				if (nExpressions > 0)				{					throw new MapyrusException("Unexpected arguments at " +						st.getFilenameAndLineNumber());				}				context.clip();				break;											case Statement.SCALE:				if (nExpressions == 2 &&					args[0].getType() == Argument.NUMERIC &&					args[1].getType() == Argument.NUMERIC)				{					context.setScaling(args[0].getNumericValue(),						args[1].getNumericValue());				}				else				{					throw new MapyrusException("Invalid scaling values at " +						st.getFilenameAndLineNumber());				}				break;			case Statement.ROTATE:				if (nExpressions == 1 && args[0].getType() == Argument.NUMERIC)				{					degrees = args[0].getNumericValue();					context.setRotation(Math.toRadians(degrees));				}				else				{					throw new MapyrusException("Invalid rotation value at " +						st.getFilenameAndLineNumber());				}				break;			case Statement.WORLDS:				if ((nExpressions == 4 || nExpressions == 5) &&					args[0].getType() == Argument.NUMERIC &&					args[1].getType() == Argument.NUMERIC &&					args[2].getType() == Argument.NUMERIC &&					args[3].getType() == Argument.NUMERIC)				{					x1 = args[0].getNumericValue();					y1 = args[1].getNumericValue();					x2 = args[2].getNumericValue();					y2 = args[3].getNumericValue();					if (nExpressions == 5)					{						Integer i;						if (args[4].getType() == Argument.STRING)						{							i = (Integer)mWorldUnitsLookup.get(args[4].getStringValue());							if (i == null)							{								throw new MapyrusException("Unknown world units value '" +									args[4].getStringValue() + "' at " +									st.getFilenameAndLineNumber());							}							units = i.intValue();						}						else						{							throw new MapyrusException("Invalid world units value at " +								st.getFilenameAndLineNumber());						}					}					else					{						units = Context.WORLD_UNITS_METRES;					}										if (x2 - x1 == 0.0 || y2 - y1 == 0.0)					{						throw new MapyrusException("Zero world coordinate range at " +							st.getFilenameAndLineNumber());					}						context.setWorlds(x1, y1, x2, y2, units);				}				else				{					throw new MapyrusException("Invalid worlds values at " +						st.getFilenameAndLineNumber());				}				break;			case Statement.PROJECT:				if (nExpressions == 2 && args[0].getType() == Argument.STRING &&					args[1].getType() == Argument.STRING)				{						context.setTransform(args[0].getStringValue(),							args[1].getStringValue());				}				else				{					throw new MapyrusException("Invaild transformation at " +						st.getFilenameAndLineNumber());				}				break;			case Statement.IMPORT:				if (nExpressions >= 3)				{					/*					 * All arguments are strings.					 */					for (int i = 0; i < nExpressions; i++)					{						if (args[i].getType() != Argument.STRING)							throw new MapyrusException("Invalid dataset at " +								st.getFilenameAndLineNumber());					}					/*					 * Build array of geometry field names.					 */										String []geometryFieldNames = new String[nExpressions - 3];					for (int i = 0; i < geometryFieldNames.length; i++)						geometryFieldNames[i] = args[i + 3].getStringValue();					/*					 * Open the dataset.					 */											context.setDataset(args[0].getStringValue(), args[1].getStringValue(),						args[2].getStringValue(), geometryFieldNames);				}				else				{					throw new MapyrusException("Invalid dataset at " +						st.getFilenameAndLineNumber());				}				break;			case Statement.FETCH:				/*				 * Add next row from dataset to path.				 */				Row row = context.fetchRow();				int index = 0;				int []geometryFieldIndexes = context.getDatasetGeometryFieldIndexes();				String []fieldNames = context.getDatasetFieldNames();				double x = 0.0;				for (int i = 0; i < row.size(); i++)				{					Argument field = (Argument)row.elementAt(i);					if (index < geometryFieldIndexes.length &&						i == geometryFieldIndexes[index])					{						if (field.getType() == Argument.GEOMETRY)						{							/*							 * Define path from fetched geometry.							 */							double []coords = field.getGeometryValue();							for (int j = 1; j < coords[0]; j++)							{								if (coords[j] == PathIterator.SEG_MOVETO)									context.moveTo(coords[j + 1], coords[j + 2]);								else									context.lineTo(coords[j + 1], coords[j + 2]);								j += 3;							}						}						else						{							/*							 * First pair of geometry fields contain moveTo coordinates.							 * Successive pairs define lineTo coordinates.							 */							if (index == 1)								context.moveTo(x, field.getNumericValue());							else if (index % 2 == 0)								x = field.getNumericValue();							else								context.lineTo(x, field.getNumericValue());						}						index++;					}					if (field.getType() != Argument.GEOMETRY)					{						/*						 * Define attributes in non-geometry fields as variables.						 */						context.defineVariable(fieldNames[i], field);					}				}				break;			case Statement.NEWPAGE:				if (nExpressions == 4 &&					args[0].getType() == Argument.STRING &&					args[1].getType() == Argument.STRING &&					args[2].getType() == Argument.NUMERIC &&					args[3].getType() == Argument.NUMERIC)				{					context.setOutputFormat(args[0].getStringValue(),						args[1].getStringValue(),						(int)args[2].getNumericValue(),						(int)args[3].getNumericValue(), "extras");				}				else				{					throw new MapyrusException("Invalid page values at " +						st.getFilenameAndLineNumber());				}				break;											case Statement.PRINT:				/*				 * Print to stdout each of the expressions passed.				 */				for (int i = 0; i <nExpressions; i++)				{					if (args[i].getType() == Argument.STRING)					{						System.out.print(args[i].getStringValue());					}					else					{						DecimalFormat format;						double d = args[i].getNumericValue();						double absoluteD = (d >= 0) ? d : -d;						/*						 * Print large or small numbers in scientific notation						 * to give more significant digits.						 */										if (absoluteD != 0 && (absoluteD < 0.01 || absoluteD > 1000000.0))							format = new DecimalFormat("#.################E0");						else							format = new DecimalFormat("#.################");						System.out.print(format.format(d));					}				}				System.out.println("");				break;							case Statement.ASSIGN:				context.defineVariable(st.getAssignedVariable(), args[0]);				break;		}			}