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 2008 Sun Microsystems, Inc.
025 *      Portions Copyright 2015 ForgeRock AS.
026 */
027
028package org.opends.guitools.controlpanel.ui.border;
029
030import java.awt.Component;
031import java.awt.Graphics;
032import java.awt.Insets;
033
034import javax.swing.border.Border;
035
036import org.opends.guitools.controlpanel.ui.ColorAndFontConstants;
037
038/** The border specific to the accordion element. */
039public class AccordionElementBorder implements Border
040{
041  private Insets insets = new Insets(1, 1, 1, 1);
042
043  /** Default constructor. */
044  public AccordionElementBorder() {
045  }
046
047  /** {@inheritDoc} */
048  public Insets getBorderInsets(Component c) {
049    return insets;
050  }
051
052  /** {@inheritDoc} */
053  public boolean isBorderOpaque() {
054    return true;
055  }
056
057  /** {@inheritDoc} */
058  public void paintBorder(Component c, Graphics g, int x, int y, int width,
059      int height) {
060    g.setColor(ColorAndFontConstants.topAccordionBorderColor);
061    // render highlight at top
062    g.drawLine(x, y, x + width - 1, y);
063    // render left
064    g.drawLine(x, y, x, y + height - 1);
065    // render right
066    g.drawLine(x + width - 1, y, x + width - 1, y + height - 1);
067    // render shadow on bottom
068    g.setColor(ColorAndFontConstants.defaultBorderColor);
069    g.drawLine(x, y + height - 1, x + width - 1, y + height - 1);
070  }
071}