本文整理匯總了Java中javax.swing.plaf.TextUI.damageRange方法的典型用法代碼示例。如果您正苦於以下問題:Java TextUI.damageRange方法的具體用法?Java TextUI.damageRange怎麽用?Java TextUI.damageRange使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.plaf.TextUI
的用法示例。
在下文中一共展示了TextUI.damageRange方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addMarkAllHighlight
import javax.swing.plaf.TextUI; //導入方法依賴的package包/類
/**
* 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;
}
示例2: addMarkedOccurrenceHighlight
import javax.swing.plaf.TextUI; //導入方法依賴的package包/類
/**
* 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;
}
示例3: run
import javax.swing.plaf.TextUI; //導入方法依賴的package包/類
/**
* Executes range(s) damage and cleans range queue.
*/
public synchronized void run() {
if (component != null) {
TextUI mapper = component.getUI();
if (mapper != null && lastDoc == component.getDocument()) {
// the Document should be the same to properly
// display highlights
int len = p0.size();
for (int i = 0; i < len; i++){
mapper.damageRange(component,
p0.get(i).getOffset(),
p1.get(i).getOffset());
}
}
}
p0.clear();
p1.clear();
// release reference
lastDoc = null;
}
示例4: addMarkedOccurrenceHighlight
import javax.swing.plaf.TextUI; //導入方法依賴的package包/類
/**
* Adds a special "marked occurrence" highlight.
*
* @param start
* @param end
* @param p
* @return
* @throws BadLocationException
* @see {@link #removeMarkOccurrencesHighlight(Object)}
*/
Object addMarkedOccurrenceHighlight(int start, int end,
MarkOccurrencesHighlightPainter p) throws BadLocationException {
Document doc = textArea.getDocument();
TextUI mapper = textArea.getUI();
// Always layered highlights for marked occurrences.
HighlightInfo i = new LayeredHighlightInfo();
i.painter = 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);
markedOccurrences.add(i);
mapper.damageRange(textArea, start, end);
return i;
}
示例5: clearParserHighlights
import javax.swing.plaf.TextUI; //導入方法依賴的package包/類
/**
* 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();
}
示例6: repaintListHighlight
import javax.swing.plaf.TextUI; //導入方法依賴的package包/類
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);
}
}
示例7: addParserHighlight
import javax.swing.plaf.TextUI; //導入方法依賴的package包/類
/**
* Adds a highlight from a parser.
*
* @param notice The notice from a {@link Parser}.
* @return A tag with which to reference the highlight.
* @throws BadLocationException
* @see #clearParserHighlights()
* @see #clearParserHighlights(Parser)
*/
HighlightInfo addParserHighlight(ParserNotice notice, HighlightPainter p)
throws BadLocationException {
Document doc = textArea.getDocument();
TextUI mapper = textArea.getUI();
int start = notice.getOffset();
int end = 0;
if (start==-1) { // Could just define an invalid line number
int line = notice.getLine();
Element root = doc.getDefaultRootElement();
if (line>=0 && line<root.getElementCount()) {
Element elem = root.getElement(line);
start = elem.getStartOffset();
end = elem.getEndOffset();
}
}
else {
end = start + notice.getLength();
}
// Always layered highlights for parser highlights.
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));
i.notice = notice;//i.color = notice.getColor();
parserHighlights.add(i);
mapper.damageRange(textArea, start, end);
return i;
}
示例8: damageRange
import javax.swing.plaf.TextUI; //導入方法依賴的package包/類
/**
* Calls the {@link TextUI#damageRange(JTextComponent, int, int)} method for
* all the UI delegates managed by this <code>MultiTextUI</code>.
*
* @param tc the component.
* @param start the start position.
* @param end the end position.
*/
public void damageRange(JTextComponent tc, int start, int end)
{
Iterator iterator = uis.iterator();
while (iterator.hasNext())
{
TextUI ui = (TextUI) iterator.next();
ui.damageRange(tc, start, end);
}
}
示例9: addParserHighlight
import javax.swing.plaf.TextUI; //導入方法依賴的package包/類
/**
* Adds a special "marked occurrence" highlight.
*
* @param notice
* The notice from a {@link Parser}.
* @return A tag with which to reference the highlight.
* @throws BadLocationException
* @see {@link #clearParserHighlights()}
*/
Object addParserHighlight(ParserNotice notice, HighlightPainter p)
throws BadLocationException {
Document doc = textArea.getDocument();
TextUI mapper = textArea.getUI();
int start = notice.getOffset();
int end = 0;
if (start == -1) { // Could just define an invalid line number
int line = notice.getLine();
Element root = doc.getDefaultRootElement();
if (line >= 0 && line < root.getElementCount()) {
Element elem = root.getElement(line);
start = elem.getStartOffset();
end = elem.getEndOffset();
}
}
else {
end = start + notice.getLength();
}
// Always layered highlights for parser highlights.
HighlightInfo i = new LayeredHighlightInfo();
i.painter = p;
i.p0 = doc.createPosition(start);
i.p1 = doc.createPosition(end);
i.notice = notice;// i.color = notice.getColor();
parserHighlights.add(i);
mapper.damageRange(textArea, start, end);
return i;
}
示例10: removeListHighlight
import javax.swing.plaf.TextUI; //導入方法依賴的package包/類
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);
}
示例11: damageRange
import javax.swing.plaf.TextUI; //導入方法依賴的package包/類
/**
* Calls the {@link TextUI#damageRange(JTextComponent, int, int)} method for
* all the UI delegates managed by this <code>MultiTextUI</code>.
*
* @param tc the component.
* @param start the start position.
* @param end the end position.
*/
public void damageRange(JTextComponent tc, int start, int end)
{
Iterator iterator = uis.iterator();
while (iterator.hasNext())
{
TextUI ui = (TextUI) iterator.next();
ui.damageRange(tc, start, end);
}
}
示例12: removeAllHighlights
import javax.swing.plaf.TextUI; //導入方法依賴的package包/類
public void removeAllHighlights()
{
// Repaint damaged region.
int minX = 0;
int maxX = 0;
int minY = 0;
int maxY = 0;
int p0 = -1;
int p1 = -1;
for (Iterator i = highlights.iterator(); i.hasNext();)
{
HighlightEntry e = (HighlightEntry) i.next();
if (e instanceof LayerHighlightEntry)
{
LayerHighlightEntry le = (LayerHighlightEntry) e;
Rectangle r = le.paintRect;
minX = Math.min(r.x, minX);
maxX = Math.max(r.x + r.width, maxX);
minY = Math.min(r.y, minY);
maxY = Math.max(r.y + r.height, maxY);
}
else
{
if (p0 == -1 || p1 == -1)
{
p0 = e.getStartOffset();
p1 = e.getEndOffset();
}
else
{
p0 = Math.min(p0, e.getStartOffset());
p1 = Math.max(p1, e.getEndOffset());
}
}
if (minX != maxX && minY != maxY)
textComponent.repaint(minX, minY, maxX - minX, maxY - minY);
if (p0 != -1 && p1 != -1)
{
TextUI ui = textComponent.getUI();
ui.damageRange(textComponent, p0, p1);
}
}
highlights.clear();
}
示例13: removeAllHighlights
import javax.swing.plaf.TextUI; //導入方法依賴的package包/類
public void removeAllHighlights()
{
// Repaint damaged region.
int minX = 0;
int maxX = 0;
int minY = 0;
int maxY = 0;
int p0 = -1;
int p1 = -1;
for (Iterator i = highlights.iterator(); i.hasNext();)
{
HighlightEntry e = (HighlightEntry) i.next();
if (e instanceof LayerHighlightEntry)
{
LayerHighlightEntry le = (LayerHighlightEntry) e;
Rectangle r = le.paintRect;
minX = Math.min(r.x, minX);
maxX = Math.max(r.x + r.width, maxX);
minY = Math.min(r.y, minY);
maxY = Math.max(r.y + r.height, maxY);
}
else
{
if (p0 == -1 || p1 == -1)
{
p0 = e.getStartOffset();
p1 = e.getEndOffset();
}
else
{
p0 = Math.min(p0, e.getStartOffset());
p1 = Math.max(p1, e.getEndOffset());
}
}
if (minX != maxX && minY != maxY)
textComponent.repaint(minX, minY, maxX - minX, maxY - minY);
if (p0 != -1 && p1 != -1)
{
TextUI ui = textComponent.getUI();
ui.damageRange(textComponent, p0, p1);
}
}
highlights.clear();
}