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
Pipeline #7476 passed with stages
in 17 minutes and 47 seconds
......@@ -21,6 +21,7 @@ import de.uniwue.mk.athen.textwidget.drawingstrategies.IAnnotationDrawingStrateg
import de.uniwue.mk.athen.textwidget.struct.TypeStyleDataStructure;
import de.uniwue.mk.kall.athen.widget.editor.AnnotationEditorWidget;
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;
public class StyleChangingDialog extends Dialog {
......@@ -104,8 +105,14 @@ public class StyleChangingDialog extends Dialog {
Color color = new Color(parent.getDisplay(), rgb);
colorLabel.setBackground(color);
// TODO this is never read!
// update TSDS
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
editor.styleChanged(tsds);
......@@ -144,9 +151,14 @@ public class StyleChangingDialog extends Dialog {
@Override
public void widgetSelected(SelectionEvent e) {
// 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))) {
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().setDrawingStrategy(strat);
......@@ -155,26 +167,28 @@ public class StyleChangingDialog extends Dialog {
else if (e.getSource().toString().contains(String.valueOf(EPaintingStyles.UNDERLINE))) {
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().setDrawingStrategy(drawingStrat);
}
else if (e.getSource().toString().contains(String.valueOf(EPaintingStyles.BRACKET))) {
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().setDrawingStrategy(strat);
}
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(
tsds.getAnnotationType(), tsds.getStyle().getStyle().foreground.getRGBA(),
tsds.getAnnotationType(), foreGround != null ? foreGround.getRGBA() : null,
tsds.getStyle().getStyle().background.getRGBA(), EDrawingType.RECTANGLE_BORDER);
tsds.getStyle().setDrawingStrategy(strat);
}
// Inform listener
editor.styleChanged(tsds);
}
......
......@@ -1124,8 +1124,8 @@ public class AnnotationEditorWidget extends Composite {
// default is backgroundDrawingStrategy
// TODO the anno browser labelprovider color seems off!!
AnnoStyle style = new AnnoStyle(DrawingTypeStrategyFactory.getNaiveSpanDrawingStrategy(next, null,
actual.getRGBA(), EDrawingType.RECTANGLE_FILLED), styleRange);
AnnoStyle style = new AnnoStyle(DrawingTypeStrategyFactory.getNaiveSpanDrawingStrategy(next,
actual.getRGBA(), actual.getRGBA(), EDrawingType.RECTANGLE_FILLED), styleRange);
// AnnoStyle style = new AnnoStyle(strat, styleRange);
TypeStyleDataStructure asds = new TypeStyleDataStructure(next, style, 0);
......
package de.uniwue.kalimachos.coref.paintingStrategies;
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;
import org.apache.uima.cas.Feature;
import org.apache.uima.cas.text.AnnotationFS;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
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.kall.drawingstrategies.generic.struct.DrawingStruct;
import de.uniwue.mk.kall.editorPainting.util.EditorDrawingUtil;
......
package de.uniwue.mk.kall.drawingstrategies.generic;
import org.apache.uima.cas.text.AnnotationFS;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import de.uniwue.mk.athen.textwidget.drawingstrategies.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
public int getPreferredLineHeight(AnnotationFS anno) {
......
......@@ -7,6 +7,7 @@ import javax.sound.midi.Synthesizer;
import org.apache.uima.cas.Feature;
import org.apache.uima.cas.text.AnnotationFS;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import de.uniwue.mk.athen.textwidget.widget.ATHENEditorWidget;
......@@ -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 {
}
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;
import org.apache.uima.cas.Type;
import org.apache.uima.cas.text.AnnotationFS;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import de.uniwue.mk.athen.textwidget.widget.ATHENEditorWidget;
......@@ -75,4 +76,11 @@ public class TypeDrawingStrategy {
}
public void changeColor(Color bg, Color fg) {
if(spanDrawingStruct!=null){
spanDrawingStruct.changeColor(bg,fg);
}
}
}
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