Skip to content
Snippets Groups Projects
Commit 53ed9a22 authored by Markus Krug's avatar Markus Krug
Browse files

stylechanging dialog should now be able to change features accordingly

as well as the colors
parent c4059af3
No related branches found
No related tags found
No related merge requests found
Pipeline #
Showing
with 58 additions and 11 deletions
...@@ -21,6 +21,7 @@ import de.uniwue.mk.athen.textwidget.drawingstrategies.IAnnotationDrawingStrateg ...@@ -21,6 +21,7 @@ import de.uniwue.mk.athen.textwidget.drawingstrategies.IAnnotationDrawingStrateg
import de.uniwue.mk.athen.textwidget.struct.TypeStyleDataStructure; import de.uniwue.mk.athen.textwidget.struct.TypeStyleDataStructure;
import de.uniwue.mk.kall.athen.widget.editor.AnnotationEditorWidget; import de.uniwue.mk.kall.athen.widget.editor.AnnotationEditorWidget;
import de.uniwue.mk.kall.drawingstrategies.generic.DrawingTypeStrategyFactory; import de.uniwue.mk.kall.drawingstrategies.generic.DrawingTypeStrategyFactory;
import de.uniwue.mk.kall.drawingstrategies.generic.GenericDrawingStrategy;
import de.uniwue.mk.kall.drawingstrategies.generic.struct.EDrawingType; import de.uniwue.mk.kall.drawingstrategies.generic.struct.EDrawingType;
public class StyleChangingDialog extends Dialog { public class StyleChangingDialog extends Dialog {
...@@ -104,8 +105,14 @@ public class StyleChangingDialog extends Dialog { ...@@ -104,8 +105,14 @@ public class StyleChangingDialog extends Dialog {
Color color = new Color(parent.getDisplay(), rgb); Color color = new Color(parent.getDisplay(), rgb);
colorLabel.setBackground(color); colorLabel.setBackground(color);
// TODO this is never read!
// update TSDS // update TSDS
tsds.getStyle().getStyle().background = color; tsds.getStyle().getStyle().background = color;
IAnnotationDrawingStrategy drawingStrategy = tsds.getStyle().getDrawingStrategy();
if (drawingStrategy != null && drawingStrategy instanceof GenericDrawingStrategy) {
GenericDrawingStrategy gds = (GenericDrawingStrategy) drawingStrategy;
gds.changeColor(color, color);
}
// inform listener // inform listener
editor.styleChanged(tsds); editor.styleChanged(tsds);
...@@ -144,9 +151,14 @@ public class StyleChangingDialog extends Dialog { ...@@ -144,9 +151,14 @@ public class StyleChangingDialog extends Dialog {
@Override @Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
// BackgroundStyle // BackgroundStyle
Color foreGround = tsds.getStyle().getStyle().foreground;
if (foreGround == null) {
// use the background
foreGround = tsds.getStyle().getStyle().background;
}
if (e.getSource().toString().contains(String.valueOf(EPaintingStyles.BACKGROUND))) { if (e.getSource().toString().contains(String.valueOf(EPaintingStyles.BACKGROUND))) {
IAnnotationDrawingStrategy strat = DrawingTypeStrategyFactory.getNaiveSpanDrawingStrategy( IAnnotationDrawingStrategy strat = DrawingTypeStrategyFactory.getNaiveSpanDrawingStrategy(
tsds.getAnnotationType(), tsds.getStyle().getStyle().foreground.getRGBA(), tsds.getAnnotationType(), foreGround != null ? foreGround.getRGBA() : null,
tsds.getStyle().getStyle().background.getRGBA(), EDrawingType.RECTANGLE_FILLED); tsds.getStyle().getStyle().background.getRGBA(), EDrawingType.RECTANGLE_FILLED);
tsds.getStyle().setDrawingStrategy(strat); tsds.getStyle().setDrawingStrategy(strat);
...@@ -155,26 +167,28 @@ public class StyleChangingDialog extends Dialog { ...@@ -155,26 +167,28 @@ public class StyleChangingDialog extends Dialog {
else if (e.getSource().toString().contains(String.valueOf(EPaintingStyles.UNDERLINE))) { else if (e.getSource().toString().contains(String.valueOf(EPaintingStyles.UNDERLINE))) {
IAnnotationDrawingStrategy drawingStrat = DrawingTypeStrategyFactory.getNaiveSpanDrawingStrategy( IAnnotationDrawingStrategy drawingStrat = DrawingTypeStrategyFactory.getNaiveSpanDrawingStrategy(
tsds.getAnnotationType(), tsds.getStyle().getStyle().foreground.getRGBA(), tsds.getAnnotationType(), foreGround != null ? foreGround.getRGBA() : null,
tsds.getStyle().getStyle().background.getRGBA(), EDrawingType.UNDERLINED); tsds.getStyle().getStyle().background.getRGBA(), EDrawingType.UNDERLINED);
tsds.getStyle().setDrawingStrategy(drawingStrat); tsds.getStyle().setDrawingStrategy(drawingStrat);
} }
else if (e.getSource().toString().contains(String.valueOf(EPaintingStyles.BRACKET))) { else if (e.getSource().toString().contains(String.valueOf(EPaintingStyles.BRACKET))) {
IAnnotationDrawingStrategy strat = DrawingTypeStrategyFactory.getNaiveSpanDrawingStrategy( IAnnotationDrawingStrategy strat = DrawingTypeStrategyFactory.getNaiveSpanDrawingStrategy(
tsds.getAnnotationType(), tsds.getStyle().getStyle().foreground.getRGBA(), tsds.getAnnotationType(), foreGround != null ? foreGround.getRGBA() : null,
tsds.getStyle().getStyle().background.getRGBA(), EDrawingType.BRACKET); tsds.getStyle().getStyle().background.getRGBA(), EDrawingType.BRACKET);
tsds.getStyle().setDrawingStrategy(strat); tsds.getStyle().setDrawingStrategy(strat);
} }
else if (e.getSource().toString().contains(String.valueOf(EPaintingStyles.BOX))) { else if (e.getSource().toString().contains(String.valueOf(EPaintingStyles.BOX))) {
System.out.println(tsds.getAnnotationType().getName());
System.out.println(tsds.getStyle().getStyle().background);
System.out.println(tsds.getStyle().getStyle().foreground);
IAnnotationDrawingStrategy strat = DrawingTypeStrategyFactory.getNaiveSpanDrawingStrategy( IAnnotationDrawingStrategy strat = DrawingTypeStrategyFactory.getNaiveSpanDrawingStrategy(
tsds.getAnnotationType(), tsds.getStyle().getStyle().foreground.getRGBA(), tsds.getAnnotationType(), foreGround != null ? foreGround.getRGBA() : null,
tsds.getStyle().getStyle().background.getRGBA(), EDrawingType.RECTANGLE_BORDER); tsds.getStyle().getStyle().background.getRGBA(), EDrawingType.RECTANGLE_BORDER);
tsds.getStyle().setDrawingStrategy(strat); tsds.getStyle().setDrawingStrategy(strat);
} }
// Inform listener // Inform listener
editor.styleChanged(tsds); editor.styleChanged(tsds);
} }
......
...@@ -1124,8 +1124,8 @@ public class AnnotationEditorWidget extends Composite { ...@@ -1124,8 +1124,8 @@ public class AnnotationEditorWidget extends Composite {
// default is backgroundDrawingStrategy // default is backgroundDrawingStrategy
// TODO the anno browser labelprovider color seems off!! // TODO the anno browser labelprovider color seems off!!
AnnoStyle style = new AnnoStyle(DrawingTypeStrategyFactory.getNaiveSpanDrawingStrategy(next, null, AnnoStyle style = new AnnoStyle(DrawingTypeStrategyFactory.getNaiveSpanDrawingStrategy(next,
actual.getRGBA(), EDrawingType.RECTANGLE_FILLED), styleRange); actual.getRGBA(), actual.getRGBA(), EDrawingType.RECTANGLE_FILLED), styleRange);
// AnnoStyle style = new AnnoStyle(strat, styleRange); // AnnoStyle style = new AnnoStyle(strat, styleRange);
TypeStyleDataStructure asds = new TypeStyleDataStructure(next, style, 0); TypeStyleDataStructure asds = new TypeStyleDataStructure(next, style, 0);
......
package de.uniwue.kalimachos.coref.paintingStrategies; package de.uniwue.kalimachos.coref.paintingStrategies;
public enum EPaintingStyles { public enum EPaintingStyles {
BACKGROUND, BOX, BRACKET, ONE_FEATURE, MULTI_FEATURE, NAMEDENTITY, UNDERLINE; BACKGROUND, BOX, BRACKET, UNDERLINE;
......
...@@ -2,13 +2,10 @@ package de.uniwue.mk.kall.drawingstrategies.generic; ...@@ -2,13 +2,10 @@ package de.uniwue.mk.kall.drawingstrategies.generic;
import org.apache.uima.cas.Feature; import org.apache.uima.cas.Feature;
import org.apache.uima.cas.text.AnnotationFS; import org.apache.uima.cas.text.AnnotationFS;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Display;
import de.uniwue.mk.athen.textwidget.drawingstrategies.IAnnotationDrawingStrategy;
import de.uniwue.mk.athen.textwidget.struct.TypeStyleDataStructure;
import de.uniwue.mk.athen.textwidget.widget.ATHENEditorWidget; import de.uniwue.mk.athen.textwidget.widget.ATHENEditorWidget;
import de.uniwue.mk.kall.drawingstrategies.generic.struct.DrawingStruct; import de.uniwue.mk.kall.drawingstrategies.generic.struct.DrawingStruct;
import de.uniwue.mk.kall.editorPainting.util.EditorDrawingUtil; import de.uniwue.mk.kall.editorPainting.util.EditorDrawingUtil;
......
package de.uniwue.mk.kall.drawingstrategies.generic; package de.uniwue.mk.kall.drawingstrategies.generic;
import org.apache.uima.cas.text.AnnotationFS; import org.apache.uima.cas.text.AnnotationFS;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.GC;
import de.uniwue.mk.athen.textwidget.drawingstrategies.IAnnotationDrawingStrategy; import de.uniwue.mk.athen.textwidget.drawingstrategies.IAnnotationDrawingStrategy;
...@@ -22,6 +23,12 @@ public class GenericDrawingStrategy implements IAnnotationDrawingStrategy{ ...@@ -22,6 +23,12 @@ public class GenericDrawingStrategy implements IAnnotationDrawingStrategy{
} }
public void changeColor(Color bg, Color fg){
if(typeDrawingStruct!=null){
typeDrawingStruct.changeColor(bg,fg);
}
}
@Override @Override
public int getPreferredLineHeight(AnnotationFS anno) { public int getPreferredLineHeight(AnnotationFS anno) {
......
...@@ -7,6 +7,7 @@ import javax.sound.midi.Synthesizer; ...@@ -7,6 +7,7 @@ import javax.sound.midi.Synthesizer;
import org.apache.uima.cas.Feature; import org.apache.uima.cas.Feature;
import org.apache.uima.cas.text.AnnotationFS; import org.apache.uima.cas.text.AnnotationFS;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.GC;
import de.uniwue.mk.athen.textwidget.widget.ATHENEditorWidget; import de.uniwue.mk.athen.textwidget.widget.ATHENEditorWidget;
...@@ -86,6 +87,13 @@ public class FeatureDrawingStrategy { ...@@ -86,6 +87,13 @@ public class FeatureDrawingStrategy {
} }
public void changeColor(Color bg, Color fg) {
if(defaultDrawingStrategy!=null){
defaultDrawingStrategy.changeColor(bg,fg);
}
}
......
...@@ -86,4 +86,17 @@ public class FeatureValueDrawingStategy { ...@@ -86,4 +86,17 @@ public class FeatureValueDrawingStategy {
} }
public void changeColor(Color bg, Color fg) {
if (drawingStruct != null) {
if (fg != null) {
drawingStruct.setForeGroundColor(fg.getRGBA());
}
if (bg != null) {
drawingStruct.setBackGroundColor(bg.getRGBA());
}
}
}
} }
...@@ -5,6 +5,7 @@ import java.util.List; ...@@ -5,6 +5,7 @@ import java.util.List;
import org.apache.uima.cas.Type; import org.apache.uima.cas.Type;
import org.apache.uima.cas.text.AnnotationFS; import org.apache.uima.cas.text.AnnotationFS;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.GC;
import de.uniwue.mk.athen.textwidget.widget.ATHENEditorWidget; import de.uniwue.mk.athen.textwidget.widget.ATHENEditorWidget;
...@@ -75,4 +76,11 @@ public class TypeDrawingStrategy { ...@@ -75,4 +76,11 @@ public class TypeDrawingStrategy {
} }
public void changeColor(Color bg, Color fg) {
if(spanDrawingStruct!=null){
spanDrawingStruct.changeColor(bg,fg);
}
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment