|
@@ -50,6 +50,7 @@ import graph.RandomGraphGenerator;
|
|
|
import graph.io.Reader;
|
|
|
import graph.io.Writer;
|
|
|
import lib.SweepCrossingMinimizer;
|
|
|
+import lib.TextLayoutHelper;
|
|
|
|
|
|
/**
|
|
|
* The main window of the application.
|
|
@@ -84,54 +85,43 @@ public class MainView {
|
|
|
public JTree pseudoTree;
|
|
|
private LayeredGraphNode graph;
|
|
|
|
|
|
- private String strToLen( String s, int l )
|
|
|
- {
|
|
|
- while( s.length() < l )
|
|
|
- {
|
|
|
- s = " " + s + " ";
|
|
|
- }
|
|
|
- if( s.length() > l )
|
|
|
- return s.substring( 0, l );
|
|
|
- return s;
|
|
|
- }
|
|
|
-
|
|
|
private String debugInfo()
|
|
|
{
|
|
|
String info = "Debug Information Table: \n";
|
|
|
info += "_______________________________________________________________________________________________________________________________________________________________________________________________________________________\n";
|
|
|
- info += "|" + strToLen( "Top -> Bottom :> Left", 51 ) + "| |" + strToLen( "Top -> Bottom :> Right", 51 ) + "| |" + strToLen( "Bottom -> Top :> Left", 51 ) + "| |" + strToLen( "Bottom -> Top :> Right", 51 ) + "|\n";
|
|
|
+ info += "|" + TextLayoutHelper.strToLen( "Top -> Bottom :> Left", 51 ) + "| |" + TextLayoutHelper.strToLen( "Top -> Bottom :> Right", 51 ) + "| |" + TextLayoutHelper.strToLen( "Bottom -> Top :> Left", 51 ) + "| |" + TextLayoutHelper.strToLen( "Bottom -> Top :> Right", 51 ) + "|\n";
|
|
|
info += "|___________________________________________________| |___________________________________________________| |___________________________________________________| |___________________________________________________|\n";
|
|
|
info += "| Node | Shift | Sink | Root | Align | x | xDef | | Node | Shift | Sink | Root | Align | x | xDef | | Node | Shift | Sink | Root | Align | x | xDef | | Node | Shift | Sink | Root | Align | x | xDef |\n";
|
|
|
for( LayeredGraphNode n : graph.getContainedNodes() )
|
|
|
{
|
|
|
- info += "|" + strToLen( n.getName(), 6 ) +
|
|
|
- "|" + strToLen( n.getShift( LayoutType.TOP_BOTTOM_LEFT ) + "", 7 ) +
|
|
|
- "|" + strToLen( n.getSink( LayoutType.TOP_BOTTOM_LEFT ).getName(), 6 ) +
|
|
|
- "|" + strToLen( n.getRoot( LayoutType.TOP_BOTTOM_LEFT ).getName(), 6 ) +
|
|
|
- "|" + strToLen( n.getAlign( LayoutType.TOP_BOTTOM_LEFT ).getName(), 7 ) +
|
|
|
- "|" + strToLen( n.getX( LayoutType.TOP_BOTTOM_LEFT ) + "", 5 ) +
|
|
|
- "|" + strToLen( !n.isXUndefined( LayoutType.TOP_BOTTOM_LEFT ) + "", 8 ) + "| " +
|
|
|
- "|" + strToLen( n.getName(), 6 ) +
|
|
|
- "|" + strToLen( n.getShift( LayoutType.TOP_BOTTOM_RIGHT ) + "", 7 ) +
|
|
|
- "|" + strToLen( n.getSink( LayoutType.TOP_BOTTOM_RIGHT ).getName(), 6 ) +
|
|
|
- "|" + strToLen( n.getRoot( LayoutType.TOP_BOTTOM_RIGHT ).getName(), 6 ) +
|
|
|
- "|" + strToLen( n.getAlign( LayoutType.TOP_BOTTOM_RIGHT ).getName(), 7 ) +
|
|
|
- "|" + strToLen( n.getX( LayoutType.TOP_BOTTOM_RIGHT ) + "", 5 ) +
|
|
|
- "|" + strToLen( !n.isXUndefined( LayoutType.TOP_BOTTOM_RIGHT ) + "", 8 ) + "| " +
|
|
|
- "|" + strToLen( n.getName(), 6 ) +
|
|
|
- "|" + strToLen( n.getShift( LayoutType.BOTTOM_TOP_LEFT ) + "", 7 ) +
|
|
|
- "|" + strToLen( n.getSink( LayoutType.BOTTOM_TOP_LEFT ).getName(), 6 ) +
|
|
|
- "|" + strToLen( n.getRoot( LayoutType.BOTTOM_TOP_LEFT ).getName(), 6 ) +
|
|
|
- "|" + strToLen( n.getAlign( LayoutType.BOTTOM_TOP_LEFT ).getName(), 7 ) +
|
|
|
- "|" + strToLen( n.getX( LayoutType.BOTTOM_TOP_LEFT ) + "", 5 ) +
|
|
|
- "|" + strToLen( !n.isXUndefined( LayoutType.BOTTOM_TOP_LEFT ) + "", 8 ) + "| " +
|
|
|
- "|" + strToLen( n.getName(), 6 ) +
|
|
|
- "|" + strToLen( n.getShift( LayoutType.BOTTOM_TOP_RIGHT ) + "", 7 ) +
|
|
|
- "|" + strToLen( n.getSink( LayoutType.BOTTOM_TOP_RIGHT ).getName(), 6 ) +
|
|
|
- "|" + strToLen( n.getRoot( LayoutType.BOTTOM_TOP_RIGHT ).getName(), 6 ) +
|
|
|
- "|" + strToLen( n.getAlign( LayoutType.BOTTOM_TOP_RIGHT ).getName(), 7 ) +
|
|
|
- "|" + strToLen( n.getX( LayoutType.BOTTOM_TOP_RIGHT ) + "", 5 ) +
|
|
|
- "|" + strToLen( !n.isXUndefined( LayoutType.BOTTOM_TOP_RIGHT ) + "", 8 ) + "|\n";
|
|
|
+ info += "|" + TextLayoutHelper.strToLen( n.getName(), 6 ) +
|
|
|
+ "|" + TextLayoutHelper.strToLen( n.getShift( LayoutType.TOP_BOTTOM_LEFT ) + "", 7 ) +
|
|
|
+ "|" + TextLayoutHelper.strToLen( n.getSink( LayoutType.TOP_BOTTOM_LEFT ).getName(), 6 ) +
|
|
|
+ "|" + TextLayoutHelper.strToLen( n.getRoot( LayoutType.TOP_BOTTOM_LEFT ).getName(), 6 ) +
|
|
|
+ "|" + TextLayoutHelper.strToLen( n.getAlign( LayoutType.TOP_BOTTOM_LEFT ).getName(), 7 ) +
|
|
|
+ "|" + TextLayoutHelper.strToLen( n.getX( LayoutType.TOP_BOTTOM_LEFT ) + "", 5 ) +
|
|
|
+ "|" + TextLayoutHelper.strToLen( !n.isXUndefined( LayoutType.TOP_BOTTOM_LEFT ) + "", 8 ) + "| " +
|
|
|
+ "|" + TextLayoutHelper.strToLen( n.getName(), 6 ) +
|
|
|
+ "|" + TextLayoutHelper.strToLen( n.getShift( LayoutType.TOP_BOTTOM_RIGHT ) + "", 7 ) +
|
|
|
+ "|" + TextLayoutHelper.strToLen( n.getSink( LayoutType.TOP_BOTTOM_RIGHT ).getName(), 6 ) +
|
|
|
+ "|" + TextLayoutHelper.strToLen( n.getRoot( LayoutType.TOP_BOTTOM_RIGHT ).getName(), 6 ) +
|
|
|
+ "|" + TextLayoutHelper.strToLen( n.getAlign( LayoutType.TOP_BOTTOM_RIGHT ).getName(), 7 ) +
|
|
|
+ "|" + TextLayoutHelper.strToLen( n.getX( LayoutType.TOP_BOTTOM_RIGHT ) + "", 5 ) +
|
|
|
+ "|" + TextLayoutHelper.strToLen( !n.isXUndefined( LayoutType.TOP_BOTTOM_RIGHT ) + "", 8 ) + "| " +
|
|
|
+ "|" + TextLayoutHelper.strToLen( n.getName(), 6 ) +
|
|
|
+ "|" + TextLayoutHelper.strToLen( n.getShift( LayoutType.BOTTOM_TOP_LEFT ) + "", 7 ) +
|
|
|
+ "|" + TextLayoutHelper.strToLen( n.getSink( LayoutType.BOTTOM_TOP_LEFT ).getName(), 6 ) +
|
|
|
+ "|" + TextLayoutHelper.strToLen( n.getRoot( LayoutType.BOTTOM_TOP_LEFT ).getName(), 6 ) +
|
|
|
+ "|" + TextLayoutHelper.strToLen( n.getAlign( LayoutType.BOTTOM_TOP_LEFT ).getName(), 7 ) +
|
|
|
+ "|" + TextLayoutHelper.strToLen( n.getX( LayoutType.BOTTOM_TOP_LEFT ) + "", 5 ) +
|
|
|
+ "|" + TextLayoutHelper.strToLen( !n.isXUndefined( LayoutType.BOTTOM_TOP_LEFT ) + "", 8 ) + "| " +
|
|
|
+ "|" + TextLayoutHelper.strToLen( n.getName(), 6 ) +
|
|
|
+ "|" + TextLayoutHelper.strToLen( n.getShift( LayoutType.BOTTOM_TOP_RIGHT ) + "", 7 ) +
|
|
|
+ "|" + TextLayoutHelper.strToLen( n.getSink( LayoutType.BOTTOM_TOP_RIGHT ).getName(), 6 ) +
|
|
|
+ "|" + TextLayoutHelper.strToLen( n.getRoot( LayoutType.BOTTOM_TOP_RIGHT ).getName(), 6 ) +
|
|
|
+ "|" + TextLayoutHelper.strToLen( n.getAlign( LayoutType.BOTTOM_TOP_RIGHT ).getName(), 7 ) +
|
|
|
+ "|" + TextLayoutHelper.strToLen( n.getX( LayoutType.BOTTOM_TOP_RIGHT ) + "", 5 ) +
|
|
|
+ "|" + TextLayoutHelper.strToLen( !n.isXUndefined( LayoutType.BOTTOM_TOP_RIGHT ) + "", 8 ) + "|\n";
|
|
|
}
|
|
|
info += "-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------";
|
|
|
return info;
|
|
@@ -722,6 +712,14 @@ public class MainView {
|
|
|
JScrollPane treeView = new JScrollPane( pseudoTree );
|
|
|
treeView.setBounds( 10, 110, 380, 380 );
|
|
|
|
|
|
+ JTextArea debugText = new JTextArea();
|
|
|
+ debugText.setFont( new Font( "Monospaced", Font.PLAIN, 12 ) );
|
|
|
+ debugText.setEditable( false );
|
|
|
+ debugText.setBackground( RenderHelper.BACKGROUND_COLOR );
|
|
|
+ debugText.setForeground( RenderHelper.FOREGROUND_COLOR );
|
|
|
+ JScrollPane debugView = new JScrollPane( debugText );
|
|
|
+ debugView.setBounds( treeView.getX(), treeView.getY() + 500, treeView.getWidth(), 250 );
|
|
|
+
|
|
|
frame.setSize( (int)graph.getWidth( LayoutType.TOP_BOTTOM_LEFT ) * 2 + 575, (int)graph.getHeight( LayoutType.TOP_BOTTOM_LEFT ) * 2 + 200 );
|
|
|
frame.setLocation( 100, 100 );
|
|
|
frame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
|
|
@@ -765,6 +763,7 @@ public class MainView {
|
|
|
menue.add( randomGraph );
|
|
|
menue.add( save );
|
|
|
menue.add( load );
|
|
|
+ menue.add( debugView );
|
|
|
frame.add( menue, BorderLayout.EAST );
|
|
|
frame.setSize( frame.getWidth() + 1, frame.getHeight() );
|
|
|
frame.setSize( frame.getWidth() - 1, frame.getHeight() );
|
|
@@ -776,7 +775,8 @@ public class MainView {
|
|
|
public void componentResized(ComponentEvent evt) {
|
|
|
pl.setSize( layne.getSize() );
|
|
|
menue.setSize( menue.getWidth(), layne.getHeight() );
|
|
|
- treeView.setSize( treeView.getWidth(), layne.getHeight() - 120 );
|
|
|
+ treeView.setSize( treeView.getWidth(), layne.getHeight() - 370 );
|
|
|
+ debugView.setBounds( treeView.getX(), treeView.getY() + treeView.getHeight() + 10, treeView.getWidth(), 240 );
|
|
|
if( graph.getColor( LayoutType.COMBINED ) == null )
|
|
|
{
|
|
|
grout.setHgap( 10 );
|
|
@@ -790,6 +790,7 @@ public class MainView {
|
|
|
combined.setSize( layne.getWidth() / 3, layne.getHeight() / 3 );
|
|
|
combined.setLocation( layne.getWidth() / 3, layne.getHeight() / 3 );
|
|
|
|
|
|
+ debugText.setText( algorithm.getDebugString() );
|
|
|
layne.remove( pl );
|
|
|
layne.add( pl, 1 );
|
|
|
frame.repaint();
|