@Test public void testComputeMatrixSizeForEqualAreaTiling() throws Exception { assertEquals(new Dimension(-1, -1), TileUtilities.computeMatrixSizeForEqualAreaTiling(0)); assertEquals(new Dimension(1, 1), TileUtilities.computeMatrixSizeForEqualAreaTiling(1)); assertEquals(new Dimension(2, 1), TileUtilities.computeMatrixSizeForEqualAreaTiling(2)); assertEquals(new Dimension(2, 2), TileUtilities.computeMatrixSizeForEqualAreaTiling(3)); assertEquals(new Dimension(2, 2), TileUtilities.computeMatrixSizeForEqualAreaTiling(4)); assertEquals(new Dimension(3, 2), TileUtilities.computeMatrixSizeForEqualAreaTiling(5)); assertEquals(new Dimension(3, 2), TileUtilities.computeMatrixSizeForEqualAreaTiling(6)); assertEquals(new Dimension(3, 3), TileUtilities.computeMatrixSizeForEqualAreaTiling(7)); assertEquals(new Dimension(3, 3), TileUtilities.computeMatrixSizeForEqualAreaTiling(8)); assertEquals(new Dimension(3, 3), TileUtilities.computeMatrixSizeForEqualAreaTiling(9)); assertEquals(new Dimension(4, 3), TileUtilities.computeMatrixSizeForEqualAreaTiling(10)); assertEquals(new Dimension(4, 3), TileUtilities.computeMatrixSizeForEqualAreaTiling(11)); assertEquals(new Dimension(4, 3), TileUtilities.computeMatrixSizeForEqualAreaTiling(12)); assertEquals(new Dimension(4, 4), TileUtilities.computeMatrixSizeForEqualAreaTiling(13)); assertEquals(new Dimension(4, 4), TileUtilities.computeMatrixSizeForEqualAreaTiling(14)); assertEquals(new Dimension(4, 4), TileUtilities.computeMatrixSizeForEqualAreaTiling(15)); assertEquals(new Dimension(4, 4), TileUtilities.computeMatrixSizeForEqualAreaTiling(16)); }
public static Dimension computeMatrixSizeForEqualAreaTiling(int windowCount) { double minDeltaValue = Double.POSITIVE_INFINITY; int bestRowCount = -1; int bestColCount = -1; for (int rowCount = 1; rowCount <= min(windowCount, MAX_TILE_ROW_COUNT); rowCount++) { for (int colCount = 1; colCount <= min(windowCount, MAX_TILE_COLUMN_COUNT); colCount++) { if (colCount * rowCount >= windowCount && colCount * rowCount <= 2 * windowCount) { double deltaRatio = Math.abs(1.0 - rowCount / (double) colCount); double deltaCount = Math.abs(1.0 - (colCount * rowCount) / ((double) windowCount)); double deltaValue = deltaRatio + deltaCount; if (deltaValue < minDeltaValue) { minDeltaValue = deltaValue; bestRowCount = rowCount; bestColCount = colCount; if (deltaValue == 0.0) { break; } } } } } return new Dimension(bestColCount, bestRowCount); }
TileUtilities { public static Dimension computeMatrixSizeForEqualAreaTiling(int windowCount) { double minDeltaValue = Double.POSITIVE_INFINITY; int bestRowCount = -1; int bestColCount = -1; for (int rowCount = 1; rowCount <= min(windowCount, MAX_TILE_ROW_COUNT); rowCount++) { for (int colCount = 1; colCount <= min(windowCount, MAX_TILE_COLUMN_COUNT); colCount++) { if (colCount * rowCount >= windowCount && colCount * rowCount <= 2 * windowCount) { double deltaRatio = Math.abs(1.0 - rowCount / (double) colCount); double deltaCount = Math.abs(1.0 - (colCount * rowCount) / ((double) windowCount)); double deltaValue = deltaRatio + deltaCount; if (deltaValue < minDeltaValue) { minDeltaValue = deltaValue; bestRowCount = rowCount; bestColCount = colCount; if (deltaValue == 0.0) { break; } } } } } return new Dimension(bestColCount, bestRowCount); } }
TileUtilities { public static Dimension computeMatrixSizeForEqualAreaTiling(int windowCount) { double minDeltaValue = Double.POSITIVE_INFINITY; int bestRowCount = -1; int bestColCount = -1; for (int rowCount = 1; rowCount <= min(windowCount, MAX_TILE_ROW_COUNT); rowCount++) { for (int colCount = 1; colCount <= min(windowCount, MAX_TILE_COLUMN_COUNT); colCount++) { if (colCount * rowCount >= windowCount && colCount * rowCount <= 2 * windowCount) { double deltaRatio = Math.abs(1.0 - rowCount / (double) colCount); double deltaCount = Math.abs(1.0 - (colCount * rowCount) / ((double) windowCount)); double deltaValue = deltaRatio + deltaCount; if (deltaValue < minDeltaValue) { minDeltaValue = deltaValue; bestRowCount = rowCount; bestColCount = colCount; if (deltaValue == 0.0) { break; } } } } } return new Dimension(bestColCount, bestRowCount); }  }
TileUtilities { public static Dimension computeMatrixSizeForEqualAreaTiling(int windowCount) { double minDeltaValue = Double.POSITIVE_INFINITY; int bestRowCount = -1; int bestColCount = -1; for (int rowCount = 1; rowCount <= min(windowCount, MAX_TILE_ROW_COUNT); rowCount++) { for (int colCount = 1; colCount <= min(windowCount, MAX_TILE_COLUMN_COUNT); colCount++) { if (colCount * rowCount >= windowCount && colCount * rowCount <= 2 * windowCount) { double deltaRatio = Math.abs(1.0 - rowCount / (double) colCount); double deltaCount = Math.abs(1.0 - (colCount * rowCount) / ((double) windowCount)); double deltaValue = deltaRatio + deltaCount; if (deltaValue < minDeltaValue) { minDeltaValue = deltaValue; bestRowCount = rowCount; bestColCount = colCount; if (deltaValue == 0.0) { break; } } } } } return new Dimension(bestColCount, bestRowCount); }  static boolean openInEditorMode(TopComponent topComponent, int rowIndex, int colIndex); static boolean openInMode(TopComponent topComponent, String modeName); static int countOpenEditorWindows(); static List<TopComponent> findOpenEditorWindows(); static List<TopComponent> findOpenEditorWindows(Comparator<TopComponent> comparator); static Dimension computeMatrixSizeForEqualAreaTiling(int windowCount); }
TileUtilities { public static Dimension computeMatrixSizeForEqualAreaTiling(int windowCount) { double minDeltaValue = Double.POSITIVE_INFINITY; int bestRowCount = -1; int bestColCount = -1; for (int rowCount = 1; rowCount <= min(windowCount, MAX_TILE_ROW_COUNT); rowCount++) { for (int colCount = 1; colCount <= min(windowCount, MAX_TILE_COLUMN_COUNT); colCount++) { if (colCount * rowCount >= windowCount && colCount * rowCount <= 2 * windowCount) { double deltaRatio = Math.abs(1.0 - rowCount / (double) colCount); double deltaCount = Math.abs(1.0 - (colCount * rowCount) / ((double) windowCount)); double deltaValue = deltaRatio + deltaCount; if (deltaValue < minDeltaValue) { minDeltaValue = deltaValue; bestRowCount = rowCount; bestColCount = colCount; if (deltaValue == 0.0) { break; } } } } } return new Dimension(bestColCount, bestRowCount); }  static boolean openInEditorMode(TopComponent topComponent, int rowIndex, int colIndex); static boolean openInMode(TopComponent topComponent, String modeName); static int countOpenEditorWindows(); static List<TopComponent> findOpenEditorWindows(); static List<TopComponent> findOpenEditorWindows(Comparator<TopComponent> comparator); static Dimension computeMatrixSizeForEqualAreaTiling(int windowCount); static final String EDITOR_MODE_NAME_FORMAT; static final int MAX_TILE_ROW_COUNT; static final int MAX_TILE_COLUMN_COUNT; }