001/*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License").  You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
010 * or http://forgerock.org/license/CDDLv1.0.html.
011 * See the License for the specific language governing permissions
012 * and limitations under the License.
013 *
014 * When distributing Covered Code, include this CDDL HEADER in each
015 * file and include the License file at legal-notices/CDDLv1_0.txt.
016 * If applicable, add the following below this CDDL HEADER, with the
017 * fields enclosed by brackets "[]" replaced with your own identifying
018 * information:
019 *      Portions Copyright [yyyy] [name of copyright owner]
020 *
021 * CDDL HEADER END
022 *
023 *
024 *      Copyright 2009 Sun Microsystems, Inc.
025 *      Portions Copyright 2015 ForgeRock AS.
026 */
027package org.opends.guitools.controlpanel.util;
028
029import java.awt.Point;
030import java.util.ArrayList;
031
032import javax.swing.JScrollPane;
033
034/**
035 * A class used to be able to update the scroll position in different panels.
036 * It basically contains two lists of scrollbars and points.
037 *
038 */
039public class ViewPositions
040{
041  private ArrayList<JScrollPane> scrolls = new ArrayList<>();
042  private ArrayList<Point> points = new ArrayList<>();
043
044  /**
045   * Returns the size of the lists.
046   * @return the size of the lists.
047   */
048  public int size()
049  {
050    return scrolls.size();
051  }
052
053  /**
054   * Adds a pair of scrollbar and point to the list.
055   * @param scroll the scroll bar.
056   * @param p the point.
057   */
058  public void add(JScrollPane scroll, Point p)
059  {
060    scrolls.add(scroll);
061    points.add(p);
062  }
063
064  /**
065   * Clears the contents of both lists.
066   *
067   */
068  public void clear()
069  {
070    scrolls.clear();
071    points.clear();
072  }
073
074  /**
075   * Returns the point at the provided index.
076   * @param index the index.
077   * @return the point at the provided index.
078   */
079  public Point getPoint(int index)
080  {
081    return points.get(index);
082  }
083
084  /**
085   * Returns the scroll at the provided index.
086   * @param index the index.
087   * @return the scroll at the provided index.
088   */
089  public JScrollPane getScrollPane(int index)
090  {
091    return scrolls.get(index);
092  }
093}