Search in sources :

Example 1 with BratSuggestionVisualizer

use of de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.BratSuggestionVisualizer in project webanno by webanno.

the class SuggestionViewPanel method updatePanel.

/**
 * @param aTarget
 *            the AJAX target.
 * @param aCurationContainer
 *            the container.
 * @param aAnnotationSelectionByUsernameAndAddress
 *            selections by user.
 * @param aCurationSegment
 *            the segment.
 * @throws UIMAException
 *             hum?
 * @throws ClassNotFoundException
 *             hum?
 * @throws IOException
 *             hum?
 * @throws AnnotationException
 *             hum?
 */
public void updatePanel(AjaxRequestTarget aTarget, CurationContainer aCurationContainer, Map<String, Map<Integer, AnnotationSelection>> aAnnotationSelectionByUsernameAndAddress, SourceListView aCurationSegment) throws UIMAException, ClassNotFoundException, IOException, AnnotationException {
    AnnotatorState state = aCurationContainer.getAnnotatorState();
    SourceDocument sourceDocument = state.getDocument();
    Map<String, JCas> jCases = new HashMap<>();
    // This is the CAS that the user can actively edit
    JCas annotatorCas = getAnnotatorCas(state, aAnnotationSelectionByUsernameAndAddress, sourceDocument, jCases);
    // We store the CAS that the user will edit as the "CURATION USER"
    jCases.put(CURATION_USER, annotatorCas);
    // get differing feature structures
    Map<String, Map<VID, AnnotationState>> annoStates = calcColors(state, aCurationSegment, annotatorCas, jCases);
    sentenceListView.visitChildren(BratSuggestionVisualizer.class, (v, visit) -> {
        BratSuggestionVisualizer vis = (BratSuggestionVisualizer) v;
        UserAnnotationSegment seg = vis.getModelObject();
        JCas jCas = jCases.get(seg.getUsername());
        // Set up coloring strategy
        ColoringStrategy curationColoringStrategy = makeColoringStrategy(annoStates.get(seg.getUsername()));
        // Create curation view for the current user
        try {
            seg.setCollectionData(getCollectionInformation(annotationService, aCurationContainer));
            seg.setDocumentResponse(render(jCas, state, curationColoringStrategy));
            seg.setAnnotatorState(state);
            seg.setSelectionByUsernameAndAddress(aAnnotationSelectionByUsernameAndAddress);
        } catch (IOException e) {
            error("Unable to render: " + e.getMessage());
            LOG.error("Unable to render", e);
        }
        vis.requestRender(aTarget);
    });
}
Also used : BratSuggestionVisualizer(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.BratSuggestionVisualizer) HashMap(java.util.HashMap) AnnotatorState(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState) SourceDocument(de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument) JCas(org.apache.uima.jcas.JCas) ColoringStrategy(de.tudarmstadt.ukp.clarin.webanno.api.annotation.coloring.ColoringStrategy) IOException(java.io.IOException) Map(java.util.Map) HashMap(java.util.HashMap) UserAnnotationSegment(de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.UserAnnotationSegment)

Aggregations

ColoringStrategy (de.tudarmstadt.ukp.clarin.webanno.api.annotation.coloring.ColoringStrategy)1 AnnotatorState (de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotatorState)1 SourceDocument (de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument)1 BratSuggestionVisualizer (de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.BratSuggestionVisualizer)1 UserAnnotationSegment (de.tudarmstadt.ukp.clarin.webanno.ui.curation.component.model.UserAnnotationSegment)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 JCas (org.apache.uima.jcas.JCas)1