Java 类javax.swing.text.Highlighter 实例源码

项目:EditCalculateAndChart    文件:TextAreaMouseListener.java   
@Override
    public void mouseExited(MouseEvent e) {

              JTextArea area = TEdit.getTextArea();
         Highlighter hilite = area.getHighlighter();
         Highlighter.Highlight[] hilites = hilite.getHighlights();
         if(hilites != null&&hilites.length>0)
             TEdit.getSwingPool().put("area.hilites", hilites);
        /*
     if(hilites != null&&hilites.length>0){
             TEdit.setEnabled("Delete", true);
             TEdit.setEnabled("Calc",true);
         }
         else{
             TEdit.setEnabled("Delete", false);
             TEdit.setEnabled("Calc",false);
         }
*/
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
项目:powertext    文件:RSyntaxTextArea.java   
/**
 * Sets the highlighter used by this text area.
 *
 * @param h The highlighter.
 * @throws IllegalArgumentException If <code>h</code> is not an instance
 *         of {@link RSyntaxTextAreaHighlighter}.
 */
@Override
public void setHighlighter(Highlighter h) {

    // Ugh, many RSTA methods assume a non-null highlighter.  This is kind
    // of icky, but most applications never *don't* want a highlighter.
    // See #189 - BasicTextUI clears highlighter by setting it to null there
    if (h == null) {
        h = new RSyntaxTextAreaHighlighter();
    }

    if (!(h instanceof RSyntaxTextAreaHighlighter)) {
        throw new IllegalArgumentException("RSyntaxTextArea requires " +
            "an RSyntaxTextAreaHighlighter for its Highlighter");
    }
    super.setHighlighter(h);
}
项目:OpenJSharp    文件:SwingUtilities2.java   
/**
 * Determines whether the SelectedTextColor should be used for painting text
 * foreground for the specified highlight.
 *
 * Returns true only if the highlight painter for the specified highlight
 * is the swing painter (whether inner class of javax.swing.text.DefaultHighlighter
 * or com.sun.java.swing.plaf.windows.WindowsTextUI) and its background color
 * is null or equals to the selection color of the text component.
 *
 * This is a hack for fixing both bugs 4761990 and 5003294
 */
public static boolean useSelectedTextColor(Highlighter.Highlight h, JTextComponent c) {
    Highlighter.HighlightPainter painter = h.getPainter();
    String painterClass = painter.getClass().getName();
    if (painterClass.indexOf("javax.swing.text.DefaultHighlighter") != 0 &&
            painterClass.indexOf("com.sun.java.swing.plaf.windows.WindowsTextUI") != 0) {
        return false;
    }
    try {
        DefaultHighlighter.DefaultHighlightPainter defPainter =
                (DefaultHighlighter.DefaultHighlightPainter) painter;
        if (defPainter.getColor() != null &&
                !defPainter.getColor().equals(c.getSelectionColor())) {
            return false;
        }
    } catch (ClassCastException e) {
        return false;
    }
    return true;
}
项目:jdk8u-jdk    文件:SwingUtilities2.java   
/**
 * Determines whether the SelectedTextColor should be used for painting text
 * foreground for the specified highlight.
 *
 * Returns true only if the highlight painter for the specified highlight
 * is the swing painter (whether inner class of javax.swing.text.DefaultHighlighter
 * or com.sun.java.swing.plaf.windows.WindowsTextUI) and its background color
 * is null or equals to the selection color of the text component.
 *
 * This is a hack for fixing both bugs 4761990 and 5003294
 */
public static boolean useSelectedTextColor(Highlighter.Highlight h, JTextComponent c) {
    Highlighter.HighlightPainter painter = h.getPainter();
    String painterClass = painter.getClass().getName();
    if (painterClass.indexOf("javax.swing.text.DefaultHighlighter") != 0 &&
            painterClass.indexOf("com.sun.java.swing.plaf.windows.WindowsTextUI") != 0) {
        return false;
    }
    try {
        DefaultHighlighter.DefaultHighlightPainter defPainter =
                (DefaultHighlighter.DefaultHighlightPainter) painter;
        if (defPainter.getColor() != null &&
                !defPainter.getColor().equals(c.getSelectionColor())) {
            return false;
        }
    } catch (ClassCastException e) {
        return false;
    }
    return true;
}
项目:openjdk-jdk10    文件:TreePosTest.java   
/** Show an entry that has been selected. */
private void showEntry(Entry e) {
    try {
        // update simple fields
        setTitle(e.file.getName());
        checkField.setText(e.check);
        enclPanel.setInfo(e.encl);
        selfPanel.setInfo(e.self);
        // show file text with highlights
        body.setText(e.file.getCharContent(true).toString());
        Highlighter highlighter = body.getHighlighter();
        highlighter.removeAllHighlights();
        addHighlight(highlighter, e.encl, enclColor);
        addHighlight(highlighter, e.self, selfColor);
        scroll(body, getMinPos(enclPanel.info, selfPanel.info));
    } catch (IOException ex) {
        body.setText("Cannot read " + e.file.getName() + ": " + e);
    }
}
项目:openjdk-jdk10    文件:TreePosTest.java   
/** Add a highlighted region based on the positions in an Info object. */
private void addHighlight(Highlighter h, Info info, Color c) {
    int start = info.start;
    int end = info.end;
    if (start == -1 && end == -1)
        return;
    if (start == -1)
        start = end;
    if (end == -1)
        end = start;
    try {
        h.addHighlight(info.start, info.end,
                new DefaultHighlighter.DefaultHighlightPainter(c));
        if (info.pos != -1) {
            Color c2 = new Color(c.getRed(), c.getGreen(), c.getBlue(), (int)(.4f * 255)); // 40%
            h.addHighlight(info.pos, info.pos + 1,
                new DefaultHighlighter.DefaultHighlightPainter(c2));
        }
    } catch (BadLocationException e) {
        e.printStackTrace();
    }
}
项目:openjdk-jdk10    文件:CheckAttributedTree.java   
/** Show an entry that has been selected. */
private void showEntry(Entry e) {
    try {
        // update simple fields
        setTitle(e.file.getName());
        checkField.setText(e.check);
        enclPanel.setInfo(e.encl);
        selfPanel.setInfo(e.self);
        // show file text with highlights
        body.setText(e.file.getCharContent(true).toString());
        Highlighter highlighter = body.getHighlighter();
        highlighter.removeAllHighlights();
        addHighlight(highlighter, e.encl, enclColor);
        addHighlight(highlighter, e.self, selfColor);
        scroll(body, getMinPos(enclPanel.info, selfPanel.info));
    } catch (IOException ex) {
        body.setText("Cannot read " + e.file.getName() + ": " + e);
    }
}
项目:openjdk-jdk10    文件:CheckAttributedTree.java   
/** Add a highlighted region based on the positions in an Info object. */
private void addHighlight(Highlighter h, Info info, Color c) {
    int start = info.start;
    int end = info.end;
    if (start == -1 && end == -1)
        return;
    if (start == -1)
        start = end;
    if (end == -1)
        end = start;
    try {
        h.addHighlight(info.start, info.end,
                new DefaultHighlighter.DefaultHighlightPainter(c));
        if (info.pos != -1) {
            Color c2 = new Color(c.getRed(), c.getGreen(), c.getBlue(), (int)(.4f * 255)); // 40%
            h.addHighlight(info.pos, info.pos + 1,
                new DefaultHighlighter.DefaultHighlightPainter(c2));
        }
    } catch (BadLocationException e) {
        e.printStackTrace();
    }
}
项目:openjdk-jdk10    文件:SwingUtilities2.java   
/**
 * Determines whether the SelectedTextColor should be used for painting text
 * foreground for the specified highlight.
 *
 * Returns true only if the highlight painter for the specified highlight
 * is the swing painter (whether inner class of javax.swing.text.DefaultHighlighter
 * or com.sun.java.swing.plaf.windows.WindowsTextUI) and its background color
 * is null or equals to the selection color of the text component.
 *
 * This is a hack for fixing both bugs 4761990 and 5003294
 */
public static boolean useSelectedTextColor(Highlighter.Highlight h, JTextComponent c) {
    Highlighter.HighlightPainter painter = h.getPainter();
    String painterClass = painter.getClass().getName();
    if (painterClass.indexOf("javax.swing.text.DefaultHighlighter") != 0 &&
            painterClass.indexOf("com.sun.java.swing.plaf.windows.WindowsTextUI") != 0) {
        return false;
    }
    try {
        DefaultHighlighter.DefaultHighlightPainter defPainter =
                (DefaultHighlighter.DefaultHighlightPainter) painter;
        if (defPainter.getColor() != null &&
                !defPainter.getColor().equals(c.getSelectionColor())) {
            return false;
        }
    } catch (ClassCastException e) {
        return false;
    }
    return true;
}
项目:openjdk-jdk10    文件:CaretFloatingPointAPITest.java   
private void updateSelection() {
    Highlighter h = component.getHighlighter();
    if (h != null) {
        int p0 = Math.min(dot, mark);
        int p1 = Math.max(dot, mark);

        if (p0 == p1 || !selectionVisible) {
            if (selectionTag != null) {
                h.removeHighlight(selectionTag);
                selectionTag = null;
            }
        } else {
            try {
                if (selectionTag != null) {
                    h.changeHighlight(selectionTag, p0, p1);
                } else {
                    Highlighter.HighlightPainter p = getSelectionPainter();
                    selectionTag = h.addHighlight(p0, p1, p);
                }
            } catch (BadLocationException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
项目:openjdk9    文件:TreePosTest.java   
/** Show an entry that has been selected. */
private void showEntry(Entry e) {
    try {
        // update simple fields
        setTitle(e.file.getName());
        checkField.setText(e.check);
        enclPanel.setInfo(e.encl);
        selfPanel.setInfo(e.self);
        // show file text with highlights
        body.setText(e.file.getCharContent(true).toString());
        Highlighter highlighter = body.getHighlighter();
        highlighter.removeAllHighlights();
        addHighlight(highlighter, e.encl, enclColor);
        addHighlight(highlighter, e.self, selfColor);
        scroll(body, getMinPos(enclPanel.info, selfPanel.info));
    } catch (IOException ex) {
        body.setText("Cannot read " + e.file.getName() + ": " + e);
    }
}
项目:openjdk9    文件:TreePosTest.java   
/** Add a highlighted region based on the positions in an Info object. */
private void addHighlight(Highlighter h, Info info, Color c) {
    int start = info.start;
    int end = info.end;
    if (start == -1 && end == -1)
        return;
    if (start == -1)
        start = end;
    if (end == -1)
        end = start;
    try {
        h.addHighlight(info.start, info.end,
                new DefaultHighlighter.DefaultHighlightPainter(c));
        if (info.pos != -1) {
            Color c2 = new Color(c.getRed(), c.getGreen(), c.getBlue(), (int)(.4f * 255)); // 40%
            h.addHighlight(info.pos, info.pos + 1,
                new DefaultHighlighter.DefaultHighlightPainter(c2));
        }
    } catch (BadLocationException e) {
        e.printStackTrace();
    }
}
项目:openjdk9    文件:CheckAttributedTree.java   
/** Show an entry that has been selected. */
private void showEntry(Entry e) {
    try {
        // update simple fields
        setTitle(e.file.getName());
        checkField.setText(e.check);
        enclPanel.setInfo(e.encl);
        selfPanel.setInfo(e.self);
        // show file text with highlights
        body.setText(e.file.getCharContent(true).toString());
        Highlighter highlighter = body.getHighlighter();
        highlighter.removeAllHighlights();
        addHighlight(highlighter, e.encl, enclColor);
        addHighlight(highlighter, e.self, selfColor);
        scroll(body, getMinPos(enclPanel.info, selfPanel.info));
    } catch (IOException ex) {
        body.setText("Cannot read " + e.file.getName() + ": " + e);
    }
}
项目:openjdk9    文件:CheckAttributedTree.java   
/** Add a highlighted region based on the positions in an Info object. */
private void addHighlight(Highlighter h, Info info, Color c) {
    int start = info.start;
    int end = info.end;
    if (start == -1 && end == -1)
        return;
    if (start == -1)
        start = end;
    if (end == -1)
        end = start;
    try {
        h.addHighlight(info.start, info.end,
                new DefaultHighlighter.DefaultHighlightPainter(c));
        if (info.pos != -1) {
            Color c2 = new Color(c.getRed(), c.getGreen(), c.getBlue(), (int)(.4f * 255)); // 40%
            h.addHighlight(info.pos, info.pos + 1,
                new DefaultHighlighter.DefaultHighlightPainter(c2));
        }
    } catch (BadLocationException e) {
        e.printStackTrace();
    }
}
项目:openjdk9    文件:SwingUtilities2.java   
/**
 * Determines whether the SelectedTextColor should be used for painting text
 * foreground for the specified highlight.
 *
 * Returns true only if the highlight painter for the specified highlight
 * is the swing painter (whether inner class of javax.swing.text.DefaultHighlighter
 * or com.sun.java.swing.plaf.windows.WindowsTextUI) and its background color
 * is null or equals to the selection color of the text component.
 *
 * This is a hack for fixing both bugs 4761990 and 5003294
 */
public static boolean useSelectedTextColor(Highlighter.Highlight h, JTextComponent c) {
    Highlighter.HighlightPainter painter = h.getPainter();
    String painterClass = painter.getClass().getName();
    if (painterClass.indexOf("javax.swing.text.DefaultHighlighter") != 0 &&
            painterClass.indexOf("com.sun.java.swing.plaf.windows.WindowsTextUI") != 0) {
        return false;
    }
    try {
        DefaultHighlighter.DefaultHighlightPainter defPainter =
                (DefaultHighlighter.DefaultHighlightPainter) painter;
        if (defPainter.getColor() != null &&
                !defPainter.getColor().equals(c.getSelectionColor())) {
            return false;
        }
    } catch (ClassCastException e) {
        return false;
    }
    return true;
}
项目:Compilador    文件:TextPanel.java   
public void highlight(String pattern){
    JTextComponent textComp = this.textPane;
    //First remove all old highlights
    removeHighlights();
    try{
        Highlighter hilite = textComp.getHighlighter();
        Document doc = textComp.getDocument();
        String text = doc.getText(0, doc.getLength());
        int pos = 0;

        //Search for pattern
        while ((pos = text.indexOf(pattern, pos)) >= 0) {
            // Create highlighter using private painter and apply around pattern
            hilite.addHighlight(pos, pos+pattern.length(), this.highlightPainter_yellow);
            pos += pattern.length();
        }

    }catch(Exception exp){

    }
}
项目:Compilador    文件:TextPanel.java   
public void highlight(String pattern){
    JTextComponent textComp = this.textPane;
    //First remove all old highlights
    removeHighlights();
    try{
        Highlighter hilite = textComp.getHighlighter();
        Document doc = textComp.getDocument();
        String text = doc.getText(0, doc.getLength());
        int pos = 0;

        //Search for pattern
        while ((pos = text.indexOf(pattern, pos)) >= 0) {
            // Create highlighter using private painter and apply around pattern
            hilite.addHighlight(pos, pos+pattern.length(), this.highlightPainter_yellow);
            pos += pattern.length();
        }

    }catch(Exception exp){

    }
}
项目:jdk8u_jdk    文件:SwingUtilities2.java   
/**
 * Determines whether the SelectedTextColor should be used for painting text
 * foreground for the specified highlight.
 *
 * Returns true only if the highlight painter for the specified highlight
 * is the swing painter (whether inner class of javax.swing.text.DefaultHighlighter
 * or com.sun.java.swing.plaf.windows.WindowsTextUI) and its background color
 * is null or equals to the selection color of the text component.
 *
 * This is a hack for fixing both bugs 4761990 and 5003294
 */
public static boolean useSelectedTextColor(Highlighter.Highlight h, JTextComponent c) {
    Highlighter.HighlightPainter painter = h.getPainter();
    String painterClass = painter.getClass().getName();
    if (painterClass.indexOf("javax.swing.text.DefaultHighlighter") != 0 &&
            painterClass.indexOf("com.sun.java.swing.plaf.windows.WindowsTextUI") != 0) {
        return false;
    }
    try {
        DefaultHighlighter.DefaultHighlightPainter defPainter =
                (DefaultHighlighter.DefaultHighlightPainter) painter;
        if (defPainter.getColor() != null &&
                !defPainter.getColor().equals(c.getSelectionColor())) {
            return false;
        }
    } catch (ClassCastException e) {
        return false;
    }
    return true;
}
项目:jdk8u_jdk    文件:CaretFloatingPointAPITest.java   
private void updateSelection() {
    Highlighter h = component.getHighlighter();
    if (h != null) {
        int p0 = Math.min(dot, mark);
        int p1 = Math.max(dot, mark);

        if (p0 == p1 || !selectionVisible) {
            if (selectionTag != null) {
                h.removeHighlight(selectionTag);
                selectionTag = null;
            }
        } else {
            try {
                if (selectionTag != null) {
                    h.changeHighlight(selectionTag, p0, p1);
                } else {
                    Highlighter.HighlightPainter p = getSelectionPainter();
                    selectionTag = h.addHighlight(p0, p1, p);
                }
            } catch (BadLocationException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
项目:littleluck    文件:SnippetHighlighter.java   
/**
    * Renders the highlights.
    *
    * @param g the graphics context
    */
   public void paint(Graphics g) {
       // PENDING(prinz) - should cull ranges not visible
       int len = highlights.size();
       for (int i = 0; i < len; i++) {
    HighlightInfo info = highlights.elementAt(i);
    if (!(info instanceof LayeredHighlightInfo)) {
    // Avoid allocing unless we need it.
    Rectangle a = component.getBounds();
    Insets insets = component.getInsets();
    a.x = insets.left;
    a.y = insets.top;
    a.width -= insets.left + insets.right;
    a.height -= insets.top + insets.bottom;
    for (; i < len; i++) {
        info = highlights.elementAt(i);
        if (!(info instanceof LayeredHighlightInfo)) {
        Highlighter.HighlightPainter p = info.getPainter();
        p.paint(g, info.getStartOffset(), info.getEndOffset(),
            a, component);
        }
    }
    }
}
   }
项目:littleluck    文件:SnippetHighlighter.java   
/**
    * Adds a highlight to the view.  Returns a tag that can be used 
    * to refer to the highlight.
    *
    * @param p0   the start offset of the range to highlight >= 0
    * @param p1   the end offset of the range to highlight >= p0
    * @param p    the painter to use to actually render the highlight
    * @return     an object that can be used as a tag
    *   to refer to the highlight
    * @exception BadLocationException if the specified location is invalid
    */
   public Object addHighlight(int p0, int p1, Highlighter.HighlightPainter p) throws BadLocationException {
Document doc = component.getDocument();
HighlightInfo i = (getDrawsLayeredHighlights() &&
           (p instanceof LayeredHighlighter.LayerPainter)) ?
                  new LayeredHighlightInfo() : new HighlightInfo();
i.painter = p;
i.p0 = doc.createPosition(p0);
i.p1 = doc.createPosition(p1);
       // For snippets, we want to make sure selection is layered ON TOP
       // since we add transparency to the selection color;  so rather
       // than append the highlight, we insert it in the front.
highlights.insertElementAt(i, 0);
       safeDamageRange(p0, p1);
       return i;
   }
项目:lookaside_java-1.8.0-openjdk    文件:TreePosTest.java   
/** Show an entry that has been selected. */
private void showEntry(Entry e) {
    try {
        // update simple fields
        setTitle(e.file.getName());
        checkField.setText(e.check);
        enclPanel.setInfo(e.encl);
        selfPanel.setInfo(e.self);
        // show file text with highlights
        body.setText(e.file.getCharContent(true).toString());
        Highlighter highlighter = body.getHighlighter();
        highlighter.removeAllHighlights();
        addHighlight(highlighter, e.encl, enclColor);
        addHighlight(highlighter, e.self, selfColor);
        scroll(body, getMinPos(enclPanel.info, selfPanel.info));
    } catch (IOException ex) {
        body.setText("Cannot read " + e.file.getName() + ": " + e);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:TreePosTest.java   
/** Add a highlighted region based on the positions in an Info object. */
private void addHighlight(Highlighter h, Info info, Color c) {
    int start = info.start;
    int end = info.end;
    if (start == -1 && end == -1)
        return;
    if (start == -1)
        start = end;
    if (end == -1)
        end = start;
    try {
        h.addHighlight(info.start, info.end,
                new DefaultHighlighter.DefaultHighlightPainter(c));
        if (info.pos != -1) {
            Color c2 = new Color(c.getRed(), c.getGreen(), c.getBlue(), (int)(.4f * 255)); // 40%
            h.addHighlight(info.pos, info.pos + 1,
                new DefaultHighlighter.DefaultHighlightPainter(c2));
        }
    } catch (BadLocationException e) {
        e.printStackTrace();
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:CheckAttributedTree.java   
/** Show an entry that has been selected. */
private void showEntry(Entry e) {
    try {
        // update simple fields
        setTitle(e.file.getName());
        checkField.setText(e.check);
        enclPanel.setInfo(e.encl);
        selfPanel.setInfo(e.self);
        // show file text with highlights
        body.setText(e.file.getCharContent(true).toString());
        Highlighter highlighter = body.getHighlighter();
        highlighter.removeAllHighlights();
        addHighlight(highlighter, e.encl, enclColor);
        addHighlight(highlighter, e.self, selfColor);
        scroll(body, getMinPos(enclPanel.info, selfPanel.info));
    } catch (IOException ex) {
        body.setText("Cannot read " + e.file.getName() + ": " + e);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:CheckAttributedTree.java   
/** Add a highlighted region based on the positions in an Info object. */
private void addHighlight(Highlighter h, Info info, Color c) {
    int start = info.start;
    int end = info.end;
    if (start == -1 && end == -1)
        return;
    if (start == -1)
        start = end;
    if (end == -1)
        end = start;
    try {
        h.addHighlight(info.start, info.end,
                new DefaultHighlighter.DefaultHighlightPainter(c));
        if (info.pos != -1) {
            Color c2 = new Color(c.getRed(), c.getGreen(), c.getBlue(), (int)(.4f * 255)); // 40%
            h.addHighlight(info.pos, info.pos + 1,
                new DefaultHighlighter.DefaultHighlightPainter(c2));
        }
    } catch (BadLocationException e) {
        e.printStackTrace();
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:SwingUtilities2.java   
/**
 * Determines whether the SelectedTextColor should be used for painting text
 * foreground for the specified highlight.
 *
 * Returns true only if the highlight painter for the specified highlight
 * is the swing painter (whether inner class of javax.swing.text.DefaultHighlighter
 * or com.sun.java.swing.plaf.windows.WindowsTextUI) and its background color
 * is null or equals to the selection color of the text component.
 *
 * This is a hack for fixing both bugs 4761990 and 5003294
 */
public static boolean useSelectedTextColor(Highlighter.Highlight h, JTextComponent c) {
    Highlighter.HighlightPainter painter = h.getPainter();
    String painterClass = painter.getClass().getName();
    if (painterClass.indexOf("javax.swing.text.DefaultHighlighter") != 0 &&
            painterClass.indexOf("com.sun.java.swing.plaf.windows.WindowsTextUI") != 0) {
        return false;
    }
    try {
        DefaultHighlighter.DefaultHighlightPainter defPainter =
                (DefaultHighlighter.DefaultHighlightPainter) painter;
        if (defPainter.getColor() != null &&
                !defPainter.getColor().equals(c.getSelectionColor())) {
            return false;
        }
    } catch (ClassCastException e) {
        return false;
    }
    return true;
}
项目:codebuff    文件:STViz.java   
protected void highlight(JTextComponent comp, int i, int j, boolean scroll) {
    Highlighter highlighter = comp.getHighlighter();
    highlighter.removeAllHighlights();
    try {
        i = toComponentPosition(comp, i);
        j = toComponentPosition(comp, j);
        highlighter.addHighlight(i, j+1, DefaultHighlighter.DefaultPainter);
        if ( scroll ) {
            if ( comp.getCaretPosition()< i || comp.getCaretPosition()>j ) {
                comp.moveCaretPosition(i);
                comp.scrollRectToVisible(comp.modelToView(i));
            }
        }
    }
    catch (BadLocationException ble) {
        errMgr.internalError(tmodel.root.event.scope.st, "bad highlight location", ble);
    }
}
项目:codebuff    文件:STViz.java   
protected void highlight(JTextComponent comp, int i, int j, boolean scroll) {
    Highlighter highlighter = comp.getHighlighter();
    highlighter.removeAllHighlights();
    try {
        i = toComponentPosition(comp, i);
        j = toComponentPosition(comp, j);
        highlighter.addHighlight(i, j+1, DefaultHighlighter.DefaultPainter);
        if ( scroll ) {
            if ( comp.getCaretPosition()< i || comp.getCaretPosition()>j ) {
                comp.moveCaretPosition(i);
                comp.scrollRectToVisible(comp.modelToView(i));
            }
        }
    }
    catch (BadLocationException ble) {
        errMgr.internalError(tmodel.root.event.scope.st, "bad highlight location", ble);
    }
}
项目:codebuff    文件:STViz.java   
protected void highlight(JTextComponent comp, int i, int j, boolean scroll) {
    Highlighter highlighter = comp.getHighlighter();
    highlighter.removeAllHighlights();
    try {
        i = toComponentPosition(comp, i);
        j = toComponentPosition(comp, j);
        highlighter.addHighlight(i, j+1, DefaultHighlighter.DefaultPainter);
        if ( scroll ) {
            if ( comp.getCaretPosition()< i || comp.getCaretPosition()>j ) {
                comp.moveCaretPosition(i);
                comp.scrollRectToVisible(comp.modelToView(i));
            }
        }
    }
    catch (BadLocationException ble) {
        errMgr.internalError(tmodel.root.event.scope.st, "bad highlight location", ble);
    }
}
项目:codebuff    文件:STViz.java   
protected void highlight(JTextComponent comp, int i, int j, boolean scroll) {
    Highlighter highlighter = comp.getHighlighter();
    highlighter.removeAllHighlights();
    try {
        i = toComponentPosition(comp, i);
        j = toComponentPosition(comp, j);
        highlighter.addHighlight(i, j+1, DefaultHighlighter.DefaultPainter);
        if ( scroll ) {
            if ( comp.getCaretPosition()< i || comp.getCaretPosition()>j ) {
                comp.moveCaretPosition(i);
                comp.scrollRectToVisible(comp.modelToView(i));
            }
        }
    }
    catch (BadLocationException ble) {
        errMgr.internalError(tmodel.root.event.scope.st, "bad highlight location", ble);
    }
}
项目:codebuff    文件:STViz.java   
protected void highlight(JTextComponent comp, int i, int j, boolean scroll) {
    Highlighter highlighter = comp.getHighlighter();
    highlighter.removeAllHighlights();
    try {
        i = toComponentPosition(comp, i);
        j = toComponentPosition(comp, j);
        highlighter.addHighlight(i, j+1, DefaultHighlighter.DefaultPainter);
        if ( scroll ) {
            if ( comp.getCaretPosition()< i || comp.getCaretPosition()>j ) {
                comp.moveCaretPosition(i);
                comp.scrollRectToVisible(comp.modelToView(i));
            }
        }
    }
    catch (BadLocationException ble) {
        errMgr.internalError(tmodel.root.event.scope.st, "bad highlight location", ble);
    }
}
项目:codebuff    文件:STViz.java   
protected void highlight(JTextComponent comp, int i, int j, boolean scroll) {
    Highlighter highlighter = comp.getHighlighter();
    highlighter.removeAllHighlights();
    try {
        i = toComponentPosition(comp, i);
        j = toComponentPosition(comp, j);
        highlighter.addHighlight(i, j+1, DefaultHighlighter.DefaultPainter);
        if ( scroll ) {
            if ( comp.getCaretPosition()< i || comp.getCaretPosition()>j ) {
                comp.moveCaretPosition(i);
                comp.scrollRectToVisible(comp.modelToView(i));
            }
        }
    }
    catch (BadLocationException ble) {
        errMgr.internalError(tmodel.root.event.scope.st, "bad highlight location", ble);
    }
}
项目:codebuff    文件:STViz.java   
protected void highlight(JTextComponent comp, int i, int j, boolean scroll) {
    Highlighter highlighter = comp.getHighlighter();
    highlighter.removeAllHighlights();
    try {
        i = toComponentPosition(comp, i);
        j = toComponentPosition(comp, j);
        highlighter.addHighlight(i, j+1, DefaultHighlighter.DefaultPainter);
        if ( scroll ) {
            if ( comp.getCaretPosition()< i || comp.getCaretPosition()>j ) {
                comp.moveCaretPosition(i);
                comp.scrollRectToVisible(comp.modelToView(i));
            }
        }
    }
    catch (BadLocationException ble) {
        errMgr.internalError(tmodel.root.event.scope.st, "bad highlight location", ble);
    }
}
项目:codebuff    文件:STViz.java   
protected void highlight(JTextComponent comp, int i, int j, boolean scroll) {
    Highlighter highlighter = comp.getHighlighter();
    highlighter.removeAllHighlights();
    try {
        i = toComponentPosition(comp, i);
        j = toComponentPosition(comp, j);
        highlighter.addHighlight(i, j+1, DefaultHighlighter.DefaultPainter);
        if ( scroll ) {
            if ( comp.getCaretPosition()< i || comp.getCaretPosition()>j ) {
                comp.moveCaretPosition(i);
                comp.scrollRectToVisible(comp.modelToView(i));
            }
        }
    }
    catch (BadLocationException ble) {
        errMgr.internalError(tmodel.root.event.scope.st, "bad highlight location", ble);
    }
}
项目:codebuff    文件:STViz.java   
protected void highlight(JTextComponent comp, int i, int j, boolean scroll) {
    Highlighter highlighter = comp.getHighlighter();
    highlighter.removeAllHighlights();
    try {
        i = toComponentPosition(comp, i);
        j = toComponentPosition(comp, j);
        highlighter.addHighlight(i, j+1, DefaultHighlighter.DefaultPainter);
        if ( scroll ) {
            if ( comp.getCaretPosition()< i || comp.getCaretPosition()>j ) {
                comp.moveCaretPosition(i);
                comp.scrollRectToVisible(comp.modelToView(i));
            }
        }
    }
    catch (BadLocationException ble) {
        errMgr.internalError(tmodel.root.event.scope.st, "bad highlight location", ble);
    }
}
项目:codebuff    文件:STViz.java   
protected void highlight(JTextComponent comp, int i, int j, boolean scroll) {
    Highlighter highlighter = comp.getHighlighter();
    highlighter.removeAllHighlights();
    try {
        i = toComponentPosition(comp, i);
        j = toComponentPosition(comp, j);
        highlighter.addHighlight(i, j+1, DefaultHighlighter.DefaultPainter);
        if ( scroll ) {
            if ( comp.getCaretPosition()< i || comp.getCaretPosition()>j ) {
                comp.moveCaretPosition(i);
                comp.scrollRectToVisible(comp.modelToView(i));
            }
        }
    }
    catch (BadLocationException ble) {
        errMgr.internalError(tmodel.root.event.scope.st, "bad highlight location", ble);
    }
}
项目:codebuff    文件:STViz.java   
protected void highlight(JTextComponent comp, int i, int j, boolean scroll) {
    Highlighter highlighter = comp.getHighlighter();
    highlighter.removeAllHighlights();
    try {
        i = toComponentPosition(comp, i);
        j = toComponentPosition(comp, j);
        highlighter.addHighlight(i, j+1, DefaultHighlighter.DefaultPainter);
        if ( scroll ) {
            if ( comp.getCaretPosition()< i || comp.getCaretPosition()>j ) {
                comp.moveCaretPosition(i);
                comp.scrollRectToVisible(comp.modelToView(i));
            }
        }
    }
    catch (BadLocationException ble) {
        errMgr.internalError(tmodel.root.event.scope.st, "bad highlight location", ble);
    }
}
项目:codebuff    文件:STViz.java   
protected void highlight(JTextComponent comp, int i, int j, boolean scroll) {
    Highlighter highlighter = comp.getHighlighter();
    highlighter.removeAllHighlights();
    try {
        i = toComponentPosition(comp, i);
        j = toComponentPosition(comp, j);
        highlighter.addHighlight(i, j+1, DefaultHighlighter.DefaultPainter);
        if ( scroll ) {
            if ( comp.getCaretPosition()< i || comp.getCaretPosition()>j ) {
                comp.moveCaretPosition(i);
                comp.scrollRectToVisible(comp.modelToView(i));
            }
        }
    }
    catch (BadLocationException ble) {
        errMgr.internalError(tmodel.root.event.scope.st, "bad highlight location", ble);
    }
}
项目:codebuff    文件:STViz.java   
protected void highlight(JTextComponent comp, int i, int j, boolean scroll) {
    Highlighter highlighter = comp.getHighlighter();
    highlighter.removeAllHighlights();
    try {
        i = toComponentPosition(comp, i);
        j = toComponentPosition(comp, j);
        highlighter.addHighlight(i, j+1, DefaultHighlighter.DefaultPainter);
        if ( scroll ) {
            if ( comp.getCaretPosition()< i || comp.getCaretPosition()>j ) {
                comp.moveCaretPosition(i);
                comp.scrollRectToVisible(comp.modelToView(i));
            }
        }
    }
    catch (BadLocationException ble) {
        errMgr.internalError(tmodel.root.event.scope.st, "bad highlight location", ble);
    }
}
项目:codebuff    文件:STViz.java   
protected void highlight(JTextComponent comp, int i, int j, boolean scroll) {
    Highlighter highlighter = comp.getHighlighter();
    highlighter.removeAllHighlights();
    try {
        i = toComponentPosition(comp, i);
        j = toComponentPosition(comp, j);
        highlighter.addHighlight(i, j+1, DefaultHighlighter.DefaultPainter);
        if ( scroll ) {
            if ( comp.getCaretPosition()< i || comp.getCaretPosition()>j ) {
                comp.moveCaretPosition(i);
                comp.scrollRectToVisible(comp.modelToView(i));
            }
        }
    }
    catch (BadLocationException ble) {
        errMgr.internalError(tmodel.root.event.scope.st, "bad highlight location", ble);
    }
}