javax.swing.text.StyledDocument.render()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(10.4k)|赞(0)|评价(0)|浏览(113)

本文整理了Java中javax.swing.text.StyledDocument.render()方法的一些代码示例,展示了StyledDocument.render()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StyledDocument.render()方法的具体详情如下:
包路径:javax.swing.text.StyledDocument
类名称:StyledDocument
方法名:render

StyledDocument.render介绍

暂无

代码示例

代码示例来源:origin: org.netbeans.api/org-openide-text

int renderToInt() {
  if (doc != null) {
    doc.render(this);
  }
  return retInt;
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

int renderToInt() {
  doc.render(this);
  return retInt;
}

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

int renderToInt() {
  doc.render(this);
  return retInt;
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

/** Registers line, but only after obtaining the lock of the document.
   * This is a fix to issue 37767 as this creates ordering of locks (first 
   * of all obtain documentrenderer, then ask for any other locks like
   * Line.Set.lines.
   *
   * @param line line we want to register
   * @return the line or some line that already was registered
   */
  private Line safelyRegisterLine (final Line line) {
    class DocumentRenderer implements Runnable {
      public Line result;
      
      public void run () {
        result = DocumentLine.Set.super.registerLine (line);
      }
    }
    DocumentRenderer renderer = new DocumentRenderer ();
    listener.doc.render (renderer);
    return renderer.result;
  }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

/** Registers line, but only after obtaining the lock of the document.
   * This is a fix to issue 37767 as this creates ordering of locks (first 
   * of all obtain documentrenderer, then ask for any other locks like
   * Line.Set.lines.
   *
   * @param line line we want to register
   * @return the line or some line that already was registered
   */
  private Line safelyRegisterLine (final Line line) {
    class DocumentRenderer implements Runnable {
      public Line result;
      
      public void run () {
        result = DocumentLine.Set.super.registerLine (line);
      }
    }
    DocumentRenderer renderer = new DocumentRenderer ();
    listener.doc.render (renderer);
    return renderer.result;
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-navigation

private static Position getPosition(final StyledDocument doc, final int offset) {
  class Impl implements Runnable {
    private Position pos;
    @Override
    public void run() {
      if (offset < 0 || offset >= doc.getLength()) {
        return;
      }
      try {
        pos = doc.createPosition(offset - NbDocument.findLineColumn(doc, offset));
      } catch (BadLocationException ex) {
        //should not happen?
        Logger.getLogger(BaseAnnotation.class.getName()).log(Level.FINE, null, ex);
      }
    }
  }
  Impl i = new Impl();
  doc.render(i);
  
  if (i.pos == null) {
    i.pos = new Position() {
      @Override
      public int getOffset() {
        return -1;
      }
    };
  }
  return i.pos;
}

代码示例来源:origin: org.netbeans.api/org-openide-text

void render() {
  StyledDocument d = mgr.getDoc();
  Object prev = DOCUMENT.get();
  try {
    if (d != null) {
      DOCUMENT.set(d);
      d.render(this);
    } else {
      DOCUMENT.set(mgr);
      this.run();
    }
  } finally {
    DOCUMENT.set(prev);
  }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

void render() {
  StyledDocument d = mgr.getDoc ();
  Object prev = DOCUMENT.get ();
  try {
    if (d != null) {
      DOCUMENT.set (d);
      d.render(this);
    } else {
      DOCUMENT.set (mgr);
      this.run();
    }
  } finally {
    DOCUMENT.set (prev);
  }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

void render() {
  StyledDocument d = mgr.getDoc ();
  Object prev = DOCUMENT.get ();
  try {
    if (d != null) {
      DOCUMENT.set (d);
      d.render(this);
    } else {
      DOCUMENT.set (mgr);
      this.run();
    }
  } finally {
    DOCUMENT.set (prev);
  }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

public String getText() {
  final StyledDocument doc = position.getCloneableEditorSupport ().getDocument ();
  // document is not opened
  if (doc == null)
    return null;
  final String[] retStringArray = new String[1];
  doc.render(new Runnable() { public void run() {
  // Part of #33165 - the following code is wrapped by doc.render()
  try {
    retStringArray[0] = doc.getText(position.getOffset(), getLength());
  } catch (BadLocationException ex) {
    ErrorManager.getDefault ().notify ( ErrorManager.EXCEPTION, ex);
    retStringArray[0] = null;
  }
  // End of the code wrapped by doc.render()
  }});
  return retStringArray[0];
}

代码示例来源:origin: org.netbeans.api/org-openide-text

public DocLockedRun(int type, StyledDocument doc, int intValue, boolean readLock) {
  this.type = type;
  this.intResult = intValue;
  if (!readLock && (doc instanceof NbDocument.WriteLockable)) {
    ((NbDocument.WriteLockable) doc).runAtomic(this);
  } else {
    if (readLock && doc != null) {
      doc.render(this);
    } else {
      // if the document is not one of "NetBeans ready"
      // that supports locking we do not have many
      // chances to do something. Maybe check for AbstractDocument
      // and call writeLock using reflection, but better than
      // that, let's leave this simple for now and wait for
      // bug reports (if any appear)
      run();
    }
  }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

public String getText() {
  final StyledDocument doc = position.getCloneableEditorSupport ().getDocument ();
  // document is not opened
  if (doc == null)
    return null;
  final String[] retStringArray = new String[1];
  doc.render(new Runnable() { public void run() {
  // Part of #33165 - the following code is wrapped by doc.render()
  try {
    retStringArray[0] = doc.getText(position.getOffset(), getLength());
  } catch (BadLocationException ex) {
    ErrorManager.getDefault ().notify ( ErrorManager.EXCEPTION, ex);
    retStringArray[0] = null;
  }
  // End of the code wrapped by doc.render()
  }});
  return retStringArray[0];
}

代码示例来源:origin: org.netbeans.api/org-openide-text

/** Registers line, but only after obtaining the lock of the document.
   * This is a fix to issue 37767 as this creates ordering of locks (first
   * of all obtain documentrenderer, then ask for any other locks like
   * Line.Set.lines.
   *
   * @param line line we want to register
   * @return the line or some line that already was registered
   */
  private Line safelyRegisterLine(final Line line) {
    assert line != null;
    class DocumentRenderer implements Runnable {
      public Line result;
      public void run() {
        result = DocumentLine.Set.super.registerLine(line);
      }
    }
    StyledDocument doc = listener.support.getDocument();
    DocumentRenderer renderer = new DocumentRenderer();
    if (doc != null) {
      doc.render(renderer);
    } else {
      renderer.run();
    }
    return renderer.result;
  }
}

代码示例来源:origin: org.netbeans.api/org-openide-text

public void run() {
    try {
      synchronized (getAnnotations()) {
        if (!anno.isInDocument()) {
          anno.setInDocument(true);
          // #33165 - find position that is surely at begining of line
          FindAnnotationPosition fap = new FindAnnotationPosition(doc, pos.getPosition());
          doc.render(fap);
          NbDocument.addAnnotation(doc, fap.getAnnotationPosition(), -1, anno);
        }
      }
    } catch (IOException ex) {
      Logger.getLogger(DocumentLine.class.getName()).log(Level.WARNING, null, ex);
    }
  }
});

代码示例来源:origin: org.netbeans.api/org-openide-text

/** Remove annotation to this Annotatable class
 * @param anno annotation which will be detached from this class  */
@Override
protected void removeAnnotation(final Annotation anno) {
  super.removeAnnotation(anno);
  final StyledDocument doc = position.getCloneableEditorSupport().getDocument();
  // document is not opened and so no annotation is attached to it
  if (doc == null) {
    return;
  }
  position.getCloneableEditorSupport().prepareDocument().waitFinished();
  doc.render(new Runnable() {
    public void run() {
      synchronized (getAnnotations()) {
        if (anno.isInDocument()) {
          anno.setInDocument(false);
          NbDocument.removeAnnotation(doc, anno);
        }
      }
    }
  });
}

代码示例来源:origin: org.netbeans.api/org-openide-text

/** Remove annotation to this Annotatable class
 * @param anno annotation which will be detached from this class  */
@Override
protected void removeAnnotation(final Annotation anno) {
  super.removeAnnotation(anno);
  final StyledDocument doc = pos.getCloneableEditorSupport().getDocument();
  // document is not opened and so no annotation is attached to it
  if (doc == null) {
    return;
  }
  pos.getCloneableEditorSupport().prepareDocument().waitFinished();
  doc.render(new Runnable() {
    public void run() {
      synchronized (getAnnotations()) {
        if (anno.isInDocument()) {
          anno.setInDocument(false);
          NbDocument.removeAnnotation(doc, anno);
        }
      }
    }
  });
}

代码示例来源:origin: org.netbeans.api/org-openide-text

/** Add annotation to this Annotatable class
 * @param anno annotation which will be attached to this class */
@Override
protected void addAnnotation(final Annotation anno) {
  super.addAnnotation(anno);
  final StyledDocument doc = position.getCloneableEditorSupport().getDocument();
  // document is not opened and so the annotation will be added to document later
  if (doc == null) {
    return;
  }
  position.getCloneableEditorSupport().prepareDocument().waitFinished();
  doc.render(new Runnable() {
    public void run() {
      try {
        synchronized (getAnnotations()) {
          if (!anno.isInDocument()) {
            anno.setInDocument(true);
            NbDocument.addAnnotation(doc, position.getPosition(), length, anno);
          }
        }
      } catch (IOException ex) {
        Logger.getLogger(DocumentLine.class.getName()).log(Level.WARNING, null, ex);
      }
    }
  });
}

代码示例来源:origin: org.netbeans.api/org-openide-text

/** Add annotation to this Annotatable class
 * @param anno annotation which will be attached to this class */
@Override
protected void addAnnotation(final Annotation anno) {
  super.addAnnotation(anno);
  final StyledDocument doc = pos.getCloneableEditorSupport().getDocument();
  // document is not opened and so the annotation will be added to document later
  if (doc == null) {
    return;
  }
  pos.getCloneableEditorSupport().prepareDocument().waitFinished();
  doc.render(new Runnable() {
    public void run() {
      try {
        synchronized (getAnnotations()) {
          if (!anno.isInDocument()) {
            anno.setInDocument(true);
            // #33165 - find position that is surely at begining of line
            FindAnnotationPosition fap = new FindAnnotationPosition(doc, pos.getPosition());
            doc.render(fap);
            NbDocument.addAnnotation(doc, fap.getAnnotationPosition(), -1, anno);
          }
        }
      } catch (IOException ex) {
        Logger.getLogger(DocumentLine.class.getName()).log(Level.WARNING, null, ex);
      }
    }
  });
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

/** Add annotation to this Annotatable class
 * @param anno annotation which will be attached to this class */
protected void addAnnotation(Annotation anno) {
  super.addAnnotation(anno);
  StyledDocument doc = pos.getCloneableEditorSupport ().getDocument ();
  
  // document is not opened and so the annotation will be added to document later
  if (doc == null)
    return;
  pos.getCloneableEditorSupport().prepareDocument().waitFinished();
  
  try {
    if (!anno.isInDocument()) {
      anno.setInDocument(true);
      // #33165 - find position that is surely at begining of line
      FindAnnotationPosition fap = new FindAnnotationPosition(doc, pos.getPosition());
      doc.render(fap);
      NbDocument.addAnnotation (doc, fap.getAnnotationPosition(), -1, anno);
    }
  }  catch (IOException ex) {
    ErrorManager.getDefault ().notify ( ErrorManager.EXCEPTION, ex);
  }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

/** Add annotation to this Annotatable class
 * @param anno annotation which will be attached to this class */
protected void addAnnotation(Annotation anno) {
  super.addAnnotation(anno);
  StyledDocument doc = pos.getCloneableEditorSupport ().getDocument ();
  
  // document is not opened and so the annotation will be added to document later
  if (doc == null)
    return;
  pos.getCloneableEditorSupport().prepareDocument().waitFinished();
  
  try {
    if (!anno.isInDocument()) {
      anno.setInDocument(true);
      // #33165 - find position that is surely at begining of line
      FindAnnotationPosition fap = new FindAnnotationPosition(doc, pos.getPosition());
      doc.render(fap);
      NbDocument.addAnnotation (doc, fap.getAnnotationPosition(), -1, anno);
    }
  }  catch (IOException ex) {
    ErrorManager.getDefault ().notify ( ErrorManager.EXCEPTION, ex);
  }
}

相关文章