de.uni_paderborn.fujaba.gui.mdi
Class FramePositioning

java.lang.Object
  extended byde.uni_paderborn.fujaba.gui.mdi.FramePositioning

public class FramePositioning
extends java.lang.Object

This class provides internal frame positioning methods for use by DesktopMenu.

Version:
1.0 11-Aug-2001
Author:
Tom Tessier

Field Summary
static java.awt.Color CONTENTS_CHANGED_COLOR
          the foreground color of inactive buttons whose associated frame contents have changed
static int MAX_FRAMES
          maximum number of internal frames allowed
static int MAXIMUM_BUTTON_WIDTH
          maximum width of frame toolbar buttons
static int MINIMUM_BUTTON_WIDTH
          minimum width of frame toolbar buttons
static int X_OFFSET
          default x offset of first frame in cascade mode, relative to desktop
static int Y_OFFSET
          default y offset of first frame in cascade mode, relative to desktop
 
Constructor Summary
FramePositioning(javax.swing.JDesktopPane desktop)
          creates the FramePositioning object
 
Method Summary
 java.awt.Point cascadeInternalFrame(javax.swing.JInternalFrame f)
          cascades the given internal frame based upon the current number of internal frames
 void cascadeInternalFrames()
          cycles through and cascades all internal frames
 void tileInternalFrames()
          tiles internal frames upon the desktop.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_FRAMES

public static final int MAX_FRAMES
maximum number of internal frames allowed

See Also:
Constant Field Values

X_OFFSET

public static final int X_OFFSET
default x offset of first frame in cascade mode, relative to desktop

See Also:
Constant Field Values

Y_OFFSET

public static final int Y_OFFSET
default y offset of first frame in cascade mode, relative to desktop

See Also:
Constant Field Values

MINIMUM_BUTTON_WIDTH

public static final int MINIMUM_BUTTON_WIDTH
minimum width of frame toolbar buttons

See Also:
Constant Field Values

MAXIMUM_BUTTON_WIDTH

public static final int MAXIMUM_BUTTON_WIDTH
maximum width of frame toolbar buttons

See Also:
Constant Field Values

CONTENTS_CHANGED_COLOR

public static final java.awt.Color CONTENTS_CHANGED_COLOR
the foreground color of inactive buttons whose associated frame contents have changed

Constructor Detail

FramePositioning

public FramePositioning(javax.swing.JDesktopPane desktop)
creates the FramePositioning object

Parameters:
desktop - a reference to the JDesktopPane
Method Detail

cascadeInternalFrames

public void cascadeInternalFrames()
cycles through and cascades all internal frames


cascadeInternalFrame

public java.awt.Point cascadeInternalFrame(javax.swing.JInternalFrame f)
cascades the given internal frame based upon the current number of internal frames

Parameters:
f - the internal frame to cascade
Returns:
a Point object representing the location assigned to the internal frame upon the virtual desktop

tileInternalFrames

public void tileInternalFrames()
tiles internal frames upon the desktop.

Based upon the following tiling algorithm:

- take the sqroot of the total frames rounded down, that gives the number of columns.

- divide the total frames by the # of columns to get the # of rows in each column, and any remainder is distributed amongst the remaining rows from right to left)

eg)
1 frame, remainder 0, 1 row
2 frames, remainder 0, 2 rows
3 frames, remainder 0, 3 rows
4 frames, remainder 0, 2 rows x 2 columns
5 frames, remainder 1, 2 rows in column I, 3 rows in column II
10 frames, remainder 1, 3 rows in column I, 3 rows in column II, 4 rows in column III
16 frames, 4 rows x 4 columns


Pseudocode:

while (frames) {
numCols = (int)sqrt(totalFrames);
numRows = totalFrames / numCols;
remainder = totalFrames % numCols
if ((numCols-curCol) <= remainder) {
numRows++; // add an extra row for this column
}
}