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