public int getPreviousLineCount0() { int lineCount = 0; View parent = this.getParent(); int count = parent.getViewCount(); for (int i = 0; i < count; i++) { if (parent.getView(i) == this) { break; } else { lineCount += parent.getView(i).getViewCount(); } } return lineCount; }
private void resetBreakSpots() { for (int i = 0; i < layoutPool.getViewCount(); i++) { View v = layoutPool.getView(i); if (v instanceof ViewLabel) { ((ViewLabel) v).resetBreakSpots(); } } } }
private void resetBreakSpots() { for (int i = 0; i < layoutPool.getViewCount(); i++) { View v = layoutPool.getView(i); if (v instanceof WrapLabelView) { ((WrapLabelView) v).resetBreakSpots(); } } }
public int getPreviousLineCount() { int lineCount = 0; View parent = this.getParent(); int count = parent.getViewCount(); for (int i = 0; i < count; i++) { if (parent.getView(i) == this) { break; } else { // Count source number lines rather than display lines... lineCount += 1; // Old (display lines): parent.getView(i).getViewCount(); } } return lineCount; } }
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); } }
/** * 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 = (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; }
/** * Returns the paragraph views. * @return the paragraph views */ public ArrayList<NoLineWrapParagraphView> getParagraphs() { ArrayList<NoLineWrapParagraphView> result = new ArrayList<NoLineWrapParagraphView>(); View rootView = getUI().getRootView(this); // TODO we assume the box view to be the root // (may change later if multiple boxes etc...) rootView = rootView.getView(0); // displayView(rootView, 2, System.out); int numberOfChildren = rootView.getViewCount(); for (int i = 0; i < numberOfChildren; i++) { View childView = rootView.getView(i); if (childView instanceof NoLineWrapParagraphView) { result.add((NoLineWrapParagraphView) childView); } } return result; }
public int updateIndex(int viewIndex, int offset, View view, FlyView.Parent flyParent) { int lastViewIndex = view.getViewCount() - 1; while (true) { int endOffset = (flyParent != null) ? flyParent.getEndOffset(viewIndex) : view.getView(viewIndex).getEndOffset(); if (endOffset != offset) { // view ends after offset if (excludeAtOffset) { viewIndex--; // return the lower view that ends at offset } break; } if (viewIndex == lastViewIndex) { // over last view break; } viewIndex++; } return viewIndex; }
public static void updateRenderer(JXLabel c) { View value = null; View oldValue = (View) c.getClientProperty(BasicHTML.propertyKey); if (oldValue == null || oldValue instanceof Renderer) { value = createView(c); } if (value != oldValue && oldValue != null) { for (int i = 0; i < oldValue.getViewCount(); i++) { oldValue.getView(i).setParent(null); } } c.putClientProperty(BasicHTML.propertyKey, value); }
public static void updateRenderer(JXLabel c) { View value = null; View oldValue = (View) c.getClientProperty(BasicHTML.propertyKey); if (oldValue == null || oldValue instanceof Renderer) { value = createView(c); } if (value != oldValue && oldValue != null) { for (int i = 0; i < oldValue.getViewCount(); i++) { oldValue.getView(i).setParent(null); } } c.putClientProperty(BasicHTML.propertyKey, value); }
public static void updateRenderer(JXLabel c) { View value = null; View oldValue = (View) c.getClientProperty(BasicHTML.propertyKey); if (oldValue == null || oldValue instanceof Renderer) { value = createView(c); } if (value != oldValue && oldValue != null) { for (int i = 0; i < oldValue.getViewCount(); i++) { oldValue.getView(i).setParent(null); } } c.putClientProperty(BasicHTML.propertyKey, value); }
public static void updateRenderer(JXLabel c) { View value = null; View oldValue = (View) c.getClientProperty(BasicHTML.propertyKey); if (oldValue == null || oldValue instanceof Renderer) { value = createView(c); } if (value != oldValue && oldValue != null) { for (int i = 0; i < oldValue.getViewCount(); i++) { oldValue.getView(i).setParent(null); } } c.putClientProperty(BasicHTML.propertyKey, value); }
public static void updateRenderer(JXLabel c) { View value = null; View oldValue = (View) c.getClientProperty(BasicHTML.propertyKey); if (oldValue == null || oldValue instanceof Renderer) { value = createView(c); } if (value != oldValue && oldValue != null) { for (int i = 0; i < oldValue.getViewCount(); i++) { oldValue.getView(i).setParent(null); } } c.putClientProperty(BasicHTML.propertyKey, value); }
/** * Returns the baseline for single line text components, like * <code>JTextField</code>. */ private 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; }
public static void updateRenderer(JLabel c, String text) { View value = null; try{ View oldValue = (View)c.getClientProperty(propertyKey); if (isHTMLString(text)) { value = ScaledHTML.createHTMLView(c, text); } if (value != oldValue && oldValue != null) { for (int i = 0; i < oldValue.getViewCount(); i++) { oldValue.getView(i).setParent(null); } } } finally{ c.putClientProperty(BasicHTML.propertyKey, value); } }
public static View getLeafViewAtPoint(Point p, View root, JEditorPane sourcePane) { int pos = sourcePane.viewToModel(p); View v = sourcePane.getUI().getRootView(sourcePane); while (v.getViewCount() > 0) { int i = v.getViewIndex(pos, Position.Bias.Forward); v = v.getView(i); } Shape alloc = getAllocation(root, sourcePane); if (alloc.contains(p)) { return v; } return null; }
@Override public int getBaseline(int width, int height) { JFormattedTextField editor = datePicker.getEditor(); View rootView = editor.getUI().getRootView(editor); if (rootView.getViewCount() > 0) { Insets insets = editor.getInsets(); Insets insetsOut = datePicker.getInsets(); int nh = height - insets.top - insets.bottom - insetsOut.top - insetsOut.bottom; int y = insets.top + insetsOut.top; View fieldView = rootView.getView(0); int vspan = (int) fieldView.getPreferredSpan(View.Y_AXIS); if (nh != vspan) { int slop = nh - vspan; y += slop / 2; } FontMetrics fm = editor.getFontMetrics(editor.getFont()); y += fm.getAscent(); return y; } return -1; }
@Override public int getBaseline(int width, int height) { JFormattedTextField editor = datePicker.getEditor(); View rootView = editor.getUI().getRootView(editor); if (rootView.getViewCount() > 0) { Insets insets = editor.getInsets(); Insets insetsOut = datePicker.getInsets(); int nh = height - insets.top - insets.bottom - insetsOut.top - insetsOut.bottom; int y = insets.top + insetsOut.top; View fieldView = rootView.getView(0); int vspan = (int) fieldView.getPreferredSpan(View.Y_AXIS); if (nh != vspan) { int slop = nh - vspan; y += slop / 2; } FontMetrics fm = editor.getFontMetrics(editor.getFont()); y += fm.getAscent(); return y; } return -1; }
@Override public int getBaseline(int width, int height) { JFormattedTextField editor = datePicker.getEditor(); View rootView = editor.getUI().getRootView(editor); if (rootView.getViewCount() > 0) { Insets insets = editor.getInsets(); Insets insetsOut = datePicker.getInsets(); int nh = height - insets.top - insets.bottom - insetsOut.top - insetsOut.bottom; int y = insets.top + insetsOut.top; View fieldView = rootView.getView(0); int vspan = (int) fieldView.getPreferredSpan(View.Y_AXIS); if (nh != vspan) { int slop = nh - vspan; y += slop / 2; } FontMetrics fm = editor.getFontMetrics(editor.getFont()); y += fm.getAscent(); return y; } return -1; }
@Override public int getBaseline(int width, int height) { JFormattedTextField editor = datePicker.getEditor(); View rootView = editor.getUI().getRootView(editor); if (rootView.getViewCount() > 0) { Insets insets = editor.getInsets(); Insets insetsOut = datePicker.getInsets(); int nh = height - insets.top - insets.bottom - insetsOut.top - insetsOut.bottom; int y = insets.top + insetsOut.top; View fieldView = rootView.getView(0); int vspan = (int) fieldView.getPreferredSpan(View.Y_AXIS); if (nh != vspan) { int slop = nh - vspan; y += slop / 2; } FontMetrics fm = editor.getFontMetrics(editor.getFont()); y += fm.getAscent(); return y; } return -1; }