Package elki.visualization.gui.overview
Class RectangleArranger<T>
- java.lang.Object
-
- elki.visualization.gui.overview.RectangleArranger<T>
-
- Type Parameters:
T
- Key type
public class RectangleArranger<T> extends java.lang.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.- Since:
- 0.4.0
- Author:
- Erich Schubert
-
-
Field Summary
Fields Modifier and Type Field Description private DoubleArray
heights
Column heightsprivate static Logging
LOG
Logging classprivate java.util.Map<T,double[]>
map
Dataprivate double
ratio
Target height/width ratioprivate double
theight
Heightprivate double
twidth
Widthprivate java.util.ArrayList<java.util.ArrayList<java.lang.Object>>
usage
Map indicating which cells are used.private DoubleArray
widths
Column widths
-
Constructor Summary
Constructors Constructor Description RectangleArranger(double ratio)
Constructor.RectangleArranger(double width, double height)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean
assertConsistent()
protected double
computeIncreaseArea(double winc, double hinc)
java.util.Set<java.util.Map.Entry<T,double[]>>
entrySet()
The items contained in the map.double[]
get(T object)
Get the position data of the objectdouble
getHeight()
Get the total canvas heightdouble
getWidth()
Get the total canvas widthjava.util.Set<T>
keySet()
The item keys contained in the map.protected void
logSizes()
Debug loggingvoid
put(double w, double h, T data)
Add a new recangle.double
relativeFill()
Compute the relative fill.private void
resize(double inc)
protected void
splitCol(int bestex, double bestwi)
protected void
splitRow(int bestey, double besthi)
-
-
-
Field Detail
-
LOG
private static final Logging LOG
Logging class
-
ratio
private double ratio
Target height/width ratio
-
twidth
private double twidth
Width
-
theight
private double theight
Height
-
widths
private DoubleArray widths
Column widths
-
heights
private DoubleArray heights
Column heights
-
usage
private java.util.ArrayList<java.util.ArrayList<java.lang.Object>> usage
Map indicating which cells are used.
-
map
private java.util.Map<T,double[]> map
Data
-
-
Method Detail
-
put
public void put(double w, double h, T data)
Add a new recangle.- Parameters:
w
- Widthh
- Heightdata
- 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
protected void logSizes()
Debug logging
-
relativeFill
public double relativeFill()
Compute the relative fill. Useful for triggering a relayout if the relative fill is not satisfactory.- Returns:
- relative fill
-
getWidth
public double getWidth()
Get the total canvas width- Returns:
- Width
-
getHeight
public double getHeight()
Get the total canvas height- Returns:
- Height
-
entrySet
public java.util.Set<java.util.Map.Entry<T,double[]>> entrySet()
The items contained in the map.- Returns:
- entry set
-
keySet
public java.util.Set<T> keySet()
The item keys contained in the map.- Returns:
- key set
-
-