类javax.swing.plaf.TextUI源码实例Demo

下面列出了怎么用javax.swing.plaf.TextUI的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: jdk8u_jdk   文件: CaretFloatingPointAPITest.java
void repaintNewCaret() {
    if (component != null) {
        TextUI mapper = component.getUI();
        Document doc = component.getDocument();
        if ((mapper != null) && (doc != null)) {
            Rectangle2D newLoc;
            try {
                newLoc = mapper.modelToView2D(component, this.dot, this.dotBias);
            } catch (BadLocationException e) {
                newLoc = null;
            }
            if (newLoc != null) {
                adjustVisibility(newLoc.getBounds());
                if (getMagicCaretPosition() == null) {
                    setMagicCaretPosition(new Point((int) newLoc.getX(),
                                                    (int) newLoc.getY()));
                }
            }
            damage(newLoc.getBounds());
        }
    }
}
 
源代码2 项目: openjdk-jdk9   文件: CaretFloatingPointAPITest.java
void repaintNewCaret() {
    if (component != null) {
        TextUI mapper = component.getUI();
        Document doc = component.getDocument();
        if ((mapper != null) && (doc != null)) {
            Rectangle2D newLoc;
            try {
                newLoc = mapper.modelToView2D(component, this.dot, this.dotBias);
            } catch (BadLocationException e) {
                newLoc = null;
            }
            if (newLoc != null) {
                adjustVisibility(newLoc.getBounds());
                if (getMagicCaretPosition() == null) {
                    setMagicCaretPosition(new Point((int) newLoc.getX(),
                                                    (int) newLoc.getY()));
                }
            }
            damage(newLoc.getBounds());
        }
    }
}
 
源代码3 项目: netbeans   文件: DocumentationScrollPane.java
/** Attempt to find the editor keystroke for the given editor action. */
private KeyStroke[] findEditorKeys(String editorActionName, KeyStroke defaultKey, JTextComponent component) {
    // This method is implemented due to the issue
    // #25715 - Attempt to search keymap for the keybinding that logically corresponds to the action
    KeyStroke[] ret = new KeyStroke[] { defaultKey };
    if (component != null) {
        TextUI componentUI = component.getUI();
        Keymap km = component.getKeymap();
        if (componentUI != null && km != null) {
            EditorKit kit = componentUI.getEditorKit(component);
            if (kit instanceof BaseKit) {
                Action a = ((BaseKit)kit).getActionByName(editorActionName);
                if (a != null) {
                    KeyStroke[] keys = km.getKeyStrokesForAction(a);
                    if (keys != null && keys.length > 0) {
                        ret = keys;
                    }
                }
            }
        }
    }
    return ret;
}
 
源代码4 项目: jdk8u-jdk   文件: MultiTextUI.java
/**
 * Invokes the <code>getNextVisualPositionFrom</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public int getNextVisualPositionFrom(JTextComponent a, int b, Position.Bias c, int d, Position.Bias[] e)
        throws BadLocationException {
    int returnValue =
        ((TextUI) (uis.elementAt(0))).getNextVisualPositionFrom(a,b,c,d,e);
    for (int i = 1; i < uis.size(); i++) {
        ((TextUI) (uis.elementAt(i))).getNextVisualPositionFrom(a,b,c,d,e);
    }
    return returnValue;
}
 
源代码5 项目: hottub   文件: HTMLEditorKit.java
/**
 * Returns a string anchor if the passed in element has a
 * USEMAP that contains the passed in location.
 */
private String getMapHREF(JEditorPane html, HTMLDocument hdoc,
                          Element elem, AttributeSet attr, int offset,
                          int x, int y) {
    Object useMap = attr.getAttribute(HTML.Attribute.USEMAP);
    if (useMap != null && (useMap instanceof String)) {
        Map m = hdoc.getMap((String)useMap);
        if (m != null && offset < hdoc.getLength()) {
            Rectangle bounds;
            TextUI ui = html.getUI();
            try {
                Shape lBounds = ui.modelToView(html, offset,
                                           Position.Bias.Forward);
                Shape rBounds = ui.modelToView(html, offset + 1,
                                           Position.Bias.Backward);
                bounds = lBounds.getBounds();
                bounds.add((rBounds instanceof Rectangle) ?
                            (Rectangle)rBounds : rBounds.getBounds());
            } catch (BadLocationException ble) {
                bounds = null;
            }
            if (bounds != null) {
                AttributeSet area = m.getArea(x - bounds.x,
                                              y - bounds.y,
                                              bounds.width,
                                              bounds.height);
                if (area != null) {
                    return (String)area.getAttribute(HTML.Attribute.
                                                     HREF);
                }
            }
        }
    }
    return null;
}
 
