All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.tidalwave.netbeans.lookandfeel.impl.ExplorerPanelBorder Maven / Gradle / Ivy

The newest version!
/***********************************************************************************************************************
 *
 * SolidBlue - open source safe data
 * Copyright (C) 2011-2011 by Tidalwave s.a.s. (http://www.tidalwave.it)
 *
 ***********************************************************************************************************************
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations under the License.
 *
 ***********************************************************************************************************************
 *
 * WWW: http://solidblue.java.net
 * SCM: https://bitbucket.org/tidalwave/solidblue-src
 *
 **********************************************************************************************************************/
package it.tidalwave.netbeans.lookandfeel.impl;

import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Insets;
import javax.swing.border.Border;
import it.tidalwave.netbeans.lookandfeel.DimmableColor;

/*******************************************************************************
 * 
 *
 * @author  Fabrizio Giudici
 * @version $Id$
 *
 ******************************************************************************/
public class ExplorerPanelBorder implements Border
  {
    private final static Color COLOR_BASE = new DimmableColor(41, 41, 41);
    private final static Color[] COLOR = 
      {
        new DimmableColor(41, 41, 41),
        new DimmableColor(66, 66, 66),
        new DimmableColor(72, 72, 72),
        new DimmableColor(80, 80, 80),
      };
            
    public void paintBorder (Component c, Graphics g, int x, int y, int width, int height)
      {
        g.setColor(Color.BLACK);
        g.drawLine(x, y, x + width - 1, y);
        g.drawRect(x, y + 1, 2, height - 4);
//        g.drawLine(x, y + height - 1, x + width - 1, y + height - 1);
//        g.drawRect(x + 2, y + height - 4, width - 1, 2);
//        g.drawRect(x + width - 3, y, 2, height - 1);
//        g.setColor(new Color(68, 68, 68));
//        g.drawLine(x + width - 1, y + 1, x + width - 1, y + height - 1);
//        g.drawLine(x + 1, y + height - 1, x + width - 1, y + height - 1);
        
        int colorBase = COLOR_BASE.getGreen(); // brightness
        Color b = c.getBackground();
        int colorTarget = (int)(Color.RGBtoHSB(b.getRed(), b.getGreen(), b.getBlue(), null)[2] * 255);
        
        for (int i = 0; i < 4; i++)
          {
            int color = colorBase + (i * (colorTarget - colorBase) / 4);
            g.setColor(new Color(color, color, color));
            g.drawLine(x + i, y + 1 + i, x + width - 1, y + 1 + i);
            g.drawLine(x + i, y + 1 + i, x + i, y + height - 1);
          }
      }

    public Insets getBorderInsets (Component c)
      {
        return new Insets(5, 4, 0, 0);
      }

    public boolean isBorderOpaque()
      {
        return true;
      }
  }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy