Input:
	public void run(String arg0)
	{
		int nbima = WindowManager.getImageCount();
		if( nbima == 0 )
		{
			IJ.error( "Watershed 3D",
					"At least one image needs to be open to run waterhsed in 3D");
			return;
		}
        String[] names = new String[ nbima ];
        String[] namesMask = new String[ nbima + 1 ];
        namesMask[ 0 ] = "None";
        for (int i = 0; i < nbima; i++)
        {
            names[ i ] = WindowManager.getImage(i + 1).getShortTitle();
            namesMask[ i + 1 ] = WindowManager.getImage(i + 1).getShortTitle();
        }
        GenericDialog gd = new GenericDialog("Watershed 3D");
        int spot = 0;
        int seed = nbima > 1 ? 1 : 0;
        gd.addChoice( "Input image", names, names[spot] );
        gd.addChoice( "Image to seed from", names, names[seed] );
        gd.addChoice( "Mask", namesMask, namesMask[ nbima > 2 ? 3 : 0 ] );
        gd.addCheckbox( "Use priority queue", usePriorityQueue );
        gd.showDialog();
        if (gd.wasOKed())
        {
            spot = gd.getNextChoiceIndex();
            seed = gd.getNextChoiceIndex();
            int maskIndex = gd.getNextChoiceIndex();
            usePriorityQueue = gd.getNextBoolean();
            ImagePlus inputImage = WindowManager.getImage(spot + 1);
            ImagePlus seedImage = WindowManager.getImage(seed + 1);
            ImagePlus maskImage = maskIndex > 0 ? WindowManager.getImage( maskIndex ) : null;
            ImagePlus result = process( inputImage, seedImage, maskImage );
            ImageProcessor ip = result.getProcessor();
            ip.resetMinAndMax();
            result.setDisplayRange(ip.getMin(),ip.getMax());
            result.show();
        }
	}

Output:
	public void run(String arg0)
	{
		int nbima = WindowManager.getImageCount();
		if( nbima == 0 )
		{
			IJ.error( "Watershed 3D",
					"ERROR: At least one image needs to be open to run watershed in 3D");
			return;
		}
        String[] names = new String[ nbima ];
        String[] namesMask = new String[ nbima + 1 ];
        namesMask[ 0 ] = "None";
        for (int i = 0; i < nbima; i++)
        {
            names[ i ] = WindowManager.getImage(i + 1).getShortTitle();
            namesMask[ i + 1 ] = WindowManager.getImage(i + 1).getShortTitle();
        }
        GenericDialog gd = new GenericDialog("Watershed 3D");
        int spot = 0;
        int seed = nbima > 1 ? 1 : 0;
        gd.addChoice( "Input image", names, names[spot] );
        gd.addChoice( "Image to seed from", names, names[seed] );
        gd.addChoice( "Mask", namesMask, namesMask[ nbima > 2 ? 3 : 0 ] );
        gd.addCheckbox( "Use priority queue", usePriorityQueue );
        gd.showDialog();
        if (gd.wasOKed())
        {
            spot = gd.getNextChoiceIndex();
            seed = gd.getNextChoiceIndex();
            int maskIndex = gd.getNextChoiceIndex();
            usePriorityQueue = gd.getNextBoolean();
            ImagePlus inputImage = WindowManager.getImage(spot + 1);
            ImagePlus seedImage = WindowManager.getImage(seed + 1);
            ImagePlus maskImage = maskIndex > 0 ? WindowManager.getImage( maskIndex ) : null;
            ImagePlus result = process( inputImage, seedImage, maskImage );
            ImageProcessor ip = result.getProcessor();
            ip.resetMinAndMax();
            result.setDisplayRange(ip.getMin(),ip.getMax());
            result.show();
        }
	}


