use of gate.resources.img.svg.RunIcon in project gate-core by GateNLP.
the class AnnotationDiffGUI method initGUI.
protected void initGUI() {
getContentPane().setLayout(new GridBagLayout());
GridBagConstraints constraints = new GridBagConstraints();
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.anchor = GridBagConstraints.WEST;
constraints.insets = new Insets(2, 2, 2, 2);
constraints.weightx = 1;
/**
*****************************************
* First row - Settings and 'Compare' button *
******************************************
*/
constraints.gridy = 0;
JLabel keyDocLabel = new JLabel("Key doc:");
keyDocLabel.setToolTipText("Key document");
getContentPane().add(keyDocLabel, constraints);
keyDocCombo = new JComboBox<String>();
keyDocCombo.setPrototypeDisplayValue("long_document_name");
// add the value of the combobox in a tooltip for long value
keyDocCombo.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value != null) {
Rectangle textRectangle = new Rectangle(keyDocCombo.getSize().width, getPreferredSize().height);
String shortText = SwingUtilities.layoutCompoundLabel(this, getFontMetrics(getFont()), value.toString(), null, getVerticalAlignment(), getHorizontalAlignment(), getHorizontalTextPosition(), getVerticalTextPosition(), textRectangle, new Rectangle(), textRectangle, getIconTextGap());
if (shortText.equals(value)) {
// no tooltip
if (index == -1) {
keyDocCombo.setToolTipText(null);
} else {
setToolTipText(null);
}
} else {
// add tooltip because text is shortened
if (index == -1) {
keyDocCombo.setToolTipText(value.toString());
} else {
setToolTipText(value.toString());
}
}
}
return this;
}
});
constraints.weightx = 3;
getContentPane().add(keyDocCombo, constraints);
constraints.weightx = 1;
JLabel keySetLabel = new JLabel("Key set:");
keySetLabel.setToolTipText("Key annotation set");
getContentPane().add(keySetLabel, constraints);
keySetCombo = new JComboBox<String>();
keySetCombo.setPrototypeDisplayValue("long_set_name");
getContentPane().add(keySetCombo, constraints);
JLabel typeLabel = new JLabel("Type:");
typeLabel.setToolTipText("Annotation type");
getContentPane().add(typeLabel, constraints);
annTypeCombo = new JComboBox<String>();
annTypeCombo.setPrototypeDisplayValue("very_long_type");
constraints.gridwidth = 3;
getContentPane().add(annTypeCombo, constraints);
constraints.gridwidth = 1;
JLabel weightLabel = new JLabel("Weight");
weightLabel.setToolTipText("F-measure weight");
getContentPane().add(weightLabel, constraints);
diffAction = new DiffAction();
diffAction.setEnabled(false);
doDiffBtn = new JButton(diffAction);
doDiffBtn.setDisabledIcon(new RunIcon(MainFrame.ICON_DIMENSION, true));
doDiffBtn.setForeground((Color) UIManager.getDefaults().get("Button.disabledText"));
doDiffBtn.setToolTipText("Choose two annotation sets " + "that have at least one annotation type in common.");
constraints.gridheight = 2;
getContentPane().add(doDiffBtn, constraints);
constraints.gridheight = 1;
/**
***********************
* Second row - Settings *
************************
*/
constraints.gridy++;
constraints.gridx = 0;
JLabel responseDocLabel = new JLabel("Resp. doc:");
responseDocLabel.setToolTipText("Response document");
getContentPane().add(responseDocLabel, constraints);
constraints.gridx = GridBagConstraints.RELATIVE;
resDocCombo = new JComboBox<String>();
resDocCombo.setPrototypeDisplayValue("long_document_name");
resDocCombo.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value != null) {
Rectangle textRectangle = new Rectangle(resDocCombo.getSize().width, getPreferredSize().height);
String shortText = SwingUtilities.layoutCompoundLabel(this, getFontMetrics(getFont()), value.toString(), null, getVerticalAlignment(), getHorizontalAlignment(), getHorizontalTextPosition(), getVerticalTextPosition(), textRectangle, new Rectangle(), textRectangle, getIconTextGap());
if (shortText.equals(value)) {
// no tooltip
if (index == -1) {
resDocCombo.setToolTipText(null);
} else {
setToolTipText(null);
}
} else {
// add tooltip because text is shortened
if (index == -1) {
resDocCombo.setToolTipText(value.toString());
} else {
setToolTipText(value.toString());
}
}
}
return this;
}
});
constraints.weightx = 3;
getContentPane().add(resDocCombo, constraints);
constraints.weightx = 1;
JLabel responseSetLabel = new JLabel("Resp. set:");
responseSetLabel.setToolTipText("Response annotation set");
getContentPane().add(responseSetLabel, constraints);
resSetCombo = new JComboBox<String>();
resSetCombo.setPrototypeDisplayValue("long_set_name");
getContentPane().add(resSetCombo, constraints);
getContentPane().add(new JLabel("Features:"), constraints);
ButtonGroup btnGrp = new ButtonGroup();
allFeaturesBtn = new JRadioButton("all");
allFeaturesBtn.setOpaque(false);
allFeaturesBtn.setMargin(new Insets(0, 0, 0, 1));
allFeaturesBtn.setIconTextGap(1);
btnGrp.add(allFeaturesBtn);
constraints.insets = new Insets(0, 0, 0, 0);
getContentPane().add(allFeaturesBtn, constraints);
someFeaturesBtn = new JRadioButton("some");
someFeaturesBtn.setOpaque(false);
someFeaturesBtn.setMargin(new Insets(0, 0, 0, 1));
someFeaturesBtn.setIconTextGap(1);
btnGrp.add(someFeaturesBtn);
getContentPane().add(someFeaturesBtn, constraints);
noFeaturesBtn = new JRadioButton("none");
noFeaturesBtn.setOpaque(false);
noFeaturesBtn.setMargin(new Insets(0, 0, 0, 1));
noFeaturesBtn.setIconTextGap(1);
btnGrp.add(noFeaturesBtn);
getContentPane().add(noFeaturesBtn, constraints);
constraints.insets = new Insets(2, 2, 2, 2);
noFeaturesBtn.setSelected(true);
weightTxt = new JTextField("1.0");
weightTxt.setToolTipText("<html>Relative weight of precision and recall aka beta." + "<ul><li>1 weights equally precision and recall" + "<li>0.5 weights precision twice as much as recall" + "<li>2 weights recall twice as much as precision</ul></html>");
constraints.fill = GridBagConstraints.HORIZONTAL;
getContentPane().add(weightTxt, constraints);
constraints.fill = GridBagConstraints.NONE;
/**
******************************
* Third row - Comparison table *
*******************************
*/
constraints.gridy++;
constraints.gridx = 0;
diffTableModel = new DiffTableModel();
diffTable = new XJTable(diffTableModel);
diffTable.setDefaultRenderer(String.class, new DiffTableCellRenderer());
diffTable.setDefaultRenderer(Boolean.class, new DiffTableCellRenderer());
diffTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
diffTable.setComparator(DiffTableModel.COL_MATCH, new Comparator<String>() {
@Override
public int compare(String label1, String label2) {
int match1 = 0;
while (!label1.equals(matchLabel[match1])) match1++;
int match2 = 0;
while (!label2.equals(matchLabel[match2])) match2++;
return match1 - match2;
}
});
diffTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
diffTable.setRowSelectionAllowed(true);
diffTable.setColumnSelectionAllowed(true);
diffTable.setEnableHidingColumns(true);
diffTable.hideColumn(DiffTableModel.COL_KEY_COPY);
diffTable.hideColumn(DiffTableModel.COL_RES_COPY);
Comparator<String> startEndComparator = new Comparator<String>() {
@Override
public int compare(String no1, String no2) {
if (no1.trim().equals("") && no2.trim().equals("")) {
return 0;
} else if (no1.trim().equals("")) {
return -1;
} else if (no2.trim().equals("")) {
return 1;
}
int n1 = Integer.parseInt(no1);
int n2 = Integer.parseInt(no2);
if (n1 == n2)
return 0;
else if (n1 > n2)
return 1;
else
return -1;
}
};
diffTable.setComparator(DiffTableModel.COL_KEY_START, startEndComparator);
diffTable.setComparator(DiffTableModel.COL_KEY_END, startEndComparator);
diffTable.setComparator(DiffTableModel.COL_RES_START, startEndComparator);
diffTable.setComparator(DiffTableModel.COL_RES_END, startEndComparator);
diffTable.setSortable(true);
diffTable.setSortedColumn(DiffTableModel.COL_MATCH);
diffTable.setAscending(true);
scroller = new JScrollPane(diffTable);
constraints.gridwidth = GridBagConstraints.REMAINDER;
constraints.weightx = 1;
constraints.weighty = 1;
constraints.fill = GridBagConstraints.BOTH;
getContentPane().add(scroller, constraints);
constraints.gridwidth = 1;
constraints.weightx = 0;
constraints.weighty = 0;
constraints.fill = GridBagConstraints.NONE;
/**
***********************************************
* Fourth row - Tabbed panes, status and buttons *
************************************************
*/
bottomTabbedPane = new JTabbedPane(JTabbedPane.BOTTOM, JTabbedPane.WRAP_TAB_LAYOUT);
// statistics pane will be added to the bottom tabbed pane
statisticsPane = new JPanel(new GridBagLayout());
GridBagConstraints constraints2 = new GridBagConstraints();
constraints2.insets = new Insets(2, 2, 2, 2);
// first column
constraints2.gridx = 0;
constraints2.anchor = GridBagConstraints.WEST;
JLabel lbl = new JLabel("Correct:");
lbl.setToolTipText("Correct:");
lbl.setBackground(diffTable.getBackground());
statisticsPane.add(lbl, constraints2);
lbl = new JLabel("Partially correct:");
lbl.setToolTipText("Partially correct:");
lbl.setBackground(PARTIALLY_CORRECT_BG);
lbl.setOpaque(true);
statisticsPane.add(lbl, constraints2);
lbl = new JLabel("Missing:");
lbl.setToolTipText("Missing:");
lbl.setBackground(MISSING_BG);
lbl.setOpaque(true);
statisticsPane.add(lbl, constraints2);
lbl = new JLabel("False positives:");
lbl.setToolTipText("False positives:");
lbl.setBackground(FALSE_POSITIVE_BG);
lbl.setOpaque(true);
statisticsPane.add(lbl, constraints2);
// second column
constraints2.gridx++;
correctLbl = new JLabel("0");
statisticsPane.add(correctLbl, constraints2);
partiallyCorrectLbl = new JLabel("0");
statisticsPane.add(partiallyCorrectLbl, constraints2);
missingLbl = new JLabel("0");
statisticsPane.add(missingLbl, constraints2);
falsePozLbl = new JLabel("0");
statisticsPane.add(falsePozLbl, constraints2);
// third column
constraints2.gridx++;
constraints2.insets = new Insets(4, 30, 4, 4);
statisticsPane.add(Box.createGlue());
lbl = new JLabel("Strict:");
statisticsPane.add(lbl, constraints2);
lbl = new JLabel("Lenient:");
statisticsPane.add(lbl, constraints2);
lbl = new JLabel("Average:");
statisticsPane.add(lbl, constraints2);
// fourth column
constraints2.gridx++;
constraints2.insets = new Insets(4, 4, 4, 4);
lbl = new JLabel("Recall");
statisticsPane.add(lbl, constraints2);
recallStrictLbl = new JLabel("0.00");
statisticsPane.add(recallStrictLbl, constraints2);
recallLenientLbl = new JLabel("0.00");
statisticsPane.add(recallLenientLbl, constraints2);
recallAveLbl = new JLabel("0.00");
statisticsPane.add(recallAveLbl, constraints2);
// fifth column
constraints2.gridx++;
lbl = new JLabel("Precision");
statisticsPane.add(lbl, constraints2);
precisionStrictLbl = new JLabel("0.00");
statisticsPane.add(precisionStrictLbl, constraints2);
precisionLenientLbl = new JLabel("0.00");
statisticsPane.add(precisionLenientLbl, constraints2);
precisionAveLbl = new JLabel("0.00");
statisticsPane.add(precisionAveLbl, constraints2);
// sixth column
constraints2.gridx++;
lbl = new JLabel("F-measure");
lbl.setToolTipText("<html>F-measure =<br>" + " ((weight² + 1) * precision * recall)<br>" + " / (weight² * precision + recall))</html>");
statisticsPane.add(lbl, constraints2);
fmeasureStrictLbl = new JLabel("0.00");
statisticsPane.add(fmeasureStrictLbl, constraints2);
fmeasureLenientLbl = new JLabel("0.00");
statisticsPane.add(fmeasureLenientLbl, constraints2);
fmeasureAveLbl = new JLabel("0.00");
statisticsPane.add(fmeasureAveLbl, constraints2);
bottomTabbedPane.add("Statistics", statisticsPane);
// adjudication pane will be added to the bottom tabbed pane
JPanel adjudicationPane = new JPanel(new GridBagLayout());
constraints2 = new GridBagConstraints();
constraints2.insets = new Insets(2, 2, 2, 2);
// first row
constraints2.gridy = 0;
adjudicationPane.add(new JLabel("Target set:"), constraints2);
consensusASTextField = new JTextField("consensus", 15);
consensusASTextField.setToolTipText("Annotation set name where to copy the selected annotations");
adjudicationPane.add(consensusASTextField, constraints2);
// second row
constraints2.gridy++;
constraints2.gridx = 0;
copyToTargetSetAction = new CopyToTargetSetAction();
copyToTargetSetAction.setEnabled(false);
copyToConsensusBtn = new JButton(copyToTargetSetAction);
copyToConsensusBtn.setDisabledIcon(new RightArrowIcon(MainFrame.ICON_DIMENSION, true));
constraints2.gridwidth = 2;
adjudicationPane.add(copyToConsensusBtn, constraints2);
bottomTabbedPane.add("Adjudication", adjudicationPane);
JPanel bottomPanel = new JPanel(new GridBagLayout());
constraints2 = new GridBagConstraints();
constraints2.insets = new Insets(2, 2, 2, 2);
// add the bottom tabbed pane to the bottom panel
constraints2.gridx = 0;
constraints2.gridy = 0;
constraints2.gridheight = 3;
constraints2.anchor = GridBagConstraints.WEST;
bottomPanel.add(bottomTabbedPane, constraints2);
constraints2.gridheight = 1;
// status bar
constraints2.gridx++;
statusLabel = new JLabel();
statusLabel.setBackground(diffTable.getBackground());
constraints2.insets = new Insets(2, 6, 6, 2);
bottomPanel.add(statusLabel, constraints2);
// toolbar
JToolBar toolbar = new JToolBar();
toolbar.setFloatable(false);
if (!isStandalone) {
showDocumentAction = new ShowDocumentAction();
showDocumentAction.setEnabled(false);
showDocumentBtn = new JButton(showDocumentAction);
showDocumentBtn.setDisabledIcon(new DocumentIcon(MainFrame.ICON_DIMENSION, true));
showDocumentBtn.setToolTipText("Use first the \"Compare\"" + " button then select an annotation in the table.");
toolbar.add(showDocumentBtn);
}
htmlExportAction = new HTMLExportAction();
htmlExportAction.setEnabled(false);
htmlExportBtn = new JButton(htmlExportAction);
htmlExportBtn.setDisabledIcon(new DownIcon(MainFrame.ICON_DIMENSION, true));
htmlExportBtn.setToolTipText("Use first the \"Compare\" button.");
toolbar.add(htmlExportBtn);
if (!isStandalone) {
toolbar.add(new HelpAction());
}
constraints2.gridy++;
constraints2.fill = GridBagConstraints.NONE;
constraints2.anchor = GridBagConstraints.NORTHWEST;
bottomPanel.add(toolbar, constraints2);
// progress bar
progressBar = new JProgressBar();
progressBar.setMinimumSize(new Dimension(5, 5));
progressBar.setBackground(diffTable.getBackground());
progressBar.setOpaque(true);
constraints2.gridy++;
constraints2.anchor = GridBagConstraints.SOUTHWEST;
bottomPanel.add(progressBar, constraints2);
// add the bottom panel to the fourth row
constraints.gridy++;
constraints.gridx = 0;
constraints.gridwidth = GridBagConstraints.REMAINDER;
constraints.gridheight = GridBagConstraints.REMAINDER;
constraints.anchor = GridBagConstraints.WEST;
constraints.insets = new Insets(0, 0, 0, 0);
getContentPane().add(bottomPanel, constraints);
constraints.insets = new Insets(2, 2, 2, 2);
// set the background colour
Color background = diffTable.getBackground();
getContentPane().setBackground(background);
scroller.setBackground(background);
scroller.getViewport().setBackground(background);
statisticsPane.setBackground(background);
adjudicationPane.setBackground(background);
bottomPanel.setBackground(background);
bottomTabbedPane.setBackground(background);
featureslistModel = new DefaultListModel<String>();
featuresList = new JList<String>(featureslistModel);
featuresList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
keySetCombo.requestFocusInWindow();
}
Aggregations