jdk/src/share/classes/sun/swing/SwingUtilities2.java
changeset 5590 3ec077d7e893
parent 4278 b7a976422d27
child 5597 ab490f66d2cf
equal deleted inserted replaced
5589:5e4f59f34eea 5590:3ec077d7e893
    42 import javax.swing.text.Highlighter;
    42 import javax.swing.text.Highlighter;
    43 import javax.swing.text.JTextComponent;
    43 import javax.swing.text.JTextComponent;
    44 import javax.swing.text.DefaultHighlighter;
    44 import javax.swing.text.DefaultHighlighter;
    45 import javax.swing.text.DefaultCaret;
    45 import javax.swing.text.DefaultCaret;
    46 import javax.swing.table.TableCellRenderer;
    46 import javax.swing.table.TableCellRenderer;
       
    47 import javax.swing.table.TableColumnModel;
       
    48 
    47 import sun.swing.PrintColorUIResource;
    49 import sun.swing.PrintColorUIResource;
    48 import sun.swing.ImageIconUIResource;
    50 import sun.swing.ImageIconUIResource;
    49 import sun.print.ProxyPrintGraphics;
    51 import sun.print.ProxyPrintGraphics;
    50 import sun.awt.*;
    52 import sun.awt.*;
    51 import sun.security.action.GetPropertyAction;
    53 import sun.security.action.GetPropertyAction;
  1805      */
  1807      */
  1806     public static Section liesInVertical(Rectangle rect, Point p,
  1808     public static Section liesInVertical(Rectangle rect, Point p,
  1807                                          boolean three) {
  1809                                          boolean three) {
  1808         return liesIn(rect, p, false, false, three);
  1810         return liesIn(rect, p, false, false, three);
  1809     }
  1811     }
       
  1812 
       
  1813     /**
       
  1814      * Maps the index of the column in the view at
       
  1815      * {@code viewColumnIndex} to the index of the column
       
  1816      * in the table model.  Returns the index of the corresponding
       
  1817      * column in the model.  If {@code viewColumnIndex}
       
  1818      * is less than zero, returns {@code viewColumnIndex}.
       
  1819      *
       
  1820      * @param cm the table model
       
  1821      * @param   viewColumnIndex     the index of the column in the view
       
  1822      * @return  the index of the corresponding column in the model
       
  1823      *
       
  1824      * @see JTable#convertColumnIndexToModel(int)
       
  1825      * @see javax.swing.plaf.basic.BasicTableHeaderUI
       
  1826      */
       
  1827     public static int convertColumnIndexToModel(TableColumnModel cm,
       
  1828                                                 int viewColumnIndex) {
       
  1829         if (viewColumnIndex < 0) {
       
  1830             return viewColumnIndex;
       
  1831         }
       
  1832         return cm.getColumn(viewColumnIndex).getModelIndex();
       
  1833     }
       
  1834 
       
  1835     /**
       
  1836      * Maps the index of the column in the {@code cm} at
       
  1837      * {@code modelColumnIndex} to the index of the column
       
  1838      * in the view.  Returns the index of the
       
  1839      * corresponding column in the view; returns {@code -1} if this column
       
  1840      * is not being displayed. If {@code modelColumnIndex} is less than zero,
       
  1841      * returns {@code modelColumnIndex}.
       
  1842      *
       
  1843      * @param cm the table model
       
  1844      * @param modelColumnIndex the index of the column in the model
       
  1845      * @return the index of the corresponding column in the view
       
  1846      *
       
  1847      * @see JTable#convertColumnIndexToView(int)
       
  1848      * @see javax.swing.plaf.basic.BasicTableHeaderUI
       
  1849      */
       
  1850     public static int convertColumnIndexToView(TableColumnModel cm,
       
  1851                                         int modelColumnIndex) {
       
  1852         if (modelColumnIndex < 0) {
       
  1853             return modelColumnIndex;
       
  1854         }
       
  1855         for (int column = 0; column < cm.getColumnCount(); column++) {
       
  1856             if (cm.getColumn(column).getModelIndex() == modelColumnIndex) {
       
  1857                 return column;
       
  1858             }
       
  1859         }
       
  1860         return -1;
       
  1861     }
  1810 }
  1862 }