Browse Source

quick fix for subgraphs

Kolja Strohm 6 years ago
parent
commit
b18a1882f6
2 changed files with 17 additions and 3 deletions
  1. 1 1
      src/main/Main.java
  2. 16 2
      src/view/NodeView.java

+ 1 - 1
src/main/Main.java

@@ -17,7 +17,7 @@ public class Main {
      * @param args the command line arguments, currently not in use
      * @param args the command line arguments, currently not in use
      */
      */
     public static void main(String[] args) {
     public static void main(String[] args) {
-        Reader r = new Reader( "papergraph.json" );
+        Reader r = new Reader( "logo.json" );
         LayeredGraphNode graph = r.readInputGraph();
         LayeredGraphNode graph = r.readInputGraph();
         SimpleNodePlacement.placeNodes( graph );
         SimpleNodePlacement.placeNodes( graph );
         new MainView( graph );
         new MainView( graph );

+ 16 - 2
src/view/NodeView.java

@@ -29,13 +29,16 @@ public class NodeView extends JPanel implements AnnimatedView, MouseListener {
     private LayeredGraphNode model;
     private LayeredGraphNode model;
     private LayoutType layout;
     private LayoutType layout;
     private JFrame mainView;
     private JFrame mainView;
+    private int originalWidth;
+    private int originalHeight;
 
 
     public NodeView( LayeredGraphNode model, LayoutType lt, JFrame mv ) {
     public NodeView( LayeredGraphNode model, LayoutType lt, JFrame mv ) {
         mainView = mv;
         mainView = mv;
         this.model = model;
         this.model = model;
         layout = lt;
         layout = lt;
-        setSize( (int)model.getWidth( layout ), (int)model.getHeight( layout ) );
         addMouseListener( this );
         addMouseListener( this );
+        originalWidth = (int)model.getWidth( lt );
+        originalHeight = (int)model.getHeight( lt );
     }
     }
 
 
     private synchronized void update()
     private synchronized void update()
@@ -98,6 +101,14 @@ public class NodeView extends JPanel implements AnnimatedView, MouseListener {
         return y;
         return y;
     }
     }
     
     
+    public int getOriginalWidth() {
+        return originalWidth;
+    }
+    
+    public int getOriginalHeight() {
+        return originalHeight;
+    }
+    
     @Override
     @Override
     public void doLayout() {
     public void doLayout() {
         double minX = Double.POSITIVE_INFINITY;
         double minX = Double.POSITIVE_INFINITY;
@@ -118,7 +129,10 @@ public class NodeView extends JPanel implements AnnimatedView, MouseListener {
                 continue;
                 continue;
             AnnimatedView view = (AnnimatedView)c;
             AnnimatedView view = (AnnimatedView)c;
             c.setLocation( getScaledX( view.getVirtualX() - (int)minX ) + x, getScaledY( view.getVirtualY() ) + y);
             c.setLocation( getScaledX( view.getVirtualX() - (int)minX ) + x, getScaledY( view.getVirtualY() ) + y);
-            c.setSize( getScaledX( view.getVirtualWidth() ), getScaledY( view.getVirtualHeight() ) );
+            if( c instanceof NodeView )
+                c.setSize( getScaledX( ((NodeView)c).getOriginalWidth() ), getScaledY( ((NodeView)c).getOriginalHeight() ) );
+            else            
+                c.setSize( getScaledX( view.getVirtualWidth() ), getScaledY( view.getVirtualHeight() ) );
             c.doLayout();
             c.doLayout();
         }
         }
     }
     }