Input:
	public void getFrames(int frame, float[][] frameData)
	{
		if (frame >= nFrames) return;
		if (isTotal())
		{
			int numFloats = Math.min(frameData[0].length,(int)(nFrames-frame))*nChannels;
			if (storeInNativeBitDepth)
			{
				int startIndex = frame * 2 * nChannels;
				float[] floatdata = new float[numFloats];
				AudioUtils.byteToFloat(floatdata, sampleData, isBigEndian, startIndex, numFloats);
				AudioUtils.deinterleave(floatdata,nChannels,frameData[0].length,frameData);
			}
			else
			{
				for(int i=0;i<nChannels;i++)
					System.arraycopy(f_sampleData[i],frame,frameData[i],0,numFloats);
			}
		}
		else
		{
			int numFloats = Math.min(frameData[0].length,(int)(nFrames-frame))*nChannels;
			float[] floatdata = null;
			if (storeInNativeBitDepth)
				floatdata = new float[numFloats];
			int floatdataindex = 0;
			int regionindex = frame % r_regionSize;
			int whichregion = frame / r_regionSize;
			int numfloatstocopy = Math.min(r_regionSize - regionindex,numFloats - floatdataindex);
			while (numfloatstocopy>0)
			{
				try {
					while (!regionLocks[whichregion].tryLock(10, TimeUnit.MILLISECONDS)){}
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
				try {
					if (storeInNativeBitDepth)
					{
						byte[] regionData = getRegion(whichregion);
						if (regionData!=null)
							AudioUtils.byteToFloat(floatdata, regionData, isBigEndian, regionindex*2*nChannels, floatdataindex*nChannels, numfloatstocopy*nChannels);
					}
					else
					{
						float[][] regionData = getRegionF(whichregion);
						if (regionData!=null)
						{
							for(int i=0;i<nChannels;i++)
							{
								System.arraycopy(regionData[i], 0, frameData[i], floatdataindex, numfloatstocopy);
							}
						}
					}
				}
				finally {
					regionLocks[whichregion].unlock();
				}
				floatdataindex += numfloatstocopy;
				regionindex = 0;
				numfloatstocopy = Math.min(r_regionSize,numFloats - floatdataindex);
				whichregion++;
			}
			AudioUtils.deinterleave(floatdata,nChannels,frameData[0].length,frameData);
		}
	}

Output:
	public void getFrames(int frame, float[][] frameData)
	{
		if (frame >= nFrames) return;
		if (isTotal())
		{
			int numFloats = Math.min(frameData[0].length,(int)(nFrames-frame));
			if (storeInNativeBitDepth)
			{
				int startIndex = frame * 2 * nChannels;
				float[] floatdata = new float[numFloats*nChannels];
				AudioUtils.byteToFloat(floatdata, sampleData, isBigEndian, startIndex, numFloats*nChannels);
				AudioUtils.deinterleave(floatdata,nChannels,frameData[0].length,frameData);
			}
			else
			{
				for(int i=0;i<nChannels;i++)
					System.arraycopy(f_sampleData[i],frame,frameData[i],0,numFloats);
			}
		}
		else
		{
			int numFloats = Math.min(frameData[0].length,(int)(nFrames-frame))*nChannels;
			float[] floatdata = null;
			if (storeInNativeBitDepth)
				floatdata = new float[numFloats];
			int floatdataindex = 0;
			int regionindex = frame % r_regionSize;
			int whichregion = frame / r_regionSize;
			int numfloatstocopy = Math.min(r_regionSize - regionindex,numFloats - floatdataindex);
			while (numfloatstocopy>0)
			{
				try {
					while (!regionLocks[whichregion].tryLock(10, TimeUnit.MILLISECONDS)){}
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
				try {
					if (storeInNativeBitDepth)
					{
						byte[] regionData = getRegion(whichregion);
						if (regionData!=null)
							AudioUtils.byteToFloat(floatdata, regionData, isBigEndian, regionindex*2*nChannels, floatdataindex*nChannels, numfloatstocopy*nChannels);
					}
					else
					{
						float[][] regionData = getRegionF(whichregion);
						if (regionData!=null)
						{
							for(int i=0;i<nChannels;i++)
							{
								System.arraycopy(regionData[i], 0, frameData[i], floatdataindex, numfloatstocopy);
							}
						}
					}
				}
				finally {
					regionLocks[whichregion].unlock();
				}
				floatdataindex += numfloatstocopy;
				regionindex = 0;
				numfloatstocopy = Math.min(r_regionSize,numFloats - floatdataindex);
				whichregion++;
			}
			AudioUtils.deinterleave(floatdata,nChannels,frameData[0].length,frameData);
		}
	}


Input:
	public static File location() {
		File file = new File(System.getenv("HOME") + File.separator + LITLE_SDK_CONFIG);
		if(System.getenv("LITLE_CONFIG_DIR") != null) {
			file = new File(System.getenv("LITLE_CONFIG_DIR") + File.separator + LITLE_SDK_CONFIG);
		}
		System.out.println("Loading config from " + file.getAbsolutePath());
		return file;
	}

Output:
	public static File location() {
		File file = new File(System.getProperty("user.home") + File.separator + LITLE_SDK_CONFIG);
		if(System.getenv("LITLE_CONFIG_DIR") != null) {
			file = new File(System.getenv("LITLE_CONFIG_DIR") + File.separator + LITLE_SDK_CONFIG);
		}
		System.out.println("Loading config from " + file.getAbsolutePath());
		return file;
	}


Input:
	private IConstructor visitElement(Element e){
		TypeInfo typeInfo = e.getSchemaTypeInfo();
		java.lang.String typeName = typeInfo.getTypeName();
		Type adt = anonymousType;
		if(typeName != null){
			adt = tf.abstractDataType(typeStore, typeName);
		}
		NodeList childNodesList = e.getChildNodes();
		int nrOfChildNodes = childNodesList.getLength();
		List<Type> childrenTypesList = new ArrayList<Type>();
		childrenTypesList.add(ATTRIBUTES_NODE);
		childrenTypesList.add(STRING_TYPE);
		List<IValue> childrenList = new ArrayList<IValue>();
		childrenList.add(getAttributes(e));
		childrenList.add(DEFAULT_TEXT_CONTENT);
		for(int i = 0; i < nrOfChildNodes; i++){
			Node childNode =  childNodesList.item(i);
			if(childNode instanceof Element){
				Element c = (Element) childNode;
				IConstructor child = visitElement(c);
				childrenTypesList.add(child.getType());
				childrenList.add(child);
			}else{
				java.lang.String textContent = childNode.getNodeValue().trim();
				if(textContent.length() > 0){
					childrenList.set(1, vf.string(textContent));
				}
			}
		}
		int nrOfChildren = childrenTypesList.size();
		Type[] types = new Type[nrOfChildren];
		types = childrenTypesList.toArray(types);
		IValue[] children = new IValue[nrOfChildren];
		children = childrenList.toArray(children);
		java.lang.String name = e.getNodeName();
		Type consType = tf.constructor(typeStore, adt, name, types);
		return vf.constructor(consType, children);
	}

Output:
	private IConstructor visitElement(Element e){
		TypeInfo typeInfo = e.getSchemaTypeInfo();
		java.lang.String typeName = typeInfo.getTypeName();
		Type adt = anonymousType;
		if(typeName != null){
			adt = tf.abstractDataType(typeStore, typeName);
		}
		NodeList childNodesList = e.getChildNodes();
		int nrOfChildNodes = childNodesList.getLength();
		List<Type> childrenTypesList = new ArrayList<Type>();
		childrenTypesList.add(ATTRIBUTES_NODE);
		List<IValue> childrenList = new ArrayList<IValue>();
		childrenList.add(getAttributes(e));
		for(int i = 0; i < nrOfChildNodes; i++){
			Node childNode =  childNodesList.item(i);
			if(childNode instanceof Element){
				Element c = (Element) childNode;
				IConstructor child = visitElement(c);
				childrenTypesList.add(child.getType());
				childrenList.add(child);
			}else{
				java.lang.String textContent = childNode.getNodeValue();
				childrenTypesList.add(STRING_TYPE);
				childrenList.add(vf.string(textContent));
			}
		}
		int nrOfChildren = childrenTypesList.size();
		Type[] types = new Type[nrOfChildren];
		types = childrenTypesList.toArray(types);
		IValue[] children = new IValue[nrOfChildren];
		children = childrenList.toArray(children);
		java.lang.String name = e.getNodeName();
		Type consType = tf.constructor(typeStore, adt, name, types);
		return vf.constructor(consType, children);
	}


Input:
    public void testExtractLeadingNumericText() {
        assertThat(extractLeadingNumericText("abc def"), is(""));
        assertThat(extractLeadingNumericText("5 abc def ds"), is("5"));
        assertThat(extractLeadingNumericText("5.0 abc def ds"), is("5.0"));
        assertThat(extractLeadingNumericText("abc"), is("0"));
    }

Output:
    public void testExtractLeadingNumericText() {
        assertThat(extractLeadingNumericText("abc def"), is(""));
        assertThat(extractLeadingNumericText("5 abc def ds"), is("5"));
        assertThat(extractLeadingNumericText("5.0 abc def ds"), is("5.0"));
        assertThat(extractLeadingNumericText("abc"), is(""));
    }


Input:
    public static String getServerString(HttpServletRequest request) {
        String scheme = request.getScheme();
        int serverPort = request.getServerPort();
        String serverName = request.getServerName();
        StringBuilder sb = new StringBuilder();
        sb.append(scheme);
        sb.append("://");
        sb.append(serverName);
        sb.append((("https".equalsIgnoreCase(scheme) && serverPort == 443) || ("http".equalsIgnoreCase(scheme) && serverPort == 80)) ? "" : ":" + serverPort);
        return sb.toString();
    }

Output:
    public static String getServerString(HttpServletRequest request) {
        String forwardedProto = request.getHeader("X-Forwarded-Proto");
        String scheme = forwardedProto != null ? forwardedProto : request.getScheme();
        int serverPort = request.getServerPort();
        String serverName = request.getServerName();
        StringBuilder sb = new StringBuilder();
        sb.append(scheme);
        sb.append("://");
        sb.append(serverName);
        sb.append((("https".equalsIgnoreCase(scheme) && serverPort == 443) || ("http".equalsIgnoreCase(scheme) && serverPort == 80)) ? "" : ":" + serverPort);
        return sb.toString();
    }


Input:
    public void exportPony(Pony pony) throws IOException
    {
	Color[] colours = new Color[256];
	boolean[] format = new boolean[9];
	Color background = null, foreground = null;
	for (int i = 0; i < 256; i++)
	{   Colour colour = new Colour(i);
	    colours[i] = new Color(colour.red, colour.green, colour.blue);
	}
	if (this.palette != null)
	    System.arraycopy(this.palette, 0, colours, 0, 16);
	StringBuilder resetpalette = null;
	if (this.tty)
	    if (this.colourful)
	    {   resetpalette = new StringBuilder();
		for (int i = 0; i < 16; i++)
		{   Colour colour = new Colour(i);
		    resetpalette.append("\033]P");
		    resetpalette.append("0123456789ABCDEF".charAt(i));
		    resetpalette.append("0123456789ABCDEF".charAt(colour.red >>> 4));
		    resetpalette.append("0123456789ABCDEF".charAt(colour.red & 15));
		    resetpalette.append("0123456789ABCDEF".charAt(colour.green >>> 4));
		    resetpalette.append("0123456789ABCDEF".charAt(colour.green & 15));
		    resetpalette.append("0123456789ABCDEF".charAt(colour.blue >>> 4));
		    resetpalette.append("0123456789ABCDEF".charAt(colour.blue & 15));
	    }   }
	    else
	    {   resetpalette = new StringBuilder();
		for (int i : new int[] { 7, 15 })
		{   Colour colour = new Colour(i);
		    resetpalette.append("\033]P");
		    resetpalette.append("0123456789ABCDEF".charAt(i));
		    resetpalette.append("0123456789ABCDEF".charAt(colour.red >>> 4));
		    resetpalette.append("0123456789ABCDEF".charAt(colour.red & 15));
		    resetpalette.append("0123456789ABCDEF".charAt(colour.green >>> 4));
		    resetpalette.append("0123456789ABCDEF".charAt(colour.green & 15));
		    resetpalette.append("0123456789ABCDEF".charAt(colour.blue >>> 4));
		    resetpalette.append("0123456789ABCDEF".charAt(colour.blue & 15));
	    }   }
	else if (this.fullcolour)
	{   resetpalette = new StringBuilder();
	    for (int i = 0; i < 16; i++)
	    {   Colour colour = new Colour(i);
		resetpalette.append("\033]4;");
		resetpalette.append(i);
		resetpalette.append(";rgb:");
		resetpalette.append("0123456789ABCDEF".charAt(colour.red >>> 4));
		resetpalette.append("0123456789ABCDEF".charAt(colour.red & 15));
		resetpalette.append('/');
		resetpalette.append("0123456789ABCDEF".charAt(colour.green >>> 4));
		resetpalette.append("0123456789ABCDEF".charAt(colour.green & 15));
		resetpalette.append('/');
		resetpalette.append("0123456789ABCDEF".charAt(colour.blue >>> 4));
		resetpalette.append("0123456789ABCDEF".charAt(colour.blue & 15));
		resetpalette.append("\033\\");
	}   }
	StringBuilder databuf = new StringBuilder();
	int curleft = 0, curright = 0, curtop = 0, curbottom = 0;
	Pony.Cell[][] matrix = pony.matrix;
	Pony.Meta[][][] metamatrix = pony.metamatrix;
	boolean[] PLAIN = new boolean[9];
	if ((pony.tags != null) || (pony.comment != null))
	    databuf.append("$$$\n");
	if (pony.tags != null)
	    for (String[] tag : pony.tags)
	    {
		databuf.append(tag[0].toUpperCase());
		databuf.append(": ");
		databuf.append(tag[1]);
		databuf.append("\n");
	    }
	if (pony.comment != null)
	{
	    if ((pony.tags != null) && (pony.tags.length != 0))
		databuf.append('\n');
	    String comment = '\n' + pony.comment.trim() + '\n';
	    while (comment.contains("\n$$$\n"))
		comment = comment.replace("\n$$$\n", "\n$$$(!)\n");
	    comment = comment.substring(1, comment.length() - 1);
	    databuf.append(comment);
	}
	if ((pony.tags != null) || (pony.comment != null))
	    databuf.append("\n$$$\n");
	if (this.ignoreballoon)
	    for (Pony.Meta[][] row : metamatrix)
		for (Pony.Meta[] cell : row)
		    if (cell != null)
			for (int i = 0, n = cell.length; i < n; i++)
			    if ((cell[i] != null) && (cell[i] instanceof Pony.Balloon))
				row[i] = null;
	if (this.ignorelink)
	    for (Pony.Cell[] row : matrix)
		for (int i = 0, n = row.length; i < n; i++)
		{   Pony.Cell cell;
		    if ((cell = row[i]) != null)
			if (this.ignorelink && ((cell.character == Pony.Cell.NNE_SSW) || (cell.character == Pony.Cell.NNW_SSE)))
			    row[i] = new Pony.Cell(' ', null, null, PLAIN);
			else
			{   Color back = ((cell.lowerColour == null) || (cell.lowerColour.getAlpha() < 112)) ? null : cell.lowerColour;
			    Color fore = ((cell.upperColour == null) || (cell.upperColour.getAlpha() < 112)) ? null : cell.upperColour;
			    row[i] = new Pony.Cell(cell.character, back, fore, cell.format);
			}
	        }
	if (this.left >= 0)
	{
	    int cur = 0;
	    outer:
	        for (int n = matrix[0].length; cur < n; cur++)
		    for (int j = 0, m = matrix.length; j < m; j++)
		    {
			boolean cellpass = true;
			Pony.Cell cell = matrix[j][cur];
			if (cell != null)
			    if ((cell.character != ' ') || (cell.lowerColour != null))
				if ((cell.character != Pony.Cell.PIXELS) || (cell.lowerColour != null) || (cell.upperColour != null))
				    cellpass = false;
			if (cellpass == false)
			{   Pony.Meta[] meta = metamatrix[j][cur];
			    if ((meta != null) && (meta.length != 0))
			    {	for (int k = 0, l = meta.length; k < l; k++)
				    if ((meta[k] != null) && ((meta[k] instanceof Pony.Store) == false))
					break outer;
			    }
			    else
				break outer;
			}
		    }
	    this.left -= cur;
	    if (this.left < 0)
		{
		    int w = matrix[0].length;
		    for (int j = 0, n = matrix.length; j < n; j++)
		    {	System.arraycopy(matrix[j], 0, matrix[j] = new Pony.Cell[w - this.left], -this.left, w);
			System.arraycopy(metamatrix[j], 0, metamatrix[j] = new Pony.Meta[w + 1 - this.left][], -this.left, w + 1);
		    }
		    this.left = 0;
		}
	}
	else
	    this.left = 0;
	if (this.right >= 0)
	{
	    int cur = 0;
	    outer:
	        for (int n = matrix[0].length - 1; cur <= n; cur++)
		    for (int j = 0, m = matrix.length; j < m; j++)
		    {
			boolean cellpass = true;
			Pony.Cell cell = matrix[j][n - cur];
			if (cell != null)
			    if ((cell.character != ' ') || (cell.lowerColour != null))
				if ((cell.character != Pony.Cell.PIXELS) || (cell.lowerColour != null) || (cell.upperColour != null))
				    cellpass = false;
			if (cellpass == false)
			{   Pony.Meta[] meta = metamatrix[j][n - cur];
			    if ((meta != null) && (meta.length != 0))
			    {	for (int k = 0, l = meta.length; k < l; k++)
				    if ((meta[k] != null) && ((meta[k] instanceof Pony.Store) == false))
					break outer;
			    }
			    else
				break outer;
			}
		    }
	    this.right -= cur;
	    if (this.right < 0)
		{
		    int w = matrix[0].length;
		    for (int j = 0, n = matrix.length; j < n; j++)
		    {	System.arraycopy(matrix[j], 0, matrix[j] = new Pony.Cell[w - this.right], 0, w);
			System.arraycopy(metamatrix[j], 0, metamatrix[j] = new Pony.Meta[w + 1 - this.right][], 0, w + 1);
		    }
		    this.right = 0;
		}
	}
	else
	    this.right = 0;
	if (this.top >= 0)
	{
	    int cur = 0, m = matrix[0].length - this.right;
	    outer:
	        for (int n = matrix.length; cur < n; cur++)
		{   Pony.Cell[] row = matrix[cur];
		    Pony.Meta[][] metarow = metamatrix[cur];
		    for (int j = this.left; j < m; j++)
		    {
			boolean cellpass = true;
			Pony.Cell cell = row[j];
			if (cell != null)
			    if ((cell.character != ' ') || (cell.lowerColour != null))
				if ((cell.character != Pony.Cell.PIXELS) || (cell.lowerColour != null) || (cell.upperColour != null))
				    cellpass = false;
			if (cellpass == false)
			{   Pony.Meta[] meta = metarow[j];
			    if ((meta != null) && (meta.length != 0))
			    {	for (int k = 0, l = meta.length; k < l; k++)
				    if ((meta[k] != null) && ((meta[k] instanceof Pony.Store) == false))
					break outer;
			    }
			    else
				break outer;
			}
		}   }
	    this.top -= cur;
	    if (this.top < 0)
		{
		    int w = matrix[0].length;
		    System.arraycopy(matrix, 0, matrix = new Pony.Cell[matrix.length - this.top][], -this.top, matrix.length);
		    System.arraycopy(new Pony.Cell[-this.top][w], 0, matrix, 0, -this.top);
		    System.arraycopy(metamatrix, 0, metamatrix = new Pony.Meta[metamatrix.length - this.top][][], -this.top, metamatrix.length);
		    System.arraycopy(new Pony.Meta[-this.top][w + 1][], 0, metamatrix, 0, -this.top);
		    this.top = 0;
		}
	}
	else
	    this.top = 0;
	if (this.bottom >= 0)
	{
	    int cur = 0, m = matrix[0].length - this.right;
	    outer:
	        for (int n = matrix.length - 1 - this.top; cur <= n; cur++)
		{   Pony.Cell[] row = matrix[n - cur];
		    Pony.Meta[][] metarow = metamatrix[n - cur];
		    for (int j = this.left; j < m; j++)
		    {
			boolean cellpass = true;
			Pony.Cell cell = row[j];
			if (cell != null)
			    if ((cell.character != ' ') || (cell.lowerColour != null))
				if ((cell.character != Pony.Cell.PIXELS) || (cell.lowerColour != null) || (cell.upperColour != null))
				    cellpass = false;
			if (cellpass == false)
			{   Pony.Meta[] meta = metarow[j];
			    if ((meta != null) && (meta.length != 0))
			    {	for (int k = 0, l = meta.length; k < l; k++)
				    if ((meta[k] != null) && ((meta[k] instanceof Pony.Store) == false))
					break outer;
			    }
			    else
				break outer;
			}
		}   }
	    this.bottom -= cur;
	    if (this.bottom < 0)
		{
		    int h = matrix.length;
		    System.arraycopy(matrix, 0, matrix = new Pony.Cell[matrix.length - this.bottom][], 0, matrix.length);
		    System.arraycopy(new Pony.Cell[-this.bottom][matrix[0].length], 0, matrix, h, -this.bottom);
		    System.arraycopy(metamatrix, 0, metamatrix = new Pony.Meta[metamatrix.length - this.bottom][][], 0, metamatrix.length);
		    System.arraycopy(new Pony.Meta[-this.bottom][metamatrix[0].length][], 0, metamatrix, h, -this.bottom);
		    this.bottom = 0;
		}
	}
	else
	    this.bottom = 0;
	if (this.left > 0)
	{   int w = matrix[0].length;
	    for (int y = 0, h = matrix.length; y < h; y++)
	    {
		System.arraycopy(matrix[y], 0, matrix[y] = new Pony.Cell[w + this.left], this.left, w);
		System.arraycopy(metamatrix[y], 0, metamatrix[y] = new Pony.Meta[w + 1 + this.left][], this.left, w + 1);
	    }
	    this.left = 0;
	}
	else
	    this.left = -this.left;
	if (this.right > 0)
	{   int w = matrix[0].length;
	    for (int y = 0, h = matrix.length; y < h; y++)
	    {
		System.arraycopy(matrix[y], 0, matrix[y] = new Pony.Cell[w + this.right], 0, w);
		System.arraycopy(metamatrix[y], 0, metamatrix[y] = new Pony.Meta[w + 1 + this.right][], 0, w + 1);
	    }
	    this.right = 0;
	}
	else
	    this.right = -this.right;
	if (this.top > 0)
	{
	    int h = matrix.length, w = matrix[0].length;
	    Pony.Cell[][] appendix = new Pony.Cell[this.top][w];
	    System.arraycopy(matrix, 0, matrix = new Pony.Cell[h + this.top][], this.top, h);
	    System.arraycopy(appendix, 0, matrix, 0, this.top);
	    Pony.Meta[][][] metaappendix = new Pony.Meta[this.top][w + 1][];
	    System.arraycopy(metamatrix, 0, metamatrix = new Pony.Meta[h + this.top][w + 1][], this.top, h);
	    System.arraycopy(metaappendix, 0, metamatrix, 0, this.top);
	    this.top = 0;
	}
	else
	    this.top = -this.top;
	if (this.bottom > 0)
	{
	    int h = matrix.length, w = matrix[0].length;
	    Pony.Cell[][] appendix = new Pony.Cell[this.bottom][w];
	    System.arraycopy(matrix, 0, matrix = new Pony.Cell[h + this.bottom][], 0, h);
	    System.arraycopy(appendix, 0, matrix, h, this.bottom);
	    Pony.Meta[][][] metaappendix = new Pony.Meta[this.bottom][w + 1][];
	    System.arraycopy(metamatrix, 0, metamatrix = new Pony.Meta[h + this.bottom][][], 0, h);
	    System.arraycopy(metaappendix, 0, metamatrix, h, this.bottom);
	    this.bottom = 0;
	}
	else
	    this.bottom = -this.bottom;
	for (int y = 0; y < this.top; y++)
	{   Pony.Meta[][] metarow = metamatrix[y];
	    for (int x = 0, w = metarow.length; x < w; x++)
	    {   Pony.Meta[] metacell = metarow[x];
		for (int z = 0, d = metacell.length; z < d; z++)
		{   Pony.Meta metaelem;
		    if (((metaelem = metacell[z]) != null) && (metaelem instanceof Pony.Store))
			databuf.append("$" + (((Pony.Store)(metaelem)).name + "=" + ((Pony.Store)(metaelem)).value).replace("$", "\033$") + "$");
	}   }   }
	if (this.right != 0)
	{   int w = matrix[0].length, r = metamatrix[0].length - this.right;
	    Pony.Meta[] leftovers = new Pony.Meta[32];
	    for (int y = this.top, h = matrix.length - this.bottom; y < h; y++)
	    {
		int ptr = 0;
		Pony.Meta[][] metarow = metamatrix[y];
		for (int x = r; x <= w; x++)
		    if (metarow[x] != null)
			for (Pony.Meta meta : metarow[x])
			    if ((meta != null) && (meta instanceof Pony.Store))
			    {   if (ptr == leftovers.length)
				    System.arraycopy(leftovers, 0, leftovers = new Pony.Meta[ptr << 1], 0, ptr);
				leftovers[ptr++] = meta;
			    }
		if (ptr != 0)
		{   Pony.Meta[] metacell = metarow[r];
		    System.arraycopy(metacell, 0, metarow[r] = metacell = new Pony.Meta[metacell.length + ptr], 0, metacell.length - ptr);
		    System.arraycopy(leftovers, 0, metacell, metacell.length - ptr, ptr);
		}
		System.arraycopy(matrix[y], 0, matrix[y] = new Pony.Cell[w - this.right], 0, w - this.right);
		System.arraycopy(metarow, 0, metamatrix[y] = new Pony.Meta[w - this.right + 1][], 0, w - this.right + 1);
	    }
	}
	int[] endings = null;
	if (this.even == false)
	{
	    int w = matrix[0].length;
	    endings = new int[matrix.length];
	    for (int y = 0, h = matrix.length; y < h; y++)
	    {
		Pony.Cell[] row = matrix[y];
		Pony.Meta[][] metarow = metamatrix[y];
		int cur = 0;
		mid:
		    for (int n = w - 1; cur <= n; cur++)
		    {
			boolean cellpass = true;
			Pony.Cell cell = row[n - cur];
			if (cell != null)
			    if ((cell.character != ' ') || (cell.lowerColour != null))
				if ((cell.character != Pony.Cell.PIXELS) || (cell.lowerColour != null) || (cell.upperColour != null))
				    cellpass = false;
			if (cellpass == false)
			{   Pony.Meta[] meta = metarow[n - cur];
			    if ((meta != null) && (meta.length != 0))
			    {	for (int k = 0, l = meta.length; k < l; k++)
				    if ((meta[k] != null) && ((meta[k] instanceof Pony.Store) == false))
					break mid;
			    }
			    else
				break mid;
			}
		    }
		endings[y] = w - cur;
	    }
	}
	Pony.Cell defaultcell = new Pony.Cell(' ', null, null, PLAIN);
	for (int y = this.top, h = matrix.length - this.bottom; y < h; y++)
	{
	    Pony.Cell[] row = matrix[y];
	    Pony.Meta[][] metarow = metamatrix[y];
	    int ending = endings == null ? row.length : endings[y];
	    for (int x = 0, w = row.length; x <= w; x++)
	    {   Pony.Meta[] metacell = metarow[x];
		if (metacell != null)
		    for (int z = 0, d = metacell.length; z < d; z++)
		    {   Pony.Meta meta = metacell[z];
			if ((meta != null) && ((x >= this.left) || (meta instanceof Pony.Store)))
			{   Class<?> metaclass = meta.getClass();
			    if (metaclass == Pony.Store.class)
				databuf.append("$" + (((Pony.Store)meta).name + "=" + ((Pony.Store)meta).value).replace("$", "\033$") + "$");
			    else if (metaclass == Pony.Recall.class)
			    {   Pony.Recall recall = (Pony.Recall)meta;
				Color back = ((recall.backgroundColour == null) || (recall.backgroundColour.getAlpha() < 112)) ? null : recall.backgroundColour;
				Color fore = ((recall.foregroundColour == null) || (recall.foregroundColour.getAlpha() < 112)) ? null : recall.foregroundColour;
				databuf.append(applyColour(colours, background, foreground, format, background = back, foreground = fore, recall.format));
				databuf.append("$" + recall.name.replace("$", "\033$") + "$");
			    }
			    else if (metaclass == Pony.Balloon.class)
			    {   databuf.append(applyColour(colours, background, foreground, format, background = null, foreground = null, format = PLAIN));
				Pony.Balloon balloon = (Pony.Balloon)meta;
				if (balloon.left != null)
				{   int justification = balloon.minWidth != null ? balloon.justification & (Pony.Balloon.LEFT | Pony.Balloon.RIGHT) : Pony.Balloon.NONE;
				    switch (justification)
				    {	case Pony.Balloon.NONE:
					    char[] spaces = new char[balloon.left.intValue()];
					    Arrays.fill(spaces, ' ');
					    databuf.append(new String(spaces));
					    databuf.append("$balloon" + balloon.left.intValue());
					    break;
					case Pony.Balloon.LEFT:
					    databuf.append("$balloon" + balloon.left.intValue() + "l");
					    databuf.append(balloon.left.intValue() + balloon.minWidth.intValue() - 1);
					    break;
					case Pony.Balloon.RIGHT:
					    databuf.append("$balloon" + balloon.left.intValue() + "r");
					    databuf.append(balloon.left.intValue() + balloon.minWidth.intValue() - 1);
					    break;
					default:
					    databuf.append("$balloon" + balloon.left.intValue() + "c");
					    databuf.append(balloon.left.intValue() + balloon.minWidth.intValue() - 1);
					    break;
				}   }
				else if (balloon.minWidth != null)
				    databuf.append("$balloon" + balloon.minWidth.toString());
				if (balloon.minHeight != null)
				    databuf.append("," + balloon.minHeight.toString());
				databuf.append("$\n");
		    }	}   }
		if ((x != w) && (x >= this.left) && (x < ending))
		{   Pony.Cell cell = row[x];
		    if (cell == null)
			cell = defaultcell;
		    if (cell.character >= 0)
		    {   databuf.append(applyColour(colours, background, foreground, format, background = cell.lowerColour, foreground = cell.upperColour, format = cell.format));
			databuf.append(utf32to16(cell.character));
		    }
		    else if (cell.character == Pony.Cell.NNE_SSW)
		    {   databuf.append(applyColour(colours, background, foreground, format, background = null, foreground = null, format = PLAIN));
			databuf.append("$\\$");
		    }
		    else if (cell.character == Pony.Cell.NNW_SSE)
		    {   databuf.append(applyColour(colours, background, foreground, format, background = null, foreground = null, format = PLAIN));
			databuf.append("$/$");
		    }
		    else if (cell.character == Pony.Cell.PIXELS)
			if (cell.lowerColour == null)
			    if (cell.upperColour == null)
			    {   databuf.append(applyColour(colours, background, foreground, format, background = null, foreground = this.spacesave ? foreground : null, format = PLAIN));
				databuf.append(' ');
			    }
			    else
			    {   databuf.append(applyColour(colours, background, foreground, format, background = null, foreground = cell.upperColour, format = PLAIN));
				databuf.append('▀');
			    }
			else
			    if (cell.upperColour == null)
			    {   databuf.append(applyColour(colours, background, foreground, format, background = cell.lowerColour, foreground = null, format = PLAIN));
				databuf.append('▀');
			    }
			    else if (cell.upperColour.equals(cell.lowerColour))
				if (this.zebra)
				{   databuf.append(applyColour(colours, background, foreground, format, background = cell.lowerColour, foreground = cell.lowerColour, format = PLAIN));
				    databuf.append('▄');
				}
				else if (this.fullblocks )
				{   databuf.append(applyColour(colours, background, foreground, format, background = this.spacesave ? background : cell.lowerColour, foreground = cell.lowerColour, format = PLAIN));
				    databuf.append('█');
				}
				else
				{   databuf.append(applyColour(colours, background, foreground, format, background = cell.lowerColour, foreground = this.spacesave ? foreground : cell.lowerColour, format = PLAIN));
				    databuf.append(' ');
				}
			    else
			    {   databuf.append(applyColour(colours, background, foreground, format, background = cell.lowerColour, foreground = cell.upperColour, format = PLAIN));
				databuf.append('▄');
			    }
		}
	    }
	    background = foreground = null;
	    format = PLAIN;
	    databuf.append("\033[0m\n");
	}
	String data = databuf.toString();
	if (this.version == VERSION_COWSAY)
	{
	    String metadata = null;
	    if (data.startsWith("$$$\n"))
	    {
		metadata = data.substring(4);
		if (metadata.startsWith("$$$\n"))
		    metadata = null;
		else
		{   metadata = metadata.substring(0, metadata.indexOf("\n$$$\n") + 5);
		    data = data.substring(data.indexOf("\n$$$\n") + 5);
		    metadata = '#' + metadata.replace("\n", "\n#");
		}
	    }
	    String eop = "\nEOP";
	    while (data.contains(eop + '\n'))
		eop += 'P';
	    data = data.replace("$/$", "/").replace("$\\$", "${thoughts}");
	    while (data.contains("$balloon"))
	    {
		int start = data.indexOf("$balloon");
		int end = data.indexOf("$", start + 8);
		data = data.substring(0, start) + data.substring(end + 1);
	    }
	    data = "$the_cow = <<" + eop + ";\n" + data;
	    data += eop + '\n';
	    if (metadata != null)
		data = metadata + data;
	    if (this.utf8 == false)
		data = data.replace("▀", "\\N{U+2580}").replace("▄", "\\N{U+2584}");
	}
	else
	{   if (this.version < VERSION_METADATA)
	    {
		if (data.startsWith("$$$\n"))
		    data = data.substring(data.indexOf("\n$$$\n") + 5);
	    }
	    if (this.version < VERSION_HORIZONTAL_JUSTIFICATION)
	    {
		databuf = new StringBuilder();
		int pos = data.indexOf("\n$$$\n");
		pos += pos < 0 ? 1 : 5;
		databuf.append(data.substring(0, pos));
		StringBuilder dollarbuf = null;
		boolean esc = false;
		for (int i = 0, n = data.length(); i < n;)
		{
		    char c = data.charAt(i++);
		    if (dollarbuf != null)
		    {
			dollarbuf.append(c);
			if (esc || (c == '\033'))
			    esc ^= true;
			else if (c == '$')
			{
			    String dollar = dollarbuf.toString();
			    dollarbuf = null;
			    if (dollar.startsWith("$balloon") == false)
				databuf.append(dollar);
			    else
			    {   databuf.append("$balloon");
				dollar = dollar.substring(8);
				if      (dollar.contains("l"))  dollar = dollar.substring(dollar.indexOf('l') + 1);
				else if (dollar.contains("r"))  dollar = dollar.substring(dollar.indexOf('r') + 1);
				else if (dollar.contains("c"))  dollar = dollar.substring(dollar.indexOf('c') + 1);
				databuf.append(dollar);
			}   }
		    }
		    else if (c == '$')
			dollarbuf = new StringBuilder("$");
		    else
			databuf.append(c);
		}
		data = databuf.toString();
	    }
	}
	if (resetpalette != null)
	    data += resetpalette.toString();
	if (this.escesc)
	    data = data.replace("\033", "\\e");
	OutputStream out = System.out;
	if (this.file != null)
	    out = new FileOutputStream(this.file);
	out.write(data.getBytes("UTF-8"));
	out.flush();
	if (out != System.out)
	    out.close();
    }

Output:
    public void exportPony(Pony pony) throws IOException
    {
	Color[] colours = new Color[256];
	boolean[] format = new boolean[9];
	Color background = null, foreground = null;
	for (int i = 0; i < 256; i++)
	{   Colour colour = new Colour(i);
	    colours[i] = new Color(colour.red, colour.green, colour.blue);
	}
	if (this.palette != null)
	    System.arraycopy(this.palette, 0, colours, 0, 16);
	StringBuilder resetpalette = null;
	if (this.tty)
	    if (this.colourful)
	    {   resetpalette = new StringBuilder();
		for (int i = 0; i < 16; i++)
		{   Colour colour = new Colour(i);
		    resetpalette.append("\033]P");
		    resetpalette.append("0123456789ABCDEF".charAt(i));
		    resetpalette.append("0123456789ABCDEF".charAt(colour.red >>> 4));
		    resetpalette.append("0123456789ABCDEF".charAt(colour.red & 15));
		    resetpalette.append("0123456789ABCDEF".charAt(colour.green >>> 4));
		    resetpalette.append("0123456789ABCDEF".charAt(colour.green & 15));
		    resetpalette.append("0123456789ABCDEF".charAt(colour.blue >>> 4));
		    resetpalette.append("0123456789ABCDEF".charAt(colour.blue & 15));
	    }   }
	    else
	    {   resetpalette = new StringBuilder();
		for (int i : new int[] { 7, 15 })
		{   Colour colour = new Colour(i);
		    resetpalette.append("\033]P");
		    resetpalette.append("0123456789ABCDEF".charAt(i));
		    resetpalette.append("0123456789ABCDEF".charAt(colour.red >>> 4));
		    resetpalette.append("0123456789ABCDEF".charAt(colour.red & 15));
		    resetpalette.append("0123456789ABCDEF".charAt(colour.green >>> 4));
		    resetpalette.append("0123456789ABCDEF".charAt(colour.green & 15));
		    resetpalette.append("0123456789ABCDEF".charAt(colour.blue >>> 4));
		    resetpalette.append("0123456789ABCDEF".charAt(colour.blue & 15));
	    }   }
	else if (this.fullcolour)
	{   resetpalette = new StringBuilder();
	    for (int i = 0; i < 16; i++)
	    {   Colour colour = new Colour(i);
		resetpalette.append("\033]4;");
		resetpalette.append(i);
		resetpalette.append(";rgb:");
		resetpalette.append("0123456789ABCDEF".charAt(colour.red >>> 4));
		resetpalette.append("0123456789ABCDEF".charAt(colour.red & 15));
		resetpalette.append('/');
		resetpalette.append("0123456789ABCDEF".charAt(colour.green >>> 4));
		resetpalette.append("0123456789ABCDEF".charAt(colour.green & 15));
		resetpalette.append('/');
		resetpalette.append("0123456789ABCDEF".charAt(colour.blue >>> 4));
		resetpalette.append("0123456789ABCDEF".charAt(colour.blue & 15));
		resetpalette.append("\033\\");
	}   }
	StringBuilder databuf = new StringBuilder();
	int curleft = 0, curright = 0, curtop = 0, curbottom = 0;
	Pony.Cell[][] matrix = pony.matrix;
	Pony.Meta[][][] metamatrix = pony.metamatrix;
	boolean[] PLAIN = new boolean[9];
	if ((pony.tags != null) || (pony.comment != null))
	    databuf.append("$$$\n");
	if (pony.tags != null)
	    for (String[] tag : pony.tags)
	    {
		databuf.append(tag[0].toUpperCase());
		databuf.append(": ");
		databuf.append(tag[1]);
		databuf.append("\n");
	    }
	if (pony.comment != null)
	{
	    if ((pony.tags != null) && (pony.tags.length != 0))
		databuf.append('\n');
	    String comment = '\n' + pony.comment.trim() + '\n';
	    while (comment.contains("\n$$$\n"))
		comment = comment.replace("\n$$$\n", "\n$$$(!)\n");
	    comment = comment.substring(1, comment.length() - 1);
	    databuf.append(comment);
	}
	if ((pony.tags != null) || (pony.comment != null))
	    databuf.append("\n$$$\n");
	if (this.ignoreballoon)
	    for (Pony.Meta[][] row : metamatrix)
		for (Pony.Meta[] cell : row)
		    if (cell != null)
			for (int i = 0, n = cell.length; i < n; i++)
			    if ((cell[i] != null) && (cell[i] instanceof Pony.Balloon))
				row[i] = null;
	if (this.ignorelink)
	    for (Pony.Cell[] row : matrix)
		for (int i = 0, n = row.length; i < n; i++)
		{   Pony.Cell cell;
		    if ((cell = row[i]) != null)
			if (this.ignorelink && ((cell.character == Pony.Cell.NNE_SSW) || (cell.character == Pony.Cell.NNW_SSE)))
			    row[i] = new Pony.Cell(' ', null, null, PLAIN);
			else
			{   Color back = ((cell.lowerColour == null) || (cell.lowerColour.getAlpha() < 112)) ? null : cell.lowerColour;
			    Color fore = ((cell.upperColour == null) || (cell.upperColour.getAlpha() < 112)) ? null : cell.upperColour;
			    row[i] = new Pony.Cell(cell.character, back, fore, cell.format);
			}
	        }
	if (this.left >= 0)
	{
	    int cur = 0;
	    outer:
	        for (int n = matrix[0].length; cur < n; cur++)
		    for (int j = 0, m = matrix.length; j < m; j++)
		    {
			boolean cellpass = true;
			Pony.Cell cell = matrix[j][cur];
			if (cell != null)
			    if ((cell.character != ' ') || (cell.lowerColour != null))
				if ((cell.character != Pony.Cell.PIXELS) || (cell.lowerColour != null) || (cell.upperColour != null))
				    cellpass = false;
			if (cellpass == false)
			{   Pony.Meta[] meta = metamatrix[j][cur];
			    if ((meta != null) && (meta.length != 0))
			    {	for (int k = 0, l = meta.length; k < l; k++)
				    if ((meta[k] != null) && ((meta[k] instanceof Pony.Store) == false))
					break outer;
			    }
			    else
				break outer;
			}
		    }
	    this.left -= cur;
	    if (this.left < 0)
		{
		    int w = matrix[0].length;
		    for (int j = 0, n = matrix.length; j < n; j++)
		    {	System.arraycopy(matrix[j], 0, matrix[j] = new Pony.Cell[w - this.left], -this.left, w);
			System.arraycopy(metamatrix[j], 0, metamatrix[j] = new Pony.Meta[w + 1 - this.left][], -this.left, w + 1);
		    }
		    this.left = 0;
		}
	}
	else
	    this.left = 0;
	if (this.right >= 0)
	{
	    int cur = 0;
	    outer:
	        for (int n = matrix[0].length - 1; cur <= n; cur++)
		    for (int j = 0, m = matrix.length; j < m; j++)
		    {
			boolean cellpass = true;
			Pony.Cell cell = matrix[j][n - cur];
			if (cell != null)
			    if ((cell.character != ' ') || (cell.lowerColour != null))
				if ((cell.character != Pony.Cell.PIXELS) || (cell.lowerColour != null) || (cell.upperColour != null))
				    cellpass = false;
			if (cellpass == false)
			{   Pony.Meta[] meta = metamatrix[j][n - cur];
			    if ((meta != null) && (meta.length != 0))
			    {	for (int k = 0, l = meta.length; k < l; k++)
				    if ((meta[k] != null) && ((meta[k] instanceof Pony.Store) == false))
					break outer;
			    }
			    else
				break outer;
			}
		    }
	    this.right -= cur;
	    if (this.right < 0)
		{
		    int w = matrix[0].length;
		    for (int j = 0, n = matrix.length; j < n; j++)
		    {	System.arraycopy(matrix[j], 0, matrix[j] = new Pony.Cell[w - this.right], 0, w);
			System.arraycopy(metamatrix[j], 0, metamatrix[j] = new Pony.Meta[w + 1 - this.right][], 0, w + 1);
		    }
		    this.right = 0;
		}
	}
	else
	    this.right = 0;
	if (this.top >= 0)
	{
	    int cur = 0, m = matrix[0].length - this.right;
	    outer:
	        for (int n = matrix.length; cur < n; cur++)
		{   Pony.Cell[] row = matrix[cur];
		    Pony.Meta[][] metarow = metamatrix[cur];
		    for (int j = this.left; j < m; j++)
		    {
			boolean cellpass = true;
			Pony.Cell cell = row[j];
			if (cell != null)
			    if ((cell.character != ' ') || (cell.lowerColour != null))
				if ((cell.character != Pony.Cell.PIXELS) || (cell.lowerColour != null) || (cell.upperColour != null))
				    cellpass = false;
			if (cellpass == false)
			{   Pony.Meta[] meta = metarow[j];
			    if ((meta != null) && (meta.length != 0))
			    {	for (int k = 0, l = meta.length; k < l; k++)
				    if ((meta[k] != null) && ((meta[k] instanceof Pony.Store) == false))
					break outer;
			    }
			    else
				break outer;
			}
		}   }
	    this.top -= cur;
	    if (this.top < 0)
		{
		    int w = matrix[0].length;
		    System.arraycopy(matrix, 0, matrix = new Pony.Cell[matrix.length - this.top][], -this.top, matrix.length);
		    System.arraycopy(new Pony.Cell[-this.top][w], 0, matrix, 0, -this.top);
		    System.arraycopy(metamatrix, 0, metamatrix = new Pony.Meta[metamatrix.length - this.top][][], -this.top, metamatrix.length);
		    System.arraycopy(new Pony.Meta[-this.top][w + 1][], 0, metamatrix, 0, -this.top);
		    this.top = 0;
		}
	}
	else
	    this.top = 0;
	if (this.bottom >= 0)
	{
	    int cur = 0, m = matrix[0].length - this.right;
	    outer:
	        for (int n = matrix.length - 1 - this.top; cur <= n; cur++)
		{   Pony.Cell[] row = matrix[n - cur];
		    Pony.Meta[][] metarow = metamatrix[n - cur];
		    for (int j = this.left; j < m; j++)
		    {
			boolean cellpass = true;
			Pony.Cell cell = row[j];
			if (cell != null)
			    if ((cell.character != ' ') || (cell.lowerColour != null))
				if ((cell.character != Pony.Cell.PIXELS) || (cell.lowerColour != null) || (cell.upperColour != null))
				    cellpass = false;
			if (cellpass == false)
			{   Pony.Meta[] meta = metarow[j];
			    if ((meta != null) && (meta.length != 0))
			    {	for (int k = 0, l = meta.length; k < l; k++)
				    if ((meta[k] != null) && ((meta[k] instanceof Pony.Store) == false))
					break outer;
			    }
			    else
				break outer;
			}
		}   }
	    this.bottom -= cur;
	    if (this.bottom < 0)
		{
		    int h = matrix.length;
		    System.arraycopy(matrix, 0, matrix = new Pony.Cell[matrix.length - this.bottom][], 0, matrix.length);
		    System.arraycopy(new Pony.Cell[-this.bottom][matrix[0].length], 0, matrix, h, -this.bottom);
		    System.arraycopy(metamatrix, 0, metamatrix = new Pony.Meta[metamatrix.length - this.bottom][][], 0, metamatrix.length);
		    System.arraycopy(new Pony.Meta[-this.bottom][metamatrix[0].length][], 0, metamatrix, h, -this.bottom);
		    this.bottom = 0;
		}
	}
	else
	    this.bottom = 0;
	if (this.left > 0)
	{   int w = matrix[0].length;
	    for (int y = 0, h = matrix.length; y < h; y++)
	    {
		System.arraycopy(matrix[y], 0, matrix[y] = new Pony.Cell[w + this.left], this.left, w);
		System.arraycopy(metamatrix[y], 0, metamatrix[y] = new Pony.Meta[w + 1 + this.left][], this.left, w + 1);
	    }
	    this.left = 0;
	}
	else
	    this.left = -this.left;
	if (this.right > 0)
	{   int w = matrix[0].length;
	    for (int y = 0, h = matrix.length; y < h; y++)
	    {
		System.arraycopy(matrix[y], 0, matrix[y] = new Pony.Cell[w + this.right], 0, w);
		System.arraycopy(metamatrix[y], 0, metamatrix[y] = new Pony.Meta[w + 1 + this.right][], 0, w + 1);
	    }
	    this.right = 0;
	}
	else
	    this.right = -this.right;
	if (this.top > 0)
	{
	    int h = matrix.length, w = matrix[0].length;
	    Pony.Cell[][] appendix = new Pony.Cell[this.top][w];
	    System.arraycopy(matrix, 0, matrix = new Pony.Cell[h + this.top][], this.top, h);
	    System.arraycopy(appendix, 0, matrix, 0, this.top);
	    Pony.Meta[][][] metaappendix = new Pony.Meta[this.top][w + 1][];
	    System.arraycopy(metamatrix, 0, metamatrix = new Pony.Meta[h + this.top][w + 1][], this.top, h);
	    System.arraycopy(metaappendix, 0, metamatrix, 0, this.top);
	    this.top = 0;
	}
	else
	    this.top = -this.top;
	if (this.bottom > 0)
	{
	    int h = matrix.length, w = matrix[0].length;
	    Pony.Cell[][] appendix = new Pony.Cell[this.bottom][w];
	    System.arraycopy(matrix, 0, matrix = new Pony.Cell[h + this.bottom][], 0, h);
	    System.arraycopy(appendix, 0, matrix, h, this.bottom);
	    Pony.Meta[][][] metaappendix = new Pony.Meta[this.bottom][w + 1][];
	    System.arraycopy(metamatrix, 0, metamatrix = new Pony.Meta[h + this.bottom][][], 0, h);
	    System.arraycopy(metaappendix, 0, metamatrix, h, this.bottom);
	    this.bottom = 0;
	}
	else
	    this.bottom = -this.bottom;
	for (int y = 0; y < this.top; y++)
	{   Pony.Meta[][] metarow = metamatrix[y];
	    for (int x = 0, w = metarow.length; x < w; x++)
	    {   Pony.Meta[] metacell = metarow[x];
		for (int z = 0, d = metacell.length; z < d; z++)
		{   Pony.Meta metaelem;
		    if (((metaelem = metacell[z]) != null) && (metaelem instanceof Pony.Store))
			databuf.append("$" + (((Pony.Store)(metaelem)).name + "=" + ((Pony.Store)(metaelem)).value).replace("$", "\033$") + "$");
	}   }   }
	if (this.right != 0)
	{   int w = matrix[0].length, r = metamatrix[0].length - this.right;
	    Pony.Meta[] leftovers = new Pony.Meta[32];
	    for (int y = this.top, h = matrix.length - this.bottom; y < h; y++)
	    {
		int ptr = 0;
		Pony.Meta[][] metarow = metamatrix[y];
		for (int x = r; x <= w; x++)
		    if (metarow[x] != null)
			for (Pony.Meta meta : metarow[x])
			    if ((meta != null) && (meta instanceof Pony.Store))
			    {   if (ptr == leftovers.length)
				    System.arraycopy(leftovers, 0, leftovers = new Pony.Meta[ptr << 1], 0, ptr);
				leftovers[ptr++] = meta;
			    }
		if (ptr != 0)
		{   Pony.Meta[] metacell = metarow[r];
		    System.arraycopy(metacell, 0, metarow[r] = metacell = new Pony.Meta[metacell.length + ptr], 0, metacell.length - ptr);
		    System.arraycopy(leftovers, 0, metacell, metacell.length - ptr, ptr);
		}
		System.arraycopy(matrix[y], 0, matrix[y] = new Pony.Cell[w - this.right], 0, w - this.right);
		System.arraycopy(metarow, 0, metamatrix[y] = new Pony.Meta[w - this.right + 1][], 0, w - this.right + 1);
	    }
	}
	int[] endings = null;
	if (this.even == false)
	{
	    int w = matrix[0].length;
	    endings = new int[matrix.length];
	    for (int y = 0, h = matrix.length; y < h; y++)
	    {
		Pony.Cell[] row = matrix[y];
		Pony.Meta[][] metarow = metamatrix[y];
		int cur = 0;
		mid:
		    for (int n = w - 1; cur <= n; cur++)
		    {
			boolean cellpass = true;
			Pony.Cell cell = row[n - cur];
			if (cell != null)
			    if ((cell.character != ' ') || (cell.lowerColour != null))
				if ((cell.character != Pony.Cell.PIXELS) || (cell.lowerColour != null) || (cell.upperColour != null))
				    cellpass = false;
			if (cellpass == false)
			{   Pony.Meta[] meta = metarow[n - cur];
			    if ((meta != null) && (meta.length != 0))
			    {	for (int k = 0, l = meta.length; k < l; k++)
				    if ((meta[k] != null) && ((meta[k] instanceof Pony.Store) == false))
					break mid;
			    }
			    else
				break mid;
			}
		    }
		endings[y] = w - cur;
	    }
	}
	Pony.Cell defaultcell = new Pony.Cell(' ', null, null, PLAIN);
	for (int y = this.top, h = matrix.length - this.bottom; y < h; y++)
	{
	    Pony.Cell[] row = matrix[y];
	    Pony.Meta[][] metarow = metamatrix[y];
	    int ending = endings == null ? row.length : endings[y];
	    for (int x = 0, w = row.length; x <= w; x++)
	    {   Pony.Meta[] metacell = metarow[x];
		if (metacell != null)
		    for (int z = 0, d = metacell.length; z < d; z++)
		    {   Pony.Meta meta = metacell[z];
			if ((meta != null) && ((x >= this.left) || (meta instanceof Pony.Store)))
			{   Class<?> metaclass = meta.getClass();
			    if (metaclass == Pony.Store.class)
				databuf.append("$" + (((Pony.Store)meta).name + "=" + ((Pony.Store)meta).value).replace("$", "\033$") + "$");
			    else if (metaclass == Pony.Recall.class)
			    {   Pony.Recall recall = (Pony.Recall)meta;
				Color back = ((recall.backgroundColour == null) || (recall.backgroundColour.getAlpha() < 112)) ? null : recall.backgroundColour;
				Color fore = ((recall.foregroundColour == null) || (recall.foregroundColour.getAlpha() < 112)) ? null : recall.foregroundColour;
				databuf.append(applyColour(colours, background, foreground, format, background = back, foreground = fore, recall.format));
				databuf.append("$" + recall.name.replace("$", "\033$") + "$");
			    }
			    else if (metaclass == Pony.Balloon.class)
			    {   databuf.append(applyColour(colours, background, foreground, format, background = null, foreground = null, format = PLAIN));
				Pony.Balloon balloon = (Pony.Balloon)meta;
				if (balloon.left != null)
				{   int justification = balloon.minWidth != null ? balloon.justification & (Pony.Balloon.LEFT | Pony.Balloon.RIGHT) : Pony.Balloon.NONE;
				    switch (justification)
				    {	case Pony.Balloon.NONE:
					    char[] spaces = new char[balloon.left.intValue()];
					    Arrays.fill(spaces, ' ');
					    databuf.append(new String(spaces));
					    databuf.append("$balloon" + balloon.left.intValue());
					    break;
					case Pony.Balloon.LEFT:
					    databuf.append("$balloon" + balloon.left.intValue() + "l");
					    databuf.append(balloon.left.intValue() + balloon.minWidth.intValue() - 1);
					    break;
					case Pony.Balloon.RIGHT:
					    databuf.append("$balloon" + balloon.left.intValue() + "r");
					    databuf.append(balloon.left.intValue() + balloon.minWidth.intValue() - 1);
					    break;
					default:
					    databuf.append("$balloon" + balloon.left.intValue() + "c");
					    databuf.append(balloon.left.intValue() + balloon.minWidth.intValue() - 1);
					    break;
				}   }
				else if (balloon.minWidth != null)
				    databuf.append("$balloon" + balloon.minWidth.toString());
				if (balloon.minHeight != null)
				    databuf.append("," + balloon.minHeight.toString());
				databuf.append("$");
		    }	}   }
		if ((x != w) && (x >= this.left) && (x < ending))
		{   Pony.Cell cell = row[x];
		    if (cell == null)
			cell = defaultcell;
		    if (cell.character >= 0)
		    {   databuf.append(applyColour(colours, background, foreground, format, background = cell.lowerColour, foreground = cell.upperColour, format = cell.format));
			databuf.append(utf32to16(cell.character));
		    }
		    else if (cell.character == Pony.Cell.NNE_SSW)
		    {   databuf.append(applyColour(colours, background, foreground, format, background = null, foreground = null, format = PLAIN));
			databuf.append("$\\$");
		    }
		    else if (cell.character == Pony.Cell.NNW_SSE)
		    {   databuf.append(applyColour(colours, background, foreground, format, background = null, foreground = null, format = PLAIN));
			databuf.append("$/$");
		    }
		    else if (cell.character == Pony.Cell.PIXELS)
			if (cell.lowerColour == null)
			    if (cell.upperColour == null)
			    {   databuf.append(applyColour(colours, background, foreground, format, background = null, foreground = this.spacesave ? foreground : null, format = PLAIN));
				databuf.append(' ');
			    }
			    else
			    {   databuf.append(applyColour(colours, background, foreground, format, background = null, foreground = cell.upperColour, format = PLAIN));
				databuf.append('▀');
			    }
			else
			    if (cell.upperColour == null)
			    {   databuf.append(applyColour(colours, background, foreground, format, background = cell.lowerColour, foreground = null, format = PLAIN));
				databuf.append('▀');
			    }
			    else if (cell.upperColour.equals(cell.lowerColour))
				if (this.zebra)
				{   databuf.append(applyColour(colours, background, foreground, format, background = cell.lowerColour, foreground = cell.lowerColour, format = PLAIN));
				    databuf.append('▄');
				}
				else if (this.fullblocks )
				{   databuf.append(applyColour(colours, background, foreground, format, background = this.spacesave ? background : cell.lowerColour, foreground = cell.lowerColour, format = PLAIN));
				    databuf.append('█');
				}
				else
				{   databuf.append(applyColour(colours, background, foreground, format, background = cell.lowerColour, foreground = this.spacesave ? foreground : cell.lowerColour, format = PLAIN));
				    databuf.append(' ');
				}
			    else
			    {   databuf.append(applyColour(colours, background, foreground, format, background = cell.lowerColour, foreground = cell.upperColour, format = PLAIN));
				databuf.append('▄');
			    }
		}
	    }
	    background = foreground = null;
	    format = PLAIN;
	    databuf.append("\033[0m\n");
	}
	String data = databuf.toString();
	if (this.version == VERSION_COWSAY)
	{
	    String metadata = null;
	    if (data.startsWith("$$$\n"))
	    {
		metadata = data.substring(4);
		if (metadata.startsWith("$$$\n"))
		    metadata = null;
		else
		{   metadata = metadata.substring(0, metadata.indexOf("\n$$$\n") + 5);
		    data = data.substring(data.indexOf("\n$$$\n") + 5);
		    metadata = '#' + metadata.replace("\n", "\n#");
		}
	    }
	    String eop = "\nEOP";
	    while (data.contains(eop + '\n'))
		eop += 'P';
	    data = data.replace("$/$", "/").replace("$\\$", "${thoughts}");
	    while (data.contains("$balloon"))
	    {
		int start = data.indexOf("$balloon");
		int end = data.indexOf("$", start + 8);
		data = data.substring(0, start) + data.substring(end + 1);
	    }
	    data = "$the_cow = <<" + eop + ";\n" + data;
	    data += eop + '\n';
	    if (metadata != null)
		data = metadata + data;
	    if (this.utf8 == false)
		data = data.replace("▀", "\\N{U+2580}").replace("▄", "\\N{U+2584}");
	}
	else
	{   if (this.version < VERSION_METADATA)
	    {
		if (data.startsWith("$$$\n"))
		    data = data.substring(data.indexOf("\n$$$\n") + 5);
	    }
	    if (this.version < VERSION_HORIZONTAL_JUSTIFICATION)
	    {
		databuf = new StringBuilder();
		int pos = data.indexOf("\n$$$\n");
		pos += pos < 0 ? 1 : 5;
		databuf.append(data.substring(0, pos));
		StringBuilder dollarbuf = null;
		boolean esc = false;
		for (int i = 0, n = data.length(); i < n;)
		{
		    char c = data.charAt(i++);
		    if (dollarbuf != null)
		    {
			dollarbuf.append(c);
			if (esc || (c == '\033'))
			    esc ^= true;
			else if (c == '$')
			{
			    String dollar = dollarbuf.toString();
			    dollarbuf = null;
			    if (dollar.startsWith("$balloon") == false)
				databuf.append(dollar);
			    else
			    {   databuf.append("$balloon");
				dollar = dollar.substring(8);
				if      (dollar.contains("l"))  dollar = dollar.substring(dollar.indexOf('l') + 1);
				else if (dollar.contains("r"))  dollar = dollar.substring(dollar.indexOf('r') + 1);
				else if (dollar.contains("c"))  dollar = dollar.substring(dollar.indexOf('c') + 1);
				databuf.append(dollar);
			}   }
		    }
		    else if (c == '$')
			dollarbuf = new StringBuilder("$");
		    else
			databuf.append(c);
		}
		data = databuf.toString();
	    }
	}
	if (resetpalette != null)
	    data += resetpalette.toString();
	if (this.escesc)
	    data = data.replace("\033", "\\e");
	OutputStream out = System.out;
	if (this.file != null)
	    out = new FileOutputStream(this.file);
	out.write(data.getBytes("UTF-8"));
	out.flush();
	if (out != System.out)
	    out.close();
    }


Input:
    public Element processTag(Element ele, Attributes attrs)
    {
        String typeAttr = attrs.getValue("type");
        if ("variant".equals(typeAttr))
        {
            Element seg = OSISUtil.factory().createSeg();
            seg.setAttribute(OSISUtil.OSIS_ATTR_TYPE, OSISUtil.VARIANT_TYPE);
            String classAttr = attrs.getValue("class");
            if (classAttr != null)
            {
                seg.setAttribute(OSISUtil.OSIS_ATTR_SUBTYPE, OSISUtil.VARIANT_CLASS + classAttr);
            }
            if (ele != null)
            {
                ele.addContent(seg);
            }
            return seg;
        }
        Element div = OSISUtil.factory().createDiv();
        if (ele != null)
        {
            ele.addContent(div);
        }
        return div;
    }

Output:
    public Element processTag(Element ele, Attributes attrs)
    {
        String typeAttr = attrs.getValue("type");
        if ("variant".equals(typeAttr))
        {
            Element seg = OSISUtil.factory().createSeg();
            seg.setAttribute(OSISUtil.OSIS_ATTR_TYPE, OSISUtil.VARIANT_TYPE);
            String classAttr = attrs.getValue("class");
            if (classAttr != null)
            {
                seg.setAttribute(OSISUtil.OSIS_ATTR_SUBTYPE, OSISUtil.VARIANT_CLASS + '-' + classAttr);
            }
            if (ele != null)
            {
                ele.addContent(seg);
            }
            return seg;
        }
        Element div = OSISUtil.factory().createDiv();
        if (ele != null)
        {
            ele.addContent(div);
        }
        return div;
    }


Input:
  public void configure(final IOCProcessingContext context, final InjectorFactory injectorFactory,
                        final IOCProcessorFactory procFactory) {
    context.addSingletonScopeAnnotation(ApplicationScoped.class);
    procFactory.registerHandler(Produces.class, new JSR330AnnotationHandler<Produces>() {
      @Override
      public Set<SortUnit> checkDependencies(DependencyControl control, final InjectableInstance instance, Produces annotation,
                                             final IOCProcessingContext context) {
        switch (instance.getTaskType()) {
          case Type:
            break;
          case PrivateField:
          case PrivateMethod:
            instance.ensureMemberExposed(PrivateAccessType.Write);
        }
        injectorFactory.addInjector(new Injector() {
          {
            super.qualifyingMetadata = JSR299QualifyingMetadata.createFromAnnotations(instance.getQualifiers());
            this.provider = true;
            this.enclosingType = instance.getEnclosingType();
            if (injectorFactory.getInjectionContext().isInjectorRegistered(enclosingType, qualifyingMetadata)) {
              setInjected(true);
            }
            else {
              context.registerTypeDiscoveryListener(new TypeDiscoveryListener() {
                @Override
                public void onDiscovery(IOCProcessingContext context, InjectionPoint injectionPoint) {
                  if (injectionPoint.getEnclosingType().equals(enclosingType)) {
                    setInjected(true);
                  }
                }
              });
            }
          }
          @Override
          public Statement instantiateOnly(InjectionContext injectContext, InjectableInstance injectableInstance) {
            return instance.getValueStatement();
          }
          @Override
          public Statement getType(InjectionContext injectContext, InjectableInstance injectableInstance) {
            return instance.getValueStatement();
          }
          @Override
          public boolean isSingleton() {
            return false;
          }
          @Override
          public boolean isPseudo() {
            return false;
          }
          @Override
          public String getVarName() {
            return null;
          }
          @Override
          public MetaClass getInjectedType() {
            switch (instance.getTaskType()) {
              case StaticMethod:
              case PrivateMethod:
              case Method:
                return instance.getMethod().getReturnType();
              case PrivateField:
              case Field:
                return instance.getField().getType();
              default:
                return null;
            }
          }
        });
        control.masqueradeAs(instance.getElementTypeOrMethodReturnType());
        return Collections.singleton(new SortUnit(instance.getEnclosingType(), true));
      }
      @Override
      public boolean handle(final InjectableInstance instance, final Produces annotation,
                            final IOCProcessingContext context) {
        return true;
      }
    }, Rule.before(EntryPoint.class, ApplicationScoped.class, Singleton.class));
    procFactory.registerHandler(ApplicationScoped.class, new JSR330AnnotationHandler<ApplicationScoped>() {
      public boolean handle(InjectableInstance instance, ApplicationScoped annotation, IOCProcessingContext context) {
        InjectionContext injectionContext = injectorFactory.getInjectionContext();
        TypeInjector i = (TypeInjector) instance.getInjector();
        i.setSingleton(true);
        i.getType(injectionContext, null);
        return true;
      }
    });
    procFactory.registerHandler(Dependent.class, new JSR330AnnotationHandler<Dependent>() {
      public boolean handle(InjectableInstance instance, Dependent annotation, IOCProcessingContext context) {
        InjectionContext injectionContext = injectorFactory.getInjectionContext();
        TypeInjector i = (TypeInjector) instance.getInjector();
        i.getType(injectionContext, null);
        return true;
      }
    });
    if (context.getGeneratorContext() != null && context.getGeneratorContext().getTypeOracle() != null) {
      for (JPackage pkg : context.getGeneratorContext().getTypeOracle().getPackages()) {
        TypeScan:
        for (JClassType type : pkg.getTypes()) {
          if (type.isAbstract() || type.isInterface() != null
                  || type.getQualifiedSourceName().startsWith("java.")) continue;
          if (!type.isDefaultInstantiable()) {
            boolean hasInjectableConstructor = false;
            for (JConstructor c : type.getConstructors()) {
              if (c.isAnnotationPresent(Inject.class)) {
                hasInjectableConstructor = true;
                break;
              }
            }
            if (!hasInjectableConstructor) {
              continue;
            }
          }
          for (Annotation a : type.getAnnotations()) {
            Class<? extends Annotation> annoClass = a.annotationType();
            if (annoClass.isAnnotationPresent(Scope.class)
                    || annoClass.isAnnotationPresent(NormalScope.class)) {
              continue TypeScan;
            }
          }
          MetaClass metaClass = GWTClass.newInstance(type.getOracle(), type);
          if (injectorFactory.hasType(metaClass)) {
            continue;
          }
          injectorFactory.addPsuedoScopeForType(metaClass);
        }
      }
    }
  }

Output:
  public void configure(final IOCProcessingContext context, final InjectorFactory injectorFactory,
                        final IOCProcessorFactory procFactory) {
    context.addSingletonScopeAnnotation(ApplicationScoped.class);
    procFactory.registerHandler(Produces.class, new JSR330AnnotationHandler<Produces>() {
      @Override
      public Set<SortUnit> checkDependencies(DependencyControl control, final InjectableInstance instance, Produces annotation,
                                             final IOCProcessingContext context) {
        switch (instance.getTaskType()) {
          case Type:
            break;
          case PrivateField:
          case PrivateMethod:
            instance.ensureMemberExposed(PrivateAccessType.Read);
        }
        injectorFactory.addInjector(new Injector() {
          {
            super.qualifyingMetadata = JSR299QualifyingMetadata.createFromAnnotations(instance.getQualifiers());
            this.provider = true;
            this.enclosingType = instance.getEnclosingType();
            if (injectorFactory.getInjectionContext().isInjectorRegistered(enclosingType, qualifyingMetadata)) {
              setInjected(true);
            }
            else {
              context.registerTypeDiscoveryListener(new TypeDiscoveryListener() {
                @Override
                public void onDiscovery(IOCProcessingContext context, InjectionPoint injectionPoint) {
                  if (injectionPoint.getEnclosingType().equals(enclosingType)) {
                    setInjected(true);
                  }
                }
              });
            }
          }
          @Override
          public Statement instantiateOnly(InjectionContext injectContext, InjectableInstance injectableInstance) {
            return instance.getValueStatement();
          }
          @Override
          public Statement getType(InjectionContext injectContext, InjectableInstance injectableInstance) {
            return instance.getValueStatement();
          }
          @Override
          public boolean isSingleton() {
            return false;
          }
          @Override
          public boolean isPseudo() {
            return false;
          }
          @Override
          public String getVarName() {
            return null;
          }
          @Override
          public MetaClass getInjectedType() {
            switch (instance.getTaskType()) {
              case StaticMethod:
              case PrivateMethod:
              case Method:
                return instance.getMethod().getReturnType();
              case PrivateField:
              case Field:
                return instance.getField().getType();
              default:
                return null;
            }
          }
        });
        control.masqueradeAs(instance.getElementTypeOrMethodReturnType());
        return Collections.singleton(new SortUnit(instance.getEnclosingType(), true));
      }
      @Override
      public boolean handle(final InjectableInstance instance, final Produces annotation,
                            final IOCProcessingContext context) {
        return true;
      }
    }, Rule.before(EntryPoint.class, ApplicationScoped.class, Singleton.class));
    procFactory.registerHandler(ApplicationScoped.class, new JSR330AnnotationHandler<ApplicationScoped>() {
      public boolean handle(InjectableInstance instance, ApplicationScoped annotation, IOCProcessingContext context) {
        InjectionContext injectionContext = injectorFactory.getInjectionContext();
        TypeInjector i = (TypeInjector) instance.getInjector();
        i.setSingleton(true);
        i.getType(injectionContext, null);
        return true;
      }
    });
    procFactory.registerHandler(Dependent.class, new JSR330AnnotationHandler<Dependent>() {
      public boolean handle(InjectableInstance instance, Dependent annotation, IOCProcessingContext context) {
        InjectionContext injectionContext = injectorFactory.getInjectionContext();
        TypeInjector i = (TypeInjector) instance.getInjector();
        i.getType(injectionContext, null);
        return true;
      }
    });
    if (context.getGeneratorContext() != null && context.getGeneratorContext().getTypeOracle() != null) {
      for (JPackage pkg : context.getGeneratorContext().getTypeOracle().getPackages()) {
        TypeScan:
        for (JClassType type : pkg.getTypes()) {
          if (type.isAbstract() || type.isInterface() != null
                  || type.getQualifiedSourceName().startsWith("java.")) continue;
          if (!type.isDefaultInstantiable()) {
            boolean hasInjectableConstructor = false;
            for (JConstructor c : type.getConstructors()) {
              if (c.isAnnotationPresent(Inject.class)) {
                hasInjectableConstructor = true;
                break;
              }
            }
            if (!hasInjectableConstructor) {
              continue;
            }
          }
          for (Annotation a : type.getAnnotations()) {
            Class<? extends Annotation> annoClass = a.annotationType();
            if (annoClass.isAnnotationPresent(Scope.class)
                    || annoClass.isAnnotationPresent(NormalScope.class)) {
              continue TypeScan;
            }
          }
          MetaClass metaClass = GWTClass.newInstance(type.getOracle(), type);
          if (injectorFactory.hasType(metaClass)) {
            continue;
          }
          injectorFactory.addPsuedoScopeForType(metaClass);
        }
      }
    }
  }


Input:
	public void actionPerformed(ActionEvent e) {
		if(e.getSource() == nameSort)
		{
			String temp;
			for(int i = 0; i < lists.size(); i++)
			{
				for(int j = 1; j < lists.size()-i; j++)
				{
					if(lists.get(j-1).getText().compareTo(lists.get(j).getText()) > 0)
					{
						temp = lists.get(j-1).getText();
						lists.get(j-1).setText(lists.get(j).getText());
						lists.get(j).setText(temp);
						temp = amounts.get(j-1).getText();
						amounts.get(j-1).setText(amounts.get(j).getText());
						amounts.get(j).setText(temp);
						temp = dates.get(j-1).getText();
						dates.get(j-1).setText(dates.get(j).getText());
						dates.get(j).setText(temp);
					}
				}
			}
			repaint();
		}
		if(e.getSource() == dateSort)
		{
			String temp;
			for(int i = 0; i < lists.size(); i++)
			{
				for(int j = 1; j < lists.size()-i; j++)
				{
					String first = dates.get(j-1).getText();
					String second = dates.get(j).getText();
					if(first.substring(first.length()-4).compareTo(second.substring(second.length()-4)) > 0)
					{
						Integer monthOne = new Integer(first.substring(0, first.indexOf('/')));
						Integer monthTwo = new Integer(second.substring(0, second.indexOf('/')));
						if(monthOne.compareTo(monthTwo) > 0)
						{
							int diff = monthTwo.intValue() - monthOne.intValue();
							boolean doSwitch = false;
							Integer dayOne = new Integer(first.substring(first.indexOf('/')+1, first.indexOf('/', first.indexOf('/')+1)));
							Integer dayTwo = new Integer(second.substring(second.indexOf('/')+1, second.indexOf('/', second.indexOf('/')+1)));
							if(diff > 0)
								doSwitch = true;
							else if(dayOne < dayTwo)
								doSwitch = true;
							if(doSwitch)
							{
								temp = lists.get(j-1).getText();
								lists.get(j-1).setText(lists.get(j).getText());
								lists.get(j).setText(temp);
								temp = amounts.get(j-1).getText();
								amounts.get(j-1).setText(amounts.get(j).getText());
								amounts.get(j).setText(temp);
								temp = dates.get(j-1).getText();
								dates.get(j-1).setText(dates.get(j).getText());
								dates.get(j).setText(temp);
							}
						}
					}
				}
			}
			repaint();
		}
		if(e.getSource() == amountSort)
		{
			String temp;
			for(int i = 0; i < lists.size(); i++)
			{
				for(int j = 1; j < lists.size()-i; j++)
				{
					Double d1 = new Double(amounts.get(j-1).getText().substring(1));
					Double d2 = new Double(amounts.get(j).getText().substring(1));
					if(d1.doubleValue() > d2.doubleValue())
					{
						temp = lists.get(j-1).getText();
						lists.get(j-1).setText(lists.get(j).getText());
						lists.get(j).setText(temp);
						temp = amounts.get(j-1).getText();
						amounts.get(j-1).setText(amounts.get(j).getText());
						amounts.get(j).setText(temp);
						temp = dates.get(j-1).getText();
						dates.get(j-1).setText(dates.get(j).getText());
						dates.get(j).setText(temp);
					}
				}
			}
			repaint();
		}
	}

Output:
	public void actionPerformed(ActionEvent e) {
		if(e.getSource() == nameSort)
		{
			String temp;
			for(int i = 0; i < lists.size(); i++)
			{
				for(int j = 1; j < lists.size()-i; j++)
				{
					if(lists.get(j-1).getText().compareTo(lists.get(j).getText()) > 0)
					{
						temp = lists.get(j-1).getText();
						lists.get(j-1).setText(lists.get(j).getText());
						lists.get(j).setText(temp);
						temp = amounts.get(j-1).getText();
						amounts.get(j-1).setText(amounts.get(j).getText());
						amounts.get(j).setText(temp);
						temp = dates.get(j-1).getText();
						dates.get(j-1).setText(dates.get(j).getText());
						dates.get(j).setText(temp);
					}
				}
			}
			repaint();
		}
		if(e.getSource() == dateSort)
		{
			String temp;
			for(int i = 0; i < lists.size(); i++)
			{
				for(int j = 1; j < lists.size()-i; j++)
				{
					String first = dates.get(j-1).getText();
					String second = dates.get(j).getText();
					if(first.substring(first.length()-4).compareTo(second.substring(second.length()-4)) >= 0)
					{
						Integer monthOne = new Integer(first.substring(0, first.indexOf('/')));
						Integer monthTwo = new Integer(second.substring(0, second.indexOf('/')));
						if(monthOne.compareTo(monthTwo) >= 0)
						{
							int diff = monthTwo.intValue() - monthOne.intValue();
							boolean doSwitch = false;
							Integer dayOne = new Integer(first.substring(first.indexOf('/')+1, first.indexOf('/', first.indexOf('/')+1)));
							Integer dayTwo = new Integer(second.substring(second.indexOf('/')+1, second.indexOf('/', second.indexOf('/')+1)));
							if(diff > 0)
								doSwitch = true;
							else if(dayOne < dayTwo)
								doSwitch = true;
							if(doSwitch)
							{
								temp = lists.get(j-1).getText();
								lists.get(j-1).setText(lists.get(j).getText());
								lists.get(j).setText(temp);
								temp = amounts.get(j-1).getText();
								amounts.get(j-1).setText(amounts.get(j).getText());
								amounts.get(j).setText(temp);
								temp = dates.get(j-1).getText();
								dates.get(j-1).setText(dates.get(j).getText());
								dates.get(j).setText(temp);
							}
						}
					}
				}
			}
			repaint();
		}
		if(e.getSource() == amountSort)
		{
			String temp;
			for(int i = 0; i < lists.size(); i++)
			{
				for(int j = 1; j < lists.size()-i; j++)
				{
					Double d1 = new Double(amounts.get(j-1).getText().substring(1));
					Double d2 = new Double(amounts.get(j).getText().substring(1));
					if(d1.doubleValue() > d2.doubleValue())
					{
						temp = lists.get(j-1).getText();
						lists.get(j-1).setText(lists.get(j).getText());
						lists.get(j).setText(temp);
						temp = amounts.get(j-1).getText();
						amounts.get(j-1).setText(amounts.get(j).getText());
						amounts.get(j).setText(temp);
						temp = dates.get(j-1).getText();
						dates.get(j-1).setText(dates.get(j).getText());
						dates.get(j).setText(temp);
					}
				}
			}
			repaint();
		}
	}


Input:
    public MakefileHolder createMakefileFromArtifacts( File outputDir, Set<Artifact> artifacts,
                                                              String ndkArchitecture, String defaultNDKArchitecture,
                                                              boolean useHeaderArchives )
            throws IOException, MojoExecutionException
    {
        final StringBuilder makeFile = new StringBuilder( "# Generated by Android Maven Plugin\n" );
        final List<File> includeDirectories = new ArrayList<File>();
        makeFile.append( "$(shell echo \"LOCAL_C_INCLUDES=$(LOCAL_C_INCLUDES)\" > $(" + MAKEFILE_CAPTURE_FILE + "))" );
        makeFile.append( '\n' );
        makeFile.append( "$(shell echo \"LOCAL_PATH=$(LOCAL_PATH)\" >> $(" + MAKEFILE_CAPTURE_FILE + "))" );
        makeFile.append( '\n' );
        makeFile.append( "$(shell echo \"LOCAL_MODULE_FILENAME=$(LOCAL_MODULE_FILENAME)\" >> $("
                + MAKEFILE_CAPTURE_FILE + "))" );
        makeFile.append( '\n' );
        makeFile.append( "$(shell echo \"LOCAL_MODULE=$(LOCAL_MODULE)\" >> $(" + MAKEFILE_CAPTURE_FILE + "))" );
        makeFile.append( '\n' );
        makeFile.append( "$(shell echo \"LOCAL_CFLAGS=$(LOCAL_CFLAGS)\" >> $(" + MAKEFILE_CAPTURE_FILE + "))" );
        makeFile.append( '\n' );
        if ( ! artifacts.isEmpty() )
        {
            for ( Artifact artifact : artifacts )
            {
                final String architecture = NativeHelper.extractArchitectureFromArtifact( artifact,
                        defaultNDKArchitecture );
                makeFile.append( '\n' );
                makeFile.append( "ifeq ($(TARGET_ARCH_ABI)," ).append( architecture ).append( ")\n" );
                makeFile.append( "#\n" );
                makeFile.append( "# Group ID: " );
                makeFile.append( artifact.getGroupId() );
                makeFile.append( '\n' );
                makeFile.append( "# Artifact ID: " );
                makeFile.append( artifact.getArtifactId() );
                makeFile.append( '\n' );
                makeFile.append( "# Artifact Type: " );
                makeFile.append( artifact.getType() );
                makeFile.append( '\n' );
                makeFile.append( "# Version: " );
                makeFile.append( artifact.getVersion() );
                makeFile.append( '\n' );
                makeFile.append( "include $(CLEAR_VARS)" );
                makeFile.append( '\n' );
                makeFile.append( "LOCAL_MODULE    := " );
                makeFile.append( artifact.getArtifactId() );
                makeFile.append( '\n' );
                final boolean apklibStatic = addLibraryDetails( makeFile, outputDir, artifact, ndkArchitecture );
                if ( useHeaderArchives )
                {
                    try
                    {
                        Artifact harArtifact = new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(),
                                artifact.getVersion(), artifact.getScope(), "har", artifact.getClassifier(),
                                artifact.getArtifactHandler() );
                        final Artifact resolvedHarArtifact = AetherHelper
                                .resolveArtifact( harArtifact, repoSystem, repoSession, projectRepos );
                        File includeDir = new File( System.getProperty( "java.io.tmpdir" ),
                                "android_maven_plugin_native_includes" + System.currentTimeMillis() + "_"
                                        + resolvedHarArtifact.getArtifactId() );
                        includeDir.deleteOnExit();
                        includeDirectories.add( includeDir );
                        JarHelper.unjar( new JarFile( resolvedHarArtifact.getFile() ), includeDir,
                                new JarHelper.UnjarListener()
                                {
                                    @Override
                                    public boolean include( JarEntry jarEntry )
                                    {
                                        return ! jarEntry.getName().startsWith( "META-INF" );
                                    }
                                } );
                        makeFile.append( "LOCAL_EXPORT_C_INCLUDES := " );
                        final String str = includeDir.getAbsolutePath();
                        makeFile.append( str );
                        makeFile.append( '\n' );
                        if ( log.isDebugEnabled() )
                        {
                            Collection<File> includes = FileUtils.listFiles( includeDir,
                                    TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE );
                            log.debug( "Listing LOCAL_EXPORT_C_INCLUDES for " + artifact.getId() + ": " + includes );
                        }
                    }
                    catch ( Exception e )
                    {
                        throw new MojoExecutionException(
                                "Error while resolving header archive file for: " + artifact.getArtifactId(), e );
                    }
                }
                if ( "a".equals( artifact.getType() ) || apklibStatic )
                {
                    makeFile.append( "include $(PREBUILT_STATIC_LIBRARY)\n" );
                }
                else
                {
                    makeFile.append( "include $(PREBUILT_SHARED_LIBRARY)\n" );
                }
                makeFile.append( "endif #" ).append( artifact.getClassifier() ).append( '\n' );
                makeFile.append( '\n' );
            }
        }
        return new MakefileHolder( includeDirectories, makeFile.toString() );
    }

Output:
    public MakefileHolder createMakefileFromArtifacts( File outputDir, Set<Artifact> artifacts,
                                                              String ndkArchitecture, String defaultNDKArchitecture,
                                                              boolean useHeaderArchives )
            throws IOException, MojoExecutionException
    {
        final StringBuilder makeFile = new StringBuilder( "# Generated by Android Maven Plugin\n" );
        final List<File> includeDirectories = new ArrayList<File>();
        makeFile.append( "$(shell echo \"LOCAL_C_INCLUDES=$(LOCAL_C_INCLUDES)\" > $(" + MAKEFILE_CAPTURE_FILE + "))" );
        makeFile.append( '\n' );
        makeFile.append( "$(shell echo \"LOCAL_PATH=$(LOCAL_PATH)\" >> $(" + MAKEFILE_CAPTURE_FILE + "))" );
        makeFile.append( '\n' );
        makeFile.append( "$(shell echo \"LOCAL_MODULE_FILENAME=$(LOCAL_MODULE_FILENAME)\" >> $("
                + MAKEFILE_CAPTURE_FILE + "))" );
        makeFile.append( '\n' );
        makeFile.append( "$(shell echo \"LOCAL_MODULE=$(LOCAL_MODULE)\" >> $(" + MAKEFILE_CAPTURE_FILE + "))" );
        makeFile.append( '\n' );
        makeFile.append( "$(shell echo \"LOCAL_CFLAGS=$(LOCAL_CFLAGS)\" >> $(" + MAKEFILE_CAPTURE_FILE + "))" );
        makeFile.append( '\n' );
        if ( ! artifacts.isEmpty() )
        {
            for ( Artifact artifact : artifacts )
            {
                final String architecture = NativeHelper.extractArchitectureFromArtifact( artifact,
                        defaultNDKArchitecture );
                makeFile.append( '\n' );
                makeFile.append( "ifeq ($(TARGET_ARCH_ABI)," ).append( architecture ).append( ")\n" );
                makeFile.append( "#\n" );
                makeFile.append( "# Group ID: " );
                makeFile.append( artifact.getGroupId() );
                makeFile.append( '\n' );
                makeFile.append( "# Artifact ID: " );
                makeFile.append( artifact.getArtifactId() );
                makeFile.append( '\n' );
                makeFile.append( "# Artifact Type: " );
                makeFile.append( artifact.getType() );
                makeFile.append( '\n' );
                makeFile.append( "# Version: " );
                makeFile.append( artifact.getVersion() );
                makeFile.append( '\n' );
                makeFile.append( "include $(CLEAR_VARS)" );
                makeFile.append( '\n' );
                makeFile.append( "LOCAL_MODULE    := " );
                makeFile.append( artifact.getArtifactId() );
                makeFile.append( '\n' );
                final boolean apklibStatic = addLibraryDetails( makeFile, outputDir, artifact, ndkArchitecture );
                if ( useHeaderArchives )
                {
                    try
                    {
                        Artifact harArtifact = new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(),
                                artifact.getVersion(), artifact.getScope(), "har", architecture,
                                artifact.getArtifactHandler() );
                        final Artifact resolvedHarArtifact = AetherHelper
                                .resolveArtifact( harArtifact, repoSystem, repoSession, projectRepos );
                        File includeDir = new File( System.getProperty( "java.io.tmpdir" ),
                                "android_maven_plugin_native_includes" + System.currentTimeMillis() + "_"
                                        + resolvedHarArtifact.getArtifactId() );
                        includeDir.deleteOnExit();
                        includeDirectories.add( includeDir );
                        JarHelper.unjar( new JarFile( resolvedHarArtifact.getFile() ), includeDir,
                                new JarHelper.UnjarListener()
                                {
                                    @Override
                                    public boolean include( JarEntry jarEntry )
                                    {
                                        return ! jarEntry.getName().startsWith( "META-INF" );
                                    }
                                } );
                        makeFile.append( "LOCAL_EXPORT_C_INCLUDES := " );
                        final String str = includeDir.getAbsolutePath();
                        makeFile.append( str );
                        makeFile.append( '\n' );
                        if ( log.isDebugEnabled() )
                        {
                            Collection<File> includes = FileUtils.listFiles( includeDir,
                                    TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE );
                            log.debug( "Listing LOCAL_EXPORT_C_INCLUDES for " + artifact.getId() + ": " + includes );
                        }
                    }
                    catch ( Exception e )
                    {
                        throw new MojoExecutionException(
                                "Error while resolving header archive file for: " + artifact.getArtifactId(), e );
                    }
                }
                if ( "a".equals( artifact.getType() ) || apklibStatic )
                {
                    makeFile.append( "include $(PREBUILT_STATIC_LIBRARY)\n" );
                }
                else
                {
                    makeFile.append( "include $(PREBUILT_SHARED_LIBRARY)\n" );
                }
                makeFile.append( "endif #" ).append( artifact.getClassifier() ).append( '\n' );
                makeFile.append( '\n' );
            }
        }
        return new MakefileHolder( includeDirectories, makeFile.toString() );
    }


