private void actionGotoPage(AjaxRequestTarget aTarget, Form<?> aForm) throws Exception { AnnotatorState state = getModelObject(); JCas jcas = getEditorCas(); List<Sentence> sentences = new ArrayList<>(select(jcas, Sentence.class)); int selectedSentence = gotoPageTextField.getModelObject(); selectedSentence = Math.min(selectedSentence, sentences.size()); gotoPageTextField.setModelObject(selectedSentence); state.setFirstVisibleUnit(sentences.get(selectedSentence - 1)); state.setFocusUnitIndex(selectedSentence); actionRefreshDocument(aTarget); }
private void actionGotoPage(AjaxRequestTarget aTarget, Form<?> aForm) throws Exception { AnnotatorState state = getModelObject(); JCas jcas = getEditorCas(); List<Sentence> sentences = new ArrayList<>(select(jcas, Sentence.class)); int selectedSentence = gotoPageTextField.getModelObject(); selectedSentence = Math.min(selectedSentence, sentences.size()); gotoPageTextField.setModelObject(selectedSentence); state.setFirstVisibleUnit(sentences.get(selectedSentence - 1)); state.setFocusUnitIndex(selectedSentence); actionRefreshDocument(aTarget); }
private void actionGotoPage(AjaxRequestTarget aTarget, Form<?> aForm) throws Exception { AnnotatorState state = getModelObject(); JCas jcas = getEditorCas(); List<Sentence> sentences = new ArrayList<>(select(jcas, Sentence.class)); int selectedSentence = gotoPageTextField.getModelObject(); selectedSentence = Math.min(selectedSentence, sentences.size()); gotoPageTextField.setModelObject(selectedSentence); state.setFirstVisibleUnit(sentences.get(selectedSentence - 1)); state.setFocusUnitIndex(selectedSentence); actionRefreshDocument(aTarget); }
private void updateSentenceNumber(JCas aJCas, int aAddress) { AnnotatorState state = getModelObject(); Sentence sentence = selectByAddr(aJCas, Sentence.class, aAddress); state.setFirstVisibleUnit(sentence); state.setFocusUnitIndex(WebAnnoCasUtil.getSentenceNumber(aJCas, sentence.getBegin())); }
private void updateSentenceNumber(JCas aJCas, int aAddress) { AnnotatorState state = getModelObject(); Sentence sentence = selectByAddr(aJCas, Sentence.class, aAddress); state.setFirstVisibleUnit(sentence); state.setFocusUnitIndex(WebAnnoCasUtil.getSentenceNumber(aJCas, sentence.getBegin())); }
private void actionGotoPage(AjaxRequestTarget aTarget, Form<?> aForm) throws Exception { AnnotatorState state = getModelObject(); JCas editorCas = getEditorCas(); List<Sentence> sentences = new ArrayList<>(select(editorCas, Sentence.class)); int selectedSentence = gotoPageTextField.getModelObject(); selectedSentence = Math.min(selectedSentence, sentences.size()); gotoPageTextField.setModelObject(selectedSentence); state.setFirstVisibleUnit(sentences.get(selectedSentence - 1)); state.setFocusUnitIndex(selectedSentence); SuggestionBuilder builder = new SuggestionBuilder(casStorageService, documentService, correctionDocumentService, curationDocumentService, annotationService, userRepository); curationContainer = builder.buildCurationContainer(state); setCurationSegmentBeginEnd(editorCas); curationContainer.setBratAnnotatorModel(state); update(aTarget); aTarget.add(gotoPageTextField); annotationEditor.requestRender(aTarget); }
private void actionGotoPage(AjaxRequestTarget aTarget, Form<?> aForm) throws Exception { AnnotatorState state = getModelObject(); JCas editorCas = getEditorCas(); List<Sentence> sentences = new ArrayList<>(select(editorCas, Sentence.class)); int selectedSentence = gotoPageTextField.getModelObject(); selectedSentence = Math.min(selectedSentence, sentences.size()); gotoPageTextField.setModelObject(selectedSentence); state.setFirstVisibleUnit(sentences.get(selectedSentence - 1)); state.setFocusUnitIndex(selectedSentence); SuggestionBuilder builder = new SuggestionBuilder(casStorageService, documentService, correctionDocumentService, curationDocumentService, annotationService, userRepository); curationContainer = builder.buildCurationContainer(state); setCurationSegmentBeginEnd(editorCas); curationContainer.setBratAnnotatorModel(state); update(aTarget); aTarget.add(gotoPageTextField); annotationEditor.requestRender(aTarget); }
private void actionGotoPage(AjaxRequestTarget aTarget, Form<?> aForm) throws Exception { AnnotatorState state = getModelObject(); JCas editorCas = getEditorCas(); List<Sentence> sentences = new ArrayList<>(select(editorCas, Sentence.class)); int selectedSentence = gotoPageTextField.getModelObject(); selectedSentence = Math.min(selectedSentence, sentences.size()); gotoPageTextField.setModelObject(selectedSentence); state.setFirstVisibleUnit(sentences.get(selectedSentence - 1)); state.setFocusUnitIndex(selectedSentence); SuggestionBuilder builder = new SuggestionBuilder(casStorageService, documentService, correctionDocumentService, curationDocumentService, annotationService, userRepository); curationContainer = builder.buildCurationContainer(state); setCurationSegmentBeginEnd(editorCas); curationContainer.setBratAnnotatorModel(state); update(aTarget); aTarget.add(gotoPageTextField); annotationEditor.requestRender(aTarget); }
/** * Show the next document if it exists, starting in a certain token position */ @Deprecated public void actionShowSelectedDocumentByTokenPosition(AjaxRequestTarget aTarget, SourceDocument aDocument, int aTokenNumber) throws IOException { actionShowSelectedDocument(aTarget, aDocument); AnnotatorState state = getModelObject(); JCas jCas = getEditorCas(); Collection<Token> tokenCollection = JCasUtil.select(jCas, Token.class); Token[] tokens = tokenCollection.toArray(new Token[tokenCollection.size()]); int sentenceNumber = WebAnnoCasUtil.getSentenceNumber(jCas, tokens[aTokenNumber].getBegin()); Sentence sentence = WebAnnoCasUtil.getSentence(jCas, tokens[aTokenNumber].getBegin()); getGotoPageTextField().setModelObject(sentenceNumber); state.setFirstVisibleUnit(sentence); state.setFocusUnitIndex(sentenceNumber); actionRefreshDocument(aTarget); }
@Override public void onClick(AjaxRequestTarget aTarget) { final SourceListView curationViewItem = getModelObject(); curationView = curationViewItem; fSn = 0; try { JCas jCas = curationDocumentService.readCurationCas(state.getDocument()); updateCurationView(CurationPanel.this.getModelObject(), curationViewItem, aTarget, jCas); updatePanel(aTarget, CurationPanel.this.getModelObject()); state.setFocusUnitIndex(curationViewItem.getSentenceNumber()); } catch (UIMAException e) { error("Error: " + ExceptionUtils.getRootCauseMessage(e)); } catch (ClassNotFoundException | AnnotationException | IOException e) { error("Error: " + e.getMessage()); } } }
@Override public void onClick(AjaxRequestTarget aTarget) { final SourceListView curationViewItem = getModelObject(); curationView = curationViewItem; fSn = 0; try { JCas jCas = curationDocumentService.readCurationCas(state.getDocument()); updateCurationView(CurationPanel.this.getModelObject(), curationViewItem, aTarget, jCas); updatePanel(aTarget, CurationPanel.this.getModelObject()); state.setFocusUnitIndex(curationViewItem.getSentenceNumber()); } catch (UIMAException e) { error("Error: " + ExceptionUtils.getRootCauseMessage(e)); } catch (ClassNotFoundException | AnnotationException | IOException e) { error("Error: " + e.getMessage()); } } }
/** * Show the next document if it exists, starting in a certain begin offset */ public void actionShowSelectedDocument(AjaxRequestTarget aTarget, SourceDocument aDocument, int aBegin, int aEnd) throws IOException { boolean switched = actionShowSelectedDocument(aTarget, aDocument); AnnotatorState state = getModelObject(); // If the document was not switched and the requested offset is already visible on screen, // then there is no need to change the screen contents if (switched || !(state.getWindowBeginOffset() <= aBegin && aEnd <= state.getWindowEndOffset())) { JCas jCas = getEditorCas(); int sentenceNumber = WebAnnoCasUtil.getSentenceNumber(jCas, aBegin); Sentence sentence = WebAnnoCasUtil.getSentence(jCas, aBegin); getGotoPageTextField().setModelObject(sentenceNumber); state.setFirstVisibleUnit(sentence); state.setFocusUnitIndex(sentenceNumber); } actionRefreshDocument(aTarget); }
state.setFocusUnitIndex(sentenceNumber); state.getDocument().setSentenceAccessed(sentenceNumber);
private void createSpan(String spanType, AnnotatorState aBModel, JCas aMergeJCas, AnnotationDocument aAnnotationDocument, int aAddress) throws IOException, UIMAException, ClassNotFoundException, AnnotationException { JCas clickedJCas = getJCas(aBModel, aAnnotationDocument); AnnotationFS fsClicked = selectByAddr(clickedJCas, aAddress); if (isCorefType(fsClicked)) { throw new AnnotationException("Coreference Annotation not supported in curation"); } long layerId = TypeUtil.getLayerId(spanType); AnnotationLayer layer = annotationService.getLayer(layerId); MergeCas.addSpanAnnotation(aBModel, annotationService, layer, aMergeJCas, fsClicked, layer.isAllowStacking()); writeEditorCas(aBModel, aMergeJCas); // update timestamp int sentenceNumber = getSentenceNumber(clickedJCas, fsClicked.getBegin()); aBModel.setFocusUnitIndex(sentenceNumber); aBModel.getDocument().setSentenceAccessed(sentenceNumber); if (aBModel.getPreferences().isScrollPage()) { Sentence sentence = selectSentenceAt(aMergeJCas, aBModel.getFirstVisibleUnitBegin(), aBModel.getFirstVisibleUnitEnd()); sentence = findWindowStartCenteringOnSelection(aMergeJCas, sentence, fsClicked.getBegin(), aBModel.getProject(), aBModel.getDocument(), aBModel.getPreferences().getWindowSize()); aBModel.setFirstVisibleUnit(sentence); } }
private void createSpan(String spanType, AnnotatorState aBModel, JCas aMergeJCas, AnnotationDocument aAnnotationDocument, int aAddress) throws IOException, UIMAException, ClassNotFoundException, AnnotationException { JCas clickedJCas = getJCas(aBModel, aAnnotationDocument); AnnotationFS fsClicked = selectByAddr(clickedJCas, aAddress); if (isCorefType(fsClicked)) { throw new AnnotationException("Coreference Annotation not supported in curation"); } long layerId = TypeUtil.getLayerId(spanType); AnnotationLayer layer = annotationService.getLayer(layerId); MergeCas.addSpanAnnotation(aBModel, annotationService, layer, aMergeJCas, fsClicked, layer.isAllowStacking()); writeEditorCas(aBModel, aMergeJCas); // update timestamp int sentenceNumber = getSentenceNumber(clickedJCas, fsClicked.getBegin()); aBModel.setFocusUnitIndex(sentenceNumber); aBModel.getDocument().setSentenceAccessed(sentenceNumber); if (aBModel.getPreferences().isScrollPage()) { Sentence sentence = selectSentenceAt(aMergeJCas, aBModel.getFirstVisibleUnitBegin(), aBModel.getFirstVisibleUnitEnd()); sentence = findWindowStartCenteringOnSelection(aMergeJCas, sentence, fsClicked.getBegin(), aBModel.getProject(), aBModel.getDocument(), aBModel.getPreferences().getWindowSize()); aBModel.setFirstVisibleUnit(sentence); } }
bModel.setFocusUnitIndex(sentenceNumber);
bModel.setFocusUnitIndex(sentenceNumber);
state.setFocusUnitIndex(sentenceNumber); state.getDocument().setSentenceAccessed(sentenceNumber);
state.setFocusUnitIndex(sentenceNumber); state.getDocument().setSentenceAccessed(sentenceNumber);