Package org.geoforge.guillc.border

Source Code of org.geoforge.guillc.border.GfrBorderRounded

/*
*  Copyright (C) 2011-2014 GeoForge Project
*
*  This program is free software: you can redistribute it and/or modify
*  it under the terms of the GNU Lesser General Public License as published by
*  the Free Software Foundation, either version 3 of the License, or
*  (at your option) any later version.
*
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU Lesser General Public License for more details.
*
*  You should have received a copy of the GNU Lesser General Public License
*  along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

package org.geoforge.guillc.border;

import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.io.Serializable;
import javax.swing.border.Border;
import org.geoforge.awt.graphics2d.GfrUtilGraphics2D;

/**
*
* @author Amadeus.Sowerby
*
* email: Amadeus.Sowerby_AT_gmail.com
* ... please remove "_AT_" from the above string to get the right email address
*/
public class GfrBorderRounded extends Object implements Border, Serializable
{

   private int _intThciknessleft_ = 0;
   private int _right_ = 0;
   private int _top_ = 0;
   private int _bottom_ = 0;
   private Color _color_;
   private int _widthRadius_;
   private int _heightRadius_;
  
  
   public GfrBorderRounded(
           Color color,
           int widthRadius,
           int heightRadius,
           int intThicknessTop,
           int intThicknessLeft,
           int intThicknessBottom,
           int intThicknessRight)
   {
      super();
     
     
      this._color_ = color;
      this._widthRadius_ = widthRadius;
      this._heightRadius_ = heightRadius;
      this._intThciknessleft_ = intThicknessLeft;
      this._right_ = intThicknessRight;
      this._top_ = intThicknessTop;
      this._bottom_ = intThicknessBottom;
   }

   public GfrBorderRounded(
           Color colBorder,
           int intWidthRadius,
           int intHeightRadius,
           int intThickness)
   {
     
      this(
            colBorder,
            intWidthRadius,
            intHeightRadius,
            intThickness,
            intThickness,
            intThickness,
            intThickness);
     
   }

   @Override
   public void paintBorder(Component c, Graphics g, int x, int y, int width, int height)
   {
      g.setColor(this._color_);
      int adjustXY = 1;
      int adjustWH = 2;
      Graphics2D g2d = (Graphics2D) g;
     
      GfrUtilGraphics2D.s_setRenderingAntiAliasOn(g2d);

      g2d.drawRoundRect(
              x + adjustXY,
              y + adjustXY,
              width - adjustWH,
              height - adjustWH - 1,
              this._widthRadius_+1,
              this._heightRadius_+1);
     
      /*
      g2.drawRoundRect(
              x + adjustXY+1,
              y + adjustXY+1,
              width - adjustWH-2,
              height - adjustWH-2,
              this._widthRadius_-1,
              this._heightRadius_-1);*/
   }

   public Insets getBorderInsets(Component c, Insets insets)
   {
      insets.top = this._top_;
      insets.left = this._intThciknessleft_;
      insets.bottom = this._bottom_;
      insets.right = this._right_;

      return insets;
   }

   @Override
   public Insets getBorderInsets(Component c)
   {
      return new Insets(_top_, _intThciknessleft_, _bottom_, _right_);
   }

   @Override
   public boolean isBorderOpaque()
   {
      return true;
   }
}
TOP

Related Classes of org.geoforge.guillc.border.GfrBorderRounded

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.