Commit d0b68fb0 authored by Markus Krug's avatar Markus Krug

Merge branch 'redeWiedergabe_dev' into 'master'

Rede wiedergabe dev

See merge request !78
parents 39c64ed9 a116e8e2
Pipeline #12045 passed with stages
in 18 minutes and 52 seconds
......@@ -909,88 +909,148 @@ public class RedeWiedergabeView extends AEditorSubordinateViewPart {
}
// methods that are required by the view
public void createSpeaker() {
int counter = 0;
AnnotationFS selected = null;
if (editor.getSelectionOfVisibleAnnotations().size() > 0) {
for (AnnotationFS anno : editor.getSelectionOfVisibleAnnotations()) {
if (anno.getType().equals(speakerType)) {
selected = anno;
boolean speakerIDFlag = false;
for (AnnotationFS speaker : speakerList){
if (speaker.getFeatureValueAsString(speakerIDFeat) == null){
JFrame jFrame = new JFrame("Information");
JOptionPane.showMessageDialog(jFrame, "Please assign an ID to the speaker " + "\"" + speaker.getFeatureValueAsString(speakerFeat) + "\"" + ".", "Attention", JOptionPane.WARNING_MESSAGE);
speakerIDFlag = true;
}
}
if (speakerIDFlag == false)
{
//int counter = 0;
AnnotationFS selected = null;
if (editor.getSelectionOfVisibleAnnotations().size() > 0) {
for (AnnotationFS anno : editor.getSelectionOfVisibleAnnotations()) {
if (anno.getType().equals(speakerType)) {
selected = anno;
}
}
}
}
// remove vorschlag
CAS cas = editor.getCas();
Type t = speakerType;
// get the selection
// remove vorschlag
CAS cas = editor.getCas();
Type t = speakerType;
// get the selection
if (selected == null) {
if (selected == null) {
Point selection = editor.getActualSelectedText();
if (selection == null || selection.x == selection.y) {
return;
}
AnnotationFS anno = cas.createAnnotation(t, selection.x, selection.y);
anno.getFeatureValueAsString(speakerFeat);
String speakerFeatValue = anno.getFeatureValueAsString(speakerFeat);
speakerFeatValue = anno.getCoveredText();
updateAnnotation(anno, speakerFeat, speakerFeatValue, true);
for (AnnotationFS frame : frameList)
{
if (anno.getBegin() >= frame.getBegin() && anno.getEnd() <= frame.getEnd())
{
anno.getFeatureValueAsString(speakerFeat);
addAnnotation(anno);
updateAnnotation(anno, speakerIDFeat, frame.getFeatureValueAsString(frameIDFeat), true);
Point selection = editor.getActualSelectedText();
if (selection == null || selection.x == selection.y) {
return;
}
else
AnnotationFS anno = cas.createAnnotation(t, selection.x, selection.y);
anno.getFeatureValueAsString(speakerFeat);
String speakerFeatValue = anno.getFeatureValueAsString(speakerFeat);
speakerFeatValue = anno.getCoveredText();
updateAnnotation(anno, speakerFeat, speakerFeatValue, true);
addAnnotation(anno);
for (AnnotationFS frame : frameList)
{
counter++;
if (anno.getBegin() >= frame.getBegin() && anno.getEnd() <= frame.getEnd())
{
anno.getFeatureValueAsString(speakerFeat);
addAnnotation(anno);
updateAnnotation(anno, speakerIDFeat, frame.getFeatureValueAsString(frameIDFeat), true);
}
for (AnnotationFS stwr : stwrList){
if (anno.getBegin() >= stwr.getBegin() && anno.getEnd() <= stwr.getEnd())
{
anno.getFeatureValueAsString(speakerFeat);
addAnnotation(anno);
updateAnnotation(anno, speakerIDFeat, stwr.getFeatureValueAsString(stwrIDFeat), true);
}
}
if (counter == frameList.size())
{
JFrame jFrame = new JFrame("Information");
JOptionPane.showMessageDialog(jFrame, "Please mark a string in a frame.", "Attention", JOptionPane.WARNING_MESSAGE);
/*
else
{
counter++;
}
if (counter == frameList.size())
{
JFrame jFrame = new JFrame("Information");
JOptionPane.showMessageDialog(jFrame, "Please mark a string in a frame.", "Attention", JOptionPane.WARNING_MESSAGE);
}
*/
}
}
}
/*
Display.getCurrent().asyncExec(() -> {
/*
Display.getCurrent().asyncExec(() -> {
renewPage();
});
*/
renewPage();
});
*/
renewPage();
}
}
public void correctSpeakerExp(AnnotationFS selected)
public void createSpeakerOutsideFrame(AnnotationFS selected)
{
List<AnnotationFS> speakerSelection = editor.getCurrentSelectionOfType(speakerType);
List<AnnotationFS> expSelection = editor.getCurrentSelectionOfType(expressionType);
String concatenatedId = "";
if (speakerSelection != null && speakerSelection.size() > 0)
{
{
AnnotationFS anno = speakerSelection.get(0);
updateAnnotation(anno, speakerIDFeat, selected.getFeatureValueAsString(frameIDFeat), true);
if (anno.getFeatureValueAsString(speakerIDFeat) == null)
{
concatenatedId = selected.getFeatureValueAsString(frameIDFeat);
updateAnnotation(anno, speakerIDFeat, concatenatedId, true);
}else if (anno.getFeatureValueAsString(speakerIDFeat).matches(".*" + " " + selected.getFeatureValueAsString(frameIDFeat) + " " + ".*")
|| anno.getFeatureValueAsString(speakerIDFeat).matches(selected.getFeatureValueAsString(frameIDFeat) + " " + ".*" )
|| anno.getFeatureValueAsString(speakerIDFeat).matches(".*" + " " + selected.getFeatureValueAsString(frameIDFeat))
|| anno.getFeatureValueAsString(speakerIDFeat).matches(selected.getFeatureValueAsString(frameIDFeat))){
JFrame jFrame = new JFrame("Information");
JOptionPane.showMessageDialog(jFrame, "The speaker already has the ID " + selected.getFeatureValueAsString(frameIDFeat) + ".", "Attention", JOptionPane.WARNING_MESSAGE);
}else {
concatenatedId = anno.getFeatureValueAsString(speakerIDFeat) + " " + selected.getFeatureValueAsString(frameIDFeat);
updateAnnotation(anno, speakerIDFeat, concatenatedId, true);
}
}
if (expSelection != null && expSelection.size() > 0)
}
public void createSpeakerOutsideStwr(AnnotationFS selected)
{
List<AnnotationFS> speakerSelection = editor.getCurrentSelectionOfType(speakerType);
String concatenatedId = "";
if (speakerSelection != null && speakerSelection.size() > 0)
{
AnnotationFS anno = expSelection.get(0);
updateAnnotation(anno, expressionIDFeat, selected.getFeatureValueAsString(frameIDFeat), true);
}
AnnotationFS anno = speakerSelection.get(0);
if (anno.getFeatureValueAsString(speakerIDFeat) == null)
{
concatenatedId = selected.getFeatureValueAsString(stwrIDFeat);
updateAnnotation(anno, speakerIDFeat, concatenatedId, true);
}else if (anno.getFeatureValueAsString(speakerIDFeat).matches(".*" + " " + selected.getFeatureValueAsString(stwrIDFeat) + " " + ".*")
|| anno.getFeatureValueAsString(speakerIDFeat).matches(selected.getFeatureValueAsString(stwrIDFeat) + " " + ".*" )
|| anno.getFeatureValueAsString(speakerIDFeat).matches(".*" + " " + selected.getFeatureValueAsString(stwrIDFeat))
|| anno.getFeatureValueAsString(speakerIDFeat).matches(selected.getFeatureValueAsString(stwrIDFeat))){
JFrame jFrame = new JFrame("Information");
JOptionPane.showMessageDialog(jFrame, "The speaker already has the ID " + selected.getFeatureValueAsString(stwrIDFeat) + ".", "Attention", JOptionPane.WARNING_MESSAGE);
}else {
concatenatedId = anno.getFeatureValueAsString(speakerIDFeat) + " " + selected.getFeatureValueAsString(stwrIDFeat);
updateAnnotation(anno, speakerIDFeat, concatenatedId, true);
}
}
}
// methods that are required by the view
public void createExpression() {
int counter = 0;
int frameCounter = 0;
int repCounter = 0;
AnnotationFS selected = null;
if (editor.getSelectionOfVisibleAnnotations().size() > 0) {
for (AnnotationFS anno : editor.getSelectionOfVisibleAnnotations()) {
......@@ -1001,7 +1061,6 @@ public class RedeWiedergabeView extends AEditorSubordinateViewPart {
}
}
// remove vorschlag
CAS cas = editor.getCas();
Type t = expressionType;
// get the selection
......@@ -1018,34 +1077,56 @@ public class RedeWiedergabeView extends AEditorSubordinateViewPart {
expFeatValue = anno.getCoveredText();
updateAnnotation(anno, expressionFeat, expFeatValue, true);
for (AnnotationFS frame : frameList)
{
if (anno.getBegin() >= frame.getBegin() && anno.getEnd() <= frame.getEnd())
{
for (AnnotationFS frame : frameList){
if (anno.getBegin() >= frame.getBegin() && anno.getEnd() <= frame.getEnd()){
anno.getFeatureValueAsString(expressionFeat);
updateAnnotation(anno, expressionIDFeat, frame.getFeatureValueAsString(frameIDFeat), true);
addAnnotation(anno);
}
}
else
{
counter++;
}
if (counter == frameList.size())
frameCounter++;
}
/*
if (frameCounter == frameList.size())
{
JFrame jFrame = new JFrame("Information");
JOptionPane.showMessageDialog(jFrame, "Please mark a string in a frame.", "Attention", JOptionPane.WARNING_MESSAGE);
JOptionPane.showMessageDialog(jFrame, "Please mark a string in a frame or a reported STWR.", "Attention", JOptionPane.WARNING_MESSAGE);
}
*/
}
ArrayList<AnnotationFS> repAnnoList = getReportedAnno(stwrList);
for (AnnotationFS repAnno : repAnnoList){
if (anno.getBegin() >= repAnno.getBegin() && anno.getEnd() <= repAnno.getEnd()){
anno.getFeatureValueAsString(expressionFeat);
updateAnnotation(anno, expressionIDFeat, repAnno.getFeatureValueAsString(stwrIDFeat), true);
addAnnotation(anno);
}
else
{
repCounter++;
}
}
if (repCounter == repAnnoList.size() && frameCounter == frameList.size())
{
JFrame jFrame = new JFrame("Information");
JOptionPane.showMessageDialog(jFrame, "Please mark a string in a frame or in a reported STWR.", "Attention", JOptionPane.WARNING_MESSAGE);
}
}
/*
Display.getCurrent().asyncExec(() -> {
renewPage();
});
*/
renewPage();
}
public ArrayList<AnnotationFS> getReportedAnno(List<AnnotationFS>stwrList){
ArrayList<AnnotationFS> reportedList = new ArrayList<AnnotationFS>();
for (AnnotationFS stwr : stwrList){
if (stwr.getFeatureValueAsString(rTypeFeat).equals("reported")){
reportedList.add(stwr);
}
}
return reportedList;
}
public void createSpeech() {
ambigMediumDialog.speechFlag = false;
ambigMediumDialog.thoughtFlag = false;
......
......@@ -201,7 +201,7 @@ public class RwFrameTableComposite extends Composite{
{
IStructuredSelection sel = (IStructuredSelection) frameViewer.getSelection();
AnnotationFS selected = (AnnotationFS) sel.getFirstElement();
part.correctSpeakerExp(selected);
part.createSpeakerOutsideFrame(selected);
}
// small utility method
......
......@@ -80,7 +80,9 @@ public class RwSpeakerDrawingStrategy implements IAnnotationDrawingStrategy {
String feat = anno.getFeatureValueAsString(f);
if (feat != null && feat.trim().length() > 0) {
// Only draw if String not empty.
gc.drawString(anno.getFeatureValueAsString(f) + s, lastRect.x + lastRect.width - 1,
//gc.drawString(anno.getFeatureValueAsString(f) + s, lastRect.x + lastRect.width - 1,
// lastRect.y - FONTSIZE - 7);
gc.drawString(anno.getFeatureValueAsString(f) + s, lastRect.x-10 + lastRect.width - 1,
lastRect.y - FONTSIZE - 7);
}
}
......
......@@ -109,12 +109,12 @@ public class RwStwrTableComposite extends Composite{
createTableViewerColumn("Stwr", 45, 1, part::determineStwr);
createTableViewerColumn("Medium", 45, 2, part::determineMedium);
createTableViewerColumn("Type", 45, 3, part::determineRType);
createTableViewerColumn("Level", 45, 4, part::determineLevel);
createTableViewerColumn("NonFact", 45, 5, part::determineNonFact);
createTableViewerColumn("Prag", 45, 6, part::determinePrag);
createTableViewerColumn("Border", 45, 7, part::determineBorder);
createTableViewerColumn("Metaph", 45, 8, part::determineMetaph);
createTableViewerColumn("ID", 45, 9, part::determineStwrID);
createTableViewerColumn("ID", 45, 4, part::determineStwrID);
createTableViewerColumn("Level", 45, 5, part::determineLevel);
createTableViewerColumn("NonFact", 45, 6, part::determineNonFact);
createTableViewerColumn("Prag", 45, 7, part::determinePrag);
createTableViewerColumn("Border", 45, 8, part::determineBorder);
createTableViewerColumn("Metaph", 45, 9, part::determineMetaph);
createTableViewerColumn("Note", 45, 10, part::determineStwrNote);
}
......@@ -203,6 +203,8 @@ public class RwStwrTableComposite extends Composite{
// table got a key listener
stwrViewer.getTable().addListener(SWT.KeyDown, (Event e) -> handleTableKeyDown(e));
stwrViewer.getTable().addListener(SWT.MouseDoubleClick, (Event e) -> handleTableDoubleClick(e));
}
private void handleTableKeyDown(Event e) {
......@@ -252,6 +254,13 @@ public class RwStwrTableComposite extends Composite{
part.toggleMetaph(selectedAnnos);
}
}
private void handleTableDoubleClick (Event e)
{
IStructuredSelection sel = (IStructuredSelection) stwrViewer.getSelection();
AnnotationFS selected = (AnnotationFS) sel.getFirstElement();
part.createSpeakerOutsideStwr(selected);
}
// small utility method
private List<AnnotationFS> getSelectedAnnotationsFromTable() {
......
Markdown is supported
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