Permalink
Browse files

refactor menu, add comments

  • Loading branch information...
1 parent 3408412 commit e4cba537af70a2e49013104d9f5600c9ffe98f67 Kyle Giovannetti committed Apr 17, 2012
Showing with 53 additions and 93 deletions.
  1. +40 −73 src/org/contextfmm/ui/Display.java
  2. +13 −20 src/org/contextfmm/ui/MetaMapper.java
@@ -32,10 +32,9 @@
public class Display extends JFrame {
/**
- *
- */
- private static final long serialVersionUID = 1L;
- // instance variables
+ * Instance variables
+ */
+ private static final long serialVersionUID = 7471962771555078398L;
public JEditorPane textPane;
public JPanel jspR;
public JScrollPane rsp;
@@ -51,101 +50,69 @@
public StatsActionListener statActionListener;
private static final String TITLE = "Con-Text for MetaMap";
+ /**
+ * ConText-FMM main display window.
+ *
+ * @param x Integer X window size.
+ * @param y Integer Y window size.
+ */
public Display(int x, int y) {
+ // create a new mmo object
this.mmo = new MMO();
+
+ // construct the vocabulary
this.vocabulary = new SourceVocabulary();
+
+ // construct the semantic type list
this.semtypes = new SemTypeList();
+
+ // pointer to this object
this.thisDisplay = this;
+
+ // set the window size
this.setSize(x, y);
- // Title the FRAME Flags, and exit on FRAME close
+
+ // set the window title
this.setTitle(Display.TITLE);
+
+ // exit when this window is closed
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+ // window close listener will prompt to save on window close
this.addWindowListener(new MainWindowClosingListener());
+ // create a new text pane
this.textPane = new JEditorPane();
this.textPane.setText("");
JScrollPane slider = new JScrollPane(this.textPane);
+ // create the right panel
jspR = new JPanel(new BorderLayout());
- DefaultMutableTreeNode top = new DefaultMutableTreeNode("Concept Map");
- model = new DefaultTreeModel(top);
- tree = new JTree();
- tree.setModel(model);
-
- JScrollPane rsp = new JScrollPane(tree);
- jspR.removeAll();
- jspR.add(BorderLayout.CENTER, rsp);
+ // build the tree
+ this.rebuildTree();
+ // create the split pane and add it to this window
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, slider, jspR);
+ // set the split pane division
+ splitPane.setDividerLocation(0.75);
+ splitPane.setResizeWeight(1);
this.add(splitPane, BorderLayout.CENTER);
+ // create the progress bar and add it to the window
this.progressBar = new WindowProgressBar();
- this.connection = new Connect(this);
this.add(this.progressBar, BorderLayout.SOUTH);
- this.setVisible(true);
- splitPane.setDividerLocation(0.75);
- splitPane.setResizeWeight(1);
+
+ // construct a new connection object
+ this.connection = new Connect(this);
// Creates a menubar for a JFrame
- JMenuBar menuBar = new JMenuBar();
+ DisplayMenu menuBar = new DisplayMenu(this);
// Add the menubar to the FRAME
this.setJMenuBar(menuBar);
- // Define and add two drop down menu to the menubar
- JMenu fileMenu = new JMenu("File");
- menuBar.add(fileMenu);
- // Create and add simple menu item to one of the drop down menu
- JMenuItem openAction = new JMenuItem("Open Textfile");
- JMenuItem saveAction = new JMenuItem("Save Project");
- JMenuItem loadAction = new JMenuItem("Load Project");
- JMenuItem exitAction = new JMenuItem("Exit");
-
- fileMenu.add(openAction);
- fileMenu.addSeparator();
- fileMenu.add(saveAction);
- fileMenu.add(loadAction);
- fileMenu.addSeparator();
- fileMenu.add(exitAction);
-
- JMenu taskMenu = new JMenu("Tasks");
- menuBar.add(taskMenu);
- JMenuItem mapAction = new JMenuItem("Map Text");
- taskMenu.add(mapAction);
-
- JMenuItem acceptSingleMapAction = new JMenuItem("Accept Single Mappings");
- taskMenu.add(acceptSingleMapAction);
-
- JMenu viewMenu = new JMenu("View");
- menuBar.add(viewMenu);
- JMenuItem statsAction = new JMenuItem("Statistics");
- viewMenu.add(statsAction);
- JMenuItem customConceptAction = new JMenuItem("Custom Concepts");
- viewMenu.add(customConceptAction);
-
- saveProjectListener = new SaveProjectListener(this);
- openAction.addActionListener(new OpenFileActionListener(this));
- saveAction.addActionListener(this.saveProjectListener);
- loadAction.addActionListener(new LoadProjectActionListener(this));
- mapAction.addActionListener(this.connection);
- statActionListener = new StatsActionListener(this);
- statsAction.addActionListener(statActionListener);
- customConceptAction.addActionListener(new CustomConceptViewerListener(this));
- acceptSingleMapAction.addActionListener(new ActionListener() {
-
- @Override
- public void actionPerformed(ActionEvent arg0) {
- mmo.acceptSingleMappings();
- }
-
- });
-
- exitAction.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent arg0) {
- dispatchEvent(new WindowEvent(thisDisplay, WindowEvent.WINDOW_CLOSING));
- System.exit(0);
- }
- });
+
+ // set this frame to visible
+ this.setVisible(true);
}
public void rebuildTree() {
@@ -1,29 +1,22 @@
package org.contextfmm.ui;
/**
- * Course Number: COMP 1113 Assignment Number: 11 Question Number: 1 reads in
- * datafile containing bridge data, plots the data to screen.
*
- * @author Kyle Giovannetti, 100078220
- * @version November 26, 2008
+ * @author Kyle Giovannetti
*/
public class MetaMapper {
- // instance variables
- public final static int FRAME_X = 1000;
- public final static int FRAME_Y = 600;
+ // instance variables
+ public final static int FRAME_X = 1000;
+ public final static int FRAME_Y = 600;
- /**
- * Main for BridgeGrapher, runs getData method for first run, getData will
- * call makePlot to create frame and plot the data.
- *
- * @param args
- * arguments to main
- * @throws FileNotFoundException
- * if datafile not found
- */
- public static void main(String[] args) {
-
- new Display(FRAME_X,FRAME_Y);
- }
+ /**
+ * Main method. Creates the display
+ *
+ * @param args arguments to main
+ */
+ public static void main(String[] args) {
+ //construct the display
+ new Display(FRAME_X, FRAME_Y);
+ }
}

0 comments on commit e4cba53

Please sign in to comment.