Package org.apache.uima.caseditor.editor

Examples of org.apache.uima.caseditor.editor.AnnotationStyle


          drawingLayer = Integer.parseInt(drawingLayerString);
        } catch (NumberFormatException e) {
          drawingLayer = 0;
        }

        AnnotationStyle style = new AnnotationStyle(type, AnnotationStyle.Style
                .valueOf(styleString), color, drawingLayer, drawingConfigString);

        dotCorpus.setStyle(style);
      } else if (CAS_PROCESSOR_ELEMENT.equals(corporaChildElement.getNodeName())) {
        dotCorpus.addCasProcessorFolder(corporaChildElement
View Full Code Here


  }

  protected abstract AnnotationStyle getAnnotationStyle(Type type);
 
  private final AnnotationStyle getWorkingCopyAnnotationStyle(Type type) {
    AnnotationStyle style = changedStyles.get(type);
   
    if (style == null)
      style = getAnnotationStyle(type);
   
    return style;
View Full Code Here

    Type selectedType = (Type) selection.getFirstElement();

    if( selectedType != null) {
     
      AnnotationStyle style = getWorkingCopyAnnotationStyle(selectedType);
 
      if (style == null) {
        style = new AnnotationStyle(selectedType.getName(), AnnotationStyle.DEFAULT_STYLE,
                AnnotationStyle.DEFAULT_COLOR, 0);
      }
 
      mStyleCombo.setText(style.getStyle().name());
      mStyleCombo.setEnabled(true);
 
      Color color = style.getColor();
      mColorSelector.setColorValue(new RGB(color.getRed(), color.getGreen(), color.getBlue()));
      mColorSelector.setEnabled(true);

      moveLayerUpButton.setEnabled(true);
      moveLayerDownButton.setEnabled(true);
View Full Code Here

      @Override
      public void update(ViewerCell cell) {

        Type type = (Type) cell.getElement();

        AnnotationStyle style = getWorkingCopyAnnotationStyle(type);

        cell.setText(Integer.toString(style.getLayer()));
      }});

    Type annotationType = typeSystem.getType(CAS.TYPE_NAME_ANNOTATION);

    List<Type> types = typeSystem.getProperlySubsumedTypes(annotationType);

    for (Type type : types) {
      // inserts objects with type Type
      mTypeList.add(type);
    }
   
    mTypeList.add(annotationType);
   
    mTypeList.addSelectionChangedListener(new ISelectionChangedListener() {

      public void selectionChanged(SelectionChangedEvent event) {
        itemSelected();
      }
    });
   
    Composite settingsComposite = new Composite(base, SWT.NONE);

    GridLayout settingsLayout = new GridLayout();
    settingsLayout.numColumns = 2;
    settingsComposite.setLayout(settingsLayout);

    // text style combo
    Label styleText = new Label(settingsComposite, SWT.READ_ONLY);

    styleText.setText("Style:");

    // style combo
    mStyleCombo = new Combo(settingsComposite, SWT.READ_ONLY | SWT.DROP_DOWN);
    mStyleCombo.setEnabled(false);
    mStyleCombo.addSelectionListener(new SelectionListener() {
      public void widgetSelected(SelectionEvent e) {
       
        AnnotationStyle style = getWorkingCopyAnnotationStyle(getSelectedType());
       
        AnnotationStyle newStyle = new AnnotationStyle(style.getAnnotation(), AnnotationStyle.Style
                .valueOf(mStyleCombo.getText()), style.getColor(), style.getLayer(), style.getConfiguration());
       
        updateCustomStyleControl(newStyle, getSelectedType());
       
        // Is there a nice way to do this ?!
        if (styleConfigurationWidget.isVisible()) {
          String configString = styleConfigurationWidget.getConfiguration();
       
          if (configString != null) {
            newStyle = new AnnotationStyle(newStyle.getAnnotation(), newStyle.getStyle(),
                newStyle.getColor(), newStyle.getLayer(), configString);
          }
        }
       
        setAnnotationStyle(newStyle);
      }
       

      public void widgetDefaultSelected(SelectionEvent e) {
        // called when enter is pressed, not needed
      }

    });
    AnnotationStyle.Style possibleStyles[] = AnnotationStyle.Style.values();

    for (AnnotationStyle.Style style : possibleStyles) {
      mStyleCombo.add(style.name());
    }

    // text color label
    Label colorText = new Label(settingsComposite, SWT.NONE);
    colorText.setText("Color:");

    mColorSelector = new ColorSelector(settingsComposite);
    mColorSelector.setEnabled(false);
    mColorSelector.addListener(new IPropertyChangeListener() {
      public void propertyChange(PropertyChangeEvent event) {
        AnnotationStyle style = getWorkingCopyAnnotationStyle( getSelectedType());

        RGB colorRGB = mColorSelector.getColorValue();

        Color color = new Color(colorRGB.red, colorRGB.green, colorRGB.blue);

        setAnnotationStyle(new AnnotationStyle(
                style.getAnnotation(), style.getStyle(),
                color, style.getLayer(), style.getConfiguration()));
      }
    });

    moveLayerUpButton = new Button(settingsComposite, SWT.NONE);
    moveLayerUpButton.setText("Move layer up");
    GridDataFactory.fillDefaults().span(2, 1).applyTo(moveLayerUpButton);
    moveLayerUpButton.addSelectionListener(new SelectionListener() {

      public void widgetDefaultSelected(SelectionEvent e) {
      }

      public void widgetSelected(SelectionEvent e) {
        AnnotationStyle style = getWorkingCopyAnnotationStyle(getSelectedType());

        setAnnotationStyle(new AnnotationStyle(
                style.getAnnotation(), AnnotationStyle.Style.valueOf(mStyleCombo.getText()),
                style.getColor(), style.getLayer() + 1, style.getConfiguration()));

        mTypeList.update(getSelectedType(), null);
      }
    });

    moveLayerDownButton = new Button(settingsComposite, SWT.NONE);
    moveLayerDownButton.setText("Move layer down");
    GridDataFactory.fillDefaults().span(2, 1).applyTo(moveLayerDownButton);

    moveLayerDownButton.addSelectionListener(new SelectionListener() {

      public void widgetDefaultSelected(SelectionEvent e) {
      }

      public void widgetSelected(SelectionEvent e) {
       
        AnnotationStyle style = getWorkingCopyAnnotationStyle(getSelectedType());

        if (style.getLayer() - 1 >= 0) {
          setAnnotationStyle(new AnnotationStyle(style
                  .getAnnotation(), AnnotationStyle.Style.valueOf(mStyleCombo.getText()),
                  style.getColor(), style.getLayer() - 1, style.getConfiguration()));

          mTypeList.update(getSelectedType(), null);
        }
      }
    });

    // Insert style dependent configuration widget
    styleConfigurationWidget = new TagStyleConfigWidget(settingsComposite);
    GridDataFactory.fillDefaults().span(2, 1).applyTo(styleConfigurationWidget);
    styleConfigurationWidget.setVisible(false);
    styleConfigurationWidget.addListener(new CustomStyleConfigChangeListener() {
      public void styleChanged(String configuration) {
        AnnotationStyle style = getWorkingCopyAnnotationStyle(getSelectedType());
       
        setAnnotationStyle(new AnnotationStyle(style.getAnnotation(),
                style.getStyle(), style.getColor(), style.getLayer(), configuration));
      }
    });
   
    // There is always at least the AnnotationFS type
    mTypeList.getTable().select(0);
View Full Code Here

      AnnotationTypeNode typeNode = (AnnotationTypeNode) element;
     
      Type type = typeNode.getAnnotationType();
     
      // TODO: Get this information trough the editor ... its easier
      AnnotationStyle style = editor.getAnnotationStyle(type);
     
      if (TYPE_NAME_COLUMN == columnIndex) {
        return type.getShortName().trim();
      }
      else if (STYLE_NAME_COLUMN == columnIndex) {
        return style.getStyle().toString();
      }
      else {
        throw new IllegalStateException("Unkown column!");
      }
    }
