⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 highlighter.java

📁 java实现浏览器等本地桌面的功能
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     * depends on two factors: (i) whether the background color for this     * <code>Highlighter</code> is null or not, and (ii) whether the cell     * identified by the specified adapter     * {@link ComponentAdapter#isSelected isSelected} or not.</p>     *     * <p>If the background color for this <code>Highlighter</code> is not     * null, this method starts with an initial value that is equal to that     * background color, and proceeds to check the selected state of the cell.     * Otherwise, it starts with the background color of the component whose     * cell is being rendererd (not the background color of the renderer component     * that was passed in), and proceeds to check the selected state of the cell.</p>     *     * <p>If the cell identified by the specified adapter is selected, this     * method returns the value computed by     * {@link #computeSelectedBackground computeSelectedBackground} when passed     * the initial background color computed earlier. Otherwise, it simply     * returns the initial background color computed earlier.</p>     *     * @param renderer the cell renderer component that is to be decorated     * @param adapter the {@link ComponentAdapter} for this decorate operation     * @return a suitable background color for the specified component and adapter     */    protected Color computeBackground(Component renderer, ComponentAdapter adapter) {        // If this.background is null, use adapter.target.getBackground();        // Never use renderer.getBackground() as the seed in this decorator        // class because renderer is too promiscuous!        Color seed = background == null ? adapter.target.getBackground() : background;        return adapter.isSelected() ? computeSelectedBackground(seed) : seed;    }    /**     * <p>Computes a suitable foreground for the renderer component within the     * specified adapter and returns the computed color. The computed color     * depends on two factors: (i) whether the foreground color for this     * <code>Highlighter</code> is null or not, and (ii) whether the cell     * identified by the specified adapter     * {@link ComponentAdapter#isSelected isSelected} or not.</p>     *     * <p>If the foreground color for this <code>Highlighter</code> is not     * null, this method starts with an initial value that is equal to that     * foreground color, and proceeds to check the selected state of the cell.     * Otherwise, it starts with the foreground color of the component whose     * cell is being rendererd (not the foreground color of the renderer component     * that was passed in), and proceeds to check the selected state of the cell.</p>     *     * <p>If the cell identified by the specified adapter is selected, this     * method returns the value computed by     * {@link #computeSelectedForeground computeSelectedBackground} when passed     * the initial foreground color computed earlier. Otherwise, it simply     * returns the initial foreground color computed earlier.</p>     *     * @param renderer the cell renderer component that is to be decorated     * @param adapter the {@link ComponentAdapter} for this decorate operation     * @return a suitable foreground color for the specified component and adapter     */    protected Color computeForeground(Component renderer, ComponentAdapter adapter) {        // If this.foreground is null, use adapter.target.getForeground();        // Never use renderer.getForeground() as the seed in this decorator        // class because renderer is too promiscuous!        Color seed = foreground == null ? adapter.target.getForeground() : foreground;        return adapter.isSelected() ? computeSelectedForeground(seed) : seed;    }    /**     * Computes the selected background color. If the selected background color     * of this <code>Highlighter</code> is not null, this method returns that     * color. Otherwise, it returns a {@link java.awt.Color#darker} version of     * the specified seed color.     *     * @param seed initial background color; must cope with null!     * @return the background color for a selected cell     */    protected Color computeSelectedBackground(Color seed) {        return selectedBackground == null ?            seed == null ? Color.gray : seed.darker() : selectedBackground;    }    /**     * Computes the selected foreground color. If the selected foreground color     * of this <code>Highlighter</code> is not null, this method returns that     * color. Otherwise, it returns {@link java.awt.Color#white}, ignoring the     * specified seed color.      *     * @param seed initial foreground color; must cope with null!     * @return the foreground color for a selected cell     */    protected Color computeSelectedForeground(Color seed) {        return selectedForeground == null ? Color.white : selectedForeground;    }    /**     * Returns the background color of this <code>Highlighter</code>.     *     * @return the background color of this <code>Highlighter</code>,     *          or null, if no background color has been set     */    public Color getBackground() {        return background;    }    /**     * Sets the background color of this <code>Highlighter</code>.     *     * @param color the background color of this <code>Highlighter</code>,     *          or null, to clear any existing background color     */    public void setBackground(Color color) {        background = color;        fireStateChanged();    }    /**     * Returns the foreground color of this <code>Highlighter</code>.     *     * @return the foreground color of this <code>Highlighter</code>,     *          or null, if no foreground color has been set     */    public Color getForeground() {        return foreground;    }    /**     * Sets the foreground color of this <code>Highlighter</code>.     *     * @param color the foreground color of this <code>Highlighter</code>,     *          or null, to clear any existing foreground color     */    public void setForeground(Color color) {        foreground = color;        fireStateChanged();    }    /**     * Returns the selected background color of this <code>Highlighter</code>.     *     * @return the selected background color of this <code>Highlighter</code>,     *          or null, if no selected background color has been set     */    public Color getSelectedBackground() {        return selectedBackground;    }    /**     * Sets the selected background color of this <code>Highlighter</code>.     *     * @param color the selected background color of this <code>Highlighter</code>,     *          or null, to clear any existing selected background color     */    public void setSelectedBackground(Color color) {        selectedBackground = color;        fireStateChanged();    }    /**     * Returns the selected foreground color of this <code>Highlighter</code>.     *     * @return the selected foreground color of this <code>Highlighter</code>,     *          or null, if no selected foreground color has been set     */    public Color getSelectedForeground() {        return selectedForeground;    }    /**     * Sets the selected foreground color of this <code>Highlighter</code>.     *     * @param color the selected foreground color of this <code>Highlighter</code>,     *          or null, to clear any existing selected foreground color     */    public void setSelectedForeground(Color color) {        selectedForeground = color;        fireStateChanged();    }    /**     * Adds a <code>ChangeListener</code>.  The change listeners are run each     * time any one of the Bounded Range model properties changes.     *     * @param l the ChangeListener to add     * @see #removeChangeListener     * @see BoundedRangeModel#addChangeListener     */    public void addChangeListener(ChangeListener l) {        listenerList.add(ChangeListener.class, l);    }        /**     * Removes a <code>ChangeListener</code>.     *     * @param l the <code>ChangeListener</code> to remove     * @see #addChangeListener     * @see BoundedRangeModel#removeChangeListener     */    public void removeChangeListener(ChangeListener l) {        listenerList.remove(ChangeListener.class, l);    }    /**     * Returns an array of all the change listeners     * registered on this <code>DefaultBoundedRangeModel</code>.     *     * @return all of this model's <code>ChangeListener</code>s      *         or an empty     *         array if no change listeners are currently registered     *     * @see #addChangeListener     * @see #removeChangeListener     *     * @since 1.4     */    public ChangeListener[] getChangeListeners() {        return (ChangeListener[])listenerList.getListeners(                ChangeListener.class);    }    /**      * Runs each <code>ChangeListener</code>'s <code>stateChanged</code> method.     *      * @see #setRangeProperties     * @see EventListenerList     */    protected void fireStateChanged()     {        Object[] listeners = listenerList.getListenerList();        for (int i = listeners.length - 2; i >= 0; i -=2 ) {            if (listeners[i] == ChangeListener.class) {                if (changeEvent == null) {                    changeEvent = new ChangeEvent(this);                }                ((ChangeListener)listeners[i+1]).stateChanged(changeEvent);            }                  }    }       }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -