Search in sources :

Example 1 with ColorGenerator

use of gate.swing.ColorGenerator in project gate-core by GateNLP.

the class CorefEditor method initGUI.

/**
 * This method intiates the GUI for co-reference editor
 */
@Override
protected void initGUI() {
    // get a pointer to the textual view used for highlights
    Iterator<DocumentView> centralViewsIter = owner.getCentralViews().iterator();
    while (textView == null && centralViewsIter.hasNext()) {
        DocumentView aView = centralViewsIter.next();
        if (aView instanceof TextualDocumentView)
            textView = (TextualDocumentView) aView;
    }
    textPane = (JTextArea) ((JScrollPane) textView.getGUI()).getViewport().getView();
    highlighter = textPane.getHighlighter();
    chainToolTipAction = new ChainToolTipAction();
    chainToolTipTimer = new javax.swing.Timer(500, chainToolTipAction);
    chainToolTipTimer.setRepeats(false);
    newCorefAction = new NewCorefAction();
    newCorefActionTimer = new javax.swing.Timer(500, newCorefAction);
    newCorefActionTimer.setRepeats(false);
    colorGenerator = new ColorGenerator();
    // main Panel
    mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());
    // topPanel
    topPanel = new JPanel();
    topPanel.setLayout(new BorderLayout());
    // subPanel
    subPanel = new JPanel();
    subPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    // showAnnotations Button
    showAnnotations = new JToggleButton("Show");
    showAnnotations.addActionListener(this);
    // annotSets
    annotSets = new JComboBox<String>();
    annotSets.addActionListener(this);
    // get all the annotationSets
    Map<String, AnnotationSet> annotSetsMap = document.getNamedAnnotationSets();
    annotSetsModel = new DefaultComboBoxModel<String>();
    if (annotSetsMap != null) {
        String[] array = annotSetsMap.keySet().toArray(new String[annotSetsMap.keySet().size()]);
        for (int i = 0; i < array.length; i++) {
            annotSetsMap.get(array[i]).addAnnotationSetListener(this);
        }
        annotSetsModel = new DefaultComboBoxModel<String>(array);
    }
    document.getAnnotations().addAnnotationSetListener(this);
    annotSetsModel.insertElementAt(DEFAULT_ANNOTSET_NAME, 0);
    annotSets.setModel(annotSetsModel);
    // annotTypes
    annotTypesModel = new DefaultComboBoxModel<String>();
    annotTypes = new JComboBox<String>(annotTypesModel);
    annotTypes.addActionListener(this);
    subPanel.add(new JLabel("Sets : "));
    subPanel.add(annotSets);
    JPanel tempPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    tempPanel.add(new JLabel("Types : "));
    tempPanel.add(annotTypes);
    tempPanel.add(showAnnotations);
    // intialises the Data
    initData();
    // and creating the tree
    corefTree = new JTree(rootNode);
    corefTree.putClientProperty("JTree.lineStyle", "None");
    corefTree.setRowHeight(corefTree.getRowHeight() * 2);
    corefTree.setLargeModel(true);
    corefTree.setAutoscrolls(true);
    // corefTree.setRootVisible(false);
    // corefTree.setShowsRootHandles(false);
    corefTree.addMouseListener(new CorefTreeMouseListener());
    corefTree.setCellRenderer(new CorefTreeCellRenderer());
    mainPanel.add(topPanel, BorderLayout.NORTH);
    mainPanel.add(new JScrollPane(corefTree), BorderLayout.CENTER);
    topPanel.add(subPanel, BorderLayout.CENTER);
    topPanel.add(tempPanel, BorderLayout.SOUTH);
    // get the highlighter
    textPaneMouseListener = new TextPaneMouseListener();
    annotSets.setSelectedIndex(0);
    // finally show the tree
    // annotSetSelectionChanged();
    document.addDocumentListener(this);
    document.getFeatures().addFeatureMapListener(this);
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) AnnotationSet(gate.AnnotationSet) BorderLayout(java.awt.BorderLayout) JToggleButton(javax.swing.JToggleButton) JScrollPane(javax.swing.JScrollPane) ColorGenerator(gate.swing.ColorGenerator) JLabel(javax.swing.JLabel) Point(java.awt.Point) JTree(javax.swing.JTree)

Aggregations

AnnotationSet (gate.AnnotationSet)1 ColorGenerator (gate.swing.ColorGenerator)1 BorderLayout (java.awt.BorderLayout)1 FlowLayout (java.awt.FlowLayout)1 Point (java.awt.Point)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1 JScrollPane (javax.swing.JScrollPane)1 JToggleButton (javax.swing.JToggleButton)1 JTree (javax.swing.JTree)1