List of usage examples for edu.stanford.nlp.parser.ui TreeJPanel TreeJPanel
public TreeJPanel()
From source file:edu.cmu.cs.in.hoop.visualizers.HoopParseTreeViewer.java
License:Open Source License
/** * // w ww . j a va2s . c o m */ public HoopParseTreeViewer() { //this.setLayout(new BoxLayout (this,BoxLayout.Y_AXIS)); Options theseOptions = new Options(); theseOptions.setOptions(new String[] {}); String theseExtraFlags[] = new String[] { "-maxLength", "256", "-retainTmpSubcategories" }; //theLexicalizedParser = LexicalizedParser.loadModel(theLexicalizedParserName, theseOptions, theseExtraFlags); theLexicalizedParser = LexicalizedParser.loadModel(); model = new DefaultListModel(); sentenceList = new JList(model); sentenceList.setOpaque(true); sentenceList.setBackground(new Color(220, 220, 220)); sentenceList.addMouseListener(this); JScrollPane scroller = new JScrollPane(sentenceList); scroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); Box controlBox = Box.createHorizontalBox(); entry = new JTextArea(); entry.setFont(new Font("Dialog", 1, 10)); //entry.setBorder(blackborder); entry.setMinimumSize(new Dimension(100, 25)); entry.setPreferredSize(new Dimension(200, 25)); entry.setMaximumSize(new Dimension(200, 25)); //entry.setText("The quick brown fox jumps over the lazy dog."); parseButton = new JButton(); //parseButton.setIcon(HoopLink.imageIcons [8]); parseButton.setMargin(new Insets(1, 1, 1, 1)); parseButton.setText("Parse"); parseButton.setFont(new Font("Courier", 1, 8)); parseButton.setPreferredSize(new Dimension(20, 16)); parseButton.addActionListener(this); controlBox.add(entry); controlBox.add(parseButton); controlBox.add(Box.createHorizontalGlue()); treePanel = new TreeJPanel(); JPanel content = (JPanel) getContentPane(); content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS)); //this.add(controlBox); //this.add(scroller); //this.add (treePanel); content.add(controlBox); content.add(scroller); content.add(treePanel); }
From source file:nlpedit.ui.NLPTreeEx.java
License:Open Source License
private void initComponents() { JPanel buttonPanel = new JPanel(); parseButton = new JButton("parse"); updateTextButton = new JButton("update text"); updateGraphButton = new JButton("update graph"); treeEdit = new NLPTreeEdit(); sentArea = new JTextArea(5, 40); treeArea = new JTextArea(5, 40); treeGraph = new TreeJPanel(); sentArea.setLineWrap(true);/* w w w . ja v a2 s. c o m*/ treeArea.setLineWrap(true); parseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { parseSentence(); updateText(); updateGraph(); } }); updateTextButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateText(); } }); updateGraphButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateGraph(); } }); JPanel leftPanel = new JPanel(); leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.Y_AXIS)); buttonPanel.add(parseButton); buttonPanel.add(updateTextButton); buttonPanel.add(updateGraphButton); leftPanel.add(buttonPanel); leftPanel.add(sentArea); leftPanel.add(treeEdit); leftPanel.add(treeArea); JScrollPane graphScroll = new JScrollPane(treeGraph); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel, graphScroll); add(splitPane); pack(); }