Package org.apache.uima.caseditor.editor

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


  /**
   * Tests the {@link AnnotationStyle#equals(Object)} method.
   */
  @Test
  public void testEquals() {
    AnnotationStyle a = new AnnotationStyle("testType", AnnotationStyle.Style.BRACKET, new Color(
            255, 255, 0), 0);

    AnnotationStyle b = new AnnotationStyle("testType", AnnotationStyle.Style.BRACKET, new Color(
            255, 255, 0), 0);

    assertEquals(a, b);
  }
View Full Code Here


  /**
   * Test the {@link AnnotationStyle#hashCode()} method.
   *
   */
  public void testHashCode() {
    AnnotationStyle a = new AnnotationStyle("testType", AnnotationStyle.Style.BRACKET, new Color(
            255, 255, 0), 0);

    AnnotationStyle b = new AnnotationStyle("testType", AnnotationStyle.Style.BRACKET, new Color(
            255, 255, 0), 0);

    assertEquals(a.hashCode(), b.hashCode());
  }
View Full Code Here

  @Test
  public void testSerializeAndCreate() throws CoreException {
    DotCorpus original = new DotCorpus();
    original.setTypeSystemFilename("typesystem");
    original.addCasProcessorFolder("uima processor folder");
    original.setStyle(new AnnotationStyle("test", Style.BRACKET, new Color(255, 255, 0), 0));
    original.addCorpusFolder("corpus");

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    DotCorpusSerializer.serialize(original, out);
View Full Code Here

    IStructuredSelection selection = (IStructuredSelection) mTypeList.getSelection();

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

    return new AnnotationStyle(selectedType.getName(), AnnotationStyle.DEFAULT_STYLE,
            AnnotationStyle.DEFAULT_COLOR, mCurrentSelectedAnnotation.getLayer());
  }
View Full Code Here

  private void itemSelected() {
    IStructuredSelection selection = (IStructuredSelection) mTypeList.getSelection();

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

    AnnotationStyle style = mDotCorpusElement.getAnnotation(selectedType);

    mCurrentSelectedAnnotation = style;

    if (style == null) {
      style = new AnnotationStyle(selectedType.getName(), AnnotationStyle.DEFAULT_STYLE,
              AnnotationStyle.DEFAULT_COLOR, mCurrentSelectedAnnotation.getLayer());
    }

    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);
  }
View Full Code Here

      @Override
      public void update(ViewerCell cell) {

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

        AnnotationStyle style = mDotCorpusElement.getAnnotation(type);

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

    TypeSystem typeSytstem = mProject.getTypesystemElement().getTypeSystem();

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

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

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

    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) {
        if (mCurrentSelectedAnnotation == null) {
          mCurrentSelectedAnnotation = getDefaultAnnotation();
        }

        mCurrentSelectedAnnotation = new AnnotationStyle(
                mCurrentSelectedAnnotation.getAnnotation(), AnnotationStyle.Style
                        .valueOf(mStyleCombo.getText()), mCurrentSelectedAnnotation.getColor(),
                mCurrentSelectedAnnotation.getLayer());

        mDotCorpusElement.setStyle(mCurrentSelectedAnnotation);
      }

      public void widgetDefaultSelected(SelectionEvent e) {
        // 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) {
        if (mCurrentSelectedAnnotation == null) {
          mCurrentSelectedAnnotation = getDefaultAnnotation();
        }

        RGB colorRGB = mColorSelector.getColorValue();

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

        mCurrentSelectedAnnotation = new AnnotationStyle(
                mCurrentSelectedAnnotation.getAnnotation(), mCurrentSelectedAnnotation.getStyle(),
                color, mCurrentSelectedAnnotation.getLayer());

        mDotCorpusElement.setStyle(mCurrentSelectedAnnotation);
      }
    });

    Button 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) {
        if (mCurrentSelectedAnnotation == null) {
          mCurrentSelectedAnnotation = getDefaultAnnotation();
        }

        mCurrentSelectedAnnotation = new AnnotationStyle(
                mCurrentSelectedAnnotation.getAnnotation(), AnnotationStyle.Style
                        .valueOf(mStyleCombo.getText()), mCurrentSelectedAnnotation.getColor(),
                mCurrentSelectedAnnotation.getLayer() + 1);

        mDotCorpusElement.setStyle(mCurrentSelectedAnnotation);

        mTypeList.refresh(((IStructuredSelection) mTypeList.getSelection()).getFirstElement(),
                true);
      }
    });

    Button 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) {
        if (mCurrentSelectedAnnotation != null && mCurrentSelectedAnnotation.getLayer() - 1 >= 0) {
          mCurrentSelectedAnnotation = getDefaultAnnotation();

          mCurrentSelectedAnnotation = new AnnotationStyle(mCurrentSelectedAnnotation
                  .getAnnotation(), AnnotationStyle.Style.valueOf(mStyleCombo.getText()),
                  mCurrentSelectedAnnotation.getColor(), mCurrentSelectedAnnotation.getLayer() - 1);

          mDotCorpusElement.setStyle(mCurrentSelectedAnnotation);
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

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

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

        dotCorpus.setStyle(style);
      } else if (CAS_PROCESSOR_ELEMENT.equals(corporaChildElement.getNodeName())) {
        dotCorpus.addCasProcessorFolder(corporaChildElement
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

          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

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.