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.ObjectThis 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 DoubleArrayheightsColumn heightsprivate static LoggingLOGLogging classprivate java.util.Map<T,double[]>mapDataprivate doubleratioTarget height/width ratioprivate doubletheightHeightprivate doubletwidthWidthprivate java.util.ArrayList<java.util.ArrayList<java.lang.Object>>usageMap indicating which cells are used.private DoubleArraywidthsColumn 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 booleanassertConsistent()protected doublecomputeIncreaseArea(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 objectdoublegetHeight()Get the total canvas heightdoublegetWidth()Get the total canvas widthjava.util.Set<T>keySet()The item keys contained in the map.protected voidlogSizes()Debug loggingvoidput(double w, double h, T data)Add a new recangle.doublerelativeFill()Compute the relative fill.private voidresize(double inc)protected voidsplitCol(int bestex, double bestwi)protected voidsplitRow(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
-
-