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

📄 filterpipeline.java

📁 java实现浏览器等本地桌面的功能
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            fireContentsChanged();        }        else {            next.refresh(); // Cascade to next filter        }    }    /**     * returns the unfiltered data adapter size or 0 if unassigned.     *      * @return     */    public int getInputSize() {        return isAssigned() ? adapter.getRowCount() : 0;    }    /**     * @param filter     * @return     */    int getInputSize(Filter filter) {        Filter  previous = previous(filter);        if (previous != null) {            return previous.getSize();        }        // fixed issue #64-swingx - removed precondition... (was: isAssigned())        return getInputSize();    }    /**     * Returns the number of records in the filtered view.     *     * @return the number of records in the filtered view     */    public int getOutputSize() {        // JW: don't need to check - but that's heavily dependent on the        // implementation detail that there's always the identityFilter        // (which might change any time)        if (!isAssigned()) return 0;        Filter last = last();        return (last == null) ? adapter.getRowCount() : last.getSize();    }    /**     * Convert row index from view coordinates to model coordinates     * accounting for the presence of sorters and filters. This is essentially     * a pass-through to the {@link org.jdesktop.swingx.decorator.Filter#convertRowIndexToModel(int) convertRowIndexToModel}     * method of the <em>last</em> {@link org.jdesktop.swingx.decorator.Filter},     * if any, in this pipeline.     *     * @param row row index in view coordinates     * @return row index in model coordinates     */    public int convertRowIndexToModel(int row) {        Filter last = last();        return (last == null) ? row : last.convertRowIndexToModel(row);    }    /**     * Convert row index from model coordinates to view coordinates     * accounting for the presence of sorters and filters. This is essentially     * a pass-through to the {@link org.jdesktop.swingx.decorator.Filter#convertRowIndexToView(int) convertRowIndexToModel}     * method of the <em>last</em> {@link org.jdesktop.swingx.decorator.Filter},     * if any, in this pipeline.     *     * @param row row index in model coordinates     * @return row index in view coordinates     */    public int convertRowIndexToView(int row) {        Filter last = last();        return (last == null) ? row : last.convertRowIndexToView(row);    }    /**     * Returns the value of the cell at the specified coordinates.     *     *      * @param row in view coordinates     * @param column in model coordinates     * @return the value of the cell at the specified coordinates     */    public Object getValueAt(int row, int column) {        // JW: this impl relies on the fact that there's always the        // identity filter installed        // should use adapter if assigned and no filter        Filter last = last();        return (last == null) ? null : last.getValueAt(row, column);    }    public void setValueAt(Object aValue, int row, int column) {        // JW: this impl relies on the fact that there's always the        // identity filter installed        // should use adapter if assigned and no filter        Filter last = last();        if (last != null) {            last.setValueAt(aValue, row, column);        }    }    public boolean isCellEditable(int row, int column) {        // JW: this impl relies on the fact that there's always the        // identity filter installed        // should use adapter if assigned and no filter        Filter last = last();        return (last == null) ? false : last.isCellEditable(row, column);    }    /**     * Flushes the pipeline by initiating a {@link org.jdesktop.swingx.decorator.Filter#refresh() refresh}     * on the <em>first</em> {@link org.jdesktop.swingx.decorator.Filter filter},     * if any, in this pipeline. After that filter has refreshed itself, it sends a     * {@link #filterChanged(org.jdesktop.swingx.decorator.Filter) filterChanged}     * notification to this pipeline, and the pipeline responds by initiating a     * {@link org.jdesktop.swingx.decorator.Filter#refresh() refresh}     * on the <em>next</em> {@link org.jdesktop.swingx.decorator.Filter filter},     * if any, in this pipeline. Eventualy, when there are no more filters left     * in the pipeline, it broadcasts a {@link org.jdesktop.swingx.decorator.PipelineEvent}     * signaling a {@link org.jdesktop.swingx.decorator.PipelineEvent#CONTENTS_CHANGED}     * message to all {@link org.jdesktop.swingx.decorator.PipelineListener} objects     * registered with this pipeline.     */    public void flush() {        // JW PENDING: use first!        if ((filters != null) && (filters.length > 0)) {            filters[0].refresh();        }        else if (sorter != null) {            sorter.refresh();        }    }    /**     * Adds a listener to the list that's notified each time there is a change     * to this pipeline.     *     * @param l the <code>PipelineListener</code> to be added     */    public void addPipelineListener(PipelineListener l) {        listenerList.add(PipelineListener.class, l);    }    /**     * Removes a listener from the list that's notified each time there is a change     * to this pipeline.     *     * @param l the <code>PipelineListener</code> to be removed     */    public void removePipelineListener(PipelineListener l) {        listenerList.remove(PipelineListener.class, l);    }    /**     * Returns an array of all the pipeline listeners     * registered on this <code>FilterPipeline</code>.     *     * @return all of this pipeline's <code>PipelineListener</code>s,     *         or an empty array if no pipeline listeners     *         are currently registered     *     * @see #addPipelineListener     * @see #removePipelineListener     */    public PipelineListener[] getPipelineListeners() {        return (PipelineListener[]) listenerList.getListeners(            PipelineListener.class);    }    /**     * Notifies all registered {@link org.jdesktop.swingx.decorator.PipelineListener}     * objects that the contents of this pipeline has changed. The event instance     * is lazily created.     */    protected void fireContentsChanged() {        Object[] listeners = listenerList.getListenerList();        PipelineEvent e = null;        for (int i = listeners.length - 2; i >= 0; i -= 2) {            if (listeners[i] == PipelineListener.class) {                if (e == null) {                    e = new PipelineEvent(this, PipelineEvent.CONTENTS_CHANGED);                }                ( (PipelineListener) listeners[i + 1]).contentsChanged(e);            }        }    }    private List locateSorters(Filter[] inList) {        BitSet  sortableColumns = new BitSet(); // temporary structure for checking        List    sorterLocations = new Vector();        for (int i = 0; i < inList.length; i++) {            if (inList[i] instanceof Sorter) {                int columnIndex = inList[i].getColumnIndex();                if (columnIndex < 0) {                    throw new IndexOutOfBoundsException(                        "Negative column index for filter: " + inList[i]);                }                if (sortableColumns.get(columnIndex)) {                    throw new IllegalArgumentException(                        "Filter "+ i +" attempting to overwrite sorter for column "                        + columnIndex);                }                sortableColumns.set(columnIndex);       // mark column index                sorterLocations.add(new Integer(i));    // mark sorter index                //columnSorterMap.put(new Integer(columnIndex), inList[i]);            }        }        return sorterLocations;    }    private Filter[] reorderSorters(Filter[] inList, List sorterLocations) {        // quick hack for issue #46-swingx: make sure we are open        // without filter.        if (inList.length == 0) {            return new Filter[] {new IdentityFilter()};        }        // always returns a new copy of inList        Filter[]    outList = (Filter[]) inList.clone();        // Invert the order of sorters, if any, in outList        int max = sorterLocations.size() - 1;        for (int i = 0; i <= max; i++) {            int orig = ((Integer) sorterLocations.get(max - i)).intValue();            int copy = ((Integer) sorterLocations.get(i)).intValue();            outList[copy] = inList[orig];        }        return outList;    }    public class IdentityFilter extends Filter {        protected void init() {        }        protected void reset() {        }        protected void filter() {        }        public int getSize() {            return getInputSize();        }        protected int mapTowardModel(int row) {            return row;        }        protected int mapTowardView(int row) {            return row;        }    }}

⌨️ 快捷键说明

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