javax.swing.plaf.TextUI Java Examples
The following examples show how to use
javax.swing.plaf.TextUI.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CaretFloatingPointAPITest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
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()); } } }
Example #2
Source File: DocumentationScrollPane.java From netbeans with Apache License 2.0 | 6 votes |
/** 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; }
Example #3
Source File: CaretFloatingPointAPITest.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
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()); } } }
Example #4
Source File: MultiTextUI.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #5
Source File: NewLineHighlightPainter.java From jlibs with Apache License 2.0 | 5 votes |
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 --- 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 } }
Example #6
Source File: MultiTextUI.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #7
Source File: MultiTextUI.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * 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) throws BadLocationException { Rectangle returnValue = ((TextUI) (uis.elementAt(0))).modelToView(a,b); for (int i = 1; i < uis.size(); i++) { ((TextUI) (uis.elementAt(i))).modelToView(a,b); } return returnValue; }
Example #8
Source File: HTMLEditorKit.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #9
Source File: AquaTextFieldSearch.java From hottub with GNU General Public License v2.0 | 5 votes |
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); } }
Example #10
Source File: SnippetHighlighter.java From beautyeye with Apache License 2.0 | 5 votes |
/** * 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 } }
Example #11
Source File: MultiTextUI.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #12
Source File: MultiTextUI.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #13
Source File: HTMLEditorKit.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Returns a string anchor if the passed in element has a * USEMAP that contains the passed in location. */ @SuppressWarnings("deprecation") 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; }
Example #14
Source File: MultiTextUI.java From Java8CN with Apache License 2.0 | 5 votes |
/** * Invokes the <code>getEditorKit</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 EditorKit getEditorKit(JTextComponent a) { EditorKit returnValue = ((TextUI) (uis.elementAt(0))).getEditorKit(a); for (int i = 1; i < uis.size(); i++) { ((TextUI) (uis.elementAt(i))).getEditorKit(a); } return returnValue; }
Example #15
Source File: MultiTextUI.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Invokes the <code>getEditorKit</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 EditorKit getEditorKit(JTextComponent a) { EditorKit returnValue = ((TextUI) (uis.elementAt(0))).getEditorKit(a); for (int i = 1; i < uis.size(); i++) { ((TextUI) (uis.elementAt(i))).getEditorKit(a); } return returnValue; }
Example #16
Source File: MultiTextUI.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #17
Source File: MultiTextUI.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #18
Source File: MultiTextUI.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #19
Source File: MultiTextUI.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * 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> * * @deprecated replaced by * {@link #modelToView2D(JTextComponent, int, Position.Bias)} */ @Deprecated(since = "9") @Override 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; }
Example #20
Source File: MultiTextUI.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #21
Source File: MultiTextUI.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
/** * 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) throws BadLocationException { Rectangle returnValue = ((TextUI) (uis.elementAt(0))).modelToView(a,b); for (int i = 1; i < uis.size(); i++) { ((TextUI) (uis.elementAt(i))).modelToView(a,b); } return returnValue; }
Example #22
Source File: AquaTextFieldSearch.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
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); } }
Example #23
Source File: AquaTextFieldSearch.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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); } }
Example #24
Source File: MultiTextUI.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #25
Source File: HTMLEditorKit.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #26
Source File: HTMLEditorKit.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #27
Source File: HTMLEditorKit.java From Java8CN with Apache License 2.0 | 5 votes |
/** * 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; }
Example #28
Source File: MultiTextUI.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #29
Source File: AquaTextFieldSearch.java From hottub with GNU General Public License v2.0 | 5 votes |
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); } }
Example #30
Source File: MultiTextUI.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * 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; }