源代码6 项目: jdk1.8-source-analysis   文件: HTMLEditorKit.java
/**
 * Returns a string anchor if the passed in element has a
 * USEMAP that contains the passed in location.
 */
private String getMapHREF(JEditorPane html, HTMLDocument hdoc,
                          Element elem, AttributeSet attr, int offset,
                          int x, int y) {
    Object useMap = attr.getAttribute(HTML.Attribute.USEMAP);
    if (useMap != null && (useMap instanceof String)) {
        Map m = hdoc.getMap((String)useMap);
        if (m != null && offset < hdoc.getLength()) {
            Rectangle bounds;
            TextUI ui = html.getUI();
            try {
                Shape lBounds = ui.modelToView(html, offset,
                                           Position.Bias.Forward);
                Shape rBounds = ui.modelToView(html, offset + 1,
                                           Position.Bias.Backward);
                bounds = lBounds.getBounds();
                bounds.add((rBounds instanceof Rectangle) ?
                            (Rectangle)rBounds : rBounds.getBounds());
            } catch (BadLocationException ble) {
                bounds = null;
            }
            if (bounds != null) {
                AttributeSet area = m.getArea(x - bounds.x,
                                              y - bounds.y,
                                              bounds.width,
                                              bounds.height);
                if (area != null) {
                    return (String)area.getAttribute(HTML.Attribute.
                                                     HREF);
                }
            }
        }
    }
    return null;
}
 
源代码7 项目: Darcula   文件: SnippetHighlighter.java
/**
        * Paints a highlight.
        *
        * @param g the graphics context
        * @param offs0 the starting model offset >= 0
        * @param offs1 the ending model offset >= offs1
        * @param bounds the bounding box for the highlight
        * @param c the editor
        */
       public void paint(Graphics g, int offs0, int offs1, Shape bounds, JTextComponent c) {
    Rectangle alloc = bounds.getBounds();
    try {
	// --- determine locations ---
	TextUI mapper = c.getUI();
	Rectangle p0 = mapper.modelToView(c, offs0);
	Rectangle p1 = mapper.modelToView(c, offs1);

	// --- render ---
	Color color = getColor();

	if (color == null) {
	    g.setColor(c.getSelectionColor());
	}
	else {
	    g.setColor(color);
	}
	if (p0.y == p1.y) {
	    // same line, render a rectangle
	    Rectangle r = p0.union(p1);
	    g.fillRect(r.x, r.y, r.width, r.height);
	} else {
	    // different lines
	    int p0ToMarginWidth = alloc.x + alloc.width - p0.x;
	    g.fillRect(p0.x, p0.y, p0ToMarginWidth, p0.height);
	    if ((p0.y + p0.height) != p1.y) {
		g.fillRect(alloc.x, p0.y + p0.height, alloc.width, 
			   p1.y - (p0.y + p0.height));
	    } 
	    g.fillRect(alloc.x, p1.y, (p1.x - alloc.x), p1.height);
	}
    } catch (BadLocationException e) {
	// can't render
    }
}
 
源代码8 项目: openjdk-jdk9   文件: MultiTextUI.java
@Override
public int viewToModel2D(JTextComponent a, Point2D b, Position.Bias[] c) {
    int returnValue =
        ((TextUI) (uis.elementAt(0))).viewToModel2D(a,b,c);
    for (int i = 1; i < uis.size(); i++) {
        ((TextUI) (uis.elementAt(i))).viewToModel2D(a,b,c);
    }
    return returnValue;
}
 
