|
@@ -68,8 +68,9 @@ public class MainView {
|
|
* Random Graph Generator should olny exist once for all windows (so the values will be stored)
|
|
* Random Graph Generator should olny exist once for all windows (so the values will be stored)
|
|
*/
|
|
*/
|
|
private static final RandomGraphDialog randomDialog = new RandomGraphDialog();
|
|
private static final RandomGraphDialog randomDialog = new RandomGraphDialog();
|
|
- private JFrame frame;
|
|
|
|
- private ProcessController controller;
|
|
|
|
|
|
+ private JFrame frame; // Zeigt alles an
|
|
|
|
+ private ProcessController controller; // Kontrolliert den Prozessor
|
|
|
|
+ // Menu Buttons, Labels and TextFields
|
|
private JButton stepForward;
|
|
private JButton stepForward;
|
|
private JButton stepForwardInto;
|
|
private JButton stepForwardInto;
|
|
private JButton stepForwardOut;
|
|
private JButton stepForwardOut;
|
|
@@ -86,12 +87,12 @@ public class MainView {
|
|
private JButton randomGraph;
|
|
private JButton randomGraph;
|
|
private JLabel delayText;
|
|
private JLabel delayText;
|
|
private JTextField delay;
|
|
private JTextField delay;
|
|
- private JTree pseudoTree;
|
|
|
|
- private LayeredGraphNode graph;
|
|
|
|
- private OptionsDialog optionsDialog;
|
|
|
|
|
|
+ private JTree pseudoTree; // Die Pseudocode Ansicht
|
|
|
|
+ private LayeredGraphNode graph; // Die interne Graph Repräsentation
|
|
|
|
+ private OptionsDialog optionsDialog; // Der Dialog mit Optionen
|
|
|
|
|
|
private String debugInfo()
|
|
private String debugInfo()
|
|
- {
|
|
|
|
|
|
+ { // Gesammter Debug Text für alle Layouts
|
|
String info = "Debug Information Table: \n";
|
|
String info = "Debug Information Table: \n";
|
|
info += "_______________________________________________________________________________________________________________________________________________________________________________________________________________________\n";
|
|
info += "_______________________________________________________________________________________________________________________________________________________________________________________________________________________\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 += "|" + 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";
|
|
@@ -133,7 +134,7 @@ public class MainView {
|
|
}
|
|
}
|
|
|
|
|
|
private void showDebugInfo()
|
|
private void showDebugInfo()
|
|
- {
|
|
|
|
|
|
+ { // Erzeuge neues Fenster mit Debug Text
|
|
JFrame debugFrame = new JFrame();
|
|
JFrame debugFrame = new JFrame();
|
|
JTextArea info = new JTextArea();
|
|
JTextArea info = new JTextArea();
|
|
info.setEditable( false );
|
|
info.setEditable( false );
|
|
@@ -403,6 +404,7 @@ public class MainView {
|
|
public void mousePressed(MouseEvent e) {
|
|
public void mousePressed(MouseEvent e) {
|
|
TreePath selPath = pseudoTree.getPathForLocation(e.getX(), e.getY());
|
|
TreePath selPath = pseudoTree.getPathForLocation(e.getX(), e.getY());
|
|
if( selPath != null && e.getClickCount() == 3 ) {
|
|
if( selPath != null && e.getClickCount() == 3 ) {
|
|
|
|
+ // Setzt einen Breakpoint bei dreifachklick
|
|
((PseudoCodeNode)selPath.getLastPathComponent()).setBreakPoint( !((PseudoCodeNode)selPath.getLastPathComponent()).hasBreakPoint() );
|
|
((PseudoCodeNode)selPath.getLastPathComponent()).setBreakPoint( !((PseudoCodeNode)selPath.getLastPathComponent()).hasBreakPoint() );
|
|
if( !pseudoTree.isExpanded( selPath ) )
|
|
if( !pseudoTree.isExpanded( selPath ) )
|
|
{
|
|
{
|
|
@@ -417,6 +419,7 @@ public class MainView {
|
|
pseudoTree.repaint();
|
|
pseudoTree.repaint();
|
|
frame.repaint();
|
|
frame.repaint();
|
|
}
|
|
}
|
|
|
|
+ // Erzeuge das Rechtsklick Menü für Collaps und Expand
|
|
if( e.getButton() == MouseEvent.BUTTON3 )
|
|
if( e.getButton() == MouseEvent.BUTTON3 )
|
|
{
|
|
{
|
|
JPopupMenu menu = new JPopupMenu();
|
|
JPopupMenu menu = new JPopupMenu();
|
|
@@ -549,6 +552,7 @@ public class MainView {
|
|
pl.setLayout( grout );
|
|
pl.setLayout( grout );
|
|
pl.setLocation( 0, 0 );
|
|
pl.setLocation( 0, 0 );
|
|
pl.setSize( frame.getSize() );
|
|
pl.setSize( frame.getSize() );
|
|
|
|
+ // Erzeugt die Graph Views für die verschiedenen Layouts
|
|
NodeView topLeft = createNodeView( graph, LayoutType.LEFTMOST_UPPER );
|
|
NodeView topLeft = createNodeView( graph, LayoutType.LEFTMOST_UPPER );
|
|
NodeView topRight = createNodeView( graph, LayoutType.RIGHTMOST_UPPER );
|
|
NodeView topRight = createNodeView( graph, LayoutType.RIGHTMOST_UPPER );
|
|
NodeView bottomLeft = createNodeView( graph, LayoutType.LEFTMOST_LOWER );
|
|
NodeView bottomLeft = createNodeView( graph, LayoutType.LEFTMOST_LOWER );
|
|
@@ -615,16 +619,17 @@ public class MainView {
|
|
frame.addComponentListener(new ComponentAdapter()
|
|
frame.addComponentListener(new ComponentAdapter()
|
|
{
|
|
{
|
|
public void componentResized(ComponentEvent evt) {
|
|
public void componentResized(ComponentEvent evt) {
|
|
|
|
+ // Aktualisiere die Höhe des Menüs
|
|
menue.setSize( menue.getWidth(), layne.getHeight() );
|
|
menue.setSize( menue.getWidth(), layne.getHeight() );
|
|
spane2.setSize( menue.getWidth() - 20, menue.getHeight() - 120 );
|
|
spane2.setSize( menue.getWidth() - 20, menue.getHeight() - 120 );
|
|
if( graph.getColor( null ) == null )
|
|
if( graph.getColor( null ) == null )
|
|
- {
|
|
|
|
|
|
+ { // Falls das Kombinierte Layout nicht gezeichnet werden soll
|
|
grout.setHgap( 10 );
|
|
grout.setHgap( 10 );
|
|
grout.setVgap( 10 );
|
|
grout.setVgap( 10 );
|
|
combined.setVisible( false );
|
|
combined.setVisible( false );
|
|
}
|
|
}
|
|
else
|
|
else
|
|
- {
|
|
|
|
|
|
+ {// Falsl das Kombinierte Layout gezeichnet werden soll
|
|
grout.setHgap( layne.getWidth() / 3 );
|
|
grout.setHgap( layne.getWidth() / 3 );
|
|
grout.setVgap( layne.getHeight() / 3 );
|
|
grout.setVgap( layne.getHeight() / 3 );
|
|
combined.setVisible( true );
|
|
combined.setVisible( true );
|
|
@@ -637,14 +642,15 @@ public class MainView {
|
|
layne.remove( pl );
|
|
layne.remove( pl );
|
|
layne.add( pl, 1 );
|
|
layne.add( pl, 1 );
|
|
if( optionsDialog != null && optionsDialog.getLayerDisplayOption() == 1 && old != algorithm.getAlgorithmState() )
|
|
if( optionsDialog != null && optionsDialog.getLayerDisplayOption() == 1 && old != algorithm.getAlgorithmState() )
|
|
- {
|
|
|
|
|
|
+ { // Es soll immer nur das aktuelle LAyout gezeichet werden und der Algorithmus hat ein neues Layout erreicht
|
|
|
|
+ // Entferne die Layouts
|
|
pl.remove( topLeft );
|
|
pl.remove( topLeft );
|
|
pl.remove( topRight );
|
|
pl.remove( topRight );
|
|
pl.remove( bottomLeft );
|
|
pl.remove( bottomLeft );
|
|
pl.remove( bottomRight );
|
|
pl.remove( bottomRight );
|
|
pl.remove( combined );
|
|
pl.remove( combined );
|
|
switch( algorithm.getAlgorithmState() )
|
|
switch( algorithm.getAlgorithmState() )
|
|
- {
|
|
|
|
|
|
+ { // füge das richtige Layout hinzu
|
|
case CONFLICT_DETECTION:
|
|
case CONFLICT_DETECTION:
|
|
pl.add( topLeft );
|
|
pl.add( topLeft );
|
|
break;
|
|
break;
|
|
@@ -687,6 +693,7 @@ public class MainView {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void actionPerformed(ActionEvent e) {
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
|
+ // Es wurden Optionen geändert
|
|
controller.setStepOption( optionsDialog.getRunStepsOption() );
|
|
controller.setStepOption( optionsDialog.getRunStepsOption() );
|
|
controller.setAutoCollapseOption( optionsDialog.getAutoCollapseOption() );
|
|
controller.setAutoCollapseOption( optionsDialog.getAutoCollapseOption() );
|
|
RenderHelper.font = new Font( "Monospaced", Font.PLAIN, optionsDialog.getFontSize() );
|
|
RenderHelper.font = new Font( "Monospaced", Font.PLAIN, optionsDialog.getFontSize() );
|
|
@@ -700,7 +707,7 @@ public class MainView {
|
|
pl.remove( combined );
|
|
pl.remove( combined );
|
|
layne.remove( combined );
|
|
layne.remove( combined );
|
|
if( optionsDialog.getLayerDisplayOption() == 0)
|
|
if( optionsDialog.getLayerDisplayOption() == 0)
|
|
- {
|
|
|
|
|
|
+ { // Es sollen alle Layouts angezeigt werden
|
|
pl.setLayout( grout );
|
|
pl.setLayout( grout );
|
|
pl.add( topLeft );
|
|
pl.add( topLeft );
|
|
pl.add( topRight );
|
|
pl.add( topRight );
|
|
@@ -709,10 +716,10 @@ public class MainView {
|
|
layne.add( combined, 0 );
|
|
layne.add( combined, 0 );
|
|
}
|
|
}
|
|
else
|
|
else
|
|
- {
|
|
|
|
|
|
+ { // Es soll nur das aktuelle Layout gezeichnet werden
|
|
pl.setLayout( new BorderLayout() );
|
|
pl.setLayout( new BorderLayout() );
|
|
switch( algorithm.getAlgorithmState() )
|
|
switch( algorithm.getAlgorithmState() )
|
|
- {
|
|
|
|
|
|
+ { // füge das richtige layout hinzu
|
|
case CONFLICT_DETECTION:
|
|
case CONFLICT_DETECTION:
|
|
pl.add( topLeft );
|
|
pl.add( topLeft );
|
|
break;
|
|
break;
|
|
@@ -747,6 +754,7 @@ public class MainView {
|
|
processor.start(); // start running the algorithm
|
|
processor.start(); // start running the algorithm
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // Erzeugt eine View für einen Graph
|
|
private NodeView createNodeView( LayeredGraphNode gNode, LayoutType lt )
|
|
private NodeView createNodeView( LayeredGraphNode gNode, LayoutType lt )
|
|
{
|
|
{
|
|
NodeView graphView = new NodeView( gNode, lt, frame );
|
|
NodeView graphView = new NodeView( gNode, lt, frame );
|