org.jscroll.widgets
Class FramePositioning

java.lang.Object
  |
  +--org.jscroll.widgets.FramePositioning
All Implemented Interfaces:
DesktopConstants

public class FramePositioning
extends Object
implements DesktopConstants

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

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

Field Summary
 
Fields inherited from interface org.jscroll.widgets.DesktopConstants
CONTENTS_CHANGED_COLOR, MAX_FRAMES, MAXIMUM_BUTTON_WIDTH, MINIMUM_BUTTON_WIDTH, X_OFFSET, Y_OFFSET
 
Constructor Summary
FramePositioning(DesktopScrollPane desktopScrollpane)
          creates the FramePositioning object
 
Method Summary
 Point cascadeInternalFrame(JInternalFrame f)
          cascades the given internal frame based upon the current number of internal frames
 void cascadeInternalFrames()
          cycles through and cascades all internal frames
 boolean getAutoTile()
          returns the autoTile mode
 void setAutoTile(boolean autoTile)
          turns autoTile on or off
 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
 

Constructor Detail

FramePositioning

public FramePositioning(DesktopScrollPane desktopScrollpane)
creates the FramePositioning object

Parameters:
desktopScrollpane - a reference to the DesktopScrollpane object
Method Detail

setAutoTile

public void setAutoTile(boolean autoTile)
turns autoTile on or off

Parameters:
autoTile - boolean representing autoTile mode. If true, then all new frames are tiled automatically. If false, then all new frames are cascaded automatically.

getAutoTile

public boolean getAutoTile()
returns the autoTile mode

Returns:
boolean representing current autoTile mode

cascadeInternalFrames

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


cascadeInternalFrame

public Point cascadeInternalFrame(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
}
}



Copyright © 2001-2003 JScroll.org. All Rights Reserved.