Forráskód Böngészése

automatisches scrollen im pseudocode tree hinzugefügt

Kolja Strohm 6 éve
szülő
commit
966b815a4d
1 módosított fájl, 12 hozzáadás és 0 törlés
  1. 12 0
      src/animation/PseudoCodeNode.java

+ 12 - 0
src/animation/PseudoCodeNode.java

@@ -1,5 +1,7 @@
 package animation;
 
+import java.awt.Rectangle;
+
 import javax.swing.JTree;
 import javax.swing.SwingUtilities;
 import javax.swing.tree.DefaultMutableTreeNode;
@@ -124,6 +126,16 @@ public class PseudoCodeNode extends DefaultMutableTreeNode {
         this.selected = selected;
         if( selected )
         {
+            if( tree != null ) {
+                TreePath path = new TreePath( getPath() );
+                Rectangle bounds = tree.getPathBounds(path);
+                if( bounds!= null )
+                {
+                    bounds.height = (int) (tree.getVisibleRect().height - tree.getVisibleRect().getHeight() / 2);
+                    bounds.x = 0;
+                    tree.scrollRectToVisible(bounds);
+                }
+            }
             if( controller == null || controller.getStepOption() != 1 || breakPoint )
             {
                 SwingUtilities.invokeLater( new Runnable() {