{
if (_headers == null)
{
_headers = new String[]{};
}
Map headerStrings = new CaseInsensitiveMap();
for (String header : _headers)
{
headerStrings.put(header, null);
}
// Step 1. Sort axes from smallest to largest.
// Hypercubes look best when the smaller axes are on the inside, and the larger axes are on the outside.
List<Axis> axes = new ArrayList<Axis>(ncube.getAxes());
Collections.sort(axes, new Comparator<Axis>()
{
public int compare(Axis a1, Axis a2)
{
return a2.size() - a1.size();
}
});
// Step 2. Now find an axis that is a good candidate for the single (top) axis. This would be an axis
// with the number of columns closest to 12.
int smallestDelta = Integer.MAX_VALUE;
int candidate = -1;
int count = 0;
for (Axis axis : axes)
{
if (headerStrings.keySet().contains(axis.getName()))
{
candidate = count;
break;
}
int delta = abs(axis.size() - 12);