Package org.apache.uima.caseditor.core.model.dotcorpus

Examples of org.apache.uima.caseditor.core.model.dotcorpus.DotCorpus


   *          internal use only
   */
  private DotCorpusElement(IFile resource, NlpProject nlpProject) {
    mResource = resource;
    mNlpProject = nlpProject;
    mDotCorpus = new DotCorpus();
  }
View Full Code Here


                                    .toPortableString())));

            if (styleFile.exists()) {
              InputStream styleFileIn = null;
              ;
              DotCorpus dotCorpus = null;
              try {
                styleFileIn = styleFile.getContents();
                dotCorpus = DotCorpusSerializer.parseDotCorpus(styleFileIn);

              } finally {
                if (styleFileIn != null)
                  try {
                    styleFileIn.close();
                  } catch (IOException e) {
                    CasEditorPlugin.log(e);
                  }
              }

              if (dotCorpus != null) {
                tsPrefStore = new PreferenceStore(prefFile.getName());
                for (AnnotationStyle style : dotCorpus.getAnnotationStyles()) {
                  AnnotationStyle.putAnnotatationStyleToStore(tsPrefStore, style);
                }

                for (String shownType : dotCorpus.getShownTypes()) {
                  tsPrefStore.putValue(shownType + ".isShown", "true");
                }

                ByteArrayOutputStream prefOut = new ByteArrayOutputStream();
                try {
View Full Code Here

              }
             
              IFile typeSystemFile = null;
              if (dotCorpusIn != null) {
                try {
                  DotCorpus dotCorpus = DotCorpusSerializer.parseDotCorpus(dotCorpusIn);
                 
                  if (dotCorpus.getTypeSystemFileName() != null)
                      typeSystemFile = project.getFile(dotCorpus.getTypeSystemFileName());
                }
                finally {
                  try {
                    dotCorpusIn.close();
                  }
View Full Code Here

   *          internal use only
   */
  private DotCorpusElement(IFile resource, NlpProject nlpProject) {
    mResource = resource;
    mNlpProject = nlpProject;
    mDotCorpus = new DotCorpus();
  }
View Full Code Here

  /**
   *
   * @throws CoreException
   */
  void createDotCorpus() throws CoreException {
    DotCorpus dotCorpus = new DotCorpus();

    dotCorpus.addCorpusFolder(mCorpusFolder.getName());
    dotCorpus.addCasProcessorFolder(mProcessorFolder.getName());
    dotCorpus.setTypeSystemFilename(mTypesystem.getName());

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    DotCorpusSerializer.serialize(dotCorpus, out);

    InputStream in = new ByteArrayInputStream(out.toByteArray());
View Full Code Here

              }
             
              IFile typeSystemFile = null;
              if (dotCorpusIn != null) {
                try {
                  DotCorpus dotCorpus = DotCorpusSerializer.parseDotCorpus(dotCorpusIn);
                 
                  if (dotCorpus.getTypeSystemFileName() != null)
                      typeSystemFile = project.getFile(dotCorpus.getTypeSystemFileName());
                }
                finally {
                  try {
                    dotCorpusIn.close();
                  }
View Full Code Here

                                    .toPortableString())));

            if (styleFile.exists()) {
              InputStream styleFileIn = null;
              ;
              DotCorpus dotCorpus = null;
              try {
                styleFileIn = styleFile.getContents();
                dotCorpus = DotCorpusSerializer.parseDotCorpus(styleFileIn);

              } finally {
                if (styleFileIn != null)
                  try {
                    styleFileIn.close();
                  } catch (IOException e) {
                    CasEditorPlugin.log(e);
                  }
              }

              if (dotCorpus != null) {
                tsPrefStore = new PreferenceStore(prefFile.getName());
                for (AnnotationStyle style : dotCorpus.getAnnotationStyles()) {
                  AnnotationStyle.putAnnotatationStyleToStore(tsPrefStore, style);
                }

                for (String shownType : dotCorpus.getShownTypes()) {
                  tsPrefStore.putValue(shownType + ".isShown", "true");
                }

                ByteArrayOutputStream prefOut = new ByteArrayOutputStream();
                try {
View Full Code Here

          // added or removed to the type system
         
          IFile styleFile = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(
                  getStyleFileForTypeSystem(typeSystemFile.getFullPath().toPortableString())));
         
          DotCorpus dotCorpus = styles.get(styleFile.getFullPath().toPortableString());
         
          if (dotCorpus == null) {
            if (styleFile.exists()) {
             InputStream styleFileIn = null;;
             try {
               styleFileIn = styleFile.getContents();
               dotCorpus = DotCorpusSerializer.parseDotCorpus(styleFileIn);
             }
             finally {
               if (styleFileIn != null)
                try {
                  styleFileIn.close();
                } catch (IOException e) {
                  CasEditorPlugin.log(e);
                }
             }
            }
           
            if (dotCorpus == null) {
              dotCorpus = new DotCorpus();
             
              // Initialize colors
              CAS cas = DocumentUimaImpl.getVirginCAS(typeSystemFile);
              TypeSystem ts = cas.getTypeSystem();
             
              Collection<AnnotationStyle> defaultStyles = dotCorpus.getAnnotationStyles();
             
              Collection<AnnotationStyle> newStyles = DefaultColors.assignColors(ts, defaultStyles);
             
              for (AnnotationStyle style : newStyles) {
               dotCorpus.setStyle(style);
              }
            }
           
            styles.put(styleFile.getFullPath().toPortableString(), dotCorpus);
          }
View Full Code Here

  }

  private void saveStyles(Object element) {
    String styleId = getStyleFileForTypeSystem(getTypesystemId(element));
   
    DotCorpus style = styles.get(styleId);
   
    // serialize ...
    IFile dotCorpusFile = ResourcesPlugin.getWorkspace().getRoot().getFile(
            Path.fromPortableString(styleId));
   
View Full Code Here

    if (nlpElement != null) {
      return nlpElement.getNlpProject().getDotCorpus().getAnnotation(type);
    }
    else {
      DotCorpus dotCorpus = getStyle(element);
     
      return dotCorpus.getAnnotation(type);
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.uima.caseditor.core.model.dotcorpus.DotCorpus

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.