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-2016 ForgeRock AS. 016 */ 017package org.opends.guitools.controlpanel.util; 018 019import java.awt.Point; 020import java.util.ArrayList; 021import java.util.List; 022 023import javax.swing.JScrollPane; 024 025/** 026 * A class used to be able to update the scroll position in different panels. 027 * It basically contains two lists of scrollbars and points. 028 */ 029public class ViewPositions 030{ 031 private final List<JScrollPane> scrolls = new ArrayList<>(); 032 private final List<Point> points = new ArrayList<>(); 033 034 /** 035 * Returns the size of the lists. 036 * @return the size of the lists. 037 */ 038 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 void add(JScrollPane scroll, Point p) 049 { 050 scrolls.add(scroll); 051 points.add(p); 052 } 053 054 /** 055 * Returns the point at the provided index. 056 * @param index the index. 057 * @return the point at the provided index. 058 */ 059 Point getPoint(int index) 060 { 061 return points.get(index); 062 } 063 064 /** 065 * Returns the scroll at the provided index. 066 * @param index the index. 067 * @return the scroll at the provided index. 068 */ 069 JScrollPane getScrollPane(int index) 070 { 071 return scrolls.get(index); 072 } 073}