Input:
	public PElementPropertySource(IPElement pelement) {
		this.pelement = pelement;
		IAttributeDefinition<?,?,?>[] attrDefs = pelement.getAttributeKeys();
        String[] keys = new String[attrDefs.length];
        for (int i = 0; i < attrDefs.length; i++) {
        	if (attrDefs[i].getDisplay()) {
        		keys[i] = attrDefs[i].getId();
        	}
        }
        for (int i = 0; i < keys.length; ++i) {
            addDescriptor(new PropertyDescriptor(keys[i], attrDefs[i].getName()));
        }
	}

Output:
	public PElementPropertySource(IPElement pelement) {
		this.pelement = pelement;
		IAttributeDefinition<?,?,?>[] attrDefs = pelement.getAttributeKeys();
        String[] keys = new String[attrDefs.length];
        for (int i = 0; i < attrDefs.length; i++) {
        	if (attrDefs[i].getDisplay()) {
        		keys[i] = attrDefs[i].getId();
                addDescriptor(new PropertyDescriptor(keys[i], attrDefs[i].getName()));
        	}
        }
	}


Input:
    public void initialize() {
        Player player = getCanvas().getClient().getMyPlayer();
        colonies = player.getColonies();
        Collections.sort(colonies, getCanvas().getClient().getClientOptions().getColonyComparator());
        reportPanel.setLayout(new HIGLayout(new int[] {780}, new int[] {0}));
        JTextPane textPane = new JTextPane();
        textPane.setOpaque(false);
	textPane.setEditable(false);
        StyledDocument doc = textPane.getStyledDocument();
        defineStyles(doc);
        int numberUnitTypes = FreeCol.getSpecification().numberOfUnitTypes();
        int numberGoodsTypes = FreeCol.getSpecification().numberOfGoodsTypes();
        unitCount = new int[colonies.size()][numberUnitTypes];
        canTrain = new boolean[colonies.size()][numberUnitTypes];
        surplus = new int[colonies.size()][numberGoodsTypes];
        List<GoodsType> goodsTypes = FreeCol.getSpecification().getGoodsTypeList();
        for (int index = 0; index < colonies.size(); index++) {
            Colony colony = colonies.get(index);
            for (Unit unit : colony.getUnitList()) {
                unitCount[index][unit.getType()]++;
                canTrain[index][unit.getType()] = colony.canTrain(unit.getUnitType());
            }
            for (GoodsType goodsType : goodsTypes) {
                surplus[index][goodsType.getIndex()] = colony.getProductionNetOf(goodsType);
            }
        }
        for (int index = 0; index < colonies.size(); index++) {
            Colony colony = colonies.get(index);
            try {
                StyleConstants.setComponent(doc.getStyle("button"), createColonyButton(colony, true));
                doc.insertString(doc.getLength(), " ", doc.getStyle("button"));
                doc.insertString(doc.getLength(), "\n\n", doc.getStyle("regular"));
            } catch(Exception e) {
                logger.warning(e.toString());
            }
            boolean[] expertWarning = new boolean[numberUnitTypes];
            boolean[] productionWarning = new boolean[numberGoodsTypes];
            boolean hasWarning = false;
            Iterator<WorkLocation> workLocationIterator = colony.getWorkLocationIterator();
            while (workLocationIterator.hasNext()) {
                WorkLocation workLocation = workLocationIterator.next();
                if (workLocation instanceof ColonyTile) {
                    Unit unit = ((ColonyTile) workLocation).getUnit();
                    if (unit != null) {
                        GoodsType workType = unit.getWorkType();
                        UnitType expert = FreeCol.getSpecification().getExpertForProducing(workType);
                        int expertIndex = expert.getIndex();
                        if (unitCount[index][expertIndex] == 0 && !expertWarning[expertIndex]) {
                            addExpertWarning(doc, index, workType.getName(), expert);
                            expertWarning[expertIndex] = true;
                            hasWarning = true;
                        }
                    }
                } else {
                    Building building = (Building) workLocation;
                    GoodsType goodsType = building.getGoodsOutputType();
                    UnitType expert = building.getExpertUnitType();
                    int expertIndex = expert.getIndex();
                    int goodsIndex = goodsType.getIndex();
                    if (goodsType != null) {
                        if (building.getFirstUnit() != null &&
                            !expertWarning[expertIndex] &&
                            unitCount[index][expertIndex] == 0) {
                            addExpertWarning(doc, index, goodsType.getName(), expert);
                            expertWarning[expertIndex] = true;
                            hasWarning = true;
                        }
                        if (building.getProductionNextTurn() < building.getMaximumProduction() &&
                            !productionWarning[goodsIndex]) {
                            addProductionWarning(doc, index, goodsType, building.getGoodsInputType());
                            productionWarning[goodsIndex] = true;
                            hasWarning = true;
                        }
                    }
                }
            }
            if (!hasWarning) {
                try {
                    doc.insertString(doc.getLength(), Messages.message("report.requirements.met") + "\n\n",
                                     doc.getStyle("regular"));
                } catch(Exception e) {
                    logger.warning(e.toString());
                }
            }
            reportPanel.add(textPane, higConst.rc(1, 1));
        }
        textPane.setCaretPosition(0);
    }

