de.lmu.ifi.dbs.elki.visualization.gui.overview
Class RectangleArranger<T>

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.visualization.gui.overview.RectangleArranger<T>
Type Parameters:
T - Key type

public class RectangleArranger<T>
extends Object

This is a rather naive rectangle arrangement class. It will try to place rectangles on a canvas while maintaining the canvas size ratio as good as possible. It does not do an exhaustive search for optimizing the layout, but a greedy placement strategy, extending the canvas as little as possible.


Field Summary
private  ArrayList<Double> heights
          Column heights
private static Logging logger
          Logging class
private  Map<T,double[]> map
          Data
private  double ratio
          Target height/width ratio
private  double theight
          Height
private  double twidth
          Width
private  ArrayList<ArrayList<Object>> usage
          Bit sets to store usage.
private  ArrayList<Double> widths
          Column widths
 
Constructor Summary
RectangleArranger(double ratio)
          Constructor.
RectangleArranger(double width, double height)
          Constructor.
 
Method Summary
private  boolean assertConsistent()
           
protected  double computeIncreaseArea(double winc, double hinc)
           
 Set<Map.Entry<T,double[]>> entrySet()
          The items contained in the map.
 double[] get(T object)
          Get the position data of the object
 double getHeight()
          Get the total canvas height
 double getWidth()
          Get the total canvas width
 void logSizes()
           
static void main(String[] args)
          Test method.
 void put(double w, double h, T data)
          Add a new recangle.
private  void resize(double inc)
           
protected  void splitCol(int bestex, double bestwi)
           
protected  void splitRow(int bestey, double besthi)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static final Logging logger
Logging class


ratio

private double ratio
Target height/width ratio


twidth

private double twidth
Width


theight

private double theight
Height


widths

private ArrayList<Double> widths
Column widths


heights

private ArrayList<Double> heights
Column heights


usage

private ArrayList<ArrayList<Object>> usage
Bit sets to store usage. ArrayList = y, BitSet = x


map

private Map<T,double[]> map
Data

Constructor Detail

RectangleArranger

public RectangleArranger(double ratio)
Constructor.

Parameters:
ratio -

RectangleArranger

public RectangleArranger(double width,
                         double height)
Constructor.

Parameters:
width - Canvas width
height - Canvas height
Method Detail

put

public void put(double w,
                double h,
                T data)
Add a new recangle.

Parameters:
w - Width
h - Height
data - Data object to add (key)

computeIncreaseArea

protected double computeIncreaseArea(double winc,
                                     double hinc)

splitRow

protected void splitRow(int bestey,
                        double besthi)

splitCol

protected void splitCol(int bestex,
                        double bestwi)

resize

private void resize(double inc)

get

public double[] get(T object)
Get the position data of the object

Parameters:
object - Query object
Returns:
Position information: x,y,w,h

assertConsistent

private boolean assertConsistent()

logSizes

public void logSizes()

getWidth

public double getWidth()
Get the total canvas width

Returns:
Width

getHeight

public double getHeight()
Get the total canvas height

Returns:
Height

entrySet

public Set<Map.Entry<T,double[]>> entrySet()
The items contained in the map.

Returns:
entry set

main

public static void main(String[] args)
Test method.

Parameters:
args -

Release 0.4.0 (2011-09-20_1324)