Package org.geoforge.guillc.border

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

/*
*  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 2
*  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, _s_write to the Free Software
*  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

package org.geoforge.guillc.border;

import java.awt.BasicStroke;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.Paint;
import java.awt.Stroke;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.logging.Logger;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.border.CompoundBorder;
import org.geoforge.java.awt.color.GfrColor;
import org.geoforge.java.util.logging.filehandler.FileHandlerLogger;
import org.geoforge.wrpbasusr.GfrWrpUsrSpcDspPrtAppRoot;

/**
*
* @author bantchao
*/
public class GfrBorderHelpOnThis extends CompoundBorder implements
        MouseListener
{
   // ----
   // final static

   final static private int _INT_SIZE_ = 4;
  
   final static private Stroke _STK_STROKE_ = new BasicStroke(4.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
           new float[]
           {
              3f
           }, 0f);
  
   final static private Paint _PNT_PAINT_ = (Paint) GfrColor.GRAY_8;
   // ----
   // begin: instantiate logger for this class
   final private static Logger _LOGGER_ = Logger.getLogger(GfrBorderHelpOnThis.class.getName());

   static
   {
      GfrBorderHelpOnThis._LOGGER_.addHandler(FileHandlerLogger.s_getInstance());
   }

   // end: instantiate logger for this class
   // ----
   // ----
   static public void s_set(JPanel pnl)
   {
      GfrBorderHelpOnThis brd = new GfrBorderHelpOnThis(pnl);
      pnl.setBorder(brd);
   }
   // ----
   // end static
   private JPanel _pnlContainer_ = null;

   private GfrBorderHelpOnThis(JPanel pnlContainer)
   {
      super();

      this._pnlContainer_ = pnlContainer;
   }

   @Override
   public Insets getBorderInsets(Component component)
   {
      return new Insets(_INT_SIZE_, _INT_SIZE_, _INT_SIZE_, _INT_SIZE_);
   }

   @Override
   public boolean isBorderOpaque()
   {
      return false;
   }

   @Override
   public void paintBorder(Component component, Graphics g, int i, int j, int k, int l)
   {
      if (!this._blnMouseEntered_)
      {
         super.paintBorder(component, g, i, j, k, l);
         return;
      }

      Graphics2D g2 = (Graphics2D) g;

      Stroke stkOri = g2.getStroke();
      Paint pntOri = g2.getPaint();


      g2.setStroke(_STK_STROKE_);
      g2.setPaint(_PNT_PAINT_);

      g2.drawRoundRect(0, 0, k - 1, l - 1, 5, 5);

      g2.setStroke(stkOri);
      g2.setPaint(pntOri);
   }

   @Override
   public void mouseClicked(MouseEvent e)
   {
   }

   @Override
   public void mousePressed(MouseEvent e)
   {
   }

   @Override
   public void mouseReleased(MouseEvent e)
   {
   }
   private boolean _blnMouseEntered_ = false;

   @Override
   public void mouseEntered(MouseEvent e)
   {
      try
      {
         if (!GfrWrpUsrSpcDspPrtAppRoot.getInstance().isEnabledVisualEffectsBorderSection())
            return;
      }
     
      catch (Exception exc)
      {
         exc.printStackTrace();
         String str = exc.getMessage();
         GfrBorderHelpOnThis._LOGGER_.warning(str);
         return;
      }

      if (e.getSource() instanceof JButton)
      {
         JButton btn = (JButton) e.getSource();

         if (!btn.isEnabled())
            return;

         this._blnMouseEntered_ = true;
         this._pnlContainer_.invalidate();
         this._pnlContainer_.repaint();
      }
   }

   @Override
   public void mouseExited(MouseEvent e)
   {
      try
      {
         if (!GfrWrpUsrSpcDspPrtAppRoot.getInstance().isEnabledVisualEffectsBorderSection())
            return;

      }
     
      catch (Exception exc)
      {
         exc.printStackTrace();
         String str = exc.getMessage();
         GfrBorderHelpOnThis._LOGGER_.warning(str);
         return;
      }

      if (e.getSource() instanceof JButton)
      {
         JButton btn = (JButton) e.getSource();

         if (!btn.isEnabled())
            return;

         this._blnMouseEntered_ = false;
         this._pnlContainer_.invalidate();
         this._pnlContainer_.repaint();
      }
   }
}
TOP

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

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.