net.sourceforge.olduvai.accordiondrawer
Class InteractionBox

java.lang.Object
  extended by net.sourceforge.olduvai.accordiondrawer.InteractionBox

public class InteractionBox
extends java.lang.Object

Draw and cache information about an onscreen rubberband box. Because we need to draw exactly this box again to erase it in XOR mode, we must cache the corner points instead of looking them up dynamically.

Author:
Tamara Munzner
See Also:
GridCell

Field Summary
private  java.awt.Color col
          Outline color of interaction box
private  AccordionDrawer d
          The drawer for this interaction box.
 int[] dragEnd
          Store where the interaction box drag ends in the interaction box
 int[] dragStart
          Store where the interaction box drag starts in the interaction box
 CellGeom item
          The item that is contained in the interaction box, if applicable
private  float linewidth
          Width of lines used to draw an interaction box
private  SplitLine[] maxLine
          Bounding box max lines, later assigned to either stuckLines or moveLines after drag starts.
private  SplitLine[] minLine
          Bounding box min lines, later assigned to either stuckLines or moveLines after drag starts.
 SplitLine[] moveLines
          Moving split lines set when starting drag
 int[] oldDragEnd
          Store where the previous interaction box drag ended in the interaction box
 int[] originalMovePixelPosition
          Store where the interaction box drag starts/ends in the interaction box
private  float plane
          Drawing plane for the interaction box
 SplitLine[] stuckLines
          Stuck split lines when starting drag
private static int X
          Redeclare X locally
private static int Y
          Redeclare Y locally
 
Constructor Summary
InteractionBox(SplitLine[] minSplit, SplitLine[] maxSplit, CellGeom item, AccordionDrawer d)
          Creates an interaction box with the given split lines, data object, and drawer
 
Method Summary
 void draw(java.awt.Color col, float linewidth, float plane)
          Set the color, plane height and line width, then draw the rubber band (interaction box outer ring) with those properties.
 void drawRubberband()
          Rendering function for interaction boxes.
 int getMax(int xy)
          Returns the pixel-position of the maximum split line in the given dimension.
 double getMaxAbs(int xy)
          Get the screen space position of the maximum split line for a given dimension.
 int getMaxIndex(int xy)
          Return the index of the maximum split line for a given dimension.
 SplitLine getMaxLine(int xy)
          Get the actual maximum split line for a given dimension.
 int getMin(int xy)
          Returns the pixel-position of the minimum split line in the given dimension.
 double getMinAbs(int xy)
          Get the screen space position of the minimum split line for a given dimension.
 int getMinIndex(int xy)
          Return the index of the minimum split line for a given dimension.
 SplitLine getMinLine(int xy)
          Get the actual minimum split line for a given dimension.
private  boolean isMinLineMoving(int dragPosition, int xy)
          Determines if dragPosition (the starting drag value) is closer to min or max.
 void setDragPoints(int[] dragStart, int[] dragEnd)
          Sets the start and end drag point variables.
 java.lang.String toString()
          Return the string representation of this interaction box.
 void undraw()
          Similar to draw(Color, float, float), but only draw the rubber band with drawRubberband() and the same set parameters, to undraw the previous interaction box.
 void updateDrag(int[] dragEnd)
          Updates oldDragEnd with the previous value of dragEnd, and dragEnd with the new value passed in.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

X

private static final int X
Redeclare X locally

See Also:
Constant Field Values

Y

private static final int Y
Redeclare Y locally

See Also:
Constant Field Values

linewidth

private float linewidth
Width of lines used to draw an interaction box


col

private java.awt.Color col
Outline color of interaction box


plane

private float plane
Drawing plane for the interaction box


dragStart

public int[] dragStart
Store where the interaction box drag starts in the interaction box


dragEnd

public int[] dragEnd
Store where the interaction box drag ends in the interaction box


oldDragEnd

public int[] oldDragEnd
Store where the previous interaction box drag ended in the interaction box


originalMovePixelPosition

public int[] originalMovePixelPosition
Store where the interaction box drag starts/ends in the interaction box


stuckLines

public SplitLine[] stuckLines
Stuck split lines when starting drag


moveLines

public SplitLine[] moveLines
Moving split lines set when starting drag


minLine

private SplitLine[] minLine
Bounding box min lines, later assigned to either stuckLines or moveLines after drag starts.


maxLine

