Java 类javax.swing.plaf.basic.BasicTableUI 实例源码

项目:incubator-netbeans    文件:DrawEngineDocView.java   
public @Override void setParent(View parent) {
    if (parent != null) { // start listening
        JTextComponent component = (JTextComponent)parent.getContainer();
        TextUI tui = component.getUI();
        if (tui instanceof BaseTextUI){
            editorUI = ((BaseTextUI)tui).getEditorUI();
            if (editorUI!=null){
                editorUI.addPropertyChangeListener(this);
            }
        }
    }

    super.setParent(parent);

    if (parent == null) {
        if (editorUI!=null){
            editorUI.removePropertyChangeListener(this);
            editorUI = null;
        }
    }
}
项目:incubator-netbeans    文件:DrawEngineDocView.java   
public @Override void paint(Graphics g, Shape allocation) {
    java.awt.Component c = getContainer();
    if (c instanceof javax.swing.text.JTextComponent){
        TextUI textUI = ((javax.swing.text.JTextComponent)c).getUI();
        if (textUI instanceof BaseTextUI){
            EditorUiAccessor.get().paint(((BaseTextUI) textUI).getEditorUI(), g);
        }
    }

    super.paint(g, allocation);

    // #114712 - set the color to foreground so that the JTextComponent.ComposedTextCaret.paint()
    // does not render white-on-white.
    if (c != null) {
        g.setColor(c.getForeground());
    }
}
项目:incubator-netbeans    文件:AnnotationView.java   
private int getYFromPos(int offset) throws BadLocationException {
    TextUI ui = pane.getUI();
    int result;

    // For some reason the offset may become -1; uncomment following line to see that
    offset = Math.max(offset, 0);
    if (ui instanceof BaseTextUI) {
        result = ((BaseTextUI) ui).getYFromPos(offset);
    } else {
        Rectangle r = pane.modelToView(offset);

        result = r != null ? r.y : 0;
    }

    if (result == 0) {
        return -1;
    } else {
        return result;
    }
}
项目:incubator-netbeans    文件:PresenterEditorAction.java   
public void actionPerformed(ActionEvent evt) {
    // Find the right action for the corresponding editor kit
    JTextComponent component = getTextComponent(evt);
    if (component != null) {
        TextUI ui = component.getUI();
        if (ui != null) {
            EditorKit kit = ui.getEditorKit(component);
            if (kit != null) {
                Action action = EditorUtilities.getAction(kit, actionName);
                if (action != null) {
                    action.actionPerformed(evt);
                } else {
                    if (LOG.isLoggable(Level.FINE)) {
                        LOG.fine("Action '" + actionName + "' not found in editor kit " + kit + '\n'); // NOI18N
                    }
                }
            }
        }
    }
}
项目:incubator-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;
}
项目:incubator-netbeans    文件:VCSHyperlinkSupport.java   
public void computeBounds(JTextPane textPane, BoundsTranslator translator) {
    Rectangle tpBounds = textPane.getBounds();
    TextUI tui = textPane.getUI();
    this.bounds = new Rectangle[length];
    for (int i = 0; i < length; i++) {
        try {
            Rectangle startr = tui.modelToView(textPane, docstart[i], Position.Bias.Forward);
            Rectangle endr = tui.modelToView(textPane, docend[i], Position.Bias.Backward);
            if (startr == null || endr == null) {
                continue;
            }
            startr = startr.getBounds();
            endr = endr.getBounds();
            this.bounds[i] = new Rectangle(tpBounds.x + startr.x, startr.y, endr.x - startr.x, startr.height);
            //NOTE the textPane is positioned within a parent panel so the origin has to be modified too
            if (null != translator) {
                translator.correctTranslation(textPane, this.bounds[i]);
            }
        } catch (BadLocationException ex) { }
    }
}
项目:incubator-netbeans    文件:VCSHyperlinkSupport.java   
public void computeBounds(JTextPane textPane, BoundsTranslator translator) {
    Rectangle tpBounds = textPane.getBounds();
    TextUI tui = textPane.getUI();
    this.bounds = new Rectangle();
    try {
        Rectangle startr = tui.modelToView(textPane, docstart, Position.Bias.Forward).getBounds();
        Rectangle endr = tui.modelToView(textPane, docend, Position.Bias.Backward).getBounds();
        if(kenaiUser.getIcon() != null) {
            endr.x += kenaiUser.getIcon().getIconWidth();
        }
        this.bounds = new Rectangle(tpBounds.x + startr.x, startr.y, endr.x - startr.x, startr.height);

        if (null != translator) {
            translator.correctTranslation(textPane, this.bounds);
        }
    } catch (BadLocationException ex) {
        Exceptions.printStackTrace(ex);
    }
}
项目:incubator-netbeans    文件:DiffSidebar.java   
/**
 * In case of two neighboring DELETE differences which meet on the same line, this method returns a difference
 * which' annotation is closer (in y-axis) to the click-point
 * @param event event with the click-point
 * @param previous a difference reaching out from the previous line
 * @param next a difference reaching out from the next line
 * @return
 */
