home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / javax / swing / AbstractButton$AccessibleAbstractButton.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  8.4 KB  |  455 lines

  1. package javax.swing;
  2.  
  3. import java.awt.Insets;
  4. import java.awt.Point;
  5. import java.awt.Rectangle;
  6. import java.awt.Shape;
  7. import java.awt.geom.Rectangle2D;
  8. import java.text.BreakIterator;
  9. import java.util.Enumeration;
  10. import javax.accessibility.Accessible;
  11. import javax.accessibility.AccessibleAction;
  12. import javax.accessibility.AccessibleContext;
  13. import javax.accessibility.AccessibleExtendedComponent;
  14. import javax.accessibility.AccessibleIcon;
  15. import javax.accessibility.AccessibleKeyBinding;
  16. import javax.accessibility.AccessibleRelation;
  17. import javax.accessibility.AccessibleRelationSet;
  18. import javax.accessibility.AccessibleState;
  19. import javax.accessibility.AccessibleStateSet;
  20. import javax.accessibility.AccessibleText;
  21. import javax.accessibility.AccessibleValue;
  22. import javax.swing.text.AttributeSet;
  23. import javax.swing.text.BadLocationException;
  24. import javax.swing.text.Document;
  25. import javax.swing.text.Element;
  26. import javax.swing.text.Position;
  27. import javax.swing.text.StyledDocument;
  28. import javax.swing.text.View;
  29. import javax.swing.text.Position.Bias;
  30.  
  31. public abstract class AbstractButton$AccessibleAbstractButton extends JComponent.AccessibleJComponent implements AccessibleAction, AccessibleValue, AccessibleText, AccessibleExtendedComponent {
  32.    // $FF: synthetic field
  33.    final AbstractButton this$0;
  34.  
  35.    protected AbstractButton$AccessibleAbstractButton(AbstractButton var1) {
  36.       super(var1);
  37.       this.this$0 = var1;
  38.    }
  39.  
  40.    public String getAccessibleName() {
  41.       String var1 = this.accessibleName;
  42.       if (var1 == null) {
  43.          var1 = (String)this.this$0.getClientProperty("AccessibleName");
  44.       }
  45.  
  46.       if (var1 == null) {
  47.          var1 = this.this$0.getText();
  48.       }
  49.  
  50.       if (var1 == null) {
  51.          var1 = super.getAccessibleName();
  52.       }
  53.  
  54.       return var1;
  55.    }
  56.  
  57.    public AccessibleIcon[] getAccessibleIcon() {
  58.       Icon var1 = this.this$0.getIcon();
  59.       if (var1 instanceof Accessible) {
  60.          AccessibleContext var2 = ((Accessible)var1).getAccessibleContext();
  61.          if (var2 != null && var2 instanceof AccessibleIcon) {
  62.             return new AccessibleIcon[]{(AccessibleIcon)var2};
  63.          }
  64.       }
  65.  
  66.       return null;
  67.    }
  68.  
  69.    public AccessibleStateSet getAccessibleStateSet() {
  70.       AccessibleStateSet var1 = super.getAccessibleStateSet();
  71.       if (this.this$0.getModel().isArmed()) {
  72.          var1.add(AccessibleState.ARMED);
  73.       }
  74.  
  75.       if (this.this$0.isFocusOwner()) {
  76.          var1.add(AccessibleState.FOCUSED);
  77.       }
  78.  
  79.       if (this.this$0.getModel().isPressed()) {
  80.          var1.add(AccessibleState.PRESSED);
  81.       }
  82.  
  83.       if (this.this$0.isSelected()) {
  84.          var1.add(AccessibleState.CHECKED);
  85.       }
  86.  
  87.       return var1;
  88.    }
  89.  
  90.    public AccessibleRelationSet getAccessibleRelationSet() {
  91.       AccessibleRelationSet var1 = super.getAccessibleRelationSet();
  92.       if (!var1.contains(AccessibleRelation.MEMBER_OF)) {
  93.          ButtonModel var2 = this.this$0.getModel();
  94.          if (var2 != null && var2 instanceof DefaultButtonModel) {
  95.             ButtonGroup var3 = ((DefaultButtonModel)var2).getGroup();
  96.             if (var3 != null) {
  97.                int var4 = var3.getButtonCount();
  98.                Object[] var5 = new Object[var4];
  99.                Enumeration var6 = var3.getElements();
  100.  
  101.                for(int var7 = 0; var7 < var4; ++var7) {
  102.                   if (var6.hasMoreElements()) {
  103.                      var5[var7] = var6.nextElement();
  104.                   }
  105.                }
  106.  
  107.                AccessibleRelation var8 = new AccessibleRelation(AccessibleRelation.MEMBER_OF);
  108.                var8.setTarget(var5);
  109.                var1.add(var8);
  110.             }
  111.          }
  112.       }
  113.  
  114.       return var1;
  115.    }
  116.  
  117.    public AccessibleAction getAccessibleAction() {
  118.       return this;
  119.    }
  120.  
  121.    public AccessibleValue getAccessibleValue() {
  122.       return this;
  123.    }
  124.  
  125.    public int getAccessibleActionCount() {
  126.       return 1;
  127.    }
  128.  
  129.    public String getAccessibleActionDescription(int var1) {
  130.       return var1 == 0 ? UIManager.getString("AbstractButton.clickText") : null;
  131.    }
  132.  
  133.    public boolean doAccessibleAction(int var1) {
  134.       if (var1 == 0) {
  135.          this.this$0.doClick();
  136.          return true;
  137.       } else {
  138.          return false;
  139.       }
  140.    }
  141.  
  142.    public Number getCurrentAccessibleValue() {
  143.       return this.this$0.isSelected() ? new Integer(1) : new Integer(0);
  144.    }
  145.  
  146.    public boolean setCurrentAccessibleValue(Number var1) {
  147.       if (var1 == null) {
  148.          return false;
  149.       } else {
  150.          int var2 = var1.intValue();
  151.          if (var2 == 0) {
  152.             this.this$0.setSelected(false);
  153.          } else {
  154.             this.this$0.setSelected(true);
  155.          }
  156.  
  157.          return true;
  158.       }
  159.    }
  160.  
  161.    public Number getMinimumAccessibleValue() {
  162.       return new Integer(0);
  163.    }
  164.  
  165.    public Number getMaximumAccessibleValue() {
  166.       return new Integer(1);
  167.    }
  168.  
  169.    public AccessibleText getAccessibleText() {
  170.       View var1 = (View)this.this$0.getClientProperty("html");
  171.       return var1 != null ? this : null;
  172.    }
  173.  
  174.    public int getIndexAtPoint(Point var1) {
  175.       View var2 = (View)this.this$0.getClientProperty("html");
  176.       if (var2 != null) {
  177.          Rectangle var3 = this.getTextRectangle();
  178.          if (var3 == null) {
  179.             return -1;
  180.          } else {
  181.             Rectangle2D.Float var4 = new Rectangle2D.Float((float)var3.x, (float)var3.y, (float)var3.width, (float)var3.height);
  182.             Position.Bias[] var5 = new Position.Bias[1];
  183.             return var2.viewToModel((float)var1.x, (float)var1.y, var4, var5);
  184.          }
  185.       } else {
  186.          return -1;
  187.       }
  188.    }
  189.  
  190.    public Rectangle getCharacterBounds(int var1) {
  191.       View var2 = (View)this.this$0.getClientProperty("html");
  192.       if (var2 != null) {
  193.          Rectangle var3 = this.getTextRectangle();
  194.          if (var3 == null) {
  195.             return null;
  196.          } else {
  197.             Rectangle2D.Float var4 = new Rectangle2D.Float((float)var3.x, (float)var3.y, (float)var3.width, (float)var3.height);
  198.  
  199.             try {
  200.                Shape var5 = var2.modelToView(var1, var4, Bias.Forward);
  201.                return var5.getBounds();
  202.             } catch (BadLocationException var6) {
  203.                return null;
  204.             }
  205.          }
  206.       } else {
  207.          return null;
  208.       }
  209.    }
  210.  
  211.    public int getCharCount() {
  212.       View var1 = (View)this.this$0.getClientProperty("html");
  213.       if (var1 != null) {
  214.          Document var2 = var1.getDocument();
  215.          if (var2 instanceof StyledDocument) {
  216.             StyledDocument var3 = (StyledDocument)var2;
  217.             return var3.getLength();
  218.          }
  219.       }
  220.  
  221.       return this.this$0.accessibleContext.getAccessibleName().length();
  222.    }
  223.  
  224.    public int getCaretPosition() {
  225.       return -1;
  226.    }
  227.  
  228.    public String getAtIndex(int var1, int var2) {
  229.       if (var2 >= 0 && var2 < this.getCharCount()) {
  230.          switch (var1) {
  231.             case 1:
  232.                try {
  233.                   return this.getText(var2, 1);
  234.                } catch (BadLocationException var8) {
  235.                   return null;
  236.                }
  237.             case 2:
  238.                try {
  239.                   String var9 = this.getText(0, this.getCharCount());
  240.                   BreakIterator var10 = BreakIterator.getWordInstance(this.getLocale());
  241.                   var10.setText(var9);
  242.                   int var11 = var10.following(var2);
  243.                   return var9.substring(var10.previous(), var11);
  244.                } catch (BadLocationException var7) {
  245.                   return null;
  246.                }
  247.             case 3:
  248.                try {
  249.                   String var3 = this.getText(0, this.getCharCount());
  250.                   BreakIterator var4 = BreakIterator.getSentenceInstance(this.getLocale());
  251.                   var4.setText(var3);
  252.                   int var5 = var4.following(var2);
  253.                   return var3.substring(var4.previous(), var5);
  254.                } catch (BadLocationException var6) {
  255.                   return null;
  256.                }
  257.             default:
  258.                return null;
  259.          }
  260.       } else {
  261.          return null;
  262.       }
  263.    }
  264.  
  265.    public String getAfterIndex(int var1, int var2) {
  266.       if (var2 >= 0 && var2 < this.getCharCount()) {
  267.          switch (var1) {
  268.             case 1:
  269.                if (var2 + 1 >= this.getCharCount()) {
  270.                   return null;
  271.                } else {
  272.                   try {
  273.                      return this.getText(var2 + 1, 1);
  274.                   } catch (BadLocationException var9) {
  275.                      return null;
  276.                   }
  277.                }
  278.             case 2:
  279.                try {
  280.                   String var10 = this.getText(0, this.getCharCount());
  281.                   BreakIterator var11 = BreakIterator.getWordInstance(this.getLocale());
  282.                   var11.setText(var10);
  283.                   int var12 = var11.following(var2);
  284.                   if (var12 != -1 && var12 < var10.length()) {
  285.                      int var13 = var11.following(var12);
  286.                      if (var13 != -1 && var13 < var10.length()) {
  287.                         return var10.substring(var12, var13);
  288.                      }
  289.  
  290.                      return null;
  291.                   }
  292.  
  293.                   return null;
  294.                } catch (BadLocationException var8) {
  295.                   return null;
  296.                }
  297.             case 3:
  298.                try {
  299.                   String var3 = this.getText(0, this.getCharCount());
  300.                   BreakIterator var4 = BreakIterator.getSentenceInstance(this.getLocale());
  301.                   var4.setText(var3);
  302.                   int var5 = var4.following(var2);
  303.                   if (var5 != -1 && var5 <= var3.length()) {
  304.                      int var6 = var4.following(var5);
  305.                      if (var6 != -1 && var6 <= var3.length()) {
  306.                         return var3.substring(var5, var6);
  307.                      }
  308.  
  309.                      return null;
  310.                   }
  311.  
  312.                   return null;
  313.                } catch (BadLocationException var7) {
  314.                   return null;
  315.                }
  316.             default:
  317.                return null;
  318.          }
  319.       } else {
  320.          return null;
  321.       }
  322.    }
  323.  
  324.    public String getBeforeIndex(int var1, int var2) {
  325.       if (var2 >= 0 && var2 <= this.getCharCount() - 1) {
  326.          switch (var1) {
  327.             case 1:
  328.                if (var2 == 0) {
  329.                   return null;
  330.                } else {
  331.                   try {
  332.                      return this.getText(var2 - 1, 1);
  333.                   } catch (BadLocationException var9) {
  334.                      return null;
  335.                   }
  336.                }
  337.             case 2:
  338.                try {
  339.                   String var10 = this.getText(0, this.getCharCount());
  340.                   BreakIterator var11 = BreakIterator.getWordInstance(this.getLocale());
  341.                   var11.setText(var10);
  342.                   var11.following(var2);
  343.                   int var12 = var11.previous();
  344.                   int var13 = var11.previous();
  345.                   if (var13 == -1) {
  346.                      return null;
  347.                   }
  348.  
  349.                   return var10.substring(var13, var12);
  350.                } catch (BadLocationException var8) {
  351.                   return null;
  352.                }
  353.             case 3:
  354.                try {
  355.                   String var3 = this.getText(0, this.getCharCount());
  356.                   BreakIterator var4 = BreakIterator.getSentenceInstance(this.getLocale());
  357.                   var4.setText(var3);
  358.                   var4.following(var2);
  359.                   int var5 = var4.previous();
  360.                   int var6 = var4.previous();
  361.                   if (var6 == -1) {
  362.                      return null;
  363.                   }
  364.  
  365.                   return var3.substring(var6, var5);
  366.                } catch (BadLocationException var7) {
  367.                   return null;
  368.                }
  369.             default:
  370.                return null;
  371.          }
  372.       } else {
  373.          return null;
  374.       }
  375.    }
  376.  
  377.    public AttributeSet getCharacterAttribute(int var1) {
  378.       View var2 = (View)this.this$0.getClientProperty("html");
  379.       if (var2 != null) {
  380.          Document var3 = var2.getDocument();
  381.          if (var3 instanceof StyledDocument) {
  382.             StyledDocument var4 = (StyledDocument)var3;
  383.             Element var5 = var4.getCharacterElement(var1);
  384.             if (var5 != null) {
  385.                return var5.getAttributes();
  386.             }
  387.          }
  388.       }
  389.  
  390.       return null;
  391.    }
  392.  
  393.    public int getSelectionStart() {
  394.       return -1;
  395.    }
  396.  
  397.    public int getSelectionEnd() {
  398.       return -1;
  399.    }
  400.  
  401.    public String getSelectedText() {
  402.       return null;
  403.    }
  404.  
  405.    private String getText(int var1, int var2) throws BadLocationException {
  406.       View var3 = (View)this.this$0.getClientProperty("html");
  407.       if (var3 != null) {
  408.          Document var4 = var3.getDocument();
  409.          if (var4 instanceof StyledDocument) {
  410.             StyledDocument var5 = (StyledDocument)var4;
  411.             return var5.getText(var1, var2);
  412.          }
  413.       }
  414.  
  415.       return null;
  416.    }
  417.  
  418.    private Rectangle getTextRectangle() {
  419.       String var1 = this.this$0.getText();
  420.       Icon var2 = this.this$0.isEnabled() ? this.this$0.getIcon() : this.this$0.getDisabledIcon();
  421.       if (var2 == null && var1 == null) {
  422.          return null;
  423.       } else {
  424.          Rectangle var3 = new Rectangle();
  425.          Rectangle var4 = new Rectangle();
  426.          Rectangle var5 = new Rectangle();
  427.          Insets var6 = new Insets(0, 0, 0, 0);
  428.          var6 = this.this$0.getInsets(var6);
  429.          var5.x = var6.left;
  430.          var5.y = var6.top;
  431.          var5.width = this.this$0.getWidth() - (var6.left + var6.right);
  432.          var5.height = this.this$0.getHeight() - (var6.top + var6.bottom);
  433.          SwingUtilities.layoutCompoundLabel(this.this$0, this.getFontMetrics(this.getFont()), var1, var2, this.this$0.getVerticalAlignment(), this.this$0.getHorizontalAlignment(), this.this$0.getVerticalTextPosition(), this.this$0.getHorizontalTextPosition(), var5, var3, var4, 0);
  434.          return var4;
  435.       }
  436.    }
  437.  
  438.    AccessibleExtendedComponent getAccessibleExtendedComponent() {
  439.       return this;
  440.    }
  441.  
  442.    public String getToolTipText() {
  443.       return this.this$0.getToolTipText();
  444.    }
  445.  
  446.    public String getTitledBorderText() {
  447.       return super.getTitledBorderText();
  448.    }
  449.  
  450.    public AccessibleKeyBinding getAccessibleKeyBinding() {
  451.       int var1 = this.this$0.getMnemonic();
  452.       return var1 == 0 ? null : new AbstractButton.AccessibleAbstractButton.ButtonKeyBinding(this, var1);
  453.    }
  454. }
  455.