private SplitLine[] maxLine
Bounding box max lines, later assigned to either stuckLines or moveLines after drag starts.


item

public CellGeom item
The item that is contained in the interaction box, if applicable


d

private AccordionDrawer d
The drawer for this interaction box.

Constructor Detail

InteractionBox

public InteractionBox(SplitLine[] minSplit,
                      SplitLine[] maxSplit,
                      CellGeom item,
                      AccordionDrawer d)
Creates an interaction box with the given split lines, data object, and drawer

Parameters:
minSplit - Minimum splits in X and Y for this box
maxSplit - Maximum splits in X and Y for this box
item - Item that is attached to this interaction box, not required
d - Drawer for this interaction box
Method Detail

setDragPoints

public void setDragPoints(int[] dragStart,
                          int[] dragEnd)
Sets the start and end drag point variables. This happens after an interaction box is created, on the first drag. First detect which split lines are moving and which are stuck (moveLines, stuckLines)

Parameters:
dragStart - Determines which split line is moving and which is stuck, sets starting position of current drag.
dragEnd - Updates the ending position of the current drag.

updateDrag

public void updateDrag(int[] dragEnd)
Updates oldDragEnd with the previous value of dragEnd, and dragEnd with the new value passed in. Essentially this is setDragPoints(int[], int[]) but ignoring the drag start, which happens if the start is set to something other than -1.

Parameters:
dragEnd - The new value for dragEnd

isMinLineMoving

private boolean isMinLineMoving(int dragPosition,
                                int xy)
Determines if dragPosition (the starting drag value) is closer to min or max. If closer to min, the min line is moving, otherwise the min line will be stuck.

Parameters:
dragPosition - The position of the cursor to check for proximity to the min or max box line
xy - The direction of the cursor being checked
Returns:
True when dragPosition is closer to getMin(int) than getMax(int)

draw

public void draw(java.awt.Color col,
                 float linewidth,
                 float plane)
Set the color, plane height and line width, then draw the rubber band (interaction box outer ring) with those properties.

Parameters:
col - Drawing color, XOR to the actual color (all drawRubberband() painting is XOR draw to be reversable on subsequent draws)
linewidth - Line width, in pixels
plane - Height of the drawing plane for the interaction box

undraw

public void undraw()
Similar to draw(Color, float, float), but only draw the rubber band with drawRubberband() and the same set parameters, to undraw the previous interaction box.


getMinAbs

public double getMinAbs(int xy)
Get the screen space position of the minimum split line for a given dimension.

Parameters:
xy - Either X or Y.
Returns:
The current screen position of minLine in X or Y.

getMaxAbs

public double getMaxAbs(int xy)
Get the screen space position of the maximum split line for a given dimension.

Parameters:
xy - Either X or Y.
Returns:
The current screen position of maxLine in X or Y.

getMinLine

public SplitLine getMinLine(int xy)
Get the actual minimum split line for a given dimension.

Parameters:
xy - Either X or Y.
Returns:
The minimum split line in X or Y.

getMaxLine

public SplitLine getMaxLine(int xy)
Get the actual maximum split line for a given dimension.

Parameters:
xy - Either X or Y.
Returns:
The maximum split line in X or Y.

getMinIndex

public int getMinIndex(int xy)
Return the index of the minimum split line for a given dimension.

Parameters:
xy - Either X or Y.
Returns:
The index of the minimum split line, determined by SplitAxis.getSplitIndex(SplitLine).

getMaxIndex

public int getMaxIndex(int xy)
Return the index of the maximum split line for a given dimension.

Parameters:
xy - Either X or Y.
Returns:
The index of the minimum split line, determined by SplitAxis.getSplitIndex(SplitLine).

getMin

public int getMin(int xy)
Returns the pixel-position of the minimum split line in the given dimension.

Parameters:
xy - Either X or Y.
Returns:
The screen position of the minimum split line, in pixels.

getMax

public int getMax(int xy)
Returns the pixel-position of the maximum split line in the given dimension.

Parameters:
xy - Either X or Y.
Returns:
The screen position of the maximum split line, in pixels.

drawRubberband

public void drawRubberband()
Rendering function for interaction boxes. Draw everything according to the set parameters, drawing and undrawing should return to initial dataset view. Draw a line loop with a center dot.


toString

public java.lang.String toString()
Return the string representation of this interaction box.

Overrides:
toString in class java.lang.Object
Returns:
(minX maxX minY maxY)