当前位置: 首页>>代码示例>>Java>>正文


Java View.getView方法代码示例

本文整理汇总了Java中javax.swing.text.View.getView方法的典型用法代码示例。如果您正苦于以下问题:Java View.getView方法的具体用法?Java View.getView怎么用?Java View.getView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.text.View的用法示例。


在下文中一共展示了View.getView方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: viewToModel

import javax.swing.text.View; //导入方法依赖的package包/类
static int viewToModel(JTextComponent tc, double x, double y, Position.Bias[] biasReturn) {
int offs = -1;
Document doc = tc.getDocument();
if (doc instanceof AbstractDocument) {
    ((AbstractDocument)doc).readLock();
}
try {
    Rectangle alloc = getVisibleEditorRect(tc);
    if (alloc != null) {
               View rootView = tc.getUI().getRootView(tc);
               View documentView = rootView.getView(0);
               if (documentView instanceof EditorView) {
                   documentView.setSize(alloc.width, alloc.height);
                   offs = ((EditorView) documentView).viewToModelChecked(x, y, alloc, biasReturn);
               } else {
                   rootView.setSize(alloc.width, alloc.height);
                   offs = rootView.viewToModel((float) x, (float) y, alloc, biasReturn);
               }
    }
} finally {
    if (doc instanceof AbstractDocument) {
	((AbstractDocument)doc).readUnlock();
    }
}
       return offs;
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:Utilities.java

示例2: getSingleLineTextBaseline

import javax.swing.text.View; //导入方法依赖的package包/类
/**
   * Returns the baseline for single line text components, like
   * <code>JTextField</code>.
   */
  private static int getSingleLineTextBaseline(JTextComponent textComponent,
                                               int h) {
      View rootView = textComponent.getUI().getRootView(textComponent);
      if (rootView.getViewCount() > 0) {
          Insets insets = textComponent.getInsets();
          int height = h - insets.top - insets.bottom;
          int y = insets.top;
          View fieldView = rootView.getView(0);
   int vspan = (int)fieldView.getPreferredSpan(View.Y_AXIS);
   if (height != vspan) {
int slop = height - vspan;
y += slop / 2;
   }
          FontMetrics fm = textComponent.getFontMetrics(
                               textComponent.getFont());
          y += fm.getAscent();
          return y;
      }
      return -1;
  }
 
开发者ID:fesch,项目名称:Moenagade,代码行数:25,代码来源:Baseline.java

示例3: checkChildrenParent

import javax.swing.text.View; //导入方法依赖的package包/类
private static void checkChildrenParent(View v) {
    int cnt = v.getViewCount();
    for (int i = 0; i < cnt; i++) {
        View child = v.getView(i);
        View childParent = child.getParent();
        if (childParent != v) {
            throw new IllegalStateException("child=" + child // NOI18N
                + " has parent=" + childParent // NOI18N
                + " instead of " + v // NOI18N
            );
        }
        checkChildrenParent(child);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:ViewUtilitiesImpl.java

示例4: getRootView

import javax.swing.text.View; //导入方法依赖的package包/类
/**
 * Get first view in the hierarchy that is an instance of the given class.
 * It allows to skip various wrapper-views around the doc-view that holds
 * the child views for the lines.
 *
 * @param component component from which the root view is fetched.
 * @param rootViewClass class of the view to return.
 * @return view being instance of the requested class or null if there
 *  is not one.
 */
public static View getRootView(JTextComponent component, Class rootViewClass) {
    View view = null;
    TextUI textUI = component.getUI();
    if (textUI != null) {
        view = textUI.getRootView(component);
        while (view != null && !rootViewClass.isInstance(view)
            && view.getViewCount() == 1 // must be wrapper view
        ) {
            view = view.getView(0); // get the only child
        }
    }
    
    return view;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:Utilities.java

示例5: get

import javax.swing.text.View; //导入方法依赖的package包/类
public static DocumentView get(JTextComponent component) {
    TextUI textUI = component.getUI();
    if (textUI != null) {
        View rootView = textUI.getRootView(component);
        if (rootView != null && rootView.getViewCount() > 0) {
            View view = rootView.getView(0);
            if (view instanceof DocumentView) {
                return (DocumentView)view;
            }
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:DocumentView.java

示例6: retrieveGlyphViews

import javax.swing.text.View; //导入方法依赖的package包/类
private static void retrieveGlyphViews(View root) {
    for (int i=0; i<= root.getViewCount()-1; i++) {
        View view = root.getView(i);
        if (view instanceof GlyphView && view.isVisible()) {
            if (!glyphViews.contains(view)) {
                glyphViews.add((GlyphView)view);
            }
        } else {
            retrieveGlyphViews(view);
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:13,代码来源:bug8014863.java

示例7: test

import javax.swing.text.View; //导入方法依赖的package包/类
private void test() {
    View root = ((View)label.getClientProperty(BasicHTML.propertyKey))
            .getView(0);
    int n = root.getViewCount();
    View v  = root.getView(n - 1);
    AttributeSet attrs = v.getAttributes();
    StyleSheet ss = ((HTMLDocument) v.getDocument()).getStyleSheet();
    Font font = ss.getFont(attrs);
    System.out.println(font.getSize());
    passed = (font.getSize() == 12);
    if(!passed) {
        throw new RuntimeException("Test failed.");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:bug4960629.java

示例8: actionPerformed

import javax.swing.text.View; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent evt, JTextComponent target) {
    AbstractDocument adoc = (AbstractDocument)target.getDocument();

    // Dump fold hierarchy
    FoldHierarchy hierarchy = FoldHierarchy.get(target);
    adoc.readLock();
    try {
        hierarchy.lock();
        try {
            /*DEBUG*/System.err.println("FOLD HIERARCHY DUMP:\n" + hierarchy); // NOI18N
            TokenHierarchy<?> th = TokenHierarchy.get(adoc);
            /*DEBUG*/System.err.println("TOKEN HIERARCHY DUMP:\n" + (th != null ? th : "<NULL-TH>")); // NOI18N

        } finally {
            hierarchy.unlock();
        }
    } finally {
        adoc.readUnlock();
    }

    View rootView = null;
    TextUI textUI = target.getUI();
    if (textUI != null) {
        rootView = textUI.getRootView(target); // Root view impl in BasicTextUI
        if (rootView != null && rootView.getViewCount() == 1) {
            rootView = rootView.getView(0); // Get DocumentView
        }
    }
    if (rootView != null) {
        String rootViewDump = (rootView instanceof DocumentView)
                ? ((DocumentView)rootView).toStringDetail()
                : rootView.toString();
        /*DEBUG*/System.err.println("DOCUMENT VIEW: " + System.identityHashCode(rootView) + // NOI18N
                "\n" + rootViewDump); // NOI18N
        int caretOffset = target.getCaretPosition();
        int caretViewIndex = rootView.getViewIndex(caretOffset, Position.Bias.Forward);
        /*DEBUG*/System.err.println("caretOffset=" + caretOffset + ", caretViewIndex=" + caretViewIndex); // NOI18N
        if (caretViewIndex >= 0 && caretViewIndex < rootView.getViewCount()) {
            View caretView = rootView.getView(caretViewIndex);
            /*DEBUG*/System.err.println("caretView: " + caretView); // NOI18N
        }
        /*DEBUG*/System.err.println(FixLineSyntaxState.lineInfosToString(adoc));
        // Check the hierarchy correctness
        //org.netbeans.editor.view.spi.ViewUtilities.checkViewHierarchy(rootView);
    }
    
    if (adoc instanceof BaseDocument) {
        /*DEBUG*/System.err.println("DOCUMENT:\n" + ((BaseDocument)adoc).toStringDetail()); // NOI18N
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:51,代码来源:ActionFactory.java

示例9: printView

import javax.swing.text.View; //导入方法依赖的package包/类
private boolean printView(final Graphics2D graphics2D,
                          final Shape allocation, final View view) {
    boolean pageExists = false;
    final Rectangle clipRectangle = new Rectangle(0, 0, (int) (pageFormat
            .getImageableWidth() / SCALE), (int) clientHeight);
    Shape childAllocation;
    View childView;

    if (view.getViewCount() > 0) {
        for (int i = 0; i < view.getViewCount(); i++) {
            childAllocation = view.getChildAllocation(i, allocation);
            if (childAllocation != null) {
                childView = view.getView(i);
                if (printView(graphics2D, childAllocation, childView)) {
                    pageExists = true;
                }
            }
        }
    } else {
        if (allocation.getBounds().getMaxY() >= clipRectangle.getY()) {

            if (allocation.getBounds().getHeight() > clipRectangle
                    .getHeight()
                    && allocation.intersects(clipRectangle)) {
                paintView(graphics2D, view, allocation);
                pageExists = true;
            } else {
                if (allocation.getBounds().getY() >= clipRectangle.getY()) {
                    if (allocation.getBounds().getMaxY() <= clipRectangle
                            .getMaxY()) {
                        paintView(graphics2D, view, allocation);
                        pageExists = true;

                    } else {
                        if (allocation.getBounds().getY() < pageEndY) {
                            pageEndY = allocation.getBounds().getY();
                        }
                    }
                }
            }
        }
    }
    return pageExists;
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:45,代码来源:HTMLPrintable.java


注:本文中的javax.swing.text.View.getView方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。