private Difference getCloserDifference(MouseEvent event, Difference previous, Difference next) {
    Difference returnedDiff = next;
    JTextComponent component = textComponent;
    if (component != null) {
        TextUI textUI = component.getUI();
        try {
            Rectangle rec = textUI.modelToView(component, textUI.viewToModel(component, new Point(0, event.getY())));
            if (rec != null && event.getY() < rec.getY() + rec.getHeight() / 2) {
                // previous difference is closer to the click
                returnedDiff = previous;
            }
        } catch (BadLocationException ex) {
            // not interested, default next is returned
        }
    }
    return returnedDiff;
}
项目:incubator-netbeans    文件:DiffSidebar.java   
private int getLineFromMouseEvent(MouseEvent e){
    int line = -1;
    EditorUI editorUI = Utilities.getEditorUI(textComponent);
    if (editorUI != null) {
        try{
            JTextComponent component = editorUI.getComponent();
            if (component != null) {
                TextUI textUI = component.getUI();
                int clickOffset = textUI.viewToModel(component, new Point(0, e.getY()));
                line = Utilities.getLineOffset(document, clickOffset);
            }
        }catch (BadLocationException ble){
            LOG.log(Level.WARNING, "getLineFromMouseEvent", ble); // NOI18N
        }
    }
    return line;
}
项目:incubator-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;
}
项目:incubator-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;
}
项目:powertext    文件:RTextAreaBase.java   
/**
 * Paints the text area.
 *
 * @param g The graphics context with which to paint.
 */
@Override
protected void paintComponent(Graphics g) {

    //long startTime = System.currentTimeMillis();

    backgroundPainter.paint(g, getVisibleRect());

    // Paint the main part of the text area.
    TextUI ui = getUI();
    if (ui != null) {
        // Not allowed to modify g, so make a copy.
        Graphics scratchGraphics = g.create();
        try {
            ui.update(scratchGraphics, this);
        } finally {
            scratchGraphics.dispose();
        }
    }

    //long endTime = System.currentTimeMillis();
    //System.err.println(endTime-startTime);

}
项目:powertext    文件:RTextAreaHighlighter.java   
/**
 * 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;
}
项目:powertext    文件:RTextArea.java   
/**
 * 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();
    }

}
项目:powertext    文件:RSyntaxTextAreaHighlighter.java   
/**
 * 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;
}
项目:openjdk-jdk10    文件: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());
        }
    }
}
项目:ftc    文件:RTextAreaBase.java   
/**
 * Paints the text area.
 *
 * @param g The graphics context with which to paint.
 */
@Override
protected void paintComponent(Graphics g) {

    //long startTime = System.currentTimeMillis();

    backgroundPainter.paint(g, getVisibleRect());

    // Paint the main part of the text area.
    TextUI ui = getUI();
    if (ui != null) {
        // Not allowed to modify g, so make a copy.
        Graphics scratchGraphics = g.create();
        try {
            ui.update(scratchGraphics, this);
        } finally {
            scratchGraphics.dispose();
        }
    }

    //long endTime = System.currentTimeMillis();
    //System.err.println(endTime-startTime);

}
项目:ftc    文件:RTextAreaHighlighter.java   
/**
 * 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;
}
项目:ftc    文件:RTextArea.java   
/**
 * 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();
    }

}
项目:ftc    文件:RSyntaxTextAreaHighlighter.java   
/**
 * 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;
}
项目:ftc    文件:UnderlineHighlightPainter.java   
@Override
public void paint(Graphics g, int offs0, int offs1, Shape bounds, JTextComponent c) {
    try {
        TextUI mapper = c.getUI();
        Rectangle p0 = mapper.modelToView(c, offs0);
        Rectangle p1 = mapper.modelToView(c, offs1);

        Color color = getColor();

        if (color == null) 
            g.setColor(c.getSelectionColor());
        else 
            g.setColor(color);

        if (sameLine(p0, p1)) {
            Rectangle r = p0.union(p1);
            underline(g, r);
        }
    } catch (BadLocationException e) {
    }
}
项目: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());
        }
    }
}
项目:littleluck    文件:SnippetHighlighter.java   
/**
 * 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;
}
项目:Tank    文件:RTextAreaBase.java   
/**
 * Paints the text area.
 * 
 * @param g
 *            The graphics context with which to paint.
 */
