@Override public boolean onUnit(Graphics g,int x,int y,int w,int h){
  FontMetrics fm=g.getFontMetrics();
  int l=(int)(m_x * w) - fm.stringWidth(m_id) / 2;
  int t=(int)(m_y * h) - fm.getHeight() / 2;
  if (x < l || x > l + fm.stringWidth(m_id) + 4 || y < t || y > t + fm.getHeight() + fm.getDescent()+ 4) {
    return false;
  }
  return true;
}

@ Override public boolean onUnit ( Graphics g , int x , int y , int w , int h ) { FontMetrics fm = g . getFontMetrics ( ) ; int l = ( int ) ( m_x * w ) - fm . stringWidth ( m_id ) / 2 ; int t = ( int ) ( m_y * h ) - fm . getHeight ( ) / 2 ; if ( x < l || x > l + fm . stringWidth ( m_id ) + 4 || y < t || y > t + fm . getHeight ( ) + fm . getDescent ( ) + 4 ) { return false ; } return true ; }
call this function to determine if the point at x , y is on the unit .