源代码9 项目: openjdk-8-source   文件: MultiTextUI.java
/**
 * Invokes the <code>getRootView</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public View getRootView(JTextComponent a) {
    View returnValue =
        ((TextUI) (uis.elementAt(0))).getRootView(a);
    for (int i = 1; i < uis.size(); i++) {
        ((TextUI) (uis.elementAt(i))).getRootView(a);
    }
    return returnValue;
}
 
源代码10 项目: jdk1.8-source-analysis   文件: MultiTextUI.java
/**
 * Invokes the <code>modelToView</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public Rectangle modelToView(JTextComponent a, int b, Position.Bias c)
        throws BadLocationException {
    Rectangle returnValue =
        ((TextUI) (uis.elementAt(0))).modelToView(a,b,c);
    for (int i = 1; i < uis.size(); i++) {
        ((TextUI) (uis.elementAt(i))).modelToView(a,b,c);
    }
    return returnValue;
}
 
源代码11 项目: openjdk-jdk8u-backup   文件: AquaTextFieldSearch.java
protected static void uninstallSearchField(final JTextComponent c) {
    c.setBorder(UIManager.getBorder("TextField.border"));
    c.removeAll();

    final TextUI ui = c.getUI();
    if (ui instanceof AquaTextFieldUI) {
        ((AquaTextFieldUI)ui).setPaintingDelegate(null);
    }
}
 
源代码12 项目: openjdk-jdk8u-backup   文件: MultiTextUI.java
/**
 * Invokes the <code>modelToView</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public Rectangle modelToView(JTextComponent a, int b, Position.Bias c)
        throws BadLocationException {
    Rectangle returnValue =
        ((TextUI) (uis.elementAt(0))).modelToView(a,b,c);
    for (int i = 1; i < uis.size(); i++) {
        ((TextUI) (uis.elementAt(i))).modelToView(a,b,c);
    }
    return returnValue;
}
 
源代码13 项目: openjdk-jdk9   文件: MultiTextUI.java
/**
 * Invokes the <code>getNextVisualPositionFrom</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public int getNextVisualPositionFrom(JTextComponent a, int b, Position.Bias c, int d, Position.Bias[] e)
        throws BadLocationException {
    int returnValue =
        ((TextUI) (uis.elementAt(0))).getNextVisualPositionFrom(a,b,c,d,e);
    for (int i = 1; i < uis.size(); i++) {
        ((TextUI) (uis.elementAt(i))).getNextVisualPositionFrom(a,b,c,d,e);
    }
    return returnValue;
}
 
源代码14 项目: openjdk-jdk9   文件: MultiTextUI.java
@Override
public Rectangle2D modelToView2D(JTextComponent a, int b, Position.Bias c) throws BadLocationException {
    Rectangle2D returnValue =
        ((TextUI) (uis.elementAt(0))).modelToView2D(a,b,c);
    for (int i = 1; i < uis.size(); i++) {
        ((TextUI) (uis.elementAt(i))).modelToView2D(a,b,c);
    }
    return returnValue;
}
 
源代码15 项目: dragonwell8_jdk   文件: HTMLEditorKit.java
/**
 * Returns true if the View representing <code>e</code> contains
 * the location <code>x</code>, <code>y</code>. <code>offset</code>
 * gives the offset into the Document to check for.
 */
private boolean doesElementContainLocation(JEditorPane editor,
                                           Element e, int offset,
                                           int x, int y) {
    if (e != null && offset > 0 && e.getStartOffset() == offset) {
        try {
            TextUI ui = editor.getUI();
            Shape s1 = ui.modelToView(editor, offset,
                                      Position.Bias.Forward);
            if (s1 == null) {
                return false;
            }
            Rectangle r1 = (s1 instanceof Rectangle) ? (Rectangle)s1 :
                            s1.getBounds();
            Shape s2 = ui.modelToView(editor, e.getEndOffset(),
                                      Position.Bias.Backward);
            if (s2 != null) {
                Rectangle r2 = (s2 instanceof Rectangle) ? (Rectangle)s2 :
                            s2.getBounds();
                r1.add(r2);
            }
            return r1.contains(x, y);
        } catch (BadLocationException ble) {
        }
    }
    return true;
}
 
源代码16 项目: jdk8u_jdk   文件: HTMLEditorKit.java
/**
 * Returns true if the View representing <code>e</code> contains
 * the location <code>x</code>, <code>y</code>. <code>offset</code>
 * gives the offset into the Document to check for.
 */
private boolean doesElementContainLocation(JEditorPane editor,
                                           Element e, int offset,
                                           int x, int y) {
    if (e != null && offset > 0 && e.getStartOffset() == offset) {
        try {
            TextUI ui = editor.getUI();
            Shape s1 = ui.modelToView(editor, offset,
                                      Position.Bias.Forward);
            if (s1 == null) {
                return false;
            }
            Rectangle r1 = (s1 instanceof Rectangle) ? (Rectangle)s1 :
                            s1.getBounds();
            Shape s2 = ui.modelToView(editor, e.getEndOffset(),
                                      Position.Bias.Backward);
            if (s2 != null) {
                Rectangle r2 = (s2 instanceof Rectangle) ? (Rectangle)s2 :
                            s2.getBounds();
                r1.add(r2);
            }
            return r1.contains(x, y);
        } catch (BadLocationException ble) {
        }
    }
    return true;
}
 
