/[classpath]/classpath/javax/swing/JLayeredPane.java
ViewVC logotype

Diff of /classpath/javax/swing/JLayeredPane.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.15 by mkoch, Fri Oct 22 12:43:59 2004 UTC revision 1.16 by mkoch, Wed Dec 1 13:28:05 2004 UTC
# Line 89  import javax.accessibility.Accessible; Line 89  import javax.accessibility.Accessible;
89   * <p><b>Note:</b> the layer numbering order is the <em>reverse</em> of the   * <p><b>Note:</b> the layer numbering order is the <em>reverse</em> of the
90   * component indexing and position order</p>   * component indexing and position order</p>
91   *   *
92   * @author Graydon Hoare <graydon@redhat.com>   * @author Graydon Hoare (graydon@redhat.com)
93   */   */
94  public class JLayeredPane extends JComponent implements Accessible  public class JLayeredPane extends JComponent implements Accessible
95  {  {
# Line 122  public class JLayeredPane extends JCompo Line 122  public class JLayeredPane extends JCompo
122     * @return the layer the component is currently assigned to, in this container.     * @return the layer the component is currently assigned to, in this container.
123     * @throws IllegalArgumentException if the component is not a child of this container.     * @throws IllegalArgumentException if the component is not a child of this container.
124     */     */
   
125    protected Integer getLayer (Component c)    protected Integer getLayer (Component c)
126    {    {
127      if (! componentToLayer.containsKey (c))      if (! componentToLayer.containsKey (c))
# Line 144  public class JLayeredPane extends JCompo Line 143  public class JLayeredPane extends JCompo
143     * @throws IllegalArgumentException if layer does not refer to an active layer     * @throws IllegalArgumentException if layer does not refer to an active layer
144     * in this container.     * in this container.
145     */     */
   
146    protected int[] layerToRange (Integer layer)    protected int[] layerToRange (Integer layer)
147    {    {
148      int[] ret = new int[2];      int[] ret = new int[2];
# Line 175  public class JLayeredPane extends JCompo Line 173  public class JLayeredPane extends JCompo
173     * @param layer the layer number to increment.     * @param layer the layer number to increment.
174     * @see #incrLayer()     * @see #incrLayer()
175     */     */
   
176    protected void incrLayer(Integer layer)    protected void incrLayer(Integer layer)
177    {    {
178      int sz = 1;      int sz = 1;
# Line 190  public class JLayeredPane extends JCompo Line 187  public class JLayeredPane extends JCompo
187     * @param layer the layer number to decrement.     * @param layer the layer number to decrement.
188     * @see #decrLayer()     * @see #decrLayer()
189     */     */
   
190    protected void decrLayer(Integer layer)    protected void decrLayer(Integer layer)
191    {    {
192      int sz = 0;      int sz = 0;
# Line 206  public class JLayeredPane extends JCompo Line 202  public class JLayeredPane extends JCompo
202     * @return the least layer number.     * @return the least layer number.
203     * @see #lowestLayer()     * @see #lowestLayer()
204     */     */
   
205    public int highestLayer()    public int highestLayer()
206    {    {
207      if (layers.size() == 0)      if (layers.size() == 0)
# Line 221  public class JLayeredPane extends JCompo Line 216  public class JLayeredPane extends JCompo
216     * @return the least layer number.     * @return the least layer number.
217     * @see #highestLayer()     * @see #highestLayer()
218     */     */
       
219    public int lowestLayer()    public int lowestLayer()
220    {    {
221      if (layers.size() == 0)      if (layers.size() == 0)
# Line 240  public class JLayeredPane extends JCompo Line 234  public class JLayeredPane extends JCompo
234     * this container.     * this container.
235     * @see #moveToBack()     * @see #moveToBack()
236     */     */
   
237    public void moveToFront(Component c)    public void moveToFront(Component c)
238    {    {
239      setPosition (c, 0);      setPosition (c, 0);
# Line 260  public class JLayeredPane extends JCompo Line 253  public class JLayeredPane extends JCompo
253     * this container.     * this container.
254     * @see #moveToFront()     * @see #moveToFront()
255     */     */
   
256    public void moveToBack(Component c)    public void moveToBack(Component c)
257    {    {
258      setPosition (c, -1);      setPosition (c, -1);
# Line 276  public class JLayeredPane extends JCompo Line 268  public class JLayeredPane extends JCompo
268     * this container.     * this container.
269     * @see #setPosition()     * @see #setPosition()
270     */     */
       
271    public int getPosition(Component c)    public int getPosition(Component c)
272    {    {
273      Integer layer = getLayer (c);      Integer layer = getLayer (c);
# Line 304  public class JLayeredPane extends JCompo Line 295  public class JLayeredPane extends JCompo
295     * this container.     * this container.
296     * @see #getPosition()     * @see #getPosition()
297     */     */
   
298    public void setPosition(Component c, int position)    public void setPosition(Component c, int position)
299    {    {
300      Integer layer = getLayer (c);      Integer layer = getLayer (c);
301      int[] range = layerToRange (layer);      int[] range = layerToRange (layer);
302      if (range[0] == range[1])      if (range[0] == range[1])
303              throw new IllegalArgumentException ();        throw new IllegalArgumentException ();
304    
305      int top = range[0];      int top = range[0];
306      int bot = range[1];      int bot = range[1];
307      if (position == -1)      if (position == -1)
308              position = (bot - top) - 1;        position = (bot - top) - 1;
309      int targ = Math.min(top + position, bot-1);      int targ = Math.min(top + position, bot-1);
310      int curr = -1;      int curr = -1;
311    
312      Component[] comps = getComponents();      Component[] comps = getComponents();
313      for (int i = top; i < bot; ++i)      for (int i = top; i < bot; ++i)
314              {        {
315          if (comps[i] == c)          if (comps[i] == c)
316            {            {
317              curr = i;              curr = i;
318              break;              break;
319            }            }
320              }        }
321      if (curr == -1)      if (curr == -1)
322              // should have found it        // should have found it
323              throw new IllegalArgumentException ();        throw new IllegalArgumentException();
324    
325      super.swapComponents (curr, targ);      super.swapComponents (curr, targ);
326      revalidate();      revalidate();
# Line 345  public class JLayeredPane extends JCompo Line 335  public class JLayeredPane extends JCompo
335     * @param layer the layer to return components from.     * @param layer the layer to return components from.
336     * @return the components in the layer.     * @return the components in the layer.
337     */     */
   
338    public Component[] getComponentsInLayer(int layer)    public Component[] getComponentsInLayer(int layer)
339    {    {
340      int[] range = layerToRange (getObjectForLayer (layer));      int[] range = layerToRange (getObjectForLayer (layer));
# Line 369  public class JLayeredPane extends JCompo Line 358  public class JLayeredPane extends JCompo
358     * @param layer the layer count components in.     * @param layer the layer count components in.
359     * @return the number of components in the layer.     * @return the number of components in the layer.
360     */     */
   
361    public int getComponentCountInLayer(int layer)    public int getComponentCountInLayer(int layer)
362    {    {
363      int[] range = layerToRange (getObjectForLayer (layer));      int[] range = layerToRange (getObjectForLayer (layer));
# Line 383  public class JLayeredPane extends JCompo Line 371  public class JLayeredPane extends JCompo
371     * Return a hashtable mapping child components of this container to     * Return a hashtable mapping child components of this container to
372     * Integer objects representing the component's layer assignments.     * Integer objects representing the component's layer assignments.
373     */     */
   
374    protected Hashtable getComponentToLayer()    protected Hashtable getComponentToLayer()
375    {    {
376      return componentToLayer;      return componentToLayer;
# Line 400  public class JLayeredPane extends JCompo Line 387  public class JLayeredPane extends JCompo
387     * @throws IllegalArgumentException if the component is not a child of     * @throws IllegalArgumentException if the component is not a child of
388     * this container.     * this container.
389     */     */
   
390    public int getIndexOf(Component c)    public int getIndexOf(Component c)
391    {    {
392      Integer layer = getLayer (c);      Integer layer = getLayer (c);
# Line 423  public class JLayeredPane extends JCompo Line 409  public class JLayeredPane extends JCompo
409     * @param layer the layer number as an int.     * @param layer the layer number as an int.
410     * @return the layer number as an Integer, possibly shared.     * @return the layer number as an Integer, possibly shared.
411     */     */
   
412    protected Integer getObjectForLayer(int layer)    protected Integer getObjectForLayer(int layer)
413    {    {
414      switch (layer)      switch (layer)
# Line 462  public class JLayeredPane extends JCompo Line 447  public class JLayeredPane extends JCompo
447     * @param position the position in the layer at which to insert a component.     * @param position the position in the layer at which to insert a component.
448     * @return the index at which to insert the component.     * @return the index at which to insert the component.
449     */     */
       
450    protected int insertIndexForLayer(int layer, int position)    protected int insertIndexForLayer(int layer, int position)
451    {    {
452    
# Line 488  public class JLayeredPane extends JCompo Line 472  public class JLayeredPane extends JCompo
472     *     *
473     * @param index the index of the child component to remove.     * @param index the index of the child component to remove.
474     */     */
       
475    public void remove (int index)    public void remove (int index)
476    {    {
477      Component c = getComponent (index);      Component c = getComponent (index);
# Line 506  public class JLayeredPane extends JCompo Line 489  public class JLayeredPane extends JCompo
489     *     *
490     * @param comp the child to remove.     * @param comp the child to remove.
491     */     */
           
492    public void remove (Component comp)    public void remove (Component comp)
493    {    {
494      remove (getIndexOf (comp));      remove (getIndexOf (comp));
# Line 523  public class JLayeredPane extends JCompo Line 505  public class JLayeredPane extends JCompo
505     * @param c the component to set the layer property for.     * @param c the component to set the layer property for.
506     * @param layer the layer number to assign to the component.     * @param layer the layer number to assign to the component.
507     */     */
   
508    public void setLayer(Component c, int layer)    public void setLayer(Component c, int layer)
509    {    {
510      componentToLayer.put (c, getObjectForLayer (layer));      componentToLayer.put (c, getObjectForLayer (layer));
# Line 536  public class JLayeredPane extends JCompo Line 517  public class JLayeredPane extends JCompo
517     * @param layer the layer number to assign to the component.     * @param layer the layer number to assign to the component.
518     * @param position the position number to assign to the component.     * @param position the position number to assign to the component.
519     */     */
   
520    public void setLayer(Component c,    public void setLayer(Component c,
521                         int layer,                         int layer,
522                         int position)                         int position)
# Line 558  public class JLayeredPane extends JCompo Line 538  public class JLayeredPane extends JCompo
538     * @param layerConstraint an integer specifying the layer to add the component to.     * @param layerConstraint an integer specifying the layer to add the component to.
539     * @param index an ignored parameter, for compatibility.     * @param index an ignored parameter, for compatibility.
540     */     */
   
541    protected void addImpl(Component comp, Object layerConstraint, int index)    protected void addImpl(Component comp, Object layerConstraint, int index)
542    {                {            
543      Integer layer;      Integer layer;

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26