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

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

本文整理了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

  1. int renderToInt() {
  2. if (doc != null) {
  3. doc.render(this);
  4. }
  5. return retInt;
  6. }

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

  1. int renderToInt() {
  2. doc.render(this);
  3. return retInt;
  4. }

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

  1. int renderToInt() {
  2. doc.render(this);
  3. return retInt;
  4. }

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

  1. /** Registers line, but only after obtaining the lock of the document.
  2. * This is a fix to issue 37767 as this creates ordering of locks (first
  3. * of all obtain documentrenderer, then ask for any other locks like
  4. * Line.Set.lines.
  5. *
  6. * @param line line we want to register
  7. * @return the line or some line that already was registered
  8. */
  9. private Line safelyRegisterLine (final Line line) {
  10. class DocumentRenderer implements Runnable {
  11. public Line result;
  12. public void run () {
  13. result = DocumentLine.Set.super.registerLine (line);
  14. }
  15. }
  16. DocumentRenderer renderer = new DocumentRenderer ();
  17. listener.doc.render (renderer);
  18. return renderer.result;
  19. }
  20. }

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

  1. /** Registers line, but only after obtaining the lock of the document.
  2. * This is a fix to issue 37767 as this creates ordering of locks (first
  3. * of all obtain documentrenderer, then ask for any other locks like
  4. * Line.Set.lines.
  5. *
  6. * @param line line we want to register
  7. * @return the line or some line that already was registered
  8. */
  9. private Line safelyRegisterLine (final Line line) {
  10. class DocumentRenderer implements Runnable {
  11. public Line result;
  12. public void run () {
  13. result = DocumentLine.Set.super.registerLine (line);
  14. }
  15. }
  16. DocumentRenderer renderer = new DocumentRenderer ();
  17. listener.doc.render (renderer);
  18. return renderer.result;
  19. }
  20. }

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

  1. private static Position getPosition(final StyledDocument doc, final int offset) {
  2. class Impl implements Runnable {
  3. private Position pos;
  4. @Override
  5. public void run() {
  6. if (offset < 0 || offset >= doc.getLength()) {
  7. return;
  8. }
  9. try {
  10. pos = doc.createPosition(offset - NbDocument.findLineColumn(doc, offset));
  11. } catch (BadLocationException ex) {
  12. //should not happen?
  13. Logger.getLogger(BaseAnnotation.class.getName()).log(Level.FINE, null, ex);
  14. }
  15. }
  16. }
  17. Impl i = new Impl();
  18. doc.render(i);
  19. if (i.pos == null) {
  20. i.pos = new Position() {
  21. @Override
  22. public int getOffset() {
  23. return -1;
  24. }
  25. };
  26. }
  27. return i.pos;
  28. }

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

  1. void render() {
  2. StyledDocument d = mgr.getDoc();
  3. Object prev = DOCUMENT.get();
  4. try {
  5. if (d != null) {
  6. DOCUMENT.set(d);
  7. d.render(this);
  8. } else {
  9. DOCUMENT.set(mgr);
  10. this.run();
  11. }
  12. } finally {
  13. DOCUMENT.set(prev);
  14. }
  15. }

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

  1. void render() {
  2. StyledDocument d = mgr.getDoc ();
  3. Object prev = DOCUMENT.get ();
  4. try {
  5. if (d != null) {
  6. DOCUMENT.set (d);
  7. d.render(this);
  8. } else {
  9. DOCUMENT.set (mgr);
  10. this.run();
  11. }
  12. } finally {
  13. DOCUMENT.set (prev);
  14. }
  15. }

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

  1. void render() {
  2. StyledDocument d = mgr.getDoc ();
  3. Object prev = DOCUMENT.get ();
  4. try {
  5. if (d != null) {
  6. DOCUMENT.set (d);
  7. d.render(this);
  8. } else {
  9. DOCUMENT.set (mgr);
  10. this.run();
  11. }
  12. } finally {
  13. DOCUMENT.set (prev);
  14. }
  15. }

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

  1. public String getText() {
  2. final StyledDocument doc = position.getCloneableEditorSupport ().getDocument ();
  3. // document is not opened
  4. if (doc == null)
  5. return null;
  6. final String[] retStringArray = new String[1];
  7. doc.render(new Runnable() { public void run() {
  8. // Part of #33165 - the following code is wrapped by doc.render()
  9. try {
  10. retStringArray[0] = doc.getText(position.getOffset(), getLength());
  11. } catch (BadLocationException ex) {
  12. ErrorManager.getDefault ().notify ( ErrorManager.EXCEPTION, ex);
  13. retStringArray[0] = null;
  14. }
  15. // End of the code wrapped by doc.render()
  16. }});
  17. return retStringArray[0];
  18. }

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

  1. public DocLockedRun(int type, StyledDocument doc, int intValue, boolean readLock) {
  2. this.type = type;
  3. this.intResult = intValue;
  4. if (!readLock && (doc instanceof NbDocument.WriteLockable)) {
  5. ((NbDocument.WriteLockable) doc).runAtomic(this);
  6. } else {
  7. if (readLock && doc != null) {
  8. doc.render(this);
  9. } else {
  10. // if the document is not one of "NetBeans ready"
  11. // that supports locking we do not have many
  12. // chances to do something. Maybe check for AbstractDocument
  13. // and call writeLock using reflection, but better than
  14. // that, let's leave this simple for now and wait for
  15. // bug reports (if any appear)
  16. run();
  17. }
  18. }
  19. }

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

  1. public String getText() {
  2. final StyledDocument doc = position.getCloneableEditorSupport ().getDocument ();
  3. // document is not opened
  4. if (doc == null)
  5. return null;
  6. final String[] retStringArray = new String[1];
  7. doc.render(new Runnable() { public void run() {
  8. // Part of #33165 - the following code is wrapped by doc.render()
  9. try {
  10. retStringArray[0] = doc.getText(position.getOffset(), getLength());
  11. } catch (BadLocationException ex) {
  12. ErrorManager.getDefault ().notify ( ErrorManager.EXCEPTION, ex);
  13. retStringArray[0] = null;
  14. }
  15. // End of the code wrapped by doc.render()
  16. }});
  17. return retStringArray[0];
  18. }

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

  1. /** Registers line, but only after obtaining the lock of the document.
  2. * This is a fix to issue 37767 as this creates ordering of locks (first
  3. * of all obtain documentrenderer, then ask for any other locks like
  4. * Line.Set.lines.
  5. *
  6. * @param line line we want to register
  7. * @return the line or some line that already was registered
  8. */
  9. private Line safelyRegisterLine(final Line line) {
  10. assert line != null;
  11. class DocumentRenderer implements Runnable {
  12. public Line result;
  13. public void run() {
  14. result = DocumentLine.Set.super.registerLine(line);
  15. }
  16. }
  17. StyledDocument doc = listener.support.getDocument();
  18. DocumentRenderer renderer = new DocumentRenderer();
  19. if (doc != null) {
  20. doc.render(renderer);
  21. } else {
  22. renderer.run();
  23. }
  24. return renderer.result;
  25. }
  26. }

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

  1. public void run() {
  2. try {
  3. synchronized (getAnnotations()) {
  4. if (!anno.isInDocument()) {
  5. anno.setInDocument(true);
  6. // #33165 - find position that is surely at begining of line
  7. FindAnnotationPosition fap = new FindAnnotationPosition(doc, pos.getPosition());
  8. doc.render(fap);
  9. NbDocument.addAnnotation(doc, fap.getAnnotationPosition(), -1, anno);
  10. }
  11. }
  12. } catch (IOException ex) {
  13. Logger.getLogger(DocumentLine.class.getName()).log(Level.WARNING, null, ex);
  14. }
  15. }
  16. });

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

  1. /** Remove annotation to this Annotatable class
  2. * @param anno annotation which will be detached from this class */
  3. @Override
  4. protected void removeAnnotation(final Annotation anno) {
  5. super.removeAnnotation(anno);
  6. final StyledDocument doc = position.getCloneableEditorSupport().getDocument();
  7. // document is not opened and so no annotation is attached to it
  8. if (doc == null) {
  9. return;
  10. }
  11. position.getCloneableEditorSupport().prepareDocument().waitFinished();
  12. doc.render(new Runnable() {
  13. public void run() {
  14. synchronized (getAnnotations()) {
  15. if (anno.isInDocument()) {
  16. anno.setInDocument(false);
  17. NbDocument.removeAnnotation(doc, anno);
  18. }
  19. }
  20. }
  21. });
  22. }

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

  1. /** Remove annotation to this Annotatable class
  2. * @param anno annotation which will be detached from this class */
  3. @Override
  4. protected void removeAnnotation(final Annotation anno) {
  5. super.removeAnnotation(anno);
  6. final StyledDocument doc = pos.getCloneableEditorSupport().getDocument();
  7. // document is not opened and so no annotation is attached to it
  8. if (doc == null) {
  9. return;
  10. }
  11. pos.getCloneableEditorSupport().prepareDocument().waitFinished();
  12. doc.render(new Runnable() {
  13. public void run() {
  14. synchronized (getAnnotations()) {
  15. if (anno.isInDocument()) {
  16. anno.setInDocument(false);
  17. NbDocument.removeAnnotation(doc, anno);
  18. }
  19. }
  20. }
  21. });
  22. }

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

  1. /** Add annotation to this Annotatable class
  2. * @param anno annotation which will be attached to this class */
  3. @Override
  4. protected void addAnnotation(final Annotation anno) {
  5. super.addAnnotation(anno);
  6. final StyledDocument doc = position.getCloneableEditorSupport().getDocument();
  7. // document is not opened and so the annotation will be added to document later
  8. if (doc == null) {
  9. return;
  10. }
  11. position.getCloneableEditorSupport().prepareDocument().waitFinished();
  12. doc.render(new Runnable() {
  13. public void run() {
  14. try {
  15. synchronized (getAnnotations()) {
  16. if (!anno.isInDocument()) {
  17. anno.setInDocument(true);
  18. NbDocument.addAnnotation(doc, position.getPosition(), length, anno);
  19. }
  20. }
  21. } catch (IOException ex) {
  22. Logger.getLogger(DocumentLine.class.getName()).log(Level.WARNING, null, ex);
  23. }
  24. }
  25. });
  26. }

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

  1. /** Add annotation to this Annotatable class
  2. * @param anno annotation which will be attached to this class */
  3. @Override
  4. protected void addAnnotation(final Annotation anno) {
  5. super.addAnnotation(anno);
  6. final StyledDocument doc = pos.getCloneableEditorSupport().getDocument();
  7. // document is not opened and so the annotation will be added to document later
  8. if (doc == null) {
  9. return;
  10. }
  11. pos.getCloneableEditorSupport().prepareDocument().waitFinished();
  12. doc.render(new Runnable() {
  13. public void run() {
  14. try {
  15. synchronized (getAnnotations()) {
  16. if (!anno.isInDocument()) {
  17. anno.setInDocument(true);
  18. // #33165 - find position that is surely at begining of line
  19. FindAnnotationPosition fap = new FindAnnotationPosition(doc, pos.getPosition());
  20. doc.render(fap);
  21. NbDocument.addAnnotation(doc, fap.getAnnotationPosition(), -1, anno);
  22. }
  23. }
  24. } catch (IOException ex) {
  25. Logger.getLogger(DocumentLine.class.getName()).log(Level.WARNING, null, ex);
  26. }
  27. }
  28. });
  29. }

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

  1. /** Add annotation to this Annotatable class
  2. * @param anno annotation which will be attached to this class */
  3. protected void addAnnotation(Annotation anno) {
  4. super.addAnnotation(anno);
  5. StyledDocument doc = pos.getCloneableEditorSupport ().getDocument ();
  6. // document is not opened and so the annotation will be added to document later
  7. if (doc == null)
  8. return;
  9. pos.getCloneableEditorSupport().prepareDocument().waitFinished();
  10. try {
  11. if (!anno.isInDocument()) {
  12. anno.setInDocument(true);
  13. // #33165 - find position that is surely at begining of line
  14. FindAnnotationPosition fap = new FindAnnotationPosition(doc, pos.getPosition());
  15. doc.render(fap);
  16. NbDocument.addAnnotation (doc, fap.getAnnotationPosition(), -1, anno);
  17. }
  18. } catch (IOException ex) {
  19. ErrorManager.getDefault ().notify ( ErrorManager.EXCEPTION, ex);
  20. }
  21. }

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

  1. /** Add annotation to this Annotatable class
  2. * @param anno annotation which will be attached to this class */
  3. protected void addAnnotation(Annotation anno) {
  4. super.addAnnotation(anno);
  5. StyledDocument doc = pos.getCloneableEditorSupport ().getDocument ();
  6. // document is not opened and so the annotation will be added to document later
  7. if (doc == null)
  8. return;
  9. pos.getCloneableEditorSupport().prepareDocument().waitFinished();
  10. try {
  11. if (!anno.isInDocument()) {
  12. anno.setInDocument(true);
  13. // #33165 - find position that is surely at begining of line
  14. FindAnnotationPosition fap = new FindAnnotationPosition(doc, pos.getPosition());
  15. doc.render(fap);
  16. NbDocument.addAnnotation (doc, fap.getAnnotationPosition(), -1, anno);
  17. }
  18. } catch (IOException ex) {
  19. ErrorManager.getDefault ().notify ( ErrorManager.EXCEPTION, ex);
  20. }
  21. }

相关文章