protected void paintComponent(Graphics g) {

    // long startTime = System.currentTimeMillis();

    backgroundPainter.paint(g, getVisibleRect());

    // Paint the main part of the text area.
    TextUI ui = getUI();
    if (ui != null) {
        // Not allowed to modify g, so make a copy.
        Graphics scratchGraphics = g.create();
        try {
            ui.update(scratchGraphics, this);
        } finally {
            scratchGraphics.dispose();
        }
    }

    // long endTime = System.currentTimeMillis();
    // System.err.println(endTime-startTime);

}
项目:Tank    文件:RTextArea.java   
/**
 * 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();
    }

}
项目:Tank    文件:RSyntaxTextAreaHighlighter.java   
/**
 * 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;
}
项目:Tank    文件:RSyntaxTextAreaHighlighter.java   
/**
 * 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();

}
项目:Tank    文件:RSyntaxTextAreaHighlighter.java   
/**
 * Removes all of the highlights for a specific parser.
 * 
 * @param parser
 *            The parser.
 */
public void clearParserHighlights(Parser parser) {

    for (Iterator i = parserHighlights.iterator(); i.hasNext();) {

        HighlightInfo info = (HighlightInfo) i.next();

        if (info.notice.getParser() == parser) {
            if (info instanceof LayeredHighlightInfo) {
                LayeredHighlightInfo lhi = (LayeredHighlightInfo) 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);
            }
            i.remove();
        }

    }

}
项目:Tank    文件:RTextAreaBase.java   
/**
 * Paints the text area.
 * 
 * @param g
 *            The graphics context with which to paint.
 */
protected void paintComponent(Graphics g) {

    // long startTime = System.currentTimeMillis();

    backgroundPainter.paint(g, getVisibleRect());

    // Paint the main part of the text area.
    TextUI ui = getUI();
    if (ui != null) {
        // Not allowed to modify g, so make a copy.
        Graphics scratchGraphics = g.create();
        try {
            ui.update(scratchGraphics, this);
        } finally {
            scratchGraphics.dispose();
        }
    }

    // long endTime = System.currentTimeMillis();
    // System.err.println(endTime-startTime);

}
项目:Tank    文件:RTextArea.java   
/**
 * 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();
    }

}
项目:Tank    文件:RSyntaxTextAreaHighlighter.java   
/**
 * 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;
}
项目:Tank    文件:RSyntaxTextAreaHighlighter.java   
/**
 * 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();

}
项目:Tank    文件:RSyntaxTextAreaHighlighter.java   
/**
 * Removes all of the highlights for a specific parser.
 * 
 * @param parser
 *            The parser.
 */
public void clearParserHighlights(Parser parser) {

    for (Iterator i = parserHighlights.iterator(); i.hasNext();) {

        HighlightInfo info = (HighlightInfo) i.next();

        if (info.notice.getParser() == parser) {
            if (info instanceof LayeredHighlightInfo) {
                LayeredHighlightInfo lhi = (LayeredHighlightInfo) 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);
            }
            i.remove();
        }

    }

}
项目:beautyeye    文件:SnippetHighlighter.java   
/**
 * 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;
}
项目:swingx    文件:SnippetHighlighter.java   
/**
 * 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;
}
项目:ESPlorer    文件:RTextAreaBase.java   
/**
 * Paints the text area.
 *
 * @param g The graphics context with which to paint.
 */
@Override
protected void paintComponent(Graphics g) {

    //long startTime = System.currentTimeMillis();

    backgroundPainter.paint(g, getVisibleRect());

    // Paint the main part of the text area.
    TextUI ui = getUI();
    if (ui != null) {
        // Not allowed to modify g, so make a copy.
        Graphics scratchGraphics = g.create();
        try {
            ui.update(scratchGraphics, this);
        } finally {
            scratchGraphics.dispose();
        }
    }

    //long endTime = System.currentTimeMillis();
    //System.err.println(endTime-startTime);

}
项目:ESPlorer    文件:RTextAreaHighlighter.java   
/**
 * 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;
}
项目:ESPlorer    文件:RTextArea.java   
/**
 * 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();
    }

}
项目:ESPlorer    文件:RSyntaxTextAreaHighlighter.java   
/**
 * 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;
}
项目:otroslogviewer    文件:FullWidthJTextPane.java   
public boolean getScrollableTracksViewportWidth() {
    if (fullWidth) {
        Container parent = getParent();
        if (parent instanceof JViewport) {
            JViewport port = (JViewport) parent;
            TextUI ui = getUI();
            int w = port.getWidth();
            final Dimension preferredSize = ui.getPreferredSize(this);
            if (preferredSize.width <= w) {
                return true;
            }
        }
        return false;
    } else {
        return super.getScrollableTracksViewportWidth();
    }
}