private static int calculateLeafNodes( DisplaySentence sentence, List featureNames, String ntFeatureName, Graphics g, int inner_term_height, int graph_terminalstart) { DisplayNode tnode; String fname; String wert; FontMetrics fm = g.getFontMetrics(); int x_position = GraphConstants.treeHorizontalMargin; for (int i = 0; i < sentence.getDisplayLeafNodeSize(); i++) { tnode = sentence.getDisplayLeafNode(i); if (tnode.isVisible()) { int maxbreite = 0; if (tnode instanceof NT_Node) { // Sonderbehandlung der implodierten Knoten if (tnode instanceof DisplayNT_Node) { maxbreite = fm.stringWidth(tnode.getNode().getFeature(ntFeatureName)); } } else { int fcount = 0; int breite; for (int j = 0; j < featureNames.size(); j++) { fname = (String) featureNames.get(j); wert = tnode.getNode().getFeature(fname); if (wert == null) { wert = ""; } Font leafFont = UtilitiesCollection.chooseFont(GraphConstants.leafFont, wert); g.setFont(leafFont); fm = g.getFontMetrics(leafFont); fcount++; if (fcount <= GraphConstants.treeTerminalFeatures) { breite = fm.stringWidth(wert); if (maxbreite < breite) { maxbreite = breite; } } } // for } int preferred = maxbreite; if (preferred > GraphConstants.leafMaxWidth) { preferred = GraphConstants.leafMaxWidth; } if (preferred < GraphConstants.leafMinWidth) { preferred = GraphConstants.leafMinWidth; } tnode.setLeftX(x_position); tnode.setX(x_position + (preferred / 2)); addLockedPosition(tnode.getX()); tnode.setWidth(preferred); if (tnode instanceof DisplayNT_Node) { tnode.setHeight(GraphConstants.nodeHeight); } else { tnode.setHeight(inner_term_height); } x_position += (preferred + GraphConstants.leafGapX); tnode.setY(graph_terminalstart); } } // T-Nodes x_position += (-GraphConstants.leafGapX + GraphConstants.treeHorizontalMargin); return x_position; }