源代码17 项目: dragonwell8_jdk   文件: MultiTextUI.java
/**
 * Invokes the <code>modelToView</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public Rectangle modelToView(JTextComponent a, int b, Position.Bias c)
        throws BadLocationException {
    Rectangle returnValue =
        ((TextUI) (uis.elementAt(0))).modelToView(a,b,c);
    for (int i = 1; i < uis.size(); i++) {
        ((TextUI) (uis.elementAt(i))).modelToView(a,b,c);
    }
    return returnValue;
}
 
源代码18 项目: dragonwell8_jdk   文件: MultiTextUI.java
/**
 * Invokes the <code>viewToModel</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public int viewToModel(JTextComponent a, Point b) {
    int returnValue =
        ((TextUI) (uis.elementAt(0))).viewToModel(a,b);
    for (int i = 1; i < uis.size(); i++) {
        ((TextUI) (uis.elementAt(i))).viewToModel(a,b);
    }
    return returnValue;
}
 
源代码19 项目: dragonwell8_jdk   文件: MultiTextUI.java
/**
 * Invokes the <code>viewToModel</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public int viewToModel(JTextComponent a, Point b, Position.Bias[] c) {
    int returnValue =
        ((TextUI) (uis.elementAt(0))).viewToModel(a,b,c);
    for (int i = 1; i < uis.size(); i++) {
        ((TextUI) (uis.elementAt(i))).viewToModel(a,b,c);
    }
    return returnValue;
}
 
源代码20 项目: jdk8u_jdk   文件: AquaTextFieldSearch.java
protected static void installSearchField(final JTextComponent c) {
    final SearchFieldBorder border = getSearchTextFieldBorder();
    c.setBorder(border);
    c.setLayout(border.getCustomLayout());
    c.add(getFindButton(c), BorderLayout.WEST);
    c.add(getCancelButton(c), BorderLayout.EAST);
    c.add(getPromptLabel(c), BorderLayout.CENTER);

    final TextUI ui = c.getUI();
    if (ui instanceof AquaTextFieldUI) {
        ((AquaTextFieldUI)ui).setPaintingDelegate(border);
    }
}
 
源代码21 项目: openjdk-jdk8u   文件: MultiTextUI.java
/**
 * Invokes the <code>viewToModel</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public int viewToModel(JTextComponent a, Point b) {
    int returnValue =
        ((TextUI) (uis.elementAt(0))).viewToModel(a,b);
    for (int i = 1; i < uis.size(); i++) {
        ((TextUI) (uis.elementAt(i))).viewToModel(a,b);
    }
    return returnValue;
}
 
源代码22 项目: Bytecoder   文件: MultiTextUI.java
/**
 * Invokes the <code>viewToModel</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
@Deprecated(since = "9")
@Override
public int viewToModel(JTextComponent a, Point b) {
    int returnValue =
        ((TextUI) (uis.elementAt(0))).viewToModel(a,b);
    for (int i = 1; i < uis.size(); i++) {
        ((TextUI) (uis.elementAt(i))).viewToModel(a,b);
    }
    return returnValue;
}
 
源代码23 项目: dragonwell8_jdk   文件: MultiTextUI.java
/**
 * Invokes the <code>getRootView</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public View getRootView(JTextComponent a) {
    View returnValue =
        ((TextUI) (uis.elementAt(0))).getRootView(a);
    for (int i = 1; i < uis.size(); i++) {
        ((TextUI) (uis.elementAt(i))).getRootView(a);
    }
    return returnValue;
}
 
源代码24 项目: jdk8u-jdk   文件: MultiTextUI.java
/**
 * Invokes the <code>getNextVisualPositionFrom</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public int getNextVisualPositionFrom(JTextComponent a, int b, Position.Bias c, int d, Position.Bias[] e)
        throws BadLocationException {
    int returnValue =
        ((TextUI) (uis.elementAt(0))).getNextVisualPositionFrom(a,b,c,d,e);
    for (int i = 1; i < uis.size(); i++) {
        ((TextUI) (uis.elementAt(i))).getNextVisualPositionFrom(a,b,c,d,e);
    }
    return returnValue;
}
 
源代码25 项目: openjdk-jdk8u-backup   文件: AquaTextFieldSearch.java
protected static void installSearchField(final JTextComponent c) {
    final SearchFieldBorder border = getSearchTextFieldBorder();
    c.setBorder(border);
    c.setLayout(border.getCustomLayout());
    c.add(getFindButton(c), BorderLayout.WEST);
    c.add(getCancelButton(c), BorderLayout.EAST);
    c.add(getPromptLabel(c), BorderLayout.CENTER);

    final TextUI ui = c.getUI();
    if (ui instanceof AquaTextFieldUI) {
        ((AquaTextFieldUI)ui).setPaintingDelegate(border);
    }
}
 
源代码26 项目: netbeans   文件: BraceMatchingSidebarComponent.java
@SuppressWarnings("LeakingThisInConstructor")
public BraceMatchingSidebarComponent(JTextComponent editor) {
    this.editor = editor;
    this.mimeType = DocumentUtilities.getMimeType(editor);
    this.prefs = MimeLookup.getLookup(MimePath.EMPTY).lookup(Preferences.class);
    
    final Lookup.Result r = MimeLookup.getLookup(org.netbeans.lib.editor.util.swing.DocumentUtilities.getMimeType(editor)).lookupResult(
            FontColorSettings.class);
    prefListenerGC = new PrefListener();
    this.colorResult = r;
    r.addLookupListener(WeakListeners.create(LookupListener.class, this , r));
    prefs.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, prefListenerGC, prefs));
    loadPreferences();
    
    editorPane = findEditorPane(editor);
    Component parent = editor.getParent();
    if (parent instanceof JLayeredPane) {
        parent = parent.getParent();
    }
    if (parent instanceof JViewport) {
        this.viewport = (JViewport)parent;
        // see #219015; need to listen on viewport change to show/hide the tooltip
        viewport.addChangeListener(WeakListeners.change(this, viewport));
    }
    TextUI ui = editor.getUI();
    if (ui instanceof BaseTextUI) {
        baseUI = (BaseTextUI)ui;
        MasterMatcher.get(editor).addMatchListener(this);
    } else {
        baseUI = null;
    }
    setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
    updatePreferredSize();
}
 
源代码27 项目: openjdk-jdk8u-backup   文件: MultiTextUI.java
/**
 * Invokes the <code>getNextVisualPositionFrom</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public int getNextVisualPositionFrom(JTextComponent a, int b, Position.Bias c, int d, Position.Bias[] e)
        throws BadLocationException {
    int returnValue =
        ((TextUI) (uis.elementAt(0))).getNextVisualPositionFrom(a,b,c,d,e);
    for (int i = 1; i < uis.size(); i++) {
        ((TextUI) (uis.elementAt(i))).getNextVisualPositionFrom(a,b,c,d,e);
    }
    return returnValue;
}
 
源代码28 项目: openjdk-8   文件: MultiTextUI.java
/**
 * Invokes the <code>getNextVisualPositionFrom</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public int getNextVisualPositionFrom(JTextComponent a, int b, Position.Bias c, int d, Position.Bias[] e)
        throws BadLocationException {
    int returnValue =
        ((TextUI) (uis.elementAt(0))).getNextVisualPositionFrom(a,b,c,d,e);
    for (int i = 1; i < uis.size(); i++) {
        ((TextUI) (uis.elementAt(i))).getNextVisualPositionFrom(a,b,c,d,e);
    }
    return returnValue;
}
 
源代码29 项目: TencentKona-8   文件: MultiTextUI.java
/**
 * Invokes the <code>getToolTipText</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 * @since 1.4
 */
public String getToolTipText(JTextComponent a, Point b) {
    String returnValue =
        ((TextUI) (uis.elementAt(0))).getToolTipText(a,b);
    for (int i = 1; i < uis.size(); i++) {
        ((TextUI) (uis.elementAt(i))).getToolTipText(a,b);
    }
    return returnValue;
}
 
源代码30 项目: hottub   文件: AquaTextFieldSearch.java
protected static void uninstallSearchField(final JTextComponent c) {
    c.setBorder(UIManager.getBorder("TextField.border"));
    c.removeAll();

    final TextUI ui = c.getUI();
    if (ui instanceof AquaTextFieldUI) {
        ((AquaTextFieldUI)ui).setPaintingDelegate(null);
    }
}
 
 类所在包
 同包方法