Search in sources :

Example 16 with Node

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++;
    }
}
Also used : Node(org.knime.workbench.ui.layout.Graph.Node)

Example 17 with Node

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);
    }
}
Also used : Node(org.knime.workbench.ui.layout.Graph.Node)

Example 18 with Node

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]);
        }
    }
}
Also used : Node(org.knime.workbench.ui.layout.Graph.Node)

Example 19 with Node

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);
        }
    }
}
Also used : Node(org.knime.workbench.ui.layout.Graph.Node)

Example 20 with Node

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;
}
Also used : Node(org.knime.workbench.ui.layout.Graph.Node)

Aggregations

Node (org.knime.workbench.ui.layout.Graph.Node)21 Edge (org.knime.workbench.ui.layout.Graph.Edge)5 ArrayList (java.util.ArrayList)4 Graph (org.knime.workbench.ui.layout.Graph)3 HashMap (java.util.HashMap)2 Point2D (java.awt.geom.Point2D)1 Point (org.eclipse.draw2d.geometry.Point)1 ConnectionID (org.knime.core.node.workflow.ConnectionID)1 ConnectionUIInformation (org.knime.core.node.workflow.ConnectionUIInformation)1 NodeID (org.knime.core.node.workflow.NodeID)1 NodeUIInformation (org.knime.core.node.workflow.NodeUIInformation)1 ConnectionContainerUI (org.knime.core.ui.node.workflow.ConnectionContainerUI)1 NodeContainerUI (org.knime.core.ui.node.workflow.NodeContainerUI)1 SimpleLayeredLayouter (org.knime.workbench.ui.layout.layeredlayout.SimpleLayeredLayouter)1