/** * Sets the UI used by this text area. This is overridden so only the * right-click popup menu's UI is updated. The look and feel of an * <code>RTextArea</code> is independent of the Java Look and Feel, and so * this method does not change the text area itself. Subclasses (such as * <code>RSyntaxTextArea</code> can call <code>setRTextAreaUI</code> if * they wish to install a new UI. * * @param ui This parameter is ignored. */ @Override public final void setUI(TextUI ui) { // Update the popup menu's ui. if (popupMenu!=null) { SwingUtilities.updateComponentTreeUI(popupMenu); } // Set things like selection color, selected text color, etc. to // laf defaults (if values are null or UIResource instances). RTextAreaUI rtaui = (RTextAreaUI)getUI(); if (rtaui!=null) { rtaui.installDefaults(); } }
protected void repaintListHighlight(HighlightInfo info) { // Note: We're relying on implementation here, not interface. Yuck... if (info instanceof LayeredHighlightInfoImpl) { LayeredHighlightInfoImpl lhi = (LayeredHighlightInfoImpl)info; if (lhi.width > 0 && lhi.height > 0) { textArea.repaint(lhi.x, lhi.y, lhi.width, lhi.height); } } else { TextUI ui = textArea.getUI(); ui.damageRange(textArea, info.getStartOffset(),info.getEndOffset()); //safeDamageRange(info.p0, info.p1); } }
/** * We override this method because the super version gives us an entirely * new <code>Document</code>, thus requiring us to re-attach our Undo * manager. With this version we just replace the text. */ @Override public void read(Reader in, Object desc) throws IOException { RTextAreaEditorKit kit = (RTextAreaEditorKit)getUI().getEditorKit(this); setText(null); Document doc = getDocument(); if (desc != null) { doc.putProperty(Document.StreamDescriptionProperty, desc); } try { // NOTE: Resets the "line separator" property. kit.read(in, doc, 0); } catch (BadLocationException e) { throw new IOException(e.getMessage()); } }
/** * Adds a special "marked occurrence" highlight. * * @param start * @param end * @param p * @return A tag to reference the highlight later. * @throws BadLocationException * @see #clearMarkAllHighlights() */ Object addMarkAllHighlight(int start, int end, HighlightPainter p) throws BadLocationException { Document doc = textArea.getDocument(); TextUI mapper = textArea.getUI(); // Always layered highlights for marked occurrences. HighlightInfoImpl i = new LayeredHighlightInfoImpl(); i.setPainter(p); i.p0 = doc.createPosition(start); // HACK: Use "end-1" to prevent chars the user types at the "end" of // the highlight to be absorbed into the highlight (default Highlight // behavior). i.p1 = doc.createPosition(end-1); markAllHighlights.add(i); mapper.damageRange(textArea, start, end); return i; }
/** * Adds a special "marked occurrence" highlight. * * @param start * @param end * @param p * @return A tag to reference the highlight later. * @throws BadLocationException * @see #clearMarkOccurrencesHighlights() */ Object addMarkedOccurrenceHighlight(int start, int end, SmartHighlightPainter p) throws BadLocationException { Document doc = textArea.getDocument(); TextUI mapper = textArea.getUI(); // Always layered highlights for marked occurrences. SyntaxLayeredHighlightInfoImpl i = new SyntaxLayeredHighlightInfoImpl(); i.setPainter(p); i.setStartOffset(doc.createPosition(start)); // HACK: Use "end-1" to prevent chars the user types at the "end" of // the highlight to be absorbed into the highlight (default Highlight // behavior). i.setEndOffset(doc.createPosition(end-1)); markedOccurrences.add(i); mapper.damageRange(textArea, start, end); return i; }
TextUI mapper = textArea.getUI(); Rectangle r = mapper.modelToView(textArea, getDot());
RTextAreaUI ui = (RTextAreaUI)textArea.getUI(); View v = ui.getRootView(textArea).getView(0); Document doc = textArea.getDocument();
RTextAreaUI ui = (RTextAreaUI)textArea.getUI(); View v = ui.getRootView(textArea).getView(0);
RTextAreaUI ui = (RTextAreaUI)textArea.getUI(); View v = ui.getRootView(textArea).getView(0);
dot = textArea.getUI().getNextVisualPositionFrom( textArea, dot, Position.Bias.Forward, direction, bias);
TextUI mapper = textArea.getUI();
RTextAreaEditorKit kit = (RTextAreaEditorKit)textArea.getUI(). getEditorKit(textArea);
/** * Sets the UI used by this text area. This is overridden so only the * right-click popup menu's UI is updated. The look and feel of an * <code>RTextArea</code> is independent of the Java Look and Feel, and so * this method does not change the text area itself. Subclasses (such as * <code>RSyntaxTextArea</code> can call <code>setRTextAreaUI</code> if * they wish to install a new UI. * * @param ui This parameter is ignored. */ public final void setUI(TextUI ui) { // Update the popup menu's ui. if (popupMenu!=null) { SwingUtilities.updateComponentTreeUI(popupMenu); } // Set things like selection color, selected text color, etc. to // laf defaults (if values are null or UIResource instances). RTextAreaUI rtaui = (RTextAreaUI)getUI(); if (rtaui!=null) { rtaui.installDefaults(); } }
/** * Removes all parser highlights. * * @see #addParserHighlight(int, int, Color, javax.swing.text.Highlighter.HighlightPainter) */ void clearParserHighlights() { for (int i=0; i<parserHighlights.size(); i++) { Object tag = parserHighlights.get(i); if (tag instanceof LayeredHighlightInfo) { LayeredHighlightInfo lhi = (LayeredHighlightInfo)tag; if (lhi.width > 0 && lhi.height > 0) { textArea.repaint(lhi.x, lhi.y, lhi.width, lhi.height); } } else { HighlightInfo info = (HighlightInfo) tag; TextUI ui = textArea.getUI(); ui.damageRange(textArea, info.getStartOffset(),info.getEndOffset()); //safeDamageRange(info.p0, info.p1); } } parserHighlights.clear(); }
private void removeListHighlight(List list, Object tag) { if (tag instanceof LayeredHighlightInfo) { LayeredHighlightInfo lhi = (LayeredHighlightInfo)tag; if (lhi.width > 0 && lhi.height > 0) { textArea.repaint(lhi.x, lhi.y, lhi.width, lhi.height); } } else { HighlightInfo info = (HighlightInfo) tag; TextUI ui = textArea.getUI(); ui.damageRange(textArea, info.getStartOffset(),info.getEndOffset()); //safeDamageRange(info.p0, info.p1); } list.remove(tag); }
/** * Removes a "marked occurrences" highlight from the view. * * @param tag The reference to the highlight * @see #addMarkedOccurrenceHighlight(int, int, javax.swing.text.Highlighter.HighlightPainter) */ void removeMarkOccurrencesHighlight(Object tag) { if (tag instanceof LayeredHighlightInfo) { LayeredHighlightInfo lhi = (LayeredHighlightInfo)tag; if (lhi.width > 0 && lhi.height > 0) { textArea.repaint(lhi.x, lhi.y, lhi.width, lhi.height); } } else { HighlightInfo info = (HighlightInfo) tag; TextUI ui = textArea.getUI(); ui.damageRange(textArea, info.getStartOffset(),info.getEndOffset()); //safeDamageRange(info.p0, info.p1); } markedOccurrences.remove(tag); }
protected void repaintListHighlight(HighlightInfo info) { // Note: We're relying on implementation here, not interface. Yuck... if (info instanceof LayeredHighlightInfoImpl) { LayeredHighlightInfoImpl lhi = (LayeredHighlightInfoImpl)info; if (lhi.width > 0 && lhi.height > 0) { textArea.repaint(lhi.x, lhi.y, lhi.width, lhi.height); } } else { TextUI ui = textArea.getUI(); ui.damageRange(textArea, info.getStartOffset(),info.getEndOffset()); //safeDamageRange(info.p0, info.p1); } }
/** * We override this method because the super version gives us an entirely * new <code>Document</code>, thus requiring us to re-attach our Undo * manager. With this version we just replace the text. */ public void read(Reader in, Object desc) throws IOException { RTextAreaEditorKit kit = (RTextAreaEditorKit)getUI().getEditorKit(this); setText(null); Document doc = getDocument(); if (desc != null) doc.putProperty(Document.StreamDescriptionProperty, desc); try { // NOTE: Resets the "line separator" property. kit.read(in, doc, 0); } catch (BadLocationException e) { throw new IOException(e.getMessage()); } }
/** * We override this method because the super version gives us an entirely * new <code>Document</code>, thus requiring us to re-attach our Undo * manager. With this version we just replace the text. */ public void read(Reader in, Object desc) throws IOException { RTextAreaEditorKit kit = (RTextAreaEditorKit)getUI().getEditorKit(this); setText(null); Document doc = getDocument(); if (desc != null) doc.putProperty(Document.StreamDescriptionProperty, desc); try { // NOTE: Resets the "line separator" property. kit.read(in, doc, 0); } catch (BadLocationException e) { throw new IOException(e.getMessage()); } }
/** * We override this method because the super version gives us an entirely * new <code>Document</code>, thus requiring us to re-attach our Undo * manager. With this version we just replace the text. */ @Override public void read(Reader in, Object desc) throws IOException { RTextAreaEditorKit kit = (RTextAreaEditorKit)getUI().getEditorKit(this); setText(null); Document doc = getDocument(); if (desc != null) { doc.putProperty(Document.StreamDescriptionProperty, desc); } try { // NOTE: Resets the "line separator" property. kit.read(in, doc, 0); } catch (BadLocationException e) { throw new IOException(e.getMessage()); } }