timeBench.action.layout.GranularityTreeLayout Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of timebench Show documentation
Show all versions of timebench Show documentation
TimeBench, a flexible, easy-to-use, and reusable software library written in Java that provides foundational data structures and algorithms for time- oriented data in Visual Analytics.
The newest version!
package timeBench.action.layout;
import ieg.prefuse.RangeModelTransformationProvider;
import ieg.prefuse.data.LinkedTree;
import ieg.prefuse.data.LinkedTree.LinkedNode;
import java.awt.geom.Rectangle2D;
import java.util.HashMap;
import java.util.Iterator;
import prefuse.Constants;
import prefuse.action.layout.Layout;
import prefuse.data.Schema;
import prefuse.data.query.NumberRangeModel;
import prefuse.util.PrefuseLib;
import prefuse.util.ui.ValuedRangeModel;
import prefuse.visual.VisualItem;
import timeBench.calendar.Granule;
import timeBench.data.GranularityAggregationTree;
import timeBench.data.TemporalDataException;
import timeBench.data.TemporalObject;
public class GranularityTreeLayout extends Layout implements RangeModelTransformationProvider {
public static final int FITTING_FULL_AVAILABLE_SPACE = 0;
public static final int FITTING_DEPENDING_ON_POSSIBLE_VALUES = 1;
public static final String FIELD_POSITION = "_position";
public static final String FIELD_GRANULE = "_granule";
// XXX assume depth is given via size of settings
protected int depth;
// TODO consider circumstances to invalidate these min max ident. arrays
protected long[] minIdentifiers;
protected long[] maxIdentifiers;
protected boolean[] axisActive = new boolean[Constants.AXIS_COUNT];
protected NumberRangeModel[] rangeModels = new NumberRangeModel[Constants.AXIS_COUNT];
protected Rectangle2D rootBounds;
protected double minSize; //minimum size of a "pixel"
HashMap additionalVisualItemInformation; // size x,y before size stretching, half border size
GranularityTreeLayoutSettings[] settings;
LinkedTree[] labels = new LinkedTree[Constants.AXIS_COUNT];
public GranularityTreeLayout(String group,
GranularityTreeLayoutSettings[] settings, double minSize) {
super(group);
this.settings = settings;
this.minSize = minSize;
}
@Override
public void run(double frac) {
GranularityAggregationTree tree = (GranularityAggregationTree) m_vis
.getSourceData(m_group);
TemporalObject root = tree.roots().iterator().next();
LinkedNode[] labelRoots = new LinkedNode[Constants.AXIS_COUNT];
Schema s = new Schema(1);
s.addColumn(FIELD_GRANULE, Granule.class);
s.addColumn(FIELD_POSITION, double.class);
for(int i=0; i(); // reset
calculateSizes(root);
for(int i=0; i 0)
currentLabels[settings[level-1].getTargetAxis()].setDouble(FIELD_POSITION,
settings[level-1].getTargetAxis() == Constants.X_AXIS ? bounds.getCenterX() : bounds.getCenterY());
double xbase = bounds.getX() + (aviivn[Constants.AXIS_COUNT+Constants.X_AXIS])*factor;
double ybase = bounds.getY() + (aviivn[Constants.AXIS_COUNT+Constants.Y_AXIS])*factor;
if (level < depth) {
Iterator childIterator = currentLabels[settings[level].getTargetAxis()].children();
for (TemporalObject o : node.childObjects()) {
double x = xbase;
double y = ybase;
VisualItem vo = m_vis.getVisualItem(m_group, o);
double[] aviivo = additionalVisualItemInformation.get(vo.getRow());
if(settings[level].getTargetAxis() == Constants.X_AXIS)
x += (o.getTemporalElement().getGranule().getIdentifier()-minIdentifiers[level]) * aviivo[Constants.X_AXIS]*factor;
if(settings[level].getTargetAxis() == Constants.Y_AXIS)
y += (o.getTemporalElement().getGranule().getIdentifier()-minIdentifiers[level]) * aviivo[Constants.Y_AXIS]*factor;
LinkedNode[] nextLabels = new LinkedNode[Constants.AXIS_COUNT];
for(int i=0; i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy