Commit 68b4acab authored by Christos Christodoulopoulos's avatar Christos Christodoulopoulos
Browse files

Added reference lists in "tree edit"

 - For now, simply lists of terminals/non-terminals
 - Rearranged the entire panel
parent 0681acdc
......@@ -244,6 +244,7 @@ public class JBOpenDialog extends JDialog implements ActionListener, ItemListene
StringTokenizer tok = new StringTokenizer((String)cb_projects.getSelectedItem(), ".");
String corpusStr = tok.nextToken();
jbtk.initProperties(corpusStr, m_dataset);
jbtk.readReferenceMaterial();
if (!ls_newTask.isSelectionEmpty()) {
String[] tmp = getFileList(ls_newTask.getSelectedValue(), true);
......
......@@ -70,6 +70,10 @@ public class JBToolkit extends JFrame implements ActionListener, ItemListener, L
int i_currSetting = 0; // current project setting (i.e. english.sample.path)
int i_maxAnn;
// Reference lists (shown during tree editing)
private ArrayList<String[]> terminalsList;
private ArrayList<String[]> nonTerminalsList;
static public String s_sysDir = null;
private static JBToolkit instance;
......@@ -126,6 +130,14 @@ public class JBToolkit extends JFrame implements ActionListener, ItemListener, L
new JBOpenDialog(this, false, i_maxAnn);
setVisible(true);
}
/**
* Reads and stores reference material (related to the annotation guidelines) for later use
*/
public void readReferenceMaterial() {
terminalsList = DataManager.getContents("terminals.txt");
nonTerminalsList = DataManager.getContents("non-terminals.txt");
}
// -------------------- initialize components --------------------
......@@ -558,4 +570,20 @@ public class JBToolkit extends JFrame implements ActionListener, ItemListener, L
new JOptionPane().showMessageDialog(this, msg, "About", JOptionPane.INFORMATION_MESSAGE);
}
public String getTerminalsList() {
String listStr = "";
for (String[] strings : terminalsList) {
listStr += strings[0] + "\t" + strings[1] + "\n";
}
return listStr;
}
public String getNonTerminalsList() {
String listStr = "";
for (String[] strings : nonTerminalsList) {
listStr += strings[0] + "\t" + strings[1] + "\n";
}
return listStr;
}
}
......@@ -30,7 +30,6 @@ public class JBTreeEditPanel extends JFrame implements ActionListener {
textArea = new JTextArea(annotation.getTbTree().toTextTree());
textArea.setMargin(new Insets(10, 10, 10, 10));
textArea.setPreferredSize(new Dimension(498, 260));
buttonApply = new JButton("Apply");
buttonApply.addActionListener(this);
......@@ -38,30 +37,80 @@ public class JBTreeEditPanel extends JFrame implements ActionListener {
buttonCancel.addActionListener(this);
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new GridLayout(0, 2, 10, 0));
buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
buttonPanel.add(buttonApply);
buttonPanel.add(Box.createRigidArea(new Dimension(10, 0)));
buttonPanel.add(buttonCancel);
String sentStr = annotation.getTbTree().getSentence();
String sentLabelStr = "<html>Sentence: <i>" + sentStr + "</i></html>";
JLabel sentLabel = new JLabel(sentLabelStr);
fieldWordsNum = new JTextField(1);
fieldWordsNum.setPreferredSize(new Dimension(10, 20));
fieldWordPos = new JTextField(1);
fieldWordsNum = new JTextField();
fieldWordsNum.setMaximumSize(new Dimension(35, 20));
fieldWordsNum.setPreferredSize(new Dimension(35, 20));
fieldWordPos = new JTextField();
fieldWordPos.setMaximumSize(new Dimension(35, 20));
fieldWordPos.setPreferredSize(new Dimension(35, 20));
JPanel addArgsPanel = new JPanel();
addArgsPanel.setLayout(new GridLayout(0, 4, 10, 0));
addArgsPanel.add(new JLabel("<html>#new words<br/>inserted</html>"));
addArgsPanel.setLayout(new BoxLayout(addArgsPanel, BoxLayout.X_AXIS));
addArgsPanel.add(new JLabel("#new words inserted"));
addArgsPanel.add(Box.createRigidArea(new Dimension(5, 0)));
addArgsPanel.add(fieldWordsNum);
addArgsPanel.add(new JLabel("<html>#words before<br/>new word</html>"));
addArgsPanel.add(Box.createHorizontalGlue());
addArgsPanel.add(new JLabel("#words before new word"));
addArgsPanel.add(Box.createRigidArea(new Dimension(5, 0)));
addArgsPanel.add(fieldWordPos);
addArgsPanel.setBorder(BorderFactory.createTitledBorder(
BorderFactory.createLineBorder(Color.BLACK), "Reposition SRL labels"));
// Set layout and add components
setLayout(new FlowLayout());
add(new JScrollPane(textArea));
add(sentLabel);
add(addArgsPanel);
add(buttonPanel);
JPanel leftPanel = new JPanel();
leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.Y_AXIS));
JScrollPane textScrollPane = new JScrollPane(textArea);
textScrollPane.setMaximumSize(new Dimension(390, 290));
textScrollPane.setPreferredSize(new Dimension(390, 290));
leftPanel.add(textScrollPane);
sentLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
leftPanel.add(sentLabel);
leftPanel.add(Box.createRigidArea(new Dimension(0, 30)));
leftPanel.add(addArgsPanel);
buttonPanel.setAlignmentY(Component.BOTTOM_ALIGNMENT);
leftPanel.add(Box.createRigidArea(new Dimension(0, 20)));
leftPanel.add(buttonPanel);
leftPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
JPanel rightPanel = new JPanel();
rightPanel.setLayout(new BoxLayout(rightPanel, BoxLayout.Y_AXIS));
Dimension referenceDimension = new Dimension(290, 190);
JTextArea referenceNonTerminalsTextArea = new JTextArea(parent.getNonTerminalsList());
referenceNonTerminalsTextArea.setEditable(false);
JScrollPane referenceNonTerminalsScrollPane = new JScrollPane(referenceNonTerminalsTextArea);
referenceNonTerminalsScrollPane.setMinimumSize(referenceDimension);
referenceNonTerminalsScrollPane.setMaximumSize(referenceDimension);
referenceNonTerminalsScrollPane.setPreferredSize(referenceDimension);
JTextArea referenceTerminalsArea = new JTextArea(parent.getTerminalsList());
referenceTerminalsArea.setEditable(false);
JScrollPane referenceTerminalsScrollPane = new JScrollPane(referenceTerminalsArea);
referenceTerminalsScrollPane.setMinimumSize(referenceDimension);
referenceTerminalsScrollPane.setMaximumSize(referenceDimension);
referenceTerminalsScrollPane.setPreferredSize(referenceDimension);
rightPanel.add(new JLabel("Reference lists:"));
rightPanel.add(new JLabel("Non-Terminal labels"));
rightPanel.add(referenceNonTerminalsScrollPane);
rightPanel.add(new JLabel("Terminal labels"));
rightPanel.add(referenceTerminalsScrollPane);
rightPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
setLayout(new BoxLayout(getContentPane(), BoxLayout.X_AXIS));
leftPanel.setAlignmentY(Component.TOP_ALIGNMENT);
rightPanel.setAlignmentY(Component.TOP_ALIGNMENT);
add(leftPanel);
add(rightPanel);
addWindowListener(new WindowAdapter() {
@Override
......@@ -70,7 +119,7 @@ public class JBTreeEditPanel extends JFrame implements ActionListener {
}
});
setBounds(20, 20, 500, 400);
setBounds(20, 20, 700, 480);
setVisible(true);
}
......
......@@ -76,7 +76,7 @@ public class DataManager {
String line = scan.nextLine().trim();
// skip comments and blank-lines
if (line.length() > 0 && line.charAt(0) != '#')
list.add(line.split(" "));
list.add(line.split("\\s+"));
}
scan.close();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment