home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &… the Search for Life CD 3 / 0_CD-ROM.iso / install / jre1_3 / lib / rt.jar / javax / swing / plaf / basic / BasicTableUI$NavigationalAction.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  2.3 KB  |  109 lines

  1. package javax.swing.plaf.basic;
  2.  
  3. import java.awt.event.ActionEvent;
  4. import java.util.EventObject;
  5. import javax.swing.AbstractAction;
  6. import javax.swing.JTable;
  7. import javax.swing.ListSelectionModel;
  8.  
  9. class BasicTableUI$NavigationalAction extends AbstractAction {
  10.    // $FF: renamed from: dx int
  11.    protected int field_0;
  12.    // $FF: renamed from: dy int
  13.    protected int field_1;
  14.    protected boolean toggle;
  15.    protected boolean extend;
  16.    protected boolean inSelection;
  17.    protected int anchorRow;
  18.    protected int anchorColumn;
  19.    protected int leadRow;
  20.    protected int leadColumn;
  21.  
  22.    protected BasicTableUI$NavigationalAction(int var1, int var2, boolean var3, boolean var4, boolean var5) {
  23.       this.field_0 = var1;
  24.       this.field_1 = var2;
  25.       this.toggle = var3;
  26.       this.extend = var4;
  27.       this.inSelection = var5;
  28.    }
  29.  
  30.    private int clipToRange(int var1, int var2, int var3) {
  31.       return Math.min(Math.max(var1, var2), var3 - 1);
  32.    }
  33.  
  34.    private void moveWithinTableRange(JTable var1, int var2, int var3, boolean var4) {
  35.       if (var4) {
  36.          this.leadRow = this.clipToRange(this.leadRow + var3, 0, var1.getRowCount());
  37.          this.leadColumn = this.clipToRange(this.leadColumn + var2, 0, var1.getColumnCount());
  38.       } else {
  39.          this.anchorRow = this.clipToRange(this.anchorRow + var3, 0, var1.getRowCount());
  40.          this.anchorColumn = this.clipToRange(this.anchorColumn + var2, 0, var1.getColumnCount());
  41.       }
  42.  
  43.    }
  44.  
  45.    private int selectionSpan(ListSelectionModel var1) {
  46.       return var1.getMaxSelectionIndex() - var1.getMinSelectionIndex() + 1;
  47.    }
  48.  
  49.    private int compare(int var1, ListSelectionModel var2) {
  50.       return this.compare(var1, var2.getMinSelectionIndex(), var2.getMaxSelectionIndex() + 1);
  51.    }
  52.  
  53.    private int compare(int var1, int var2, int var3) {
  54.       return var1 < var2 ? -1 : (var1 >= var3 ? 1 : 0);
  55.    }
  56.  
  57.    private boolean moveWithinSelectedRange(JTable var1, int var2, int var3, boolean var4) {
  58.       ListSelectionModel var5 = var1.getSelectionModel();
  59.       ListSelectionModel var6 = var1.getColumnModel().getSelectionModel();
  60.       int var7 = this.anchorRow + var3;
  61.       int var8 = this.anchorColumn + var2;
  62.       int var11 = this.selectionSpan(var5);
  63.       int var12 = this.selectionSpan(var6);
  64.       boolean var13 = var11 * var12 > 1;
  65.       int var9;
  66.       int var10;
  67.       if (var13) {
  68.          var9 = this.compare(var7, var5);
  69.          var10 = this.compare(var8, var6);
  70.       } else {
  71.          var11 = var1.getRowCount();
  72.          var12 = var1.getColumnCount();
  73.          var9 = this.compare(var7, 0, var11);
  74.          var10 = this.compare(var8, 0, var12);
  75.       }
  76.  
  77.       this.anchorRow = var7 - var11 * var9;
  78.       this.anchorColumn = var8 - var12 * var10;
  79.       return !var4 ? this.moveWithinSelectedRange(var1, var9, var10, true) : var13;
  80.    }
  81.  
  82.    public void actionPerformed(ActionEvent var1) {
  83.       JTable var2 = (JTable)((EventObject)var1).getSource();
  84.       ListSelectionModel var3 = var2.getSelectionModel();
  85.       this.anchorRow = var3.getAnchorSelectionIndex();
  86.       this.leadRow = var3.getLeadSelectionIndex();
  87.       ListSelectionModel var4 = var2.getColumnModel().getSelectionModel();
  88.       this.anchorColumn = var4.getAnchorSelectionIndex();
  89.       this.leadColumn = var4.getLeadSelectionIndex();
  90.       int var5 = this.anchorRow;
  91.       int var6 = this.anchorColumn;
  92.       if (!var2.isEditing() || var2.getCellEditor().stopCellEditing()) {
  93.          if (!this.inSelection) {
  94.             this.moveWithinTableRange(var2, this.field_0, this.field_1, this.extend);
  95.             if (!this.extend) {
  96.                var2.changeSelection(this.anchorRow, this.anchorColumn, false, this.extend);
  97.             } else {
  98.                var2.changeSelection(this.leadRow, this.leadColumn, false, this.extend);
  99.             }
  100.          } else if (this.moveWithinSelectedRange(var2, this.field_0, this.field_1, false)) {
  101.             var2.changeSelection(this.anchorRow, this.anchorColumn, true, true);
  102.          } else {
  103.             var2.changeSelection(this.anchorRow, this.anchorColumn, false, false);
  104.          }
  105.  
  106.       }
  107.    }
  108. }
  109.