use of org.knime.base.node.mine.sota.view.interaction.SotaTreeCellLocations in project knime-core by knime.
the class SotaDrawingPane method computeTreeNodeCoordinates.
/**
* Computes the coordinates of the SotaTreeNodes and sets them, so that they
* can be reused to draw the nodes. This method only computes the
* coordinates of the trees cell level and delegates the rest of the work to
* the recursive method
* {@link #computeParentTreeNodeCoordinates(ArrayList, int)} where the
* coordinates of the cells parents and parents parents and so on is
* computed.
*/
private void computeTreeNodeCoordinates() {
int startX = 0;
int startY = m_jpHeight - PIXEL_HEIGHT;
for (int j = 0; j < m_cells.size(); j++) {
int ids = m_cells.get(j).getDataIds().size();
int x = ids * m_pixelWidth / 2;
x += startX;
// save coordinates
SotaTreeCellLocations cellLocation = m_cellLocations.get(m_cells.get(j));
cellLocation.setStartX(x);
cellLocation.setEndX(x);
cellLocation.setStartY(startY);
int heightFactor;
if (m_isHierarchicalFuzzyData && m_drawHierarchicalFuzzyData) {
// if hierarchical data is used:
// get hierarchical level of current cell
int currentHLevel = m_cells.get(j).getHierarchyLevel();
// get difference to maximal hierarchical level
int hLevelDiff = m_maxHLevel - currentHLevel;
heightFactor = m_hierarchicalMaxLevels.get(currentHLevel) - m_cells.get(j).getLevelInHierarchy();
for (int l = 1; l <= hLevelDiff; l++) {
heightFactor += m_hierarchicalMaxLevels.get(currentHLevel + l);
}
} else {
heightFactor = m_maxLevel - m_cells.get(j).getLevel();
}
cellLocation.setEndY((startY - m_clusterLineHeight) - (heightFactor * m_clusterLineHeight));
startX += ids * m_pixelWidth;
// Save the X coordinates and the related cell
addCellToCoordHash(x, m_cells.get(j));
}
computeParentTreeNodeCoordinates(m_cells, m_maxLevel);
}
Aggregations