Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Commits on Apr 17, 2012
Kyle Giovannetti refactor menu, add comments e4cba53
Kyle Giovannetti add display menu object 5c783ff
Showing with 167 additions and 93 deletions.
  1. +40 −73 src/org/contextfmm/ui/Display.java
  2. +114 −0 src/org/contextfmm/ui/DisplayMenu.java
  3. +13 −20 src/org/contextfmm/ui/MetaMapper.java
View
113 src/org/contextfmm/ui/Display.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() {
View
114 src/org/contextfmm/ui/DisplayMenu.java
@@ -0,0 +1,114 @@
+/**
+ *
+ */
+package org.contextfmm.ui;
+
+import java.awt.Frame;
+import java.awt.Window;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowEvent;
+
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+
+import org.contextfmm.controller.CustomConceptViewerListener;
+import org.contextfmm.controller.LoadProjectActionListener;
+import org.contextfmm.controller.OpenFileActionListener;
+import org.contextfmm.controller.SaveProjectListener;
+import org.contextfmm.controller.StatsActionListener;
+import org.contextfmm.model.MMO;
+
+/**
+ * @author Kyle Giovannetti
+ *
+ */
+public class DisplayMenu extends JMenuBar {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -8652834321040285754L;
+ private SaveProjectListener saveProjectListener;
+ private StatsActionListener statActionListener;
+
+ /**
+ *
+ */
+ public DisplayMenu(Display parent) {
+ // Define and add two drop down menu to the menubar
+ JMenu fileMenu = new JMenu("File");
+ this.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");
+ this.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");
+ this.add(viewMenu);
+ JMenuItem statsAction = new JMenuItem("Statistics");
+ viewMenu.add(statsAction);
+ JMenuItem customConceptAction = new JMenuItem("Custom Concepts");
+ viewMenu.add(customConceptAction);
+
+ saveProjectListener = new SaveProjectListener(parent);
+ openAction.addActionListener(new OpenFileActionListener(parent));
+ saveAction.addActionListener(this.saveProjectListener);
+ loadAction.addActionListener(new LoadProjectActionListener(parent));
+ mapAction.addActionListener(parent.connection);
+ statActionListener = new StatsActionListener(parent);
+ statsAction.addActionListener(statActionListener);
+ customConceptAction.addActionListener(new CustomConceptViewerListener(parent));
+ acceptSingleMapAction.addActionListener(new AcceptSingleMappingActionListener(parent.mmo));
+
+ exitAction.addActionListener(new ExitActionListener());
+ }
+
+ class AcceptSingleMappingActionListener implements ActionListener {
+
+ private MMO mmo;
+
+ public AcceptSingleMappingActionListener(MMO mmo) {
+ this.mmo = mmo;
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ mmo.acceptSingleMappings();
+
+ }
+
+ }
+
+ class ExitActionListener implements ActionListener {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ Frame[] frames = Frame.getFrames();
+ for (int i = 0; i < frames.length; i++) {
+ frames[i].dispatchEvent(new WindowEvent(frames[i], WindowEvent.WINDOW_CLOSING));
+ }
+ System.exit(0);
+
+ }
+
+ }
+
+}
View
33 src/org/contextfmm/ui/MetaMapper.java
@@ -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);
+ }
}

No commit comments for this range

Something went wrong with that request. Please try again.