Dimension computeSize(IFigure figure, boolean flushCache) {
		if (cacheWidth != -1 && cacheHeight != -1) {
			return new Dimension(cacheWidth, cacheHeight);
		}
		for (int i = 0; i < cacheIndex + 1; i++) {
			if (cache[i][0] == widthHint && cache[i][1] == heightHint) {
				cacheWidth = cache[i][2];
				cacheHeight = cache[i][3];
				return new Dimension(cacheWidth, cacheHeight);
			}
		}

		Dimension size = figure.getPreferredSize(widthHint, heightHint)
				.getCopy();
		if (widthHint != -1)
			size.width = widthHint;
		if (heightHint != -1)
			size.height = heightHint;

		if (cacheIndex < cache.length - 1)
			cacheIndex++;
		cache[cacheIndex][0] = widthHint;
		cache[cacheIndex][1] = heightHint;
		cacheWidth = cache[cacheIndex][2] = size.width;
		cacheHeight = cache[cacheIndex][3] = size.height;
		return size;
	}