use of org.knime.workbench.ui.layout.Graph.Node in project knime-core by knime.
the class CrossingMinimizer method updateY.
private void updateY(final ArrayList<Node> curLayer) {
double y = 0;
for (Node n : curLayer) {
m_g.setY(n, y);
y++;
}
}
use of org.knime.workbench.ui.layout.Graph.Node in project knime-core by knime.
the class VerticalCoordinateAssigner method initNodeMaps.
/**
* initialize node maps needed for alignment and compaction phases.
*/
private void initNodeMaps() {
for (Node n : m_g.nodes()) {
m_align.put(n, n);
m_root.put(n, n);
m_sink.put(n, n);
m_shift.put(n, Double.POSITIVE_INFINITY);
m_y.put(n, Double.NaN);
}
}
use of org.knime.workbench.ui.layout.Graph.Node in project knime-core by knime.
the class VerticalCoordinateAssigner method balance.
/*
* Functions needed for fourth phase : Balancing
*/
/**
* balance coordinates obtained by the 4 different alignments.
*/
private void balance() {
// align to smallest height layout would come here
// BUT it is not needed here in my opinion.
double[] height = new double[4];
height[0] = getHeight(m_yLT);
height[1] = getHeight(m_yLB);
height[2] = getHeight(m_yRT);
height[3] = getHeight(m_yRB);
// average median
for (Node n : m_g.nodes()) {
double[] y = new double[4];
y[0] = m_yLT.get(n);
y[1] = m_yLB.get(n);
y[2] = m_yRT.get(n);
y[3] = m_yRB.get(n);
Arrays.sort(y);
if (m_balanceBranching) {
m_y.put(n, (y[1] + y[2]) / 2);
} else {
m_y.put(n, y[1]);
}
}
}
use of org.knime.workbench.ui.layout.Graph.Node in project knime-core by knime.
the class VerticalCoordinateAssigner method verticalCompaction.
/*
* Functions needed for third phase : Compaction
*/
/**
* place blocks according to longest path layering, compute coordinates from
* offsets.
*/
private void verticalCompaction() {
for (Node v : m_g.nodes()) {
if (m_root.get(v) == v) {
placeBlock(v);
}
}
for (Node v : m_g.nodes()) {
double y = m_y.get(m_root.get(v)).doubleValue();
m_y.put(v, y);
double shift = m_shift.get(m_sink.get(m_root.get(v))).doubleValue();
if (shift < Double.POSITIVE_INFINITY) {
m_y.put(v, y + shift);
}
}
}
use of org.knime.workbench.ui.layout.Graph.Node in project knime-core by knime.
the class VerticalCoordinateAssigner method getHeight.
/**
* get maximal height difference of coordinates given in y.
*
* @param y
* @return
*/
private double getHeight(final HashMap<Node, Double> y) {
double max = 0;
double min = Double.POSITIVE_INFINITY;
for (Node n : m_g.nodes()) {
max = Math.max(max, y.get(n));
min = Math.min(min, y.get(n));
}
return max - min;
}
Aggregations