Output:
    public void initialize() {
        Player player = getCanvas().getClient().getMyPlayer();
        colonies = player.getColonies();
        Collections.sort(colonies, getCanvas().getClient().getClientOptions().getColonyComparator());
        reportPanel.setLayout(new HIGLayout(new int[] {780}, new int[] {0}));
        JTextPane textPane = new JTextPane();
        textPane.setOpaque(false);
        textPane.setEditable(false);
        StyledDocument doc = textPane.getStyledDocument();
        defineStyles(doc);
        int numberUnitTypes = FreeCol.getSpecification().numberOfUnitTypes();
        int numberGoodsTypes = FreeCol.getSpecification().numberOfGoodsTypes();
        unitCount = new int[colonies.size()][numberUnitTypes];
        canTrain = new boolean[colonies.size()][numberUnitTypes];
        surplus = new int[colonies.size()][numberGoodsTypes];
        List<GoodsType> goodsTypes = FreeCol.getSpecification().getGoodsTypeList();
        for (int index = 0; index < colonies.size(); index++) {
            Colony colony = colonies.get(index);
            for (Unit unit : colony.getUnitList()) {
                unitCount[index][unit.getType()]++;
                canTrain[index][unit.getType()] = colony.canTrain(unit.getUnitType());
            }
            for (GoodsType goodsType : goodsTypes) {
                surplus[index][goodsType.getIndex()] = colony.getProductionNetOf(goodsType);
            }
        }
        for (int index = 0; index < colonies.size(); index++) {
            Colony colony = colonies.get(index);
            try {
                StyleConstants.setComponent(doc.getStyle("button"), createColonyButton(colony, true));
                doc.insertString(doc.getLength(), " ", doc.getStyle("button"));
                doc.insertString(doc.getLength(), "\n\n", doc.getStyle("regular"));
            } catch(Exception e) {
                logger.warning(e.toString());
            }
            boolean[] expertWarning = new boolean[numberUnitTypes];
            boolean[] productionWarning = new boolean[numberGoodsTypes];
            boolean hasWarning = false;
            Iterator<WorkLocation> workLocationIterator = colony.getWorkLocationIterator();
            while (workLocationIterator.hasNext()) {
                WorkLocation workLocation = workLocationIterator.next();
                if (workLocation instanceof ColonyTile) {
                    Unit unit = ((ColonyTile) workLocation).getUnit();
                    if (unit != null) {
                        GoodsType workType = unit.getWorkType();
                        UnitType expert = FreeCol.getSpecification().getExpertForProducing(workType);
                        int expertIndex = expert.getIndex();
                        if (unitCount[index][expertIndex] == 0 && !expertWarning[expertIndex]) {
                            addExpertWarning(doc, index, workType.getName(), expert);
                            expertWarning[expertIndex] = true;
                            hasWarning = true;
                        }
                    }
                } else {
                    Building building = (Building) workLocation;
                    GoodsType goodsType = building.getGoodsOutputType();
                    UnitType expert = building.getExpertUnitType();
                    if (goodsType != null && expert!=null) {
                        int expertIndex = expert.getIndex();
                        if (building.getFirstUnit() != null &&
                            !expertWarning[expertIndex] &&
                            unitCount[index][expertIndex] == 0) {
                            addExpertWarning(doc, index, goodsType.getName(), expert);
                            expertWarning[expertIndex] = true;
                            hasWarning = true;
                        }
                    }
                    if (goodsType != null) {
                        int goodsIndex = goodsType.getIndex();
                        if (building.getProductionNextTurn() < building.getMaximumProduction() &&
                            !productionWarning[goodsIndex]) {
                            addProductionWarning(doc, index, goodsType, building.getGoodsInputType());
                            productionWarning[goodsIndex] = true;
                            hasWarning = true;
                        }
                    }
                }
            }
            if (!hasWarning) {
                try {
                    doc.insertString(doc.getLength(), Messages.message("report.requirements.met") + "\n\n",
                                     doc.getStyle("regular"));
                } catch(Exception e) {
                    logger.warning(e.toString());
                }
            }
            reportPanel.add(textPane, higConst.rc(1, 1));
        }
        textPane.setCaretPosition(0);
    }