View Full Code Here

     
      AnnotationTypeNode typeNode = (AnnotationTypeNode) element;
     
      Type type = typeNode.getAnnotationType();
     
      AnnotationStyle style = editor.getAnnotationStyle(type);
     
      return new Color(Display.getCurrent(), style.getColor().getRed(),
              style.getColor().getGreen(), style.getColor().getBlue());
    }
View Full Code Here

      typeNameToColorMap.remove(style.getAnnotation());
      newStyles.add(style);
    }
   
    for (Map.Entry<String, Color> entry : typeNameToColorMap.entrySet()) {
      newStyles.add(new AnnotationStyle(entry.getKey(), AnnotationStyle.Style.BACKGROUND,
              entry.getValue(), 0));
    }
   
    return Collections.unmodifiableSet(newStyles);
  }
View Full Code Here

   *
   * @param type
   * @return the requested style or null if none
   */
  public AnnotationStyle getAnnotation(Type type) {
    AnnotationStyle style = mStyleMap.get(type.getName());

    if (style == null) {
      style = new AnnotationStyle(type.getName(), AnnotationStyle.DEFAULT_STYLE,
              AnnotationStyle.DEFAULT_COLOR, 0);
    }

    return style;
  }
View Full Code Here

    }
  }

  private Image updateIcon(Type type) {
    AnnotationStyle style = editor.getAnnotationStyle(type);
    Color fg = new Color(Display.getCurrent(), 0, 0, 0);
    Color bg = new Color(Display.getCurrent(), style.getColor().getRed(), style.getColor()
            .getGreen(), style.getColor().getBlue());

    PaletteData paletteData = new PaletteData(new RGB[] { bg.getRGB(), fg.getRGB() });
    ImageData imageData = new ImageData(40, 40, 1, paletteData);

    Image image = new Image(Display.getCurrent(), imageData);
    GC gc = new GC(image);

    String styleString = style.getStyle().name().substring(0, 2);
    Point p = gc.stringExtent(styleString);

    gc.dispose();
    image.dispose();
View Full Code Here

      typeNameToColorMap.remove(style.getAnnotation());
      newStyles.add(style);
    }
   
    for (Map.Entry<String, Color> entry : typeNameToColorMap.entrySet()) {
      newStyles.add(new AnnotationStyle(entry.getKey(), AnnotationStyle.Style.BACKGROUND,
              entry.getValue(), 0));
    }
   
    return Collections.unmodifiableSet(newStyles);
  }
View Full Code Here

TOP

Related Classes of org.apache.uima.caseditor.editor.AnnotationStyle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.